aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-01-04 04:46:22 +0100
committerShauren <shauren.trinity@gmail.com>2021-05-16 21:56:05 +0200
commit5aee452943e5c76f54f58eea9e6880b54a61ec9c (patch)
treef604cbf92a9207d6d9f8d94ff1a8d8b08f3d248f /src/server/game
parent83159544b52bf48e8ba3a6eb98c1f4918c0b7bbe (diff)
Core/Misc: A variety of clean-up changes, mostly following up on 532ab1c to fix legacy bugs exposed by it:
- Triggers can no longer have a threat list (this may expose some ugliness in old legacy scripts) - Threat entries are forced to OFFLINE if the AI refuses to attack the target - Clean up passive creature evade behavior to be more consistent - Fix a months old issue in spawn group management that would cause "Inactive" to incorrectly show in .list respawns for system groups outside of map 0 - Valithria script cleanups, remove old hacks and make it work with the new system. Closes #21174. - Some strings cleanup (cherry picked from commit 9f9507e6a1fd50a5ce643a4096c1712700244a61)
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/CreatureAI.cpp17
-rw-r--r--src/server/game/Combat/ThreatManager.cpp11
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp2
-rw-r--r--src/server/game/Maps/Map.cpp5
4 files changed, 20 insertions, 15 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 2c07dcd551d..6e337ff8c5d 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -84,11 +84,12 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange
{
if (Unit* summoner = creature->ToTempSummon()->GetSummoner())
{
- Unit* target = summoner->getAttackerForHelper();
- if (!target && !summoner->GetThreatManager().IsThreatListEmpty())
- target = summoner->GetThreatManager().GetAnyTarget();
- if (target && (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(target)))
- creature->AI()->AttackStart(target);
+ if (creature->IsFriendlyTo(summoner))
+ {
+ Unit* target = summoner->getAttackerForHelper();
+ if (target && creature->IsHostileTo(target))
+ creature->AI()->AttackStart(target);
+ }
}
}
}
@@ -109,7 +110,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange
for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
if (Player* player = itr->GetSource())
if (player->IsAlive())
- creature->SetInCombatWith(player);
+ creature->EngageWithTarget(player);
}
// scripts does not take care about MoveInLineOfSight loops
@@ -237,12 +238,12 @@ bool CreatureAI::UpdateVictim()
return me->GetVictim() != nullptr;
}
- else if (me->GetThreatManager().IsThreatListEmpty(true))
+ else if (!me->IsInCombat())
{
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
return false;
}
- else
+ else if (me->GetVictim())
me->AttackStop();
return true;
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index 16511b14a3b..03d12c12def 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -94,6 +94,8 @@ ThreatReference::OnlineState ThreatReference::SelectOnlineState()
return ONLINE_STATE_OFFLINE;
if (!FlagsAllowFighting(_owner, _victim) || !FlagsAllowFighting(_victim, _owner))
return ONLINE_STATE_OFFLINE;
+ if (_owner->IsAIEnabled && !_owner->GetAI()->CanAIAttack(_victim))
+ return ONLINE_STATE_OFFLINE;
// next, check suppression (immunity to chosen melee attack school)
if (_victim->IsImmunedToDamage(_owner->GetMeleeDamageSchoolMask()))
return ONLINE_STATE_SUPPRESSED;
@@ -135,16 +137,17 @@ void ThreatReference::ClearThreat(bool sendRemove)
/*static*/ bool ThreatManager::CanHaveThreatList(Unit const* who)
{
+ Creature const* cWho = who->ToCreature();
// only creatures can have threat list
- if (who->GetTypeId() != TYPEID_UNIT)
+ if (!cWho)
return false;
- // pets and totems cannot have threat list
- if (who->IsPet() || who->IsTotem())
+ // pets, totems and triggers cannot have threat list
+ if (cWho->IsPet() || cWho->IsTotem() || cWho->IsTrigger())
return false;
// summons cannot have a threat list, unless they are controlled by a creature
- if (who->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN) && !who->GetOwnerGUID().IsCreature())
+ if (cWho->HasUnitTypeMask(UNIT_MASK_MINION | UNIT_MASK_GUARDIAN) && !cWho->GetOwnerGUID().IsCreature())
return false;
return true;
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index e6fd20e73aa..585dbe4a6ce 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -678,7 +678,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
void Creature::Update(uint32 diff)
{
- if (IsAIEnabled && m_triggerJustAppeared && m_deathState == ALIVE)
+ if (IsAIEnabled && m_triggerJustAppeared && m_deathState != DEAD)
{
if (m_respawnCompatibilityMode && m_vehicleKit)
m_vehicleKit->Reset();
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 8d6d2e8f663..557bec6dbd0 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -3396,7 +3396,7 @@ void Map::ApplyDynamicModeRespawnScaling(WorldObject const* obj, ObjectGuid::Low
SpawnGroupTemplateData const* Map::GetSpawnGroupData(uint32 groupId) const
{
SpawnGroupTemplateData const* data = sObjectMgr->GetSpawnGroupData(groupId);
- if (data && data->mapId == GetId())
+ if (data && (data->flags & SPAWNGROUP_FLAG_SYSTEM || data->mapId == GetId()))
return data;
return nullptr;
}
@@ -3527,11 +3527,12 @@ bool Map::IsSpawnGroupActive(uint32 groupId) const
SpawnGroupTemplateData const* const data = GetSpawnGroupData(groupId);
if (!data)
{
- TC_LOG_WARN("maps", "Tried to query state of non-existing spawn group %u on map %u.", groupId, GetId());
+ TC_LOG_ERROR("maps", "Tried to query state of non-existing spawn group %u on map %u.", groupId, GetId());
return false;
}
if (data->flags & SPAWNGROUP_FLAG_SYSTEM)
return true;
+ // either manual spawn group and toggled, or not manual spawn group and not toggled...
return (_toggledSpawnGroupIds.find(groupId) != _toggledSpawnGroupIds.end()) != !(data->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN);
}