| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System.Drawing;
- using Server.MirDatabase;
- using Server.MirEnvir;
- namespace Server.MirObjects.Monsters
- {
- public class Doe : MonsterObject
- {
- public long FearTime;
- public long teleportTime = 5000;
- protected internal Doe(MonsterInfo info)
- : base(info)
- {
- }
- protected override void ProcessTarget()
- {
- if (Target == null || !CanAttack) return;
- if (Envir.Time < FearTime)
- {
- Attack();
- return;
- }
- FearTime = Envir.Time + 5000;
- var hpPercent = (HP * 100) / Stats[Stat.HP];
- bool halfHealth = hpPercent <= 50;
- if(halfHealth == true && Envir.Time > teleportTime)
- {
- TeleportRandom(1, 5, CurrentMap);
- }
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
- if (dist >= Info.ViewRange)
- MoveTo(Target.CurrentLocation);
- else
- {
- MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
- if (Walk(dir)) return;
- switch (Envir.Random.Next(2)) //No favour
- {
- case 0:
- for (int i = 0; i < 7; i++)
- {
- dir = Functions.NextDir(dir);
- if (Walk(dir))
- return;
- }
- break;
- default:
- for (int i = 0; i < 7; i++)
- {
- dir = Functions.PreviousDir(dir);
- if (Walk(dir))
- return;
- }
- break;
- }
- }
- }
- public override bool TeleportRandom(int attempts, int distance, Map temp = null)
- {
- for (int i = 0; i < attempts; i++)
- {
- Point location;
- if (distance <= 0)
- location = new Point(Envir.Random.Next(CurrentMap.Width), Envir.Random.Next(CurrentMap.Height));
- else
- location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
- CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));
- if (Teleport(CurrentMap, location, true, 9)) return true;
- }
- return false;
- }
- }
- }
|