EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   NPC Out of Combat Regen (https://www.eqemulator.org/forums/showthread.php?t=24003)

TheLieka 12-20-2007 08:30 AM

NPC Out of Combat Regen
 
Request from thread:
http://www.eqemulator.net/forums/showthread.php?t=23824

On Live NPCs regen at a much higher rate when they are out of combat, on Emu they regen at the same rate, inside or outside of combat. Here is my fix for that.

change .\zone\npc.cpp (inside the bool NPC::Process() function)
Code:

                if(GetHP() < GetMaxHP()) {
                        if(GetOwnerID()!=0 && !IsEngaged()) //pet
                                SetHP(GetHP()+hp_regen+bonus+(GetLevel()/5));
                        else
                                SetHP(GetHP()+hp_regen+bonus);
                }

to
Code:

                float MobOOCRegen = 0;
                char val[10] = {0};
                if(database.GetVariable("NPCOOCRegen", val, 10)){
                MobOOCRegen = atoi(val);
                MobOOCRegen *= 0.01;
                MobOOCRegen *= GetMaxHP();
                }
                //Lieka Edit:  Fixing NPC regen.  NPCs should regen to full during a set duration, not based on their HPs.  Increase NPC's HPs by % of total HPs / tick.
                if((GetHP() < GetMaxHP()) && !IsPet()) {
                        if(!IsEngaged()) //NPC out of combat
                                SetHP(GetHP() + hp_regen + MobOOCRegen);
                        else
                                SetHP(GetHP()+hp_regen);
                } else if(GetHP() < GetMaxHP() && IsPet()) {
                        if(!IsEngaged()) //pet
                                SetHP(GetHP()+hp_regen+bonus+(GetLevel()/5));
                        else
                                SetHP(GetHP()+hp_regen+bonus);
                } else SetHP(GetHP()+hp_regen);

Required SQL:
Code:

insert into `variables` values ('NPCOOCRegen', 0, 'Out of Combat Regen % for NPCs. 0 to disable.', '2007-12-20 12:00:00');
Set the Variable "NPCOOCRegen" to whatever percentage of NPC health should be regenerated per tick. By default it is turned off (with this SQL insert).

Dax

cavedude 12-20-2007 08:48 AM

This is a much needed fix! Thanks! The only issue, could you scratch the variable and make it a rule instead? The common trend is that we are trying to do away with the variables table in favor of the superior rules system. The reason being rules can be loaded on-demand and don't require a server reboot, unlike most variables.

TheLieka 12-21-2007 04:20 AM

I'll take a look at the coding for the rules system and see what I can do.

Dax

TheLieka 12-26-2007 05:41 AM

Got tied up for the holidays (of course), I look into this today.

Dax

TheLieka 12-26-2007 09:59 AM

Ok, for a rules based fix:

add the line in red to .\common\ruletypes.h
Code:

RULE_CATEGORY( NPC )
RULE_INT ( NPC, MinorNPCCorpseDecayTimeMS, 450000 ) //level<55
RULE_INT ( NPC, MajorNPCCorpseDecayTimeMS, 1500000 ) //level>=55
RULE_BOOL (NPC, UseItemBonusesForNonPets, true)
RULE_REAL ( NPC, OOCRegen, 0 ) //Lieka Edit:  NPC Out of Combat Regen Percentage Per Tick
RULE_CATEGORY_END()

change these lines in the bool NPC::Process() function in .\zone\npc.cpp
Code:

                if(GetHP() < GetMaxHP()) {
                        if(GetOwnerID()!=0 && !IsEngaged()) //pet
                                SetHP(GetHP()+hp_regen+bonus+(GetLevel()/5));
                        else
                                SetHP(GetHP()+hp_regen+bonus);
                }

to

Code:

        float NPCOOCRegen = 0;
        if(RuleR(NPC, OOCRegen) >= 0){
                NPCOOCRegen += RuleR(NPC, OOCRegen);
                NPCOOCRegen *= 0.01;
                NPCOOCRegen *= GetMaxHP();
                }
                //Lieka Edit:  Fixing NPC regen.  NPCs should regen to full during a set duration, not based on their HPs.  Increase NPC's HPs by % of total HPs / tick.
                if((GetHP() < GetMaxHP()) && !IsPet()) {
                        if(!IsEngaged()) //NPC out of combat
                                SetHP(GetHP() + hp_regen + NPCOOCRegen);
                        else
                                SetHP(GetHP()+hp_regen);
                } else if(GetHP() < GetMaxHP() && GetOwnerID() !=0) {
                        if(!IsEngaged()) //pet
                                SetHP(GetHP()+hp_regen+bonus+(GetLevel()/5));
                        else
                                SetHP(GetHP()+hp_regen+bonus);
                } else SetHP(GetHP()+hp_regen);

Required SQL:

Code:

insert into rule_values values (0, 'NPC:OOCRegen', 0);
The NPC Out of Combat Regen correction is disabled by default. The NPC will regen the rule value percentage of hps per tick once the rule is set. (e.g. NPC:OOCRegen to 5, and the mob will regen 5% health per tick when out of combat).

Dax


All times are GMT -4. The time now is 04:28 AM.

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