Core/SAI: Preliminary implementation of SMART_EVENT_GAME_EVENT_START and SMART_EVENT_GAME_EVENT_END {param1: game_event.entry}

This commit is contained in:
Machiavelli
2011-12-11 16:23:43 +01:00
parent c7ebd0ffa9
commit 1b2c413933
10 changed files with 83 additions and 12 deletions
+27
View File
@@ -27,6 +27,8 @@
#include "GossipDef.h"
#include "Player.h"
#include "BattlegroundMgr.h"
#include "UnitAI.h"
#include "GameObjectAI.h"
bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
{
@@ -1059,6 +1061,8 @@ uint32 GameEventMgr::Update() // return the next e
void GameEventMgr::UnApplyEvent(uint16 event_id)
{
sLog->outDetail("GameEvent %u \"%s\" removed.", event_id, mGameEvent[event_id].description.c_str());
//! Run SAI scripts with SMART_EVENT_GAME_EVENT_END
RunSmartAIScripts(event_id, false);
// un-spawn positive event tagged objects
GameEventUnspawn(event_id);
// spawn negative event tagget objects
@@ -1090,6 +1094,9 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id)
sLog->outDetail("GameEvent %u \"%s\" started.", event_id, mGameEvent[event_id].description.c_str());
//! Run SAI scripts with SMART_EVENT_GAME_EVENT_END
RunSmartAIScripts(event_id, true);
// spawn positive event tagget objects
GameEventSpawn(event_id);
// un-spawn negative event tagged objects
@@ -1601,6 +1608,26 @@ void GameEventMgr::SendWorldStateUpdate(Player* player, uint16 event_id)
}
}
void GameEventMgr::RunSmartAIScripts(uint16 event_id, bool activate)
{
//! Iterate over every supported source type (creature and gameobject)
//! Not entirely sure how this will affect units in non-loaded grids.
{
TRINITY_READ_GUARD(HashMapHolder<Creature>::LockType, *HashMapHolder<Creature>::GetLock());
HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures();
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld())
iter->second->AI()->sOnGameEvent(activate, event_id);
}
{
TRINITY_READ_GUARD(HashMapHolder<GameObject>::LockType, *HashMapHolder<Creature>::GetLock());
HashMapHolder<GameObject>::MapType const& m = ObjectAccessor::GetGameObjects();
for (HashMapHolder<GameObject>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld())
iter->second->AI()->OnGameEvent(activate, event_id);
}
}
bool IsHolidayActive(HolidayIds id)
{
if (id == HOLIDAY_NONE)
+1
View File
@@ -132,6 +132,7 @@ class GameEventMgr
void UpdateEventNPCFlags(uint16 event_id);
void UpdateEventNPCVendor(uint16 event_id, bool activate);
void UpdateBattlegroundSettings();
void RunSmartAIScripts(uint16 event_id, bool activate); //! Runs SMART_EVENT_GAME_EVENT_START/_END SAI
bool CheckOneGameEventConditions(uint16 event_id);
void SaveWorldEventStateToDB(uint16 event_id);
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id);