public void GetPlayerOwner_InitWithPlayer_Player()
        {
            var player = new FakePlayer();
            var brain  = new ControlledNpcBrain(player);

            var actual = brain.GetPlayerOwner();

            var expected = player;

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public override void OnEffectStart(GameSpellEffect effect)
        {
            base.OnEffectStart(effect);

            GamePlayer player = Caster as GamePlayer;
            GameNPC    npc    = effect.Owner as GameNPC;

            if (player != null && npc != null)
            {
                if (m_controlledBrain == null)
                {
                    m_controlledBrain = new ControlledNpcBrain(player);
                }

                if (!m_isBrainSet)
                {
                    npc.AddBrain(m_controlledBrain);
                    m_isBrainSet = true;

                    GameEventMgr.AddHandler(npc, GameLivingEvent.PetReleased, new DOLEventHandler(ReleaseEventHandler));
                }

                if (player.ControlledBrain != m_controlledBrain)
                {
                    // sorc: "The slough serpent is enthralled!" ct_spell
                    Message.SystemToArea(effect.Owner, Util.MakeSentence(Spell.Message1, npc.GetName(0, false)), eChatType.CT_Spell);
                    MessageToCaster(npc.GetName(0, true) + " is now under your control.", eChatType.CT_Spell);

                    player.SetControlledBrain(m_controlledBrain);

                    foreach (GamePlayer ply in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                    {
                        ply.Out.SendNPCCreate(npc);
                        if (npc.Inventory != null)
                        {
                            ply.Out.SendLivingEquipmentUpdate(npc);
                        }

                        ply.Out.SendObjectGuildID(npc, player.Guild);
                    }
                }
            }
            else
            {
                // something went wrong.
                if (log.IsWarnEnabled)
                {
                    log.Warn(string.Format("charm effect start: Caster={0} effect.Owner={1}",
                                           (Caster == null ? "(null)" : Caster.GetType().ToString()),
                                           (effect.Owner == null ? "(null)" : effect.Owner.GetType().ToString())));
                }
            }
        }
Пример #3
0
        protected override IControlledBrain GetPetBrain(GameLiving owner)
        {
            IControlledBrain controlledBrain = null;

            BDSubPet.SubPetType type = (BDSubPet.SubPetType)(byte) this.Spell.DamageType;
            owner = owner.ControlledBrain.Body;

            switch (type)
            {
            //Melee
            case BDSubPet.SubPetType.Melee:
                controlledBrain = new BDMeleeBrain(owner);
                break;

            //Healer
            case BDSubPet.SubPetType.Healer:
                controlledBrain = new BDHealerBrain(owner);
                break;

            //Mage
            case BDSubPet.SubPetType.Caster:
                controlledBrain = new BDCasterBrain(owner);
                break;

            //Debuffer
            case BDSubPet.SubPetType.Debuffer:
                controlledBrain = new BDDebufferBrain(owner);
                break;

            //Buffer
            case BDSubPet.SubPetType.Buffer:
                controlledBrain = new BDBufferBrain(owner);
                break;

            //Range
            case BDSubPet.SubPetType.Archer:
                controlledBrain = new BDArcherBrain(owner);
                break;

            //Other
            default:
                controlledBrain = new ControlledNpcBrain(owner);
                break;
            }

            return(controlledBrain);
        }
Пример #4
0
        /// <summary>
        /// Message the pet's owner, not the pet
        /// </summary>
        /// <param name="message"></param>
        /// <param name="chatType"></param>
        protected override void MessageToOwner(String message, eChatType chatType)
        {
            GameNPC npc = Caster as GameNPC;

            if (npc != null)
            {
                ControlledNpcBrain brain = npc.Brain as ControlledNpcBrain;
                if (brain != null)
                {
                    GamePlayer owner = brain.Owner as GamePlayer;
                    if (owner != null)
                    {
                        owner.Out.SendMessage(message, chatType, eChatLoc.CL_SystemWindow);
                    }
                }
            }
        }
Пример #5
0
        public override void FinishSpellCast(GameLiving target)
        {
            GamePlayer player = Caster as GamePlayer;

            if (player == null || player.ControlledBrain == null)
            {
                return;
            }

            // No power cost, we'll drain power on the caster when
            // the pet actually starts casting it.
            // If there is an ID, create a sub spell for the pet.

            ControlledNpcBrain petBrain = player.ControlledBrain as ControlledNpcBrain;

            if (petBrain != null && Spell.SubSpellID > 0)
            {
                Spell spell = SkillBase.GetSpellByID(Spell.SubSpellID);
                if (spell != null && spell.SubSpellID == 0)
                {
                    spell.Level = Spell.Level;
                    petBrain.Notify(GameNPCEvent.PetSpell, this,
                                    new PetSpellEventArgs(spell, SpellLine, target));
                }
            }

            // Facilitate Painworking.

            if (Spell.RecastDelay > 0 && m_startReuseTimer)
            {
                foreach (Spell spell in SkillBase.GetSpellList(SpellLine.KeyName))
                {
                    if (spell.SpellType == Spell.SpellType &&
                        spell.RecastDelay == Spell.RecastDelay &&
                        spell.Group == Spell.Group)
                    {
                        Caster.DisableSkill(spell, spell.RecastDelay);
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// When an applied effect starts
        /// duration spells only
        /// </summary>
        /// <param name="effect"></param>
        public override void OnEffectStart(GameSpellEffect effect)
        {
            base.OnEffectStart(effect);

            if (Caster is GamePlayer player && effect.Owner is GameNPC npc)
            {
                if (m_controlledBrain == null)
                {
                    m_controlledBrain = new ControlledNpcBrain(player);
                }

                if (!m_isBrainSet)
                {
                    npc.AddBrain(m_controlledBrain);
                    m_isBrainSet = true;

                    GameEventMgr.AddHandler(npc, GameLivingEvent.PetReleased, new DOLEventHandler(ReleaseEventHandler));
                }

                if (player.ControlledBrain != m_controlledBrain)
                {
                    // sorc: "The slough serpent is enthralled!" ct_spell
                    Message.SystemToArea(effect.Owner, Util.MakeSentence(Spell.Message1, npc.GetName(0, false)), eChatType.CT_Spell);
                    MessageToCaster($"{npc.GetName(0, true)} is now under your control.", eChatType.CT_Spell);

                    player.SetControlledBrain(m_controlledBrain);

                    foreach (GamePlayer ply in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                    {
                        ply.Out.SendNPCCreate(npc);
                        if (npc.Inventory != null)
                        {
                            ply.Out.SendLivingEquipmentUpdate(npc);
                        }

                        ply.Out.SendObjectGuildID(npc, player.Guild);
                    }
                }
            }