45 lines
2.3 KiB
C++
45 lines
2.3 KiB
C++
// PORT extension test: real Python settings → CG_CHAT → GC_CHAT → player state.
|
|
if (server && CPythonCharacterManager::Instance().GetMainInstancePtr()) {
|
|
auto* main_instance = CPythonCharacterManager::Instance().GetMainInstancePtr();
|
|
CPythonPlayer& player = CPythonPlayer::Instance();
|
|
const auto savedConfig = player.AutoHunt_GetConfig();
|
|
const int hp = player.GetStatus(POINT_HP), maxHP = player.GetStatus(POINT_MAX_HP);
|
|
player.SetStatus(POINT_HP, 1000);
|
|
player.SetStatus(POINT_MAX_HP, 1000);
|
|
CHECK(py("import player; player.AutoHuntSetConfig(5000, 0, 0, 0, 0, 0, 0, 20)"));
|
|
CHECK(player.AutoHunt_GetConfig().iGatherCount == 20);
|
|
TPixelPosition savedPosition = {};
|
|
main_instance->NEW_GetPixelPosition(&savedPosition);
|
|
auto* pullMob = CPythonCharacterManager::Instance().GetInstancePtr(FakeLoginServer::kMobVID);
|
|
TPixelPosition pullPosition = {};
|
|
pullMob->NEW_GetPixelPosition(&pullPosition);
|
|
pullPosition.x += 1000;
|
|
main_instance->NEW_Stop();
|
|
main_instance->NEW_SetPixelPosition(pullPosition);
|
|
CHECK(!main_instance->IsInSafe());
|
|
CHECK(py("player.AutoHuntSetConfig(5000, 0, 0, 0, 0, 0, 0, 3); player.AutoHuntSetEnabled(1)"));
|
|
TPixelPosition origin = {};
|
|
main_instance->NEW_GetPixelPosition(&origin);
|
|
CHECK(pump_until(2, [&] {
|
|
return server->Has("game2:chat 0 /autohunt_pull 3 5000 0 1") &&
|
|
player.AutoHunt_GetGatheredCount() == 1 && !player.AutoHunt_IsGathering();
|
|
}));
|
|
TPixelPosition current = {};
|
|
main_instance->NEW_GetPixelPosition(¤t);
|
|
CHECK(std::hypot(current.x-origin.x, current.y-origin.y) < 5.0f);
|
|
player.AutoHunt_SetEnabled(false);
|
|
CHECK(player.AutoHunt_HandleServerCommand("AutoHuntGather 1 mob 123"));
|
|
CHECK(player.AutoHunt_GetGatheredCount() == 0);
|
|
// Old replies must not complete a new request; cooldown remains across toggles.
|
|
player.AutoHunt_SetEnabled(true);
|
|
CHECK(player.AutoHunt_HandleServerCommand("AutoHuntGather 1 done 20"));
|
|
CHECK(player.AutoHunt_GetGatheredCount() == 0);
|
|
player.AutoHunt_SetEnabled(false);
|
|
player.AutoHunt_SetConfig(savedConfig);
|
|
player.SetStatus(POINT_HP, hp);
|
|
player.SetStatus(POINT_MAX_HP, maxHP);
|
|
main_instance->NEW_Stop();
|
|
main_instance->NEW_SetPixelPosition(savedPosition);
|
|
pump_frames(30); // restore the camera/picking matrices before the existing combat fixture
|
|
}
|