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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-03-2007, 12:50 PM
zydria
Fire Beetle
 
Join Date: Nov 2004
Posts: 12
Default Out of combat regen rates.

I wanted to add the increased out of combat regen rates to my server like live. I coded it to check if there were variables called HPRegen, MPRegen and ENRegen in the variables table, if not it just defaults to normal regen rates. So admins can set thier regen rates however they like. Here is the code if anyone wants to use it.

change
Code:
void Client::DoHPRegen() {
	sint32 normal_regen = LevelRegen();
	sint32 item_regen = itembonuses.HPRegen;
	sint32 spell_regen = spellbonuses.HPRegen;
	sint32 total_regen = normal_regen + item_regen + spell_regen;
	total_regen = (total_regen * RuleI(Character, HPRegenMultiplier)) / 100;
	SetHP(GetHP() + total_regen);
	SendHPUpdate();
}
to
Code:
void Client::DoHPRegen() {
	/* Out of combat HP Regen Multiplier added by Zydria */

	/* Out of combat hp regen rate */
	/* Create variable in db called HPRegen */
	float HPRegen;
	HPRegen = (float)1;
	char tmp[10];
	char *tmp2;

	sint32 normal_regen = LevelRegen();
	sint32 item_regen = itembonuses.HPRegen;
	sint32 spell_regen = spellbonuses.HPRegen;
	sint32 total_regen = normal_regen + item_regen + spell_regen;
	
	// if the player is in combat... normal hp regen
	if (IsEngaged())
		{
			total_regen = (total_regen * RuleI(Character, HPRegenMultiplier)) / 100;
		}
	// if they are out of combat... normal regen multiplied by variable HPRegen 
	// Default: Normal Regen
	else
		{
			if (database.GetVariable("HPRegen", tmp, 9)) 
			HPRegen = strtod((const char*)tmp, &tmp2);
			total_regen = ((total_regen * RuleI(Character, HPRegenMultiplier)) / 100) * HPRegen;
		}

	SetHP(GetHP() + total_regen);
	SendHPUpdate();
}
then change
Code:
void Client::DoManaRegen() {
	if (GetMana() >= max_mana)
		return;
	int32 level=GetLevel();
	int32 regen = 0;
	if (IsSitting()) {		//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);
	}
	regen += GetAA(aaMentalClarity);
	regen += GetAA(aaBodyAndMindRejuvenation);
	regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
	
	SetMana(GetMana() + regen);
	SendManaUpdatePacket();
}
to
Code:
void Client::DoManaRegen() {
	/* Out of combat Mana Regen Multiplier added by Zydria */

	// Out of combat mp regen rate
	// Create variable in db called MPRegen
	float MPRegen;
	MPRegen = (float)1;

	char tmp[10];
	char *tmp2;

	if (GetMana() >= max_mana)
		return;
	int32 level=GetLevel();
	int32 regen = 0;
	
	if (IsSitting()) {		//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);
	}
	regen += GetAA(aaMentalClarity);
	regen += GetAA(aaBodyAndMindRejuvenation);
	
	// if character is in combat
	if (IsEngaged())
		{	
			// normal regen
			regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
		}
	//if not
	else
		{
			//if mpregen is set in variable db to higher than 1
			if (database.GetVariable("MPRegen", tmp, 9)) 
			MPRegen = strtod((const char*)tmp, &tmp2);
			// regen at normal regen * mpregen value
			regen = ((regen * RuleI(Character, ManaRegenMultiplier)) / 100) * MPRegen;
		}
	
	SetMana(GetMana() + regen);
	SendManaUpdatePacket();
}
then change
Code:
void Client::DoEnduranceRegen()
{
	if(GetEndurance() >= GetMaxEndurance())
		return;

	int32 level=GetLevel();
	int32 regen = 0;

	regen = int(level*4/10) + 2;
	regen += spellbonuses.EnduranceRegen + itembonuses.EnduranceRegen;
	
	regen = (regen * RuleI(Character, EnduranceRegenMultiplier)) / 100;

	SetEndurance(GetEndurance() + regen);
}
to
Code:
void Client::DoEnduranceRegen()
{
	/* Out of combat Endurance Regen Multiplier added by Zydria */

	// Out of combat mp regen rate
	// Create variable in db called MPRegen
	float ENRegen;
	ENRegen = (float)1;

	char tmp[10];
	char *tmp2;

	if(GetEndurance() >= GetMaxEndurance())
		return;

	int32 level=GetLevel();
	int32 regen = 0;

	regen = int(level*4/10) + 2;
	regen += spellbonuses.EnduranceRegen + itembonuses.EnduranceRegen;
	// if player is in combat...
	if (IsEngaged()) 
		{
			// normal regen
			regen = (regen * RuleI(Character, EnduranceRegenMultiplier)) / 100;
		}
	// if not...
	else
		{
			// if ENRegen is set to higher than 1 in the variables db
			if (database.GetVariable("ENRegen", tmp, 9)) 
			ENRegen = strtod((const char*)tmp, &tmp2);
			// regen at normal end regen * ENRegen value
			regen = ((regen * RuleI(Character, EnduranceRegenMultiplier)) / 100) * ENRegen;
		}
	SetEndurance(GetEndurance() + regen);
}
then add the rows to your variables table
Code:
INSERT INTO `variables` (`varname`,`value`,`information`) VALUES ('HPRegen','1','Out of combat hit point regen is multiplied by this number. Default: 1');
INSERT INTO `variables` (`varname`,`value`,`information`) VALUES ('MPRegen','1','Out of combat mana regen is multiplied by this number. Default: 1');
INSERT INTO `variables` (`varname`,`value`,`information`) VALUES ('ENRegen','1','Out of combat endurance regen is multiplied by this number. Default: 1');
and set the values to whatever you would like them to be, they default to 1 (normal rates) and if the rows arent set in the variables table, then it also defaults to 1.


I also changed my server to allow players to meditate while standing. it is setup with a variable to turn it on or off too... if anyone wants it just use this code for the "void Client:oManaRegen() "instead of the above code...

Code:
void Client::DoManaRegen() {
	/* Out of combat Mana Regen Multiplier and Med while standing added by Zydria */

	// Out of combat mp regen rate
	// Create variable in db called MPRegen
	float MPRegen;
	MPRegen = (float)1;

	// Allow characters to meditate while standing up
	// create variabe in db called SitToMed, value: 1 = med while standing. 0 = required to sit
	int SitToMed;
	SitToMed = 0;

	char tmp[10];
	char *tmp2;

	if (GetMana() >= max_mana)
		return;
	int32 level=GetLevel();
	int32 regen = 0;
	
	// checks to see if player can med while standing
	if (database.GetVariable("SitToMed", tmp, 9)) 
	SitToMed = strtod((const char*)tmp, &tmp2);
	
	// if not, make sure there sitting
	if (SitToMed == 0){
	if (IsSitting()) {		//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);
	}
	}
	// if med while standing is enabled,
	else if (SitToMed == 1)
	{
		// always meditate
		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);
	}
	regen += GetAA(aaMentalClarity);
	regen += GetAA(aaBodyAndMindRejuvenation);
	
	// if character is in combat
	if (IsEngaged())
		{	
			// normal regen
			regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
		}
	//if not
	else
		{
			//if mpregen is set in variable db to higher than 1
			if (database.GetVariable("MPRegen", tmp, 9)) 
			MPRegen = strtod((const char*)tmp, &tmp2);
			// regen at normal regen * mpregen value
			regen = ((regen * RuleI(Character, ManaRegenMultiplier)) / 100) * MPRegen;
		}
	
	SetMana(GetMana() + regen);
	SendManaUpdatePacket();
}
and add the variable...
Code:
INSERT INTO `variables` (`varname`,`value`,`information`) VALUES ('SitToMed','0','0 = Player has to sit to med. 1 = Player meditates while standing. Default: 0');
by default it is set to 0, (player must sit to med) change it to 1 to allow them to med while standing.

This is my first contribution, as I am relativly new to the eqemu scene, I hope someone will get some use out of this, and if you find any problems with it, just let me know and i'll try and get it fixed...

Zydria

Last edited by zydria; 09-03-2007 at 08:52 PM..
Reply With Quote
  #2  
Old 09-03-2007, 01:18 PM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default

This looks interesting.

I am going to move this for now into "Custom Code" until KLS weighs in and where she thinks this ought to go. I can see the argument for this getting integrating into the official code...
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
Reply With Quote
  #3  
Old 09-03-2007, 01:27 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Character:HPRegenMultiplier, Character:ManaRegenMultiplier, and Character:EnduranceRegenMultiplier are all already rules...

Though, your mana regen addition may be able to be modified to allow people to med while on horses.

Last edited by cavedude; 09-03-2007 at 09:30 PM..
Reply With Quote
  #4  
Old 09-03-2007, 02:08 PM
zydria
Fire Beetle
 
Join Date: Nov 2004
Posts: 12
Default

I have tried to get those working, perhaps im not setting them properly, but they do not seem to have any effect on regen amounts. I have added them both though ingame commands and directly to the database, but each time i test it, my regen rates are just normal.
Reply With Quote
  #5  
Old 09-04-2007, 01:05 AM
soulshot
Hill Giant
 
Join Date: Jun 2006
Posts: 142
Default Feature

This was implemented in live and I think its a great feature. The longer you sit the more hp/mana you gain over time. I think the delay between combat and rest mode is something like 10-15 seconds isnt it?

-Mard
Reply With Quote
  #6  
Old 09-04-2007, 02:24 AM
zydria
Fire Beetle
 
Join Date: Nov 2004
Posts: 12
Default

Ok, I got the HPRegenMultiplier, ManaRegenMultiplier and EnduranceRegenMultiplier rules to work, so I change my code to work with those. The code now checks a variable to see if the server allows increase out of combat regen rates, if it does, it will increase the characters out of combat regen rate by the amount in the HP, Mana and EnduranceRegenMultiplier rules.
If the server is not using out of combat regen rates, but has the regenmultiplier rules set, then it will use them the way the worked before.

Here's the new code.

Code:
void Client::DoHPRegen() {
	/* Out of combat HP Regen Multiplier added by Zydria */

	//Set OOCRegen to default to off
	int OOCRegen;
	OOCRegen = 0;

	char tmp[10];
	char *tmp2;

	if (database.GetVariable("OOCRegen", tmp, 9)) 
	OOCRegen = strtod((const char*)tmp, &tmp2);

	sint32 normal_regen = LevelRegen();
	sint32 item_regen = itembonuses.HPRegen;
	sint32 spell_regen = spellbonuses.HPRegen;
	sint32 total_regen = normal_regen + item_regen + spell_regen;
	
	//if Out of Combat Regen is turned on
	if (OOCRegen = 1){

		// if the player is in combat... normal hp regen
		if (IsEngaged())
			{
				total_regen = total_regen / 100;
			}
		// if they are out of combat... normal regen multiplied by variable HPRegen 
		// Default: Normal Regen
		else
			{
				total_regen = (total_regen / 100) * RuleI(Character, HPRegenMultiplier);
			}
	} else {
		total_regen = (total_regen * RuleI(Character, HPRegenMultiplier)) / 100;
	}

	SetHP(GetHP() + total_regen);
	SendHPUpdate();
}

Code:
void Client::DoManaRegen() {
	/* Out of combat Mana Regen Multiplier added by Zydria */
	
	//Set out of combat regen to default to off
	int OOCRegen;
	OOCRegen = 0;

	char tmp[10];
	char *tmp2;

	if (database.GetVariable("OOCRegen", tmp, 9)) 
	OOCRegen = strtod((const char*)tmp, &tmp2);

	if (GetMana() >= max_mana)
		return;
	int32 level=GetLevel();
	int32 regen = 0;
	
	if (IsSitting()) {		//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);
	}
	regen += GetAA(aaMentalClarity);
	regen += GetAA(aaBodyAndMindRejuvenation);
	
	// if out of combat regen is turned on
	if (OOCRegen == 1) {

		// if character is in combat
		if (IsEngaged())
			{	
				// normal regen
				regen = regen / 100;
			}
		//if not
		else
			{
				// regen at normal regen * mpregen value
				regen = (regen / 100) * RuleI(Character, ManaRegenMultiplier);
			}
	
	} else {
			regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
		}
	
	
	SetMana(GetMana() + regen);
	SendManaUpdatePacket();
}


Code:
void Client::DoEnduranceRegen()
{
	/* Out of combat Endurance Regen Multiplier added by Zydria */

	//Set out of combat regen to default to off
	int OOCRegen;
	OOCRegen = 0;

	char tmp[10];
	char *tmp2;

	if (database.GetVariable("OOCRegen", tmp, 9)) 
	OOCRegen = strtod((const char*)tmp, &tmp2);

	if(GetEndurance() >= GetMaxEndurance())
		return;

	int32 level=GetLevel();
	int32 regen = 0;

	regen = int(level*4/10) + 2;
	regen += spellbonuses.EnduranceRegen + itembonuses.EnduranceRegen;

	//if out of combar regen is on.
	if (OOCRegen == 1){
		// if player is in combat...
		if (IsEngaged()) 
			{
				// normal regen
				regen = regen / 100;
			}
		// if not...
		else
			{
				// regen at normal end regen * ENRegen value
				regen = (regen / 100) * RuleI(Character, EnduranceRegenMultiplier);
			}
	} else {
		regen = (regen * RuleI(Character, EnduranceRegenMultiplier)) / 100;
	}


	SetEndurance(GetEndurance() + regen);
}

and insert the variable in the db
Code:
INSERT INTO `variables` (`varname`,`value`,`information`) VALUES ('OOCRegen','0','Out Of Combat Regen Multiplier. If set to 1 characters hp, mana and endurance will regen at regular speed multiplied by the values entered in the HPRegenMultiplier, ManaRegenMultiplier and EnduranceRegenMultiplier rules. Default is 0 (Off), you must set the above rules or players will only recieve regular regen rates');
Be sure to setup the Rules, HPRegenMultiplier, ManaRegenMultiplier and EnduranceRegenMultiplier with a value higher than 1 to recieve regen bonus rates.

By default, the out of combat regen is turned off, so change the variable OOCRegen to 1 to turn it on


Zydria
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:39 PM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3