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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2011, 02:48 AM
SuperUserJD
Fire Beetle
 
Join Date: Apr 2011
Location: Canada
Posts: 5
Default COMMITTED: Mob::SpellOnTarget

This fixes the casting of beneficial spells on grouped raid members. From a fresh install of peq, Tricksters Augmentation behaved the same as Ant Legs, so however the DB is configured, this seems to be the correct fix for dealing with casting beneficial spells at group members and group pets, raids too.

Perform these tests before and after for verification:

Before you begin:
-get two clients connected to server, standing next to eachother, one having pet
-#si 28906, on toon that does not have pet. This is what we will clickie with to test. You can give Tricksters a shot too, with an ENC.
-Not sure which version of your db has that target type of 5 or 43. Try both?

Test#1: Ungrouped, "Clickie on the Pet and the Player" (CoPP)
Test#2: Grouped (regular), CoPP
Test#3: In Raid, ungrouped, CoPP
Test#4: In Raid, different groups, CoPP
Test#5: In Raid, both in group#1, CoPP
Test#6: In Raid, both in group#2, CoPP

That should do it. Make a little grid or something, two columns of six rows, on paper.. to mark your test results. Since this test uses shrink, I tested with a shaman so I can cast grow to allow for more testing without zoning.


Code:
Index: trunk/EQEmuServer/zone/spells.cpp
===================================================================
--- trunk/EQEmuServer/zone/spells.cpp	(revision 1997)
+++ trunk/EQEmuServer/zone/spells.cpp	(working copy)
@@ -3018,31 +3018,75 @@
 		// Beneficial spells check
 		if(IsBeneficialSpell(spell_id))
 		{
-			if
-			(
-				IsClient() &&	//let NPCs do beneficial spells on anybody if they want, should be the job of the AI, not the spell code to prevent this from going wrong
-				spelltar != this &&
-				(
-					!IsBeneficialAllowed(spelltar) ||
-					(
-						IsGroupOnlySpell(spell_id) &&
+			if(IsClient() &&	//let NPCs do beneficial spells on anybody if they want, should be the job of the AI, not the spell code to prevent this from going wrong
+				spelltar != this)
+			{
+				Client* pClient = 0;
+				Raid* pRaid = 0;
+				Group* pBasicGroup = 0;
+				int32 nGroup = 0; //raid group
+
+				Client* pClientTarget = 0;
+				Raid* pRaidTarget = 0;
+				Group* pBasicGroupTarget = 0;
+				int32 nGroupTarget = 0; //raid group 
+
+				Client* pClientTargetPet = 0;
+				Raid* pRaidTargetPet = 0;
+				Group* pBasicGroupTargetPet = 0;
+				int32 nGroupTargetPet = 0; //raid group
+
+				const int32 cnWTF = 0xFFFFFFFF + 1; //this should be zero unless on 64bit? forced int64?
+
+				//Caster client pointers
+				pClient = this->CastToClient();
+				pRaid = entity_list.GetRaidByClient(pClient);
+				pBasicGroup = entity_list.GetGroupByMob(this);
+				if(pRaid)
+					nGroup = pRaid->GetGroup(pClient) + 1;
+					
+				//Target client pointers
+				if(spelltar->IsClient())
+				{
+					pClientTarget = spelltar->CastToClient();
+					pRaidTarget = entity_list.GetRaidByClient(pClientTarget);
+					pBasicGroupTarget = entity_list.GetGroupByMob(spelltar);
+					if(pRaidTarget)
+						nGroupTarget = pRaidTarget->GetGroup(pClientTarget) + 1;
+				}
+
+				if(spelltar->IsPet())
+				{
+					Mob *owner = spelltar->GetOwner();
+					if(owner->IsClient())
+					{
+						pClientTargetPet = owner->CastToClient();
+						pRaidTargetPet = entity_list.GetRaidByClient(pClientTargetPet);
+						pBasicGroupTargetPet = entity_list.GetGroupByMob(owner);
+						if(pRaidTargetPet)
+							nGroupTargetPet = pRaidTargetPet->GetGroup(pClientTargetPet) + 1;
+					}
+
+				}
+
+
+				if(!IsBeneficialAllowed(spelltar) ||
+					(IsGroupOnlySpell(spell_id) &&
 						!(
-							(entity_list.GetGroupByMob(this) &&
-							entity_list.GetGroupByMob(this)->IsGroupMember(spelltar)) ||
-							(spelltar->IsClient() &&
-							entity_list.GetRaidByMob(this) &&
-							entity_list.GetRaidByMob(this)->GetGroup(this->CastToClient()) ==
-								entity_list.GetRaidByMob(spelltar)->GetGroup(spelltar->CastToClient())) ||
+							(pBasicGroup && ((pBasicGroup == pBasicGroupTarget) || (pBasicGroup == pBasicGroupTargetPet))) || //Basic Group
+
+							((nGroup != cnWTF) && ((nGroup == nGroupTarget) || (nGroup == nGroupTargetPet))) || //Raid group
+
 							(spelltar == GetPet()) //should be able to cast grp spells on self and pet despite grped status.
 						)
 					)
 				)
-			)
-			{
-				mlog(SPELLS__CASTING_ERR, "Beneficial spell %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar));
-				Message_StringID(MT_Shout, SPELL_NO_HOLD);
-				safe_delete(action_packet);
-				return false;
+				{
+					mlog(SPELLS__CASTING_ERR, "Beneficial spell %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar));
+					Message_StringID(MT_Shout, SPELL_NO_HOLD);
+					safe_delete(action_packet);
+					return false;
+				}
 			}
 		}
 		else if	( !IsAttackAllowed(spelltar, true) && !IsResurrectionEffects(spell_id)) // Detrimental spells - PVP check

Last edited by trevius; 08-22-2011 at 06:27 AM.. Reason: Removed extra lines
Reply With Quote
Reply


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 02:44 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3