*Implemented gameobjects and creatures grouping (pools of them)
*Groups (called pools) can be also member of any game event Author: Neo2003 --HG-- branch : trunk
This commit is contained in:
1 parent
5076e99df1
commit
e21b2c9baa
12 files changed
+214
-39
No files matched your search
@@ -21,6 +21,7 @@
|
||||
#include "GameEvent.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PoolHandler.h"
|
||||
#include "ProgressBar.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
@@ -916,6 +917,61 @@ void GameEvent::LoadFromDB()
|
||||
|
||||
delete result;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// GameEventPool
|
||||
////////////////////////
|
||||
|
||||
mGameEventPoolIds.resize(mGameEvent.size()*2-1);
|
||||
// 1 2
|
||||
result = WorldDatabase.Query("SELECT pool_template.entry, game_event_pool.event "
|
||||
"FROM pool_template JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry");
|
||||
|
||||
count = 0;
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar2(1);
|
||||
bar2.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u pools in game events", count );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
barGoLink bar2( result->GetRowCount() );
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
bar2.step();
|
||||
|
||||
uint32 entry = fields[0].GetUInt16();
|
||||
int16 event_id = fields[1].GetInt16();
|
||||
|
||||
int32 internal_event_id = mGameEvent.size() + event_id - 1;
|
||||
|
||||
if(internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
|
||||
{
|
||||
sLog.outErrorDb("`game_event_pool` game event id (%i) is out of range compared to max event id in `game_event`",event_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!poolhandler.CheckPool(entry))
|
||||
{
|
||||
sLog.outErrorDb("Pool Id (%u) has all creatures or gameobjects with explicit chance sum <>100 and no equal chance defined. The pool system cannot pick one to spawn.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
++count;
|
||||
IdList& poollist = mGameEventPoolIds[internal_event_id];
|
||||
poollist.push_back(entry);
|
||||
|
||||
} while( result->NextRow() );
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u pools in game events", count );
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 GameEvent::GetNPCFlag(Creature * cr)
|
||||
@@ -1188,6 +1244,17 @@ void GameEvent::GameEventSpawn(int16 event_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
|
||||
{
|
||||
sLog.outError("GameEvent::GameEventSpawn attempt access to out of range mGameEventPoolIds element %i (size: %u)",internal_event_id,mGameEventPoolIds.size());
|
||||
return;
|
||||
}
|
||||
|
||||
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin();itr != mGameEventPoolIds[internal_event_id].end();++itr)
|
||||
{
|
||||
poolhandler.SpawnPool(*itr);
|
||||
}
|
||||
}
|
||||
|
||||
void GameEvent::GameEventUnspawn(int16 event_id)
|
||||
@@ -1238,6 +1305,16 @@ void GameEvent::GameEventUnspawn(int16 event_id)
|
||||
pGameobject->AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
if(internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
|
||||
{
|
||||
sLog.outError("GameEvent::GameEventUnspawn attempt access to out of range mGameEventPoolIds element %i (size: %u)",internal_event_id,mGameEventPoolIds.size());
|
||||
return;
|
||||
}
|
||||
|
||||
for (IdList::iterator itr = mGameEventPoolIds[internal_event_id].begin();itr != mGameEventPoolIds[internal_event_id].end();++itr)
|
||||
{
|
||||
poolhandler.DespawnPool(*itr);
|
||||
}
|
||||
}
|
||||
|
||||
void GameEvent::ChangeEquipOrModel(int16 event_id, bool activate)
|
||||
|
||||
Reference in new issue
Block a user