Improve auto-hunt navigation, recovery and mounted skill casting

This commit is contained in:
shen
2026-10-01 07:46:44 -07:00
parent 586bae51e4
commit e7f2202a94
14 changed files with 854 additions and 148 deletions
+45 -7
View File
@@ -2182,21 +2182,21 @@ PyObject * playerAutoHuntIsEnabled(PyObject* poSelf, PyObject* poArgs)
return Py_BuildValue("i", CPythonPlayer::Instance().AutoHunt_IsEnabled());
}
// (state, stop reason, out of HP potions, out of SP potions, gathering, gathered mobs alive)
// (state, stop reason, out of HP potions, out of SP potions, gathering, gathered groups, mount stage)
PyObject * playerAutoHuntGetState(PyObject* poSelf, PyObject* poArgs)
{
CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
return Py_BuildValue("iiiiii", rkPlayer.AutoHunt_GetState(), rkPlayer.AutoHunt_GetStopReason(),
return Py_BuildValue("iiiiiii", rkPlayer.AutoHunt_GetState(), rkPlayer.AutoHunt_GetStopReason(),
rkPlayer.AutoHunt_HasNoPotion(true), rkPlayer.AutoHunt_HasNoPotion(false),
rkPlayer.AutoHunt_IsGathering(), rkPlayer.AutoHunt_GetGatheredCount());
rkPlayer.AutoHunt_IsGathering(), rkPlayer.AutoHunt_GetGatheredCount(), rkPlayer.AutoHunt_GetMountState());
}
// (range, hp %, sp %, pickup, stone, boss, quick-slot skill mask, gather count)
// (range, hp %, sp %, pickup, stone, boss, legacy mask, gather count, revive, dismount skill)
PyObject * playerAutoHuntGetConfig(PyObject* poSelf, PyObject* poArgs)
{
const CPythonPlayer::SAutoHuntConfig& c_rkConfig = CPythonPlayer::Instance().AutoHunt_GetConfig();
return Py_BuildValue("iiiiiiii", c_rkConfig.iRange, c_rkConfig.iHPPercent, c_rkConfig.iSPPercent, c_rkConfig.iPickup,
c_rkConfig.bAttackStone, c_rkConfig.bAttackBoss, int(c_rkConfig.dwSkillSlotMask), c_rkConfig.iGatherCount);
return Py_BuildValue("iiiiiiiiii", c_rkConfig.iRange, c_rkConfig.iHPPercent, c_rkConfig.iSPPercent, c_rkConfig.iPickup,
c_rkConfig.bAttackStone, c_rkConfig.bAttackBoss, int(c_rkConfig.dwSkillSlotMask), c_rkConfig.iGatherCount, c_rkConfig.bAutoRevive, c_rkConfig.bDismountSkill);
}
PyObject * playerAutoHuntSetConfig(PyObject* poSelf, PyObject* poArgs)
@@ -2206,7 +2206,7 @@ PyObject * playerAutoHuntSetConfig(PyObject* poSelf, PyObject* poArgs)
if (!PyTuple_GetInteger(poArgs, i, &aiValue[i]))
return Py_BuildException();
CPythonPlayer::SAutoHuntConfig kConfig;
CPythonPlayer::SAutoHuntConfig kConfig=CPythonPlayer::Instance().AutoHunt_GetConfig();
kConfig.iRange = aiValue[0];
kConfig.iHPPercent = aiValue[1];
kConfig.iSPPercent = aiValue[2];
@@ -2215,10 +2215,46 @@ PyObject * playerAutoHuntSetConfig(PyObject* poSelf, PyObject* poArgs)
kConfig.bAttackBoss = aiValue[5] != 0;
kConfig.dwSkillSlotMask = DWORD(aiValue[6]);
kConfig.iGatherCount = aiValue[7];
if (PyTuple_Size(poArgs)>8) {
int revive=0,dismount=0;
if (PyTuple_Size(poArgs)!=10 || !PyTuple_GetInteger(poArgs,8,&revive) || !PyTuple_GetInteger(poArgs,9,&dismount)) return Py_BuildException();
kConfig.bAutoRevive=revive!=0; kConfig.bDismountSkill=dismount!=0;
}
CPythonPlayer::Instance().AutoHunt_SetConfig(kConfig);
return Py_BuildNone();
}
// PORT: skill indices persist independently from shortcut positions.
PyObject* playerAutoHuntGetSkills(PyObject*,PyObject*)
{
auto& player=CPythonPlayer::Instance();
const auto available=player.AutoHunt_GetAvailableSkills();
const auto selected=player.AutoHunt_GetConfig().vecSkillIndices;
PyObject* choices=PyTuple_New(available.size());
PyObject* selection=PyTuple_New(selected.size());
for (size_t i=0;i<available.size();++i) PyTuple_SET_ITEM(choices,i,PyInt_FromLong(available[i]));
for (size_t i=0;i<selected.size();++i) PyTuple_SET_ITEM(selection,i,PyInt_FromLong(selected[i]));
return Py_BuildValue("NN",selection,choices);
}
PyObject* playerAutoHuntSetSkills(PyObject*,PyObject* args)
{
PyObject* source=nullptr;
if (!PyArg_ParseTuple(args,"O",&source)) return nullptr;
PyObject* sequence=PySequence_Fast(source,"skill indices must be a sequence");
if (!sequence) return nullptr;
const Py_ssize_t count=PySequence_Fast_GET_SIZE(sequence);
if (count>32) { Py_DECREF(sequence); PyErr_SetString(PyExc_ValueError,"at most 32 skills"); return nullptr; }
std::vector<DWORD> indices;
for (Py_ssize_t i=0;i<count;++i) {
const long index=PyInt_AsLong(PySequence_Fast_GET_ITEM(sequence,i));
if (PyErr_Occurred()) { Py_DECREF(sequence); return nullptr; }
if (index>0 && index<=65535) indices.push_back(DWORD(index));
}
Py_DECREF(sequence); CPythonPlayer::Instance().AutoHunt_SetSkills(indices);
return Py_BuildNone();
}
// The auto hunt window's UTF-8 source strings in the locale's code page (locale.cfg), as the packed
// locale_game.txt strings are.
PyObject * playerAutoHuntLocalize(PyObject* poSelf, PyObject* poArgs)
@@ -2417,6 +2453,8 @@ void initPlayer()
{ "AutoHuntGetState", playerAutoHuntGetState, METH_VARARGS },
{ "AutoHuntGetConfig", playerAutoHuntGetConfig, METH_VARARGS },
{ "AutoHuntSetConfig", playerAutoHuntSetConfig, METH_VARARGS },
{ "AutoHuntGetSkills", playerAutoHuntGetSkills, METH_VARARGS },
{ "AutoHuntSetSkills", playerAutoHuntSetSkills, METH_VARARGS },
{ "AutoHuntLocalize", playerAutoHuntLocalize, METH_VARARGS },
{ NULL, NULL, NULL },