ElephantMan.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class ElephantMan : MonsterObject
  7. {
  8. protected internal ElephantMan(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override void Attack()
  13. {
  14. if (!Target.IsAttackTarget(this))
  15. {
  16. Target = null;
  17. return;
  18. }
  19. ShockTime = 0;
  20. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  21. ActionTime = Envir.Time + 300;
  22. AttackTime = Envir.Time + AttackSpeed;
  23. if (Envir.Random.Next(5) > 0)
  24. {
  25. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  26. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  27. if (damage == 0) return;
  28. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, false);
  29. ActionList.Add(action);
  30. }
  31. else
  32. {
  33. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  34. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  35. if (damage == 0) return;
  36. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.AC, true);
  37. ActionList.Add(action);
  38. }
  39. }
  40. protected override void CompleteAttack(IList<object> data)
  41. {
  42. MapObject target = (MapObject)data[0];
  43. int damage = (int)data[1];
  44. DefenceType defence = (DefenceType)data[2];
  45. bool aoe = (bool)data[3];
  46. if (!aoe)
  47. {
  48. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  49. target.Attacked(this, damage, defence);
  50. }
  51. else
  52. {
  53. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  54. if (targets.Count == 0) return;
  55. for (int i = 0; i < targets.Count; i++)
  56. {
  57. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  58. }
  59. }
  60. }
  61. }
  62. }