|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
 |
|
 |

04-12-2009, 08:30 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
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());
|
 |
|
 |

04-13-2009, 07:11 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
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.
|

04-13-2009, 08:13 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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.
|

04-13-2009, 08:28 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Quote:
Originally Posted by trevius
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
|

04-13-2009, 09:45 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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.
|

04-13-2009, 09:55 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Quote:
Originally Posted by trevius
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.
|

04-13-2009, 10:06 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Also, just a question; Are you removing the current Out of Combat Regen functionality? Currently, there is already a rule for NPCs to regen when they are out of combat.
If you are removing the current rule for it, you might want to make separate rules for players and NPCs.
Also, if you are removing the current rule for NPC OOC Regen, please submit the SQL to remove the rule from the rule_values table and add in the new ones you are making.
Sorry, to be bugging you about this. I don't know who you are, and I know the number of people with direct access to update the SVN is very limited, so I am just not sure how familiar you are with the process. I am familiar with all of the people who have access to make commits to the SVN, so maybe you are one of them using another forum account? If you aren't one of them, then you won't be able to commit the code yourself.
|
 |
|
 |
 |
|
 |

04-13-2009, 10:37 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Quote:
Originally Posted by trevius
Also, just a question; Are you removing the current Out of Combat Regen functionality? Currently, there is already a rule for NPCs to regen when they are out of combat.
If you are removing the current rule for it, you might want to make separate rules for players and NPCs.
Also, if you are removing the current rule for NPC OOC Regen, please submit the SQL to remove the rule from the rule_values table and add in the new ones you are making.
Sorry, to be bugging you about this. I don't know who you are, and I know the number of people with direct access to update the SVN is very limited, so I am just not sure how familiar you are with the process. I am familiar with all of the people who have access to make commits to the SVN, so maybe you are one of them using another forum account? If you aren't one of them, then you won't be able to commit the code yourself.
|
Old OOCRegen code is staying in for NPC Functionality. Rest regen currently only applies to clients. If you need an sql for the adding of the two fields, I can give you one, but its set in the rules field in the program to default to it if its not already set in the database.
And as for the SVN, cavedude gave me access earlier today. This is my only forum account, but I've been on/off since 2002. Don't worry, I won't break the code, :];
|
 |
|
 |
 |
|
 |

04-13-2009, 11:13 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Ok, so maybe he didn't give me access,  , so here is a diff file I guess.
Code:
Index: common/ruletypes.h
===================================================================
--- common/ruletypes.h (revision 432)
+++ common/ruletypes.h (working copy)
@@ -54,7 +54,9 @@
RULE_INT ( Character, ItemStrikethroughCap, 35)
RULE_INT ( Character, SkillUpModifier, 100) //skill ups are at 100%
RULE_BOOL ( Character, SharedBankPlat, false) //off by default to prevent duping for now
-RULE_BOOL ( Character, BindAnywhere, false)
+RULE_BOOL ( Character, BindAnywhere, false)
+RULE_INT ( Character, RestRegenPercent, 20)
+RULE_INT ( Character, RestRegenTimeToActivate, 30000)
RULE_CATEGORY_END()
RULE_CATEGORY( Guild )
Index: zone/mob.h
===================================================================
--- zone/mob.h (revision 432)
+++ zone/mob.h (working copy)
@@ -1182,7 +1182,12 @@
bool m_hasRune;
bool m_hasSpellRune;
- bool m_hasDeathSaveChance;
+ bool m_hasDeathSaveChance;
+
+ unsigned int restregenhp;
+ unsigned int restregenmp;
+ unsigned int restregenrate;
+ Timer rest_timer;
private:
void _StopSong(); //this is not what you think it is
Index: zone/entity.h
===================================================================
--- zone/entity.h (revision 432)
+++ zone/entity.h (working copy)
@@ -333,7 +333,9 @@
void ReloadAllClientsTaskState(int TaskID=0);
void CreateGroundObject(int32 itemid, float x, float y, float z, float heading, int32 decay_time = 300000);
- void ZoneWho(Client *c, Who_All_Struct* Who);
+ void ZoneWho(Client *c, Who_All_Struct* Who);
+
+ bool MobCheckHate(Mob* mobe);
#ifdef EQBOTS
Index: zone/client_process.cpp
===================================================================
--- zone/client_process.cpp (revision 432)
+++ zone/client_process.cpp (working copy)
@@ -75,6 +75,13 @@
extern bool spells_loaded;
extern PetitionList petition_list;
extern EntityList entity_list;
+
+bool Client::IsAgroed() {
+ if (entity_list.MobCheckHate(this))
+ return true;
+ else
+ return false;
+}
bool Client::Process() {
_ZP(Client_Process);
@@ -536,8 +543,29 @@
adverrorinfo = 4;
if (endupkeep_timer.Check() && !dead){
DoEnduranceUpkeep();
- }
+ }
+
+ if(IsAgroed())
+ {
+ 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;
+ }
+ }
+
if (tic_timer.Check() && !dead) {
CalcMaxHP();
CalcMaxMana();
@@ -1676,7 +1704,7 @@
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);
+ SetHP(GetHP() + total_regen + restregenhp);
SendHPUpdate();
}
@@ -1705,7 +1733,7 @@
regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
- SetMana(GetMana() + regen);
+ SetMana(GetMana() + regen + restregenmp);
SendManaUpdatePacket();
}
Index: zone/mob.cpp
===================================================================
--- zone/mob.cpp (revision 432)
+++ zone/mob.cpp (working copy)
@@ -107,7 +107,8 @@
stunned_timer(0),
bardsong_timer(6000),
flee_timer(FLEE_CHECK_TIMER),
- bindwound_timer(10000)
+ bindwound_timer(10000),
+ rest_timer(RuleI(Character, RestRegenTimeToActivate))
// mezzed_timer(0)
{
targeted = false;
@@ -157,8 +158,12 @@
level = in_level;
npctype_id = in_npctype_id; // rembrant, Dec. 20, 2001
size = in_size;
- runspeed = in_runspeed;
+ runspeed = in_runspeed;
+ restregenhp = 0;
+ restregenmp = 0;
+ restregenrate = (RuleI(Character, RestRegenPercent));
+
// neotokyo: sanity check
if (runspeed < 0 || runspeed > 20)
Index: zone/client.h
===================================================================
--- zone/client.h (revision 432)
+++ zone/client.h (working copy)
@@ -867,7 +867,9 @@
inline int CompletedTasksInSet(int TaskSet)
{ return (taskstate ? taskstate->CompletedTasksInSet(TaskSet) :0); }
- inline EQClientVersion GetClientVersion() { return ClientVersion; }
+ inline EQClientVersion GetClientVersion() { return ClientVersion; }
+
+ bool IsAgroed();
protected:
friend class Mob;
Index: zone/entity.cpp
===================================================================
--- zone/entity.cpp (revision 432)
+++ zone/entity.cpp (working copy)
@@ -289,7 +289,18 @@
if (count <= 2)
return true;
return false;
-}
+}
+
+bool EntityList::MobCheckHate(Mob* mobe) {
+ LinkedListIterator<Mob*> iterator(mob_list);
+ for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
+ {
+ Mob* mobf = iterator.GetData();
+ if (mobf->CheckAggro(mobe))
+ return true;
+ }
+ return false;
+}
void EntityList::AddClient(Client* client) {
client->SetID(GetFreeID());
|
 |
|
 |

04-14-2009, 03:49 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
For those of you that actually need it, here is the sql query for the database if you aren't using the default values. Change as needed. Sorry I didn't get it up last night, was dead tired.
Code:
INSERT INTO rule_values VALUES(1,'Character:RestRegenPercent',20);
INSERT INTO rule_values VALUES(1,'Character:RestRegenTimeToActivate',30000);
It should work fine even if you don't source the rules, as they are set inside the ruletypes source.
|

04-17-2009, 12:55 PM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Thanks for the SQL makes me job a tiny bit easier. Quick question, does this effect the regen players already have when meditating if the RestRegenPercent rule is set to 0? I just want to make sure this can be disabled without reducing regen to 0 
|

04-17-2009, 01:35 PM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Perhaps I should read the code and test it out before asking questions. This works perfectly, and doesn't effect natural regen if set to 0. I am going to make that the default, however so this system is optional and Server Ops don't complain that regen is way too high  I'll get this into SVN with my next batch. Thank you!
|

04-17-2009, 04:10 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Thanks cavedude,
On my own server, I wrote extra code in that checks for guild pvp targets in range. I'm trying to think of a good way to do that for an entire pvp server though. I'm not sure if the PVP on flag in the database means that anyone can attack anyone period or not.
__________________
Hmm.
|
 |
|
 |

04-18-2009, 07:53 AM
|
Developer
|
|
Join Date: Feb 2004
Location: UK
Posts: 1,540
|
|
I've made a few changes to this (I hope you don't mind), primarily because I wanted to tie it in with the SoF rest state indicator that I found the opcode for, because I wanted it to work a bit more like live currently does, and to make it a bit more efficient.
Functionally, the changes are:
* Default RestRegenPercent to 0
* RestRegenTimeToActivate now specified in seconds rather than milliseconds. (This is because I needed to convert it to seconds for the SoF packet).
* Client must be sitting and not have a detrimental spell on them for rest state regen to kick-in.
* SoF clients get the combat/rest symbol and timer. Still works in Titanium, but with no indicators.
Codewise, rather than checking in every call to Client::Process whether the client has aggro, I added a 'HaveAggro' member to the client class which is set true whenever the client gets added to a mob's hate list.
When a mob's hate list is wiped (dies or is memblurred), then any client on that mob's hate checks to see if it has aggro from any other mob, and if not, starts the rest state timer.
I'll commit it later on today. Thanks for the contribution.
|
 |
|
 |

04-18-2009, 04:20 PM
|
Hill Giant
|
|
Join Date: Nov 2002
Location: NC, USA
Posts: 182
|
|
Thanks Derision, I don't mind the changes, just as long as you didn't have to go a long way out of your way to fix anything.
__________________
Hmm.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 08:30 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |