Merge 7ba22c44c3c4ef2154174a94731abce801445529 into 5bef92d5eaca3e2ecc317f9d599312bc23eb71aa

This commit is contained in:
DealsBeam 2025-11-10 04:07:27 +03:00 committed by GitHub
commit 79bb8c7ac7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 1 deletions

View File

@ -2706,7 +2706,6 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/)
if (unitTarget->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING))
return;
unitTarget->SetFacingTo(unitTarget->GetAngle(destTarget)); /// @BUG Causes the player to stop moving.
unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILLISECONDS);
}

View File

@ -14,6 +14,10 @@ CollectSourceFiles(
PRIVATE_SOURCES
)
list(APPEND PRIVATE_SOURCES
"server/game/Spells/SpellEffectsTest.cpp"
)
include_directories(
"mocks"
)

View File

@ -0,0 +1,45 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Mocks/WorldMock.h"
#include "Player.h"
#include "Spell.h"
#include "gtest/gtest.h"
TEST(SpellEffectsTest, DistractDoesNotStopMovement)
{
WorldMock world;
Player* player = new Player(nullptr);
player->Create(sObjectMgr->GenerateLowGuid<HighGuid::Player>(), nullptr);
Unit* target = new Unit(false);
target->Create(sObjectMgr->GenerateLowGuid<HighGuid::Unit>(), nullptr, 0, 0);
target->GetMotionMaster()->MovePoint(1, 10.0f, 10.0f, 10.0f);
// Verify that the target is moving and the stack size is 1
ASSERT_EQ(target->GetMotionMaster()->size(), 1);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(1725); // Distract
Spell* spell = new Spell(player, spellInfo, TriggerCastFlags(TRIGGERED_NONE));
spell->m_targets.SetUnitTarget(target);
spell->EffectDistract(EFFECT_0);
// Verify that the movement stack size is now 2, meaning the original movement was not cleared
EXPECT_EQ(target->GetMotionMaster()->size(), 2);
}