本文整理汇总了C#中Server.Targeting.LandTarget类的典型用法代码示例。如果您正苦于以下问题:C# LandTarget类的具体用法?C# LandTarget怎么用?C# LandTarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LandTarget类属于Server.Targeting命名空间,在下文中一共展示了LandTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TargetResponse
public static void TargetResponse( NetState state, PacketReader pvSrc )
{
int type = pvSrc.ReadByte();
int targetID = pvSrc.ReadInt32();
int flags = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16();
int graphic = pvSrc.ReadUInt16();
if ( targetID == unchecked( (int) 0xDEADBEEF ) )
return;
Mobile from = state.Mobile;
Target t = from.Target;
if ( t != null )
{
TargetProfile prof = TargetProfile.Acquire( t.GetType() );
if ( prof != null ) {
prof.Start();
}
try {
if ( x == -1 && y == -1 && !serial.IsValid )
{
// User pressed escape
t.Cancel( from, TargetCancelType.Canceled );
}
else if ( Target.TargetIDValidation && t.TargetID != targetID )
{
// Sanity, prevent fake target
return;
}
else
{
object toTarget;
if ( type == 1 )
{
if ( graphic == 0 )
{
toTarget = new LandTarget( new Point3D( x, y, z ), from.Map );
}
else
{
Map map = from.Map;
if ( map == null || map == Map.Internal )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
StaticTile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis );
bool valid = false;
if ( state.HighSeas ) {
ItemData id = TileData.ItemTable[graphic&TileData.MaxItemValue];
if ( id.Surface ) {
z -= id.Height;
}
}
for ( int i = 0; !valid && i < tiles.Length; ++i )
{
if ( tiles[i].Z == z && tiles[i].ID == graphic )
valid = true;
}
if ( !valid )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
toTarget = new StaticTarget( new Point3D( x, y, z ), graphic );
}
}
}
}
else if ( serial.IsMobile )
{
toTarget = World.FindMobile( serial );
}
else if ( serial.IsItem )
{
toTarget = World.FindItem( serial );
}
else
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
t.Invoke( from, toTarget );
//.........这里部分代码省略.........
示例2: DoActionGuard
public override bool DoActionGuard()
{
if (m_LastTarget != null && m_LastTarget.Hidden)
{
Map map = m_Mobile.Map;
if (map == null || !m_Mobile.InRange(m_LastTargetLoc, Core.ML ? 10 : 12))
{
m_LastTarget = null;
}
else if (m_Mobile.Spell == null && DateTime.Now > m_NextCastTime)
{
m_Mobile.DebugSay("I am going to reveal my last target");
m_RevealTarget = new LandTarget(m_LastTargetLoc, map);
Spell spell = new RevealSpell(m_Mobile, null);
if (spell.Cast())
m_LastTarget = null; // only do it once
m_NextCastTime = DateTime.Now + GetDelay(spell);
}
}
if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true))
{
m_Mobile.DebugSay("I am going to attack {0}", m_Mobile.FocusMob.Name);
m_Mobile.Combatant = m_Mobile.FocusMob;
Action = ActionType.Combat;
}
else
{
if (!m_Mobile.Controlled)
{
ProcessTarget();
Spell spell = CheckCastHealingSpell();
if (spell != null)
spell.Cast();
}
base.DoActionGuard();
}
return true;
}
示例3: ProcessTarget
//.........这里部分代码省略.........
teleportAway = true;
}
}
else
{
toTarget = m_Mobile.Combatant;
if (toTarget != null)
RunTo(toTarget);
}
if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null)
{
if ((targ.Range == -1 || m_Mobile.InRange(toTarget, targ.Range)) && m_Mobile.CanSee(toTarget) && m_Mobile.InLOS(toTarget))
{
targ.Invoke(m_Mobile, toTarget);
}
else if (isDispel)
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
}
else if ((targ.Flags & TargetFlags.Beneficial) != 0)
{
targ.Invoke(m_Mobile, m_Mobile);
}
else if (isReveal && m_RevealTarget != null)
{
targ.Invoke(m_Mobile, m_RevealTarget);
}
else if (isTeleport && toTarget != null)
{
Map map = m_Mobile.Map;
if (map == null)
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
return true;
}
int px, py;
if (teleportAway)
{
int rx = m_Mobile.X - toTarget.X;
int ry = m_Mobile.Y - toTarget.Y;
double d = m_Mobile.GetDistanceToSqrt(toTarget);
px = toTarget.X + (int)(rx * (10 / d));
py = toTarget.Y + (int)(ry * (10 / d));
}
else
{
px = toTarget.X;
py = toTarget.Y;
}
for (int i = 0; i < m_Offsets.Length; i += 2)
{
int x = m_Offsets[i], y = m_Offsets[i + 1];
Point3D p = new Point3D(px + x, py + y, 0);
LandTarget lt = new LandTarget(p, map);
if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map))
{
targ.Invoke(m_Mobile, lt);
return true;
}
}
int teleRange = targ.Range;
if (teleRange < 0)
teleRange = Core.ML ? 11 : 12;
for (int i = 0; i < 10; ++i)
{
Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0);
LandTarget lt = new LandTarget(randomPoint, map);
if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map))
{
targ.Invoke(m_Mobile, new LandTarget(randomPoint, map));
return true;
}
}
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
else
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
return true;
}
示例4: Teleport
public virtual void Teleport()
{
if ( Combatant == null )
return;
// 20 tries to teleport
for ( int tries = 0; tries < 20; tries ++ )
{
int x = Utility.RandomMinMax( 5, 7 );
int y = Utility.RandomMinMax( 5, 7 );
if ( Utility.RandomBool() )
x *= -1;
if ( Utility.RandomBool() )
y *= -1;
Point3D p = new Point3D( X + x, Y + y, 0 );
IPoint3D po = new LandTarget( p, Map ) as IPoint3D;
if ( po == null )
continue;
SpellHelper.GetSurfaceTop( ref po );
if ( InRange( p, 12 ) && InLOS( p ) && Map.CanSpawnMobile( po.X, po.Y, po.Z ) )
{
Point3D from = Location;
Point3D to = new Point3D( po );
Location = to;
ProcessDelta();
FixedParticles( 0x376A, 9, 32, 0x13AF, EffectLayer.Waist );
PlaySound( 0x1FE );
return;
}
}
RevealingAction();
}
示例5: TargetResponse
public static void TargetResponse( NetState state, PacketReader pvSrc )
{
int type = pvSrc.ReadByte();
int targetID = pvSrc.ReadInt32();
/*int flags = */pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16();
int graphic = pvSrc.ReadInt16();
if ( targetID == unchecked( (int) 0xDEADBEEF ) )
return;
Mobile from = state.Mobile;
Target t = from.Target;
if ( t != null )
{
if ( x == -1 && y == -1 && !serial.IsValid )
{
// User pressed escape
t.Cancel( from, TargetCancelType.Canceled );
}
else
{
object toTarget;
if ( type == 1 )
{
if ( graphic == 0 )
{
toTarget = new LandTarget( new Point3D( x, y, z ), from.Map );
}
else
{
Map map = from.Map;
if ( map == null || map == Map.Internal )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
Tile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis );
bool valid = false;
for ( int i = 0; !valid && i < tiles.Length; ++i )
{
if ( tiles[i].Z == z && (tiles[i].ID & 0x3FFF) == (graphic & 0x3FFF) )
valid = true;
}
if ( !valid )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
toTarget = new StaticTarget( new Point3D( x, y, z ), graphic );
}
}
}
}
else if ( serial.IsMobile )
{
toTarget = World.FindMobile( serial );
}
else if ( serial.IsItem )
{
toTarget = World.FindItem( serial );
}
else
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
try {
t.Invoke( from, toTarget );
} catch (Exception e) {
log.Fatal(String.Format("Exception disarmed in target {0} > {1} > {2}",
from, t, toTarget), e);
}
}
}
}
示例6: Create
public static GreenThornsEffect Create( Mobile from, LandTarget land )
{
if ( !from.Map.CanSpawnMobile( land.Location ) )
return null;
int tileID = land.TileID;
foreach ( TilesAndEffect taep in m_Table )
{
bool contains = false;
for ( int i = 0; !contains && i < taep.Tiles.Length; i += 2 )
contains = ( tileID >= taep.Tiles[i] && tileID <= taep.Tiles[i + 1] );
if ( contains )
{
GreenThornsEffect effect = (GreenThornsEffect)Activator.CreateInstance( taep.Effect, new object[] { land.Location, from.Map, from } );
return effect;
}
}
return null;
}
示例7: ProcessTarget
protected virtual bool ProcessTarget()
{
Target targ = m_Mobile.Target;
if (targ == null)
return false;
bool isDispel = (targ is DispelSpell.InternalTarget || targ is MassDispelSpell.InternalTarget);
bool isParalyze = (targ is ParalyzeSpell.InternalTarget);
bool isTeleport = (targ is TeleportSpell.InternalTarget);
bool isSummon = (targ is EnergyVortexSpell.InternalTarget || targ is BladeSpiritsSpell.InternalTarget || targ is NatureFurySpell.InternalTarget);
bool isField = (targ is FireFieldSpell.InternalTarget || targ is PoisonFieldSpell.InternalTarget || targ is ParalyzeFieldSpell.InternalTarget);
bool isAnimate = (targ is AnimateDeadSpell.InternalTarget);
bool isDispelField = (targ is DispelFieldSpell.InternalTarget);
bool teleportAway = false;
bool harmful = (targ.Flags & TargetFlags.Harmful) != 0 || targ is HailStormSpell.InternalTarget || targ is WildfireSpell.InternalTarget;
bool beneficial = (targ.Flags & TargetFlags.Beneficial) != 0 || targ is ArchCureSpell.InternalTarget;
if (isTeleport && m_Mobile.CanSwim)
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
IDamageable toTarget = null;
if (isDispel)
{
toTarget = FindDispelTarget(false);
if (toTarget != null)
RunTo(toTarget);
}
else if (isDispelField)
{
Item field = GetHarmfulFieldItem();
if (field != null)
targ.Invoke(m_Mobile, field);
else
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
else if (SmartAI && (isParalyze || isTeleport))
{
toTarget = FindDispelTarget(true);
if (toTarget == null)
{
toTarget = m_Mobile.Combatant as Mobile;
if (toTarget != null)
RunTo(toTarget);
}
else if (m_Mobile.InRange(toTarget, 10))
{
RunFrom(toTarget);
teleportAway = true;
}
else
{
teleportAway = true;
}
}
else if (isAnimate)
{
Item corpse = FindCorpseToAnimate();
if (corpse != null)
targ.Invoke(m_Mobile, corpse);
}
else
{
toTarget = m_Mobile.Combatant;
if (toTarget != null)
RunTo(toTarget);
}
if (isSummon && toTarget != null)
{
int failSafe = 0;
Map map = toTarget.Map;
while (failSafe <= 25)
{
int x = Utility.RandomMinMax(toTarget.X - 2, toTarget.X + 2);
int y = Utility.RandomMinMax(toTarget.Y - 2, toTarget.Y + 2);
int z = toTarget.Z;
LandTarget lt = new LandTarget(new Point3D(x, y, z), map);
if (map.CanSpawnMobile(x, y, z))
{
targ.Invoke(m_Mobile, lt);
break;
}
failSafe++;
}
}
else if (isField && toTarget != null)
{
Map map = toTarget.Map;
//.........这里部分代码省略.........
示例8: Teleport
public void Teleport()
{
// 20 tries to teleport
for (int tries = 0; tries < 20; tries ++)
{
int x = Utility.RandomMinMax(5, 7);
int y = Utility.RandomMinMax(5, 7);
if (Utility.RandomBool())
x *= -1;
if (Utility.RandomBool())
y *= -1;
Point3D p = new Point3D(this.X + x, this.Y + y, 0);
IPoint3D po = new LandTarget(p, this.Map)as IPoint3D;
if (po == null)
continue;
SpellHelper.GetSurfaceTop(ref po);
if (this.InRange(p, 12) && this.InLOS(p) && this.Map.CanSpawnMobile(po.X, po.Y, po.Z))
{
Point3D from = this.Location;
Point3D to = new Point3D(po);
this.Location = to;
this.ProcessDelta();
this.FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist);
this.PlaySound(0x1FE);
break;
}
}
this.RevealingAction();
}
示例9: ProcessTarget
//.........这里部分代码省略.........
else if (isAnimate)
{
Item corpse = this.FindCorpseToAnimate();
if (corpse != null)
targ.Invoke(this.m_Mobile, corpse);
toTarget = null;
}
else
{
toTarget = this.m_Mobile.Combatant;
if (toTarget != null)
this.RunTo(toTarget);
}
if ((targ.Flags & TargetFlags.Harmful) != 0 && toTarget != null)
{
if ((targ.Range == -1 || this.m_Mobile.InRange(toTarget, targ.Range)) && this.m_Mobile.CanSee(toTarget) && this.m_Mobile.InLOS(toTarget))
{
targ.Invoke(this.m_Mobile, toTarget);
}
else if (isDispel)
{
targ.Cancel(this.m_Mobile, TargetCancelType.Canceled);
}
}
else if ((targ.Flags & TargetFlags.Beneficial) != 0)
{
targ.Invoke(this.m_Mobile, this.m_Mobile);
}
else if (isTeleport && toTarget != null)
{
Map map = this.m_Mobile.Map;
if (map == null)
{
targ.Cancel(this.m_Mobile, TargetCancelType.Canceled);
return;
}
int px, py;
if (teleportAway)
{
int rx = this.m_Mobile.X - toTarget.X;
int ry = this.m_Mobile.Y - toTarget.Y;
double d = this.m_Mobile.GetDistanceToSqrt(toTarget);
px = toTarget.X + (int)(rx * (10 / d));
py = toTarget.Y + (int)(ry * (10 / d));
}
else
{
px = toTarget.X;
py = toTarget.Y;
}
for (int i = 0; i < m_Offsets.Length; i += 2)
{
int x = m_Offsets[i], y = m_Offsets[i + 1];
Point3D p = new Point3D(px + x, py + y, 0);
LandTarget lt = new LandTarget(p, map);
if ((targ.Range == -1 || this.m_Mobile.InRange(p, targ.Range)) && this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map))
{
targ.Invoke(this.m_Mobile, lt);
return;
}
}
int teleRange = targ.Range;
if (teleRange < 0)
teleRange = 12;
for (int i = 0; i < 10; ++i)
{
Point3D randomPoint = new Point3D(this.m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), this.m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0);
LandTarget lt = new LandTarget(randomPoint, map);
if (this.m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map))
{
targ.Invoke(this.m_Mobile, new LandTarget(randomPoint, map));
return;
}
}
targ.Cancel(this.m_Mobile, TargetCancelType.Canceled);
}
else
{
targ.Cancel(this.m_Mobile, TargetCancelType.Canceled);
}
}
示例10: ProcessTarget
private bool ProcessTarget()
{
Target targ = m_Mobile.Target;
if ( targ == null )
return false;
Mobile toTarget;
toTarget = m_Mobile.Combatant;
//if ( toTarget != null )
//RunTo( toTarget );
if ( targ is DispelSpell.InternalTarget && !(m_Mobile.AutoDispel) )
{
List<Mobile> targets = new List<Mobile>();
foreach ( Mobile m in m_Mobile.GetMobilesInRange( 12 ) )
{
if ( m is BaseCreature )
{
if ( ((BaseCreature)m).IsDispellable && CanTarget( m_Mobile, m ) )
targets.Add( m );
}
}
if ( targets.Count >= 0 )
{
int whichone = Utility.RandomMinMax( 0, targets.Count );
if ( targets[whichone] != null )
targ.Invoke( m_Mobile, targets[whichone] );
}
}
else if ( targ is TeleportSpell.InternalTarget || targ is Shadowjump.InternalTarget )
{
if ( targ is Shadowjump.InternalTarget && !m_Mobile.Hidden )
return false;
Map map = m_Mobile.Map;
if ( map == null )
{
targ.Cancel( m_Mobile, TargetCancelType.Canceled );
return true;
}
int px, py;
bool teleportAway = ( m_Mobile.Hits < (m_Mobile.Hits / 10) );
if ( teleportAway )
{
int rx = m_Mobile.X - toTarget.X;
int ry = m_Mobile.Y - toTarget.Y;
double d = m_Mobile.GetDistanceToSqrt( toTarget );
px = toTarget.X + (int)(rx * (10 / d));
py = toTarget.Y + (int)(ry * (10 / d));
}
else
{
px = toTarget.X;
py = toTarget.Y;
}
for ( int i = 0; i < m_RandomLocations.Length; i += 2 )
{
int x = m_RandomLocations[i], y = m_RandomLocations[i + 1];
Point3D p = new Point3D( px + x, py + y, 0 );
LandTarget lt = new LandTarget( p, map );
if ( (targ.Range == -1 || m_Mobile.InRange( p, targ.Range )) && m_Mobile.InLOS( lt ) && map.CanSpawnMobile( px + x, py + y, lt.Z ) && !SpellHelper.CheckMulti( p, map ) )
{
targ.Invoke( m_Mobile, lt );
return true;
}
}
int teleRange = targ.Range;
if ( teleRange < 0 )
teleRange = 12;
for ( int i = 0; i < 10; ++i )
{
Point3D randomPoint = new Point3D( m_Mobile.X - teleRange + Utility.Random( teleRange * 2 + 1 ), m_Mobile.Y - teleRange + Utility.Random( teleRange * 2 + 1 ), 0 );
LandTarget lt = new LandTarget( randomPoint, map );
if ( m_Mobile.InLOS( lt ) && map.CanSpawnMobile( lt.X, lt.Y, lt.Z ) && !SpellHelper.CheckMulti( randomPoint, map ) )
{
targ.Invoke( m_Mobile, new LandTarget( randomPoint, map ) );
return true;
}
}
}
else if ( targ is AnimateDeadSpell.InternalTarget )
//.........这里部分代码省略.........
示例11: TryToTeleport
private void TryToTeleport()
{
Mobile m = FindNearestAggressor();
if ( m == null || m.Map == null || m_Mobile.Map == null )
{
return;
}
if ( m_Mobile.GetDistanceToSqrt( m ) > m_Mobile.RangePerception + 1 )
{
return;
}
int px = m_Mobile.X;
int py = m_Mobile.Y;
int dx = m_Mobile.X - m.X;
int dy = m_Mobile.Y - m.Y;
// get vector's length
double l = Math.Sqrt( (double) (dx*dx + dy*dy) );
if ( l == 0 )
{
int rand = Utility.Random( 8 ) + 1;
rand *= 2;
dx = m_Offsets[ rand ];
dy = m_Offsets[ rand + 1 ];
l = Math.Sqrt( (double) (dx*dx + dy*dy) );
}
// normalize vector
double dpx = ((double) dx)/l;
double dpy = ((double) dy)/l;
// move
px += (int) (dpx*(4 + Utility.Random( 3 )));
py += (int) (dpy*(4 + Utility.Random( 3 )));
for ( int i = 0; i < m_Offsets.Length; i += 2 )
{
int x = m_Offsets[ i ], y = m_Offsets[ i + 1 ];
Point3D p = new Point3D( px + x, py + y, 0 );
LandTarget lt = new LandTarget( p, m_Mobile.Map );
if ( m_Mobile.InLOS( lt ) && m_Mobile.Map.CanSpawnMobile( px + x, py + y, lt.Z ) && !SpellHelper.CheckMulti( p, m_Mobile.Map ) )
{
m_Mobile.FixedParticles( 0x376A, 9, 32, 0x13AF, EffectLayer.Waist );
m_Mobile.PlaySound( 0x1FE );
m_Mobile.Location = new Point3D( lt.X, lt.Y, lt.Z );
m_Mobile.ProcessDelta();
return;
}
}
return;
}
示例12: Target
public void Target(LandTarget p)
{
if (!Caster.CanSee(p))
{
Caster.SendLocalizedMessage(500237); // Target can not be seen.
}
else if (!CheckLineOfSight(p))
{
this.DoFizzle();
Caster.SendAsciiMessage("Target is not in line of sight");
}
else
{
if (CheckSequence())
{
try
{
BaseCreature creature = (BaseCreature)Activator.CreateInstance(m_Types[Utility.Random(m_Types.Length)]);
creature.ControlSlots = 2;
TimeSpan duration;
if (Core.AOS)
duration = TimeSpan.FromSeconds((2 * Caster.Skills.Magery.Fixed) / 5);
else
duration = TimeSpan.FromSeconds(4.0 * Caster.Skills[SkillName.Magery].Value);
SpellHelper.Summon(creature, Caster, 0x215, duration, false, false);
creature.MoveToWorld(new Point3D(p), Caster.Map );
}
catch
{
}
}
FinishSequence();
}
}
示例13: PerformShadowjump
// Shadowjump
private bool PerformShadowjump( Mobile toTarget )
{
if ( m_Mobile.Skills[ SkillName.Ninjitsu ].Value < 50.0 )
{
return false;
}
if ( toTarget != null )
{
Map map = m_Mobile.Map;
if ( map == null )
{
return false;
}
int px, py, ioffset = 0;
px = toTarget.X;
py = toTarget.Y;
if ( Action == ActionType.Flee )
{
double outerradius = m_Mobile.Skills[ SkillName.Ninjitsu ].Value/10.0;
double radiusoffset = 2.0;
// random point for direction vector
int rpx = Utility.Random( 40 ) - 20 + toTarget.X;
int rpy = Utility.Random( 40 ) - 20 + toTarget.Y;
// get vector
int dx = rpx - toTarget.X;
int dy = rpy - toTarget.Y;
// get vector's length
double l = Math.Sqrt( (double) (dx*dx + dy*dy) );
if ( l == 0 )
{
return false;
}
// normalize vector
double dpx = ((double) dx)/l;
double dpy = ((double) dy)/l;
// move
px += (int) (dpx*(outerradius - radiusoffset) + Math.Sign( dpx )*(radiusoffset + 0.5));
py += (int) (dpy*(outerradius - radiusoffset) + Math.Sign( dpy )*(radiusoffset + 0.5));
}
else
{
ioffset = 2;
}
for ( int i = ioffset; i < m_Offsets.Length; i += 2 )
{
int x = m_Offsets[ i ], y = m_Offsets[ i + 1 ];
Point3D p = new Point3D( px + x, py + y, 0 );
LandTarget lt = new LandTarget( p, map );
if ( m_Mobile.InLOS( lt ) && map.CanSpawnMobile( px + x, py + y, lt.Z ) && !SpellHelper.CheckMulti( p, map ) )
{
m_Mobile.Location = new Point3D( lt.X, lt.Y, lt.Z );
m_Mobile.ProcessDelta();
return true;
}
}
}
return false;
}
示例14: TargetResponse
public static void TargetResponse( NetState state, PacketReader pvSrc )
{
int type = pvSrc.ReadByte();
int targetID = pvSrc.ReadInt32();
int flags = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16();
int graphic = pvSrc.ReadInt16();
Mobile from = state.Mobile;
Target t = from.Target;
if ( t != null )
{
TargetProfile prof = TargetProfile.Acquire( t.GetType() );
if ( prof != null ) {
prof.Start();
}
try {
if (( x == -1 && y == -1 && !serial.IsValid ) || ( targetID == unchecked( (int) 0xDEADBEEF ) ))
{
// User pressed escape
t.Cancel( from, TargetCancelType.Canceled );
}
else
{
object toTarget;
if ( type == 1 )
{
if ( graphic == 0 )
{
toTarget = new LandTarget( new Point3D( x, y, z ), from.Map );
}
else
{
Map map = from.Map;
if ( map == null || map == Map.Internal )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
Tile[] tiles = map.Tiles.GetStaticTiles( x, y, !t.DisallowMultis );
bool valid = false;
for ( int i = 0; !valid && i < tiles.Length; ++i )
{
if ( tiles[i].Z == z && (tiles[i].ID & 0x3FFF) == (graphic & 0x3FFF) )
valid = true;
}
if ( !valid )
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
else
{
toTarget = new StaticTarget( new Point3D( x, y, z ), graphic );
}
}
}
}
else if ( serial.IsMobile )
{
toTarget = World.FindMobile( serial );
}
else if ( serial.IsItem )
{
toTarget = World.FindItem( serial );
}
else
{
t.Cancel( from, TargetCancelType.Canceled );
return;
}
t.Invoke( from, toTarget );
}
} finally {
if ( prof != null ) {
prof.Finish();
}
}
}
}
示例15: ProcessTarget
//.........这里部分代码省略.........
else if ((targ.Flags & TargetFlags.Beneficial) != 0 && toHeal != null)
{
if ((m_Mobile.InRange(toHeal, 10)) && m_Mobile.CanSee(toHeal) && m_Mobile.InLOS(toHeal) && NeedGHeal(toHeal))
{
targ.Invoke(m_Mobile, toHeal);
}
else
{
Targeting.Target.Cancel(m_Mobile);
}
}
else if ((targ.Flags & TargetFlags.Beneficial) != 0)
{
if (!isCrossHeal)
{
targ.Invoke(m_Mobile, m_Mobile);
}
if ((isCrossHeal) && (NeedGHeal(m_Mobile)))
{
targ.Invoke(m_Mobile, m_Mobile);
}
else
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
}
else if (isTeleport && toTarget != null)
{
Map map = m_Mobile.Map;
if (map == null)
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
return;
}
int px, py;
if (teleportAway)
{
int rx = m_Mobile.X - toTarget.X;
int ry = m_Mobile.Y - toTarget.Y;
double d = m_Mobile.GetDistanceToSqrt(toTarget);
px = toTarget.X + (int)(rx * (10 / d));
py = toTarget.Y + (int)(ry * (10 / d));
}
else
{
px = toTarget.X;
py = toTarget.Y;
}
for (int i = 0; i < m_Offsets.Length; i += 2)
{
int x = m_Offsets[i], y = m_Offsets[i + 1];
Point3D p = new Point3D(px + x, py + y, 0);
LandTarget lt = new LandTarget(p, map);
if ((targ.Range == -1 || m_Mobile.InRange(p, targ.Range)) && m_Mobile.InLOS(lt) && map.CanSpawnMobile(px + x, py + y, lt.Z) && !SpellHelper.CheckMulti(p, map))
{
targ.Invoke(m_Mobile, lt);
return;
}
}
int teleRange = targ.Range;
if (teleRange < 0)
teleRange = 12;
for (int i = 0; i < 10; ++i)
{
Point3D randomPoint = new Point3D(m_Mobile.X - teleRange + Utility.Random(teleRange * 2 + 1), m_Mobile.Y - teleRange + Utility.Random(teleRange * 2 + 1), 0);
LandTarget lt = new LandTarget(randomPoint, map);
if (m_Mobile.InLOS(lt) && map.CanSpawnMobile(lt.X, lt.Y, lt.Z) && !SpellHelper.CheckMulti(randomPoint, map))
{
targ.Invoke(m_Mobile, new LandTarget(randomPoint, map));
return;
}
}
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
else
{
targ.Cancel(m_Mobile, TargetCancelType.Canceled);
}
}