EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   COMMITTED: SE_MaxHPChange (https://www.eqemulator.org/forums/showthread.php?t=31674)

Caryatis 07-16-2010 01:24 AM

COMMITTED: SE_MaxHPChange
 
Used in the monk 2.0 epic click Peace of the Disciple and everybody's favorite MPG trial Test of Efficiency, also used in some player spells like Wake of Atrophy.

code...

spell effects
Code:

Index: spell_effects.cpp
===================================================================
--- spell_effects.cpp        (revision 1602)
+++ spell_effects.cpp        (working copy)
@@ -2812,6 +2812,7 @@
                        case SE_LimitCastTime:
                        case SE_NoCombatSkills:
                        case SE_TriggerOnCast:
+                        case SE_MaxHPChange:
                        {
                                break;
                        }

mob.h
Code:

Index: mob.h
===================================================================
--- mob.h        (revision 1602)
+++ mob.h        (working copy)
@@ -582,7 +582,7 @@
 
        inline sint32        GetHP()                        const { return cur_hp; }
        inline sint32        GetMaxHP()                const { return max_hp; }
-        virtual inline sint32        CalcMaxHP()                { return max_hp = (base_hp  + itembonuses.HP + spellbonuses.HP); }
+        virtual sint32        CalcMaxHP();
        float GetWalkspeed() const { return(_GetMovementSpeed(-47)); }
        float GetRunspeed() const { return(_GetMovementSpeed(0)); }
        float GetBaseRunspeed() const { return runspeed; }

mob.cpp
Code:

Index: mob.cpp
===================================================================
--- mob.cpp        (revision 1602)
+++ mob.cpp        (working copy)
@@ -596,6 +596,25 @@
        return max_mana;
 }
 
+sint32 Mob::CalcMaxHP()
+{
+
+        max_hp = (base_hp  + itembonuses.HP + spellbonuses.HP);
+       
+        int slot = GetBuffSlotFromType(SE_MaxHPChange);
+        if(slot >= 0)
+        {
+                for(int i = 0; i < EFFECT_COUNT; i++)
+                {
+                        if (spells[buffs[slot].spellid].effectid[i] == SE_MaxHPChange)
+                        {
+                                max_hp += max_hp * spells[buffs[slot].spellid].base[i] / 10000;
+                        }
+                }
+        }
+        return max_hp;
+}
+
 char Mob::GetCasterClass() const {
        switch(class_)
        {

client mods.cpp
Code:

Index: client_mods.cpp
===================================================================
--- client_mods.cpp        (revision 1602)
+++ client_mods.cpp        (working copy)
@@ -240,6 +240,18 @@
 
        max_hp += GroupLeadershipAAHealthEnhancement();
       
+        int slot = GetBuffSlotFromType(SE_MaxHPChange);
+        if(slot >= 0)
+        {
+                for(int i = 0; i < EFFECT_COUNT; i++)
+                {
+                        if (spells[buffs[slot].spellid].effectid[i] == SE_MaxHPChange)
+                        {
+                                max_hp += max_hp * spells[buffs[slot].spellid].base[i] / 10000;
+                        }
+                }
+        }
+       
        if (cur_hp > max_hp)
                cur_hp = max_hp;
        return max_hp;


AndMetal 07-26-2010 01:02 PM

Wouldn't it make more sense to calculate this as a Spell Bonus in Mob::ApplySpellBonuses()?

Mob::CalcSpellBonuses() iterates through the spell slots (including any ones that have been added by AAs) already, so it seems redundant to do it again when calling GetBuffSlotFromType() and then iterating through the spell's effects. It would also allow for stacking (if able) of the spell effects since GetBuffSlotFromType() only gets the first slot.

Caryatis 07-26-2010 08:22 PM

Most likely there are better ways to do some of these effects as my understanding of the code isnt very comprehensive yet.

Caryatis 11-04-2010 07:03 PM

Updated this code like AndMetal suggested, so it uses the bonuses code and can stack, etc.

Code:

Index: bonuses.cpp
===================================================================
--- bonuses.cpp        (revision 1713)
+++ bonuses.cpp        (working copy)
@@ -1206,8 +1206,11 @@
                                        newbon->Accuracy = effect_value;
                                break;
                        }
-
-                               
+                        case SE_MaxHPChange:
+                        {
+                                newbon->MaxHPChange += effect_value;
+                                break;
+                        }
                }
        }
 }
Index: client_mods.cpp
===================================================================
--- client_mods.cpp        (revision 1713)
+++ client_mods.cpp        (working copy)
@@ -240,17 +240,7 @@
 
        max_hp += GroupLeadershipAAHealthEnhancement();
       
-        int slot = GetBuffSlotFromType(SE_MaxHPChange);
-        if(slot >= 0)
-        {
-                for(int i = 0; i < EFFECT_COUNT; i++)
-                {
-                        if (spells[buffs[slot].spellid].effectid[i] == SE_MaxHPChange)
-                        {
-                                max_hp += max_hp * spells[buffs[slot].spellid].base[i] / 10000;
-                        }
-                }
-        }
+        max_hp += max_hp * (spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000;
 
        if (cur_hp > max_hp)
                cur_hp = max_hp;
Index: mob.cpp
===================================================================
--- mob.cpp        (revision 1713)
+++ mob.cpp        (working copy)
@@ -605,19 +605,10 @@
 sint32 Mob::CalcMaxHP()
 {
 
-        max_hp = (base_hp  + itembonuses.HP + spellbonuses.HP);
+        max_hp = (base_hp + itembonuses.HP + spellbonuses.HP);
       
-        int slot = GetBuffSlotFromType(SE_MaxHPChange);
-        if(slot >= 0)
-        {
-                for(int i = 0; i < EFFECT_COUNT; i++)
-                {
-                        if (spells[buffs[slot].spellid].effectid[i] == SE_MaxHPChange)
-                        {
-                                max_hp += max_hp * spells[buffs[slot].spellid].base[i] / 10000;
-                        }
-                }
-        }
+        max_hp += max_hp * (spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000;
+       
        return max_hp;
 }
 
Index: mob.h
===================================================================
--- mob.h        (revision 1713)
+++ mob.h        (working copy)
@@ -275,6 +275,7 @@
 
        sint8 HundredHands;                //extra haste, stacks with all other haste  i
        sint8 MeleeLifetap;
+        sint16 MaxHPChange;
        int XPRateMod;
 
        sint8        Packrat;        //weight reduction for items, 1 point = 10%



All times are GMT -4. The time now is 12:46 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.