[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:
VladimirMangos 2010-12-28 23:32:57 +03:00
parent e52ebaf7a9
commit d38df50a7e
11 changed files with 145 additions and 55 deletions

View file

@ -200,6 +200,10 @@ void Creature::RemoveCorpse()
*/
bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/ )
{
// use game event entry if any instead default suggested
if (eventData && eventData->entry_id)
Entry = eventData->entry_id;
CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if(!normalInfo)
{
@ -357,6 +361,10 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=
for(int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = GetCreatureInfo()->spells[i];
// if eventData set then event active and need apply spell_start
if (eventData)
ApplyGameEventSpells(eventData, true);
return true;
}
@ -447,7 +455,11 @@ void Creature::Update(uint32 update_diff, uint32 diff)
lootForSkin = false;
if(m_originalEntry != GetEntry())
UpdateEntry(m_originalEntry);
{
// need preserver gameevent state
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetDBTableGUIDLow());
UpdateEntry(m_originalEntry, TEAM_NONE, NULL, eventData);
}
CreatureInfo const *cinfo = GetCreatureInfo();
@ -1351,7 +1363,7 @@ void Creature::DeleteFromDB()
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.CommitTransaction();
}
@ -2344,3 +2356,17 @@ void Creature::RelocationNotify()
float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO);
Cell::VisitAllObjects(this, relocationNotifier, radius);
}
void Creature::ApplyGameEventSpells(GameEventCreatureData const* eventData, bool activated)
{
uint32 cast_spell = activated ? eventData->spell_id_start : eventData->spell_id_end;
uint32 remove_spell = activated ? eventData->spell_id_end : eventData->spell_id_start;
if (remove_spell)
if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(remove_spell))
if (IsSpellAppliesAura(spellEntry))
RemoveAurasDueToSpell(remove_spell);
if (cast_spell)
CastSpell(this, cast_spell, true);
}