| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using Server.MirDatabase;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class FrostTiger : MonsterObject
- {
- protected byte AttackRange = 6;
- public long SitDownTime;
- protected internal FrostTiger(MonsterInfo info)
- : base(info)
- {
- SitDownTime = NewSitDownTime();
- }
- private bool _sitting;
- public bool Sitting
- {
- get { return _sitting; }
- set
- {
- if (_sitting == value) return;
- _sitting = value;
- Hidden = value;
- CurrentMap.Broadcast(new S.ObjectSitDown { ObjectID = ObjectID, Location = CurrentLocation, Direction = Direction, Sitting = value }, CurrentLocation);
- }
- }
- protected override bool CanAttack
- {
- get
- {
- return !Sitting && base.CanAttack;
- }
- }
- protected override bool CanMove
- {
- get
- {
- return !Sitting && base.CanMove;
- }
- }
- public override bool Walk(MirDirection dir)
- {
- return !Sitting && base.Walk(dir);
- }
- protected override bool InAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
- }
- protected long NewSitDownTime()
- {
- long newtime = Envir.Time + Envir.Random.Next(1000 * 60 * 2);
- return newtime < SitDownTime ? SitDownTime : newtime;
- }
- protected override void FindTarget() { }
- 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;
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (!ranged)
- {
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- if (damage == 0) return;
- DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
- ActionList.Add(action);
- }
- else
- {
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
- AttackTime = Envir.Time + AttackSpeed + 500;
- if (damage == 0) return;
- int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
- DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MAC);
- ActionList.Add(action);
- if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.Stats[Stat.PoisonResist])
- {
- if (Envir.Random.Next(8) == 0)
- {
- if (Info.Effect == 0)
- {
- Target.ApplyPoison(new Poison
- {
- Owner = this,
- Duration = 5,
- PType = PoisonType.Bleeding,
- TickSpeed = 1000,
- }, this);
- }
- else if (Info.Effect == 1)
- {
- Target.ApplyPoison(new Poison
- {
- Owner = this,
- Duration = 5,
- PType = PoisonType.Slow,
- TickSpeed = 1000,
- }, this);
- }
- }
- }
- }
- if (Target.Dead)
- FindTarget();
- }
- protected override void ProcessTarget()
- {
- if (Target == null) return;
- if (Sitting) Sitting = false;
- SitDownTime = NewSitDownTime();
- if (InAttackRange() && CanAttack)
- {
- Attack();
- return;
- }
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- MoveTo(Target.CurrentLocation);
- }
- protected override void ProcessAI()
- {
- if (!Dead && !Sitting && Envir.Time > SitDownTime)
- {
- Sitting = true;
- }
- base.ProcessAI();
- }
- public override Packet GetInfo()
- {
- var packet = (S.ObjectMonster)base.GetInfo();
- packet.Extra = Sitting;
- return packet;
- }
- }
- }
|