feat(Core/SmartScripts): SMART_ACTION_SET_HEALTH_PCT

This commit is contained in:
IntelligentQuantum
2022-01-05 16:08:14 +03:30
committed by GitHub
parent 86f1b87fe6
commit e28bdf9bde
3 changed files with 36 additions and 0 deletions

View File

@@ -3311,6 +3311,25 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
}
delete targets;
break;
}
case SMART_ACTION_SET_HEALTH_PCT:
{
ObjectList* targets = GetTargets(e, unit);
if (!targets)
{
break;
}
for (auto const& target : *targets)
{
if (Unit* targetUnit = target->ToUnit())
{
targetUnit->SetHealth(targetUnit->CountPctFromMaxHealth(e.action.setHealthPct.percent));
}
}
delete targets;
break;
}

View File

@@ -1172,6 +1172,16 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
}
case SMART_ACTION_SET_HEALTH_PCT:
{
if (e.action.setHealthPct.percent > 100 || !e.action.setHealthPct.percent)
{
LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u is trying to set invalid HP percent %u, skipped.",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.setHealthPct.percent);
return false;
}
break;
}
case SMART_ACTION_START_CLOSEST_WAYPOINT:
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:

View File

@@ -608,6 +608,8 @@ enum SMART_ACTION
SMART_ACTION_TC_END = 135, // placeholder
SMART_ACTION_SET_HEALTH_PCT = 142, // percent
// AC-only SmartActions:
SMART_ACTION_AC_START = 200, // placeholder
@@ -1286,6 +1288,11 @@ struct SmartAction
{
uint32 timer;
} corpseDelay;
struct
{
uint32 percent;
} setHealthPct;
//! Note for any new future actions
//! All parameters must have type uint32