mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/SmartScripts): SMART_ACTION_SET_HEALTH_PCT
This commit is contained in:
committed by
GitHub
parent
86f1b87fe6
commit
e28bdf9bde
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user