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