| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- using Server.MirDatabase;
- using Server.MirEnvir;
- using S = ServerPackets;
- namespace Server.MirObjects.Monsters
- {
- public class TucsonEgg : MonsterObject
- {
- protected override bool CanMove { get { return false; } }
- protected internal TucsonEgg(MonsterInfo info)
- : base(info)
- {
- }
- public override void Turn(MirDirection dir)
- {
- }
- public override bool Walk(MirDirection dir) { return false; }
- public override bool IsAttackTarget(MonsterObject attacker)
- {
- return base.IsAttackTarget(attacker);
- }
- public override bool IsAttackTarget(HumanObject attacker)
- {
- return base.IsAttackTarget(attacker);
- }
- protected override void ProcessRoam() { }
- protected override void ProcessSearch()
- {
- base.ProcessSearch();
- }
- public override Packet GetInfo()
- {
- return base.GetInfo();
- }
- public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
- {
- int armour = 0;
- switch (type)
- {
- case DefenceType.ACAgility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
- break;
- case DefenceType.AC:
- armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
- break;
- case DefenceType.MACAgility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
- break;
- case DefenceType.MAC:
- armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
- break;
- case DefenceType.Agility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- break;
- }
- if (armour >= damage) return 0;
- ShockTime = 0;
- for (int i = PoisonList.Count - 1; i >= 0; i--)
- {
- if (PoisonList[i].PType != PoisonType.LRParalysis) continue;
- PoisonList.RemoveAt(i);
- OperateTime = 0;
- }
- if (attacker.Info.AI == 6)
- EXPOwner = null;
- else if (attacker.Master != null)
- {
- if (EXPOwner == null || EXPOwner.Dead)
- EXPOwner = attacker.Master switch
- {
- HeroObject hero => hero.Owner,
- _ => attacker.Master
- };
- if (EXPOwner == attacker.Master)
- EXPOwnerTime = Envir.Time + EXPOwnerDelay;
- }
- Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });
- ChangeHP(-1);
- return 1;
- }
- public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
- {
- int armour = 0;
- switch (type)
- {
- case DefenceType.ACAgility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
- break;
- case DefenceType.AC:
- armour = GetDefencePower(Stats[Stat.MinAC], Stats[Stat.MaxAC]);
- break;
- case DefenceType.MACAgility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
- break;
- case DefenceType.MAC:
- armour = GetDefencePower(Stats[Stat.MinMAC], Stats[Stat.MaxMAC]);
- break;
- case DefenceType.Agility:
- if (Envir.Random.Next(Stats[Stat.Agility] + 1) > attacker.Stats[Stat.Accuracy]) return 0;
- break;
- }
- if (armour >= damage) return 0;
- if (damageWeapon)
- attacker.DamageWeapon();
- ShockTime = 0;
- for (int i = PoisonList.Count - 1; i >= 0; i--)
- {
- if (PoisonList[i].PType != PoisonType.LRParalysis) continue;
- PoisonList.RemoveAt(i);
- OperateTime = 0;
- }
- if (Master != null && Master != attacker)
- if (Envir.Time > Master.BrownTime && Master.PKPoints < 200)
- attacker.BrownTime = Envir.Time + Settings.Minute;
- if (EXPOwner == null || EXPOwner.Dead)
- EXPOwner = GetAttacker(attacker);
- if (EXPOwner == attacker)
- EXPOwnerTime = Envir.Time + EXPOwnerDelay;
- Broadcast(new S.ObjectStruck { ObjectID = ObjectID, AttackerID = attacker.ObjectID, Direction = Direction, Location = CurrentLocation });
- attacker.GatherElement();
- ChangeHP(-1);
- return 1;
- }
- protected override void ProcessTarget()
- {
- if (Target == null)
- return;
- if (Envir.Time < ShockTime)
- {
- Target = null;
- return;
- }
- }
- protected override void CompleteAttack(IList<object> data)
- {
- List<MapObject> targets = FindAllTargets(1, CurrentLocation);
- if (targets.Count == 0) return;
- for (int i = 0; i < targets.Count; i++)
- {
- int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
- if (damage == 0) return;
- if (targets[i].Attacked(this, damage, DefenceType.MAC) <= 0) return;
- PoisonTarget(targets[i], 3, 5, PoisonType.Green, 2000);
- }
- }
- public override void Die()
- {
- ActionList.Add(new DelayedAction(DelayedType.Damage, Envir.Time + 300));
- if (Info.Effect == 1)
- {
- SpawnSlave();
- }
- base.Die();
- }
- private void SpawnSlave()
- {
- ActionTime = Envir.Time + 300;
- AttackTime = Envir.Time + AttackSpeed;
- var mob = GetMonster(Envir.GetMonsterInfo(Settings.TucsonGeneralEgg));
- if (mob == null) return;
- if (!mob.Spawn(CurrentMap, Front))
- mob.Spawn(CurrentMap, CurrentLocation);
- mob.Target = Target;
- mob.ActionTime = Envir.Time + 2000;
- }
- }
- }
|