aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptMgr.cpp
diff options
context:
space:
mode:
authorr00ty-tc <r00ty-tc@users.noreply.github.com>2017-05-07 21:48:41 +0100
committerTreeston <treeston.mmoc@gmail.com>2017-07-31 21:21:04 +0200
commit59db2eeea0a35028779fd76372ae06cc98c8086f (patch)
treea9532989868948cb309cb8d76a2e76a017fa9246 /src/server/game/Scripting/ScriptMgr.cpp
parentd24ce1739a799042d5a164794c09674227c8572c (diff)
Dynamic Creature/Go spawning:
- True blizzlike creature spawn/respawn behavior - new creature = new object - Toggleable spawn groups (with C++/SAI/command options to use them) - Custom feature: dynamic spawn rate scaling. Accelerates respawn rate based on players in the zone. - Backward compatibility mode (set via group and for summons) to support creatures/gos that currently don't work well with this (this should be removed once the exceptions are fixed) Fixes and closes #2858 Tags #8661 as fixable. Fixes and closes #13787 Fixes #15222.
Diffstat (limited to 'src/server/game/Scripting/ScriptMgr.cpp')
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 9f42ded8cc6..cfc64b83005 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -1566,16 +1566,32 @@ bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo co
return tmpscript->OnCastItemCombatSpell(player, victim, spellInfo, item);
}
-bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map)
+bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureData const* cData, Map const* map)
{
- ASSERT(actTemplate);
-
+ ASSERT(map);
CreatureTemplate const* baseTemplate = sObjectMgr->GetCreatureTemplate(entry);
- if (!baseTemplate)
- baseTemplate = actTemplate;
+ ASSERT(baseTemplate);
+
+ // find out which template we'd be using
+ CreatureTemplate const* actTemplate = baseTemplate;
+ for (uint8 diff = uint8(map->GetSpawnMode()); diff > 0;)
+ {
+ if (uint32 diffEntry = baseTemplate->DifficultyEntry[diff - 1])
+ if (CreatureTemplate const* diffTemplate = sObjectMgr->GetCreatureTemplate(diffEntry))
+ {
+ actTemplate = diffTemplate;
+ break;
+ }
+ if (diff >= RAID_DIFFICULTY_10MAN_HEROIC && map->IsRaid())
+ diff -= 2;
+ else
+ diff -= 1;
+ }
+
uint32 scriptId = baseTemplate->ScriptID;
- if (cData && cData->ScriptId)
- scriptId = cData->ScriptId;
+ if (cData && cData->scriptId)
+ scriptId = cData->scriptId;
+
GET_SCRIPT_RET(CreatureScript, scriptId, tmpscript, true);
return tmpscript->CanSpawn(spawnId, entry, baseTemplate, actTemplate, cData, map);
}