Expand auto-hunt pursuit ranges and show server bonus effects
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# 自动狩猎范围与服务器加成状态
|
||||
|
||||
2026-09-30 用户要求:引怪追击距离跟随狩猎距离;游戏左上角补充服务器经验、金币等加成。
|
||||
|
||||
本补丁在 `autohunt-pull/server.patch` 之后应用,基础补丁保持字节不变。
|
||||
`../rebuild.sh check/build/deploy` 已处理增量补丁,并强制重新编译包含命令头文件的 `cmd_general.cpp`。
|
||||
|
||||
引怪支持 35/100/150 米,地图分区按半径完整遍历并使用快照;不扫描整张地图。
|
||||
只有本命令引来的怪物获得指定玩家的临时追击距离,原有 40 米战斗目标限制和 50 米离巢限制
|
||||
在这一上下文中扩展。停止狩猎取消扩展,180 秒不刷新自动过期,换目标/地图后恢复正常追击。
|
||||
原披风道具及其他怪物 AI 保持不变;寻路仍受地图阻挡和怪物自身移动规则约束。
|
||||
|
||||
客户端每 15 秒请求 `/server_bonuses`;服务器按角色限制查询频率为至少 2 秒。
|
||||
响应 `ServerBonuses <经验倍率> <金币数量倍率> <金币掉落倍率> <物品掉落倍率> <经验活动加成> <物品活动加成> <金币活动加成> <金币礼包活动加成>`。
|
||||
前四项来自 `CHARACTER_MANAGER` 的全局实际倍率,后四项来自 `CPrivManager::GetPriv`,
|
||||
与奖励结算使用的活动数据来源一致,包含适用于当前角色的国家、公会和角色特权。
|
||||
全局 200% 与活动额外 +200% 分别显示,不假定它们相同,也不伪造持续时间。
|
||||
标准 100% 倍率和零活动加成不显示;活动结束、变化和重新登录会更新图标。
|
||||
|
||||
客户端通过 `ServerBonusScript.inc` 的 PORT 模块向原有增益栏添加独立图标及中文提示。
|
||||
原版角色/技能增益不被覆盖,打包的 `uiaffectshower.py` 和 `game.py` 保持不变。
|
||||
Android 点击图标可看到提示,macOS 悬停显示;FPS 移到顶部中间避免遮挡图标。
|
||||
|
||||
203 源文件备份:`/root/autohunt-range-20260930/`,隔离构建:`/root/rebuild/20261001-074644/`。
|
||||
部署及二进制回滚使用 `rebuild.sh`,不需要数据库迁移。
|
||||
旧停服脚本可能使用缺失的 PID 文件:重建脚本对剩余进程补发 TERM 并等待正常退出,未使用强制终止。
|
||||
|
||||
验证:`host.autohunt_pull` 覆盖远处分区、100/150 米边界、指定玩家追击、取消及过期。
|
||||
`port.login_flow` 覆盖真实 Python 配置和聊天封包链、石头优先与回退、加成图标新增/更新/移除;
|
||||
桌面及 `MT_TEST_MOBILE=1` 均通过。Mi 8 Lite 真机在模拟服务器场景显示图标和“服务器经验 200%”提示。
|
||||
macOS app 与 Android Release native/debug APK 已构建;APK 已安装到 63c36adb。
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
// PORT extension: ordinary monster pursuit remains 40 metres.
|
||||
int AutoHuntPullLeash(LPCHARACTER mob, LPCHARACTER victim);
|
||||
@@ -0,0 +1,176 @@
|
||||
--- a/server/game/src/sectree_manager.h
|
||||
+++ b/server/game/src/sectree_manager.h
|
||||
@@ -88,6 +88,18 @@
|
||||
}
|
||||
*/
|
||||
}
|
||||
+
|
||||
+ // PORT: snapshot traversal for the complete auto-hunt radius.
|
||||
+ template<typename Func>
|
||||
+ void for_each_in_rect(DWORD minX, DWORD minY, DWORD maxX, DWORD maxY, Func& func) {
|
||||
+ FCollectEntity collector;
|
||||
+ for (DWORD x = minX / SECTREE_SIZE * SECTREE_SIZE; x <= maxX; x += SECTREE_SIZE)
|
||||
+ for (DWORD y = minY / SECTREE_SIZE * SECTREE_SIZE; y <= maxY; y += SECTREE_SIZE) {
|
||||
+ LPSECTREE tree = Find(x, y);
|
||||
+ if (tree) tree->for_each_entity(collector);
|
||||
+ }
|
||||
+ collector.ForEach(func);
|
||||
+ }
|
||||
|
||||
void DumpAllToSysErr() {
|
||||
SECTREE_MAP::MapType::iterator i;
|
||||
--- a/server/game/src/autohunt_pull.h
|
||||
+++ b/server/game/src/autohunt_pull.h
|
||||
@@ -3,8 +3,37 @@
|
||||
#include "group_select.h"
|
||||
#else
|
||||
#include "sectree_manager.h"
|
||||
+#include "autohunt_pull_range.h"
|
||||
#include "autohunt_group_select.h"
|
||||
#endif
|
||||
+
|
||||
+// PORT: only mobs pulled by this command receive a temporary extended pursuit leash.
|
||||
+struct AutoHuntPullLease {
|
||||
+ LPCHARACTER mob;
|
||||
+ DWORD ownerPID;
|
||||
+ int radius;
|
||||
+ int expires;
|
||||
+};
|
||||
+static std::map<DWORD, AutoHuntPullLease> s_autoHuntPullLeases;
|
||||
+int AutoHuntPullLeash(LPCHARACTER mob, LPCHARACTER victim) {
|
||||
+ std::map<DWORD, AutoHuntPullLease>::iterator it = s_autoHuntPullLeases.find((DWORD)mob->GetVID());
|
||||
+ if (it == s_autoHuntPullLeases.end()) return 4000;
|
||||
+ const AutoHuntPullLease& lease = it->second;
|
||||
+ if (lease.mob != mob || !victim || !victim->IsPC() || victim->IsDead() ||
|
||||
+ victim->GetPlayerID() != lease.ownerPID || mob->GetMapIndex() != victim->GetMapIndex() ||
|
||||
+ get_global_time() >= lease.expires) {
|
||||
+ s_autoHuntPullLeases.erase(it);
|
||||
+ return 4000;
|
||||
+ }
|
||||
+ return std::max(4000, lease.radius + 1);
|
||||
+}
|
||||
+static void AutoHuntPullPrune(DWORD cancelPID = 0) {
|
||||
+ for (std::map<DWORD, AutoHuntPullLease>::iterator it = s_autoHuntPullLeases.begin(); it != s_autoHuntPullLeases.end();) {
|
||||
+ if (it->second.expires <= get_global_time() || (cancelPID && it->second.ownerPID == cancelPID))
|
||||
+ s_autoHuntPullLeases.erase(it++);
|
||||
+ else ++it;
|
||||
+ }
|
||||
+}
|
||||
|
||||
struct AutoHuntPullCollector {
|
||||
LPCHARACTER owner;
|
||||
@@ -35,8 +64,11 @@
|
||||
unsigned int request = 0;
|
||||
char extra = 0;
|
||||
if (sscanf(argument, "%d %d %d %u %c", &groups, &radius, &bosses, &request, &extra) != 4 ||
|
||||
- (groups != 3 && groups != 10 && groups != 20) || radius < 500 || radius > 5000 ||
|
||||
+ (groups != 0 && groups != 3 && groups != 10 && groups != 20) || radius < 500 || radius > 15000 ||
|
||||
(bosses != 0 && bosses != 1)) return;
|
||||
+ if (!ch->IsPC()) return;
|
||||
+ AutoHuntPullPrune(groups == 0 ? ch->GetPlayerID() : 0);
|
||||
+ if (groups == 0) return;
|
||||
const int now = get_global_time();
|
||||
if (!ch->IsPC() || ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || !ch->GetSectree() ||
|
||||
(ch->GetSectree()->GetAttribute(ch->GetX(), ch->GetY()) & ATTR_BANPK) ||
|
||||
@@ -47,13 +79,23 @@
|
||||
// Server-side cooldown survives reconnects and switching auto hunt on/off.
|
||||
ch->SetQuestFlag("autohunt.next_pull", now + 10);
|
||||
AutoHuntPullCollector collector(ch, radius, bosses != 0);
|
||||
- ch->GetSectree()->ForEachAround(collector);
|
||||
+ // ForEachAround only covers nine cells: visit every cell intersecting the requested radius.
|
||||
+ LPSECTREE_MAP map = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
|
||||
+ if (map) map->for_each_in_rect(std::max(0, int(ch->GetX()) - radius),
|
||||
+ std::max(0, int(ch->GetY()) - radius), ch->GetX() + radius, ch->GetY() + radius, collector);
|
||||
const mt_autohunt::Selection selected = mt_autohunt::SelectGroups(collector.candidates, groups);
|
||||
for (size_t i = 0; i < selected.mobs.size(); ++i) {
|
||||
LPCHARACTER mob = CHARACTER_MANAGER::instance().Find(selected.mobs[i]);
|
||||
if (!mob) continue;
|
||||
+ if (mob->IsDead() || (mob->GetVictim() && mob->GetVictim() != ch)) continue;
|
||||
+ AutoHuntPullLease lease = {mob, ch->GetPlayerID(), radius, now + 180};
|
||||
+ s_autoHuntPullLeases[(DWORD)mob->GetVID()] = lease;
|
||||
if (!mob->GetVictim()) mob->BeginFight(ch);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "AutoHuntGather %u mob %u", request, selected.mobs[i]);
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "AutoHuntGather %u done %d", request, selected.groups);
|
||||
}
|
||||
+
|
||||
+#ifndef MT_AUTOHUNT_SERVER_TEST
|
||||
+#include "server_bonuses.h"
|
||||
+#endif
|
||||
--- a/server/game/src/char_state.cpp
|
||||
+++ b/server/game/src/char_state.cpp
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "utils.h"
|
||||
#include "vector.h"
|
||||
#include "char.h"
|
||||
+#include "autohunt_pull_range.h"
|
||||
#include "battle.h"
|
||||
#include "char_manager.h"
|
||||
#include "packet.h"
|
||||
@@ -1035,7 +1036,7 @@
|
||||
|
||||
float fDist = DISTANCE_APPROX(GetX() - victim->GetX(), GetY() - victim->GetY());
|
||||
|
||||
- if (fDist >= 4000.0f) // 40미터 이상 멀어지면 포기
|
||||
+ if (fDist >= AutoHuntPullLeash(this, victim)) // 40미터 이상 멀어지면 포기
|
||||
{
|
||||
MonsterLog("타겟이 멀어서 포기");
|
||||
SetVictim(NULL);
|
||||
--- a/server/game/src/cmd.cpp
|
||||
+++ b/server/game/src/cmd.cpp
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "desc.h"
|
||||
|
||||
ACMD(do_autohunt_pull);
|
||||
+ACMD(do_server_bonuses);
|
||||
ACMD(do_user_horse_ride);
|
||||
ACMD(do_user_horse_back);
|
||||
ACMD(do_user_horse_feed);
|
||||
@@ -281,6 +282,7 @@
|
||||
{
|
||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_STANDING, GM_PLAYER },
|
||||
+ { "server_bonuses", do_server_bonuses, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "who", do_who, 0, POS_DEAD, GM_IMPLEMENTOR },
|
||||
{ "war", do_war, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "warp", do_warp, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
--- /dev/null
|
||||
+++ b/server/game/src/autohunt_pull_range.h
|
||||
@@ -0,0 +1,3 @@
|
||||
+#pragma once
|
||||
+// PORT extension: ordinary monster pursuit remains 40 metres.
|
||||
+int AutoHuntPullLeash(LPCHARACTER mob, LPCHARACTER victim);
|
||||
--- /dev/null
|
||||
+++ b/server/game/src/server_bonuses.h
|
||||
@@ -0,0 +1,12 @@
|
||||
+// PORT: report actual global rates and the character's effective event privileges.
|
||||
+#include "priv_manager.h"
|
||||
+ACMD(do_server_bonuses) {
|
||||
+ if (!ch->IsPC() || get_global_time() < ch->GetQuestFlag("server_bonuses.next_query")) return;
|
||||
+ ch->SetQuestFlag("server_bonuses.next_query", get_global_time() + 2);
|
||||
+ CHARACTER_MANAGER& cm = CHARACTER_MANAGER::instance();
|
||||
+ CPrivManager& pm = CPrivManager::instance();
|
||||
+ ch->ChatPacket(CHAT_TYPE_COMMAND, "ServerBonuses %d %d %d %d %d %d %d %d",
|
||||
+ cm.GetMobExpRate(NULL), cm.GetMobGoldAmountRate(NULL), cm.GetMobGoldDropRate(NULL), cm.GetMobItemRate(NULL),
|
||||
+ pm.GetPriv(ch, PRIV_EXP_PCT), pm.GetPriv(ch, PRIV_ITEM_DROP),
|
||||
+ pm.GetPriv(ch, PRIV_GOLD_DROP), pm.GetPriv(ch, PRIV_GOLD10_DROP));
|
||||
+}
|
||||
--- a/server/game/src/char.cpp
|
||||
+++ b/server/game/src/char.cpp
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../common/VnumHelper.h"
|
||||
|
||||
#include "char.h"
|
||||
+#include "autohunt_pull_range.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
@@ -5440,7 +5441,7 @@
|
||||
if (get_dword_time() - m_pkMobInst->m_dwLastAttackedTime >= 15000) // 마지막으로 공격받은지 15초가 지났고
|
||||
{
|
||||
// 마지막 맞은 곳으로 부터 50미터 이상 차이나면 포기하고 돌아간다.
|
||||
- if (5000 < DISTANCE_APPROX(m_pkMobInst->m_posLastAttacked.x - GetX(), m_pkMobInst->m_posLastAttacked.y - GetY()))
|
||||
+ if (MAX(5000, AutoHuntPullLeash(this, pkChr)) < DISTANCE_APPROX(m_pkMobInst->m_posLastAttacked.x - GetX(), m_pkMobInst->m_posLastAttacked.y - GetY()))
|
||||
if (Return())
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// PORT: report actual global rates and the character's effective event privileges.
|
||||
#include "priv_manager.h"
|
||||
ACMD(do_server_bonuses) {
|
||||
if (!ch->IsPC() || get_global_time() < ch->GetQuestFlag("server_bonuses.next_query")) return;
|
||||
ch->SetQuestFlag("server_bonuses.next_query", get_global_time() + 2);
|
||||
CHARACTER_MANAGER& cm = CHARACTER_MANAGER::instance();
|
||||
CPrivManager& pm = CPrivManager::instance();
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "ServerBonuses %d %d %d %d %d %d %d %d",
|
||||
cm.GetMobExpRate(NULL), cm.GetMobGoldAmountRate(NULL), cm.GetMobGoldDropRate(NULL), cm.GetMobItemRate(NULL),
|
||||
pm.GetPriv(ch, PRIV_EXP_PCT), pm.GetPriv(ch, PRIV_ITEM_DROP),
|
||||
pm.GetPriv(ch, PRIV_GOLD_DROP), pm.GetPriv(ch, PRIV_GOLD10_DROP));
|
||||
}
|
||||
@@ -5,22 +5,32 @@
|
||||
原披风的道具消耗和随机拉怪行为保持不变;本功能按距离确定性选择最多 N 个队伍。
|
||||
|
||||
“组”是服务端实际的怪物 `CParty`,没有队伍的单只怪物算一组。同一队伍在范围内的成员一起拉取。
|
||||
不足所选组数时拉取实际可用的组数。范围使用自动狩猎的范围设置,上限 5000 cm。
|
||||
不足所选组数时拉取实际可用的组数。狩猎边界、披风引怪半径和扩展追击距离跟随 35/100/150 米设置。
|
||||
服务端支持 500..15000 cm,并搜索半径覆盖的全部地图分区。普通怪物原有的 40 米追击限制保持不变;
|
||||
被本命令选中的怪物获得对应玩家专属的临时追击距离,并同步扩展原有 50 米离巢返回限制。
|
||||
每次引怪刷新 180 秒有效期,停止狩猎或修改范围/引怪选项会取消本玩家的扩展追击距离。
|
||||
安全区、死亡/眩晕、低于 50% HP 或不能操作道具时不引怪;默认不拉首领。
|
||||
队伍在范围内存在首领或正在攻击其他玩家的成员时,整组跳过。
|
||||
|
||||
请求 `/autohunt_pull <3|10|20> <500..5000> <boss:0|1> <request-id>` 走现有 CG_CHAT。
|
||||
请求 `/autohunt_pull <3|10|20> <500..15000> <boss:0|1> <request-id>` 走现有 CG_CHAT。
|
||||
组数为 0 时取消本玩家的扩展追击距离,不重置冷却。
|
||||
服务端每次发 `AutoHuntGather <id> mob <vid>`,最后发 `AutoHuntGather <id> done <groups>`,
|
||||
走现有 CHAT_TYPE_COMMAND。每个消息很短,不受一条聊天封包长度限制。
|
||||
客户端只接受当前请求的回包;停用、手动暂停后旧回包不生效。
|
||||
双方有 10 秒冷却,服务端冷却以角色任务标记保存,重新登录或开关狩猎不能绕过。
|
||||
客户端原地等待追击怪物进入近战距离,最多等待 8 秒;3 秒无回包则继续普通狩猎。
|
||||
客户端搜索时原地等待追击怪物进入近战距离,最多等待 8 秒;3 秒无回包则继续普通狩猎。
|
||||
战斗中也会在 10 秒冷却后补拉,不必先杀完整批怪物;补拉不打断当前攻击。
|
||||
尚未进入客户端视野的服务端确认 VID 按距离保留 35/100/150 秒,给怪物时间接近玩家。
|
||||
界面显示本轮服务端确认的实际组数/设置组数,附近不足 20 组时不会产生额外怪物。
|
||||
“优先石头”优先选择狩猎范围内的石头,没有石头再攻击普通怪物;石头不受首领开关过滤。
|
||||
战斗中更改选项或出现石头时可以切换目标,优先攻击石头期间不发起新的引怪。
|
||||
|
||||
## 构建和回滚
|
||||
|
||||
`server.patch` 以 40250 的 `/usr/metin2/src` 为根,`patch -p1` 应用。
|
||||
`autohunt_pull.h` 和 `group_select.h` 是补丁中两份新增头文件的源文件。
|
||||
`../rebuild.sh` 已加入本补丁,沿用 build / deploy 流程。
|
||||
`group_select.h` 是基础补丁中新增的队伍选择头文件,`autohunt_pull.h` 保存当前扩展版本。
|
||||
基础补丁保持不变,范围扩展在 `../autohunt-pull-range/server.patch`,须按顺序应用。
|
||||
`../rebuild.sh` 已加入这两个补丁,沿用 build / deploy 流程,并处理基础头文件被后续补丁更新的状态检查。
|
||||
|
||||
2026-09-30 已在 192.168.21.203 编译并部署。原 `cmd.cpp`、`cmd_general.cpp`、旧 game
|
||||
备份在 `/root/autohunt-pull-20260930/`(旧程序为 `game.before`)。回滚时停 game、恢复旧程序后启动;
|
||||
@@ -31,3 +41,15 @@
|
||||
桌面和移动模式均通过。真服临时角色实测回包为 **3 组、9 只怪物**,随后进入自动战斗。
|
||||
临时角色、账号和关联数据已在刷新对应 DB 缓存后清理;auth/game/db 监听已检查。
|
||||
macOS 原生包及 Android debug APK 已重新构建。
|
||||
|
||||
## 2026-09-30 修正
|
||||
|
||||
修复了石头与首领等级过滤混用、普通怪物优先于石头、必须清空旧怪物批次才再次引怪、
|
||||
远处尚未同步的怪物 VID 被立即删除,以及近距离范围让 20 组请求只搜索很小区域的问题。
|
||||
狩猎边界增加至 35/100/150 米,旧设置低于 35 米会提升到 35 米;3/10/20 组按当前狩猎半径选择最近队伍。
|
||||
狩猎边界用于已同步角色的目标选择,超过当前视野的怪物需要先进入服务器同步范围。
|
||||
范围扩展需要重新构建和部署服务端。
|
||||
|
||||
回归测试 `port.login_flow` 使用真实 Python 配置和消息链,覆盖较远石头优先于近处已引来的怪物、
|
||||
关闭优先石头、战斗中开启优先石头、没有石头时回退打怪,以及 35/100/150 米设置和 20 组随狩猎距离拉怪。
|
||||
`host.autohunt_pull` 继续验证服务端 3/10/20 个真实队伍、冷却和队伍过滤。
|
||||
|
||||
@@ -3,9 +3,38 @@
|
||||
#include "group_select.h"
|
||||
#else
|
||||
#include "sectree_manager.h"
|
||||
#include "autohunt_pull_range.h"
|
||||
#include "autohunt_group_select.h"
|
||||
#endif
|
||||
|
||||
// PORT: only mobs pulled by this command receive a temporary extended pursuit leash.
|
||||
struct AutoHuntPullLease {
|
||||
LPCHARACTER mob;
|
||||
DWORD ownerPID;
|
||||
int radius;
|
||||
int expires;
|
||||
};
|
||||
static std::map<DWORD, AutoHuntPullLease> s_autoHuntPullLeases;
|
||||
int AutoHuntPullLeash(LPCHARACTER mob, LPCHARACTER victim) {
|
||||
std::map<DWORD, AutoHuntPullLease>::iterator it = s_autoHuntPullLeases.find((DWORD)mob->GetVID());
|
||||
if (it == s_autoHuntPullLeases.end()) return 4000;
|
||||
const AutoHuntPullLease& lease = it->second;
|
||||
if (lease.mob != mob || !victim || !victim->IsPC() || victim->IsDead() ||
|
||||
victim->GetPlayerID() != lease.ownerPID || mob->GetMapIndex() != victim->GetMapIndex() ||
|
||||
get_global_time() >= lease.expires) {
|
||||
s_autoHuntPullLeases.erase(it);
|
||||
return 4000;
|
||||
}
|
||||
return std::max(4000, lease.radius + 1);
|
||||
}
|
||||
static void AutoHuntPullPrune(DWORD cancelPID = 0) {
|
||||
for (std::map<DWORD, AutoHuntPullLease>::iterator it = s_autoHuntPullLeases.begin(); it != s_autoHuntPullLeases.end();) {
|
||||
if (it->second.expires <= get_global_time() || (cancelPID && it->second.ownerPID == cancelPID))
|
||||
s_autoHuntPullLeases.erase(it++);
|
||||
else ++it;
|
||||
}
|
||||
}
|
||||
|
||||
struct AutoHuntPullCollector {
|
||||
LPCHARACTER owner;
|
||||
int radius;
|
||||
@@ -35,8 +64,11 @@ ACMD(do_autohunt_pull) {
|
||||
unsigned int request = 0;
|
||||
char extra = 0;
|
||||
if (sscanf(argument, "%d %d %d %u %c", &groups, &radius, &bosses, &request, &extra) != 4 ||
|
||||
(groups != 3 && groups != 10 && groups != 20) || radius < 500 || radius > 5000 ||
|
||||
(groups != 0 && groups != 3 && groups != 10 && groups != 20) || radius < 500 || radius > 15000 ||
|
||||
(bosses != 0 && bosses != 1)) return;
|
||||
if (!ch->IsPC()) return;
|
||||
AutoHuntPullPrune(groups == 0 ? ch->GetPlayerID() : 0);
|
||||
if (groups == 0) return;
|
||||
const int now = get_global_time();
|
||||
if (!ch->IsPC() || ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || !ch->GetSectree() ||
|
||||
(ch->GetSectree()->GetAttribute(ch->GetX(), ch->GetY()) & ATTR_BANPK) ||
|
||||
@@ -47,13 +79,23 @@ ACMD(do_autohunt_pull) {
|
||||
// Server-side cooldown survives reconnects and switching auto hunt on/off.
|
||||
ch->SetQuestFlag("autohunt.next_pull", now + 10);
|
||||
AutoHuntPullCollector collector(ch, radius, bosses != 0);
|
||||
ch->GetSectree()->ForEachAround(collector);
|
||||
// ForEachAround only covers nine cells: visit every cell intersecting the requested radius.
|
||||
LPSECTREE_MAP map = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
|
||||
if (map) map->for_each_in_rect(std::max(0, int(ch->GetX()) - radius),
|
||||
std::max(0, int(ch->GetY()) - radius), ch->GetX() + radius, ch->GetY() + radius, collector);
|
||||
const mt_autohunt::Selection selected = mt_autohunt::SelectGroups(collector.candidates, groups);
|
||||
for (size_t i = 0; i < selected.mobs.size(); ++i) {
|
||||
LPCHARACTER mob = CHARACTER_MANAGER::instance().Find(selected.mobs[i]);
|
||||
if (!mob) continue;
|
||||
if (mob->IsDead() || (mob->GetVictim() && mob->GetVictim() != ch)) continue;
|
||||
AutoHuntPullLease lease = {mob, ch->GetPlayerID(), radius, now + 180};
|
||||
s_autoHuntPullLeases[(DWORD)mob->GetVID()] = lease;
|
||||
if (!mob->GetVictim()) mob->BeginFight(ch);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "AutoHuntGather %u mob %u", request, selected.mobs[i]);
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "AutoHuntGather %u done %d", request, selected.groups);
|
||||
}
|
||||
|
||||
#ifndef MT_AUTOHUNT_SERVER_TEST
|
||||
#include "server_bonuses.h"
|
||||
#endif
|
||||
|
||||
+19
-2
@@ -20,10 +20,15 @@ set -eu
|
||||
SRC=${SRC:-/usr/metin2/src}
|
||||
SERVER=${SERVER:-/usr/metin2/server}
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
PATCHES="inventory-5-pages hunt-set shop-item-time autohunt-pull"
|
||||
PATCHES="inventory-5-pages hunt-set shop-item-time autohunt-pull autohunt-pull-range"
|
||||
TS=$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
patch_state() {
|
||||
# The follow-up changes the header added by the base patch.
|
||||
if [ "$1" = autohunt-pull ] && patch -p1 -R -C -s -f -d "$SRC" < "$HERE/autohunt-pull-range/server.patch" > /dev/null 2>&1; then
|
||||
echo applied
|
||||
return
|
||||
fi
|
||||
if patch -p1 -R -C -s -f -d "$SRC" < "$HERE/$1/server.patch" > /dev/null 2>&1; then
|
||||
echo applied
|
||||
elif patch -p1 -C -s -f -d "$SRC" < "$HERE/$1/server.patch" > /dev/null 2>&1; then
|
||||
@@ -36,6 +41,16 @@ patch_state() {
|
||||
stop_server() {
|
||||
(cd "$SERVER" && sh close.sh) > /dev/null 2>&1 || true
|
||||
sleep 8
|
||||
remaining=$(ps ax -o pid,command | awk '$2 ~ /^\.\/(game|db|auth)$/ {print $1}')
|
||||
if [ -n "$remaining" ]; then
|
||||
# Some old shut.sh scripts reference stale/missing pid files. Still request a graceful exit.
|
||||
kill -TERM $remaining
|
||||
attempts=0
|
||||
while ps ax -o command | grep -q '^[.]/\(game\|db\|auth\)' && [ "$attempts" -lt 15 ]; do
|
||||
sleep 2
|
||||
attempts=$((attempts + 1))
|
||||
done
|
||||
fi
|
||||
if ps ax -o command | grep -q '^[.]/\(game\|db\|auth\)'; then echo "server still running" >&2; exit 1; fi
|
||||
}
|
||||
|
||||
@@ -58,7 +73,9 @@ build)
|
||||
conflict) echo "$p/server.patch does not apply" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
OUT=/root/rebuild/$TS
|
||||
# The legacy makefile does not track includes. Recompile commands after header patches.
|
||||
touch "$SRC/server/game/src/cmd_general.cpp"
|
||||
OUT=/root/rebuild/$TS
|
||||
mkdir -p "$OUT"
|
||||
# The Makefiles move the binary to GAMEDIR/DBDIR (default: the live share/bin).
|
||||
(cd "$SRC/server/game/src" && gmake -j2 GAMEDIR="$OUT") > "$OUT/game.log" 2>&1 || { tail "$OUT/game.log" >&2; exit 1; }
|
||||
|
||||
Reference in New Issue
Block a user