IcePillar.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class IcePillar : MonsterObject
  6. {
  7. protected override bool CanMove { get { return false; } }
  8. protected override bool CanRegen { get { return false; } }
  9. protected internal IcePillar(MonsterInfo info)
  10. : base(info)
  11. {
  12. Direction = MirDirection.Up;
  13. }
  14. protected override void FindTarget() { }
  15. public override void Turn(MirDirection dir)
  16. {
  17. }
  18. public override bool Walk(MirDirection dir)
  19. {
  20. return false;
  21. }
  22. protected override void ProcessRegen() { }
  23. protected override void ProcessSearch() { }
  24. protected override void ProcessRoam() { }
  25. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
  26. {
  27. int armour = 0;
  28. switch (type)
  29. {
  30. case DefenceType.ACAgility:
  31. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  32. armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
  33. break;
  34. case DefenceType.AC:
  35. armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
  36. break;
  37. case DefenceType.MACAgility:
  38. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  39. armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
  40. break;
  41. case DefenceType.MAC:
  42. armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
  43. break;
  44. case DefenceType.Agility:
  45. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  46. break;
  47. }
  48. if (armour >= damage) return 0;
  49. ShockTime = 0;
  50. if (attacker.Info.AI == 6)
  51. EXPOwner = null;
  52. else if (attacker.Master != null)
  53. {
  54. if (EXPOwner == null || EXPOwner.Dead)
  55. EXPOwner = attacker.Master switch
  56. {
  57. HeroObject hero => hero.Owner,
  58. _ => attacker.Master
  59. };
  60. if (EXPOwner == attacker.Master)
  61. EXPOwnerTime = Envir.Time + EXPOwnerDelay;
  62. }
  63. if(Envir.Random.Next(3) == 0)
  64. {
  65. CloseAttack(damage);
  66. }
  67. Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });
  68. ChangeHP(-1);
  69. return 1;
  70. }
  71. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
  72. {
  73. int armour = 0;
  74. switch (type)
  75. {
  76. case DefenceType.ACAgility:
  77. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  78. armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
  79. break;
  80. case DefenceType.AC:
  81. armour = GetAttackPower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
  82. break;
  83. case DefenceType.MACAgility:
  84. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  85. armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
  86. break;
  87. case DefenceType.MAC:
  88. armour = GetAttackPower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
  89. break;
  90. case DefenceType.Agility:
  91. if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
  92. break;
  93. }
  94. if (armour >= damage) return 0;
  95. if (damageWeapon)
  96. attacker.DamageWeapon();
  97. ShockTime = 0;
  98. if (Master != null && Master != attacker)
  99. if (Envir.Time > Master.BrownTime && Master.PKPoints < 200)
  100. attacker.BrownTime = Envir.Time + Settings.Minute;
  101. if (EXPOwner == null || EXPOwner.Dead)
  102. EXPOwner = GetAttacker(attacker);
  103. if (EXPOwner == attacker)
  104. EXPOwnerTime = Envir.Time + EXPOwnerDelay;
  105. if (Envir.Random.Next(3) == 0)
  106. {
  107. CloseAttack(damage);
  108. }
  109. Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });
  110. attacker.GatherElement();
  111. ChangeHP(-1);
  112. return 1;
  113. }
  114. public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
  115. {
  116. return 0;
  117. }
  118. public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true) { }
  119. private void CloseAttack(int damage)
  120. {
  121. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  122. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  123. if (targets.Count == 0) return;
  124. for (int i = 0; i < targets.Count; i++)
  125. {
  126. Broadcast(new S.ObjectEffect { ObjectID = targets[i].ObjectID, Effect = SpellEffect.IcePillar });
  127. if (targets[i].Attacked(this, damage, DefenceType.MACAgility) <= 0) continue;
  128. PoisonTarget(targets[i], 5, GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]), PoisonType.Frozen, 1000);
  129. }
  130. }
  131. public override void Die()
  132. {
  133. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  134. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  135. List<MapObject> targets = FindAllTargets(7, CurrentLocation, false);
  136. for (int i = 0; i < targets.Count; i++)
  137. {
  138. int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 500; //50 MS per Step
  139. DelayedAction action = new DelayedAction(DelayedType.Die, Envir.Time + delay, targets[i], damage, DefenceType.ACAgility);
  140. ActionList.Add(action);
  141. }
  142. base.Die();
  143. }
  144. protected override void CompleteDeath(IList<object> data)
  145. {
  146. MapObject target = (MapObject)data[0];
  147. int damage = (int)data[1];
  148. DefenceType defence = (DefenceType)data[2];
  149. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  150. target.Attacked(this, damage, defence);
  151. PoisonTarget(target, 5, 5, PoisonType.Frozen, 1000);
  152. }
  153. }
  154. }