aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-03-13 20:22:47 +0100
committerShauren <shauren.trinity@gmail.com>2023-03-13 20:22:47 +0100
commitd26d38075cdb56dcef77f05276a360e717cc5032 (patch)
treef35aa8fa9e9a3b1bef09f38d3709f1fbf44eaddd /src/server/game/AI/SmartScripts
parenteb93afffc08a45354e1b896adf38d1f8e8b352ac (diff)
Core/Creatures: Allow disabling melee attacks for all creatures, not just the ones using SAI
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp9
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h7
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp5
3 files changed, 6 insertions, 15 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 56c6b98c208..1e0e0b9dec0 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -33,7 +33,7 @@
SmartAI::SmartAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), _charmed(false), _followCreditType(0), _followArrivedTimer(0), _followCredit(0), _followArrivedEntry(0), _followDistance(0.f), _followAngle(0.f),
_escortState(SMART_ESCORT_NONE), _escortNPCFlags(0), _escortInvokerCheckTimer(1000), _currentWaypointNode(0), _waypointReached(false), _waypointPauseTimer(0), _waypointPauseForced(false), _repeatWaypointPath(false),
- _OOCReached(false), _waypointPathEnded(false), _run(true), _evadeDisabled(false), _canAutoAttack(true), _canCombatMove(true), _invincibilityHPLevel(0), _despawnTime(0), _despawnState(0), _vehicleConditionsTimer(0),
+ _OOCReached(false), _waypointPathEnded(false), _run(true), _evadeDisabled(false), _canCombatMove(true), _invincibilityHPLevel(0), _despawnTime(0), _despawnState(0), _vehicleConditionsTimer(0),
_gossipReturn(false), _escortQuestId(0)
{
_vehicleConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, creature->GetEntry());
@@ -309,8 +309,7 @@ void SmartAI::UpdateAI(uint32 diff)
if (!hasVictim)
return;
- if (_canAutoAttack)
- DoMeleeAttackIfReady();
+ DoMeleeAttackIfReady();
}
bool SmartAI::IsEscortInvokerInRange()
@@ -594,11 +593,11 @@ void SmartAI::AttackStart(Unit* who)
if (!IsAIControlled())
{
if (who)
- me->Attack(who, _canAutoAttack);
+ me->Attack(who, true);
return;
}
- if (who && me->Attack(who, _canAutoAttack))
+ if (who && me->Attack(who, true))
{
me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
me->PauseMovement();
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index b5f07778d32..82e2a53be3c 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -68,12 +68,8 @@ class TC_GAME_API SmartAI : public CreatureAI
{
_escortState &= ~escortState;
}
- void SetAutoAttack(bool on)
- {
- _canAutoAttack = on;
- }
void SetCombatMove(bool on, bool stopMoving = false);
- bool CanCombatMove()
+ bool CanCombatMove() const
{
return _canCombatMove;
}
@@ -268,7 +264,6 @@ class TC_GAME_API SmartAI : public CreatureAI
bool _run;
bool _evadeDisabled;
- bool _canAutoAttack;
bool _canCombatMove;
uint32 _invincibilityHPLevel;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 5454b012212..2d8ebcc7783 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -743,10 +743,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_AUTO_ATTACK:
{
- if (!IsSmart())
- break;
-
- ENSURE_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack != 0);
+ me->SetCanMelee(e.action.autoAttack.attack != 0);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: {} bool on = {}",
me->GetGUID().ToString(), e.action.autoAttack.attack);
break;