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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2009, 08:30 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default Rest State HP and MP Bonus

I don't have a chance today to check and see if this works in game, but if someone could look over the following code and see if it looks okay. There are two parts to this. One is for mobs, and the other is for players.

Main thing I am worried about is that I put things under the wrong classes/functions, as I don't know the code that well yet.

CLIENT CODE

Under Class Client in client.h,

Code:
ADD
sint16 restregenhp;
sint16 restregenmp;
sint32 restregenrate;

Timer rest_timer;
-------------------------

Under Class Client Constructor in client.cpp

Code:
ADD
sint16 restregenhp = 0;
sint16 restregenmp = 0;
sint32 restregenrate = 20;  //Defines a % bonus for hp and mana recovery at rest

Timer rest_timer(30000); //Sets up a Timer for rest bonuses
------------------------

Under Class Client in client_process.cpp

Code:
ADD
        if(IsEngaged())
        {
		    rest_timer.SetTimer(0);
            restregenhp = 0;
            restregenmp = 0;
        }		
		else
		{
            if (rest_timer.Check(FALSE) && (restregenrate > 0))
            {             
                restregenhp += (GetMaxHP() * restregenrate / 100);
                restregenmp += (GetMaxMana() * restregenrate / 100);
            }
            else
            {
                restregenhp = 0;
                restregenmp = 0;
            }
        }


BEFORE
        if (tic_timer.Check() && !dead) {  //From Process under client.cpp
			CalcMaxHP();
			CalcMaxMana();


REPLACE under Client::DoHPRegen()
	SetHP(GetHP() + total_regen);

WITH
	SetHP(GetHP() + total_regen + restregenhp);


REPLACE  under void Client::DoManaRegen()
	SetMana(GetMana() + regen);

WITH
	SetMana(GetMana() + regen + restregenmp);
--------------------------------------

END CLIENT STUFF

STARTING NPC/MOB STUFF

-------------------------------------

Under Class Mob : Public Entity in mob.h,

Code:
ADD
sint16 restregenhp;
sint16 restregenmp;
sint32 restregenrate;

Timer rest_timer;
-------------------------

Under Mob::Mob Constructor in mob.cpp,

Code:
ADD
sint16 restregenhp = 0;
sint16 restregenmp = 0;
sint32 restregenrate = 20;  //Defines a % bonus for hp and mana recovery at rest

Timer rest_timer(30000); //Sets up a Timer for rest bonuses
-------------------------

Under NPC::Process in npc.cpp,

Code:
REPLACE
		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()) {//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);
		}
    }



WITH

		if(oocregenrate > 0)  //should pull from Mob class
        {
			OOCRegen += GetMaxHP() * oocregen / 100;
		}
		
        //Below function checks to see if the rest timer has been reached.  If it has, then the rest HP amount is added.  
        //Current Edit by Drakelord.  Previous edit by Lieka.  
        if(!IsPet())
        {
            if(IsEngaged())
            {
                rest_timer.SetTimer(0);
                SetHP(GetHP() + hp_regen);
                SetMana(GetMana() + mana_regen + bonus);
            }
            else
            {
                if (rest_timer.Check(FALSE))
                    {
                        if(restregenrate >0)  //Sets the regeneration rate for while at rest, (drakelord)
		                {
                            restregenhp += (GetMaxHP() * restregenrate / 100);
                            restregenmp += (GetMaxMana() * restregenrate / 100);
                        }
                        
                        if (hp_regen > restregenhp)
                            SetHP(GetHP() + hp_regen);
                        else if ( OOCRegen > restregenhp)
                            SetHP(GetHP() + OOCRegen);
                        else
                            SetHP(GetHP() + restregen);
                      
                        if (mana_regen > restregenmp)
                            SetMana(GetMana() + mana_regen + bonus);
                        else
                            SetMana(GetMana() + restregenmp + bonus);
                    }
                else
                {
                    if (hp_regen > OOCRegen)
                        SetHP(GetHP() + hp_regen);
                    else 
                        SetHP(GetHP() + OOCRegen);
                        
                    SetMana(GetMana() + mana_regen + bonus);
                }
            }
        }
        else if(GetOwnerID() !=0)
        {
            if(!IsEngaged()) //pet
                SetHP(GetHP() + hp_regen + bonus + (GetLevel() / 5));
            else
                SetHP(GetHP() + hp_regen + bonus);
            SetMana(GetMana() + mana_regen + bouns);
        }
        else
        {
            SetHP(GetHP() + hp_regen);
            SetMana(GetMana() + mana_regen + bouns);
        }
        
        if (GetHP() > GetMaxHP())
            SetHP(GetMaxHP());
        if  (GetMana() > GetMaxMana())
            SetMana(GetMaxMana());
Reply With Quote
  #2  
Old 04-13-2009, 07:11 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Ok, I got the code working for clients, and it is tested and working.

I decided to add it to the rules set so that the regen % amount and time it takes before the rest counter starts is editable.

I will upload it to the SVN here shortly.
Reply With Quote
  #3  
Old 04-13-2009, 08:13 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

If you are going to put that on the SVN, you might want to set a rule to allow/disable it or adjust rates if needed. Just a suggestion anyway.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 04-13-2009, 08:28 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Quote:
Originally Posted by trevius View Post
If you are going to put that on the SVN, you might want to set a rule to allow/disable it or adjust rates if needed. Just a suggestion anyway.
As I said in my previous post, I made a rule for doing just that,

RestRegenPercent <--- Sets a percent for extra recovery
RestRegenTimeToActivate <---- Sets the wait timer before the recovery period begins

I've already hard coded them into the rules file. I'm just fixing one last bug before I upload
Reply With Quote
  #5  
Old 04-13-2009, 09:45 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

So, to disable it, I am guessing you can just set those rules to -1 or something?

Code:
RestRegenPercent <--- Sets a percent for extra recovery
RestRegenTimeToActivate <---- Sets the wait timer before the recovery period begins
I think being able to disable the feature is probably the main option some servers might want. I would definitely use it on Storm Haven, but I am sure some servers might not want to use it.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 04-13-2009, 09:55 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Quote:
Originally Posted by trevius View Post
So, to disable it, I am guessing you can just set those rules to -1 or something?

Code:
RestRegenPercent <--- Sets a percent for extra recovery
RestRegenTimeToActivate <---- Sets the wait timer before the recovery period begins
I think being able to disable the feature is probably the main option some servers might want. I would definitely use it on Storm Haven, but I am sure some servers might not want to use it.
Just set RestRegenPercent to 0. Then, no bonus. But don't use that code from my first post. It has changed a bit.
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 05:44 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