Files
ForeverCore/tests/game/PetStayCommand.cpp
T
Karrz1 edcd627657 Pets: Move To works like Stay at the clicked spot
After the pet bar's Move To a pet never fought again until it was dismissed
and called back: PetAI only knew Stay and Follow, so it sent the pet home on
the next update and refused every target, even an explicit Attack. Move To
now counts as Stay at the new spot everywhere the code checked for Stay (pet
AI attack, chase and return, catch-up and travel parking, resurrect, possess),
and the handler stores the clicked spot as the stay position (the spline had
not started yet, so it saved where the pet stood). Test: PetStayCommand.

From buildthehomelab/wow-trinitycore-everlake, commit 5ad51b11b, by Bob (GPL-2.0). Thank you!
2026-11-14 09:36:57 +00:00

49 lines
1.7 KiB
C++

#include "tc_catch2.h"
#include "CharmInfo.h"
#include "Creature.h"
// "Move To" must leave a pet in the same mode as "Stay" at the new spot. PetAI only knew COMMAND_STAY and
// COMMAND_FOLLOW, so after Move To the pet refused every target, even an explicit Attack, until it was re-summoned.
TEST_CASE("Stay and Move To are stay commands; Follow, Attack and Abandon are not", "[PetStayCommand]")
{
STATIC_CHECK(IsPetStayCommand(COMMAND_STAY));
STATIC_CHECK(IsPetStayCommand(COMMAND_MOVE_TO));
STATIC_CHECK_FALSE(IsPetStayCommand(COMMAND_FOLLOW));
STATIC_CHECK_FALSE(IsPetStayCommand(COMMAND_ATTACK));
STATIC_CHECK_FALSE(IsPetStayCommand(COMMAND_ABANDON));
}
TEST_CASE("A pet's charm info reports a stay command after Stay or Move To", "[PetStayCommand]")
{
Creature pet(false);
CharmInfo charmInfo(&pet);
// New pets start on Follow.
CHECK_FALSE(charmInfo.HasStayCommand());
charmInfo.SetCommandState(COMMAND_MOVE_TO);
CHECK(charmInfo.HasStayCommand());
CHECK_FALSE(charmInfo.HasCommandState(COMMAND_STAY));
charmInfo.SetCommandState(COMMAND_STAY);
CHECK(charmInfo.HasStayCommand());
charmInfo.SetCommandState(COMMAND_FOLLOW);
CHECK_FALSE(charmInfo.HasStayCommand());
}
TEST_CASE("Move To stores the clicked spot as the stay position", "[PetStayCommand]")
{
// The handler cannot read the spot from the spline: the point movement it just queued has not started yet.
Creature pet(false);
CharmInfo charmInfo(&pet);
charmInfo.SetStayPosition(-8913.5f, 554.25f, 93.75f);
float x = 0.0f, y = 0.0f, z = 0.0f;
charmInfo.GetStayPosition(x, y, z);
CHECK(x == -8913.5f);
CHECK(y == 554.25f);
CHECK(z == 93.75f);
}