| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- using System.Drawing;
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class ZumaMonster : MonsterObject
- {
- public bool Stoned = true;
- public bool AvoidFireWall = true;
- protected override bool CanMove
- {
- get
- {
- return base.CanMove && !Stoned;
- }
- }
- protected override bool CanAttack
- {
- get
- {
- return base.CanAttack && !Stoned;
- }
- }
- protected internal ZumaMonster(MonsterInfo info) : base(info)
- {
- }
- public override int Pushed(MapObject pusher, MirDirection dir, int distance)
- {
- return Stoned ? 0 : base.Pushed(pusher, dir, distance);
- }
- public override void ApplyPoison(Poison p, MapObject Caster = null, bool NoResist = false, bool ignoreDefence = true)
- {
- if (Stoned) return;
- base.ApplyPoison(p, Caster, NoResist, ignoreDefence);
- }
- public override Buff AddBuff(BuffType type, MapObject owner, int duration, Stats stats, bool refreshStats = true, bool updateOnly = false, params int[] values)
- {
- if (Stoned) return null;
- return base.AddBuff(type, owner, duration, stats, refreshStats, updateOnly, values);
- }
- public override bool IsFriendlyTarget(HumanObject ally)
- {
- if (Stoned) return false;
- return base.IsFriendlyTarget(ally);
- }
- protected override void ProcessAI()
- {
- if (!Dead && Envir.Time > ActionTime)
- {
- bool stoned = !FindNearby(2);
-
- if (Stoned && !stoned)
- {
- Wake();
- WakeAll(14);
- }
- }
- base.ProcessAI();
- }
- public void Wake()
- {
- if (!Stoned) return;
- Stoned = false;
- Broadcast(new S.ObjectShow { ObjectID = ObjectID });
- ActionTime = Envir.Time + 1000;
- }
- public void WakeAll(int dist)
- {
- for (int y = CurrentLocation.Y - dist; y <= CurrentLocation.Y + dist; y++)
- {
- if (y < 0) continue;
- if (y >= CurrentMap.Height) break;
- for (int x = CurrentLocation.X - dist; x <= CurrentLocation.X + dist; x++)
- {
- if (x < 0) continue;
- if (x >= CurrentMap.Width) break;
- Cell cell = CurrentMap.GetCell(x, y);
- if (!cell.Valid || cell.Objects == null) continue;
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- ZumaMonster target = cell.Objects[i] as ZumaMonster;
- if (target == null || !target.Stoned) continue;
- target.Wake();
- target.Target = Target;
- }
- }
- }
- }
- public override bool IsAttackTarget(MonsterObject attacker)
- {
- return !Stoned && base.IsAttackTarget(attacker);
- }
- public override bool IsAttackTarget(HumanObject attacker)
- {
- return !Stoned && base.IsAttackTarget(attacker);
- }
- public override bool Walk(MirDirection dir)
- {
- if (!CanMove) return false;
- Point location = Functions.PointMove(CurrentLocation, dir, 1);
- if (!CurrentMap.ValidPoint(location)) return false;
- Cell cell = CurrentMap.GetCell(location);
- if (cell.Objects != null)
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- MapObject ob = cell.Objects[i];
- if (AvoidFireWall && ob.Race == ObjectType.Spell)
- if (((SpellObject)ob).Spell == Spell.FireWall) return false;
- if (!ob.Blocking) continue;
- return false;
- }
- CurrentMap.GetCell(CurrentLocation).Remove(this);
- Direction = dir;
- RemoveObjects(dir, 1);
- CurrentLocation = location;
- CurrentMap.GetCell(CurrentLocation).Add(this);
- AddObjects(dir, 1);
- if (Hidden)
- {
- RemoveBuff(BuffType.Hiding);
- }
- CellTime = Envir.Time + 500;
- ActionTime = Envir.Time + 300;
- MoveTime = Envir.Time + MoveSpeed;
- if (MoveTime > AttackTime)
- AttackTime = MoveTime;
- InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null;
- Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- cell = CurrentMap.GetCell(CurrentLocation);
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- if (cell.Objects[i].Race != ObjectType.Spell) continue;
- SpellObject ob = (SpellObject)cell.Objects[i];
- ob.ProcessSpell(this);
- //break;
- }
- return true;
- }
- public override Packet GetInfo()
- {
- var packet = (S.ObjectMonster)base.GetInfo();
- packet.Extra = Stoned;
- return packet;
- }
- }
- }
|