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)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
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
 


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