Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System;
- using System.Drawing;
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class MutantCatLord : MonsterObject
- {
- public long FearTime, ChargeTime;
- public byte AttackRange = 6;
- protected internal MutantCatLord(MonsterInfo info)
- : base(info)
- {
- }
- protected override bool InAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
- }
- protected override void Attack()
- {
- if (!Target.IsAttackTarget(this))
- {
- Target = null;
- return;
- }
- if (ChargeTime > 0 && Envir.Time > ChargeTime)
- {
- ChargeTime = 0;
- RefreshAll();
- }
- ShockTime = 0;
- int damage = GetAttackPower(MinDC, MaxDC);
- if (damage == 0) return;
- Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
- ActionTime = Envir.Time + 300;
- AttackTime = Envir.Time + AttackSpeed;
- if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 1) && Envir.Random.Next(2) == 0)
- {
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- Target.Attacked(this, damage, DefenceType.MagicArmour, Info.element);
- int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
- DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MagicArmour, Info.element);
- ActionList.Add(action);
- // Two actions as its a double attack
- }
- else if (Envir.Random.Next(8) != 0)
- {
- Point offset = new Point(CurrentLocation.X, CurrentLocation.Y);
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
- int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
- DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MagicArmour, Info.element);
- ActionList.Add(action);
- }
- else
- {
- Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
- int levelgap = 50 - Target.Level;
- if (Envir.Random.Next(20) < 4 + levelgap)
- Target.ApplyPoison(new Poison
- {
- Owner = this,
- Duration = 5,
- PType = PoisonType.Bleed,
- TickSpeed = 1000,
- }, this);
- }
- if (Target.Dead)
- FindTarget();
- }
- protected override void ProcessTarget()
- {
- bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
- MapObject LowHPTarget = Target;
- List<MapObject> targets = FindAllTargets(range ? AttackRange : 4, CurrentLocation);
- if (Target == null || !CanAttack) return;
- if (InAttackRange() && (Envir.Time < FearTime))
- {
- if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 2) && Envir.Time > ChargeTime && Envir.Random.Next(5) == 0)
- {
- ChargeTime = Envir.Time + 8000;
- Broadcast(new S.ObjectEffect { ObjectID = ObjectID, Effect = SpellEffect.CatLordCharge });
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
- FireResistance = 75;
- IceResistance = 75;
- WindResistance = 75;
- LightningResistance = 75;
- ChaosResistance = 75;
- DivineResistance = 75;
- return;
- }
- if (targets.Count >= 2)
- {
- for (int i = 0; i < targets.Count; i++)
- {
- Target = targets[i];
- if (Target.Health > LowHPTarget.Health)
- {
- Target = LowHPTarget;
- Attack();
- }
- }
- }
- else
- {
- Attack();
- return;
- }
- }
- FearTime = Envir.Time + 5000;
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
- if (dist >= AttackRange)
- 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;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement