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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-17-2010, 10:20 AM
bad_captain
Developer
 
Join Date: Feb 2009
Location: Cincinnati, OH
Posts: 512
Default Pet Focus

Below are changes that can be used to make pet focii work about as close as possible to live without maintaining multiple versions of pets per focus, which is a maintenance headache.

First, in pets.cpp I add a parameter to makepet to allow new pets to be created at a specified pet power level (suspend minion, zoning, etc.) Then, I take out the current focus code, and call virtual GetPetFocusEffects, so it works for both clients and bots. Then, after the pet is created, I set the pet's focus power level so it can be recalled later if needed. I then create a method to call a single CalcPetFocusEffects() method that can be called from both clients and bots (to keep all the calcs in one place). The CalcPetFocusEffects() method contains all of the focus effect code. I update HP, AC, min and max damage, regen, size, and accuracy. HP, AC, min and max damage are as close to live as I could get. The actual values seen vary by class pet (mage pet increase was average- mostly hps, while necro increased AC significantly more, and beastlord warders increased melee damage the most. These equations keep the values within observed live values all the way up to pet power 90, which won't likely be seen here unless SoD is added. Lower level pet focus numbers (shovel of ponz, broom of trilon, etc. numbers couldn't be found, but the numbers end up in line with the rest.
Code:
--- pets.cpp	(revision 1126)
+++ pets.cpp	(working copy)
@@ -215,7 +215,7 @@
 */
 
 
-void Mob::MakePet(int16 spell_id, const char* pettype, const char *petname) {
+void Mob::MakePet(int16 spell_id, const char* pettype, sint16 petFocusPower, const char *petname) {
 	//see if we are a special type of pet (for command filtering)
 	PetType type = petOther;
 	if(strncmp(pettype, "Familiar", 8) == 0) {
@@ -226,7 +226,6 @@
 	
 	if(HasPet())
 		return;
-
 	
 	//lookup our pets table record for this type
 	PetRecord record;
@@ -248,16 +247,7 @@
 	NPCType *npc_type = new NPCType;
 	memcpy(npc_type, base, sizeof(NPCType));
 	
-	if (this->IsClient() && CastToClient()->GetFocusEffect(focusPetPower, spell_id) > 0)
-	{
-		npc_type->max_hp *= 1.20;
-		npc_type->cur_hp = npc_type->max_hp;
-		npc_type->AC *= 1.20;
-		npc_type->level += 1;
-		npc_type->min_dmg = (npc_type->min_dmg * 110 / 100);
-		npc_type->max_dmg = (npc_type->max_dmg * 110 / 100);
-		npc_type->size *= 1.15;
-	}
+	GetPetFocusEffects(npc_type, spell_id, petFocusPower);
 
 	switch (GetAA(aaElementalDurability))
 	{
@@ -354,9 +344,48 @@
 	//this takes ownership of the npc_type data
 	Pet *npc = new Pet(npc_type, this, type, spell_id);
 
+	npc->SetPetFocusPower(petFocusPower);
+
 	entity_list.AddNPC(npc, true, true);
 	SetPetID(npc->GetID());
 }
+
+void Mob::GetPetFocusEffects(NPCType *npc_type, int16 spell_id, sint16 &petFocusPower) {
+	
+	if(IsClient())
+	{
+		if(petFocusPower == 0)
+		{
+			petFocusPower = CastToClient()->GetFocusEffect(focusPetPower, spell_id);
+		}
+
+		if(petFocusPower > 0)
+		{
+			CalcPetFocusEffects(npc_type, petFocusPower);
+		}
+	}
+}
+
+void Mob::CalcPetFocusEffects(NPCType *npc_type, sint16 petFocusPower) {
+		
+	if(petFocusPower < 15){
+            	npc_type->AC = (int16)floor((double)npc_type->AC * (petFocusPower/2+100)/100);
+            	npc_type->min_dmg += (int32)floor((double)petFocusPower/5);
+            	npc_type->max_dmg += (int32)floor((double)petFocusPower/5);
+	}
+	else{
+            	npc_type->AC += (int16)floor((.75*petFocusPower*petFocusPower)/5);
+            	npc_type->level += (int8)floor((double)2*(petFocusPower / 40));
+            	npc_type->min_dmg += (int32)floor((double)petFocusPower/4 - 2);
+            	npc_type->max_dmg = (int32)floor((double)npc_type->max_dmg * ((0.4*(petFocusPower-10)+100)/100));
+	}
+
+	npc_type->max_hp = (sint32)floor((double)npc_type->max_hp * ((0.35*petFocusPower)+100)/100);
+	npc_type->cur_hp = npc_type->max_hp;
+	npc_type->hp_regen = (sint32)floor((double)npc_type->hp_regen * ((petFocusPower/2)+100)/100);
+    npc_type->size *= (((petFocusPower/2)+100)/100);
+	npc_type->accuracy_rating += (petFocusPower + 25);
+}

The declarations in mob.h:
Code:
--- mob.h	(revision 1205)
+++ mob.h	(working copy)
@@ -500,7 +500,9 @@
 	int		CountDispellableBuffs();
 	bool	HasBuffIcon(Mob* caster, Mob* target, int16 spell_id);
 
-	virtual void MakePet(int16 spell_id, const char* pettype, const char *petname = NULL);
+	virtual void MakePet(int16 spell_id, const char* pettype, sint16 petFocusPower, const char *petname = NULL);
+	virtual void GetPetFocusEffects(NPCType *npc_type, int16 spell_id, sint16 &focusPower);
+	void CalcPetFocusEffects(NPCType *npc_type, sint16 focusPower);
 //	inline void	MakePetType(int16 spell_id, const char* pettype, const char *petname = NULL) { MakePet(spell_id, pettype, petname); }	//for perl
 //	void	MakePet(int16 spell_id, int8 in_level, int8 in_class, int16 in_race, int8 in_texture = 0, int8 in_pettype = 0, float in_size = 0, int8 type = 0, int32 min_dmg = 0, int32 max_dmg = 0, const char *petname = NULL);

A few changes to account for added parameter to MakePet:
Code:
--- perl_mob.cpp	(revision 1205)
+++ perl_mob.cpp	(working copy)
@@ -1476,7 +1476,7 @@
 			name = (char *)SvPV_nolen(ST(3));
 		}
 
-		THIS->MakePet(spell_id, pettype, name);
+		THIS->MakePet(spell_id, pettype, 0, name);
 	}
 	XSRETURN_EMPTY;
 }
Code:
--- command.cpp	  (revision 1213)
+++ command.cpp	  (working copy)
@@ -2731,7 +2731,7 @@
 	if (sep->arg[1][0] == '\0')
 		c->Message(0, "Usage: #makepet pet_type_name (will not survive across zones)");
 	else
-		c->MakePet(0, sep->arg[1]);
+		c->MakePet(0, sep->arg[1], 0);
 }
 
 void command_level(Client *c, const Seperator *sep)
Code:
--- client_packet.cpp	(revision 1227)
+++ client_packet.cpp	(working copy)
@@ -8063,7 +8063,7 @@
 	//Remake pet
 	if (m_epp.pet_id > 1 && !GetPet() && m_epp.pet_id <= SPDAT_RECORDS)
 	{
-		MakePet(m_epp.pet_id, spells[m_epp.pet_id].teleport_zone, m_epp.pet_name);
+		MakePet(m_epp.pet_id, spells[m_epp.pet_id].teleport_zone, 0, m_epp.pet_name);
 		if (GetPet() && GetPet()->IsNPC()) {
 			NPC *pet = GetPet()->CastToNPC();
 			pet->SetPetState(m_epp.pet_buffs, m_epp.pet_items);
This one also makes a change to the SE_LimitMaxLevel in CalcFocusEffects() due to the fact that pet focii (as well as some other focus effects) have a 0 in the per level falloff over the max level, which designates that they should stop working altogether. They could be set to 100 in the database to achieve the same effect, but this one change keeps from having to maintain those changes, as any new focus effects pulled from live (lucy) would have the 0, and would need to be changed.
Code:
--- spell_effects.cpp	(revision 1126)
+++ spell_effects.cpp	(working copy)
@@ -1048,7 +1048,7 @@
 				}
 				else
 				{
-					MakePet(spell_id, spell.teleport_zone);
+					MakePet(spell_id, spell.teleport_zone, 0);
 				}
 				break;
 			}
@@ -3580,7 +3580,7 @@
 
 			if(lvldiff > 0){ //every level over cap reduces the effect by spell.base2[i] percent
 				lvlModifier -= spell.base2[i]*lvldiff;
-				if(lvlModifier < 1)
+				if((lvlModifier < 1) || (spell.base2[i] == 0))
 					return 0;
 			}
 			break;

Next, is the code to save petFocusPower within the pet.
Code:
--- npc.h	(revision 1175)
+++ npc.h	(working copy)
@@ -201,6 +201,8 @@
 	bool	IsAnimal() const { return(bodytype == BT_Animal); }
 	int16   GetPetSpellID() const {return pet_spell_id;}
 	void    SetPetSpellID(int16 amt) {pet_spell_id = amt;}
+	sint16  GetPetFocusPower() const {return pet_focus_power;}
+	void    SetPetFocusPower(sint16 amt) {pet_focus_power = amt;}
 	int32	GetMaxDamage(int8 tlevel);
 	void    SetTaunting(bool tog) {taunting = tog;}
 	void	PickPocket(Client* thief);
@@ -336,6 +338,7 @@
 	
 	//pet crap:
 	int16	pet_spell_id;
+	sint16	pet_focus_power;
 	bool	taunting;
     Timer	taunt_timer;		//for pet taunting
Declaration for Bot's version of GetPetFocusEffects()
Code:
--- bot.h	(revision 1132)
+++ bot.h	(working copy)
@@ -113,6 +113,7 @@
 	virtual sint32 CheckAggroAmount(int16 spellid);
 	virtual void CalcBonuses();
 	virtual void MakePet(int16 spell_id, const char* pettype, const char *petname = NULL);
+	virtual void GetPetFocusEffects(NPCType *npc_type, int16 spell_id, sint16 &focusPower);
 	virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther);
 	inline virtual bool IsPet() { return false; }
 	virtual bool IsNPC() const { return false; }
Bot code to get BotfocusPetPower. (It couldn't be accessed from within mob.cpp)
Code:
--- bot.cpp	(revision 1180)
+++ bot.cpp	(working copy)
@@ -6792,9 +6792,22 @@
 }
 
 void Bot::MakePet(int16 spell_id, const char* pettype, const char *petname) {
-	Mob::MakePet(spell_id, pettype, petname);
+	Mob::MakePet(spell_id, pettype, 0, petname);
 }
 
+void Bot::GetPetFocusEffects(NPCType *npc_type, int16 spell_id, sint16 &focusPower) {
+	
+	if(IsBot())
+	{
+		focusPower = GetBotFocusEffect(BotfocusPetPower, spell_id);
+
+		if(focusPower > 0)
+		{
+			CalcPetFocusEffects(npc_type, focusPower);
+		}
+	}
+}
+
 void Bot::AI_Stop() {
 	NPC::AI_Stop();
 	Mob::AI_Stop();
Change to the player profile struct to store the petFocusPower to allow unsuspended pets to retain their power if the caster had removed the focus item after summoning, just like live.
Code:
--- eq_packet_structs.h	(revision 1208)
+++ eq_packet_structs.h	(working copy)
@@ -767,6 +767,7 @@
 	uint16			SpellID;
 	uint32			HP;
 	uint32			Mana;
+	sint16			PetFocusPower;
 	SpellBuff_Struct	Buffs[BUFF_COUNT];
 	uint32			Items[MAX_MATERIALS];
 	char			Name[64];
@@ -1004,8 +1005,8 @@
 /*12804*/	uint32				aapoints;	//avaliable, unspent
 /*12808*/	uint8				unknown12808[36];
 /*12844*/	Bandolier_Struct	bandoliers[MAX_PLAYER_BANDOLIER];
-/*14124*/	uint8				unknown14124[4506];
-/*18630*/	SuspendedMinion_Struct		SuspendedMinion;
+/*14124*/	uint8				unknown14124[4504];
+/*18628*/	SuspendedMinion_Struct		SuspendedMinion;
 /*19240*/	uint32				timeentitledonaccount;
 /*19244*/	PotionBelt_Struct	potionbelt;	//there should be 3 more of these
 /*19532*/	uint8				unknown19532[8];

Change to client.cpp to suspend and unsuspend pet, saving and restoring pet with same pet level.
Code:
--- client.cpp	(revision 1207)
+++ client.cpp	(working copy)
@@ -5608,7 +5608,7 @@
 	{
 		if(m_pp.SuspendedMinion.SpellID > 0)
 		{
-			MakePet(m_pp.SuspendedMinion.SpellID, spells[m_pp.SuspendedMinion.SpellID].teleport_zone);
+			MakePet(m_pp.SuspendedMinion.SpellID, spells[m_pp.SuspendedMinion.SpellID].teleport_zone, m_pp.SuspendedMinion.PetFocusPower);
 
 			CurrentPet = GetPet()->CastToNPC();
 
@@ -5630,6 +5630,8 @@
 
 			CurrentPet->SetMana(m_pp.SuspendedMinion.Mana);
 
+			CurrentPet->SetPetFocusPower(m_pp.SuspendedMinion.PetFocusPower);
+
 			Message_StringID(clientMessageTell, SUSPEND_MINION_UNSUSPEND, CurrentPet->GetCleanName());
 			
 			memset(&m_pp.SuspendedMinion, 0, sizeof(SuspendedMinion_Struct));
@@ -5664,10 +5666,12 @@
 			{
 				m_pp.SuspendedMinion.SpellID = SpellID;
 
-				m_pp.SuspendedMinion.HP = CurrentPet->GetHP();;
+				m_pp.SuspendedMinion.HP = CurrentPet->GetHP();
 
 				m_pp.SuspendedMinion.Mana = CurrentPet->GetMana();
 
+				m_pp.SuspendedMinion.PetFocusPower = CurrentPet->GetPetFocusPower();
+
 				if(AALevel >= 2)
 					CurrentPet->GetPetState(m_pp.SuspendedMinion.Buffs, m_pp.SuspendedMinion.Items, m_pp.SuspendedMinion.Name);
Reply With Quote
 


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 08:56 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