Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 09-26-2010, 04:00 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default Disable PVP for same group/same guild

Code:
Index: aggro.cpp
===================================================================
--- aggro.cpp	(revision 1668)
+++ aggro.cpp	(working copy)
@@ -41,7 +41,11 @@
 		Mob* mob = iterator.GetData();
 		if(mob->IsClient())	//also ensures that mob != around
 			continue;
+
+		if(mob && mob->IsNPC() && mob->CastToNPC()->GetGuildID() == around->GuildID())
+			continue;
 		
+		
 		if(mob->CheckWillAggro(around)) {
 			if(mob->IsEngaged())
 			{
@@ -256,6 +260,18 @@
 	if(ownr && ownr->IsClient() && !ownr->CastToClient()->ClientFinishedLoading())
 		return false;
 
+	if(mob->IsNPC() && IsNPC())
+	{
+		if(CastToNPC()->GetGuildID() != 0 && mob->CastToNPC()->GetGuildID() != 0)
+		{
+			if(CastToNPC()->GetGuildID() == mob->CastToNPC()->GetGuildID())
+			{
+				return false;
+			}
+		}
+	}
+		return false;
+
 	float iAggroRange = GetAggroRange();
 	
 	// Check If it's invisible and if we can see invis
@@ -499,7 +515,7 @@
 {
 	Mob *mob1, *mob2, *tempmob;
 	Client *c1, *c2, *becomenpc;
-//	NPC *npc1, *npc2;
+	NPC *npc1, *npc2;
 	int reverse;
 
 	if(!zone->CanDoCombat())
@@ -551,26 +567,31 @@
 			{
 				c1 = mob1->CastToClient();
 				c2 = mob2->CastToClient();
-	
-				if	// if both are pvp they can fight
-				(
-					c1->GetPVP() &&
-					c2->GetPVP()
-				)
+
+					if(zone->GetZoneID() == 1)
+						return false;
+
+					if(c1->GuildID() != 0xFFFFFFFF && c2->GuildID() != 0xFFFFFFFF)
+					{
+				if(c1->GuildID() == c2->GuildID())
+					return false;
+					}
+				if(c1->GetGroup() && c2->GetGroup())
+				{
+					if(c1->GetGroup()->GetID() == c2->GetGroup()->GetID())
+						return false;
+					else
+						return true;
+				}
 					return true;
-				else if	// if they're dueling they can go at it
-				(
-					c1->IsDueling() &&
-					c2->IsDueling() &&
-					c1->GetDuelTarget() == c2->GetID() &&
-					c2->GetDuelTarget() == c1->GetID()
-				)
-					return true;
-				else
-					return false;
 			}
 			else if(_NPC(mob2))				// client vs npc
 			{	
+			c1 = mob1->CastToClient();
+			npc1 = mob2->CastToNPC();
+
+				if(npc1->GetGuildID() == c1->GuildID())
+					return false;
 				return true;
 			}
 			else if(_BECOMENPC(mob2))	// client vs becomenpc
@@ -596,7 +617,17 @@
 		{
 			if(_NPC(mob2))						// npc vs npc
 			{
-/*
+
+				npc1 = mob1->CastToNPC();
+				npc2 = mob2->CastToNPC();
+
+
+			if(npc1->GetGuildID() != 4294967295 && npc2->GetGuildID() != 4294967295)
+				{
+				if(npc1->GetGuildID() == npc2->GetGuildID())
+					return false;
+				}
+				/*
 this says that an NPC can NEVER attack a faction ally...
 this is stupid... somebody else should check this rule if they want to
 enforce it, this just says 'can they possibly fight based on their
@@ -693,6 +724,7 @@
 {
 	Mob *mob1, *mob2, *tempmob;
 	Client *c1, *c2;
+	NPC *npc1, *npc2;
 	int reverse;
 
 	if(!target)
@@ -719,23 +751,41 @@
 				c1 = mob1->CastToClient();
 				c2 = mob2->CastToClient();
 
-				if(c1->GetPVP() == c2->GetPVP())
+
+				if(zone->GetZoneID() == 1)
+						return true;
+
+
+				if(c1->GuildID() != 0xFFFFFFFF && c2->GuildID() != 0xFFFFFFFF)
+				{
+				if(c1->GuildID() == c2->GuildID())
 					return true;
-				else if	// if they're dueling they can heal each other too
-				(
-					c1->IsDueling() &&
-					c2->IsDueling() &&
-					c1->GetDuelTarget() == c2->GetID() &&
-					c2->GetDuelTarget() == c1->GetID()
-				)
-					return true;
-				else
+				}
+
+				if(c1->GetGroup() && c2->GetGroup())
+				{
+					if(c1->GetGroup()->GetID() != c2->GetGroup()->GetID())
+						return false;
+					else
+						return true;
+				}
+
+
 					return false;
 			}
 			else if(_NPC(mob2))				// client to npc
 			{
-                /* fall through and swap positions */
+			c1 = mob1->CastToClient();
+			npc2 = mob2->CastToNPC();
+
+			if(npc2->GetGuildID() != 0 && c1->GuildID() != 0)
+			{
+				if(npc2->GetGuildID() == c1->GuildID())
+					return true;
 			}
+				return false;
+
+			}
 			else if(_BECOMENPC(mob2))	// client to becomenpc
 			{
 				return false;
@@ -757,11 +807,24 @@
 		{
 			if(_CLIENT(mob2))
 			{
+
+			npc1 = mob1->CastToNPC();
+			c2 = mob2->CastToClient();
+				if(npc1->GetGuildID() != 0 && c2->GuildID() != 0)
+				{
+				if(c2->GuildID() == npc1->GetGuildID())
+					return true;
+				}
+
 				return false;
 			}
 			if(_NPC(mob2))						// npc to npc
 			{
-				return true;
+				npc1 = mob1->CastToNPC();
+				npc2 = mob2->CastToNPC();
+				if(npc1->GetGuildID() == npc2->GetGuildID())
+					return true;
+				return false;
 			}
 			else if(_BECOMENPC(mob2))	// npc to becomenpc
 			{
requested by songie

Last edited by Secrets; 09-27-2010 at 12:47 AM..
Reply With Quote
  #2  
Old 09-26-2010, 05:04 PM
songie
Sarnak
 
Join Date: Dec 2009
Posts: 43
Default

Much appreciated Secrets, with this i can develop some stuff regarding pvp between the 3 faction, i was holding off that boat until i was done with everything else but now i can look into it early on.

EQ-Heroes says thanks
__________________
--You start casting "Extra Content"--
--You Hit your database for 9.999 Damage, you have slain your Server--
--Please wait reinstalling!--/Sigh
Reply With Quote
  #3  
Old 09-26-2010, 11:15 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default

Updating main post, had an extra \ that I fat fingered.
Reply With Quote
  #4  
Old 09-27-2010, 12:48 AM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default

Re-wrote part of it to use proper values for guild ID.. Also added proper checking for groups. It also adds NPC guild ID stuff, so remove those functions if you get compile errors.
Reply With Quote
  #5  
Old 09-27-2010, 08:48 AM
songie
Sarnak
 
Join Date: Dec 2009
Posts: 43
Default

alright, thanks

quick question, does this replace the current aggro.cpp or does it go somewhere in there :p, like i said c++ isnt my thing
__________________
--You start casting "Extra Content"--
--You Hit your database for 9.999 Damage, you have slain your Server--
--Please wait reinstalling!--/Sigh
Reply With Quote
  #6  
Old 09-27-2010, 10:52 AM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,450
Default

Quote:
Originally Posted by songie View Post
alright, thanks

quick question, does this replace the current aggro.cpp or does it go somewhere in there :p, like i said c++ isnt my thing
This is a diff, which replaces part of aggro.cpp by using GNU's diffutils. You will need to use something like TortoiseSVN to check out the source code from code.google.com/p/projecteqemu and then right click on the folder -> apply patch.

I'm posting everything I did for the server I mentioned though. Feel free to apply the full diff.
Reply With Quote
  #7  
Old 07-27-2011, 04:31 AM
anxious's Avatar
anxious
Fire Beetle
 
Join Date: Apr 2006
Posts: 10
Default

anyone able to help with implementing this into my aggro.cpp or can someone send one my way with this included... Thanks
Reply With Quote
  #8  
Old 08-04-2011, 12:38 AM
anxious's Avatar
anxious
Fire Beetle
 
Join Date: Apr 2006
Posts: 10
Default

to get this to work, do I need to revert the entire source to 1668? do I just need to patch this code into the aggro.cpp?
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 04:12 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3