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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2009, 10:37 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Quote:
Originally Posted by trevius View Post
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, :];
Reply With Quote
  #2  
Old 04-13-2009, 11:13 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

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());
Reply With Quote
  #3  
Old 04-14-2009, 03:49 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

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.
Reply With Quote
  #4  
Old 04-17-2009, 12:55 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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
Reply With Quote
  #5  
Old 04-17-2009, 01:35 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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!
Reply With Quote
  #6  
Old 04-17-2009, 04:10 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

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.
Reply With Quote
  #7  
Old 04-18-2009, 07:53 AM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

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:00 PM.


 

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