mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-15 20:52:22 -04:00
Scripts/SmartScripts: Fix charmed behavior for SmartAI. For real this time.
- Core AI logic will no longer issue attack/movement commands while under player control. - Add new SMART_EVENT_FLAG_WHILE_CHARMED (0x200). Any event without this flag won't run while charmed. - Add SMART_EVENT_FLAG_WHILE_CHARMED to existing actions, except a select subset (movement, talking, and nontriggered casts, pretty much).
This commit is contained in:
@@ -99,7 +99,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
//calc random
|
||||
if (e.GetEventType() != SMART_EVENT_LINK && e.event.event_chance < 100 && e.event.event_chance)
|
||||
{
|
||||
uint32 rnd = urand(0, 100);
|
||||
uint32 rnd = urand(1, 100);
|
||||
if (e.event.event_chance <= rnd)
|
||||
return;
|
||||
}
|
||||
@@ -769,6 +769,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
me->DoFleeToGetAssistance();
|
||||
|
||||
if (e.action.flee.withEmote)
|
||||
{
|
||||
Trinity::BroadcastTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, BROADCAST_TEXT_FLEE_FOR_ASSIST);
|
||||
@@ -1175,6 +1176,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!IsCreature(*itr))
|
||||
continue;
|
||||
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && !IsCreatureInControlOfSelf(*itr))
|
||||
continue;
|
||||
|
||||
Position pos = (*itr)->GetPosition();
|
||||
|
||||
// Use forward/backward/left/right cartesian plane movement
|
||||
@@ -2848,6 +2852,9 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if ((e.event.event_phase_mask && !IsInPhase(e.event.event_phase_mask)) || ((e.event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE) && e.runOnce))
|
||||
return;
|
||||
|
||||
if (!(e.event.event_flags & SMART_EVENT_FLAG_WHILE_CHARMED) && IsCreature(me) && !IsCreatureInControlOfSelf(me))
|
||||
return;
|
||||
|
||||
switch (e.GetEventType())
|
||||
{
|
||||
case SMART_EVENT_LINK://special handling
|
||||
@@ -2987,12 +2994,16 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
ProcessTimedAction(e, e.event.aura.repeatMin, e.event.aura.repeatMax);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_CHARMED:
|
||||
{
|
||||
if (bvar == (e.event.charm.onRemove != 1))
|
||||
ProcessAction(e, unit, var0, var1, bvar, spell, gob);
|
||||
}
|
||||
//no params
|
||||
case SMART_EVENT_AGGRO:
|
||||
case SMART_EVENT_DEATH:
|
||||
case SMART_EVENT_EVADE:
|
||||
case SMART_EVENT_REACHED_HOME:
|
||||
case SMART_EVENT_CHARMED:
|
||||
case SMART_EVENT_CHARMED_TARGET:
|
||||
case SMART_EVENT_CORPSE_REMOVED:
|
||||
case SMART_EVENT_AI_INIT:
|
||||
|
||||
Reference in New Issue
Block a user