Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-20-2007, 08:30 AM
TheLieka
Developer
 
Join Date: Oct 2004
Location: THE ATL (wut wut)
Posts: 325
Default 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
__________________
Daxum



Former ServerOp - Vallon Zek / Tallon Zek Emu Server - Legit / Guild PvP - (2007 - 2011 RIP)
Reply With Quote
  #2  
Old 12-20-2007, 08:48 AM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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.
Reply With Quote
  #3  
Old 12-21-2007, 04:20 AM
TheLieka
Developer
 
Join Date: Oct 2004
Location: THE ATL (wut wut)
Posts: 325
Default

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

Dax
__________________
Daxum



Former ServerOp - Vallon Zek / Tallon Zek Emu Server - Legit / Guild PvP - (2007 - 2011 RIP)
Reply With Quote
  #4  
Old 12-26-2007, 05:41 AM
TheLieka
Developer
 
Join Date: Oct 2004
Location: THE ATL (wut wut)
Posts: 325
Default

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

Dax
__________________
Daxum



Former ServerOp - Vallon Zek / Tallon Zek Emu Server - Legit / Guild PvP - (2007 - 2011 RIP)
Reply With Quote
  #5  
Old 12-26-2007, 09:59 AM
TheLieka
Developer
 
Join Date: Oct 2004
Location: THE ATL (wut wut)
Posts: 325
Default

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
__________________
Daxum



Former ServerOp - Vallon Zek / Tallon Zek Emu Server - Legit / Guild PvP - (2007 - 2011 RIP)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:47 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3