// Every member in the target's party is effected by whatever you coded in SpellEffect. public void DoPartyEffect(BlueSpell spell, Mobile target) { Party p = Party.Get(target); if (p == null) { return; } for (int i = 0; i < p.Members.Count; ++i) { PartyMemberInfo pmi = (PartyMemberInfo)p.Members[i]; if (pmi == null) { continue; } Mobile member = pmi.Mobile; if (member == null) { continue; } if (target.Map == member.Map && target.CanSee(member)) { spell.SpellEffect(member); } } FinishSequence(); }
// Every member in the target's party is effected by whatever you coded in SpellEffect. public void DoPartyEffect( BlueSpell spell, Mobile target ) { Party p = Party.Get( target ); if ( p == null ) return; for ( int i = 0; i < p.Members.Count; ++i ) { PartyMemberInfo pmi = (PartyMemberInfo)p.Members[i]; if ( pmi == null ) continue; Mobile member = pmi.Mobile; if ( member == null ) continue; if ( target.Map == member.Map && target.CanSee( member ) ) { spell.SpellEffect( member ); } } FinishSequence(); }
// It gets everyone near the center, if burst is true (which the DoBurstEffect ovverload handles) it does the math to make it a circle. public void DoAreaEffect( BlueSpell spell, Point3D target, bool burst ) { if ( Caster.Map == null || spell.Range == 0 ) return; List<Mobile> targets = new List<Mobile>(); foreach ( Mobile mob in Caster.Map.GetMobilesInRange( target, spell.Range ) ) { if ( mob == null ) continue; if ( CanTarget( Caster, mob, spell.IsHarmful ) ) { /*if ( !Caster.Map.LineOfSight( target, mob.Location ) ) { Caster.Say("LOS fail. X:" + mob.X.ToString() + " Y:" + mob.Y.ToString() ); continue; } else /*/if ( burst ) { if ( GetDist( target, mob.Location ) > ((double)Range + 0.1) ) continue; } targets.Add( mob ); } } if ( burst ) { Point3D point = new Point3D(); for ( int i = -Range; i < Range + 1; i++ ) for ( int j = -Range; j < Range + 1; j++ ) { point.X = target.X + i; point.Y = target.Y + j; if ( GetDist( target, point ) < ((double)Range + 0.1) ) { point.Z = Caster.Map.GetAverageZ( point.X, point.Y ); spell.VisualEffects( point ); } } } for ( int i = targets.Count - 1; i > 0; i-- ) spell.SpellEffect( targets[i] ); targets.Clear(); FinishSequence(); }
// Spffy Cone thing public void DoConeEffect( BlueSpell spell ) { int x = Caster.X, y = Caster.Y, xoffset = 0, yoffset = 0; List<Mobile> mobiles = new List<Mobile>(); List<Point3D> points = new List<Point3D>(); foreach ( Mobile m in Caster.GetMobilesInRange( Range ) ) { if ( m != null ) if ( CanTarget( Caster, m, spell.IsHarmful ) ) mobiles.Add( m ); } switch( Caster.Direction ) { case (Direction)0x0: case (Direction)0x80: yoffset--; break; //North case (Direction)0x1: case (Direction)0x81: { xoffset++; yoffset--; break; } //Right case (Direction)0x2: case (Direction)0x82: xoffset++; break; //East case (Direction)0x3: case (Direction)0x83: { xoffset++; yoffset++; break; } //Down case (Direction)0x4: case (Direction)0x84: yoffset++; break; //South case (Direction)0x5: case (Direction)0x85: { xoffset--; yoffset++; break; } //Left case (Direction)0x6: case (Direction)0x86: xoffset--; break; //West case (Direction)0x7: case (Direction)0x87: { xoffset--; yoffset--; break; } //Up default: { break; } } for ( int i = 0; i < Range; i++ ) // goes to the sides { for ( int j = i + 1; j <= Range; j++ ) // j goes forward { if ( j >= i + 1 ) { Point3D point = new Point3D( 0, 0, 0 ); point.X = ( x + j * xoffset - i * yoffset ); point.Y = ( y + j * yoffset + i * xoffset ); point.Z = Caster.Map.GetAverageZ( point.X, point.Y ); points.Add( point ); if ( i > 0 ) { point.X = ( x + j * xoffset + i * yoffset ); point.Y = ( y + j * yoffset - i * xoffset ); point.Z = Caster.Map.GetAverageZ( point.X, point.Y ); points.Add( point ); } } } } for ( int i = 0; i < points.Count; i++ ) { if ( mobiles.Count > 0 ) { for ( int j = mobiles.Count - 1; j > -1; j-- ) { if ( mobiles[j].X == points[i].X && mobiles[j].Y == points[i].Y ) { spell.SpellEffect( mobiles[j] ); if ( mobiles[j] != null ) mobiles.Remove( mobiles[j] ); } } } spell.VisualEffects( points[i] ); } mobiles.Clear(); points.Clear(); }
// Creates a line, and gets everyone standing in the line. public void DoLineEffect( BlueSpell spell, Direction direction, Point3D point ) { List<Mobile> targets = new List<Mobile>(); List<Mobile> potentialtargets = new List<Mobile>(); foreach ( Mobile mob in Caster.GetMobilesInRange( spell.Range ) ) { if ( mob != null ) if ( CanTarget( Caster, mob, spell.IsHarmful ) ) potentialtargets.Add( mob ); } for ( int i = 1; i < spell.Range+1; i++ ) { switch( direction ) { case (Direction)0x0: case (Direction)0x80: point.Y--; break; //North case (Direction)0x1: case (Direction)0x81: { point.X++; point.Y--; break; } //Right case (Direction)0x2: case (Direction)0x82: point.X++; break; //East case (Direction)0x3: case (Direction)0x83: { point.X++; point.Y++; break; } //Down case (Direction)0x4: case (Direction)0x84: point.Y++; break; //South case (Direction)0x5: case (Direction)0x85: { point.X--; point.Y++; break; } //Left case (Direction)0x6: case (Direction)0x86: point.X--; break; //West case (Direction)0x7: case (Direction)0x87: { point.X--; point.Y--; break; } //Up default: { break; } } if ( !Caster.CanSee( point ) ) break; spell.VisualEffects( point ); // Running a 0 range check on each square in the line may be better than running a massive area foreach and checking every's X/Y location in it I think. foreach ( Mobile mob in potentialtargets ) { if ( mob != null && mob.X == point.X && mob.Y == point.Y ) // Ignore Z axis per RunUO's spells. targets.Add( mob ); } } for ( int i = targets.Count - 1; i > 0; i-- ) spell.SpellEffect( targets[i] ); targets.Clear(); FinishSequence(); }
// It gets everyone near the center, if burst is true (which the DoBurstEffect ovverload handles) it does the math to make it a circle. public void DoAreaEffect(BlueSpell spell, Point3D target, bool burst) { if (Caster.Map == null || spell.Range == 0) { return; } List <Mobile> targets = new List <Mobile>(); foreach (Mobile mob in Caster.Map.GetMobilesInRange(target, spell.Range)) { if (mob == null) { continue; } if (CanTarget(Caster, mob, spell.IsHarmful)) { /*if ( !Caster.Map.LineOfSight( target, mob.Location ) ) * { * Caster.Say("LOS fail. X:" + mob.X.ToString() + " Y:" + mob.Y.ToString() ); * continue; * } * else /*/if (burst) { if (GetDist(target, mob.Location) > ((double)Range + 0.1)) { continue; } } targets.Add(mob); } } if (burst) { Point3D point = new Point3D(); for (int i = -Range; i < Range + 1; i++) { for (int j = -Range; j < Range + 1; j++) { point.X = target.X + i; point.Y = target.Y + j; if (GetDist(target, point) < ((double)Range + 0.1)) { point.Z = Caster.Map.GetAverageZ(point.X, point.Y); spell.VisualEffects(point); } } } } for (int i = targets.Count - 1; i > 0; i--) { spell.SpellEffect(targets[i]); } targets.Clear(); FinishSequence(); }
// Spffy Cone thing public void DoConeEffect(BlueSpell spell) { int x = Caster.X, y = Caster.Y, xoffset = 0, yoffset = 0; List <Mobile> mobiles = new List <Mobile>(); List <Point3D> points = new List <Point3D>(); foreach (Mobile m in Caster.GetMobilesInRange(Range)) { if (m != null) { if (CanTarget(Caster, m, spell.IsHarmful)) { mobiles.Add(m); } } } switch (Caster.Direction) { case (Direction)0x0: case (Direction)0x80: yoffset--; break; //North case (Direction)0x1: case (Direction)0x81: { xoffset++; yoffset--; break; } //Right case (Direction)0x2: case (Direction)0x82: xoffset++; break; //East case (Direction)0x3: case (Direction)0x83: { xoffset++; yoffset++; break; } //Down case (Direction)0x4: case (Direction)0x84: yoffset++; break; //South case (Direction)0x5: case (Direction)0x85: { xoffset--; yoffset++; break; } //Left case (Direction)0x6: case (Direction)0x86: xoffset--; break; //West case (Direction)0x7: case (Direction)0x87: { xoffset--; yoffset--; break; } //Up default: { break; } } for (int i = 0; i < Range; i++) // goes to the sides { for (int j = i + 1; j <= Range; j++) // j goes forward { if (j >= i + 1) { Point3D point = new Point3D(0, 0, 0); point.X = (x + j * xoffset - i * yoffset); point.Y = (y + j * yoffset + i * xoffset); point.Z = Caster.Map.GetAverageZ(point.X, point.Y); points.Add(point); if (i > 0) { point.X = (x + j * xoffset + i * yoffset); point.Y = (y + j * yoffset - i * xoffset); point.Z = Caster.Map.GetAverageZ(point.X, point.Y); points.Add(point); } } } } for (int i = 0; i < points.Count; i++) { if (mobiles.Count > 0) { for (int j = mobiles.Count - 1; j > -1; j--) { if (mobiles[j].X == points[i].X && mobiles[j].Y == points[i].Y) { spell.SpellEffect(mobiles[j]); if (mobiles[j] != null) { mobiles.Remove(mobiles[j]); } } } } spell.VisualEffects(points[i]); } mobiles.Clear(); points.Clear(); }
// Creates a line, and gets everyone standing in the line. public void DoLineEffect(BlueSpell spell, Direction direction, Point3D point) { List <Mobile> targets = new List <Mobile>(); List <Mobile> potentialtargets = new List <Mobile>(); foreach (Mobile mob in Caster.GetMobilesInRange(spell.Range)) { if (mob != null) { if (CanTarget(Caster, mob, spell.IsHarmful)) { potentialtargets.Add(mob); } } } for (int i = 1; i < spell.Range + 1; i++) { switch (direction) { case (Direction)0x0: case (Direction)0x80: point.Y--; break; //North case (Direction)0x1: case (Direction)0x81: { point.X++; point.Y--; break; } //Right case (Direction)0x2: case (Direction)0x82: point.X++; break; //East case (Direction)0x3: case (Direction)0x83: { point.X++; point.Y++; break; } //Down case (Direction)0x4: case (Direction)0x84: point.Y++; break; //South case (Direction)0x5: case (Direction)0x85: { point.X--; point.Y++; break; } //Left case (Direction)0x6: case (Direction)0x86: point.X--; break; //West case (Direction)0x7: case (Direction)0x87: { point.X--; point.Y--; break; } //Up default: { break; } } if (!Caster.CanSee(point)) { break; } spell.VisualEffects(point); // Running a 0 range check on each square in the line may be better than running a massive area foreach and checking every's X/Y location in it I think. foreach (Mobile mob in potentialtargets) { if (mob != null && mob.X == point.X && mob.Y == point.Y) // Ignore Z axis per RunUO's spells. { targets.Add(mob); } } } for (int i = targets.Count - 1; i > 0; i--) { spell.SpellEffect(targets[i]); } targets.Clear(); FinishSequence(); }