feat(Core/Scripting): Implement SetAutoAttackAllowed() to disable aut… (#20805)
* feat(Core/Scripting): Implement SetAutoAttackAllowed() to disable autoattacks * Update ScriptedCreature.cpp
This commit is contained in:
@@ -195,6 +195,7 @@ ScriptedAI::ScriptedAI(Creature* creature) : CreatureAI(creature),
|
|||||||
_isHeroic = me->GetMap()->IsHeroic();
|
_isHeroic = me->GetMap()->IsHeroic();
|
||||||
_difficulty = Difficulty(me->GetMap()->GetSpawnMode());
|
_difficulty = Difficulty(me->GetMap()->GetSpawnMode());
|
||||||
_invincible = false;
|
_invincible = false;
|
||||||
|
_canAutoAttack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedAI::AttackStartNoMove(Unit* who)
|
void ScriptedAI::AttackStartNoMove(Unit* who)
|
||||||
@@ -220,7 +221,8 @@ void ScriptedAI::UpdateAI(uint32 /*diff*/)
|
|||||||
if (!UpdateVictim())
|
if (!UpdateVictim())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
if (IsAutoAttackAllowed())
|
||||||
|
DoMeleeAttackIfReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptedAI::DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/)
|
void ScriptedAI::DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/)
|
||||||
@@ -739,7 +741,8 @@ void BossAI::UpdateAI(uint32 diff)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
if (IsAutoAttackAllowed())
|
||||||
|
DoMeleeAttackIfReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BossAI::DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask)
|
void BossAI::DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask)
|
||||||
|
|||||||
@@ -442,10 +442,15 @@ struct ScriptedAI : public CreatureAI
|
|||||||
void SetInvincibility(bool apply) { _invincible = apply; };
|
void SetInvincibility(bool apply) { _invincible = apply; };
|
||||||
[[nodiscard]] bool IsInvincible() const { return _invincible; };
|
[[nodiscard]] bool IsInvincible() const { return _invincible; };
|
||||||
|
|
||||||
|
// Disables creature auto attacks.
|
||||||
|
void SetAutoAttackAllowed(bool allow) { _canAutoAttack = allow; };
|
||||||
|
[[nodiscard]] bool IsAutoAttackAllowed() const { return _canAutoAttack; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Difficulty _difficulty;
|
Difficulty _difficulty;
|
||||||
bool _isHeroic;
|
bool _isHeroic;
|
||||||
bool _invincible;
|
bool _invincible;
|
||||||
|
bool _canAutoAttack;
|
||||||
std::unordered_set<uint32> _uniqueTimedEvents;
|
std::unordered_set<uint32> _uniqueTimedEvents;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user