本文整理匯總了C#中Server.Mobile.CanBeHarmful方法的典型用法代碼示例。如果您正苦於以下問題:C# Mobile.CanBeHarmful方法的具體用法?C# Mobile.CanBeHarmful怎麽用?C# Mobile.CanBeHarmful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Server.Mobile
的用法示例。
在下文中一共展示了Mobile.CanBeHarmful方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Effect
public static void Effect( Mobile attacker, Mobile defender, int featlevel )
{
IKhaerosMobile featuser = attacker as IKhaerosMobile;
ArrayList list = new ArrayList();
foreach( Mobile m in defender.GetMobilesInRange( featlevel + 2 ) )
{
if( m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee( m ) || !attacker.CanBeHarmful( m ) || featuser.IsAllyOf( m ) )
continue;
if( !attacker.InRange( m, ((BaseWeapon)attacker.Weapon).MaxRange ) )
continue;
if( m != attacker && Spells.SpellHelper.ValidIndirectTarget( attacker, m ) )
{
if( attacker.InLOS( m ) )
list.Add( m );
}
}
for( int i = 0; i < Math.Min( list.Count, featlevel + 1 ); ++i )
{
int random = Utility.Random( list.Count );
Mobile m = (Mobile)list[random];
featuser.CleaveAttack = true;
((BaseWeapon)attacker.Weapon).OnSwing( attacker, m, 0.5, true );
}
}
示例2: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
from.RevealingAction();
if ( targeted is BaseCreature && from.CanBeHarmful( (Mobile) targeted, true ) )
{
BaseCreature creature = (BaseCreature) targeted;
if ( !m_Instrument.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1062488 ); // The instrument you are trying to play is no longer in your backpack!
}
else if ( creature.Controlled )
{
from.SendLocalizedMessage( 501590 ); // They are too loyal to their master to be provoked.
}
else if ( creature.IsParagon && BaseInstrument.GetBaseDifficulty( creature ) >= 160.0 )
{
from.SendLocalizedMessage( 1049446 ); // You have no chance of provoking those creatures.
}
else
{
from.RevealingAction();
m_Instrument.PlayInstrumentWell( from );
from.SendLocalizedMessage( 1008085 ); // You play your music and your target becomes angered. Whom do you wish them to attack?
from.Target = new InternalSecondTarget( from, m_Instrument, creature );
}
}
else
{
from.SendLocalizedMessage( 501589 ); // You can't incite that!
}
}
示例3: CheckSnoopAllowed
public static bool CheckSnoopAllowed( Mobile from, Mobile to )
{
Map map = from.Map;
if ( to.Player && !to.Hidden )
return from.CanBeHarmful( to, false, true ); // normal restrictions
return false;
}
示例4: OnHit
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
if ( !Validate( attacker ) )
return;
ClearCurrentAbility( attacker );
Map map = attacker.Map;
if ( map == null )
return;
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
if ( weapon == null )
return;
if ( !CheckMana( attacker, true ) )
return;
attacker.FixedEffect( 0x3728, 10, 15 );
attacker.PlaySound( 0x2A1 );
ArrayList list = new ArrayList();
foreach ( Mobile m in attacker.GetMobilesInRange( 1 ) )
list.Add( m );
Party p = Party.Get( attacker );
for ( int i = 0; i < list.Count; ++i )
{
Mobile m = (Mobile)list[i];
if (m != defender && m != attacker &&
SpellHelper.ValidIndirectTarget(attacker, m) &&
attacker.CanBeHarmful(m, false) &&
(p == null || !p.Contains(m)))
{
if ( m == null || m.Deleted || attacker.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.Alive || !attacker.CanSee( m ) )
continue;
if ( !attacker.InRange( m, weapon.MaxRange ) )
continue;
if ( attacker.InLOS( m ) )
{
attacker.RevealingAction();
attacker.SendLocalizedMessage( 1060161 ); // The whirling attack strikes a target!
m.SendLocalizedMessage( 1060162 ); // You are struck by the whirling attack and take damage!
weapon.OnHit( attacker, m );
}
}
}
}
示例5: OnTarget
protected override void OnTarget( Mobile from, object obj )
{
if ( m_BaseThrowingItem.Deleted || m_BaseThrowingItem.Map == Map.Internal)
return;
if ( obj is Mobile )
{
Mobile to = (Mobile)obj;
if ( !from.CanBeHarmful( to ) )
{
}
else
{ from.Direction = from.GetDirectionTo( to );
from.Animate( 11, 5, 1, true, false, 0 );
from.MovingEffect( to, m_BaseThrowingItem.ItemID, 10, 0, false, false );
Timer.DelayCall<ThrowInfo>( TimeSpan.FromSeconds( 0.5 ), new TimerStateCallback<ThrowInfo>( FinishThrow ), new ThrowInfo( from, to, m_DamageMin, m_DamageMax, m_Break, m_BaseThrowingItem ) );
if ( m_DeleteOnThrow || m_Break )
m_BaseThrowingItem.Delete();
}
}
else
{
IPoint3D p = obj as IPoint3D;
if ( p == null )
return;
Map map = from.Map;
if ( map == null )
return;
IEntity to;
to = new Entity( Serial.Zero, new Point3D( p ), map );
from.Direction = from.GetDirectionTo( to );
Effects.SendMovingEffect( from, to, m_BaseThrowingItem.ItemID & 0x3FFF, 7, 0, false, false, m_BaseThrowingItem.Hue, 0 );
from.Animate( 11, 5, 1, true, false, 0 );
if ( m_DeleteOnThrow )
{
m_BaseThrowingItem.Delete();
from.SendMessage( "You miss the target and the {0} is wasted", m_BaseThrowingItem.Name );
}
else
{
Timer.DelayCall<object[]>( TimeSpan.FromSeconds( 0.5 ), new TimerStateCallback<object[]>( FinishMiss ), new object[]{ to, map, m_BaseThrowingItem } );
from.SendMessage( "You miss the target" );
}
}
}
示例6: OnHit
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
if ( !Validate( attacker ) || !CheckMana( attacker, true ) )
return;
ClearCurrentAbility( attacker );
Map map = attacker.Map;
if ( map != null )
{
defender.PlaySound( 0x5BF );
ArrayList targets = new ArrayList();
foreach ( Mobile m in defender.GetMobilesInRange( 5 ) )
{
if ( SpellHelper.ValidIndirectTarget( attacker, m ) && attacker.CanBeHarmful( m, false ) && defender.InLOS( m ) && defender.CanSee( m ) )
targets.Add( m );
}
double dm;
for ( int i = 0; i < targets.Count; ++i )
{
Mobile m = (Mobile) targets[i];
if ( attacker.CanBeHarmful( m ) && attacker != m )
{
attacker.DoHarmful( m );
Effects.SendBoltEffect( m, false, 0 );
// TODO: Revisar formula del daño
dm = Utility.RandomMinMax( 25, 30 );
SpellHelper.Damage( TimeSpan.Zero, m, attacker, dm, 0, 0, 0, 0, 100 );
}
}
}
}
示例7: CheckSnoopAllowed
public static bool CheckSnoopAllowed( Mobile from, Mobile to )
{
Map map = from.Map;
if ( to.Player )
return from.CanBeHarmful( to, false, true ); // normal restrictions
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
return true; // felucca you can snoop anybody
GuardedRegion reg = (GuardedRegion) to.Region.GetRegion( typeof( GuardedRegion ) );
if ( reg == null || reg.IsDisabled() )
return true; // not in town? we can snoop any npc
BaseCreature cret = to as BaseCreature;
if ( to.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
return false; // in town we cannot snoop blue human npcs
return true;
}
示例8: ValidIndirectTarget
public static bool ValidIndirectTarget( Mobile from, Mobile to )
{
if( from == to )
return true;
if( to.Hidden && to.AccessLevel > from.AccessLevel )
return false;
Guild fromGuild = GetGuildFor( from );
Guild toGuild = GetGuildFor( to );
if( fromGuild != null && toGuild != null && (fromGuild == toGuild || fromGuild.IsAlly( toGuild )) )
return false;
Party p = Party.Get( from );
if( p != null && p.Contains( to ) )
return false;
if( to is BaseCreature )
{
BaseCreature c = (BaseCreature)to;
if( c.Controlled || c.Summoned )
{
if( c.ControlMaster == from || c.SummonMaster == from )
return false;
if( p != null && (p.Contains( c.ControlMaster ) || p.Contains( c.SummonMaster )) )
return false;
}
}
if( from is BaseCreature )
{
BaseCreature c = (BaseCreature)from;
if( c.Controlled || c.Summoned )
{
if( c.ControlMaster == to || c.SummonMaster == to )
return false;
p = Party.Get( to );
if( p != null && (p.Contains( c.ControlMaster ) || p.Contains( c.SummonMaster )) )
return false;
}
if( to is BaseCreature )
{
BaseCreature tc = (BaseCreature) to;
Mobile master = tc.GetMaster();
if( master != null && master != from && !ValidIndirectTarget( from, master ) )
return false;
if( !c.IsEnemy( tc ) )
return false;
}
return from.CanBeHarmful( to );
}
if( to is BaseCreature && !((BaseCreature)to).Controlled && ((BaseCreature)to).InitialInnocent )
return true;
int noto = Notoriety.Compute( from, to );
return (noto != Notoriety.Innocent || from.Kills >= 5);
}
示例9: OnHit
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
if( !Validate( attacker ) ) //Mana check after check that there are targets
return;
ClearCurrentAbility( attacker );
Map map = attacker.Map;
if( map == null )
return;
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
if( weapon == null )
return;
ArrayList list = new ArrayList();
foreach( Mobile m in attacker.GetMobilesInRange( 1 ) )
list.Add( m );
ArrayList targets = new ArrayList();
for( int i = 0; i < list.Count; ++i )
{
Mobile m = (Mobile)list[i];
if( m != defender && m != attacker && SpellHelper.ValidIndirectTarget( attacker, m ) )
{
if( m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee( m ) || !attacker.CanBeHarmful( m ) )
continue;
if( !attacker.InRange( m, weapon.MaxRange ) )
continue;
if( attacker.InLOS( m ) )
targets.Add( m );
}
}
if( targets.Count > 0 )
{
if( !CheckMana( attacker, true ) )
return;
attacker.FixedEffect( 0x3728, 10, 15 );
attacker.PlaySound( 0x2A1 );
// 5-15 damage
int amount = (int)(10.0 * ((Math.Max( attacker.Skills[SkillName.Bushido].Value, attacker.Skills[SkillName.Ninjitsu].Value ) - 50.0) / 70.0 + 5));
for( int i = 0; i < targets.Count; ++i )
{
Mobile m = (Mobile)targets[i];
attacker.DoHarmful( m, true );
Timer t = Registry[m] as Timer;
if( t != null )
{
t.Stop();
Registry.Remove( m );
}
t = new InternalTimer( attacker, m, amount );
t.Start();
Registry.Add( m, t );
}
Timer.DelayCall( TimeSpan.FromSeconds( 2.0 ), new TimerStateCallback( RepeatEffect ), attacker );
}
}
示例10: OnHit
public override void OnHit( Mobile attacker, Mobile defender, int damage )
{
if ( !Validate( attacker ) )
return;
ClearCurrentAbility( attacker );
Map map = attacker.Map;
if ( map == null )
return;
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
if ( weapon == null )
return;
if ( !CheckMana( attacker, true ) )
return;
attacker.FixedEffect( 0x3728, 10, 15 );
attacker.PlaySound( 0x2A1 );
ArrayList list = new ArrayList();
foreach ( Mobile m in attacker.GetMobilesInRange( 1 ) )
list.Add( m );
ArrayList targets = new ArrayList();
for ( int i = 0; i < list.Count; ++i )
{
Mobile m = (Mobile)list[i];
if ( m != defender && m != attacker && SpellHelper.ValidIndirectTarget( attacker, m ) )
{
if ( m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee( m ) || !attacker.CanBeHarmful( m ) )
continue;
if ( !attacker.InRange( m, weapon.MaxRange ) )
continue;
if ( attacker.InLOS( m ) )
targets.Add( m );
}
}
if ( targets.Count > 0 )
{
double bushido = attacker.Skills.Bushido.Value;
double damageBonus = 1.0 + Math.Pow( (targets.Count * bushido) / 60, 2 ) / 100;
if ( damageBonus > 2.0 )
damageBonus = 2.0;
attacker.RevealingAction();
for ( int i = 0; i < targets.Count; ++i )
{
Mobile m = (Mobile)targets[i];
attacker.SendLocalizedMessage( 1060161 ); // The whirling attack strikes a target!
m.SendLocalizedMessage( 1060162 ); // You are struck by the whirling attack and take damage!
weapon.OnHit( attacker, m, damageBonus );
}
}
}
示例11: Explode
public void Explode( Mobile from, Point3D loc, Map map )
{
if ( map == null )
return;
Effects.PlaySound( loc, map, 0x207 );
Effects.SendLocationEffect( loc, map, 0x36BD, 20 );
IPooledEnumerable eable = map.GetObjectsInRange( loc, 2 ) ;
ArrayList toExplode = new ArrayList();
int toDamage = 0;
foreach ( object o in eable )
{
if ( o is Mobile )
{
toExplode.Add( o );
++toDamage;
}
else if ( o is BaseExplosionPotion && o != this )
{
toExplode.Add( o );
}
else if ( o is ICannonDamage )
{
toExplode.Add( o );
}
}
eable.Free();
int d = 0; // Damage scalar
int damage = 0;
for ( int i = 0; i < toExplode.Count; ++i )
{
object o;
o = toExplode[i];
if ( o is Mobile )
{
Mobile m = (Mobile)o;
if ( m.InRange( loc, 0 ) )
d = 1;
else if ( m.InRange( loc, 1 ) )
d = 2;
else if ( m.InRange( loc, 2 ) )
d = 3;
if ( from != null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
{
if ( from != null )
from.DoHarmful( m );
damage = Utility.RandomMinMax( (MinDamage / d), (MaxDamage / d) );
if( d == 1 )
AOS.Damage( m, from, damage, 50, 50, 0, 0, 0 ); // Same tile 50% physical 50% fire
else
AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 ); // 2 tile radius 100% fire damage
}
}
else if ( o is BaseExplosionPotion )
{
BaseExplosionPotion pot = (BaseExplosionPotion)o;
pot.Explode( from, true, pot.GetWorldLocation(), pot.Map );
}
else if ( o is ICannonDamage )
{
//((ICannonDamage)o).Hits -= Utility.RandomMinMax(MinDamage/3,MaxDamage/3);
((ICannonDamage)o).Damage(from,Utility.RandomMinMax(MinDamage/3,MaxDamage/3));
}
}
}
示例12: Shoot
public void Shoot( Mobile from, Mobile target )
{
if ( from == target )
return;
if ( m_UsesRemaining < 1 )
{
// You have no AzhuranBlowGun darts!
from.SendMessage( "You have no blow gun darts in the weapon." );
}
else if ( m_Using )
{
// You are already using that AzhuranBlowGun.
from.SendMessage( "You are already using that blow gun." );
}
else if ( !BasePotion.HasFreeHand( from ) )
{
// You must have a free hand to use a AzhuranBlowGun.
from.SendMessage( "You must have a free hand to use a blow gun." );
}
else if ( from.CanBeHarmful( target ) )
{
m_Using = true;
from.Direction = from.GetDirectionTo( target );
if ( from.Body.IsHuman && !from.Mounted )
from.Animate( 33, 2, 1, true, true, 0 );
from.PlaySound( 0x223 );
from.MovingEffect( target, 0x2804, 5, 0, false, false );
if ( from.CheckSkill( SkillName.Archery, -10.0, 50.0 ) )
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( OnDartHit ), new object[]{ from, target } );
else
ConsumeUse();
Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerCallback( ResetUsing ) );
}
}
示例13: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Charmed.DeathAdderCharmable || m_Charmed.Combatant != null || !from.CanBeHarmful( m_Charmed, false ) )
return;
DeathAdder da = Spells.Necromancy.SummonFamiliarSpell.Table[from] as DeathAdder;
if ( da == null || da.Deleted )
return;
Mobile targ = targeted as Mobile;
if ( targ == null || !from.CanBeHarmful( targ, false ) )
return;
from.RevealingAction();
from.DoHarmful( targ, true );
m_Charmed.Combatant = targ;
if ( m_Charmed.AIObject != null )
m_Charmed.AIObject.Action = ActionType.Combat;
}
示例14: Shoot
public void Shoot( Mobile from, Mobile target )
{
if ( from == target )
return;
if ( m_UsesRemaining < 1 )
{
// You have no fukiya darts!
from.SendLocalizedMessage( 1063325 );
}
else if ( m_Using )
{
// You are already using that fukiya.
from.SendLocalizedMessage( 1063326 );
}
else if ( !BasePotion.HasFreeHand( from ) )
{
// You must have a free hand to use a fukiya.
from.SendLocalizedMessage( 1063327 );
}
else if ( from.CanBeHarmful( target ) )
{
m_Using = true;
from.Direction = from.GetDirectionTo( target );
from.RevealingAction();
if ( from.Body.IsHuman && !from.Mounted )
from.Animate( 33, 2, 1, true, true, 0 );
from.PlaySound( 0x223 );
from.MovingEffect( target, 0x2804, 5, 0, false, false );
if ( from.CheckSkill( SkillName.Ninjitsu, -10.0, 50.0 ) )
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( OnDartHit ), new object[]{ from, target } );
else
ConsumeUse();
Timer.DelayCall( TimeSpan.FromSeconds( 2.5 ), new TimerCallback( ResetUsing ) );
}
}
示例15: Use
public void Use( Mobile from, IPoint3D loc )
{
if ( !CheckUse( from ) )
return;
from.BeginAction( typeof( FireHorn ) );
Timer.DelayCall( Core.AOS ? TimeSpan.FromSeconds( 6.0 ) : TimeSpan.FromSeconds( 12.0 ), new TimerStateCallback( EndAction ), from );
int music = from.Skills[SkillName.Musicianship].Fixed;
int sucChance = 500 + ( music - 775 ) * 2;
double dSucChance = ((double)sucChance) / 1000.0;
if ( !from.CheckSkill( SkillName.Musicianship, dSucChance ) )
{
from.SendLocalizedMessage( 1049618 ); // The horn emits a pathetic squeak.
from.PlaySound( 0x18A );
return;
}
int sulfAsh = Core.AOS ? 4 : 15;
from.Backpack.ConsumeUpTo( typeof( SulfurousAsh ), sulfAsh );
from.PlaySound( 0x15F );
Effects.SendPacket( from, from.Map, new HuedEffect( EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0, 0 ) );
ArrayList targets = new ArrayList();
bool playerVsPlayer = false;
IPooledEnumerable eable = from.Map.GetMobilesInRange( new Point3D( loc ), 2 );
foreach ( Mobile m in eable )
{
if ( from != m && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) )
{
if ( Core.AOS && !from.InLOS( m ) )
continue;
targets.Add( m );
if ( m.Player )
playerVsPlayer = true;
}
}
eable.Free();
if ( targets.Count > 0 )
{
int prov = from.Skills[SkillName.Provocation].Fixed;
int disc = from.Skills[SkillName.Discordance].Fixed;
int peace = from.Skills[SkillName.Peacemaking].Fixed;
int minDamage, maxDamage;
if ( Core.AOS )
{
int musicScaled = music + Math.Max( 0, music - 900 ) * 2;
int provScaled = prov + Math.Max( 0, prov - 900 ) * 2;
int discScaled = disc + Math.Max( 0, disc - 900 ) * 2;
int peaceScaled = peace + Math.Max( 0, peace - 900 ) * 2;
int weightAvg = ( musicScaled + provScaled * 3 + discScaled * 3 + peaceScaled ) / 80;
int avgDamage;
if ( playerVsPlayer )
avgDamage = weightAvg / 3;
else
avgDamage = weightAvg / 2;
minDamage = ( avgDamage * 9 ) / 10;
maxDamage = ( avgDamage * 10 ) / 9;
}
else
{
int total = prov + disc / 5 + peace / 5;
if ( playerVsPlayer )
total /= 3;
maxDamage = ( total * 2 ) / 30;
minDamage = ( maxDamage * 7 ) / 10;
}
double damage = Utility.RandomMinMax( minDamage, maxDamage );
if ( Core.AOS && targets.Count > 1 )
damage = (damage * 2) / targets.Count;
else if ( !Core.AOS )
damage /= targets.Count;
for ( int i = 0; i < targets.Count; ++i )
{
Mobile m = (Mobile)targets[i];
double toDeal = damage;
if ( !Core.AOS && m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 ) )
{
toDeal *= 0.5;
//.........這裏部分代碼省略.........