| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class FrozenMagician : MonsterObject
- {
- private const byte AttackRange = 9;
- protected internal FrozenMagician(MonsterInfo info)
- : base(info)
- {
- }
- protected override bool InAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
- }
- protected bool InRangeAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
- }
- protected override void ProcessTarget()
- {
- if (Target == null || Dead) return;
- if (!InAttackRange())
- {
- if (CanAttack)
- {
- if (Envir.Random.Next(2) == 0)
- RangeAttack();
- }
- if (CurrentLocation == Target.CurrentLocation)
- {
- MirDirection direction = (MirDirection)Envir.Random.Next(8);
- int rotation = Envir.Random.Next(2) == 0 ? 1 : -1;
- for (int d = 0; d < 8; d++)
- {
- if (Walk(direction)) break;
- direction = Functions.ShiftDirection(direction, rotation);
- }
- }
- else
- MoveTo(Target.CurrentLocation);
- }
- if (!CanAttack) return;
- if (Envir.Random.Next(3) > 0)
- {
- if (InAttackRange())
- Attack();
- }
- else RangeAttack();
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- }
- protected override void Attack()
- {
- if (!Target.IsAttackTarget(this))
- {
- Target = null;
- return;
- }
- ShockTime = 0;
- Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
- ActionTime = Envir.Time + 300;
- AttackTime = Envir.Time + AttackSpeed;
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage, DefenceType.ACAgility, false);
- ActionList.Add(action);
- }
- public void RangeAttack()
- {
- if (!Target.IsAttackTarget(this))
- {
- Target = null;
- return;
- }
- ShockTime = 0;
- ActionTime = Envir.Time + 1500;
- AttackTime = Envir.Time + AttackSpeed + 1000;
- int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
- if (damage == 0) return;
- Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
- int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
- if (Envir.Random.Next(3) > 0)
- {
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
- if (damage == 0) return;
- DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 100 + delay, Target, damage, DefenceType.MACAgility);
- ActionList.Add(action);
- }
- else
- {
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
- if (damage == 0) return;
- DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 250 + delay, Target, damage * 3 / 2, DefenceType.MACAgility);
- ActionList.Add(action);
- }
- }
- }
- }
|