All pastes #9065 Raw Edit

tobz

public text v1 · immutable
#9065 ·published 2005-04-08 01:23 UTC
rendered paste body
public virtual bool HealTarget(GameLiving target, int amount)
        {
            if (target == null || target.ObjectState != GameLiving.eObjectState.Active) return false;

            if (!target.Alive)
            {
                //"You cannot heal the dead!" sshot550.tga
                MessageToCaster(target.GetName(0, true) + " is dead!", eChatType.CT_SpellResisted);
                return false;
            }

            MasteryofConcentrationEffect MOCEffect = (MasteryofConcentrationEffect)m_caster.EffectList.GetOfType(typeof(MasteryofConcentrationEffect));
            if (MOCEffect != null)
            {
                int modifier = 0;
                int mocLevel = 0;
                double modifierFloat = 0;

                GamePlayer spellCaster = m_caster as GamePlayer;
                mocLevel = spellCaster.GetAbilityLevel("Mastery of Concentration");
                DOLConsole.WriteLine("moc -> normal heal -> original heal: " + amount.ToString());
                DOLConsole.WriteLine("moc -> normal heal -> moc level: " + mocLevel.ToString());

                switch (mocLevel)
                {
                    case 1:
                        modifier = 25;
                        break;
                    case 2:
                        modifier = 50;
                        break;
                    case 3:
                        modifier = 75;
                        break;
                }

                modifierFloat = modifier / 100;

                amount = (int)(amount * (modifier / 100));
                DOLConsole.WriteLine("moc -> normal heal -> modifier: " + modifierFloat.ToString() + "%");
                DOLConsole.WriteLine("moc -> normal heal -> heal after moc: " + amount.ToString());
            }

            int heal = target.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, amount);
            DOLConsole.WriteLine("normal heal -> original heal val: " + amount.ToString() + " heal change: " + heal.ToString());

            if (heal == 0)
            {
                if (Spell.Pulse == 0)
                {
                    if (target == m_caster) MessageToCaster("You are fully healed.", eChatType.CT_SpellResisted);
                    else MessageToCaster(target.GetName(0, true) + " is fully healed.", eChatType.CT_SpellResisted);
                }
                return false;
            }

            if (m_caster == target)
            {
                MessageToCaster("You heal yourself for " + heal + " hit points.", eChatType.CT_Spell);
                if (heal < amount)
                    MessageToCaster("You are fully healed.", eChatType.CT_Spell);
            }
            else
            {
                MessageToCaster("You heal " + target.GetName(0, false) + " for " + heal + " hit points!", eChatType.CT_Spell);
                MessageToLiving(target, "You are healed by " + m_caster.GetName(0, false) + " for " + heal + " hit points.", eChatType.CT_Spell);
                if (heal < amount)
                    MessageToCaster(target.GetName(0, true) + " is fully healed.", eChatType.CT_Spell);
            }

            return true;
        }