Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ CollectSourceFiles(
PRIVATE_SOURCES
)

list(APPEND PRIVATE_SOURCES
"server/game/Spells/SpellEffectsTest.cpp"
)

include_directories(
"mocks"
)
Expand Down
45 changes: 45 additions & 0 deletions src/test/server/game/Spells/SpellEffectsTest.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
Loading