| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class OmaWitchDoctor : MonsterObject
- {
- protected internal OmaWitchDoctor(MonsterInfo info)
- : base(info)
- {
- }
- protected override bool InAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
- }
- protected bool InLineAttackRange()
- {
- if (Target.CurrentMap != CurrentMap) return false;
- if (Target.CurrentLocation == CurrentLocation) return false;
- int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
- int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
- if (x > 6 || y > 6) return false;
- return (x == 0) || (y == 0) || (x == y);
- }
- protected override void Attack()
- {
- if (!Target.IsAttackTarget(this))
- {
- Target = null;
- return;
- }
- ShockTime = 0;
- Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
- bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
- ActionTime = Envir.Time + 300;
- AttackTime = Envir.Time + AttackSpeed;
- if (!ranged)
- {
- 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 + 500, Target, damage, DefenceType.ACAgility);
- ActionList.Add(action);
- }
- else
- {
- if (InLineAttackRange())
- {
- AttackTime = Envir.Time + AttackSpeed + 500;
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
-
- int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
- if (damage == 0) return;
-
- LineAttack(damage, 6, 500, DefenceType.MACAgility);
- }
- else
- {
- AttackTime = Envir.Time + AttackSpeed + 500;
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
- int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
- if (damage == 0) return;
- DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
- ActionList.Add(action);
- }
- }
- }
- protected override void ProcessTarget()
- {
- if (Target == null) return;
- if (InAttackRange() && CanAttack)
- {
- Attack();
- return;
- }
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- if (!InLineAttackRange())
- {
- MoveTo(Target.CurrentLocation);
- }
- }
- }
- }
|