feat(Core/SmartScripts): SMART_ACTION_DISABLE_EVADE (#9772)

* Update SmartScriptMgr.h

* Update SmartScript.cpp

* Update SmartAI.h

* Update SmartAI.cpp
This commit is contained in:
IntelligentQuantum
2021-12-20 01:00:55 +03:30
committed by GitHub
parent 7a612f3dd9
commit f7ff583b7e
4 changed files with 29 additions and 1 deletions
@@ -46,6 +46,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
// spawn in run mode // spawn in run mode
// Xinef: spawn in run mode and set mRun to run... this overrides SetWalk EVERYWHERE // Xinef: spawn in run mode and set mRun to run... this overrides SetWalk EVERYWHERE
mRun = true; mRun = true;
mEvadeDisabled = false;
mCanAutoAttack = true; mCanAutoAttack = true;
mCanCombatMove = true; mCanCombatMove = true;
@@ -623,6 +624,12 @@ void SmartAI::EnterEvadeMode()
if (!me->IsAlive() || me->IsInEvadeMode()) if (!me->IsAlive() || me->IsInEvadeMode())
return; return;
if (mEvadeDisabled)
{
GetScript()->ProcessEventsFor(SMART_EVENT_EVADE);
return;
}
if (me->GetCharmerGUID().IsPlayer() || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) if (me->GetCharmerGUID().IsPlayer() || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
{ {
me->AttackStop(); me->AttackStop();
@@ -935,6 +942,11 @@ void SmartAI::SetSwim(bool swim)
me->SetSwim(swim); me->SetSwim(swim);
} }
void SmartAI::SetEvadeDisabled(bool disable)
{
mEvadeDisabled = disable;
}
void SmartAI::sGossipHello(Player* player) void SmartAI::sGossipHello(Player* player)
{ {
GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player); GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player);
@@ -173,6 +173,8 @@ public:
void SetSwim(bool swim = true); void SetSwim(bool swim = true);
void SetEvadeDisabled(bool disable = true);
void SetInvincibilityHpLevel(uint32 level) { mInvincibilityHpLevel = level; } void SetInvincibilityHpLevel(uint32 level) { mInvincibilityHpLevel = level; }
void sGossipHello(Player* player) override; void sGossipHello(Player* player) override;
@@ -223,6 +225,7 @@ private:
uint32 GetWPCount() { return mWayPoints ? mWayPoints->size() : 0; } uint32 GetWPCount() { return mWayPoints ? mWayPoints->size() : 0; }
bool mCanRepeatPath; bool mCanRepeatPath;
bool mRun; bool mRun;
bool mEvadeDisabled;
bool mCanAutoAttack; bool mCanAutoAttack;
bool mCanCombatMove; bool mCanCombatMove;
bool mForcedPaused; bool mForcedPaused;
@@ -3267,6 +3267,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
} }
break; break;
} }
case SMART_ACTION_DISABLE_EVADE:
{
if (!IsSmart())
break;
CAST_AI(SmartAI, me->AI())->SetEvadeDisabled(e.action.disableEvade.disable != 0);
break;
}
default: default:
LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry %d SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break; break;
@@ -585,7 +585,7 @@ enum SMART_ACTION
SMART_ACTION_RISE_UP = 114, // distance SMART_ACTION_RISE_UP = 114, // distance
SMART_ACTION_RANDOM_SOUND = 115, // SoundId1, SoundId2, SoundId3, SoundId4, onlySelf SMART_ACTION_RANDOM_SOUND = 115, // SoundId1, SoundId2, SoundId3, SoundId4, onlySelf
SMART_ACTION_SET_CORPSE_DELAY = 116, // TODO: NOT SUPPORTED YET SMART_ACTION_SET_CORPSE_DELAY = 116, // TODO: NOT SUPPORTED YET
SMART_ACTION_DISABLE_EVADE = 117, // TODO: NOT SUPPORTED YET SMART_ACTION_DISABLE_EVADE = 117, // 0/1 (1 = disabled, 0 = enabled)
SMART_ACTION_GO_SET_GO_STATE = 118, // TODO: NOT SUPPORTED YET SMART_ACTION_GO_SET_GO_STATE = 118, // TODO: NOT SUPPORTED YET
SMART_ACTION_SET_CAN_FLY = 119, // TODO: NOT SUPPORTED YET SMART_ACTION_SET_CAN_FLY = 119, // TODO: NOT SUPPORTED YET
SMART_ACTION_REMOVE_AURAS_BY_TYPE = 120, // TODO: NOT SUPPORTED YET SMART_ACTION_REMOVE_AURAS_BY_TYPE = 120, // TODO: NOT SUPPORTED YET
@@ -1274,6 +1274,11 @@ struct SmartAction
uint32 isNegative; uint32 isNegative;
uint32 instanceTarget; uint32 instanceTarget;
} doAction; } doAction;
struct
{
uint32 disable;
} disableEvade;
//! Note for any new future actions //! Note for any new future actions
//! All parameters must have type uint32 //! All parameters must have type uint32