mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Game/Scripting: Follow-up to b3d44d6. Fix script selection for creatures on difficulty > 0.
This commit is contained in:
@@ -519,7 +519,7 @@ void Creature::Update(uint32 diff)
|
||||
if (m_respawnTime <= now)
|
||||
{
|
||||
// First check if there are any scripts that object to us respawning
|
||||
if (!sScriptMgr->CanSpawn(GetSpawnId(), GetCreatureTemplate(), GetCreatureData(), GetMap()))
|
||||
if (!sScriptMgr->CanSpawn(GetSpawnId(), GetEntry(), GetCreatureTemplate(), GetCreatureData(), GetMap()))
|
||||
break; // Will be rechecked on next Update call
|
||||
|
||||
ObjectGuid dbtableHighGuid(HighGuid::Unit, GetEntry(), m_spawnId);
|
||||
@@ -1390,7 +1390,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
|
||||
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId);
|
||||
|
||||
// Is the creature script objecting to us spawning? If yes, delay by one second (then re-check in ::Update)
|
||||
if (!m_respawnTime && !sScriptMgr->CanSpawn(spawnId, GetCreatureTemplate(), GetCreatureData(), map))
|
||||
if (!m_respawnTime && !sScriptMgr->CanSpawn(spawnId, GetEntry(), GetCreatureTemplate(), GetCreatureData(), map))
|
||||
m_respawnTime = time(NULL)+1;
|
||||
|
||||
if (m_respawnTime) // respawn on Update
|
||||
|
||||
@@ -1602,12 +1602,13 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature)
|
||||
return tmpscript->GetDialogStatus(player, creature);
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, CreatureTemplate const* cTemplate, CreatureData const* cData, Map const* map)
|
||||
bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map)
|
||||
{
|
||||
ASSERT(cTemplate);
|
||||
|
||||
GET_SCRIPT_RET(CreatureScript, cTemplate->ScriptID, tmpscript, true);
|
||||
return tmpscript->CanSpawn(spawnId, cTemplate, cData, map);
|
||||
CreatureTemplate const* baseTemplate = sObjectMgr->GetCreatureTemplate(entry);
|
||||
GET_SCRIPT_RET(CreatureScript, baseTemplate->ScriptID, tmpscript, true);
|
||||
return tmpscript->CanSpawn(spawnId, entry, baseTemplate, actTemplate, cData, map);
|
||||
}
|
||||
|
||||
CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
|
||||
|
||||
@@ -435,7 +435,7 @@ class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScript<Cre
|
||||
virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
|
||||
|
||||
// Called when the creature tries to spawn. Return false to block spawn and re-evaluate on next tick.
|
||||
virtual bool CanSpawn(ObjectGuid::LowType /*spawnId*/, CreatureTemplate const* /*cTemplate*/, CreatureData const* /*cData*/, Map const* /*map*/) const { return true; }
|
||||
virtual bool CanSpawn(ObjectGuid::LowType /*spawnId*/, uint32 /*entry*/, CreatureTemplate const* /*baseTemplate*/, CreatureTemplate const* /*actTemplate*/, CreatureData const* /*cData*/, Map const* /*map*/) const { return true; }
|
||||
|
||||
// Called when a CreatureAI object is needed for the creature.
|
||||
virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; }
|
||||
@@ -962,7 +962,7 @@ class TC_GAME_API ScriptMgr
|
||||
bool OnQuestSelect(Player* player, Creature* creature, Quest const* quest);
|
||||
bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt);
|
||||
uint32 GetDialogStatus(Player* player, Creature* creature);
|
||||
bool CanSpawn(ObjectGuid::LowType spawnId, CreatureTemplate const* cTemplate, CreatureData const* cData, Map const* map);
|
||||
bool CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* baseTemplate, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map);
|
||||
CreatureAI* GetCreatureAI(Creature* creature);
|
||||
void OnCreatureUpdate(Creature* creature, uint32 diff);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user