protected void TakeDamageNPC(DOLEvent e, object sender, EventArgs args)
        {
            GameNPC npc = sender as GameNPC;

            if (!npc.IsWithinRadius(m_owner, 2300))
            {
                return;
            }

            if (!npc.IsAlive)
            {
                return;
            }

            int dmgamount = npc.MaxHealth - npc.Health;

            if (dmgamount <= 0 || npc.HealthPercent >= 75)
            {
                return;
            }

            int healamount;

            if (_poolValue <= 0)
            {
                Cancel(false);
            }

            if (_poolValue - dmgamount > 0)
            {
                healamount = dmgamount;
            }
            else
            {
                healamount = dmgamount - _poolValue;
            }

            foreach (GamePlayer tPlayer in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                if (!tPlayer.IsAlive)
                {
                    continue;
                }

                tPlayer.Out.SendSpellEffectAnimation(m_owner, npc, 8051, 0, false, 1);
            }

            var petOwner = (npc.Brain as IControlledBrain)?.Owner as GamePlayer;

            petOwner?.Out.SendMessage($"Your {npc.Name} was healed by the pool of healing for {healamount}!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
            _playerOwner.Out.SendMessage($"Your pool of healing heals the {npc.Name} of {petOwner?.Name} for {healamount}!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);

            npc.ChangeHealth(m_owner, GameLiving.eHealthChangeType.Spell, healamount);
            _poolValue -= dmgamount;

            if (_poolValue <= 0)
            {
                Cancel(false);
            }
        }
Ejemplo n.º 2
0
        protected void TakeDamageNPC(DOLEvent e, object sender, EventArgs args)
        {
            TakeDamageEventArgs targs = args as TakeDamageEventArgs;
            GameNPC             npc   = sender as GameNPC;

            if (!npc.IsWithinRadius(m_owner, 2300))
            {
                return;
            }

            if (!npc.IsAlive)
            {
                return;
            }

            int dmgamount = npc.MaxHealth - npc.Health;

            if (dmgamount <= 0 || npc.HealthPercent >= 75)
            {
                return;
            }

            int healamount = 0;


            if (PoolValue <= 0)
            {
                Cancel(false);
            }

            if (PoolValue - dmgamount > 0)
            {
                healamount = dmgamount;
            }
            else
            {
                healamount = dmgamount - PoolValue;
            }
            foreach (GamePlayer t_player in npc.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                if (!t_player.IsAlive)
                {
                    continue;
                }
                t_player.Out.SendSpellEffectAnimation(m_owner, npc, 8051, 0, false, 1);
            }
            GamePlayer petOwner = null;

            petOwner = ((npc as GameNPC).Brain as IControlledBrain).Owner as GamePlayer;
            if (petOwner != null)
            {
                petOwner.Out.SendMessage("Your " + npc.Name + " was healed by the pool of healing for " + healamount + "!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
            }

            m_playerOwner.Out.SendMessage("Your pool of healing heals the " + npc.Name + " of " + petOwner.Name + " for " + healamount + "!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);

            npc.ChangeHealth(m_owner, GameLiving.eHealthChangeType.Spell, healamount);
            PoolValue -= dmgamount;

            if (PoolValue <= 0)
            {
                Cancel(false);
            }
        }