PDA

View Full Version : Disable PVP for same group/same guild


Secrets
09-26-2010, 04:00 PM
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

songie
09-26-2010, 05:04 PM
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 :)

Secrets
09-26-2010, 11:15 PM
Updating main post, had an extra \ that I fat fingered.

Secrets
09-27-2010, 12:48 AM
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.

songie
09-27-2010, 08:48 AM
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 :)

Secrets
09-27-2010, 10:52 AM
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.

anxious
07-27-2011, 04:31 AM
anyone able to help with implementing this into my aggro.cpp or can someone send one my way with this included... Thanks

anxious
08-04-2011, 12:38 AM
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?