mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[10932] Imporvments gameevent creature morphing.
* Table `game_event_model_equip` renamed to `game_event_creature_data`
* Table allow now store same creatures for different events, BUT
expected that related events no active in same time.
* Added possibility switch entry at gameevent time.
This let have diff factions/loot and etc for creatures.
* Added possibility cast spells at gameevent start/end.
Exist some spells that expected casted to creature at gameevent start
for model replace, and for animation in other cases.
Note: `game_event_creature_data`.`modelid` field posisble will removed soon in fowor related spell use.
Ofc, when spells will implemented in core.
This commit is contained in:
parent
e52ebaf7a9
commit
d38df50a7e
11 changed files with 145 additions and 55 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include "Log.h"
|
||||
#include "MapManager.h"
|
||||
#include "BattleGroundMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Policies/SingletonImp.h"
|
||||
|
||||
INSTANTIATE_SINGLETON_1(GameEventMgr);
|
||||
|
|
@ -345,10 +346,12 @@ void GameEventMgr::LoadFromDB()
|
|||
|
||||
mGameEventCreatureData.resize(mGameEvent.size());
|
||||
// 0 1 2
|
||||
result = WorldDatabase.Query("SELECT creature.guid, game_event_model_equip.event, game_event_model_equip.modelid,"
|
||||
// 3
|
||||
"game_event_model_equip.equipment_id "
|
||||
"FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
|
||||
result = WorldDatabase.Query("SELECT creature.guid, game_event_creature_data.event, game_event_creature_data.modelid,"
|
||||
// 3 4
|
||||
"game_event_creature_data.equipment_id, game_event_creature_data.entry_id, "
|
||||
// 5 6
|
||||
"game_event_creature_data.spell_start, game_event_creature_data.spell_end "
|
||||
"FROM creature JOIN game_event_creature_data ON creature.guid=game_event_creature_data.guid");
|
||||
|
||||
count = 0;
|
||||
if( !result )
|
||||
|
|
@ -357,7 +360,7 @@ void GameEventMgr::LoadFromDB()
|
|||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u model/equipment changes in game events", count );
|
||||
sLog.outString(">> Loaded %u creature reactions at game events", count );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -371,35 +374,59 @@ void GameEventMgr::LoadFromDB()
|
|||
uint32 guid = fields[0].GetUInt32();
|
||||
uint16 event_id = fields[1].GetUInt16();
|
||||
|
||||
if(event_id==0)
|
||||
{
|
||||
sLog.outErrorDb("`game_event_creature_data` game event id (%i) is reserved and can't be used.",event_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(event_id >= mGameEventCreatureData.size())
|
||||
{
|
||||
sLog.outErrorDb("`game_event_model_equip` game event id (%u) is out of range compared to max event id in `game_event`",event_id);
|
||||
sLog.outErrorDb("`game_event_creature_data` game event id (%u) is out of range compared to max event id in `game_event`",event_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
++count;
|
||||
GameEventCreatureDataList& equiplist = mGameEventCreatureData[event_id];
|
||||
GameEventCreatureData newModelEquipSet;
|
||||
newModelEquipSet.modelid = fields[2].GetUInt32();
|
||||
newModelEquipSet.equipment_id = fields[3].GetUInt32();
|
||||
GameEventCreatureData newData;
|
||||
newData.modelid = fields[2].GetUInt32();
|
||||
newData.equipment_id = fields[3].GetUInt32();
|
||||
newData.entry_id = fields[4].GetUInt32();
|
||||
newData.spell_id_start = fields[5].GetUInt32();
|
||||
newData.spell_id_end = fields[6].GetUInt32();
|
||||
|
||||
if(newModelEquipSet.equipment_id > 0)
|
||||
if (newData.equipment_id && !sObjectMgr.GetEquipmentInfo(newData.equipment_id))
|
||||
{
|
||||
if(!sObjectMgr.GetEquipmentInfo(newModelEquipSet.equipment_id))
|
||||
{
|
||||
sLog.outErrorDb("Table `game_event_model_equip` have creature (Guid: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", guid, newModelEquipSet.equipment_id);
|
||||
continue;
|
||||
}
|
||||
sLog.outErrorDb("Table `game_event_creature_data` have creature (Guid: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", guid, newData.equipment_id);
|
||||
newData.equipment_id = 0;
|
||||
}
|
||||
|
||||
equiplist.push_back(GameEventCreatureDataPair(guid, newModelEquipSet));
|
||||
mGameEventCreatureDataPerGuid[guid] = event_id;
|
||||
if (newData.entry_id && !sObjectMgr.GetCreatureTemplate(newData.entry_id))
|
||||
{
|
||||
sLog.outErrorDb("Table `game_event_creature_data` have creature (Guid: %u) with event time entry %u not found in table `creature_template`, set to no 0.", guid, newData.entry_id);
|
||||
newData.entry_id = 0;
|
||||
}
|
||||
|
||||
if (newData.spell_id_start && !sSpellStore.LookupEntry(newData.spell_id_start))
|
||||
{
|
||||
sLog.outErrorDb("Table `game_event_creature_data` have creature (Guid: %u) with nonexistent spell_start %u, set to no start spell.", guid, newData.spell_id_start);
|
||||
newData.spell_id_start = 0;
|
||||
}
|
||||
|
||||
if (newData.spell_id_end && !sSpellStore.LookupEntry(newData.spell_id_end))
|
||||
{
|
||||
sLog.outErrorDb("Table `game_event_creature_data` have creature (Guid: %u) with nonexistent spell_end %u, set to no end spell.", guid, newData.spell_id_end);
|
||||
newData.spell_id_end = 0;
|
||||
}
|
||||
|
||||
equiplist.push_back(GameEventCreatureDataPair(guid, newData));
|
||||
mGameEventCreatureDataPerGuid.insert(GameEventCreatureDataPerGuidMap::value_type(guid, event_id));
|
||||
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u model/equipment changes in game events", count );
|
||||
sLog.outString(">> Loaded %u creature reactions at game events", count );
|
||||
}
|
||||
|
||||
mGameEventQuests.resize(mGameEvent.size());
|
||||
|
|
@ -726,15 +753,22 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
GameEventCreatureData const* GameEventMgr::GetCreatureUpdateDataForActiveEvent(uint32 lowguid) const
|
||||
{
|
||||
// only for active event
|
||||
GameEventCreatureDataPerGuidMap::const_iterator itr = mGameEventCreatureDataPerGuid.find(lowguid);
|
||||
if (itr == mGameEventCreatureDataPerGuid.end() || !IsActiveEvent(itr->second))
|
||||
return NULL;
|
||||
// only for active event, creature can be listed for many so search all
|
||||
uint32 event_id = 0;
|
||||
GameEventCreatureDataPerGuidBounds bounds = mGameEventCreatureDataPerGuid.equal_range(lowguid);
|
||||
for(GameEventCreatureDataPerGuidMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
{
|
||||
if (IsActiveEvent(itr->second))
|
||||
{
|
||||
event_id = itr->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 event_id = itr->second;
|
||||
if (!event_id)
|
||||
return NULL;
|
||||
|
||||
for(GameEventCreatureDataList::const_iterator itr = mGameEventCreatureData[event_id].begin();itr != mGameEventCreatureData[event_id].end();++itr)
|
||||
if (itr->first == lowguid)
|
||||
|
|
@ -754,7 +788,13 @@ void GameEventMgr::UpdateCreatureData(int16 event_id, bool activate)
|
|||
|
||||
// Update if spawned
|
||||
if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, itr->first)))
|
||||
{
|
||||
pCreature->UpdateEntry(data->id, TEAM_NONE, data, activate ? &itr->second : NULL);
|
||||
|
||||
// spells not casted for event remove case (sent NULL into update), do it
|
||||
if (!activate)
|
||||
pCreature->ApplyGameEventSpells(&itr->second, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue