mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 12:47:07 +00:00
feat(Core/SmartScripts): Implement Scripted Spawn System (#19499)
* prespawn2 * pfta * Update rev_1717715555182000500.sql * Update rev_1717715555182000500.sql * Update rev_1717715555182000500.sql * Update rev_1717715555182000500.sql * Update rev_1717715555182000500.sql * Update rev_1717715555182000500.sql
This commit is contained in:
@@ -70,6 +70,8 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
mJustReset = false;
|
||||
|
||||
mcanSpawn = true;
|
||||
|
||||
// Xinef: Vehicle conditions
|
||||
m_ConditionsTimer = 0;
|
||||
if (me->GetVehicleKit())
|
||||
@@ -1166,6 +1168,7 @@ void SmartAI::OnSpellClick(Unit* clicker, bool& /*result*/)
|
||||
void SmartAI::PathEndReached(uint32 /*pathId*/)
|
||||
{
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_DATA_ENDED, nullptr, 0, me->GetWaypointPath());
|
||||
me->LoadPath(0);
|
||||
}
|
||||
|
||||
void SmartGameObjectAI::SummonedCreatureDies(Creature* summon, Unit* /*killer*/)
|
||||
|
||||
@@ -207,6 +207,9 @@ public:
|
||||
|
||||
void PathEndReached(uint32 pathId) override;
|
||||
|
||||
bool CanRespawn() override { return mcanSpawn; };
|
||||
void SetCanRespawn(bool canSpawn) { mcanSpawn = canSpawn; }
|
||||
|
||||
// Xinef
|
||||
void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; }
|
||||
|
||||
@@ -249,6 +252,8 @@ private:
|
||||
uint32 mEscortInvokerCheckTimer;
|
||||
bool mJustReset;
|
||||
|
||||
bool mcanSpawn;
|
||||
|
||||
// Xinef: Vehicle conditions
|
||||
void CheckConditions(const uint32 diff);
|
||||
ConditionList conditions;
|
||||
|
||||
@@ -2940,15 +2940,64 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_DISABLE:
|
||||
case SMART_ACTION_SCRIPTED_SPAWN:
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
// Enable Scripted Spawns
|
||||
switch (e.action.scriptSpawn.state)
|
||||
{
|
||||
if (IsUnit(target))
|
||||
case 0: // Disable Respawn
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
target->ToUnit()->SetImmuneToAll(!e.action.disable.state);
|
||||
target->ToUnit()->SetVisible(e.action.disable.state);
|
||||
if (Creature* c = target->ToCreature())
|
||||
{
|
||||
CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
|
||||
if (!e.action.scriptSpawn.dontDespawn)
|
||||
c->DespawnOrUnsummon();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: // Respawn Once
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
if (Creature* c = target->ToCreature())
|
||||
{
|
||||
CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
|
||||
c->Respawn(true);
|
||||
CAST_AI(SmartAI, c->AI())->SetCanRespawn(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: // Enable Respawning
|
||||
{
|
||||
for (WorldObject* target : targets)
|
||||
{
|
||||
if (Creature* c = target->ToCreature())
|
||||
{
|
||||
CAST_AI(SmartAI, c->AI())->SetCanRespawn(true);
|
||||
|
||||
// If 0, respawn immediately
|
||||
if (e.action.scriptSpawn.spawnTimerMax)
|
||||
c->SetRespawnTime(urand(e.action.scriptSpawn.spawnTimerMin, e.action.scriptSpawn.spawnTimerMax));
|
||||
else
|
||||
c->Respawn(true);
|
||||
|
||||
// If 0, use DB values
|
||||
if (e.action.scriptSpawn.respawnDelay)
|
||||
c->SetRespawnDelay(e.action.scriptSpawn.respawnDelay);
|
||||
|
||||
// If 0, use default
|
||||
if (e.action.scriptSpawn.corpseDelay)
|
||||
c->SetCorpseDelay(e.action.scriptSpawn.corpseDelay);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
|
||||
case SMART_ACTION_LOAD_GRID: return NO_PARAMS;
|
||||
case SMART_ACTION_MUSIC: return sizeof(SmartAction::music);
|
||||
case SMART_ACTION_SET_GUID: return sizeof(SmartAction::setGuid);
|
||||
case SMART_ACTION_DISABLE: return sizeof(SmartAction::disable);
|
||||
case SMART_ACTION_SCRIPTED_SPAWN: return sizeof(SmartAction::scriptSpawn);
|
||||
case SMART_ACTION_SET_SCALE: return sizeof(SmartAction::setScale);
|
||||
case SMART_ACTION_SUMMON_RADIAL: return sizeof(SmartAction::radialSummon);
|
||||
case SMART_ACTION_PLAY_SPELL_VISUAL: return sizeof(SmartAction::spellVisual);
|
||||
@@ -1949,7 +1949,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_ATTACK_STOP:
|
||||
case SMART_ACTION_PLAY_CINEMATIC:
|
||||
case SMART_ACTION_SET_GUID:
|
||||
case SMART_ACTION_DISABLE:
|
||||
case SMART_ACTION_SCRIPTED_SPAWN:
|
||||
case SMART_ACTION_SET_SCALE:
|
||||
case SMART_ACTION_SUMMON_RADIAL:
|
||||
case SMART_ACTION_PLAY_SPELL_VISUAL:
|
||||
|
||||
@@ -716,7 +716,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_DO_ACTION = 223, // ActionId
|
||||
SMART_ACTION_ATTACK_STOP = 224, //
|
||||
SMART_ACTION_SET_GUID = 225, // Sends the invoker's or the base object's own ObjectGuid to target
|
||||
SMART_ACTION_DISABLE = 226, // state
|
||||
SMART_ACTION_SCRIPTED_SPAWN = 226, // state, spawnTimerMin, spawnTimerMax, respawnDelay, corpseDelay, dontDespawn
|
||||
SMART_ACTION_SET_SCALE = 227, // scale
|
||||
SMART_ACTION_SUMMON_RADIAL = 228, // summonEntry, summonDuration, repetitions, startAngle, stepAngle, dist
|
||||
SMART_ACTION_PLAY_SPELL_VISUAL = 229, // visualId, visualIdImpact
|
||||
@@ -1411,7 +1411,12 @@ struct SmartAction
|
||||
struct
|
||||
{
|
||||
SAIBool state;
|
||||
} disable;
|
||||
uint32 spawnTimerMin;
|
||||
uint32 spawnTimerMax;
|
||||
uint32 respawnDelay;
|
||||
uint32 corpseDelay;
|
||||
SAIBool dontDespawn;
|
||||
} scriptSpawn;
|
||||
|
||||
struct
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user