Add free cloak-style auto-hunt pull for 3 10 or 20 monster groups

This commit is contained in:
shen
2026-09-30 17:07:24 -07:00
parent d1f8d3dddd
commit 8a6aeaedf0
18 changed files with 558 additions and 96 deletions
+44
View File
@@ -0,0 +1,44 @@
// 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(&current);
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
}
+11
View File
@@ -864,6 +864,17 @@ bool FakeLoginServer::ServeGame(Connection& c, int index)
return Fail(name + ": send GC_SAFEBOX_SET");
}
}
else if (text.rfind("/autohunt_pull ", 0) == 0) {
int groups = 0, radius = 0, bosses = 0;
unsigned request = 0;
if (sscanf(text.c_str() + 15, "%d %d %d %u", &groups, &radius, &bosses, &request) != 4)
return Fail(name + ": malformed autohunt pull");
for (const std::string& cmd : {"AutoHuntGather " + std::to_string(request) + " mob " + std::to_string(kMobVID),
"AutoHuntGather " + std::to_string(request) + " done 1"}) {
GCChatHead chat = {HDR_GC_CHAT, static_cast<std::uint16_t>(sizeof(GCChatHead) + cmd.size() + 1), 5, 0, 1};
if (!c.Send(chat) || !c.Send(cmd.c_str(), cmd.size() + 1)) return Fail(name + ": autohunt pull reply");
}
}
else if (text == "/safebox_close")
{
Event(name + ":safebox_close");
+1
View File
@@ -744,6 +744,7 @@ int main(int argc, char** argv)
std::printf("port_login_flow_test: %s\n", e.c_str());
}
}
#include "autohunt_pull_checks.inc"
// 9. (批次 4-b) Combat: a left click on the stray dog reaches CPythonPlayer::__OnClickActor, which targets it
// (CG_TARGET → GC_TARGET, uitarget shows the HP board) and walks into range to attack. Each attack frame's
// hit (CPythonPlayerEventHandler::OnHit) sends CG_ATTACK; the fake server answers GC_DAMAGE_INFO + GC_TARGET,