Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2008, 11:57 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default OOC Regen Enable/Disable

As a quick idea for a feature request I think that it might be good to have an option to disable the OOC Regen on an NPC. This could either be done by a setting in the NPC_Types table or even better would be via a quest command that could enable or disable it on the fly.

Here is the code that sets the OOC Regen. To disable it, we would just need to add in another check in the if statement to see if the NPC should use the OOC Regen bonus or not. If we were just making a setting in the NPC_Types table, then this could just check that setting in the table. But, if there was a way to make a quest command to change it on the fly, I think it would be best, but am not sure exactly how to do it. Maybe setting a new field in the NPC_Types table and then make a command that can change that field in real time to turn it on or off.

npc.cpp
Code:
		sint32 OOCRegen = 0;
		if(RuleI(NPC, OOCRegen) > 0){
			OOCRegen += GetMaxHP() * RuleI(NPC, OOCRegen) / 100;
			}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 10-07-2008, 12:28 AM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

don't we allready have a rule which set mobs OCC regen? If I set it to 0 - won't that work as disabled?

UPDATE: Ah I see - you want this to be done on the fly. could be usefull

PS: Its about time we add PLAYER OOC regeneration =)
Reply With Quote
  #3  
Old 10-07-2008, 12:39 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, that too does sound like a fun idea! Though, I would think it would need to be a bit more complex and scale up per level, but shouldn't be too hard to figure out a simple equation. I will see if I can write a rule or 2 for Player OOC regen. Maybe having 1 for the regen amount and another for level scaling. So, you could have it regen a level 1 character to full HPs in 15 seconds, but a level 70 character might take 1 minute or something if you wanted it to scale. Of course with an option to turn both off and use normal regen rates. That should be pretty easy code to write.

But, I would still like to see some ideas for how to disable OOC Regen on NPCs on the fly. There are only a few cases where I would want this, but for some advanced events, the fast OOC regen rates make the event harder to setup properly. For example, if you have a fight that once the NPC gets to 50% health, it goes ABH and whipes the aggro list and then players are supposed to do something else before the mob goes back to normal fight mode.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 10-07-2008, 01:11 AM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by trevius View Post
Ya, that too does sound like a fun idea! Though, I would think it would need to be a bit more complex and scale up per level, but shouldn't be too hard to figure out a simple equation. I will see if I can write a rule or 2 for Player OOC regen. Maybe having 1 for the regen amount and another for level scaling. So, you could have it regen a level 1 character to full HPs in 15 seconds, but a level 70 character might take 1 minute or something if you wanted it to scale. Of course with an option to turn both off and use normal regen rates. That should be pretty easy code to write.
.
yeah we prabobly want low lev folks to have almost no down time , but high end people should invest into some potions anyway (too bad we don't have Food the way its done in EQ2. If you never played EQ2, there food/drink are not just for keeping your char fed, they actualy give you mana/hp reg Out of COmbat over time and stats (regen effect halted during combat). Which makes far more sence than eq1 food which gives stats when it sits in your bag and does nothing- which result in evertone buying SINGLE best food/drink they can find and then force feeding themselves with junk food. In EQ2 you get stats/effect from food AFTER you eat it. Would be nice if our food/drink could be made the same way. It will also encourage people to seek and consume best food they can find for faster OCC regen. Note however that in EQ2 you don't have meditation and essentialy you do not realy regenerate mana during combat unless you have effecst like Clarity or +mana regen items. WHich is good cuase ecounters based on a chalange of defeating a mob with LIMITED mana/hp rather than relaying on your mana reg bonus, but once combat is over you have almost no down time (with good food/drink))


In main time, the OOC regen for players could be soemthing like (5+Level) per tick as a base with a Rule seting this from 100% and up (setting it to 0% will effectivly turn it to off)
Reply With Quote
  #5  
Old 10-07-2008, 01:30 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by ChaosSlayer View Post
PS: Its about time we add PLAYER OOC regeneration =)
Just a random thought, but couldn't we do this with player quests? Start a timer when out of combat, stop it while in combat, and when the timer comes up, either cast a spell, #heal, etc.

As far as per-mob Out of Combat regen, I think the best way to handle this might be to set this in the Mob class (make it sint32 oocregen or something like that), have it default to whatever the rule is set to, and make a function, say SetOOCRegen, to change it. Then, just wrap it into the quest code so you can trigger it via quest. That way, you can execute it on sub EVENT_SPAWN if you want it on by default instead of setting it in the database, and change it whenever/wherever you want. I think this should just about do it:
In zone/mob.h, around line 928, add
Code:
	sint16	hp_regen;
	sint16	mana_regen;
	sint32	oocregen; //Out of Combat Regen, % per tick
	void SetOOCRegen(sint32 newoocregen) {oocregen = newoocregen;}
In zone/mob.cpp, around line 29, add
Code:
#include "map.h"
#include "StringIDs.h"
#include "../common/rulesys.h"
and around line 206, add
Code:
	hp_regen = in_hp_regen;
	mana_regen = in_mana_regen;
	oocregen = RuleI(NPC, OOCRegen); //default Out of Combat Regen
Then we just need to get it into the quests. I think this should do it:
in zone/perl_mob.cpp, around line 5569, add
Code:
XS(XS_Mob_SetOOCRegen); /* prototype to pass -Wmissing-prototypes */
XS(XS_Mob_SetOOCRegen)
{
	dXSARGS;
	if (items != 2)
		Perl_croak(aTHX_ "Usage: Mob::SetOOCRegen(THIS, newoocregen)");
	{
		Mob *		THIS;
		sint32		newoocregen = (sint32)SvIV(ST(1));

		if (sv_derived_from(ST(0), "Mob")) {
			IV tmp = SvIV((SV*)SvRV(ST(0)));
			THIS = INT2PTR(Mob *,tmp);
		}
		else
			Perl_croak(aTHX_ "THIS is not of type Mob");
		if(THIS == NULL)
			Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");

		THIS->SetOOCRegen(newoocregen);
	}
	XSRETURN_EMPTY;
}
and around line 5813, add
Code:
		newXSproto(strcpy(buf, "ClearFeignMemory"), XS_Mob_ClearFeignMemory, file, "$");
		newXSproto(strcpy(buf, "SetOOCRegen"), XS_Mob_SetOOCRegen, file, "$$");
Now, you can change it using $Mob->SetOOCRegen(0). If you decide to try it out, let me know how it works.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki

Last edited by AndMetal; 10-07-2008 at 09:32 AM..
Reply With Quote
  #6  
Old 10-07-2008, 04:09 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

I just tried to compile the changes, and it looks like I didn't work the function correctly. If you put it around line 401 & add inline:
Code:
	inline virtual void SetHP(sint32 hp) { if (hp >= max_hp) cur_hp = max_hp; else cur_hp = hp;}
	bool ChangeHP(Mob* other, sint32 amount, int16 spell_id = 0, sint8 buffslot = -1, bool iBuffTic = false);
	inline void SetOOCRegen(sint32 newoocregen) {oocregen = newoocregen;}
	int MonkSpecialAttack(Mob* other, int8 skill_used);
	void TryBackstab(Mob *other);
it should compile fine (I did verify this).

Of course, I also forgot the most important part: adding the check on whether or not to calculate OOC regen:
in zone/npc.cpp, around line 558, change
Code:
		sint32 OOCRegen = 0;
		if(oocregen > 0){ //should pull from Mob class
			OOCRegen += GetMaxHP() * oocregen / 100;
			}
		//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() && oocregen > 0) //NPC out of combat
				SetHP(GetHP() + hp_regen + OOCRegen);
			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);
Verified that compiles also, just need to see if/how it works (if at all, lol).
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #7  
Old 10-07-2008, 05:27 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I think that code looks really good accept I don't think you want this:

npc.cpp
Code:
		//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() && oocregen > 0) //NPC out of combat
				SetHP(GetHP() + hp_regen + OOCRegen);
Because with that set, NPCs wouldn't regen at all out combat even with their natural regen setting unless oocregen was set. I think you would need to check which is higher and use that instead. Maybe something like this:

Code:
		//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
				if(hp_regen > OOCRegen)
					SetHP(GetHP() + hp_regen);
				else
					SetHP(GetHP() + OOCRegen);
			} 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);

		if(GetMana() < GetMaxMana()) {
			SetMana(GetMana()+mana_regen+bonus);
		}
I think that should work for almost any scenario. The only thing I can think of that might be worth considering would be a way to make an NPC stop regening completely when out of combat but still regen while in combat by the amount set in the npc_types table. But, if you absolutely had to do that, you could still do it via current quest commands fairly easily when needed.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #8  
Old 10-07-2008, 06:53 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I am not sure if the IsEngaged() check works for players, but if so, I think this code might work for character OOC regen:

client_process.cpp
Code:
void Client::DoHPRegen() {
	if(GetHP() < GetMaxHP()) {  //Don't do HP regen if HPs are full
		int32 level=GetLevel();
		int32 oochpregen = 0;
		int8 oocwaittime = 0;
		sint32 normal_regen = LevelRegen();
		sint32 item_regen = itembonuses.HPRegen;
		sint32 spell_regen = spellbonuses.HPRegen;
		sint32 total_regen = normal_regen + item_regen + spell_regen;
		if(IsEngaged()) {
			oochpregen = 0;
			oocwaittime = 0;
		}
		if(IsCasting() && RuleB(Character, OOCRegenCastCheck)) {
			oochpregen = 0;
			oocwaittime = 0;
		} else {
			if(oocwaittime >= RuleI(Character, OOCRegenWaitTicks)) {
				oochpregen += GetMaxHP() * RuleI(Character, OOCHPRegen) / 100;
				oochpregen -= level / RuleI(Character, MaxLevel) * oochpregen * RuleI(Character, OOCRegenLevelScale) / 100;
			} else
				oocwaittime = oocwaittime++;
		}
		total_regen = ((total_regen * RuleI(Character, HPRegenMultiplier)) / 100) + oochpregen;
		SetHP(GetHP() + total_regen);
		SendHPUpdate();
	}
}

void Client::DoManaRegen() {
	if(GetMana() < GetMaxMana()) { //Don't do mana regen if mana is full
		int32 level=GetLevel();
		int32 regen = 0;
		int8 oocwaittime = 0;
		int32 oocmanaregen = 0;
		if(IsEngaged()) {
			oocmanaregen = 0;
			oocwaittime = 0;
		}
		if(IsCasting() && RuleB(Character, OOCRegenCastCheck)) {
			oocmanaregen = 0;
			oocwaittime = 0;
		} else {
			if(oocwaittime >= RuleI(Character, OOCRegenWaitTicks)) {
				oocwaittime = oocwaittime++;
				oocmanaregen += GetMaxMana() * RuleI(Character, OOCManaRegen) / 100;
				oocmanaregen -= level / RuleI(Character, MaxLevel) * oocmanaregen * RuleI(Character, OOCRegenLevelScale) / 100;
			} else
				oocwaittime = oocwaittime++;
		}
		if (IsSitting() ||(GetHorseId() != 0)) {		//this should be changed so we dont med while camping, etc...
			if(HasSkill(MEDITATE)) {
				medding = true;
				regen = (((GetSkill(MEDITATE)/10)+(level-(level/4)))/4)+4;
				regen += spellbonuses.ManaRegen + itembonuses.ManaRegen;
				CheckIncreaseSkill(MEDITATE, -10);
			}
			else
				regen = 2+spellbonuses.ManaRegen+itembonuses.ManaRegen+(level/5);
		}
		else {
			medding = false;
			regen = 2+spellbonuses.ManaRegen+itembonuses.ManaRegen+(level/5);
		}

		//AAs
		regen += GetAA(aaMentalClarity) + GetAA(aaBodyAndMindRejuvenation);

		regen = ((regen * RuleI(Character, ManaRegenMultiplier)) / 100) + oocmanaregen;
		
		SetMana(GetMana() + regen);
		SendManaUpdatePacket();
	}
}
ruletypes.h
Code:
RULE_INT ( Character, OOCHPRegen, 0) //Regens this % of HPs per tick if not engaged with a mob (Disabled = 0)
RULE_INT ( Character, OOCManaRegen, 0) //Regens this % of Mana per tick if not engaged with a mob (Disabled = 0)
RULE_INT ( Character, OOCRegenLevelScale, 0) //OOC Regen will scale down per level (0 = scaling disabled, 1 = least scaling, 100 = most)
RULE_INT ( Character, OOCRegenWaitTicks, 0) //OOC Regen will wait this many ticks after combat before starting Out of Combat Regen
RULE_BOOL ( Character, OOCRegenCastCheck, false) //OOC Regen will be stopped if player is casting and this rule is set to true
Note that setting OOCRegenLevelScale to 100 will make it so that a max level character will not get any OOC Regen bonus at all, but a level 1 will still get almost the full bonus and as they level up the bonus will get less and less.

Optional SQL
Code:
Insert into rule_values values (0, 'Character:OOCHPRegen', 0);
Insert into rule_values values (0, 'Character:OOCManaRegen', 0);
Insert into rule_values values (0, 'Character:OOCRegenLevelScale', 0);
Insert into rule_values values (0, 'Character:OOCRegenWaitTicks', 0);
Insert into rule_values values (0, 'Character:OOCRegenCastCheck', false);
I will try this out and post back on how this and the code AndMetal posted work if at all
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 11-16-2008 at 04:15 PM..
Reply With Quote
  #9  
Old 10-07-2008, 08:44 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Good and bad news!

The code I wrote for player OOC HP and Mana regen does work, but it doesn't seem to actually check if you are engaged or not. So, the !IsEngaged check isn't working. If someone knows how to check that for players, then it should be able to be added and get this code working right away. It did compile just fine, but the way it is now, it will regen at the OOC rates whether you are engaged or not.

The good news is that AndMetal's code with my modifications works perfectly! Here is an example quest that I tested and that works exactly as intended:

Code:
#OOC Regen Test

sub EVENT_SAY {

if ($text=~ /Hail/i){
  quest::say("I can set the OOC regen rates to 0, 5, 10, or 20.  Just ask for the number and I will set it right now.");}

if ($text=~ /^0$/i ){
$npc->SetOOCRegen(0);
  quest::say("Setting OOC Regen to 0");}

if ($text=~ /5/i){
$npc->SetOOCRegen(5);
  quest::say("Setting OOC Regen to 5");}
  
if ($text=~ /10/i){
$npc->SetOOCRegen(10);
  quest::say("Setting OOC Regen to 10");}
  
if ($text=~ /20/i){
$npc->SetOOCRegen(20);
  quest::say("Setting OOC Regen to 20");}
                  
}
Using this quest, I was able to set the regen rates in real time while the mob was out of combat. If it is set to 0, the NPC will regen at whatever normal amount it is set to from the npc_types table. If it is in combat, the OOC code will not effect it at all. Note that it won't set the OOC higher than a certain amount. I tried setting it to 50 and it was the same as setting it to 0, so there may be some kind of cap.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-07-2008 at 04:51 PM..
Reply With Quote
  #10  
Old 10-07-2008, 10:36 AM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

PC OOC regen on live is done like so:

Take total mana pool and divide it by 30. That gives you three minutes to go to full mana from 0. There are 30 "ticks" in 3 minutes. Nice thing is it scales based on the size of the mana pool.
Reply With Quote
  #11  
Old 10-07-2008, 12:09 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Trev, for players you would prabobly need to check if player is on any mob hate list.

Andrew80k, 3 min for any player of any lev to get to FM is bad imho, it would be better for gameplay if high lev player ooc downtime would stil be greater than for low lev player. But I guess if we figure out player occ regen at all, the rules can handle the rest
Reply With Quote
  #12  
Old 10-07-2008, 12:11 PM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

Chaos, I think you'd be surprised at how long 3 minutes is in game. But indeed a rule for that would handle it. It's just a matter of figuring out the formula and applying the rule.
Reply With Quote
  #13  
Old 10-07-2008, 12:35 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by Andrew80k View Post
Chaos, I think you'd be surprised at how long 3 minutes is in game. But indeed a rule for that would handle it. It's just a matter of figuring out the formula and applying the rule.
considering that i used to sit on my but for 15-20 min back on live -3 min gona be a breeze =)

i havent played on eq1 when they implemented OCC regen, but on EQ2 under lev 5 you regenerate from almost 0 (hp and mana) to full in about 30 seconds, but it starts to slow down as you level (the numbers of hp and mana pool on eq2 are MUCH larger however. My lev 35 druid had like 2k hp and 4k mana and that was considered poor). I think at lev 80 it takes like 10 min.
But thats what hp/mn regene foods are for
ANorher thing that on eq2 there is no meditation (not during combat not ever) all classes melee or caster all regen hp and mana at same rate in and out of combat (not counting buffs and items of course)
Reply With Quote
  #14  
Old 10-07-2008, 05:12 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Woah, they put OOC regen on live? LOL, they might actually be getting smarter :P

Either way, with the rule, you will be able to easily turn it on or off, or adjust the rate you want them to regen at. By setting the rule to 1, you would regen 1% per tick. So, if you wanted to regen from 0 to full in 3 minutes, you would just take 180/6 = 30, so 30 ticks, and if you set your rules to 3 (3 X 30 = 90), it would be pretty close to 3 minutes to regen full HPs or Mana. I think it is nice to have the option to enable/disable and increase/decrease the OOC Regen rates.

As for the code to check if they are engaged, I see in command.cpp from the latest SVN that it uses:
Code:
c->IsEngaged()
To check something with Feign Death (I don't have the code handy right now to post the exact line).

I tried using something like that, but I don't know how to define "c" properly. I think if I could figure out how to do that, that it should probably work. Maybe something like this:

Code:
	if(c->IsEngaged())
		oochpregen = 0;
	else
		oochpregen += GetMaxHP() * RuleI(Character, OOCHPRegen) / 100;
I think that looks about right, but I would need someone to help me to define "c" so that it worked like it does in command.cpp. I am still a noob lol.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #15  
Old 10-07-2008, 05:26 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

Quote:
Originally Posted by trevius View Post
Woah, they put OOC regen on live? LOL, they might actually be getting smarter :P

Either way, with the rule, you will be able to easily turn it on or off, or adjust the rate you want them to regen at. By setting the rule to 1, you would regen 1% per tick. So, if you wanted to regen from 0 to full in 3 minutes, you would just take 180/6 = 30, so 30 ticks, and if you set your rules to 3 (3 X 30 = 90), it would be pretty close to 3 minutes to regen full HPs or Mana. I think it is nice to have the option to enable/disable and increase/decrease the OOC Regen rates.
yeah they added it 1 or 2 expansiosn ago (after Aniversary package i think)

Note important thing to allow a rule to set diffirent scaling for OCC regen, cuase just setting it at % rate would make OOC regen identical (in time) for all levels and all mana pools.
where my originaly proposed formula 5+level would slow down as you go up, to leave some room to force people to buy potions (which is good for economy)

another good thing would be be a rule to turn OFF meditation =)
The logical reason for this that if you have OOC regen, then casters also havign bonsu from meditation will get MASSIVE and unfair advantage over melees (specialy since in Emu you don't need to sit down to meditate - which means all the time figth goes on- you still meditating at full speed)
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 12:11 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