feat(Core/SAI): Implement New Smart Actions SET_SCALE & SUMMON_RADIAL (#16444)

* init

* Update SmartScriptMgr.cpp

* Update SmartScript.cpp

* Update SmartScriptMgr.h

* more

* scale

* dist offset

* Update SmartScriptMgr.h
This commit is contained in:
Gultask
2023-06-27 19:34:26 -03:00
committed by GitHub
parent 6edcf05cc2
commit 7ec04d1408
3 changed files with 77 additions and 4 deletions

View File

@@ -1644,6 +1644,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break; break;
} }
if (e.action.orientation.turnAngle)
{
float turnOri = me->GetOrientation() + (static_cast<float>(e.action.orientation.turnAngle) * M_PI / 180.0f);
me->SetFacingTo(turnOri);
if (e.action.orientation.quickChange)
me->SetOrientation(turnOri);
break;
}
if (e.GetTargetType() == SMART_TARGET_SELF) if (e.GetTargetType() == SMART_TARGET_SELF)
{ {
me->SetFacingTo((me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && me->GetTransGUID() ? me->GetTransportHomePosition() : me->GetHomePosition()).GetOrientation()); me->SetFacingTo((me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && me->GetTransGUID() ? me->GetTransportHomePosition() : me->GetHomePosition()).GetOrientation());
@@ -2824,6 +2833,48 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
} }
break; break;
} }
case SMART_ACTION_SET_SCALE:
{
float scale = static_cast<float>(e.action.setScale.scale) / 100.0f;
for (WorldObject* target : targets)
{
if (IsUnit(target))
{
target->ToUnit()->SetObjectScale(scale);
}
}
break;
}
case SMART_ACTION_SUMMON_RADIAL:
{
if (!me)
break;
TempSummonType spawnType = (e.action.radialSummon.summonDuration > 0) ? TEMPSUMMON_TIMED_DESPAWN : TEMPSUMMON_CORPSE_DESPAWN;
float startAngle = me->GetOrientation() + (static_cast<float>(e.action.radialSummon.startAngle) * M_PI / 180.0f);
float stepAngle = static_cast<float>(e.action.radialSummon.stepAngle) * M_PI / 180.0f;
if (e.action.radialSummon.dist)
{
for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
{
Position summonPos = me->GetPosition();
summonPos.RelocatePolarOffset(itr * stepAngle, static_cast<float>(e.action.radialSummon.dist));
me->SummonCreature(e.action.radialSummon.summonEntry, summonPos, spawnType, e.action.radialSummon.summonDuration);
}
break;
}
for (uint32 itr = 0; itr < e.action.radialSummon.repetitions; itr++)
{
float currentAngle = startAngle + (itr * stepAngle);
me->SummonCreature(e.action.radialSummon.summonEntry, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), currentAngle, spawnType, e.action.radialSummon.summonDuration);
}
break;
}
default: default:
LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break; break;

View File

@@ -671,7 +671,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_SET_COUNTER: return sizeof(SmartAction::setCounter); case SMART_ACTION_SET_COUNTER: return sizeof(SmartAction::setCounter);
case SMART_ACTION_STORE_TARGET_LIST: return sizeof(SmartAction::storeTargets); case SMART_ACTION_STORE_TARGET_LIST: return sizeof(SmartAction::storeTargets);
case SMART_ACTION_WP_RESUME: return NO_PARAMS; case SMART_ACTION_WP_RESUME: return NO_PARAMS;
case SMART_ACTION_SET_ORIENTATION: return NO_PARAMS; case SMART_ACTION_SET_ORIENTATION: return sizeof(SmartAction::orientation);
case SMART_ACTION_CREATE_TIMED_EVENT: return sizeof(SmartAction::timeEvent); case SMART_ACTION_CREATE_TIMED_EVENT: return sizeof(SmartAction::timeEvent);
case SMART_ACTION_PLAYMOVIE: return sizeof(SmartAction::movie); case SMART_ACTION_PLAYMOVIE: return sizeof(SmartAction::movie);
case SMART_ACTION_MOVE_TO_POS: return sizeof(SmartAction::moveToPos); case SMART_ACTION_MOVE_TO_POS: return sizeof(SmartAction::moveToPos);
@@ -763,6 +763,8 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_MUSIC: return sizeof(SmartAction::music); case SMART_ACTION_MUSIC: return sizeof(SmartAction::music);
case SMART_ACTION_SET_GUID: return sizeof(SmartAction::setGuid); case SMART_ACTION_SET_GUID: return sizeof(SmartAction::setGuid);
case SMART_ACTION_DISABLE: return sizeof(SmartAction::disable); case SMART_ACTION_DISABLE: return sizeof(SmartAction::disable);
case SMART_ACTION_SET_SCALE: return sizeof(SmartAction::setScale);
case SMART_ACTION_SUMMON_RADIAL: return sizeof(SmartAction::radialSummon);
default: default:
LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.", LOG_WARN("sql.sql", "SmartAIMgr: entryorguid {} source_type {} id {} action_type {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.",
e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
@@ -1920,6 +1922,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
case SMART_ACTION_PLAY_CINEMATIC: case SMART_ACTION_PLAY_CINEMATIC:
case SMART_ACTION_SET_GUID: case SMART_ACTION_SET_GUID:
case SMART_ACTION_DISABLE: case SMART_ACTION_DISABLE:
case SMART_ACTION_SET_SCALE:
case SMART_ACTION_SUMMON_RADIAL:
break; break;
default: default:
LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type({}), event_type({}), Entry {} SourceType {} Event {}, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id); LOG_ERROR("sql.sql", "SmartAIMgr: Not handled action_type({}), event_type({}), Entry {} SourceType {} Event {}, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);

View File

@@ -588,7 +588,7 @@ enum SMART_ACTION
SMART_ACTION_SET_COUNTER = 63, // id, value, reset (0/1) SMART_ACTION_SET_COUNTER = 63, // id, value, reset (0/1)
SMART_ACTION_STORE_TARGET_LIST = 64, // varID, SMART_ACTION_STORE_TARGET_LIST = 64, // varID,
SMART_ACTION_WP_RESUME = 65, // none SMART_ACTION_WP_RESUME = 65, // none
SMART_ACTION_SET_ORIENTATION = 66, // quick change, random orientation? (0/1) SMART_ACTION_SET_ORIENTATION = 66, // quick change, random orientation? (0/1), turnAngle
SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance
SMART_ACTION_PLAYMOVIE = 68, // entry SMART_ACTION_PLAYMOVIE = 68, // entry
SMART_ACTION_MOVE_TO_POS = 69, // PointId (optional x,y,z offset), transport, controlled, ContactDistance SMART_ACTION_MOVE_TO_POS = 69, // PointId (optional x,y,z offset), transport, controlled, ContactDistance
@@ -693,9 +693,11 @@ enum SMART_ACTION
SMART_ACTION_DO_ACTION = 223, // ActionId SMART_ACTION_DO_ACTION = 223, // ActionId
SMART_ACTION_ATTACK_STOP = 224, // 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_SET_GUID = 225, // Sends the invoker's or the base object's own ObjectGuid to target
SMART_ACTION_DISABLE = 226, // Disable the targeted creatures, setting them Invisible and Immune to All SMART_ACTION_DISABLE = 226, // state
SMART_ACTION_SET_SCALE = 227, // scale
SMART_ACTION_SUMMON_RADIAL = 228, // summonEntry, summonDuration, repetitions, startAngle, stepAngle, dist
SMART_ACTION_AC_END = 227, // placeholder SMART_ACTION_AC_END = 229, // placeholder
}; };
enum class SmartActionSummonCreatureFlags enum class SmartActionSummonCreatureFlags
@@ -1289,6 +1291,7 @@ struct SmartAction
{ {
uint32 quickChange; uint32 quickChange;
uint32 random; uint32 random;
uint32 turnAngle;
} orientation; } orientation;
struct struct
@@ -1376,6 +1379,21 @@ struct SmartAction
{ {
SAIBool state; SAIBool state;
} disable; } disable;
struct
{
uint32 scale;
} setScale;
struct
{
uint32 summonEntry;
uint32 summonDuration;
uint32 repetitions;
uint32 startAngle;
uint32 stepAngle;
uint32 dist;
} radialSummon;
//! Note for any new future actions //! Note for any new future actions
//! All parameters must have type uint32 //! All parameters must have type uint32