diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 3de02a988..61d62dd38 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1978,6 +1978,43 @@ void Creature::SendZoneUnderAttackMessage(Player* attacker) sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE)); } +void Creature::SetInCombatWithZone() +{ + if (!CanHaveThreatList()) + { + error_log("Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry()); + return; + } + + Map* pMap = GetMap(); + + if (!pMap->IsDungeon()) + { + error_log("Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), pMap->GetId()); + return; + } + + Map::PlayerList const &PlList = pMap->GetPlayers(); + + if (PlList.isEmpty()) + return; + + for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) + { + if (Player* pPlayer = i->getSource()) + { + if (pPlayer->isGameMaster()) + continue; + + if (pPlayer->isAlive()) + { + pPlayer->SetInCombatWith(this); + AddThreat(pPlayer, 0.0f); + } + } + } +} + void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time) { m_CreatureSpellCooldowns[spell_id] = end_time; diff --git a/src/game/Creature.h b/src/game/Creature.h index 834dec44b..01259c3ea 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -648,6 +648,8 @@ class MANGOS_DLL_SPEC Creature : public Unit void SendZoneUnderAttackMessage(Player* attacker); + void SetInCombatWithZone(); + bool hasQuest(uint32 quest_id) const; bool hasInvolvedQuest(uint32 quest_id) const; diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index cd120c80e..7b7e6966e 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -761,15 +761,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); break; case ACTION_T_ZONE_COMBAT_PULSE: - if (!m_creature->isInCombat() || !m_creature->GetMap()->IsDungeon()) - { - - sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_ZONE_COMBAT_PULSE on creature out of combat or in non-dungeon map. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - DoZoneInCombat(m_creature); + { + m_creature->SetInCombatWithZone(); break; + } case ACTION_T_CALL_FOR_HELP: { m_creature->CallForHelp(action.call_for_help.radius); @@ -1320,33 +1315,6 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* } } -void CreatureEventAI::DoZoneInCombat(Unit* pUnit) -{ - if (!pUnit) - pUnit = m_creature; - - Map *map = pUnit->GetMap(); - - if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated - { - sLog.outErrorDb("CreatureEventAI: DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - return; - } - - if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) - { - sLog.outErrorDb("CreatureEventAI: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - - return; - } - - Map::PlayerList const &PlayerList = map->GetPlayers(); - for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* i_pl = i->getSource()) - if (!i_pl->isGameMaster()) - pUnit->AddThreat(i_pl, 0.0f); -} - void CreatureEventAI::DoMeleeAttackIfReady() { //Make sure our attack is ready before checking distance diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 8e7aab9f2..ecdcaeb6f 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -588,7 +588,6 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI inline Unit* SelectUnit(AttackingTarget target, uint32 position); void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); - void DoZoneInCombat(Unit* pUnit); void DoMeleeAttackIfReady(); bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4fb68485a..044be343f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8056" + #define REVISION_NR "8057" #endif // __REVISION_NR_H__