107 lines
6.1 KiB
C++
107 lines
6.1 KiB
C++
// PORT extension test: real Python settings → CG_CHAT → GC_CHAT → player state.
|
|
if (server && CPythonCharacterManager::Instance().GetMainInstancePtr()) {
|
|
// Real command reply inserts distinct global/event icons without replacing character affects.
|
|
CHECK(pump_until(2, [&] { return server->Has("game2:chat 0 /server_bonuses"); }));
|
|
CHECK(py("import mt_bonuses; _bonus_bar = mt_bonuses.g_game.affectShower"));
|
|
CHECK(pump_until(2, [&] { return py_true("all(k in _bonus_bar.affectImageDict for k in (20000,20001,20002,20003,20004,20006))"); }));
|
|
CHECK(py("_bonus_image = _bonus_bar.affectImageDict[20000]; assert _bonus_image.IsShow(); assert _bonus_image.description == mt_bonuses.L(mt_bonuses.ENTRIES[0][0] % 200)"));
|
|
CHECK(py("mt_bonuses.g_game.BINARY_ServerCommand_Run('ServerBonuses 100 100 100 100 0 0 0 0'); assert not any(k >= 20000 for k in _bonus_bar.affectImageDict)"));
|
|
CHECK(py("mt_bonuses.g_game.BINARY_ServerCommand_Run('ServerBonuses 300 100 100 100 0 0 0 0'); assert _bonus_bar.affectImageDict[20000].description == mt_bonuses.L(mt_bonuses.ENTRIES[0][0] % 300)"));
|
|
CHECK(py("mt_bonuses.g_game.BINARY_ServerCommand_Run('ServerBonuses bad'); assert 20000 in _bonus_bar.affectImageDict"));
|
|
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(3500, 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 3500 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);
|
|
TPixelPosition originalMobPosition = {};
|
|
pullMob->NEW_GetPixelPosition(&originalMobPosition);
|
|
TPixelPosition closeMobPosition = origin;
|
|
closeMobPosition.x += 100;
|
|
pullMob->NEW_Stop();
|
|
pullMob->NEW_SetPixelPosition(closeMobPosition);
|
|
main_instance->NEW_Stop();
|
|
main_instance->NEW_SetPixelPosition(origin);
|
|
// A farther stone outranks the nearer pulled monster, even with bosses disabled.
|
|
CInstanceBase::SCreateData stoneData = {};
|
|
stoneData.m_bType = CActorInstance::TYPE_STONE;
|
|
stoneData.m_dwRace = 8001;
|
|
stoneData.m_dwVID = 0x700001;
|
|
stoneData.m_dwMovSpd = 100;
|
|
stoneData.m_dwAtkSpd = 100;
|
|
stoneData.m_lPosX = LONG(origin.x + 400);
|
|
stoneData.m_lPosY = LONG(origin.y);
|
|
stoneData.m_stName = "AutoHuntStoneFixture";
|
|
auto* stone = CPythonCharacterManager::Instance().CreateInstance(stoneData);
|
|
CHECK(stone && stone->IsStone() && !stone->IsInSafe());
|
|
if (stone) {
|
|
auto cfg = player.AutoHunt_GetConfig();
|
|
cfg.bAttackStone = true;
|
|
player.AutoHunt_SetConfig(cfg);
|
|
CHECK(pump_until(2, [&] { return player.GetTargetVID() == stoneData.m_dwVID; }));
|
|
player.AutoHunt_SetEnabled(false);
|
|
cfg.iGatherCount = 0;
|
|
cfg.bAttackStone = false;
|
|
player.AutoHunt_SetConfig(cfg);
|
|
player.AutoHunt_SetEnabled(true);
|
|
CHECK(pump_until(2, [&] { return player.GetTargetVID() == FakeLoginServer::kMobVID; }));
|
|
// Changing the option while already fighting takes effect immediately.
|
|
cfg.bAttackStone = true;
|
|
player.AutoHunt_SetConfig(cfg);
|
|
CHECK(pump_until(2, [&] { return player.GetTargetVID() == stoneData.m_dwVID; }));
|
|
player.AutoHunt_SetEnabled(false);
|
|
CPythonCharacterManager::Instance().DeleteInstance(stoneData.m_dwVID);
|
|
player.AutoHunt_SetEnabled(true);
|
|
CHECK(pump_until(2, [&] { return player.GetTargetVID() == FakeLoginServer::kMobVID; }));
|
|
}
|
|
player.AutoHunt_SetEnabled(false);
|
|
pullMob->NEW_Stop();
|
|
pullMob->NEW_SetPixelPosition(originalMobPosition);
|
|
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);
|
|
CHECK(py("player.AutoHuntSetConfig(10000, 0, 0, 0, 0, 0, 0, 0)"));
|
|
CHECK(player.AutoHunt_GetConfig().iRange == 10000);
|
|
CHECK(py("player.AutoHuntSetConfig(15000, 0, 0, 0, 0, 0, 0, 0)"));
|
|
CHECK(player.AutoHunt_GetConfig().iRange == 15000);
|
|
TPixelPosition farPosition = origin;
|
|
farPosition.x += 2000;
|
|
main_instance->NEW_Stop();
|
|
main_instance->NEW_SetPixelPosition(farPosition);
|
|
CHECK(py("player.AutoHuntSetConfig(15000, 0, 0, 0, 0, 0, 0, 20); player.AutoHuntSetEnabled(1)"));
|
|
CHECK(player.AutoHunt_GetConfig().iRange == 15000);
|
|
CHECK(pump_until(12, [&] { return server->Has("game2:chat 0 /autohunt_pull 20 15000 0 2"); }));
|
|
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
|
|
}
|