| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- using System.Collections.Generic;
- using System.Drawing;
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class SepHighWarrior : MonsterObject
- {
- public long FearTime, DecreaseMPTime;
- public byte AttackRange = 1;
- public bool Summoned;
- protected internal SepHighWarrior(MonsterInfo info)
- : base(info)
- {
- }
- protected override bool InAttackRange()
- {
- return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
- }
- protected override void ProcessTarget()
- {
- if (Target == null) return;
- if (!InAttackRange())
- {
- if (CurrentLocation == Target.CurrentLocation)
- {
- MirDirection direction = (MirDirection)Envir.Random.Next(8);
- int rotation = Envir.Random.Next(2) == 0 ? 1 : -1;
- for (int d = 0; d < 8; d++)
- {
- if (Walk(direction)) break;
- direction = Functions.ShiftDirection(direction, rotation);
- }
- }
- else
- MoveTo(Target.CurrentLocation);
- }
- if (!CanAttack) return;
- if (InAttackRange())
- {
- Attack();
- }
- }
- protected override void Attack()
- {
- if (!Target.IsAttackTarget(this))
- {
- Target = null;
- return;
- }
- ShockTime = 0;
- ActionTime = Envir.Time + 500;
- AttackTime = Envir.Time + AttackSpeed;
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
- switch (Envir.Random.Next(5))
- {
- case 0:
- TwinDrakeBlade();
- break;
- case 1:
- CrossHalfMoon();
- break;
- case 2:
- BladeAvalanche();
- break;
- default:
- base.Attack();
- break;
- }
- }
- public void TwinDrakeBlade()
- {
- if (Target == null) return;
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = Spell.TwinDrakeBlade });
- Target.Attacked(this, (int)(damage * 0.8), DefenceType.AC);
- ProjectileAttack((int)(damage * 0.8), DefenceType.ACAgility);
- if (((Target.Race != ObjectType.Player || Settings.PvpCanResistPoison) && (Envir.Random.Next(Settings.PoisonAttackWeight) >= Target.Stats[Stat.PoisonResist])) && (Target.Level <= Level + 8 && Envir.Random.Next(20) <= 5))
- {
- Target.ApplyPoison(new Poison { PType = PoisonType.Stun, Duration = 5, TickSpeed = 1000 }, this);
- Target.Broadcast(new S.ObjectEffect { ObjectID = Target.ObjectID, Effect = SpellEffect.TwinDrakeBlade });
- }
- }
- public void CrossHalfMoon()
- {
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = Spell.CrossHalfMoon });
- List<MapObject> targets = FindAllTargets(1, CurrentLocation, false);
- if (targets.Count == 0) return;
- Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- for (int i = 0; i < targets.Count; i++)
- {
- HalfmoonAttack(damage);
- }
- }
- public void BladeAvalanche()
- {
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- Broadcast(new S.ObjectMagic { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Spell = Spell.BladeAvalanche, TargetID = Target.ObjectID, Target = Target.CurrentLocation, Cast = true, Level = 3 });
- int col = 3;
- int row = 3;
- Point[] loc = new Point[col];
- loc[0] = Functions.PointMove(CurrentLocation, Functions.PreviousDir(Direction), 1);
- loc[1] = Functions.PointMove(CurrentLocation, Direction, 1);
- loc[2] = Functions.PointMove(CurrentLocation, Functions.NextDir(Direction), 1);
- for (int i = 0; i < col; i++)
- {
- Point startPoint = loc[i];
- for (int j = 0; j < row; j++)
- {
- Point hitPoint = Functions.PointMove(startPoint, Direction, j);
- if (!CurrentMap.ValidPoint(hitPoint)) continue;
- Cell cell = CurrentMap.GetCell(hitPoint);
- if (cell.Objects == null) continue;
- for (int k = 0; k < cell.Objects.Count; k++)
- {
- MapObject target = cell.Objects[k];
- switch (target.Race)
- {
- case ObjectType.Monster:
- case ObjectType.Player:
- case ObjectType.Hero:
- //Only targets
- if (target.IsAttackTarget(this))
- {
- target.Attacked(this, j <= 1 ? damage : (int)(damage * 0.6), DefenceType.MAC);
- }
- break;
- }
- }
- }
- }
- }
- public bool Walk(MirDirection dir, bool br = false)
- {
- if (!CanMove) return false;
- var temploc = Functions.PointMove(CurrentLocation, dir, 1);
- if (!CurrentMap.ValidPoint(temploc)) return false;
- var cell = CurrentMap.GetCell(temploc);
- if (cell.Objects != null)
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- MapObject ob = cell.Objects[i];
- if (!ob.Blocking) continue;
- return false;
- }
- Point location = Functions.PointMove(CurrentLocation, dir, 2);
- if (!CurrentMap.ValidPoint(location)) return false;
- cell = CurrentMap.GetCell(location);
- bool isBreak = br;
- if (cell.Objects != null)
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- MapObject ob = cell.Objects[i];
- if (!ob.Blocking) continue;
- isBreak = true;
- break;
- }
- if (isBreak)
- {
- location = Functions.PointMove(CurrentLocation, dir, 1);
- if (!CurrentMap.ValidPoint(location)) return false;
- cell = CurrentMap.GetCell(location);
- if (cell.Objects != null)
- for (int i = 0; i < cell.Objects.Count; i++)
- {
- MapObject ob = cell.Objects[i];
- 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)
- {
- Hidden = false;
- for (int i = 0; i < Buffs.Count; i++)
- {
- if (Buffs[i].Type != BuffType.Hiding) continue;
- Buffs[i].ExpireTime = 0;
- break;
- }
- }
- CellTime = Envir.Time + 500;
- ActionTime = Envir.Time + 300;
- MoveTime = Envir.Time + MoveSpeed;
- if (MoveTime > AttackTime)
- AttackTime = MoveTime;
- InSafeZone = CurrentMap.GetSafeZone(CurrentLocation) != null;
- if (isBreak)
- Broadcast(new S.ObjectWalk { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
- else
- Broadcast(new S.ObjectRun { 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 void Die()
- {
- if (Dead) return;
- HP = 0;
- Dead = true;
- //DeadTime = Envir.Time + DeadDelay;
- DeadTime = 0;
- Broadcast(new S.ObjectDied { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = (byte)(Master != null ? 1 : 0) });
- if (EXPOwner != null && Master == null && EXPOwner.Race == ObjectType.Player) EXPOwner.WinExp(Experience, Level);
- if (Respawn != null)
- Respawn.Count--;
- if (Master == null)
- Drop();
- Master = null;
- PoisonList.Clear();
- Envir.MonsterCount--;
- if (CurrentMap != null)
- CurrentMap.MonsterCount--;
- }
- public override Packet GetInfo()
- {
- PlayerObject master = null;
- short weapon = -1;
- short armour = 0;
- byte wing = 0;
- if (Master != null && Master is PlayerObject) master = (PlayerObject)Master;
- if (master != null)
- {
- weapon = master.Looks_Weapon;
- armour = master.Looks_Armour;
- wing = master.Looks_Wings;
- }
- return new S.ObjectPlayer
- {
- ObjectID = ObjectID,
- Name = master != null ? master.Name : Name,
- NameColour = NameColour,
- Class = MirClass.Warrior,
- Gender = master != null ? master.Gender : Envir.Random.Next(2) == 0 ? MirGender.Male : MirGender.Female,
- Location = CurrentLocation,
- Direction = Direction,
- Hair = master != null ? master.Hair : (byte)Envir.Random.Next(0, 5),
- Weapon = 52,
- Armour = 31,
- Light = master != null ? master.Light : Light,
- Poison = CurrentPoison,
- Dead = Dead,
- Hidden = Hidden,
- Effect = SpellEffect.None,
- WingEffect = wing,
- Extra = Summoned,
- TransformType = -1,
- };
- }
- }
- }
|