//Provides the Parent Item (this) with a new Entity Link private void ProvideEntity( ) { if (m_Child != null) { m_Child.Delete( ); } IDamageableItem2 Idam = new IDamageableItem2(this); if (Idam != null && !Idam.Deleted && this.Map != null) { m_Child = Idam; m_Child.Update( ); } }
//Provides the Parent Item (this) with a new Entity Link private void ProvideEntity( ) { if( m_Child != null ) { m_Child.Delete( ); } IDamageableItem2 Idam = new IDamageableItem2( this ); if( Idam != null && !Idam.Deleted && this.Map != null ) { m_Child = Idam; m_Child.Update( ); } }
//This Wraps the target and resets the targeted ITEM to it's child BASECREATURE //Unfortunately, there is no accessible Array for a player's followers, //so we must use the GetMobilesInRage(int range) method for our reference checks! public override bool CheckTarget(Mobile from, Target targ, object targeted) { #region CheckEntity //Check to see if we have an Entity Link (Child BaseCreature) //If not, create one! //(Without Combatant Change, since this is for pets) PlayerMobile pm = from as PlayerMobile; if (pm != null) { if (m_Child != null && !m_Child.Deleted) { m_Child.Update( ); } else { ProvideEntity( ); if (m_Child != null && !m_Child.Deleted) { m_Child.Update( ); } } } #endregion if (targ is AIControlMobileTarget && targeted == this) { //Wrap the target AIControlMobileTarget t = targ as AIControlMobileTarget; //Get the OrderType OrderType order = t.Order; //Search for our controlled pets within screen range foreach (Mobile m in from.GetMobilesInRange(16)) { if (!(m is BaseCreature)) { continue; } BaseCreature bc = m as BaseCreature; if (from != null && !from.Deleted && from.Alive) { if (bc == null || bc.Deleted || !bc.Alive || !bc.Controlled || bc.ControlMaster != from) { continue; } //Reset the pet's ControlTarget and OrderType. bc.ControlTarget = m_Child; bc.ControlOrder = t.Order; } } } return(base.CheckTarget(from, targ, targeted)); }