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: Slow Mitigation (https://www.eqemulator.org/forums/showthread.php?t=28240)

drakelord 05-17-2009 09:28 AM

COMMITTED: Slow Mitigation
 
As requested, I have setup slow mitigation for mobs. I felt bad last time I submitted and Derision had to go back and change a bunch of things, so I made sure everything looked a lot cleaner this time. I have also been studying the emu code a bit more, so hopefully this submission doesn't need any changes.

~~Fully tested. Compiled and works in game.~~

How it works: Mobs have a new added column under npc_types that is a float. 0 = 0%, 1 = 100%, .5 = 50%, etc. With the way the code currently is, if you try to go past 100%, it will default to 100. However, this can easily be changed for anyone who wants to say, penalize a party for trying to slow a mob by hasting it instead. And for those that are worried, this defaults to 0 for all NPCs unless you change it in the database. *Pokes Trev*

Code time~
===============================
----SQL CHANGES----
Code:

ALTER TABLE `npc_types` ADD COLUMN `slow_mitigation` FLOAT UNSIGNED NOT NULL DEFAULT 0;
----FILE CHANGES----
Code:

mob.h
--------

REPLACE
                int8        in_qglobal
WITH
                int8        in_qglobal,
                float        in_slow_mitigation //Drakelord:  Allows for mobs to mitigate how much they are slowed. 
AFTER
                sint16        in_hp_regen,
                sint16        in_mana_regen,


ADD
        float        slow_mitigation; //Allows for a slow mitigation based on a % in decimal form.  IE, 1 = 100% mitigation, .5 is 50%
AFTER
        sint32        max_mana;
        sint16        hp_regen;
        sint16        mana_regen;
        sint32        oocregen; //Out of Combat Regen, % per tick

Code:

mob.cpp
--------

REPLACE
                int8        in_qglobal
WITH
                int8        in_qglobal,
                float        in_slow_mitigation //Drakelord:  Allows for mobs to mitigate how much they are slowed.
AFTER
                int8  in_see_improved_hide,
                sint16 in_hp_regen,
                sint16 in_mana_regen,


ADD
        slow_mitigation = in_slow_mitigation;
AFTER
        hp_regen = in_hp_regen;
        mana_regen = in_mana_regen;
        oocregen = RuleI(NPC, OOCRegen); //default Out of Combat Regen

Code:

zonedb.cpp
---------

REPLACE
                        "npc_types.Accuracy"
WITH
                        "npc_types.Accuracy,"
                        "npc_types.slow_mitigation";
AFTER
                        "npc_types.see_improved_hide,"
                        "npc_types.ATK,"

ADD
                                tmpNPCType->slow_mitigation = atoi(row[r++]);
AFTER
                                tmpNPCType->see_improved_hide = atoi(row[r++])==0?false:true;
                                tmpNPCType->ATK = atoi(row[r++]);
                                tmpNPCType->accuracy_rating = atoi(row[r++]);

Code:

zonedump.h
--------

ADD
        float        slow_mitigation; //Drakelord:  Slow mitigation % in decimal form.
AFTER
        int                accuracy_rating;  //10 = 1% accuracy
        bool        findable;                //can be found with find command
        bool        trackable;

Code:

npc.cpp
---------

REPLACE
          d->qglobal ),
WITH
          d->qglobal,
          d->slow_mitigation ),
AFTER
          d->see_improved_hide,
          d->hp_regen,
          d->mana_regen,

Code:

client.cpp
----------

REPLACE
        0        // qglobal
WITH
        0,        // qglobal
        0 //Drakelord:  slow_mitigation
AFTER
        0xff,        // AA Title
        0,        // see_invis
        0,        // see_invis_undead
        0,
        0,
        0,
        0,

Code:

beacon.cpp
------------

REPLACE
(
        NULL, NULL, 0, 0, 0, INVISIBLE_MAN, 0, BT_NoTarget, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
),
WITH
(
        NULL, NULL, 0, 0, 0, INVISIBLE_MAN, 0, BT_NoTarget, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
),
AFTER
Beacon::Beacon(Mob *at_mob, int lifetime)
:Mob

Code:

PlayerCorpse.cpp
----------------

REPLACE
Corpse::Corpse(NPC* in_npc, ItemList* in_itemlist, int32 in_npctypeid, const NPCType** in_npctypedata, int32 in_decaytime)
// vesuvias - appearence fix
 : Mob("Unnamed_Corpse","",0,0,in_npc->GetGender(),in_npc->GetRace(),in_npc->GetClass(),BT_Humanoid//bodytype added
      ,in_npc->GetDeity(),in_npc->GetLevel(),in_npc->GetNPCTypeID(),in_npc->GetSize(),0,
        in_npc->GetHeading(),in_npc->GetX(),in_npc->GetY(),in_npc->GetZ(),0,
        in_npc->GetTexture(),in_npc->GetHelmTexture(),
        0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0xff,0,0,0,0,0,0,0),
        corpse_decay_timer(in_decaytime),
        corpse_delay_timer(RuleI(NPC, CorpseUnlockTimer)),
        corpse_graveyard_timer(0)
WITH
 : Mob("Unnamed_Corpse","",0,0,in_npc->GetGender(),in_npc->GetRace(),in_npc->GetClass(),BT_Humanoid//bodytype added
      ,in_npc->GetDeity(),in_npc->GetLevel(),in_npc->GetNPCTypeID(),in_npc->GetSize(),0,
        in_npc->GetHeading(),in_npc->GetX(),in_npc->GetY(),in_npc->GetZ(),0,
        in_npc->GetTexture(),in_npc->GetHelmTexture(),
        0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0xff,0,0,0,0,0,0,0,0),
        corpse_decay_timer(in_decaytime),
        corpse_delay_timer(RuleI(NPC, CorpseUnlockTimer)),
        corpse_graveyard_timer(0)
AFTER
// To be used on NPC death and ZoneStateLoad
// Mongrel: added see_invis and see_invis_undead


REPLACE
        0        // qglobal
WITH
        0,        // qglobal
        0 //Drakelord:  slow_mitigation
AFTER
        client->GetPP().drakkin_heritage,
        client->GetPP().drakkin_tattoo,
        client->GetPP().drakkin_details,
        0,
        0xff,        // aa title
        0,
        0,
        0,
        0,
        0,
        0,

REPLACE
Corpse::Corpse(int32 in_dbid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard)
 : Mob("Unnamed_Corpse","",0,0,in_gender, in_race, in_class, BT_Humanoid, in_deity, in_level,0, in_size, 0, in_heading, in_x, in_y, in_z,0,in_texture,in_helmtexture,
        0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0xff,
        0,0,0,0,0,0,0),
WITH
Corpse::Corpse(int32 in_dbid, int32 in_charid, char* in_charname, ItemList* in_itemlist, int32 in_copper, int32 in_silver, int32 in_gold, int32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, int8 in_gender, int16 in_race, int8 in_class, int8 in_deity, int8 in_level, int8 in_texture, int8 in_helmtexture,int32 in_rezexp, bool wasAtGraveyard)
 : Mob("Unnamed_Corpse","",0,0,in_gender, in_race, in_class, BT_Humanoid, in_deity, in_level,0, in_size, 0, in_heading, in_x, in_y, in_z,0,in_texture,in_helmtexture,
        0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0xff,
        0,0,0,0,0,0,0,0),
AFTER
// To be called from LoadFromDBData
// Mongrel: added see_invis and see_invis_undead

Code:

bonuses.cpp
----------------------

REPLACE

                        case SE_AttackSpeed:
                        {
                                if ((effect_value - 100) > 0) { // Haste
                                        if (newbon->haste < 0) break; // Slowed - Don't apply haste
                                        if ((effect_value - 100) > newbon->haste) {
                                                newbon->haste = effect_value - 100;
                                        }
                                } else if ((effect_value - 100) < 0) { // Slow
                                        if ((effect_value - 100) < newbon->haste) {
                                                newbon->haste = effect_value - 100;
                                        }
                                }
                                break;
                        }



WITH
                        case SE_AttackSpeed:
                        {
                                if ((effect_value - 100) > 0) // Haste
                                {
                                        if (newbon->haste < 0)
                                                break; // Slowed - Don't apply haste
                                        if ((effect_value - 100) > newbon->haste)
                                        {
                                                newbon->haste = effect_value - 100;
                                        }
                                }
                                else if ((effect_value - 100) < 0) // Slow
                                { 
                                        //Slow Mitigation works by taking the amount that would be slowed, and adding a multiplied version of the difference.
                                        int new_effect_value;
                                        float slow_amount_mitigated = 100 - effect_value; //Gives us a value that actually represents the slow amount.
                                        slow_amount_mitigated = slow_amount_mitigated * this->slow_mitigation;  // Use *= if you really want?
                                        new_effect_value = effect_value + slow_amount_mitigated;
                                        if (new_effect_value > 100)
                                                new_effect_value = 100;
                                        if ((new_effect_value - 100) < newbon->haste)
                                        {
                                                newbon->haste = new_effect_value - 100;
                                        }
                                }
                                break;
                        }


trevius 05-20-2009 11:47 PM

I hate when forums get marked as read just because I didn't refresh for long enough! I want to read them all myself, not have them automark as read lol. I didn't see this until now. Thanks for the submission. Hopefully someone can get this tested and added on the SVN soon. If not, I will try to get to it at some point. This definitely has potential for making more customizable encounters. It will be nice to allow slows without making the fight too overly easy.

Did you poke me because you thought I would be worried about this getting added, or because I added something recently that didn't default to 0? Just curious lol. If I added something that doesn't default to 0, it should get fixed!

drakelord 05-21-2009 11:25 AM

Quote:

Originally Posted by trevius (Post 170209)
I hate when forums get marked as read just because I didn't refresh for long enough! I want to read them all myself, not have them automark as read lol. I didn't see this until now. Thanks for the submission. Hopefully someone can get this tested and added on the SVN soon. If not, I will try to get to it at some point. This definitely has potential for making more customizable encounters. It will be nice to allow slows without making the fight too overly easy.

Did you poke me because you thought I would be worried about this getting added, or because I added something recently that didn't default to 0? Just curious lol. If I added something that doesn't default to 0, it should get fixed!

Poked you because with my last submission, your biggest question was, "does this default to 0?" :)

trevius 06-10-2009 06:14 PM

Did any of the other devs ever get a chance to look at this? Sounds like it should be a pretty good change. Bumping this so it doesn't get forgotten. I might try to add it sometime if I get time to do so. Just always so busy with other stuff that it is sometimes hard to find the time to add in submissions and fully test them.

drakelord 06-29-2009 08:51 PM

Since it has been so long, it will probably have to be redone a bit now to be honest, :/.

trevius 06-29-2009 09:28 PM

Yeah, it will probably need minor adjustments due to changes with the npc_types table. But, it shouldn't be hard to adjust for I think. I just still haven't had the time to get to this. It would take a while to get it added in, fully tested and make sure the default doesn't affect existing encounters at all.

jenco420 06-29-2009 11:12 PM

if i remember correctly players where told if mobs mitigated slow. Something to the extent of "Your spell was moslty successful" if i remember correctly. And thanks been waiting on this!

gaeorn 07-05-2009 01:08 PM

This has been added to SVN. It still does not give a message if slow is mitigated.

drakelord 07-07-2009 12:36 PM

If that feature is live like, I can add it in shortly. Just have to send a message really to the caster with the reply.

Shendare 07-07-2009 12:55 PM

My memory suggests that there were two mitigation messages:

Your slow was mostly successful.

Your slow was partially successful.

I don't know what mitigation percentage levels determined which of the two messages was sent, however. Whether 1-33% mitigation sending "mostly" and 34%+ "partially", or 1-50% "mostly" and 51%+ "partially", or something else, no clue.

Dibalamin 07-07-2009 01:51 PM

Think of it this way

Immune ---> Partially ---> Mostly ----> Fully
0 ---> 25% of effect --- > Half Effect ---> Full Effect

gaeorn 07-07-2009 02:49 PM

I found this in eqstr_us.txt:

9029 Your spell was mostly successful.
9030 Your spell was partially successful.
9031 Your spell was slightly successful.
9032 Your spell may have had the opposite effect of what you desired.

Shendare 07-07-2009 02:58 PM

Aha, very good! Looks like increments of 25% perhaps?

Mitigate 25% - Mostly successful
Mitigate 50% - Partially successful
Mitigate 75% - Slightly successful
Mitigate 100% - Immune
Mitigate 125% - Opposite Effect (haste 25% instead of slow)

gaeorn 07-07-2009 03:26 PM

I was thinking increments of 33.3%

0% mitigated = no message
0.1-33.3% mitigated = mostly
33.4-66.6% mitigated = partially
66.7-99.9% mitigated = slightly
100% mitigated = immune
100.1% and up mitigated = opposite effect

Shendare 07-07-2009 03:40 PM

Good call, good call. That looks perfectly logical to me.


All times are GMT -4. The time now is 10:12 PM.

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