mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
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.
This commit is contained in:
@@ -2052,6 +2052,92 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (IsCreature(target))
|
||||
target->ToCreature()->SetCorpseDelay(e.action.corpseDelay.timer);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SPAWN_SPAWNGROUP:
|
||||
{
|
||||
if (e.action.groupSpawn.minDelay == 0 && e.action.groupSpawn.maxDelay == 0)
|
||||
{
|
||||
bool const ignoreRespawn = ((e.action.groupSpawn.spawnflags & SMARTAI_SPAWN_FLAGS::SMARTAI_SPAWN_FLAG_IGNORE_RESPAWN) != 0);
|
||||
bool const force = ((e.action.groupSpawn.spawnflags & SMARTAI_SPAWN_FLAGS::SMARTAI_SPAWN_FLAG_FORCE_SPAWN) != 0);
|
||||
|
||||
// Instant spawn
|
||||
sObjectMgr->SpawnGroupSpawn(e.action.groupSpawn.groupId, GetBaseObject()->GetMap(), ignoreRespawn, force);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Delayed spawn (use values from parameter to schedule event to call us back
|
||||
SmartEvent ne = SmartEvent();
|
||||
ne.type = (SMART_EVENT)SMART_EVENT_UPDATE;
|
||||
ne.event_chance = 100;
|
||||
|
||||
ne.minMaxRepeat.min = e.action.groupSpawn.minDelay;
|
||||
ne.minMaxRepeat.max = e.action.groupSpawn.maxDelay;
|
||||
ne.minMaxRepeat.repeatMin = 0;
|
||||
ne.minMaxRepeat.repeatMax = 0;
|
||||
|
||||
ne.event_flags = 0;
|
||||
ne.event_flags |= SMART_EVENT_FLAG_NOT_REPEATABLE;
|
||||
|
||||
SmartAction ac = SmartAction();
|
||||
ac.type = (SMART_ACTION)SMART_ACTION_SPAWN_SPAWNGROUP;
|
||||
ac.groupSpawn.groupId = e.action.groupSpawn.groupId;
|
||||
ac.groupSpawn.minDelay = 0;
|
||||
ac.groupSpawn.maxDelay = 0;
|
||||
ac.groupSpawn.spawnflags = e.action.groupSpawn.spawnflags;
|
||||
ac.timeEvent.id = e.action.timeEvent.id;
|
||||
|
||||
SmartScriptHolder ev = SmartScriptHolder();
|
||||
ev.event = ne;
|
||||
ev.event_id = e.event_id;
|
||||
ev.target = e.target;
|
||||
ev.action = ac;
|
||||
InitTimer(ev);
|
||||
mStoredEvents.push_back(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_DESPAWN_SPAWNGROUP:
|
||||
{
|
||||
if (e.action.groupSpawn.minDelay == 0 && e.action.groupSpawn.maxDelay == 0)
|
||||
{
|
||||
bool const deleteRespawnTimes = ((e.action.groupSpawn.spawnflags & SMARTAI_SPAWN_FLAGS::SMARTAI_SPAWN_FLAG_NOSAVE_RESPAWN) != 0);
|
||||
|
||||
// Instant spawn
|
||||
sObjectMgr->SpawnGroupDespawn(e.action.groupSpawn.groupId, GetBaseObject()->GetMap(), deleteRespawnTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Delayed spawn (use values from parameter to schedule event to call us back
|
||||
SmartEvent ne = SmartEvent();
|
||||
ne.type = (SMART_EVENT)SMART_EVENT_UPDATE;
|
||||
ne.event_chance = 100;
|
||||
|
||||
ne.minMaxRepeat.min = e.action.groupSpawn.minDelay;
|
||||
ne.minMaxRepeat.max = e.action.groupSpawn.maxDelay;
|
||||
ne.minMaxRepeat.repeatMin = 0;
|
||||
ne.minMaxRepeat.repeatMax = 0;
|
||||
|
||||
ne.event_flags = 0;
|
||||
ne.event_flags |= SMART_EVENT_FLAG_NOT_REPEATABLE;
|
||||
|
||||
SmartAction ac = SmartAction();
|
||||
ac.type = (SMART_ACTION)SMART_ACTION_DESPAWN_SPAWNGROUP;
|
||||
ac.groupSpawn.groupId = e.action.groupSpawn.groupId;
|
||||
ac.groupSpawn.minDelay = 0;
|
||||
ac.groupSpawn.maxDelay = 0;
|
||||
ac.groupSpawn.spawnflags = e.action.groupSpawn.spawnflags;
|
||||
ac.timeEvent.id = e.action.timeEvent.id;
|
||||
|
||||
SmartScriptHolder ev = SmartScriptHolder();
|
||||
ev.event = ne;
|
||||
ev.event_id = e.event_id;
|
||||
ev.target = e.target;
|
||||
ev.action = ac;
|
||||
InitTimer(ev);
|
||||
mStoredEvents.push_back(ev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_DISABLE_EVADE:
|
||||
|
||||
Reference in New Issue
Block a user