From 15dde4778a1697dd178012120f61743f858bfd70 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 11:52:27 -0400 Subject: [PATCH 1/8] Update aggro.cpp --- zone/aggro.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 87b98d599..dad9aacc4 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -237,6 +237,11 @@ bool Mob::CheckWillAggro(Mob *mob) { if (!mob->CastToClient()->ClientFinishedLoading() || mob->CastToClient()->IsHoveringForRespawn() || mob->CastToClient()->bZoning) return false; } + + // We don't want to aggro clients outside of water if we're water only. + if (mob->IsClient() && mob->CastToClient()->GetLastRegion() != RegionTypeWater && IsUnderwaterOnly()) { + return false; + } /** * Pets shouldn't scan for aggro From 803c3aabe434ee22aacbffe035aeaf40d4d75871 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 11:54:19 -0400 Subject: [PATCH 2/8] Update client.cpp --- zone/client.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/client.cpp b/zone/client.cpp index 8c4b42957..a270d6579 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8756,6 +8756,11 @@ void Client::CheckRegionTypeChanges() // still same region, do nothing if (last_region_type == new_region) return; + + // If we got out of water clear any water aggro for water only npcs + if (last_region_type == RegionTypeWater) { + entity_list.ClearWaterAggro(this); + } // region type changed last_region_type = new_region; From a898a1d07b9833fbe261f2cc9a1eafc48c107d62 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 11:55:05 -0400 Subject: [PATCH 3/8] Update aggro.cpp --- zone/aggro.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index dad9aacc4..b568d11af 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -32,6 +32,7 @@ #endif #include "map.h" +#include "water_map.h" extern Zone* zone; //#define LOSDEBUG 6 From 42f959329d8190cd33070a5001869cc373771364 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 11:56:06 -0400 Subject: [PATCH 4/8] Update client.h --- zone/client.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zone/client.h b/zone/client.h index 58b0d9af8..edc3f18c0 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1293,6 +1293,8 @@ public: void SendHPUpdateMarquee(); void CheckRegionTypeChanges(); + + WaterRegionType GetLastRegion() { return last_region_type; } int32 CalcATK(); From ef0b29dc8e43ce9f98f1385b907df87587dc38bb Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 12:03:45 -0400 Subject: [PATCH 5/8] Update entity.cpp --- zone/entity.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/zone/entity.cpp b/zone/entity.cpp index b13fb5649..0e93be722 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3294,6 +3294,36 @@ void EntityList::ClearAggro(Mob* targ) } } +//removes "targ" from all hate lists of mobs that are water only. +//water only mobs that are fleed from to another region are healed as per live +void EntityList::ClearWaterAggro(Mob* targ) +{ + Client *c = nullptr; + if (targ->IsClient()) + c = targ->CastToClient(); + auto it = npc_list.begin(); + while (it != npc_list.end()) { + if (it->second->IsUnderwaterOnly()) { + if (it->second->CheckAggro(targ)) { + if (c) + c->RemoveXTarget(it->second, false); + it->second->RemoveFromHateList(targ); + } + if (c && it->second->IsOnFeignMemory(c)) { + it->second->RemoveFromFeignMemory(c); //just in case we feigned + c->RemoveXTarget(it->second, false); + } + if (!it->second->GetHateTop()) { + // target fled the water and no other targets. + // Heal NPC as on live + it->second->Heal(); + } + } + ++it; + } +} + + void EntityList::ClearFeignAggro(Mob *targ) { auto it = npc_list.begin(); From abeb93f1e60b802b46c41c98874eda0a16e97532 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 12:04:16 -0400 Subject: [PATCH 6/8] Update entity.h --- zone/entity.h | 1 + 1 file changed, 1 insertion(+) diff --git a/zone/entity.h b/zone/entity.h index 505f34963..3c182be29 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -447,6 +447,7 @@ public: void Process(); void ClearAggro(Mob* targ); + void ClearWaterAggro(Mob* targ); void ClearFeignAggro(Mob* targ); void ClearZoneFeignAggro(Client* targ); void AggroZone(Mob* who, uint32 hate = 0); From 561433902e28a039b3e7d604c4c1049f30d04530 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Thu, 2 Apr 2020 13:08:05 -0400 Subject: [PATCH 7/8] Removed heal per @mackal --- zone/entity.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index 0e93be722..e74136be7 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3295,7 +3295,6 @@ void EntityList::ClearAggro(Mob* targ) } //removes "targ" from all hate lists of mobs that are water only. -//water only mobs that are fleed from to another region are healed as per live void EntityList::ClearWaterAggro(Mob* targ) { Client *c = nullptr; @@ -3313,11 +3312,6 @@ void EntityList::ClearWaterAggro(Mob* targ) it->second->RemoveFromFeignMemory(c); //just in case we feigned c->RemoveXTarget(it->second, false); } - if (!it->second->GetHateTop()) { - // target fled the water and no other targets. - // Heal NPC as on live - it->second->Heal(); - } } ++it; } From b5575133cd08bc0854e3c3d584b248dac773d9d0 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Mon, 6 Apr 2020 08:10:15 -0400 Subject: [PATCH 8/8] Put in braces in my new function as well as the source function. The entire file has implied braces... I'd change them all but fear making a mistake. --- zone/entity.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zone/entity.cpp b/zone/entity.cpp index e74136be7..b3805ad63 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3277,13 +3277,15 @@ void EntityList::Evade(Mob *who) void EntityList::ClearAggro(Mob* targ) { Client *c = nullptr; - if (targ->IsClient()) + if (targ->IsClient()) { c = targ->CastToClient(); + } auto it = npc_list.begin(); while (it != npc_list.end()) { if (it->second->CheckAggro(targ)) { - if (c) + if (c) { c->RemoveXTarget(it->second, false); + } it->second->RemoveFromHateList(targ); } if (c && it->second->IsOnFeignMemory(c)) { @@ -3298,14 +3300,16 @@ void EntityList::ClearAggro(Mob* targ) void EntityList::ClearWaterAggro(Mob* targ) { Client *c = nullptr; - if (targ->IsClient()) + if (targ->IsClient()) { c = targ->CastToClient(); + } auto it = npc_list.begin(); while (it != npc_list.end()) { if (it->second->IsUnderwaterOnly()) { if (it->second->CheckAggro(targ)) { - if (c) + if (c) { c->RemoveXTarget(it->second, false); + } it->second->RemoveFromHateList(targ); } if (c && it->second->IsOnFeignMemory(c)) {