Merge pull request #1017 from noudess/master

Fix Issue #849.
This commit is contained in:
Chris Miles
2020-04-06 15:39:43 -05:00
committed by GitHub
5 changed files with 44 additions and 2 deletions
+6
View File
@@ -32,6 +32,7 @@
#endif
#include "map.h"
#include "water_map.h"
extern Zone* zone;
//#define LOSDEBUG 6
@@ -237,6 +238,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
+5
View File
@@ -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;
+2
View File
@@ -1293,6 +1293,8 @@ public:
void SendHPUpdateMarquee();
void CheckRegionTypeChanges();
WaterRegionType GetLastRegion() { return last_region_type; }
int32 CalcATK();
+30 -2
View File
@@ -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)) {
@@ -3294,6 +3296,32 @@ void EntityList::ClearAggro(Mob* targ)
}
}
//removes "targ" from all hate lists of mobs that are water only.
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);
}
}
++it;
}
}
void EntityList::ClearFeignAggro(Mob *targ)
{
auto it = npc_list.begin();
+1
View File
@@ -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);