예제 #1
0
        protected override int CalculateEffectDuration(GameLiving target, double effectiveness)
        {
            double duration  = base.CalculateEffectDuration(target, effectiveness);
            double mocFactor = 1.0;
            MasteryofConcentrationEffect moc = Caster.EffectList.GetOfType <MasteryofConcentrationEffect>();

            if (moc != null)
            {
                MasteryofConcentrationAbility ra = Caster.GetAbility <MasteryofConcentrationAbility>();
                if (ra != null)
                {
                    mocFactor = System.Math.Round((double)ra.GetAmountForLevel(ra.Level) * 25 / 100, 2);
                }
                duration = (double)Math.Round(duration * mocFactor);
            }


            if (Spell.SpellType.ToLower() != "stylestun")
            {
                // capping duration adjustment to 100%, live cap unknown - Tolakram
                int hitChance = Math.Min(200, CalculateToHitChance(target));

                if (hitChance <= 0)
                {
                    duration = 0;
                }
                else if (hitChance < 55)
                {
                    duration -= (int)(duration * (55 - hitChance) * 0.01);
                }
                else if (hitChance > 100)
                {
                    duration += (int)(duration * (hitChance - 100) * 0.01);
                }
            }


            return((int)duration);
        }
        /// <summary>
        /// Heals hit points of one target and sends needed messages, no spell effects
        /// </summary>
        /// <param name="target"></param>
        /// <param name="amount">amount of hit points to heal</param>
        /// <returns>true if heal was done</returns>
        public virtual bool HealTarget(GameLiving target, int amount)
        {
            if (target == null || target.ObjectState != GameLiving.eObjectState.Active)
            {
                return(false);
            }

            // we can't heal people we can attack
            if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true))
            {
                return(false);
            }

            // no healing of keep components
            if (target is Keeps.GameKeepComponent || target is Keeps.GameKeepDoor)
            {
                return(false);
            }

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

            if (target is GamePlayer && (target as GamePlayer).NoHelp && Caster is GamePlayer)
            {
                //player not grouped, anyone else
                //player grouped, different group
                if ((target as GamePlayer).Group == null ||
                    (Caster as GamePlayer).Group == null ||
                    (Caster as GamePlayer).Group != (target as GamePlayer).Group)
                {
                    MessageToCaster("That player does not want assistance", eChatType.CT_SpellResisted);
                    return(false);
                }
            }

            //moc heal decrease
            double mocFactor = 1.0;
            MasteryofConcentrationEffect moc = Caster.EffectList.GetOfType <MasteryofConcentrationEffect>();

            if (moc != null)
            {
                GamePlayer playerCaster          = Caster as GamePlayer;
                MasteryofConcentrationAbility ra = playerCaster.GetAbility <MasteryofConcentrationAbility>();
                if (ra != null)
                {
                    mocFactor = System.Math.Round((double)ra.GetAmountForLevel(ra.Level) / 100, 2);
                }
                amount = (int)Math.Round(amount * mocFactor);
            }
            int    criticalvalue  = 0;
            int    criticalchance = Caster.GetModified(eProperty.CriticalHealHitChance);
            double effectiveness  = 0;

            if (Caster is GamePlayer)
            {
                effectiveness = ((GamePlayer)Caster).Effectiveness + Caster.GetModified(eProperty.HealingEffectiveness) * 0.01;
            }
            if (Caster is GameNPC)
            {
                effectiveness = 1.0;
            }

            //USE DOUBLE !
            double cache = (double)amount * effectiveness;

            amount = (int)cache;

            if (Util.Chance(criticalchance))
            {
                criticalvalue = Util.Random(amount / 10, amount / 2 + 1);
            }

            amount += criticalvalue;

            GamePlayer playerTarget = target as GamePlayer;

            if (playerTarget != null)
            {
                GameSpellEffect HealEffect = SpellHandler.FindEffectOnTarget(playerTarget, "EfficientHealing");
                if (HealEffect != null)
                {
                    double HealBonus = amount * ((int)HealEffect.Spell.Value * 0.01);
                    amount += (int)HealBonus;
                    playerTarget.Out.SendMessage("Your Efficient Healing buff grants you a additional" + HealBonus + " in the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
                }
                GameSpellEffect EndEffect = SpellHandler.FindEffectOnTarget(playerTarget, "EfficientEndurance");
                if (EndEffect != null)
                {
                    double EndBonus = amount * ((int)EndEffect.Spell.Value * 0.01);
                    //600 / 10 = 60end
                    playerTarget.Endurance += (int)EndBonus;
                    playerTarget.Out.SendMessage("Your Efficient Endurance buff grants you " + EndBonus + " Endurance from the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
                }
            }

            GameSpellEffect flaskHeal = FindEffectOnTarget(target, "HealFlask");

            if (flaskHeal != null)
            {
                amount += (int)((amount * flaskHeal.Spell.Value) * 0.01);
            }

            int heal = target.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, amount);

            #region PVP DAMAGE

            long healedrp = 0;

            if (target.DamageRvRMemory > 0 &&
                (target is NecromancerPet &&
                 ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null ||
                 target is GamePlayer))
            {
                healedrp = (long)Math.Max(heal, 0);
                target.DamageRvRMemory -= healedrp;
            }

            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 is GamePlayer && target is NecromancerPet &&
                ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null ||
                target is GamePlayer && healedrp > 0)
            {
                int POURCENTAGE_SOIN_RP = ServerProperties.Properties.HEAL_PVP_DAMAGE_VALUE_RP; // ...% de bonus RP pour les soins effectués

                if (m_spell.Pulse == 0 && m_caster.CurrentRegionID != 242 &&                    // On Exclu zone COOP
                    m_spell.SpellType.ToLower() != "spreadheal" && target != m_caster &&
                    m_spellLine.KeyName != GlobalSpellsLines.Item_Spells &&
                    m_spellLine.KeyName != GlobalSpellsLines.Potions_Effects &&
                    m_spellLine.KeyName != GlobalSpellsLines.Combat_Styles_Effect &&
                    m_spellLine.KeyName != GlobalSpellsLines.Reserved_Spells)
                {
                    GamePlayer player = m_caster as GamePlayer;

                    if (player != null)
                    {
                        long Bonus_RP_Soin = Convert.ToInt64((double)healedrp * POURCENTAGE_SOIN_RP / 100.0);

                        if (Bonus_RP_Soin >= 1)
                        {
                            PlayerStatistics stats = player.Statistics as PlayerStatistics;

                            if (stats != null)
                            {
                                stats.RPEarnedFromHitPointsHealed += (uint)Bonus_RP_Soin;
                                stats.HitPointsHealed             += (uint)healedrp;
                            }

                            player.GainRealmPoints(Bonus_RP_Soin, false);
                            player.Out.SendMessage("Vous gagnez " + Bonus_RP_Soin.ToString() + " points de royaume pour avoir soigné un membre de votre royaume.", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        }
                    }
                }
            }

            #endregion PVP DAMAGE

            if (m_caster == target)
            {
                MessageToCaster("You heal yourself for " + heal + " hit points.", eChatType.CT_Spell);
                if (heal < amount)
                {
                    #region PVP DAMAGE

                    if (target is NecromancerPet &&
                        ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer)
                    {
                        if (target.DamageRvRMemory > 0)
                        {
                            target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps
                        }
                    }

                    #endregion PVP DAMAGE

                    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)
                {
                    #region PVP DAMAGE

                    if (target is NecromancerPet &&
                        ((target as NecromancerPet).Brain as IControlledBrain).GetPlayerOwner() != null || target is GamePlayer)
                    {
                        if (target.DamageRvRMemory > 0)
                        {
                            target.DamageRvRMemory = 0; //Remise a zéro compteur dommages/heal rps
                        }
                    }

                    #endregion PVP DAMAGE

                    MessageToCaster(target.GetName(0, true) + " is fully healed.", eChatType.CT_Spell);
                }
                if (heal > 0 && criticalvalue > 0)
                {
                    MessageToCaster("Your heal criticals for an extra " + criticalvalue + " amount of hit points!", eChatType.CT_Spell);
                }
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Heals hit points of one target and sends needed messages, no spell effects
        /// </summary>
        /// <param name="target"></param>
        /// <param name="amount">amount of hit points to heal</param>
        /// <returns>true if heal was done</returns>
        public virtual bool HealTarget(GameLiving target, double amount)
        {
            if (target == null || target.ObjectState != GameObject.eObjectState.Active)
            {
                return(false);
            }

            // we can't heal people we can attack
            if (GameServer.ServerRules.IsAllowedToAttack(Caster, target, true))
            {
                return(false);
            }

            // no healing of keep components
            if (target is Keeps.GameKeepComponent || target is Keeps.GameKeepDoor)
            {
                return(false);
            }

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

            if (target is GamePlayer gamePlayer && gamePlayer.NoHelp && Caster is GamePlayer)
            {
                // player not grouped, anyone else
                // player grouped, different group
                if (gamePlayer.Group == null ||
                    ((GamePlayer)Caster).Group == null ||
                    ((GamePlayer)Caster).Group != gamePlayer.Group)
                {
                    MessageToCaster("That player does not want assistance", eChatType.CT_SpellResisted);
                    return(false);
                }
            }

            // moc heal decrease
            double mocFactor = 1.0;
            MasteryofConcentrationEffect moc = Caster.EffectList.GetOfType <MasteryofConcentrationEffect>();

            if (moc != null)
            {
                if (Caster is GamePlayer playerCaster)
                {
                    MasteryofConcentrationAbility ra = playerCaster.GetAbility <MasteryofConcentrationAbility>();
                    if (ra != null)
                    {
                        mocFactor = ra.GetAmountForLevel(ra.Level) / 100.0;
                    }
                }

                amount = amount * mocFactor;
            }

            double criticalvalue  = 0;
            int    criticalchance = Caster.GetModified(eProperty.CriticalHealHitChance);
            double effectiveness  = 0;

            if (Caster is GamePlayer player1)
            {
                effectiveness = player1.Effectiveness + Caster.GetModified(eProperty.HealingEffectiveness) * 0.01;
            }

            if (Caster is GameNPC)
            {
                effectiveness = 1.0;
            }

            // USE DOUBLE !
            double cache = amount * effectiveness;

            amount = cache;

            if (Util.Chance(criticalchance))
            {
                double minValue = amount / 10;
                double maxValue = amount / 2 + 1;
                criticalvalue = Util.RandomDouble() * (maxValue - minValue) + minValue;
            }

            amount += criticalvalue;

            if (target is GamePlayer playerTarget)
            {
                GameSpellEffect HealEffect = FindEffectOnTarget(playerTarget, "EfficientHealing");
                if (HealEffect != null)
                {
                    double HealBonus = amount * ((int)HealEffect.Spell.Value * 0.01);
                    amount += (int)HealBonus;
                    playerTarget.Out.SendMessage($"Your Efficient Healing buff grants you a additional{HealBonus} in the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
                }

                GameSpellEffect EndEffect = FindEffectOnTarget(playerTarget, "EfficientEndurance");
                if (EndEffect != null)
                {
                    double EndBonus = amount * ((int)EndEffect.Spell.Value * 0.01);

                    // 600 / 10 = 60end
                    playerTarget.Endurance += (int)EndBonus;
                    playerTarget.Out.SendMessage($"Your Efficient Endurance buff grants you {EndBonus} Endurance from the Heal!", eChatType.CT_Spell, eChatLoc.CL_ChatWindow);
                }
            }

            GameSpellEffect flaskHeal = FindEffectOnTarget(target, "HealFlask");

            if (flaskHeal != null)
            {
                amount += (int)((amount * flaskHeal.Spell.Value) * 0.01);
            }

            // Scale spells that are cast by pets
            if (Caster is GamePet && !(Caster is NecromancerPet) && ServerProperties.Properties.PET_SCALE_SPELL_MAX_LEVEL > 0)
            {
                amount = ScalePetHeal(amount);
            }

            int heal = target.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, (int)Math.Round(amount));

            long healedrp = 0;

            if (target.DamageRvRMemory > 0 && (((target as NecromancerPet)?.Brain as IControlledBrain)?.GetPlayerOwner() != null || target is GamePlayer))
            {
                healedrp = Math.Max(heal, 0);
                target.DamageRvRMemory -= healedrp;
            }

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

                return(false);
            }

            if (Caster is GamePlayer && ((target as NecromancerPet)?.Brain as IControlledBrain)?.GetPlayerOwner() != null || target is GamePlayer && healedrp > 0)
            {
                int POURCENTAGE_SOIN_RP = ServerProperties.Properties.HEAL_PVP_DAMAGE_VALUE_RP; // ...% de bonus RP pour les soins effectués

                if (Spell.Pulse == 0 && Caster.CurrentRegionID != 242 &&                        // On Exclu zone COOP
                    Spell.SpellType.ToLower() != "spreadheal" && target != Caster &&
                    SpellLine.KeyName != GlobalSpellsLines.Item_Spells &&
                    SpellLine.KeyName != GlobalSpellsLines.Potions_Effects &&
                    SpellLine.KeyName != GlobalSpellsLines.Combat_Styles_Effect &&
                    SpellLine.KeyName != GlobalSpellsLines.Reserved_Spells)
                {
                    if (Caster is GamePlayer player)
                    {
                        long Bonus_RP_Soin = Convert.ToInt64((double)healedrp * POURCENTAGE_SOIN_RP / 100.0);

                        if (Bonus_RP_Soin >= 1)
                        {
                            if (player.Statistics is PlayerStatistics stats)
                            {
                                stats.RPEarnedFromHitPointsHealed += (uint)Bonus_RP_Soin;
                                stats.HitPointsHealed             += (uint)healedrp;
                            }

                            player.GainRealmPoints(Bonus_RP_Soin, false);
                            player.Out.SendMessage($"You earn {Bonus_RP_Soin} Realm Points for healing a member of your realm.", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                        }
                    }
                }
            }

            if (Caster == target)
            {
                MessageToCaster($"You heal yourself for {heal} hit points.", eChatType.CT_Spell);
                if (heal < amount)
                {
                    if (((target as NecromancerPet)?.Brain as IControlledBrain)?.GetPlayerOwner() != null || target is GamePlayer)
                    {
                        if (target.DamageRvRMemory > 0)
                        {
                            target.DamageRvRMemory = 0; // Remise a zéro compteur dommages/heal rps
                        }
                    }

                    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 {Caster.GetName(0, false)} for {heal} hit points.", eChatType.CT_Spell);
                if (heal < amount)
                {
                    if (((target as NecromancerPet)?.Brain as IControlledBrain)?.GetPlayerOwner() != null || target is GamePlayer)
                    {
                        if (target.DamageRvRMemory > 0)
                        {
                            target.DamageRvRMemory = 0; // Remise a zéro compteur dommages/heal rps
                        }
                    }

                    MessageToCaster($"{target.GetName(0, true)} is fully healed.", eChatType.CT_Spell);
                }

                if (heal > 0 && criticalvalue > 0)
                {
                    MessageToCaster($"Your heal criticals for an extra {criticalvalue} amount of hit points!", eChatType.CT_Spell);
                }
            }

            return(true);
        }