From 0b551a055cbba0e1529a116cd73fe898ce6e0e8b Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Mon, 29 Nov 2021 16:09:39 +0100 Subject: [PATCH] fix(Scripts/Spells): Mind Control should put both caster and target in combat. (#9301) Fixes #8938 --- .../rev_1637699382534407800.sql | 5 ++++ src/server/game/Entities/Unit/Unit.cpp | 2 +- src/server/scripts/Spells/spell_priest.cpp | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 data/sql/updates/pending_db_world/rev_1637699382534407800.sql diff --git a/data/sql/updates/pending_db_world/rev_1637699382534407800.sql b/data/sql/updates/pending_db_world/rev_1637699382534407800.sql new file mode 100644 index 000000000..683943443 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1637699382534407800.sql @@ -0,0 +1,5 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1637699382534407800'); + +DELETE FROM `spell_script_names` WHERE `spell_id`=605; +INSERT INTO `spell_script_names` VALUES +(605,'spell_pri_mind_control'); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 70434d0aa..add68ffc3 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12988,7 +12988,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration) if (controlled->GetTypeId() == TYPEID_UNIT && controlled->ToCreature()->HasReactState(REACT_PASSIVE)) continue; - controlled->SetInCombatState(PvP, enemy); + controlled->SetInCombatState(PvP, enemy, duration); } #ifdef ELUNA if (Player* player = this->ToPlayer()) diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 32facf6e7..700a1698c 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -807,6 +807,33 @@ class spell_pri_vampiric_touch : public AuraScript } }; +// 605 - Mind Control +class spell_pri_mind_control : public SpellScript +{ + PrepareSpellScript(spell_pri_mind_control); + + void OnHit() + { + if (Aura const* aura = GetHitAura()) + { + if (Unit* caster = GetCaster()) + { + if (Unit* target = GetHitUnit()) + { + uint32 duration = static_cast(aura->GetMaxDuration()); + caster->SetInCombatWith(target, duration); + target->SetInCombatWith(caster, duration); + } + } + } + } + + void Register() override + { + AfterHit += SpellHitFn(spell_pri_mind_control::OnHit); + } +}; + void AddSC_priest_spell_scripts() { RegisterSpellScript(spell_pri_shadowfiend_scaling); @@ -828,4 +855,5 @@ void AddSC_priest_spell_scripts() RegisterSpellScript(spell_pri_renew); RegisterSpellScript(spell_pri_shadow_word_death); RegisterSpellScript(spell_pri_vampiric_touch); + RegisterSpellScript(spell_pri_mind_control); }