fix(Core/SmartScripts): Allow SAI_ACTION_DIE to accept params (#16411)

This commit is contained in:
Angelo Venturini
2023-05-31 23:32:15 -03:00
committed by GitHub
parent 44e461ce6f
commit d204eccdea
4 changed files with 28 additions and 3 deletions

View File

@@ -1139,7 +1139,22 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_DIE:
{
if (me && !me->isDead())
if (e.action.die.milliseconds)
{
if (me && !me->isDead())
{
me->m_Events.AddEventAtOffset([&]
{
// We need to check again to see if we didn't die in the process.
if (me && !me->isDead())
{
me->KillSelf();
LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());
}
}, Milliseconds(e.action.die.milliseconds));
}
}
else if (me && !me->isDead())
{
me->KillSelf();
LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_DIE: Creature {}", me->GetGUID().ToString());

View File

@@ -641,7 +641,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_SET_INST_DATA: return sizeof(SmartAction::setInstanceData);
case SMART_ACTION_SET_INST_DATA64: return sizeof(SmartAction::setInstanceData64);
case SMART_ACTION_UPDATE_TEMPLATE: return sizeof(SmartAction::updateTemplate);
case SMART_ACTION_DIE: return NO_PARAMS;
case SMART_ACTION_DIE: return sizeof(SmartAction::die);
case SMART_ACTION_SET_IN_COMBAT_WITH_ZONE: return NO_PARAMS;
case SMART_ACTION_CALL_FOR_HELP: return sizeof(SmartAction::callHelp);
case SMART_ACTION_SET_SHEATH: return sizeof(SmartAction::setSheath);

View File

@@ -559,7 +559,7 @@ enum SMART_ACTION
SMART_ACTION_SET_INST_DATA = 34, // Field, Data
SMART_ACTION_SET_INST_DATA64 = 35, // Field,
SMART_ACTION_UPDATE_TEMPLATE = 36, // Entry, UpdateLevel
SMART_ACTION_DIE = 37, // No Params
SMART_ACTION_DIE = 37, // Milliseconds
SMART_ACTION_SET_IN_COMBAT_WITH_ZONE = 38, // Range (if outside of dungeon)
SMART_ACTION_CALL_FOR_HELP = 39, // Radius, With Emote
SMART_ACTION_SET_SHEATH = 40, // Sheath (0-unarmed, 1-melee, 2-ranged)
@@ -925,6 +925,11 @@ struct SmartAction
SAIBool updateLevel;
} updateTemplate;
struct
{
uint32 milliseconds;
} die;
struct
{
uint32 range;