Exemplo n.º 1
0
        /// <summary>
        /// Removes the brain from
        /// </summary>
        /// <param name="controlledNpc">The brain to find and remove</param>
        /// <returns>Whether the pet was removed</returns>
        public override bool RemoveControlledNpc(IControlledBrain controlledNpc)
        {
            bool found = false;

            lock (ControlledNpcList)
            {
                if (controlledNpc == null)
                {
                    return(false);
                }
                IControlledBrain[] brainlist = ControlledNpcList;
                int i = 0;
                //Try to find the minion in the list
                for (; i < brainlist.Length; i++)
                {
                    //Found it
                    if (brainlist[i] == controlledNpc)
                    {
                        found = true;
                        break;
                    }
                }

                //Found it, lets remove it
                if (found)
                {
                    if (controlledNpc.Body != null && controlledNpc.Body is GamePet)
                    {
                        GamePet minion = controlledNpc.Body as GamePet;
                        minion.StripOwnerBuffs(this);                         // Strip buffs off commander
                        minion.StripOwnerBuffs(Owner);                        // Strip buffs off player
                    }

                    //First lets store the brain to kill it
                    IControlledBrain tempBrain = m_controlledBrain[i];
                    //Lets get rid of the brain asap
                    m_controlledBrain[i] = null;

                    //Only decrement, we just lost one pet
                    PetCount--;

                    return(base.RemoveControlledNpc(controlledNpc));
                }
            }

            return(found);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Releases controlled object
        /// </summary>
        public virtual void CommandNpcRelease()
        {
            IControlledBrain controlledBrain = Player.ControlledBrain;

            if (controlledBrain == null)
            {
                return;
            }

            GameNPC npc = controlledBrain.Body;

            if (npc == null)
            {
                return;
            }
            else if (npc is GamePet)
            {
                GamePet pet = npc as GamePet;
                pet.StripOwnerBuffs(pet.Owner);
            }

            Player.Notify(GameLivingEvent.PetReleased, npc);
        }