View Single Post
  #1  
Old 09-26-2010, 04:00 PM
Secrets's Avatar
Secrets
Demi-God
 
Join Date: May 2007
Location: b
Posts: 1,449
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