Add mobile touch UI and AVA2 biology system with server tools
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# AVA2 生物学家系统
|
||||
|
||||
本实现已替代最初的 collect_quest 远程窗口。任务状态使用 AVA2 的 `bio.level`、`bio.count`、`bio.time` 和 `bio.bonusN`;不迁移旧角色。
|
||||
|
||||
## 依据与规则
|
||||
|
||||
- 原始逻辑:`build/ava2-comparison/server/game/src/constants.cpp`、`cmd_general.cpp::do_bio`、`char.cpp::CheckBio`;原始客户端 `AVA2/1. Client DEV/pack_maker/root/uibiyolog.py`。
|
||||
- `import_ava2.py` 提取 13 阶段表和 do_bio 主体,输出 `ava2_biolog_core.h`、`catalog.json`、`reference.json`。保留算法与状态变更顺序,仅适配分词、消息本地化和当前协议中的点数编号。
|
||||
- 阶段为 30/40/50/60/70/80/85/90/92/94/98/100/105。基础成功率全部 60%;等待时间分别为 600/600/900/900/1800/1800/2700/3600/7200/7200/10800/10800/10800 秒。
|
||||
- 材料、数量、任务石、全部奖励值及是否选择奖励,均取原表。最后一份材料成功后进入任务石阶段;交石后自动发放全部固定奖励,或等待玩家选择一个奖励。没有原版额外宝箱。
|
||||
- 精华 71035 提高本次成功率 50 个百分点(60+50,必定成功);开启但未持有时沿用基础概率。冷却药剂 30250 只在仍处于冷却且选择跳过时消耗。提交失败也扣材料并开始下一次冷却,保持 AVA2 行为。
|
||||
- 默认开启精华、跳过冷却、到期提醒,按角色保存偏好。奖励在窗口直接选择;70028 从背包使用打开重选界面,重选消耗一份并只替换对应阶段的已选奖励。
|
||||
|
||||
## 实现
|
||||
|
||||
`src/platform/ScriptLib/BiologScript.inc` 通过 PythonBoot 注入 `mt_biolog`,界面适配鼠标和触摸,使用原有 `biodata`、`biostone`、`bioodul`、`bioempty` 消息。
|
||||
|
||||
服务端 `biolog_remote.h` 提供 `/bio status`、`mission <精华0/1> <跳过0/1>`、`gift <0起选项>`;增加 scoped 的 `buy <商品索引>` 和 `reset <阶段索引> <选项>` 以适配当前客户端协议。原 `/biolog status` 仅作查询别名,旧 act 不再执行。
|
||||
|
||||
原 do_bio 中伪造的空奖励选项可能让任务前进却不发奖。适配层拒绝非法选项、溢出的布尔值和额外参数;交易、仓库、商店、任务协程、死亡、传送期间不能变更研究状态。合法请求与 AVA2 对照验证。
|
||||
|
||||
### 属性实际效果
|
||||
|
||||
`patch_points.py` 增加 POINT_ATTBONUS_STONE=240、POINT_ATTBONUS_BOSS=241、POINT_RESIST_HUMAN=220;保留原 255 点数据包大小。PointChange、持久化 AFFECT_COLLECT 和实际 CalcAttBonus 均接入这些属性。
|
||||
|
||||
陨石/Boss 伤害的插入顺序和半人抗性的 PvP/NPC 算法取 AVA2;研究给予的怪物加成按 AVA2 排除 Boss。当前服务器原有非研究装备属性保持原规则。近战/魔法加成 132 已有实际效果。
|
||||
|
||||
### 商店及资源
|
||||
|
||||
`shop.json` / `ava2_biolog_shop.h` 来自 AVA2 MYSQL56 的 shop=8、shop_item 表:13 颗任务石按原金币价格出售,9 种后期材料按原指定材料数量兑换,共 22 项。当前服务器原 shop=8 为烟花店,保持它不变;新 UI 的研究商店使用独立命令,沿用 AVA2 的支付及发物顺序。
|
||||
|
||||
`make_assets.py` 从 AVA2 `home/srv1/db/item_proto.txt` 和解包客户端提取 29 个研究相关物品定义、图标和物品列表,输出当前 156 字节格式 proto 和小型 `biolog.eix/.epk`。名称/描述为中文。`tests/port/biolog_proto_patch.cpp` 对其他物品记录不做变更,并校验编码回读。
|
||||
|
||||
资源包必须作为当前 `Client/pack/Index` 的首个条目:
|
||||
|
||||
```
|
||||
PACK
|
||||
*
|
||||
biolog
|
||||
...原有条目...
|
||||
```
|
||||
|
||||
Android APK 不包含完整游戏资源;必须同时更新 `biolog.eix`、`biolog.epk` 与 Index。正常使用 `android/push-client.sh --locale zh` 同步即可。商店所用兑换货币在当前服已有物品定义;没有把 AVA2 的其他地图、世界 Boss 或全服掉落系统一并替换。
|
||||
|
||||
## 构建、部署和回滚
|
||||
|
||||
1. `python3 import_ava2.py AVA2_GAME_SOURCE OUTPUT`,核对 reference.json;生成的主体不手改。
|
||||
2. 使用 `make_assets.py` 准备物品和补丁包。生成命令/输入参数见脚本。
|
||||
3. 备份当前源码,在服务器执行 `prepare_source.py GAME_SRC STAGE`、`patch_points.py GAME_SRC`,隔离输出 `gmake -j2 GAMEDIR=BUILD_DIR`。char.h 变化需要重编依赖。
|
||||
4. 在隔离目录用当前 qc 编译 `port_bio_reset.quest`。
|
||||
5. `sh deploy_ava2.sh BUILD_DIR`。先等待所有 game cores 正常保存退出,再停 db/auth;备份原 game、物品表、旧任务对象,加载新增物品后重启服务。
|
||||
|
||||
`install_ava2_data.py` 将 455 个旧 collect_quest_lv*、collect_quest_reset 事件移到备份目录,避免两个研究系统同时生效;原始任务源文件与现有角色数据库未批量修改。
|
||||
|
||||
2026-10-14 已部署到 203:独立构建 `/root/biolog-ava2-build-20261014`,回滚备份 `/root/backup-biolog-ava2/20261015-030954`(服务器时区)。源码修改前备份在构建目录的 source-backup。
|
||||
|
||||
回滚需停 game/db/auth,恢复备份 game、data/item_proto.txt、data/item_names.txt 和 data/legacy-objects.json 中的任务文件;移除 port_bio_reset 对象,再启动服务。部署前 source-backup 可恢复源码。新系统不继承 collect_quest 的 flag;不对旧角色已存在的历史属性做清除。
|
||||
|
||||
## 验证
|
||||
|
||||
- `tests/test_ava2.py AVA2_GAME_SOURCE`:6,674 组原始 do_bio 与适配入口对照,涵盖 13 阶段、概率边界、材料/石头、冷却、辅助道具、固定/选择奖励累计;验证重复领奖、非法参数、22 项商店和奖励重选。
|
||||
- `tests/test_combat.py PATCHED_BATTLE_CPP`:编译实际 CalcAttBonus,检查陨石/Boss 加成、研究怪物加成排除 Boss、半人抗性。
|
||||
- `port.login_flow`:桌面与触摸均通过,包含真实点击入口、消息处理、重复点击拦截、冷却、各阶段奖励选项显示。
|
||||
- 专用角色联机 initial/aux/gift4/gift13/shop:真实扣材料、精华必成、冷却药剂消耗、石头转选奖、点数 240 生效、最终完成、兑换扣料均通过。重登和背包使用重选道具另有 resume/reset 模式。
|
||||
- 日志、资源生成记录及截图在忽略的 `build/biolog-ava2-validation/`。离线截图使用演示数据;未自动安装到 Android 真机。
|
||||
|
||||
最终验收补充:70028 的 ITEM_QUEST 类型、堆叠与数值也按 AVA2 导入(因此总计 29 个模板)。
|
||||
第二次物品备份 `/root/backup-biolog-ava2/20261015-031709`,完成角色奖励列表补充的 game 备份 `/root/backup-biolog-ava2-game/20261015-032329`。
|
||||
常规 `scripts/build_zh_locale.py` 已自动生成并注册 biolog 补丁;Android 同步摘要纳入其配置及生成器。
|
||||
Mac 本地签名包已校验并从独立 bundle 资源完成渲染启动检查;Android 更新 ZIP 包含 APK、三份资源文件及同步脚本。
|
||||
最终联机 resume/reset/complete 均通过,覆盖从背包使用 70028、不提前扣券、只替换所选奖励、完成全部研究后重登保留选择记录。五个专用测试账号已设为 BLOCK,临时 AVA2 MyISAM 参考数据库已移除。两个 ZIP 均完成 CRC 校验,Mac bundle 签名校验通过。
|
||||
@@ -0,0 +1,389 @@
|
||||
// Generated from AVA2 constants.cpp + cmd_general.cpp by import_ava2.py.
|
||||
static const unsigned bio_data[][17] = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{30, 30006, 10, 600, 60, 30220, POINT_DEF_GRADE_BONUS, 30, 0, 0, 0, 0, 0, 0, 0, 71035, 30250},
|
||||
{40, 30047, 15, 600, 60, 30221, POINT_ATT_GRADE_BONUS, 40, 0, 0, 0, 0, 0, 0, 0, 71035, 30250},
|
||||
{50, 30015, 15, 900, 60, 30222, POINT_ATTBONUS_MONSTER, 5, 0, 0, 0, 0, 0, 0, 0, 71035, 30250},
|
||||
{60, 30050, 20, 900, 60, 30223, POINT_ATTBONUS_STONE, 4, POINT_ATTBONUS_BOSS, 4, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
{70, 300004, 25, 1800, 60, 30224, POINT_ATTBONUS_BOSS, 6, POINT_ATTBONUS_STONE, 6, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
{80, 300005, 30, 1800, 60, 30225, POINT_MAX_HP, 1000, POINT_CASTING_SPEED, 10, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
{85, 300006, 40, 2700, 60, 30226, POINT_RESIST_WARRIOR, 10, POINT_RESIST_ASSASSIN, 10, POINT_RESIST_SURA, 10, POINT_RESIST_SHAMAN, 10, 0, 71035, 30250},
|
||||
{90, 300007, 50, 3600, 60, 30227, POINT_ATTBONUS_WARRIOR, 10, POINT_ATTBONUS_ASSASSIN, 10, POINT_ATTBONUS_SURA, 10, POINT_ATTBONUS_SHAMAN, 10, 0, 71035, 30250},
|
||||
{92, 300008, 10, 7200, 60, 30228, POINT_MAX_HP, 1200, POINT_DEF_GRADE_BONUS, 120, POINT_ATT_GRADE_BONUS, 50, 0, 0, 1, 71035, 30250},
|
||||
{94, 300009, 20, 7200, 60, 30229, POINT_MAX_HP, 1500, POINT_DEF_GRADE_BONUS, 140, POINT_ATT_GRADE_BONUS, 60, 0, 0, 1, 71035, 30250},
|
||||
{98, 300010, 35, 10800, 60, 30230, POINT_ATTBONUS_MONSTER, 10, POINT_RESIST_HUMAN, 10, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
{100, 300011, 35, 10800, 60, 30231, POINT_ATTBONUS_STONE, 10, POINT_MELEE_MAGIC_ATT_BONUS_PER, 10, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
{105, 300012, 35, 10800, 60, 30232, POINT_ATTBONUS_BOSS, 10, POINT_ATTBONUS_HUMAN, 10, 0, 0, 0, 0, 1, 71035, 30250},
|
||||
};
|
||||
static const unsigned bio_max = 14;
|
||||
static ACMD(do_ava2_bio)
|
||||
{
|
||||
if (ch->GetLevel() < 30)
|
||||
return;
|
||||
|
||||
std::vector<std::string> vecArgs;
|
||||
BioSplitArgument(argument, vecArgs);
|
||||
if (vecArgs.size() < 2) { return; }
|
||||
|
||||
int level = ch->GetQuestFlag("bio.level");
|
||||
|
||||
if (level >= bio_max)
|
||||
return;
|
||||
else if (level < 1)
|
||||
return;
|
||||
else if (ch->GetLevel() < bio_data[level][0])
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice level %d", bio_data[level][0]);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = ch->GetQuestFlag("bio.count");
|
||||
int time = ch->GetQuestFlag("bio.time");
|
||||
|
||||
if (vecArgs[1] == "mission")
|
||||
{
|
||||
if (vecArgs.size() < 4) { return; }
|
||||
BYTE isOzut = 0;
|
||||
BYTE isUnutkanlik = 0;
|
||||
|
||||
str_to_number(isOzut, vecArgs[2].c_str());
|
||||
str_to_number(isUnutkanlik, vecArgs[3].c_str());
|
||||
|
||||
if (count < bio_data[level][2])
|
||||
{
|
||||
if (ch->CountSpecifyItem(bio_data[level][1]) < 1)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice material %d", bio_data[level][1]);
|
||||
return;
|
||||
}
|
||||
|
||||
//bool isUnutkanlikDrink = false;
|
||||
|
||||
if (isUnutkanlik)
|
||||
{
|
||||
if (ch->CountSpecifyItem(bio_data[level][16]) > 0 && time > get_global_time())//fix
|
||||
//if (ch->CountSpecifyItem(bio_data[level][16]) > 0)
|
||||
{
|
||||
ch->RemoveSpecifyItem(bio_data[level][16], 1);
|
||||
//isUnutkanlikDrink = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time > get_global_time())
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice cooldown %d", bio_data[level][16]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time > get_global_time())
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice cooldown %d",bio_data[level][16]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isOzutDrink = false;
|
||||
if (isOzut)
|
||||
{
|
||||
if (ch->CountSpecifyItem(bio_data[level][15]) > 0)
|
||||
{
|
||||
ch->RemoveSpecifyItem(bio_data[level][15], 1);
|
||||
isOzutDrink = true;
|
||||
}
|
||||
}
|
||||
|
||||
int prob = isOzutDrink ? bio_data[level][4] + 50 : bio_data[level][4];
|
||||
ch->RemoveSpecifyItem(bio_data[level][1], 1);
|
||||
if (prob >= number(1, 100))
|
||||
{
|
||||
count += 1;
|
||||
time = get_global_time() + bio_data[level][3];
|
||||
ch->SetQuestFlag("bio.count", count);
|
||||
ch->SetQuestFlag("bio.time", time);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biodata %d %d %d", level, count, time);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice success %d", bio_data[level][1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
time = get_global_time() + bio_data[level][3];
|
||||
ch->SetQuestFlag("bio.time", time);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biodata %d %d %d", level, count, time);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice failure %d", bio_data[level][1]);
|
||||
}
|
||||
|
||||
if (bio_data[level][5] != 0)
|
||||
{
|
||||
if (count == bio_data[level][2])
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biostone %d", level);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (bio_data[level][5] != 0)
|
||||
{
|
||||
if (count == bio_data[level][2])
|
||||
{
|
||||
if (ch->CountSpecifyItem(bio_data[level][5]) < 1)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice stone %d", bio_data[level][5]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch->RemoveSpecifyItem(bio_data[level][5], 1);
|
||||
ch->SetQuestFlag("bio.count", count+1);
|
||||
|
||||
if (bio_data[level][14] == 0)
|
||||
{
|
||||
ch->SetQuestFlag("bio.count", 0);
|
||||
ch->SetQuestFlag("bio.level", level + 1);
|
||||
ch->SetQuestFlag("bio.time", 0);
|
||||
|
||||
if (bio_data[level][6] != 0)
|
||||
{
|
||||
long value = bio_data[level][7];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][6]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][6], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][6]), bio_data[level][7]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][8] != 0)
|
||||
{
|
||||
long value = bio_data[level][9];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][8]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][8], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][8]), bio_data[level][9]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][10] != 0)
|
||||
{
|
||||
long value = bio_data[level][11];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][10]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][10], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][10]), bio_data[level][11]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][12] != 0)
|
||||
{
|
||||
long value = bio_data[level][13];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][12]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][12], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][12]), bio_data[level][13]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
int newLevel = level + 1;
|
||||
if (newLevel >= bio_max)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice complete");
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "bioempty");
|
||||
return;
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biodata %d %d %d", newLevel,0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "bioodul %d", level);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (count == bio_data[level][2]+1)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count == bio_data[level][2])
|
||||
{
|
||||
if (bio_data[level][14] == 0)
|
||||
{
|
||||
ch->SetQuestFlag("bio.count", 0);
|
||||
ch->SetQuestFlag("bio.level", level + 1);
|
||||
ch->SetQuestFlag("bio.time", 0);
|
||||
|
||||
if (bio_data[level][6] != 0)
|
||||
{
|
||||
long value = bio_data[level][7];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][6]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][6], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][6]), bio_data[level][7]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][8] != 0)
|
||||
{
|
||||
long value = bio_data[level][9];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][8]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][8], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][8]), bio_data[level][9]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][10] != 0)
|
||||
{
|
||||
long value = bio_data[level][11];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][10]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][10], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][10]), bio_data[level][11]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][12] != 0)
|
||||
{
|
||||
long value = bio_data[level][13];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][12]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][12], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][12]), bio_data[level][13]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
int newLevel = level + 1;
|
||||
if (newLevel >= bio_max)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice complete");
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "bioempty");
|
||||
return;
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biodata %d %d %d", newLevel, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "bioodul %d", level);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (vecArgs[1] == "gift")
|
||||
{
|
||||
if (vecArgs.size() < 3) { return; }
|
||||
BYTE index = 0;
|
||||
str_to_number(index, vecArgs[2].c_str());
|
||||
|
||||
if (index > 3)
|
||||
return;
|
||||
|
||||
if (bio_data[level][5] != 0)
|
||||
{
|
||||
if (count != bio_data[level][2] + 1)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != bio_data[level][2])
|
||||
return;
|
||||
}
|
||||
|
||||
ch->SetQuestFlag("bio.count", 0);
|
||||
ch->SetQuestFlag("bio.level", level + 1);
|
||||
ch->SetQuestFlag("bio.time", 0);
|
||||
|
||||
if (bio_data[level][6] != 0 && index == 0)
|
||||
{
|
||||
long value = bio_data[level][7];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][6]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][6], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][6]), bio_data[level][7]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][8] != 0 && index == 1)
|
||||
{
|
||||
long value = bio_data[level][9];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][8]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][8], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][8]), bio_data[level][9]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
if (bio_data[level][10] != 0 && index == 2)
|
||||
{
|
||||
long value = bio_data[level][11];
|
||||
CAffect* affect = ch->FindAffect(AFFECT_COLLECT, bio_data[level][10]);
|
||||
if (affect) {
|
||||
value += affect->lApplyValue;
|
||||
ch->RemoveAffect(affect);
|
||||
}
|
||||
ch->AddAffect(AFFECT_COLLECT, bio_data[level][10], value, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false);
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice reward %d %d", BioPointIdentity(bio_data[level][10]), bio_data[level][11]);
|
||||
//ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice next");
|
||||
}
|
||||
|
||||
char flag[100];
|
||||
sprintf(flag, "bio.bonus%d", level);
|
||||
ch->SetQuestFlag(flag, index + 1);
|
||||
|
||||
int newLevel = level + 1;
|
||||
if (newLevel >= bio_max)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "BioNotice complete");
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "bioempty");
|
||||
return;
|
||||
}
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "biodata %d %d %d", newLevel, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// AVA2 shop 8 snapshot; IDs are scoped to /bio buy, no current shop is replaced.
|
||||
struct BioShopEntry {unsigned vnum,count,cost,amount,gold;};
|
||||
static const BioShopEntry kBioShop[] = {
|
||||
{30220,1,0,0,5000000},
|
||||
{30221,1,0,0,7000000},
|
||||
{30222,1,0,0,10000000},
|
||||
{30223,1,0,0,13000000},
|
||||
{30224,1,0,0,20000000},
|
||||
{30225,1,0,0,25000000},
|
||||
{30226,1,0,0,50000000},
|
||||
{30227,1,0,0,100000000},
|
||||
{30228,1,0,0,200000000},
|
||||
{30229,1,0,0,200000000},
|
||||
{30230,1,0,0,500000000},
|
||||
{30231,1,0,0,500000000},
|
||||
{30232,1,0,0,500000000},
|
||||
{300004,1,30091,5,0},
|
||||
{300005,1,30197,3,0},
|
||||
{300006,1,30198,2,0},
|
||||
{300007,1,30196,2,0},
|
||||
{300008,1,70031,3,0},
|
||||
{300009,1,70031,5,0},
|
||||
{300010,1,30520,7,0},
|
||||
{300011,1,30521,7,0},
|
||||
{300012,1,30518,7,0},
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
// PORT: AVA2 bio.* system. The extracted core preserves its 13 stages and reward accumulation.
|
||||
#include "questpc.h"
|
||||
#include "item_manager.h"
|
||||
#include "item.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
static void BioSplitArgument(const char* argument, std::vector<std::string>& out) {
|
||||
// AVA2 split_argument includes the sub-command at index 1.
|
||||
out.push_back("bio"); std::istringstream input(argument); std::string word;
|
||||
while (input >> word) out.push_back(word);
|
||||
}
|
||||
static unsigned BioPointIdentity(unsigned point) { return point; }
|
||||
#include "ava2_biolog_core.h"
|
||||
|
||||
static void SendBioState(LPCHARACTER ch) {
|
||||
int stage=ch->GetQuestFlag("bio.level");
|
||||
if (stage==0) {stage=1;ch->SetQuestFlag("bio.level",1);}
|
||||
if (stage<1 || stage>=int(bio_max)) ch->ChatPacket(CHAT_TYPE_COMMAND,"bioempty");
|
||||
else {
|
||||
int count=ch->GetQuestFlag("bio.count");
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"biotime %d",int(get_global_time()));
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"biodata %d %d %d",stage,count,ch->GetQuestFlag("bio.time"));
|
||||
if (count>=int(bio_data[stage][2])) {
|
||||
if (count==int(bio_data[stage][2]) && bio_data[stage][5]) ch->ChatPacket(CHAT_TYPE_COMMAND,"biostone %d",stage);
|
||||
else if (bio_data[stage][14]) ch->ChatPacket(CHAT_TYPE_COMMAND,"bioodul %d",stage);
|
||||
}
|
||||
}
|
||||
// Completed characters still need their selections for the 70028 reselection UI.
|
||||
std::ostringstream bonuses;
|
||||
for (unsigned i=1;i<bio_max;++i) {
|
||||
char flag[40];snprintf(flag,sizeof(flag),"bio.bonus%u",i);
|
||||
bonuses << ' ' << ch->GetQuestFlag(flag);
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"biobonuses%s",bonuses.str().c_str());
|
||||
}
|
||||
|
||||
#include "ava2_biolog_shop.h"
|
||||
|
||||
static bool BioShopBuy(LPCHARACTER ch, unsigned index) {
|
||||
if (index>=sizeof(kBioShop)/sizeof(kBioShop[0])) return false;
|
||||
const BioShopEntry& offer=kBioShop[index];
|
||||
if ((offer.cost && ch->CountSpecifyItem(offer.cost)<int(offer.amount)) ||
|
||||
(!offer.cost && ch->GetGold()<int(offer.gold))) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"BioNotice cost"); return true;
|
||||
}
|
||||
LPITEM item=ch->AutoGiveItem(offer.vnum,offer.count,-1,true);
|
||||
if (!item) return true;
|
||||
if (offer.cost) ch->RemoveSpecifyItem(offer.cost,offer.amount);
|
||||
else ch->PointChange(POINT_GOLD,-int(offer.gold),false);
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"BioNotice bought");
|
||||
return true;
|
||||
}
|
||||
|
||||
static void BioResetBonus(LPCHARACTER ch,unsigned index,unsigned choice) {
|
||||
if (index<1 || index>=bio_max || index>=unsigned(ch->GetQuestFlag("bio.level")) ||
|
||||
!bio_data[index][14] || choice>3 || !bio_data[index][6+choice*2]) return;
|
||||
char flag[40];snprintf(flag,sizeof(flag),"bio.bonus%u",index);
|
||||
int old=ch->GetQuestFlag(flag)-1;
|
||||
if(old<0 || old>3 || old==int(choice)) return;
|
||||
if(ch->CountSpecifyItem(70028)<1) {ch->ChatPacket(CHAT_TYPE_COMMAND,"BioNotice reset_item");return;}
|
||||
unsigned oldPoint=bio_data[index][6+old*2];
|
||||
CAffect* previous=ch->FindAffect(AFFECT_COLLECT,oldPoint);
|
||||
// Missing persisted rewards must not create a new bonus through a reset request.
|
||||
if(!previous || previous->lApplyValue<int(bio_data[index][7+old*2])) return;
|
||||
int remaining=previous->lApplyValue-bio_data[index][7+old*2];
|
||||
ch->RemoveAffect(previous);
|
||||
if(remaining)ch->AddAffect(AFFECT_COLLECT,oldPoint,remaining,AFF_NONE,INFINITE_AFFECT_DURATION,0,false);
|
||||
unsigned point=bio_data[index][6+choice*2];
|
||||
int value=bio_data[index][7+choice*2];
|
||||
CAffect* existing=ch->FindAffect(AFFECT_COLLECT,point);
|
||||
if(existing) {value+=existing->lApplyValue;ch->RemoveAffect(existing);}
|
||||
ch->RemoveSpecifyItem(70028,1);
|
||||
ch->AddAffect(AFFECT_COLLECT,point,value,AFF_NONE,INFINITE_AFFECT_DURATION,0,false);
|
||||
ch->SetQuestFlag(flag,choice+1);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"BioNotice reset");
|
||||
}
|
||||
|
||||
ACMD(do_port_biolog) {
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
std::vector<std::string> args;BioSplitArgument(argument,args);
|
||||
if (args.size()==2 && args[1]=="status") {SendBioState(ch);return;}
|
||||
if (pc->IsRunning() || !ch->CanHandleItem() || ch->IsDead() || ch->IsStun() || ch->IsWarping() ||
|
||||
ch->GetExchange() || ch->GetShop() || ch->GetMyShop() || ch->IsOpenSafebox() || ch->IsCubeOpen()) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"BioNotice busy"); return;
|
||||
}
|
||||
if(args.size()==3 && args[1]=="buy") {
|
||||
unsigned index=999;std::istringstream parser(args[2]);char extra;
|
||||
if((parser>>index) && !(parser>>extra)) BioShopBuy(ch,index);
|
||||
SendBioState(ch);return;
|
||||
}
|
||||
if(args.size()==4 && args[1]=="reset") {
|
||||
unsigned index=999,choice=999;char extra;
|
||||
std::istringstream a(args[2]),b(args[3]);
|
||||
if((a>>index) && !(a>>extra) && (b>>choice) && !(b>>extra)) BioResetBonus(ch,index,choice);
|
||||
SendBioState(ch);return;
|
||||
}
|
||||
int stage=ch->GetQuestFlag("bio.level");
|
||||
if (stage<1 || stage>=int(bio_max)) return;
|
||||
// Reject forged booleans/empty reward choices before AVA2's byte parsing can wrap them.
|
||||
if (args.size()==4 && args[1]=="mission" && (args[2]=="0" || args[2]=="1") && (args[3]=="0" || args[3]=="1")) {
|
||||
do_ava2_bio(ch,argument,cmd,subcmd);
|
||||
} else if (args.size()==3 && args[1]=="gift" && args[2].size()==1 && args[2][0]>='0' && args[2][0]<='3') {
|
||||
unsigned choice=args[2][0]-'0';
|
||||
if (!bio_data[stage][14] || !bio_data[stage][6+choice*2]) return;
|
||||
do_ava2_bio(ch,argument,cmd,subcmd);
|
||||
} else return;
|
||||
SendBioState(ch);
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
[
|
||||
{
|
||||
"index": 1,
|
||||
"level": 30,
|
||||
"material": 30006,
|
||||
"count": 10,
|
||||
"cooldown": 600,
|
||||
"chance": 60,
|
||||
"stone": 30220,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_DEF_GRADE_BONUS",
|
||||
"label": "防御力",
|
||||
"value": 30
|
||||
}
|
||||
],
|
||||
"choose": false,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"level": 40,
|
||||
"material": 30047,
|
||||
"count": 15,
|
||||
"cooldown": 600,
|
||||
"chance": 60,
|
||||
"stone": 30221,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATT_GRADE_BONUS",
|
||||
"label": "攻击力",
|
||||
"value": 40
|
||||
}
|
||||
],
|
||||
"choose": false,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 3,
|
||||
"level": 50,
|
||||
"material": 30015,
|
||||
"count": 15,
|
||||
"cooldown": 900,
|
||||
"chance": 60,
|
||||
"stone": 30222,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_MONSTER",
|
||||
"label": "对怪物伤害 %",
|
||||
"value": 5
|
||||
}
|
||||
],
|
||||
"choose": false,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 4,
|
||||
"level": 60,
|
||||
"material": 30050,
|
||||
"count": 20,
|
||||
"cooldown": 900,
|
||||
"chance": 60,
|
||||
"stone": 30223,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_STONE",
|
||||
"label": "对陨石伤害 %",
|
||||
"value": 4
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_BOSS",
|
||||
"label": "对 Boss 伤害 %",
|
||||
"value": 4
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 5,
|
||||
"level": 70,
|
||||
"material": 300004,
|
||||
"count": 25,
|
||||
"cooldown": 1800,
|
||||
"chance": 60,
|
||||
"stone": 30224,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_BOSS",
|
||||
"label": "对 Boss 伤害 %",
|
||||
"value": 6
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_STONE",
|
||||
"label": "对陨石伤害 %",
|
||||
"value": 6
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 6,
|
||||
"level": 80,
|
||||
"material": 300005,
|
||||
"count": 30,
|
||||
"cooldown": 1800,
|
||||
"chance": 60,
|
||||
"stone": 30225,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_MAX_HP",
|
||||
"label": "生命值",
|
||||
"value": 1000
|
||||
},
|
||||
{
|
||||
"point": "POINT_CASTING_SPEED",
|
||||
"label": "施法速度",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 7,
|
||||
"level": 85,
|
||||
"material": 300006,
|
||||
"count": 40,
|
||||
"cooldown": 2700,
|
||||
"chance": 60,
|
||||
"stone": 30226,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_RESIST_WARRIOR",
|
||||
"label": "战士抗性 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_RESIST_ASSASSIN",
|
||||
"label": "忍者抗性 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_RESIST_SURA",
|
||||
"label": "修罗抗性 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_RESIST_SHAMAN",
|
||||
"label": "萨满抗性 %",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": false,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 8,
|
||||
"level": 90,
|
||||
"material": 300007,
|
||||
"count": 50,
|
||||
"cooldown": 3600,
|
||||
"chance": 60,
|
||||
"stone": 30227,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_WARRIOR",
|
||||
"label": "对战士伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_ASSASSIN",
|
||||
"label": "对忍者伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_SURA",
|
||||
"label": "对修罗伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_SHAMAN",
|
||||
"label": "对萨满伤害 %",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": false,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 9,
|
||||
"level": 92,
|
||||
"material": 300008,
|
||||
"count": 10,
|
||||
"cooldown": 7200,
|
||||
"chance": 60,
|
||||
"stone": 30228,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_MAX_HP",
|
||||
"label": "生命值",
|
||||
"value": 1200
|
||||
},
|
||||
{
|
||||
"point": "POINT_DEF_GRADE_BONUS",
|
||||
"label": "防御力",
|
||||
"value": 120
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATT_GRADE_BONUS",
|
||||
"label": "攻击力",
|
||||
"value": 50
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 10,
|
||||
"level": 94,
|
||||
"material": 300009,
|
||||
"count": 20,
|
||||
"cooldown": 7200,
|
||||
"chance": 60,
|
||||
"stone": 30229,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_MAX_HP",
|
||||
"label": "生命值",
|
||||
"value": 1500
|
||||
},
|
||||
{
|
||||
"point": "POINT_DEF_GRADE_BONUS",
|
||||
"label": "防御力",
|
||||
"value": 140
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATT_GRADE_BONUS",
|
||||
"label": "攻击力",
|
||||
"value": 60
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 11,
|
||||
"level": 98,
|
||||
"material": 300010,
|
||||
"count": 35,
|
||||
"cooldown": 10800,
|
||||
"chance": 60,
|
||||
"stone": 30230,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_MONSTER",
|
||||
"label": "对怪物伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_RESIST_HUMAN",
|
||||
"label": "半人抗性 %",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 12,
|
||||
"level": 100,
|
||||
"material": 300011,
|
||||
"count": 35,
|
||||
"cooldown": 10800,
|
||||
"chance": 60,
|
||||
"stone": 30231,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_STONE",
|
||||
"label": "对陨石伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_MELEE_MAGIC_ATT_BONUS_PER",
|
||||
"label": "近战及魔法攻击 %",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
},
|
||||
{
|
||||
"index": 13,
|
||||
"level": 105,
|
||||
"material": 300012,
|
||||
"count": 35,
|
||||
"cooldown": 10800,
|
||||
"chance": 60,
|
||||
"stone": 30232,
|
||||
"bonuses": [
|
||||
{
|
||||
"point": "POINT_ATTBONUS_BOSS",
|
||||
"label": "对 Boss 伤害 %",
|
||||
"value": 10
|
||||
},
|
||||
{
|
||||
"point": "POINT_ATTBONUS_HUMAN",
|
||||
"label": "对半人伤害 %",
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
"choose": true,
|
||||
"enhancer": 71035,
|
||||
"skip": 30250
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# Switch the running 203 runtime to AVA2 bio.* and reload the added item templates.
|
||||
set -eu
|
||||
SERVER=${SERVER:-/usr/metin2/server}
|
||||
OUT=${1:?usage: deploy_ava2.sh BUILD_DIR}
|
||||
PYTHON=${PYTHON:-/usr/local/bin/python3.9}
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
BACKUP=/root/backup-biolog-ava2/$(date +%Y%m%d-%H%M%S)
|
||||
PIDS=/usr/metin2/.mt40250-pids
|
||||
[ -x "$OUT/game" ] && [ -s "$OUT/items/items-server.tsv" ] && [ -s "$OUT/quest-stage/object/state/port_bio_reset" ]
|
||||
mkdir -p "$BACKUP"
|
||||
cp -p "$SERVER/share/bin/game" "$BACKUP/game"
|
||||
cp -p "$PIDS" "$BACKUP/pids"
|
||||
# Wait for graceful game saves before stopping their database process.
|
||||
awk '$2 != "db" && $2 != "auth" {print $1}' "$PIDS" | while read -r pid; do kill -TERM "$pid" 2>/dev/null || true; done
|
||||
attempt=0
|
||||
while ps ax -o command | grep -q '^[.]/game' && [ "$attempt" -lt 180 ]; do
|
||||
sleep 1;attempt=$((attempt+1))
|
||||
done
|
||||
if ps ax -o command | grep -q '^[.]/game'; then echo "game processes did not exit; backup $BACKUP" >&2;exit 1;fi
|
||||
sh "$HERE/../stop_server.sh"
|
||||
attempt=0
|
||||
while ps ax -o command | grep -q '^[.]/\(db\|auth\)' && [ "$attempt" -lt 30 ]; do sleep 1;attempt=$((attempt+1));done
|
||||
if ps ax -o command | grep -q '^[.]/\(db\|auth\)'; then echo "db/auth did not exit" >&2;exit 1;fi
|
||||
"$PYTHON" "$HERE/install_ava2_data.py" "$SERVER" "$OUT/items" "$OUT/quest-stage" "$BACKUP/data"
|
||||
cp -p "$OUT/game" "$SERVER/share/bin/game.biolog-new"
|
||||
mv "$SERVER/share/bin/game.biolog-new" "$SERVER/share/bin/game"
|
||||
sh "$HERE/../start_server.sh"
|
||||
echo "AVA2 biolog installed; backup: $BACKUP"
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Game-only update when item templates/quest objects have not changed.
|
||||
set -eu
|
||||
NEW=${1:?usage: deploy_game.sh NEW_GAME}
|
||||
SERVER=${SERVER:-/usr/metin2/server}
|
||||
PIDS=/usr/metin2/.mt40250-pids
|
||||
BACKUP=/root/backup-biolog-ava2-game/$(date +%Y%m%d-%H%M%S)
|
||||
[ -x "$NEW" ] && [ -f "$PIDS" ]
|
||||
mkdir -p "$BACKUP"
|
||||
cp -p "$SERVER/share/bin/game" "$BACKUP/game"
|
||||
cp -p "$PIDS" "$BACKUP/pids"
|
||||
cp -p "$NEW" "$SERVER/share/bin/game.bio-next"
|
||||
awk '$2!="db" && $2!="auth" {print $1}' "$PIDS" | while read -r pid; do kill -TERM "$pid" 2>/dev/null || true; done
|
||||
attempt=0
|
||||
while ps ax -o command | grep -q '^[.]/game' && [ "$attempt" -lt 180 ]; do sleep 1;attempt=$((attempt+1));done
|
||||
if ps ax -o command | grep -q '^[.]/game';then echo "game cores did not stop; backup $BACKUP" >&2;exit 1;fi
|
||||
mv "$SERVER/share/bin/game.bio-next" "$SERVER/share/bin/game"
|
||||
awk '$2=="db" || $2=="auth" {print}' "$BACKUP/pids" > "$PIDS"
|
||||
awk '$2!="db" && $2!="auth" {print $2}' "$BACKUP/pids" | while read -r name;do
|
||||
(cd "$SERVER/$name" && exec ./game) >> "$SERVER/$name/console.log" 2>&1 &
|
||||
echo "$! $name" >> "$PIDS"
|
||||
done
|
||||
echo "Game update installed; backup: $BACKUP"
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extract AVA2's active biology table and command body, retaining reference provenance.
|
||||
Only command dispatch, notification transport and three PORT point numbers are adapted.
|
||||
"""
|
||||
import argparse, hashlib, json, re
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parent
|
||||
NAMES={
|
||||
'POINT_DEF_GRADE_BONUS':'防御力','POINT_ATT_GRADE_BONUS':'攻击力','POINT_ATTBONUS_MONSTER':'对怪物伤害 %',
|
||||
'POINT_ATTBONUS_STONE':'对陨石伤害 %','POINT_ATTBONUS_BOSS':'对 Boss 伤害 %','POINT_MAX_HP':'生命值',
|
||||
'POINT_CASTING_SPEED':'施法速度','POINT_RESIST_WARRIOR':'战士抗性 %','POINT_RESIST_ASSASSIN':'忍者抗性 %',
|
||||
'POINT_RESIST_SURA':'修罗抗性 %','POINT_RESIST_SHAMAN':'萨满抗性 %','POINT_ATTBONUS_WARRIOR':'对战士伤害 %',
|
||||
'POINT_ATTBONUS_ASSASSIN':'对忍者伤害 %','POINT_ATTBONUS_SURA':'对修罗伤害 %','POINT_ATTBONUS_SHAMAN':'对萨满伤害 %',
|
||||
'POINT_RESIST_HUMAN':'半人抗性 %','POINT_MELEE_MAGIC_ATT_BONUS_PER':'近战及魔法攻击 %','POINT_ATTBONUS_HUMAN':'对半人伤害 %'}
|
||||
|
||||
def extract(reference):
|
||||
constants=(reference/'constants.cpp').read_bytes().decode('latin1')
|
||||
table=re.search(r'const DWORD bio_data\[\]\[17\] = \{(.*?)\n\};',constants,re.S).group(1)
|
||||
rows=[]
|
||||
for match in re.finditer(r'\{([^{}]+)\}', table):
|
||||
values=[x.strip() for x in match[1].split(',')]; assert len(values)==17
|
||||
rows.append([v if v.startswith('POINT_') else int(v) for v in values])
|
||||
assert len(rows)==14
|
||||
return rows
|
||||
|
||||
def generate(reference,output):
|
||||
rows=extract(reference)
|
||||
source=(reference/'cmd_general.cpp').read_bytes().decode('latin1').replace('\r','')
|
||||
start=source.index('ACMD(do_bio)\n');end=source.index('\n#endif',start)
|
||||
body=source[start:end]
|
||||
# Maintain the upstream algorithm verbatim. Adapter guards live outside this function.
|
||||
body=body.replace('ACMD(do_bio)', 'static ACMD(do_ava2_bio)')
|
||||
body=body.replace('split_argument(argument, vecArgs);','BioSplitArgument(argument, vecArgs);')
|
||||
notices={'562':'level','563':'material','564':'cooldown','565':'success','566':'failure','567':'stone','568':'reward','569':'next','570':'complete'}
|
||||
for key,name in notices.items():
|
||||
body=body.replace('CHAT_TYPE_INFO, "'+key+'"','CHAT_TYPE_COMMAND, "BioNotice '+name+'"')
|
||||
body=body.replace('CHAT_TYPE_INFO, "'+key+' I%d"','CHAT_TYPE_COMMAND, "BioNotice '+name+' %d"')
|
||||
body=body.replace('CHAT_TYPE_INFO, "'+key+' E%d:%d"','CHAT_TYPE_COMMAND, "BioNotice '+name+' %d %d"')
|
||||
body=body.replace('pointToApply(', 'BioPointIdentity(')
|
||||
# The level notice in upstream forgot its printf placeholder. Keep its level argument visible.
|
||||
body=body.replace('"BioNotice level"','"BioNotice level %d"')
|
||||
table='static const unsigned bio_data[][17] = {\n'+''.join(' {'+', '.join(map(str,row))+'},\n' for row in rows)+'};\nstatic const unsigned bio_max = 14;\n'
|
||||
generated='// Generated from AVA2 constants.cpp + cmd_general.cpp by import_ava2.py.\n'+table+body+'\n'
|
||||
output.mkdir(parents=True,exist_ok=True)
|
||||
(output/'ava2_biolog_core.h').write_text(generated)
|
||||
catalog=[]
|
||||
for i,row in enumerate(rows[1:],1):
|
||||
catalog.append(dict(index=i,level=row[0],material=row[1],count=row[2],cooldown=row[3],chance=row[4],stone=row[5],
|
||||
bonuses=[dict(point=row[j],label=NAMES[row[j]],value=row[j+1]) for j in (6,8,10,12) if row[j]],choose=bool(row[14]),enhancer=row[15],skip=row[16]))
|
||||
(output/'catalog.json').write_text(json.dumps(catalog,ensure_ascii=False,indent=2)+'\n')
|
||||
(output/'reference.json').write_text(json.dumps({name:hashlib.sha256((reference/name).read_bytes()).hexdigest() for name in ('constants.cpp','cmd_general.cpp','char.cpp')},indent=2)+'\n')
|
||||
return catalog
|
||||
|
||||
if __name__=='__main__':
|
||||
parser=argparse.ArgumentParser();parser.add_argument('reference',type=Path);parser.add_argument('output',type=Path)
|
||||
args=parser.parse_args();generate(args.reference,args.output)
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Activate AVA2 biology items and quarantine legacy research events (cores/db must be stopped).
|
||||
Original quest sources, role flags and unrelated item rows remain untouched.
|
||||
"""
|
||||
import json,shutil,sys
|
||||
from pathlib import Path
|
||||
server,assets,quest_stage,backup=map(Path,sys.argv[1:5])
|
||||
if backup.exists():raise SystemExit('use a fresh backup directory')
|
||||
backup.mkdir(parents=True)
|
||||
conf=server/'share/conf'
|
||||
for filename in ('item_proto.txt','item_names.txt'):
|
||||
shutil.copy2(conf/filename,backup/filename)
|
||||
items={int(line.split(b'\t')[0]):line for line in (assets/'items-server.tsv').read_bytes().splitlines()}
|
||||
proto=conf/'item_proto.txt';output=[]
|
||||
for line in proto.read_bytes().splitlines():
|
||||
key=line.split(b'\t',1)[0]
|
||||
if not key.isdigit() or int(key) not in items:output.append(line)
|
||||
output.extend(items[k] for k in sorted(items))
|
||||
proto.write_bytes(b'\n'.join(output)+b'\n')
|
||||
names=conf/'item_names.txt';output=[]
|
||||
for line in names.read_bytes().splitlines():
|
||||
key=line.split(b'\t',1)[0]
|
||||
if not key.isdigit() or int(key) not in items:output.append(line)
|
||||
output.extend(str(k).encode()+b'\t'+items[k].split(b'\t')[1] for k in sorted(items))
|
||||
names.write_bytes(b'\n'.join(output)+b'\n')
|
||||
quest=server/'share/locale/newcibn/quest';manifest=[]
|
||||
for file in sorted((quest/'object').rglob('*')):
|
||||
if file.is_file() and (file.name.startswith('collect_quest_lv') or file.name.startswith('collect_quest_reset') or file.name.startswith('xxx_collect_quest_lv')):
|
||||
relative=file.relative_to(quest);destination=backup/relative;destination.parent.mkdir(parents=True,exist_ok=True)
|
||||
shutil.move(str(file),str(destination));manifest.append(str(relative))
|
||||
# Reset item delegates to the same new UI, which validates persisted AVA2 bonus selections.
|
||||
for file in sorted((quest_stage/'object').rglob('*')):
|
||||
if file.is_file():
|
||||
destination=quest/file.relative_to(quest_stage);destination.parent.mkdir(parents=True,exist_ok=True)
|
||||
if destination.exists():
|
||||
prior=backup/'reset-objects'/file.relative_to(quest_stage);prior.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(destination,prior)
|
||||
shutil.copy2(file,destination)
|
||||
(backup/'legacy-objects.json').write_text(json.dumps(manifest,indent=2)+'\n')
|
||||
print('AVA2 items installed:',len(items),'legacy quest events quarantined:',len(manifest))
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage the exact AVA2 biology items/icons for the current 156-byte proto format.
|
||||
No whole AVA2 locale/protocol is imported. Outputs are a reproducible, small client patch pack.
|
||||
"""
|
||||
import argparse,json,shutil,subprocess
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parent
|
||||
NAMES={70028:'研究奖励重选券',300004:'榉木树枝',300005:'图吉木板',300006:'红鬼树枝',300007:'首领笔记',300008:'嫉妒宝石',300009:'智慧宝石',300010:'凤凰羽毛',300011:'红色单片镜',300012:'古老配方',30229:'智慧灵魂石',30230:'凤凰灵魂石',30231:'红镜灵魂石',30232:'古方灵魂石',30250:'研究冷却药剂',71035:'研究员精华'}
|
||||
|
||||
def prepare(proto,ava,locale,output,tool,packer):
|
||||
catalog=json.loads((HERE/'catalog.json').read_text());wanted={v for r in catalog for v in (r['material'],r['stone'],r['enhancer'],r['skip']) if v}|{70028}
|
||||
rows={}
|
||||
for line in proto.read_bytes().splitlines():
|
||||
cols=line.split(b'\t')
|
||||
if cols[0].isdigit() and int(cols[0]) in wanted: rows[int(cols[0])]=cols
|
||||
assert rows.keys()==wanted
|
||||
output.mkdir(parents=True,exist_ok=True)
|
||||
server=[];numeric=[]
|
||||
listrows={}
|
||||
for line in (ava/'locale/locale/es/item_list.txt').read_bytes().splitlines():
|
||||
c=line.split();
|
||||
if c and c[0].isdigit() and int(c[0]) in wanted:listrows[int(c[0])]=c
|
||||
assert listrows.keys()==wanted
|
||||
assets=output/'assets';(assets/'icon/item').mkdir(parents=True,exist_ok=True)
|
||||
# Chinese names for existing IDs come from the already reviewed current locale.
|
||||
names={}
|
||||
for filename in ('item_names_zh.txt','item_names_zh_overlay.txt'):
|
||||
path=HERE.parents[2]/'data/zh_40250'/filename
|
||||
for line in path.read_text().splitlines():
|
||||
c=line.split('\t',1)
|
||||
if len(c)==2 and c[0].isdigit():names[int(c[0])]=c[1]
|
||||
for v,c in sorted(rows.items()):
|
||||
original_name=c[1].decode('cp949','replace')
|
||||
name=NAMES.get(v,names.get(v,original_name))
|
||||
c[1]=name.encode('gbk');server.append(b'\t'.join(c))
|
||||
types={b'ITEM_NONE':0,b'ITEM_MATERIAL':5,b'ITEM_QUEST':18}
|
||||
flags={b'NONE':0,b'ITEM_STACKABLE':4,b'LOG':8192}
|
||||
antis={b'NONE':0,b'ANTI_DROP':128,b'ANTI_SELL':256,b'ANTI_GIVE':8192,b'ANTI_MYSHOP':65536}
|
||||
parse=lambda s,m:sum(m[x.strip()] for x in s.split(b'|'))
|
||||
assert all(c[i] in (b'0',b'',b'LIMIT_NONE',b'APPLY_NONE',b'NONE') for i in (12,14,15,16,17,18,19,20,21,22,23))
|
||||
numeric.append('%d\t%d\t0\t%d\t%d\t%d\t%d\t%d\t%s\t%s' % (v,types[c[2]],int(c[4]),parse(c[5],antis),parse(c[6],flags),int(c[9]),int(c[10]),'\t'.join(str(int(c[i] or b'0')) for i in range(24,30)),name))
|
||||
icon=listrows[v][2].decode('ascii');shutil.copy2(ava/'icon'/icon,assets/icon)
|
||||
(output/'items-server.tsv').write_bytes(b'\n'.join(server)+b'\n')
|
||||
(output/'items-client.tsv').write_bytes(('\n'.join(numeric)+'\n').encode('gbk'))
|
||||
target=assets/'locale/zh';target.mkdir(parents=True,exist_ok=True)
|
||||
subprocess.run([str(tool),str(locale/'item_proto'),str(output/'items-client.tsv'),str(target/'item_proto')],check=True)
|
||||
# Replace only the matching item_list/description rows; all other current entries stay byte-identical.
|
||||
for filename in ('item_list.txt','itemdesc.txt'):
|
||||
lines=(locale/filename).read_bytes().splitlines();result=[]
|
||||
for line in lines:
|
||||
key=line.split(b'\t',1)[0]
|
||||
if not key.isdigit() or int(key) not in wanted:result.append(line)
|
||||
for v in sorted(wanted):
|
||||
if filename=='item_list.txt':result.append(b'\t'.join(listrows[v]))
|
||||
else:
|
||||
name=NAMES.get(v,names.get(v,'研究材料')).encode('gbk')
|
||||
description=('重新选择一次已经领取的生物学家奖励。' if v==70028 else '提高本次研究成功率 50 个百分点。' if v==71035 else '跳过本次提交的等待时间;仅在冷却期间消耗。' if v==30250 else '用于生物学家研究。').encode('gbk')
|
||||
result.append(str(v).encode()+b'\t'+name+b'\t'+description)
|
||||
(target/filename).write_bytes(b'\n'.join(result)+b'\n')
|
||||
subprocess.run([str(packer),str(output/'biolog'),str(assets), ''],check=True)
|
||||
(output/'items.json').write_text(json.dumps({v:NAMES.get(v,names.get(v,'研究材料')) for v in sorted(wanted)},ensure_ascii=False,indent=2)+'\n')
|
||||
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('proto',type=Path);p.add_argument('ava',type=Path);p.add_argument('locale',type=Path);p.add_argument('output',type=Path);p.add_argument('tool',type=Path);p.add_argument('packer',type=Path)
|
||||
a=p.parse_args();prepare(a.proto,a.ava,a.locale,a.output,a.tool.resolve(),a.packer.resolve())
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""PORT missing AVA2 biology stats into unused points (no packet-size change).
|
||||
Existing non-biology monster bonuses keep the current server's combat rule.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
source=Path(sys.argv[1])
|
||||
|
||||
def edit(name, marker, replacement, tag):
|
||||
p=source/name;s=p.read_bytes()
|
||||
if tag.encode() not in s:
|
||||
if s.count(marker.encode())!=1:raise ValueError('source mismatch: '+name)
|
||||
p.write_bytes(s.replace(marker.encode(),replacement.encode()))
|
||||
edit('char.h','\tPOINT_MELEE_MAGIC_ATT_BONUS_PER = 132,',
|
||||
'\tPOINT_MELEE_MAGIC_ATT_BONUS_PER = 132,\n\t// PORT AVA2 biology points, within the existing 255-point packet.\n\tPOINT_ATTBONUS_STONE = 240,\n\tPOINT_ATTBONUS_BOSS = 241,\n\tPOINT_RESIST_HUMAN = 220,','PORT AVA2 biology points')
|
||||
edit('char.cpp','\t\tcase POINT_ATTBONUS_MONSTER:',
|
||||
'\t\t// PORT AVA2 biology points\n\t\tcase POINT_ATTBONUS_STONE:\n\t\tcase POINT_ATTBONUS_BOSS:\n\t\tcase POINT_RESIST_HUMAN:\n\t\tcase POINT_ATTBONUS_MONSTER:', 'PORT AVA2 biology points')
|
||||
p=source/'battle.cpp';s=p.read_bytes()
|
||||
if b'PORT AVA2 biology combat' not in s:
|
||||
start=s.index(b'int CalcAttBonus(');end=s.index(b'\nint ',start+1)
|
||||
body=s[start:end]
|
||||
body=body.replace(b'\tif (pkVictim->IsNPC())',b''' // PORT AVA2 biology combat: stone bonus precedes race modifiers, as upstream.
|
||||
if (pkVictim->IsStone())
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_STONE)) / 100;
|
||||
\tif (pkVictim->IsNPC())''',1)
|
||||
marker=b'\t\tiAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER)) / 100;'
|
||||
assert body.count(marker)==1
|
||||
body=body.replace(marker,b''' if (pkVictim->GetMobRank() >= MOB_RANK_BOSS && !pkVictim->IsStone())
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
|
||||
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
|
||||
if (pkVictim->GetMobRank() >= MOB_RANK_BOSS) {
|
||||
CAffect* research = pkAttacker->FindAffect(AFFECT_COLLECT, POINT_ATTBONUS_MONSTER);
|
||||
if (research) monsterBonus -= research->lApplyValue;
|
||||
}
|
||||
iAtk += (iAtk * monsterBonus) / 100;''')
|
||||
body=body.replace(b'\treturn iAtk;',b''' if (pkAttacker->IsNPC() && pkVictim->IsPC() && pkAttacker->IsRaceFlag(RACE_FLAG_HUMAN))
|
||||
iAtk -= (iAtk * 30 * pkVictim->GetPoint(POINT_RESIST_HUMAN)) / 10000;
|
||||
if (pkAttacker->IsPC() && pkVictim->IsPC())
|
||||
iAtk -= (iAtk * pkVictim->GetPoint(POINT_RESIST_HUMAN)) / 100;
|
||||
\treturn iAtk;''',1)
|
||||
s=s[:start]+body+s[end:]
|
||||
if b'#include "affect.h"' not in s:s=s.replace(b'#include "char.h"',b'#include "char.h"\n#include "affect.h"')
|
||||
p.write_bytes(s)
|
||||
@@ -0,0 +1,7 @@
|
||||
quest port_bio_reset begin
|
||||
state start begin
|
||||
when 70028.use begin
|
||||
cmdchat("bioreselect")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Install the two small command hooks in a server source tree, keeping byte encoding intact."""
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
source, stage = map(Path, sys.argv[1:3])
|
||||
here = Path(__file__).resolve().parent
|
||||
for filename, marker, insertion in (
|
||||
('cmd_general.cpp', b'#include "autohunt_pull.h"', b'\n#include "biolog_remote.h"'),
|
||||
('cmd.cpp', b'ACMD(do_server_bonuses);', b'\nACMD(do_port_biolog);'),
|
||||
):
|
||||
path = source / filename
|
||||
data = path.read_bytes()
|
||||
if insertion.strip() not in data:
|
||||
if data.count(marker) != 1:
|
||||
raise RuntimeError('source hook mismatch: ' + str(path))
|
||||
data = data.replace(marker, marker + insertion)
|
||||
if filename == 'cmd.cpp' and b'{ "biolog",' not in data:
|
||||
marker = b'\t{ "server_bonuses",'
|
||||
if data.count(marker) != 1:
|
||||
raise RuntimeError('command registry mismatch')
|
||||
data = data.replace(marker, b'\t{ "biolog", do_port_biolog, 0, POS_DEAD, GM_PLAYER },\n' + marker)
|
||||
if filename == 'cmd.cpp' and b'{ "bio",' not in data:
|
||||
marker = b'\t{ "biolog",'
|
||||
data = data.replace(marker, b'\t{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },\n' + marker)
|
||||
path.write_bytes(data)
|
||||
for name, root in [('biolog_remote.h', here), ('ava2_biolog_core.h', here), ('ava2_biolog_shop.h', here)]:
|
||||
shutil.copy2(root / name, source / name)
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"constants.cpp": "da80974ca68d9d6deead78c907ca3bf9fabad89a0a5da1d23126740bf13f14b2",
|
||||
"cmd_general.cpp": "b4fc1cfe43af6695e86777ac96a199ce128d27130e8172dd1c2110efec7d48de",
|
||||
"char.cpp": "e9af1478df9939a4a367f3a2bfeaf2096203962b1df7d1e4c69153e509550a5c"
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
[
|
||||
{
|
||||
"vnum": 30220,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 5000000
|
||||
},
|
||||
{
|
||||
"vnum": 30221,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 7000000
|
||||
},
|
||||
{
|
||||
"vnum": 30222,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 10000000
|
||||
},
|
||||
{
|
||||
"vnum": 30223,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 13000000
|
||||
},
|
||||
{
|
||||
"vnum": 30224,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 20000000
|
||||
},
|
||||
{
|
||||
"vnum": 30225,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 25000000
|
||||
},
|
||||
{
|
||||
"vnum": 30226,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 50000000
|
||||
},
|
||||
{
|
||||
"vnum": 30227,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 100000000
|
||||
},
|
||||
{
|
||||
"vnum": 30228,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 200000000
|
||||
},
|
||||
{
|
||||
"vnum": 30229,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 200000000
|
||||
},
|
||||
{
|
||||
"vnum": 30230,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 500000000
|
||||
},
|
||||
{
|
||||
"vnum": 30231,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 500000000
|
||||
},
|
||||
{
|
||||
"vnum": 30232,
|
||||
"count": 1,
|
||||
"cost": 0,
|
||||
"amount": 0,
|
||||
"gold": 500000000
|
||||
},
|
||||
{
|
||||
"vnum": 300004,
|
||||
"count": 1,
|
||||
"cost": 30091,
|
||||
"amount": 5,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300005,
|
||||
"count": 1,
|
||||
"cost": 30197,
|
||||
"amount": 3,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300006,
|
||||
"count": 1,
|
||||
"cost": 30198,
|
||||
"amount": 2,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300007,
|
||||
"count": 1,
|
||||
"cost": 30196,
|
||||
"amount": 2,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300008,
|
||||
"count": 1,
|
||||
"cost": 70031,
|
||||
"amount": 3,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300009,
|
||||
"count": 1,
|
||||
"cost": 70031,
|
||||
"amount": 5,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300010,
|
||||
"count": 1,
|
||||
"cost": 30520,
|
||||
"amount": 7,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300011,
|
||||
"count": 1,
|
||||
"cost": 30521,
|
||||
"amount": 7,
|
||||
"gold": 0
|
||||
},
|
||||
{
|
||||
"vnum": 300012,
|
||||
"count": 1,
|
||||
"cost": 30518,
|
||||
"amount": 7,
|
||||
"gold": 0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,103 @@
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include "questpc.h"
|
||||
#include "item.h"
|
||||
// PORT point numbers are intentionally not AVA2 protocol numbers; effects are compared by named point.
|
||||
POINT_ENUMS
|
||||
typedef unsigned char BYTE;
|
||||
template<class T>void str_to_number(T& result,const char* value){result=std::atoi(value);}
|
||||
static int roll=1;
|
||||
static int get_global_time(){return 1000;}
|
||||
static int number(int,int){return roll;}
|
||||
enum { CHAT_TYPE_COMMAND=5,CHAT_TYPE_INFO=1,AFFECT_COLLECT=515,AFF_NONE=0,INFINITE_AFFECT_DURATION=1892160000 };
|
||||
struct CAffect {unsigned point;int lApplyValue;};
|
||||
struct Character {
|
||||
int level=105,gold=1000000000;
|
||||
bool blocked=false;
|
||||
std::map<std::string,int> flags;
|
||||
std::map<unsigned,int> items;
|
||||
std::map<unsigned,CAffect> effects;
|
||||
std::vector<std::string> replies;
|
||||
unsigned GetPlayerID(){return 123;}
|
||||
int GetLevel(){return level;}
|
||||
int GetGold(){return gold;}
|
||||
int GetQuestFlag(const std::string& s){auto i=flags.find(s);return i==flags.end()?0:i->second;}
|
||||
void SetQuestFlag(const std::string& s,int n){if(n)flags[s]=n;else flags.erase(s);}
|
||||
int CountSpecifyItem(unsigned id){auto i=items.find(id);return i==items.end()?0:i->second;}
|
||||
void RemoveSpecifyItem(unsigned id,int n){assert(CountSpecifyItem(id)>=n);items[id]-=n;}
|
||||
CAffect* FindAffect(int,unsigned point){auto i=effects.find(point);return i==effects.end()?nullptr:&i->second;}
|
||||
void RemoveAffect(CAffect* a){effects.erase(a->point);}
|
||||
void AddAffect(int,unsigned point,int n,int,int,int,bool){effects[point]={point,n};}
|
||||
void PointChange(int,int n,bool){gold+=n;}
|
||||
LPITEM AutoGiveItem(unsigned id,unsigned count,int,bool){items[id]+=count;static FakeItem item;return &item;}
|
||||
bool CanHandleItem(){return !blocked;}
|
||||
bool IsDead(){return false;}bool IsStun(){return false;}bool IsWarping(){return false;}
|
||||
bool GetExchange(){return false;}bool GetShop(){return false;}bool GetMyShop(){return false;}
|
||||
bool IsOpenSafebox(){return false;}bool IsCubeOpen(){return false;}
|
||||
void ChatPacket(int,const char* format,...){char b[1024];va_list ap;va_start(ap,format);vsnprintf(b,sizeof(b),format,ap);va_end(ap);replies.push_back(b);}
|
||||
std::string Snapshot()const{
|
||||
std::string s=std::to_string(gold);
|
||||
for(const auto& p:flags)s+="|"+p.first+":"+std::to_string(p.second);
|
||||
for(const auto& p:items)s+="|item"+std::to_string(p.first)+":"+std::to_string(p.second);
|
||||
for(const auto& p:effects)s+="|point"+std::to_string(p.first)+":"+std::to_string(p.second.lApplyValue);
|
||||
return s;
|
||||
}
|
||||
};
|
||||
typedef Character* LPCHARACTER;
|
||||
#define ACMD(name) void name(Character* ch,const char* argument,int cmd,int subcmd)
|
||||
#include "../biolog_remote.h"
|
||||
#define split_argument BioSplitArgument
|
||||
static unsigned pointToApply(unsigned value){return value;}
|
||||
REFERENCE_COMMAND
|
||||
int main(){
|
||||
int cases=0;
|
||||
for(unsigned stage=1;stage<bio_max;++stage) {
|
||||
for(unsigned count:{0U,bio_data[stage][2]-1,bio_data[stage][2],bio_data[stage][2]+1})
|
||||
for(int material:{0,2})for(int stone:{0,2})for(int cooldown:{0,2000})
|
||||
for(int enhance:{0,1})for(int skip:{0,1})for(int random:{1,60,61,100}) {
|
||||
Character expected,actual;expected.flags={{"bio.level",int(stage)},{"bio.count",int(count)},{"bio.time",cooldown}};
|
||||
expected.items={{bio_data[stage][1],material},{bio_data[stage][5],stone},{71035,2},{30250,2}};
|
||||
// Preserve accumulation across different stages sharing the same reward point.
|
||||
expected.effects[bio_data[stage][6]]={bio_data[stage][6],17};actual=expected;roll=random;
|
||||
std::string command=" mission "+std::to_string(enhance)+" "+std::to_string(skip);
|
||||
reference_do_bio(&expected,command.c_str(),0,0);
|
||||
do_port_biolog(&actual,command.c_str(),0,0);
|
||||
assert(expected.Snapshot()==actual.Snapshot());++cases;
|
||||
}
|
||||
if(bio_data[stage][14])for(unsigned choice=0;choice<4;++choice)if(bio_data[stage][6+choice*2]) {
|
||||
Character expected,actual;expected.flags={{"bio.level",int(stage)},{"bio.count",int(bio_data[stage][2]+1)}};
|
||||
expected.effects[bio_data[stage][6+choice*2]]={bio_data[stage][6+choice*2],23};actual=expected;
|
||||
std::string command=" gift "+std::to_string(choice);
|
||||
reference_do_bio(&expected,command.c_str(),0,0);do_port_biolog(&actual,command.c_str(),0,0);
|
||||
assert(expected.Snapshot()==actual.Snapshot());++cases;
|
||||
std::string awarded=actual.Snapshot();do_port_biolog(&actual,command.c_str(),0,0);assert(actual.Snapshot()==awarded);
|
||||
}
|
||||
}
|
||||
Character invalid;invalid.flags={{"bio.level",4},{"bio.count",21}};
|
||||
for(const char* command:{"mission 256 0","mission -1 0","gift 3","gift -1","gift 256","gift 1 extra"}) {
|
||||
std::string before=invalid.Snapshot();do_port_biolog(&invalid,command,0,0);assert(invalid.Snapshot()==before);
|
||||
}
|
||||
Character fresh;SendBioState(&fresh);assert(fresh.GetQuestFlag("bio.level")==1);
|
||||
Character completed;completed.flags={{"bio.level",14},{"bio.bonus13",2}};
|
||||
SendBioState(&completed);assert(completed.replies.back().find("biobonuses")==0 && completed.replies.back().back()=='2');
|
||||
for(unsigned i=0;i<sizeof(kBioShop)/sizeof(kBioShop[0]);++i) {
|
||||
Character buyer;auto offer=kBioShop[i];buyer.items[offer.cost]=offer.amount;
|
||||
int gold=buyer.gold;assert(BioShopBuy(&buyer,i));assert(buyer.CountSpecifyItem(offer.vnum)==int(offer.count));
|
||||
if(offer.cost)assert(buyer.CountSpecifyItem(offer.cost)==0);else assert(buyer.gold==gold-int(offer.gold));
|
||||
}
|
||||
// Reward reselection transfers only the selected stage's value and charges exactly one note.
|
||||
Character reset;reset.flags={{"bio.level",14},{"bio.bonus9",1}};reset.items[70028]=2;
|
||||
reset.effects[POINT_MAX_HP]={POINT_MAX_HP,2200};
|
||||
BioResetBonus(&reset,9,1);assert(reset.GetQuestFlag("bio.bonus9")==2);
|
||||
assert(reset.effects[POINT_MAX_HP].lApplyValue==1000);
|
||||
assert(reset.effects[POINT_DEF_GRADE_BONUS].lApplyValue==120 && reset.CountSpecifyItem(70028)==1);
|
||||
BioResetBonus(&reset,9,1);assert(reset.CountSpecifyItem(70028)==1);
|
||||
std::printf("PASS: %d AVA2 differential scenarios; invalid requests, repeat rewards, 22 shop offers and reselection\n",cases);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
struct FakeItem {};
|
||||
typedef FakeItem* LPITEM;
|
||||
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
struct ITEM_MANAGER { static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;} template<class T>void FlushDelayedSave(T*){} };
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
// Small test double for the PORT command's interaction with the existing quest engine.
|
||||
#include <map>
|
||||
#include <string>
|
||||
namespace quest {
|
||||
struct PC {
|
||||
std::map<std::string, int> flags;
|
||||
bool running = false, loaded = true;
|
||||
int GetFlag(const std::string& key) { return flags[key]; }
|
||||
void SetFlag(const std::string& key, int value, bool = false) { flags[key] = value; }
|
||||
bool IsRunning() const { return running; }
|
||||
bool IsLoaded() const { return loaded; }
|
||||
};
|
||||
struct CQuestManager {
|
||||
PC pc;
|
||||
int dispatched = 0;
|
||||
bool available = true;
|
||||
static CQuestManager& instance() { static CQuestManager manager; return manager; }
|
||||
PC* GetPCForce(unsigned) { return &pc; }
|
||||
unsigned GetQuestIndexByName(const std::string&) { return available ? 1 : 0; }
|
||||
void QuestButton(unsigned, unsigned) { ++dispatched; pc.running = true; }
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
import importlib.util,json,re,subprocess,sys,tempfile
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
reference=Path(sys.argv[1]);template=ROOT/'tests/ava2_core_test.cpp'
|
||||
# Compare the generated 13-stage table with both upstream server and Python UI tables.
|
||||
spec=importlib.util.spec_from_file_location('import_ava2',ROOT/'import_ava2.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
|
||||
rows=module.extract(reference);catalog=json.loads((ROOT/'catalog.json').read_text())
|
||||
assert len(rows)==14 and len(catalog)==13
|
||||
for row,c in zip(rows[1:],catalog):
|
||||
assert row[:6]==[c['level'],c['material'],c['count'],c['cooldown'],c['chance'],c['stone']]
|
||||
ui=ROOT.parents[2]/'src/platform/ScriptLib/BiologScript.inc';source=ui.read_text();data=re.search(r'^CATALOG = (.*)$',source,re.M).group(1)
|
||||
import ast
|
||||
assert ast.literal_eval(data)=={c['index']:c for c in catalog}
|
||||
points=sorted({v for row in rows for v in row if isinstance(v,str)})
|
||||
raw=(reference/'cmd_general.cpp').read_bytes().decode('latin1').replace('\r','');start=raw.index('ACMD(do_bio)\n');end=raw.index('\n#endif',start)
|
||||
original=raw[start:end].replace('ACMD(do_bio)','static ACMD(reference_do_bio)')
|
||||
code=template.read_text().replace('POINT_ENUMS','enum {'+', '.join([points[0]+'=1']+points[1:]+['POINT_GOLD'])+'};').replace('REFERENCE_COMMAND',original)
|
||||
with tempfile.TemporaryDirectory(prefix='biolog-ava2-') as folder:
|
||||
folder=Path(folder);cpp=folder/'test.cpp';cpp.write_text(code)
|
||||
# Keep relative production include paths resolvable when compiling the generated source.
|
||||
cpp.write_text(cpp.read_text().replace('#include "../biolog_remote.h"','#include "'+str(ROOT/'biolog_remote.h')+'"'))
|
||||
subprocess.run(['c++','-std=c++17','-I'+str(ROOT/'tests'),str(cpp),'-o',str(folder/'test')],check=True)
|
||||
subprocess.run([str(folder/'test')],check=True)
|
||||
print('PASS: 13-stage catalog and embedded client table match extracted AVA2 server constants')
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile the actual patched CalcAttBonus and assert the biology bonuses in real arithmetic."""
|
||||
from pathlib import Path
|
||||
import re,subprocess,sys,tempfile
|
||||
source=Path(sys.argv[1]).read_bytes().decode('latin1');start=source.index('int CalcAttBonus(');end=source.index('\nvoid Item_GetDamage',start);body=source[start:end]
|
||||
assert 'PORT AVA2 biology combat' in body
|
||||
names=sorted(set(re.findall(r'\b(?:POINT_|RACE_FLAG_|JOB_|UNIQUE_ITEM_)[A-Z_0-9]+',body)))
|
||||
code=r'''
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
NAMES
|
||||
enum {MOB_RANK_BOSS=4,AFFECT_COLLECT=515};
|
||||
struct CAffect {int lApplyValue;};
|
||||
struct Character {
|
||||
bool pc=true,stone=false;int rank=1,job=-1;
|
||||
std::map<int,int> points;std::set<int> races;CAffect research{0};
|
||||
bool IsPC(){return pc;}bool IsNPC(){return !pc;}bool IsStone(){return stone;}
|
||||
int GetPoint(int n){return points[n];}int GetJob(){return job;}int GetMobRank(){return rank;}
|
||||
int GetMarriageBonus(int){return 0;}bool IsRaceFlag(int n){return races.count(n);}
|
||||
CAffect* FindAffect(int,int){return research.lApplyValue?&research:nullptr;}
|
||||
};
|
||||
struct CHARACTER_MANAGER {
|
||||
static CHARACTER_MANAGER& instance(){static CHARACTER_MANAGER m;return m;}
|
||||
int GetMobDamageRate(Character*){return 100;}
|
||||
};
|
||||
typedef Character* LPCHARACTER;
|
||||
BODY
|
||||
int main(){
|
||||
Character attacker,victim;victim.pc=false;victim.stone=true;
|
||||
attacker.points[POINT_ATTBONUS_STONE]=10;
|
||||
assert(CalcAttBonus(&attacker,&victim,1000)==1100);
|
||||
victim.stone=false;victim.rank=MOB_RANK_BOSS;attacker.points.clear();attacker.points[POINT_ATTBONUS_BOSS]=6;
|
||||
assert(CalcAttBonus(&attacker,&victim,1000)==1060);
|
||||
// AVA2's research monster bonus excludes bosses; unrelated existing equipment still applies.
|
||||
attacker.points.clear();attacker.points[POINT_ATTBONUS_MONSTER]=15;attacker.research.lApplyValue=5;
|
||||
assert(CalcAttBonus(&attacker,&victim,1000)==1100);
|
||||
victim.rank=1;assert(CalcAttBonus(&attacker,&victim,1000)==1150);
|
||||
attacker.points.clear();attacker.research.lApplyValue=0;victim.pc=true;victim.points[POINT_RESIST_HUMAN]=10;
|
||||
assert(CalcAttBonus(&attacker,&victim,1000)==900);
|
||||
attacker.pc=false;attacker.races.insert(RACE_FLAG_HUMAN);
|
||||
assert(CalcAttBonus(&attacker,&victim,1000)==970);
|
||||
attacker.races.clear();assert(CalcAttBonus(&attacker,&victim,1000)==1000);
|
||||
std::puts("PASS: patched combat applies stone/boss bonuses, excludes research monster bonus on bosses, and applies PvP/NPC human resistance");
|
||||
}
|
||||
'''
|
||||
code=code.replace('NAMES','enum {'+', '.join([names[0]+'=1']+names[1:])+'};').replace('BODY',body)
|
||||
with tempfile.TemporaryDirectory(prefix='bio-combat-') as folder:
|
||||
folder=Path(folder);(folder/'test.cpp').write_text(code)
|
||||
subprocess.run(['c++','-std=c++17',str(folder/'test.cpp'),'-o',str(folder/'test')],check=True)
|
||||
subprocess.run([str(folder/'test')],check=True)
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
| 目录 | 商店 | NPC | 位置 |
|
||||
|---|---|---|---|
|
||||
| `item-mall/` | 14 / 16 `item_mall`(两页:增益、道具) | 9010 百店老板娘 | 杂货店 9003 旁 |
|
||||
| `item-mall/` | 14 / 16 `item_mall`(三页:增益、道具、宝石) | 9010 百店老板娘 | 杂货店 9003 旁 |
|
||||
| `mount/` | 15 `mount` | 20368 坐骑商人(原「铁算盘」,未使用的货郎模型) | 马夫 20349 旁 |
|
||||
|
||||
`install.sh` 对一个商店做这些事:
|
||||
@@ -42,6 +42,8 @@
|
||||
| 双倍伤害丸、无视防御丸 | 各 15 万 |
|
||||
| 经验药水、夺宝手套 | 各 20 万 |
|
||||
| 物品属性转换秘籍 | 50 万 |
|
||||
| 超级属性转换秘籍、超级属性追加秘籍 | 各 1 |
|
||||
| +6 镶嵌石(28700~28713,全部 14 种,宝石页) | 各 1 |
|
||||
| 移动戒指(不限次数、无冷却,见 `../ring-warp`) | 1 |
|
||||
| 追加物品属性秘籍、龙神的祝福书 | 各 100 万 |
|
||||
|
||||
@@ -89,3 +91,7 @@ mysql -uroot player < $B/player-shop.sql
|
||||
|
||||
- 商城:`/root/backup-itemmall/20260929-162714`。这份还没备份 mob_proto;9010 原来的 on_click 是 2。
|
||||
- 坐骑:`/root/backup-npcshop/mount-20260929-172630`。更早的 mount 备份里还没有 mob_names.txt;20368 原名是 Peddler。
|
||||
|
||||
## +6 石头与红国位置修复(2026-10-02)
|
||||
|
||||
`item-mall/stones.tsv` 来自 server_extracted 的 28700~28713 实际数值。203 原来的同编号为空类型,安装时以对应普通石头行恢复标志与镶嵌族,再写入 +6 数值;客户端同步表为 `data/zh_40250/item_stones_server.tsv`。红国老板娘改为本地坐标 678,575(杂货店前方),重复安装会更新已有 NPC 的坐标。
|
||||
|
||||
@@ -35,6 +35,33 @@ echo "$VILLAGES" | while read -r map x y dir; do cp -p "$MAPS/$map/npc.txt" "$BA
|
||||
mysqldump -uroot player shop shop_item item_proto mob_proto > "$BACKUP/player-shop.sql"
|
||||
echo "backup: $BACKUP"
|
||||
|
||||
# Optional stone restoration: reuse the corresponding valid +3 row for flags and
|
||||
# socket family, then apply the extracted +6 values. Preserve its existing name.
|
||||
if [ -f "$SHOP_DIR/stones.tsv" ]; then
|
||||
awk -F'\t' -v OFS='\t' '
|
||||
NR==FNR {if ($1 !~ /^#/ && NF==12) {wanted[$1]=$6; count++} next}
|
||||
{line[NR]=$0; order[++n]=$1; original[$1]=$0}
|
||||
END {
|
||||
for (i=1;i<=n;i++) {
|
||||
v=order[i]
|
||||
if (v in wanted) {
|
||||
split(original[v], old, "\t")
|
||||
base=28330+v-28700
|
||||
if (!(base in original)) exit 1
|
||||
split(original[base], a, "\t")
|
||||
a[1]=v; a[2]=old[2]; a[10]=1; a[11]=0; a[20]=wanted[v]
|
||||
for (j=1;j<=33;j++) printf "%s%s",a[j],(j==33 ? "\n" : OFS)
|
||||
found++
|
||||
} else print original[v]
|
||||
}
|
||||
if (found!=count || count!=14) exit 1
|
||||
}' "$SHOP_DIR/stones.tsv" "$PROTO" > "$BACKUP/stones.new"
|
||||
cat "$BACKUP/stones.new" > "$PROTO"
|
||||
awk -F'\t' '$1 !~ /^#/ && NF==12 {
|
||||
printf "UPDATE item_proto SET type=%d,subtype=%d,wearflag=%d,applytype0=%d,applyvalue0=%d,applytype1=0,applyvalue1=0,applytype2=0,applyvalue2=0,value0=%d,value1=%d,value2=%d,value3=%d,value4=%d,value5=%d,shop_buy_price=0 WHERE vnum=%d;\n",$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$1
|
||||
}' "$SHOP_DIR/stones.tsv" | mysql -uroot player
|
||||
fi
|
||||
|
||||
# item_proto.txt column 10 is the price an NPC shop sells the item for (TItemTable::dwGold).
|
||||
awk -F'\t' -v OFS='\t' 'NR == FNR { if ($1 !~ /^#/ && NF >= 3) { price[$1] = $3; want++ } next }
|
||||
($1 in price) { $10 = price[$1]; n++ } { print }
|
||||
@@ -105,7 +132,9 @@ fi
|
||||
echo "$VILLAGES" | while read -r map x y dir; do
|
||||
npc="$MAPS/$map/npc.txt"
|
||||
if awk -F'\t' -v v=$NPC_VNUM '$11 == v { found = 1 } END { exit !found }' "$npc"; then
|
||||
echo "$map: NPC $NPC_VNUM already placed"
|
||||
awk -F'\t' -v OFS='\t' -v v=$NPC_VNUM -v x="$x" -v y="$y" -v dir="$dir" '$11==v {$2=x; $3=y; $7=dir} {print}' "$npc" > "$BACKUP/$map.npc.new"
|
||||
cat "$BACKUP/$map.npc.new" > "$npc"
|
||||
echo "$map: NPC $NPC_VNUM positioned at $x,$y"
|
||||
else
|
||||
[ -z "$(tail -c 1 "$npc")" ] || echo >> "$npc"
|
||||
printf 'm\t%d\t%d\t0\t0\t0\t%d\t1m\t100\t1\t%d\n' "$x" "$y" "$dir" "$NPC_VNUM" >> "$npc"
|
||||
|
||||
@@ -43,3 +43,20 @@
|
||||
71032 1 1000000 龙神的祝福书
|
||||
70058 1 1 移动戒指 不限次数、无冷却(../../ring-warp)
|
||||
50307 1 0 小狩猎套装礼包 1级+9全套、满属性(../../hunt-set)
|
||||
71052 1 1 超级属性转换秘籍
|
||||
71051 1 1 超级属性追加秘籍
|
||||
[宝石]
|
||||
28700 1 1 鸡血石+6
|
||||
28701 1 1 羊脂玉+6
|
||||
28702 1 1 羚角石+6
|
||||
28703 1 1 虹河石+6
|
||||
28704 1 1 青胆石+6
|
||||
28705 1 1 精石+6
|
||||
28706 1 1 鹰翼石+6
|
||||
28707 1 1 木鱼石+6
|
||||
28708 1 1 龙骨石+6
|
||||
28709 1 1 青石+6
|
||||
28710 1 1 彩芒石+6
|
||||
28711 1 1 鹿影石+6
|
||||
28712 1 1 东海石+6
|
||||
28713 1 1 帝王石+6
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
SHOP_VNUM=14
|
||||
SHOP_NAME=item_mall
|
||||
NPC_VNUM=9010
|
||||
VILLAGES="metin2_map_a1 686 565 8
|
||||
VILLAGES="metin2_map_a1 678 575 8
|
||||
metin2_map_b1 598 689 4
|
||||
metin2_map_c1 391 693 5"
|
||||
# Shop vnum of each page after the first (items.tsv has [tab] lines, so this is a shop_table_ex.txt shop).
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# vnum type subtype wear apply_type apply_value value0 value1 value2 value3 value4 value5
|
||||
28700 10 0 16 16 25 0 0 0 0 0 17
|
||||
28701 10 0 16 15 25 0 0 0 0 0 18
|
||||
28702 10 0 16 9 50 0 0 0 0 0 19
|
||||
28703 10 0 16 59 55 0 0 0 0 0 20
|
||||
28704 10 0 16 60 55 0 0 0 0 0 21
|
||||
28705 10 0 16 61 55 0 0 0 0 0 22
|
||||
28706 10 0 16 62 55 0 0 0 0 0 23
|
||||
28707 10 0 16 63 25 0 0 0 0 0 24
|
||||
28708 10 0 1 27 25 0 0 0 0 0 25
|
||||
28709 10 0 1 28 25 0 0 0 0 0 26
|
||||
28710 10 0 1 2 1000 0 0 0 0 0 27
|
||||
28711 10 0 1 1 2000 0 0 0 0 0 28
|
||||
28712 10 0 1 54 500 0 0 0 0 0 29
|
||||
28713 10 0 1 8 50 0 0 0 0 0 30
|
||||
|
Reference in New Issue
Block a user