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());