From 5624873cd730e422769ee4662bac930aa319c56e Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 19 Oct 2009 01:00:36 +0000 Subject: [PATCH] Refactor IDevourable to IDevourer, as the interface represents an entity that consumes corpses, and not the entity being consumed. Refactor PlagueBeast to not require additional API by handling the devour goal increase in the property directly. --- Scripts/Items/Misc/Corpses/Corpse.cs | 8 ++++---- Scripts/Mobiles/AI/Creature/BaseCreature.cs | 16 --------------- Scripts/Mobiles/AI/Creature/Paragon.cs | 7 ------- .../Monsters/Misc/Melee/PlagueBeast.cs | 20 +++++-------------- 4 files changed, 9 insertions(+), 42 deletions(-) diff --git a/Scripts/Items/Misc/Corpses/Corpse.cs b/Scripts/Items/Misc/Corpses/Corpse.cs index 15f049ac2..a1a1f88bb 100644 --- a/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Scripts/Items/Misc/Corpses/Corpse.cs @@ -14,7 +14,7 @@ using Server.Network; namespace Server.Items { - public interface IDevourable + public interface IDevourer { bool Devour( Corpse corpse ); } @@ -66,7 +66,7 @@ namespace Server.Items private List m_Aggressors; // Anyone from this list will be able to loot this corpse; we attacked them, or they attacked us when we were freely attackable private string m_CorpseName; // Value of the CorpseNameAttribute attached to the owner when he died -or- null if the owner had no CorpseNameAttribute; use "the remains of ~name~" - private IDevourable m_Devourer; // The creature that devoured this corpse + private IDevourer m_Devourer; // The creature that devoured this corpse // For notoriety: private AccessLevel m_AccessLevel; // Which AccessLevel the owner had when he died @@ -646,10 +646,10 @@ namespace Server.Items public bool DevourCorpse() { - if( Devoured || Deleted || m_Killer == null || m_Killer.Deleted || !m_Killer.Alive || !(m_Killer is IDevourable) || m_Owner == null || m_Owner.Deleted ) + if( Devoured || Deleted || m_Killer == null || m_Killer.Deleted || !m_Killer.Alive || !(m_Killer is IDevourer) || m_Owner == null || m_Owner.Deleted ) return false; - m_Devourer = (IDevourable)m_Killer; // Set the devourer the killer + m_Devourer = (IDevourer)m_Killer; // Set the devourer the killer return m_Devourer.Devour( this ); // Devour the corpse if it hasn't } diff --git a/Scripts/Mobiles/AI/Creature/BaseCreature.cs b/Scripts/Mobiles/AI/Creature/BaseCreature.cs index 98d315877..71f01506c 100644 --- a/Scripts/Mobiles/AI/Creature/BaseCreature.cs +++ b/Scripts/Mobiles/AI/Creature/BaseCreature.cs @@ -955,22 +955,6 @@ namespace Server.Mobiles base.OnBeforeSpawn( location, m ); } - public virtual void OnBeforeParagonConvert() - { - } - - public virtual void OnAfterParagonConvert() - { - } - - public virtual void OnBeforeParagonUnConvert() - { - } - - public virtual void OnAfterParagonUnConvert() - { - } - public override ApplyPoisonResult ApplyPoison( Mobile from, Poison poison ) { if ( !Alive || IsDeadPet ) diff --git a/Scripts/Mobiles/AI/Creature/Paragon.cs b/Scripts/Mobiles/AI/Creature/Paragon.cs index ccb1a8de3..a699c6f89 100644 --- a/Scripts/Mobiles/AI/Creature/Paragon.cs +++ b/Scripts/Mobiles/AI/Creature/Paragon.cs @@ -46,8 +46,6 @@ namespace Server.Mobiles if ( bc.IsParagon ) return; - bc.OnBeforeParagonConvert(); - bc.Hue = Hue; if ( bc.HitsMaxSeed >= 0 ) @@ -90,8 +88,6 @@ namespace Server.Mobiles if( Math.Abs( bc.Karma ) > 32000 ) bc.Karma = 32000 * Math.Sign( bc.Karma ); } - - bc.OnAfterParagonConvert(); } public static void UnConvert( BaseCreature bc ) @@ -99,7 +95,6 @@ namespace Server.Mobiles if ( !bc.IsParagon ) return; - bc.OnBeforeParagonUnConvert(); bc.Hue = 0; if ( bc.HitsMaxSeed >= 0 ) @@ -131,8 +126,6 @@ namespace Server.Mobiles bc.Fame = (int)( bc.Fame / FameBuff ); if ( bc.Karma != 0 ) bc.Karma = (int)( bc.Karma / KarmaBuff ); - - bc.OnAfterParagonUnConvert(); } public static bool CheckConvert( BaseCreature bc ) diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs index d32fd01ad..f8fa8ccac 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs @@ -7,7 +7,7 @@ using Server.Network; namespace Server.Mobiles { [CorpseName( "a plague beast corpse" )] - public class PlagueBeast : BaseCreature, IDevourable + public class PlagueBeast : BaseCreature, IDevourer { private int m_DevourTotal; private int m_DevourGoal; @@ -23,7 +23,7 @@ namespace Server.Mobiles [CommandProperty( AccessLevel.GameMaster )] public int DevourGoal { - get { return m_DevourGoal; } + get { return ( this.Paragon ? m_DevourGoal + 25 : m_DevourGoal ); } set { m_DevourGoal = value; } } @@ -72,7 +72,7 @@ namespace Server.Mobiles PackItem( Engines.Plants.Seed.RandomPeculiarSeed(4) ); m_DevourTotal = 0; - m_DevourGoal = Utility.RandomMinMax( 15, 25 ); // The goal amount of how many corpses must devour before metal chest is rewarded + m_DevourGoal = Utility.RandomMinMax( 15, 25 ); // How many corpses must be devoured before a metal chest is awarded } public override void GenerateLoot() @@ -82,16 +82,6 @@ namespace Server.Mobiles // TODO: dungeon chest, healthy gland } - public override void OnAfterParagonConvert() - { - m_DevourGoal += 25; - } - - public override void OnAfterParagonUnConvert() - { - m_DevourGoal -= 25; - } - public override void OnGaveMeleeAttack( Mobile defender ) { base.OnGaveMeleeAttack( defender ); @@ -211,7 +201,7 @@ namespace Server.Mobiles eable.Free(); } - #region IDevourable Members + #region IDevourer Members public bool Devour( Corpse corpse ) { @@ -226,7 +216,7 @@ namespace Server.Mobiles PublicOverheadMessage( MessageType.Emote, 0x3B2, 1053033 ); // * The plague beast absorbs the fleshy remains of the corpse * - if( !m_HasMetalChest && m_DevourTotal >= m_DevourGoal ) + if( !m_HasMetalChest && m_DevourTotal >= DevourGoal ) { PackItem( new MetalChest() ); m_HasMetalChest = true;