public override void OnDamage(int amount, Mobile from, bool willKill) { base.OnDamage(amount, from, willKill); Mobile controlMaster = null; if (amount == 0 || from == null || from.Deleted || !from.Alive || willKill) { return; } if (from is BaseCreature) { //pet BaseCreature bc = ((BaseCreature)from); if (bc.Controlled && bc.ControlMaster != null) { controlMaster = ((Mobile)bc.ControlMaster); //This is someone's pet, reflect the damage back on them double from.Damage(amount * 2, this); //Have a small chance to perform a life-leeching move on the tamer if (controlMaster.Alive && Utility.RandomChance(5)) { int max = 20; int min = 5; if (controlMaster.Hits < max) { max = controlMaster.Hits - 1; } if (controlMaster.Hits < min) { min = controlMaster.Hits / 2; } int damage = Utility.RandomMinMax(min, max); controlMaster.Damage(damage, this); this.Hits += damage; Effects.PlaySound(Location, Map, GetRandomNoise()); controlMaster.SendMessage("You feel the power vortex sapping your health!"); } } else if (bc.Summoned && bc.SummonMaster != null) { controlMaster = ((Mobile)bc.SummonMaster); //This is someone's summon , reflect the damage back on them from.Damage(amount, this); if (Utility.RandomChance(10)) { Effects.PlaySound(Location, Map, GetRandomNoise()); } } } else { //player if (amount / 2 > from.Hits) { //this will never actually kill a player, but will come close. from.Damage(from.Hits - 1, this); } else { from.Damage(amount / 2, this); } } int maxGuardians = 0; if (Hits < (HitsMax * 0.7)) { maxGuardians = 2; } if (Hits < (HitsMax * 0.5)) { maxGuardians = 3; } if (Hits < (HitsMax * 0.3)) { maxGuardians = 4; } DefragGuardians(); if (m_Guardians.Count < maxGuardians && Utility.RandomChance(10)) { GolemController gc = new GolemController(); if (controlMaster != null && controlMaster.Alive && !controlMaster.Deleted) { gc.ForceTarget(controlMaster); } gc.Home = Location; Point3D location = Location; if (from.Hidden) { from.SendMessage("You are forced out of hiding by the immense power!"); from.RevealingAction(); } m_Guardians.Add(gc); gc.MoveToWorld(location, Map); gc.OnThink(); Effects.PlaySound(Location, Map, 0x81); } }
public override void OnDamage(int amount, Mobile from, bool willKill) { base.OnDamage(amount, from, willKill); Mobile controlMaster = null; if (amount == 0 || from == null || from.Deleted || !from.Alive || willKill) return; if (from is BaseCreature) { //pet BaseCreature bc = ((BaseCreature)from); if (bc.Controlled && bc.ControlMaster != null) { controlMaster = ((Mobile)bc.ControlMaster); //This is someone's pet, reflect the damage back on them double from.Damage(amount*2, this); //Have a small chance to perform a life-leeching move on the tamer if (controlMaster.Alive && Utility.RandomChance(5)) { int max = 20; int min = 5; if (controlMaster.Hits < max) { max = controlMaster.Hits - 1; } if (controlMaster.Hits < min) { min = controlMaster.Hits / 2; } int damage = Utility.RandomMinMax(min, max); controlMaster.Damage(damage, this); this.Hits += damage; Effects.PlaySound(Location, Map, GetRandomNoise()); controlMaster.SendMessage("You feel the power vortex sapping your health!"); } } else if (bc.Summoned && bc.SummonMaster != null) { controlMaster = ((Mobile)bc.SummonMaster); //This is someone's summon , reflect the damage back on them from.Damage(amount, this); if (Utility.RandomChance(10)) Effects.PlaySound(Location, Map, GetRandomNoise()); } } else { //player if (amount / 2 > from.Hits) { //this will never actually kill a player, but will come close. from.Damage(from.Hits - 1, this); } else { from.Damage(amount / 2, this); } } int maxGuardians = 0; if (Hits < (HitsMax * 0.7)) maxGuardians = 2; if (Hits < (HitsMax * 0.5)) maxGuardians = 3; if (Hits < (HitsMax * 0.3)) maxGuardians = 4; DefragGuardians(); if (m_Guardians.Count < maxGuardians && Utility.RandomChance(10)) { GolemController gc = new GolemController(); if (controlMaster != null && controlMaster.Alive && !controlMaster.Deleted) { gc.ForceTarget(controlMaster); } gc.Home = Location; Point3D location = Location; if (from.Hidden) { from.SendMessage("You are forced out of hiding by the immense power!"); from.RevealingAction(); } m_Guardians.Add(gc); gc.MoveToWorld(location, Map); gc.OnThink(); Effects.PlaySound(Location, Map, 0x81); } }