HoodedSummonerScrolls.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. /// <summary>
  6. /// Contains AI's for all of the HoodedSummoner's scrolls (WarriorScroll / TaoistScroll / WizardScroll / AssassinScroll).
  7. /// Set AI for all Scrolls to this AI and set the Effect to case number based on which scroll you want.
  8. ///
  9. /// WarriorScroll = 0
  10. /// TaoistScroll = 1
  11. /// WizardScroll = 2
  12. /// AssassinScroll = 3
  13. ///
  14. /// </summary>
  15. class HoodedSummonerScrolls : ZumaMonster
  16. {
  17. public long FearTime;
  18. protected internal HoodedSummonerScrolls(MonsterInfo info)
  19. : base(info)
  20. {
  21. }
  22. protected override bool InAttackRange()
  23. {
  24. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
  25. }
  26. protected override void Attack()
  27. {
  28. if (!Target.IsAttackTarget(this))
  29. {
  30. Target = null;
  31. return;
  32. }
  33. ShockTime = 0;
  34. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  35. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  36. ActionTime = Envir.Time + 300;
  37. AttackTime = Envir.Time + AttackSpeed;
  38. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  39. if (damage == 0) return;
  40. switch (Info.Effect)
  41. {
  42. case 0: // WarriorScroll - FireWall attack?
  43. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  44. DelayedAction warriorScrollAction = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MACAgility);
  45. ActionList.Add(warriorScrollAction);
  46. break;
  47. case 1: // TaoistScroll - PoisonCloud + PoisonExplosion on death.
  48. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  49. DelayedAction taoistScrollAction = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MACAgility, true);
  50. ActionList.Add(taoistScrollAction);
  51. break;
  52. case 2: // WizardScroll - Projectile Attack (D16).
  53. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  54. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  55. DelayedAction wizardScrollAction = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MACAgility);
  56. ActionList.Add(wizardScrollAction);
  57. break;
  58. case 3: // AssassinScroll - ThunderBolt Attack.
  59. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  60. DelayedAction assassinScrollAction = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MACAgility);
  61. ActionList.Add(assassinScrollAction);
  62. break;
  63. default:
  64. base.Attack();
  65. break;
  66. }
  67. }
  68. protected override void CompleteRangeAttack(IList<object> data)
  69. {
  70. MapObject target = (MapObject)data[0];
  71. int damage = (int)data[1];
  72. DefenceType defence = (DefenceType)data[2];
  73. bool poisonAttack = (bool)data[3];
  74. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  75. List<MapObject> targets = FindAllTargets(1, target.CurrentLocation);
  76. if (targets.Count == 0) return;
  77. for (int i = 0; i < targets.Count; i++)
  78. {
  79. targets[i].Attacked(this, damage, defence);
  80. PoisonTarget(targets[i], 7, 5, PoisonType.Green);
  81. }
  82. }
  83. protected override void ProcessTarget()
  84. {
  85. if (Target == null || !CanAttack) return;
  86. if (InAttackRange() && Envir.Time < FearTime)
  87. {
  88. Attack();
  89. return;
  90. }
  91. FearTime = Envir.Time + 5000;
  92. if (Envir.Time < ShockTime)
  93. {
  94. Target = null;
  95. return;
  96. }
  97. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  98. if (dist >= Info.ViewRange)
  99. MoveTo(Target.CurrentLocation);
  100. else
  101. {
  102. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  103. if (Walk(dir)) return;
  104. switch (Envir.Random.Next(2)) //No favour
  105. {
  106. case 0:
  107. for (int i = 0; i < 7; i++)
  108. {
  109. dir = Functions.NextDir(dir);
  110. if (Walk(dir))
  111. return;
  112. }
  113. break;
  114. default:
  115. for (int i = 0; i < 7; i++)
  116. {
  117. dir = Functions.PreviousDir(dir);
  118. if (Walk(dir))
  119. return;
  120. }
  121. break;
  122. }
  123. }
  124. }
  125. public override void Die()
  126. {
  127. switch (Info.Effect)
  128. {
  129. case 1:
  130. ActionList.Add(new DelayedAction(DelayedType.Die, Envir.Time + 500));
  131. break;
  132. case 0:
  133. case 2:
  134. case 3:
  135. default:
  136. base.Die();
  137. break;
  138. }
  139. }
  140. protected override void CompleteDeath(IList<object> data)
  141. {
  142. List<MapObject> targets = FindAllTargets(1, CurrentLocation, false);
  143. if (targets.Count == 0) return;
  144. for (int i = 0; i < targets.Count; i++)
  145. {
  146. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  147. if (damage == 0) return;
  148. if (targets[i].Attacked(this, damage, DefenceType.ACAgility) <= 0) continue;
  149. PoisonTarget(targets[i], 7, 5, PoisonType.Green);
  150. }
  151. }
  152. }
  153. }