Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b8cc3069f | ||
|
|
bce34954d9 | ||
|
|
71c299c98f | ||
|
|
2048808c75 | ||
|
|
ff6163a685 | ||
|
|
0b9c2bb6b0 | ||
|
|
ac4a05a0c3 | ||
|
|
d7d0de3ae9 | ||
|
|
b625ba5695 | ||
|
|
e097b927de | ||
|
|
c9268424ab | ||
|
|
3c0141d639 | ||
|
|
3222614dd2 | ||
|
|
972c200cd0 | ||
|
|
a28393b16b | ||
|
|
c6813cd653 | ||
|
|
22228857ff | ||
|
|
e313d9ea85 | ||
|
|
f09ffd8a35 | ||
|
|
6199b2cbff | ||
|
|
fb066e7046 | ||
|
|
c30258ef5e | ||
|
|
14c4491469 | ||
|
|
5ad07886ea | ||
|
|
89261fdf8a | ||
|
|
38b62cfdbd | ||
|
|
cd395c73b7 | ||
|
|
7f4e8b3f76 | ||
|
|
1bdaae8807 | ||
|
|
69e335ba9c | ||
|
|
3590a06946 | ||
|
|
06b96c62d1 | ||
|
|
bc32475742 | ||
|
|
4b4f32ed58 | ||
|
|
bcd318791e |
+17
-12
@@ -1,6 +1,6 @@
|
||||
# PORT attribute lock
|
||||
|
||||
AVA2 `ENABLE_LOCK_ATTR`, rebuilt for this server's item layout. Up to two of the five normal attribute slots keep their type and value when the item is rerolled. Source: `src/server/game/src/port_attr_lock.{h,cpp}`, `CItem::ChangeAttribute` / `CopyAttributeTo` (item_attribute.cpp), the cache fields in item.h/item.cpp, the boot hook in main.cpp, and the `lock` verb of `mt_switchbot` (port_switchbot.h).
|
||||
AVA2 `ENABLE_LOCK_ATTR`, rebuilt for this server's item layout. Up to two of the five normal attribute slots keep their type and value when the item is rerolled. Source: `src/server/game/src/port_attr_lock.{h,cpp}`, `CItem::ChangeAttribute` / `CopyAttributeTo` (item_attribute.cpp), the cache fields in item.h/item.cpp, and the boot hook in main.cpp. The `lock` verb of the v1 `mt_switchbot` command was removed with the AVA2 switchbot port (FEATURE-SWITCHBOT.md). Locks are now set only by using 50348 (lock) / 50349 (unlock) on the item. `UseItemEx` passes the material to `PortAttrLockUse`, which reads the 1-based slot from the material's socket 0 and consumes one material on success.
|
||||
|
||||
## Storage
|
||||
|
||||
@@ -24,7 +24,6 @@ CREATE TABLE IF NOT EXISTS mt_item_attr_lock (item_id INT UNSIGNED NOT NULL PRIM
|
||||
|
||||
- Only the five normal slots can be locked; the rare slots 5/6 are not affected. The item must sit in the inventory, not be equipped or in an exchange, not be a costume, and have an attribute set. The slot must hold an attribute.
|
||||
- At most 2 lock groups, and at least one filled slot must stay unlocked. On items with an addon type (`sAddonType`, weapons whose slots 0/1 are the skill / normal hit bonus pair), slots 0 and 1 lock and unlock together and count as one group.
|
||||
- The bot's own item cannot be locked or unlocked while the bot is rolling it (`running`).
|
||||
- Locking is free. AVA2 consumes 50348/50349 per lock or unlock; those vnums do not exist in 203 `item_proto`.
|
||||
- `CItem::ChangeAttribute` (scroll rerolls, the switchbot, the GM command):
|
||||
1. take the effective mask: stored mask ∩ filled slots, with the addon pair kept whole;
|
||||
@@ -36,15 +35,9 @@ CREATE TABLE IF NOT EXISTS mt_item_attr_lock (item_id INT UNSIGNED NOT NULL PRIM
|
||||
With no lock, the effective mask is 0 and the sequence equals the original. The attribute count is kept, and the rare slots are untouched.
|
||||
- Adding an attribute (71085) and rare-attribute scrolls do not look at the lock.
|
||||
|
||||
## Protocol (part of mt_switchbot v1)
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_switchbot 1 lock CELL SLOT toggle the lock on normal slot SLOT (0..4)
|
||||
MTSB1 lock CELL VNUM MASK effective mask; also sent after every attrs_end
|
||||
MTSB1 error lock CODE item equipped no_attr busy running slot max db rate invalid
|
||||
```
|
||||
|
||||
`slot` means out of range or empty. `max` means a third group, or every filled slot locked. `db` means the write failed. Older servers never send a `lock` line, so the client shows no lock buttons there.
|
||||
No dedicated packet. The v1 `/mt_switchbot 1 lock CELL SLOT` / `MTSB1 lock` lines were removed together with that command. What remains is the item-use path above. AVA2's UI for picking the slot and showing the lock in the tooltip is still open (metin2-client docs/AVA2-PARITY-PLAN.md).
|
||||
|
||||
## Verification
|
||||
|
||||
@@ -58,7 +51,7 @@ MTSB1 error lock CODE item equipped no_attr busy running slot max
|
||||
- there is no DB lookup when there are no attributes;
|
||||
- every toggle, effective-mask and group-count rule holds.
|
||||
- It also checks the boot hook, the Makefile, the cache initialisation and that `CopyAttributeTo` copies the lock.
|
||||
- `tests/features/test_switchbot.py` covers the `lock` verb (toggle, `slot`, `max`, `db`, `running`, `no_attr`, `item`, `invalid`, the addon pair) and the lock line after `attrs_end`.
|
||||
- `tests/features/test_switchbot.py` checks that the v1 command (and with it the `lock` verb) is gone.
|
||||
- FreeBSD: full rebuild of game in `/root/metin2-features-dev` (log `attrlock-build.log`; `item.h` changed, so every .cpp was touched).
|
||||
- Live on 2026-10-15, channel-5 test core (13040) with the isolated binary, macOS client, [SA]Admin, armour 11209 (item 20000178, 5 attributes), scroll 71084:
|
||||
- the first boot created the table;
|
||||
@@ -68,4 +61,16 @@ MTSB1 error lock CODE item equipped no_attr busy running slot max
|
||||
- a new client session showed `lock 19 11209 10` (reloaded from the table);
|
||||
- unlocking → 8 → 0, and the row was deleted;
|
||||
- `log` has four `ATTR_LOCK` rows (hints 2, 10, 8, 0).
|
||||
- Not done: Android device test and production deploy.
|
||||
- Not done: Android device test.
|
||||
|
||||
## Production deployment
|
||||
|
||||
- 2026-10-15 16:08, approved by the user. All 203 live cores now run main `dc71593` (`game` sha256 `a8556bdc…`, the exact binary the channel-5 core was tested with, built in `/root/metin2-features-dev`). The db binary is unchanged. 0 players were online.
|
||||
- Package `/root/deploy-features/20261015-attrlock` (`deploy.sh check|go|rollback`, `SHA256SUMS`). The previous `game`/`db` (boss deploy, `400e44f`) are in `/root/backup-bin/20261015-160813`. The 8 changed files were synced into `/usr/metin2/src`, and the replaced ones are in `src-before/`. Because `item.h` changed, a later `rebuild.sh build` must touch every game .cpp. `sh deploy.sh rollback` restores both; the `mt_item_attr_lock` table can stay, since old binaries ignore it.
|
||||
- CH2–CH4 and the channel-5 core were started by hand after `start.sh 1`, giving 14 game cores plus db and auth.
|
||||
- Live acceptance on CH1 (13000), same armour 11209 (item 20000178), scroll 71084:
|
||||
- lock slot 1 → 2, slot 3 → 10, slot 0 → `error lock max`;
|
||||
- 10 switchbot rolls (scrolls 133 → 123): (23,10) and (39,10) unchanged on every roll, the other slots changed;
|
||||
- the row read `20000178 10`; a new session showed `lock 19 11209 10`;
|
||||
- unlocking → 8 → 0 deleted the row, and four new `ATTR_LOCK` log rows were written;
|
||||
- no `PortAttrLock` syserr entries.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# AVA2 属性锁定选择与展示
|
||||
|
||||
2026-10-18;仅 sbtest,game SHA256 `a324f3d0646ce8e8579c34237bbdc54855be2d5578f54476a27005f0af364765`。正式服未变更。
|
||||
|
||||
补齐 AVA2 char_item.cpp 的材料使用契约:无目标使用 50348/50349 进入选择 quest,socket 0 保存1~5;拖放时锁定或解锁。选择返回按 ID 重新解析物品,校验所有者、库存与交易/角色状态。选择不扣材料,锁定只有持久保存成功才扣一张;数据库读取失败拒绝覆盖已有状态。处理放在时装/护符专用分支之前。独立 mt_item_attr_lock 表及现有 ChangeAttribute 保留算法继续使用。
|
||||
|
||||
`/attr_lock_info TOKEN WINDOW CELL` 只读查询自己的背包、装备或洗练槽(每秒限频),含请求序号和 vnum 的响应让客户端拒绝过时提示;SQL 错误发未知掩码而非未锁定。
|
||||
|
||||
两种材料原型从 AVA2 客户端 DumpProto 读取并只合并两行;归档没有材料的选择 quest,中文 attr_lock.quest 根据 C++ 契约补齐。安装器和详细验证见客户端 tools/server/ava2-attr-lock/README.md。
|
||||
|
||||
已实际验证选择4、掩码8、锁定消耗4→3、洗练卷20→19且第4条保持、重复锁定不消耗、重启测试 db/auth/game 和客户端后读回、取消不消耗、解锁4→3。备份为 /root/deploy-features/20261018-ava2-parity/backup-attr-lock 和 backup-attr-lock-install-recheck;QA 专属夹具保存在该目录 private-attr-lock-*,勿纳入发布包。
|
||||
|
||||
直接函数测试 test_attr_lock_use.py 与原 ChangeAttribute 测试 test_attr_lock.py 通过。还未闭合其他玩家/交易/商店锁定提示、物理输入和 Android 联机。客户端脚本在 OnUpdate 内操作重新登录触发的窗口遍历崩溃单独记录,不能计作重连通过。
|
||||
@@ -0,0 +1,16 @@
|
||||
# AVA2 原生批量开箱
|
||||
|
||||
2026-10-18:测试服接入;正式服未部署。客户端完整记录见 metin2-client/docs/AVA2-CHEST-PICKUP.md。
|
||||
|
||||
来源:AVA2 FILES+SRC.tgz 的 game/src/char_item.cpp,ENABLE_MULTI_CHEST 的 OpenChest、GiveItemFromSpecialItemGroupNew、AutoGiveItemChest;cmd_general.cpp 的 chest_drop 和 chestdrop;GC66 DWORD 长度预览布局。
|
||||
|
||||
- 原生入口 `/chest_drop <window> <cell> <count>`,仅普通背包合法格,最多 1000、且只消费该格当前数量。原始基础物品封包仍是 BYTE 数量,单堆仍为 200,没有扩大成 1000。
|
||||
- 独立批量发奖,不再逐次 UseItem。保留特殊组金币/经验/异常效果及批次堆叠、延后更新/任务拾取回调。`/mt_chest` 保留为旧端兼容。
|
||||
- 交易、锁定、装备、死亡/观察/传送、商店/仓库/合成等状态拒绝;保留基础服等级、竞技场与龙魂资格检查。新堆与已有堆都检查孔值后合并。
|
||||
- 适配当前 200 堆叠:大数量奖励分堆,非堆叠逐个创建,MAKECOUNT 的最小量不会使剩余计数下溢;提示汇报实际创建数量。背包不足延续 AVA2 部分成功消耗语义,不把物品掉在地上。
|
||||
- `/chestdrop <vnum>` 只查询有效宝箱组。GC66 帧有 8190 行/65535 字节边界;客户端校验实际长度。
|
||||
- 物品 CItem 延后更新标志在 Initialize 重置。Makefile 为新 include 添加显式依赖,避免旧 Depend 漏编。
|
||||
|
||||
验证:`python3 tests/features/test_ava2_chest.py` 编译并执行真实 include;覆盖余量、合并、孔隔离、满包、状态、等级/龙魂、450 个奖励拆堆、非堆叠及 MAKECOUNT。另保留原 `/mt_chest` 测试。FreeBSD 隔离编译通过;普通 QA 在 sbtest 的真实窗口滑块开启 5 个,背包回调整叠开启其余 15 个。物理按键和 Android 真机仍未验收。
|
||||
|
||||
测试构建与原型备份在 /root/deploy-features/20261018-ava2-parity。回退:停止 sbtest,恢复 backup-pickup-proto 中 conf/db 两套原型(70002),game 链接恢复 sbtest/game.ava2-stones,重启测试 db/auth/channel5。没有操作正式服 share/bin/game。
|
||||
@@ -0,0 +1,38 @@
|
||||
# AVA2 drop tables
|
||||
|
||||
203 drops what AVA2 drops. Tables: `tools/ava2-drops/make_drops.py`. Code: `ITEM_MANAGER::ReadCommonDropNewItemFile` (item_manager_read_tables.cpp), the common-drop block and `GetDropPct` in item_manager.cpp, the load in input_db.cpp. The items AVA2 drops that 40250 lacks come from metin2-client `tools/server/ava2-items` and must be installed in the same deploy (the readers fail on an unknown item vnum and the core stops).
|
||||
|
||||
## Tables
|
||||
|
||||
Built by `make_drops.py <AVA2 locale dir> <203 locale dir> <out dir> <item_proto.txt>...`, the protos being every row the db will load (live item_proto.txt + ava2-items' items-server.tsv).
|
||||
|
||||
| File | Content |
|
||||
|---|---|
|
||||
| mob_drop_item.txt | AVA2's 247 `drop` groups. Entries with an unknown item are removed and the rest renumbered: the reader stops at the first missing index. |
|
||||
| common_drop_new.txt | AVA2's 26 level-range common groups (new file, see below). |
|
||||
| special_item_group.txt | 203's groups; AVA2's groups replace those of the same box vnum (50011, 50082, 50186, 50255) and AVA2-only boxes are added. 50035 keeps 203's group: it is the children's day box on 203 but a GM box on AVA2. |
|
||||
| common_drop_item.txt, etc_drop_item.txt | empty, as on AVA2. |
|
||||
|
||||
`report.json` lists group counts, removed items and replaced boxes.
|
||||
|
||||
## common_drop_new.txt
|
||||
|
||||
```
|
||||
Group <name>
|
||||
{
|
||||
map_index 0 # 0 = every map, otherwise the maps listed
|
||||
level_range <min> <max> # killer level
|
||||
<n> <item vnum> <count> <pct> # pct as a float, chance = pct / 100
|
||||
}
|
||||
```
|
||||
|
||||
A group drops when the monster level is within 20 of the killer, the killer level is in `level_range` and the map matches. Each entry is rolled against `GetDropPct`'s range (base 4,000,000) with probability `pct × 40000`. A missing file is logged and skipped; a parse error or unknown item fails the boot like the other drop files.
|
||||
|
||||
## Changes to the drop code (from AVA2)
|
||||
|
||||
- `GetDropPct`: premium item or glove doubles the drop rate, otherwise +50%; the permanent glove adds 100 (50 with premium) to the denominator bonus. `iRandRange = 4000000 * 100 / (100 + priv + bonus)`; 203 had an operator-precedence bug that fixed the divisor at 100.
|
||||
- PC-bang bonus removed. The event-manager bonus is not ported (203 has no ENABLE_EVENT_MANAGER).
|
||||
- A mob with two `drop` groups no longer reads an uninitialised group pointer.
|
||||
- special_item_group.txt groups may have up to 1023 entries (AVA2's cofreskindop boxes have 267).
|
||||
|
||||
The wiki (`/mt_features ... mob`) lists common_drop_new rows as rule 0 (FEATURE-QUERY-PROTOCOL.md). Not ported: AVA2's `/reload y`; quest-script and hardcoded drops are not compared.
|
||||
@@ -0,0 +1,17 @@
|
||||
# AVA2 原生换线
|
||||
|
||||
来源为 AVA2 启用的 `cmd.cpp move_channel → do_cmd(SCMD_CHANGE_CHANNEL) → timed_event → CHARACTER::MoveChannel`,不是同归档中已注释的另一套 `do_change_channel`。3秒倒计时,重复命令取消;结束时再校验任务、角色、物品操作、地图和对端可用性。
|
||||
|
||||
现有 `WarpSet(x,y,map)` 保留原签名,新增4参重载选择目标频道。普通传送继续走原路径。换线共享原保存/移除实体/GC Warp/P2P switchbot交接,避免另写一套传送清理顺序;不发送 VALID_LOGOUT。
|
||||
|
||||
AVA2 原端口步长100不适合203。`ava2_channel` 通过已有 GG relay 的保留名字 `#ava2_channels` 发送版本化快照,只接收已登记P2P对端身份匹配的频道和P2P端口。游戏端口来自该核心,地图来自 MAP_ALLOW。5秒心跳,30秒过期,断开删除,歧义归属拒绝;范围为1..7频道,99不可切。不会读取玩家输入的IP/端口。
|
||||
|
||||
配套客户端扩展命令:`ChannelList <current> <csv>`、`ChannelEndpoint <target> <ipv4> <gameport>`、`ChannelError unavailable`;频道标题仍发送 AVA2 原 `UpdateServerInfo`。列表只读,每角色每秒最多一次。私人地图没有跨频道路线,保留本频道条目,客户端不会回落到旧退出重登UI。
|
||||
|
||||
离线路由检查:`python3 tests/features/test_ava2_channel_registry.py`。编译必须显式指定隔离的 BINDIR 与 GAMEDIR,默认 Makefile 会部署正式二进制,不可直接裸跑。
|
||||
|
||||
macOS/sbtest已验证5:13040→6:13050→5续洗,active始终1、两套目标表和锁定第4条保持,71084消耗1034→976→919。正常退出重登保留频道6与auth11040;辅助核心关闭后列表移除6,旧目标请求被拒绝。同频道、未开放频道、倒计时取消和任务选择中的拒绝已通过。
|
||||
|
||||
测试版本game hash为2575de51a19dd080f6ecbff2cea8a549df1d8fd66be867bc483a412287fc9114。恢复原CONFIG逐字节核对,辅助13050/14050关闭,sbtest db/auth/core已重启;正式服game仍40335e41…,原15000/11000监听保持。备份、测试日志在 /root/deploy-features/20261018-ava2-parity/native-channel,不提交CONFIG/凭据。
|
||||
|
||||
当前变更仅部署sbtest,不能据此认定正式服已有原生换线。Android仅离线编译,用户暂停手机验收。
|
||||
@@ -0,0 +1,15 @@
|
||||
# AVA2 CG235 拾取
|
||||
|
||||
2026-10-18:仅 sbtest。客户端记录见 metin2-client/docs/AVA2-CHEST-PICKUP.md。
|
||||
|
||||
移植来源为 AVA2 ItemsPickup / CheckItemCanGet、70002 USE_SPECIAL 分支、char.h eAutomaticPickUP。CG235 固定头 5 字节(BYTE + DWORD count)后接 VID 数组与常规序列字节。客户端原版候选收集与 500ms 节流;服务端最多 4096 个 VID,先校验完整帧,再检查地面/距离/所有权/角色状态/分类。
|
||||
|
||||
bit0 开启,1–18 是原版忽略分类。修正原版 CHESTS 使用 ITEM_METIN 的误写为 ITEM_GIFTBOX;未移植职业、时装和稀有度能力不伪造为已支持。原有 /mt_pickup 仅兼容旧端。
|
||||
|
||||
`/setpickupmode <mode> <rarity>` 更新,空参数读取,`PickUPMode` 回传。当前选定的基础 DB 结构不扩大,设置持久化到 `ava2_pickup.mode` / `.rarity` quest 标记;PC 未加载时拒绝读写默认值,QuestLoad/延后登录事件完成后主动同步。冷重启验证曾暴露“初始读取早于 flags 加载”的竞态,现已修复。
|
||||
|
||||
70002 原型恢复 ITEM_USE/USE_SPECIAL;使用后消耗一颗并持久化 705 affect,30 天;已有状态重复使用不消耗。此处按原版只实现状态和键触发批量拾取,不声称周期无人操作拾取。稀有度过滤仅保存配置,稀有度物品系统及界面按钮尚未开放。
|
||||
|
||||
验证:`python3 tests/features/test_ava2_pickup.py` 执行真实封包解析和分类函数,覆盖截断、计数溢出、开关、距离/所有权、宝箱/灵石独立过滤。真实客户端 CG235 验证忽略灵石时只取回药水、取消过滤后取回灵石;激活/重复不消耗及测试 db/auth/core 冷重启后模式、剩余状态、图标和道具数量恢复通过。
|
||||
|
||||
没有正式服部署,未做 Android 真机或跨核心设置同步验收。备份和回滚同 FEATURE-AVA2-CHEST.md。构建必须覆盖 BINDIR 与 GAMEDIR,不能使用默认正式服输出路径。
|
||||
@@ -0,0 +1,14 @@
|
||||
# AVA2 spirit stones (staged on sbtest)
|
||||
|
||||
The stone catalogue and portable generator are in the sibling metin2-client repository:
|
||||
`tools/server/ava2-stones/README.md`. That directory includes the complete source audit, generated patch interface, read-only owned-item impact audit and test results.
|
||||
|
||||
The 138 source ITEM_METIN rows include 20 ordinary +0..+5 chains, special stones and the broken-stone marker. Unsupported wolfman stones and original empty-attribute placeholders are explicitly disabled in the staged data, rather than silently converted to sword resistance or usable zero-effect stones. Existing custom +6 rows remain compatible until a separately backed-up inventory/socket migration.
|
||||
|
||||
This server change aligns the actual ITEM_METIN branch with AVA2's default (ENABLE_ADDSTONE_FAILURE is disabled): insertion always succeeds, and exactly one stone is consumed. Existing destination, wear-flag, duplicate-family and socket checks remain. The selected 40250-compatible three-socket packet format remains unchanged.
|
||||
|
||||
`python3 tests/features/test_stone_socket.py` compiles and executes the actual branch with lightweight dependencies. It verifies success, one-per-stack and last-item removal, duplicate family, equipped/exchange refusal, target type and socket eligibility. Full FreeBSD compilation also succeeded. The staged binary hash is 4b335083a26116771e18c97b3a41b039e1ff28efe93e957494fc62b6c5dfe94d.
|
||||
|
||||
Ordinary QA1017, isolated player_sb/account_sb, confirmed insertion and stack decrement, actual casting-speed +35 and max-HP +1200 deltas, and all three new exclusive-family pairs. The original test equipment was re-equipped after the probes. No production binary, owned item or socket was changed.
|
||||
|
||||
For isolated gmake builds, override both BINDIR and GAMEDIR: the old Makefile automatically moves its output into GAMEDIR after linking. The sbtest proto backups and test fixture backups are under /root/deploy-features/20261017-ava2-stones/.
|
||||
@@ -0,0 +1,17 @@
|
||||
# AVA2 原生追踪和门票商店
|
||||
|
||||
2026-10-18,feature/ava2-unlock;仅 sbtest,正式服 game SHA256 仍为 `40335e41d466fd7379c805749978ad6df9c82f5673a3e5b8881b3bee8767663d`。
|
||||
|
||||
实现为 `new_mob_timer.*`(AVA2 刷新日历和首领状态)、`ava2_track.*`(八副本)、`ava2_track_commands.h`(查询/传送)、`ava2_ticket_shop.*`(原 shop12)。详尽来源、联机证据和未闭合范围见客户端 `docs/AVA2-TRACK.md`。
|
||||
|
||||
`d.track_update` 支持原任务的一参数调用;quest DB 载入完成后补发早期查询。首领 P2P 使用已有变长 relay,避免修改所有 GG 固定包;owner 心跳过期后停止显示其存活。未知/未开放地图不报存活。原日历按星期取模;65535 为存活标记,普通同值倒计时发送 65536。
|
||||
|
||||
八副本优先原冷却标记,重返为次选。203 旧地下墓穴 last_exit_time、火焰 exit_time、蜘蛛 retry_limit_time 也读取;旧蓝龙冷却通过无副作用的现行 Lua settings 读取,正在任务内或缺配置报不可用。读 Lua 的公共实现提取为 `port_dungeon_settings.h`,现有只读副本查询继续复用。
|
||||
|
||||
shop12 不占已有 shop manager ID,只有八个原始报价;使用原 CShop 的同步发奖/空格检查,成功才扣材料,金币价格为零。禁止卖出和任意商店 ID 远程打开;客户端追加 GC_SHOP 子包并校验长度,不改变旧子包。协议和客户端必须一起更新。
|
||||
|
||||
测试:`python3 tests/features/test_ava2_track.py`、`test_ava2_dungeon_track.py`、`test_ava2_ticket_shop.py`。FreeBSD 编译必须同时指定 BINDIR 与 GAMEDIR,默认 Makefile 输出会覆盖生产目录。
|
||||
|
||||
本批追踪部署时的 game SHA256:`8640644b94005a463e9e8244e6c414f1700ab675950e7bd3b0958bee289b1119`。部署及构建日志在 `/root/deploy-features/20261018-ava2-parity/`,此次兼容读取前的 game 备份为 `game-before-legacy-track`。只可用 sbtest stop/restart 脚本切换,不能用生产重启脚本。
|
||||
|
||||
尚未完成:八副本原版任务/门票/等级全量迁移、真实跨核心故障切换、Android 触控、全套资源缺口修复、正式服发布。冷却状态不能替代入口 NPC 的队伍/门票/房间权限检查。
|
||||
@@ -0,0 +1,140 @@
|
||||
# AVA2 items: unlocking the locked systems
|
||||
|
||||
The 478 AVA2 drop items come from metin2-client `tools/server/ava2-items` (see FEATURE-AVA2-DROPS.md). Items of systems 40250 lacks were imported as ITEM_NONE. This branch turns them back into usable items one system at a time. Each phase keeps the AVA2 row (type, subtype, values, applies) once the server and client understand it.
|
||||
|
||||
| Phase | Items | State |
|
||||
|---|---|---|
|
||||
| P1 boxes and keys | 77918–77920 boxes, 77921–77923 keys (`ITEM_TREASURE_BOX` / `ITEM_TREASURE_KEY`, value0 3–5) | done |
|
||||
| P2 stones | 28444 破碑之石+4 (`APPLY_ATTBONUS_STONE`), 28445 Boss stone (`APPLY_ATTBONUS_BOSS`) | done |
|
||||
| P3 dragon armor | 21210–21219 暗龙 (warrior), 21230– 风龙 (assassin), 21250– 魔龙 (sura), 21270– 神龙 (shaman), +0..+9 | done (client) |
|
||||
| P4 sash | 85004 领主 / 85008 大师 / 85014 王朝 / 85018 皇家 披风 (`COSTUME_SASH`, grade 4) | done, not deployed |
|
||||
| P5 mounts | 71502 / 71505 / 71508 / 71511 坐骑时装 (`COSTUME_MOUNT`), 71234 / 71254 坐骑外观 (`COSTUME_MOUNT_SKIN`) + mobs 32012 / 32028 | done, not deployed |
|
||||
| P6 costume enchants | 54001–54078 时装 / 发型强化石, 54124–54174 坐骑外观强化石 (`USE_CHANGE_ATTRIBUTE`); weapon / sash-skin / effect ranges and 53996 stay locked | done, not deployed |
|
||||
| P7 talismans | 护符 chains 9600–10950 (`ARMOR_PENDANT`, +0..+200 per element), 71301 / 71302 / 53996 / 53997 talisman attribute items | done, not deployed |
|
||||
| P8 new rings | 戒指 chains 19500 红宝石 / 19520 石榴石 / 19540 祖母绿 / 19560 蓝宝石 (`ITEM_NEW_RINGS`, +0..+9) | done, not deployed |
|
||||
|
||||
## P1: boxes and keys
|
||||
|
||||
40250 already has both types. A key opens a box when their value0 match (char_item.cpp, `ITEM_TREASURE_KEY`); the box then hands out its special_item_group group (live since the drops deploy). 203's own boxes use value0 0–2, so AVA2's 3–5 don't clash.
|
||||
|
||||
## P2: stone and Boss bonus
|
||||
|
||||
The points exist from the biolog port (POINT_ATTBONUS_STONE 240, POINT_ATTBONUS_BOSS 241, damage in battle.cpp); the apply types did not.
|
||||
|
||||
- `APPLY_ATTBONUS_STONE = 139`, `APPLY_ATTBONUS_BOSS = 140` (common/length.h), the same numbers as AVA2 and the client (`ItemData.h`). 92–138 are reserved for AVA2 applies not ported yet: `aApplyInfo` maps them to POINT_NONE and ProtoReader's `arApplyType` names them `APPLY_RESERVED_<n>`, so array index = apply number.
|
||||
- `CHARACTER::ApplyPoint` handles both like the other additive applies.
|
||||
- ProtoReader is in the db, so **the db binary must be redeployed with the game**; an old db rejects the items' `APPLY_ATTBONUS_*` columns.
|
||||
- The two stones share AVA2's stone family 31 (value5), so a weapon holds only one of them. The 7 guardian weapons keep their AVA2 `APPLY_ATTBONUS_BOSS 5`.
|
||||
|
||||
Test: `tests/features/test_applies.py` (numbering in length.h, constants.cpp, ProtoReader and the client header).
|
||||
|
||||
## P3: dragon armor
|
||||
|
||||
Ordinary `ARMOR_BODY` items; the server needed nothing. All ten refine steps are imported so the refine chain (refine sets 81–89, 203's own costs) works; +9 ends the chain.
|
||||
|
||||
The look is armor shape 32 (value3). The 40250 race msm stop at shape 30, and they cannot be patched from a pack (a bare file name always comes from the root pack). The client therefore registers the shape after each race msm load: script `mt_shapes` (metin2-client `src/platform/ScriptLib/ArmorShapesScript.inc`). The models `<race>_7_1.gr2` (+ LODs, skin) ship in the ava2items pack.
|
||||
|
||||
**Open:** AVA2 requires level 115–120. 203 caps at MAX_LEVEL 105, so nobody can wear the armor, nor the guardian weapons (level 120) already live.
|
||||
|
||||
## P4: sash
|
||||
|
||||
AVA2's sash (acce) system, ported from `Srcs/Server` (`#ifdef __SASH_SYSTEM__`) into `game/src/port_sash.cpp`.
|
||||
|
||||
- Item: `ITEM_COSTUME` / `COSTUME_SASH = 3` (ProtoReader `arSub28`, so **the db binary changes too**). value0 = grade (the four imported sashes are grade 4); socket0 = absorption %, socket1 = vnum of the absorbed weapon/armor. An unrolled grade-4 sash gets 11–25 % on first equip/creation (`SASH_GRADE_4_ABS_*`), combining caps at 19 %.
|
||||
- Slot `WEAR_COSTUME_SASH = 24`; `PART_SASH` follows `PART_HAIR`. The part is not stored in the player table: `SetPlayerProto` clears it and the equipped sash sets it to vnum − 85000, +1000 once absorption reaches 19 % (the client shows the glow above 86000).
|
||||
- **Protocol:** `CHR_EQUIPPART_SASH` is a fifth `awPart` WORD in GC_CHARACTER_ADD / ADD2 / UPDATE, `HEADER_CG_SASH = 211`, `HEADER_GC_SASH = 215`. Old clients break; the server and the client deploy together.
|
||||
- Absorbed bonuses: the sash adds the absorbed item's applies, attributes and (weapons) attack values scaled by absorption, `int(v*abs/100 + .5)` (+1 when positive), in `CItem::ModifyPoints` and battle.cpp. `MTSASH <code>` chat commands report window errors and results to the client (`mt_sash`).
|
||||
- Combine: two sashes of the same grade, price 100k/200k/300k/500k by grade, success 80/70/50/30 %. Absorb: sash + weapon/armor, the material is destroyed.
|
||||
- Window: quest `sash` on 王铁匠 20016 (203 has no NPC 60003), `pc.open_sash(true)` combine / `(false)` absorb: metin2-client `tools/server/sash` (installs `pc.open_sash` into quest_functions).
|
||||
- Client: `src/platform/ScriptLib/SashScript.inc` (`mt_sash`: windows, costume slot, tooltips), models + `item_scale.txt` + effects in the ava2items pack.
|
||||
|
||||
Test: `tests/features/test_sash.py` (numbering, packet layout shared with the client header, quest hook).
|
||||
|
||||
## P5: mount costume and mount skin
|
||||
|
||||
AVA2's `ENABLE_MOUNT_COSTUME_SYSTEM` + `ENABLE_MOUNT_SKIN`, ported 1:1 into `game/src/port_mount.cpp`. They ride on the 40250 horse: the worn costume only changes the horse race.
|
||||
|
||||
- Items: `ITEM_COSTUME` / `COSTUME_MOUNT = 2` and `COSTUME_MOUNT_SKIN = 4` (AVA2 numbers the skin 7; ProtoReader `arSub28` gains `COSTUME_MOUNT_SKIN`, so **the db binary changes again**). value0 = horse race.
|
||||
- 71502 狮子 20113 (怪物强悍 +30 %), 71505 野猪 20110 (破碑 +30 %), 71508 狼 20111 (Boss +30 %), 71511 20112 (双倍经验 30 %).
|
||||
- The applies count while the costume is worn.
|
||||
- Skins 71234 蓝色巴里 → 32012, 71254 白色冬日羊驼 → 32028.
|
||||
- Both subtypes return no attribute set (`GetAttributeSetIndex` −1, the sash too), so they cannot be rerolled.
|
||||
- Slots `WEAR_COSTUME_MOUNT = 25` and `WEAR_COSTUME_MOUNT_SKIN = 26`.
|
||||
- `GetMyHorseVnum`: the worn skin's value0, else the worn mount's value0, else the horse-level race.
|
||||
- Summoning and riding still need horse level ≥ 1, as on AVA2; equipping without a horse says `MTMOUNT need_horse`.
|
||||
- Riding uses horse stamina.
|
||||
- Hooks follow AVA2:
|
||||
- Equipping re-summons.
|
||||
- Taking the mount off sends the horse away; taking the skin off re-summons.
|
||||
- A skin needs a worn mount (`need_mount`). Neither piece changes while riding (`riding`). The mount stays while a skin is worn (`has_skin`).
|
||||
- A worn mount is summoned on login.
|
||||
- `/user_horse_back` also takes the mount off.
|
||||
- Mobs 32012 / 32028 come from the AVA2 mob_proto rows (`mobs-server.tsv`, installed by `install_items.py … <mobs-server.tsv>`).
|
||||
- Client:
|
||||
- RaceManager `__IsNewMountRace` (32000–32100 → `npc_mount`).
|
||||
- `mt_mount` (`MountScript.inc`) registers the npclist rows, adds the costume window slots and renders the `MTMOUNT` messages.
|
||||
- The models ship in the ava2items pack (`MOUNT_MOBS`).
|
||||
|
||||
Test: `tests/features/test_mount.py`.
|
||||
|
||||
## P6: costume enchants
|
||||
|
||||
AVA2's `ENABLE_SPECIAL_COSTUME_ATTR`, in `game/src/port_costume_attr.cpp`. The items are `ITEM_USE` / `USE_CHANGE_ATTRIBUTE`. value0 is the apply type and value1 the value; AVA2 apply numbers equal 203's (P2 aligned 139/140). value2 is the target mask `1 << bonus flag`.
|
||||
|
||||
- Unlocked ranges (make_items `ENCHANT_KEEP`):
|
||||
- 54001–54027 时装 (mask 2, body);
|
||||
- 54028–54078 发型 (4, hair);
|
||||
- 54124–54174 坐骑外观 (16, mount skin).
|
||||
- Still locked, since the target systems don't exist here: 54079– weapon costume (8), 54175– sash skin (32), 54220– effect (64). 53996 became a talisman item in P7.
|
||||
- `CItem::IsCostumeEnchant` (vnum 54001–54267 with a nonzero value2) is checked first in the change/add-attribute case of `UseItemEx`, before the 40250 costume refusal. So an enchant never reaches the reroll code, and dragged onto gear it is refused (`MTCATTR target`).
|
||||
- `CostumeEnchantUse` follows AVA2's checks:
|
||||
- target kind and mask (`target`);
|
||||
- apply none (`none`);
|
||||
- not while worn (`equipped`, the 40250 switcher rule);
|
||||
- at most 3 attributes (`full`);
|
||||
- no duplicate apply (`has`).
|
||||
- Then `AddAttribute`, consume one, `ItemLog COSTUME_ENCHANT`, `done`.
|
||||
- The switchbot never uses enchants: it only looks up the switcher vnums in FEATURE-SWITCHBOT.md.
|
||||
- Client `mt_costume_attr` (`CostumeAttrScript.inc`):
|
||||
- marks matching costumes as usable drop targets (the 40250 inventory already sends every `USE_CHANGE_ATTRIBUTE` drop);
|
||||
- adds the attribute and targets to the enchant tooltip;
|
||||
- renders `MTCATTR`.
|
||||
|
||||
Test: `tests/features/test_costume_attr.py`.
|
||||
|
||||
## P7: talismans
|
||||
|
||||
AVA2's `ITEM_TALISMAN_EQUIPMENT` + `ELEMENT_NEW_BONUSES`, in `game/src/port_pendant.cpp`.
|
||||
|
||||
- Item: `ITEM_ARMOR` / `ARMOR_PENDANT = 7` (ProtoReader `arSub2`, so **the db binary changes again**), worn in `WEAR_PENDANT = 27`. The AVA2 wear flag `WEAR_PENDANT` does not exist here: `FindEquipCell` sends every talisman to the slot before the wear-flag check.
|
||||
- Six chains of 201 items (+0..+200), fire 9600, ice 9830, earth 10060, dark 10290, wind 10520, elect 10750. Each carries `APPLY_ENCHANT_<element>` = its step; the level limit rises from 20 to 60 along the chain.
|
||||
- Refine sets 440–499 (fragment 96001–96006 + 30031 + 33031 ×10, 50000 yang, 100 %) are SQL rows: metin2-client `tools/server/pendant` (`install.sh`, then restart the db).
|
||||
- Applies `APPLY_ENCHANT_ELEC..DARK = 123..128` (AVA2 numbers; the db names are AVA2's, `APPLY_ENCHANT_ELECT` first) → `POINT_ENCHANT_* = 242..247`.
|
||||
- Damage (battle.cpp `CalcAttBonus`): against a monster with `RACE_FLAG_ATT_<element>`, attack +point %, so a +200 talisman triples the attack on those monsters (×(1+200/100)), which is AVA2's own balance. Each flag is its own `if`, as on AVA2. AVA2 leaves out ICE; we include it, since 203 has 83 ice monsters and an ice talisman chain.
|
||||
- Attributes:
|
||||
- The pool is AVA2's item_attr pendant column (20 rows, levels 1–5), kept in a table in `port_pendant.cpp` instead of a new item_attr column (that would change the db boot packet).
|
||||
- `GetAttributeSetIndex` stays −1. So talismans drop without attributes, and the 40250 switchers and the attribute lock refuse them. The switchbot rolls them with 71302 only (pseudo attribute set 9).
|
||||
- 71302 rerolls all attributes (needs at least one; levels 0/10/40/35/15 %). 71301 adds one up to 5, always succeeding (levels 40/50/10 %). No duplicates.
|
||||
- **Deviation:** AVA2's 53996 / 53997 are generic switcher / adder items, a free 40250 gear reroll. Here they work like 71302 / 71301, as their zh names (护符附魔道具 / 护符加持道具) say.
|
||||
- Not while worn (`equipped`), like the 40250 switcher. Any other attribute item dropped on a talisman, or a talisman item dropped on anything else, gets `target`.
|
||||
- Messages: `MTPENDANT target|equipped|empty|changed|full|added` (client `mt_pendant`). `ItemLog PENDANT_CHANGE` / `PENDANT_ADD`.
|
||||
- Not ported: AVA2's element target packet (`ELEMENT_TARGET`, the element icon over the target HP bar).
|
||||
- Client: `ItemData.h` / `PythonItemModule` constants, `c_Equipment_Pendant`, apply texts, and `mt_pendant` (`PendantScript.inc`: the equipment slot under the earring, item drop targets, messages).
|
||||
|
||||
Test: `tests/features/test_pendant.py`; `test_applies.py` covers the 123–128 numbering.
|
||||
|
||||
## P8: new rings
|
||||
|
||||
AVA2's `ENABLE_NEW_RINGS`, in `game/src/port_rings.cpp`.
|
||||
|
||||
- Item: `ITEM_NEW_RINGS = 36` (`ITEM_SHINING = 35` is reserved for the AVA2 numbering and not ported). It is a new ProtoReader type, so **the db binary changes again**. Worn in `WEAR_RINGS_1 = 28` / `WEAR_RINGS_2 = 29`: `FindEquipCell` takes ring slot 1 when free, else slot 2. Rings have no wear flag.
|
||||
- Four chains of 10 (+0..+9). Each step carries a stat (INT / DEX / STR / CON) and a resist against one class. Level limit 90 (203's MAX_LEVEL is 105). They reuse 203's refine sets 46–54, which already have AVA2's materials, so no refine SQL is needed.
|
||||
- Sockets: rings are socket accessories (`IsAccessoryForSocket`). Drills add sockets (up to 3). As with every socket or attribute item in 40250, the ring must not be worn. Each family takes its AVA2 jewel (`CanPutInto`): 19500 → 50635, 19520 → 50636, 19540 → 50637, 19560 → 50638 (19220 → 50634 is in the table, but that family is not imported).
|
||||
- Attributes:
|
||||
- The pool is AVA2's `item_attr_rings` (20 rows, levels 1–5), kept as a table in `port_rings.cpp`. `GetAttributeSetIndex` stays −1, and `PutAttributeWithLevel` branches to the ring pool.
|
||||
- The 40250 switchers and adders (`USE_CHANGE_ATTRIBUTE`, `USE_ADD_ATTRIBUTE`, `USE_ADD_ATTRIBUTE2`) accept rings, with the usual not-while-worn rule. 71151 / 71152 (weapon / armor only) refuse them, by design.
|
||||
- The switchbot rolls rings from this pool (pseudo attribute set 8). The rare (6th / 7th) attributes skip rings. AVA2's `item_attr_rare_rings` is not ported.
|
||||
- Rings drop without attributes: `AlterToMagicItem` only handles weapons and armor.
|
||||
- Client: `ITEM_TYPE_RINGS`, `c_Equipment_Rings1/2` (253 / 254), and `mt_rings` (`RingsScript.inc`). That module adds the two slots beside the shoes, the accessory tooltip (applies, attributes, jewel sockets) and the drop targets for drills, jewels, switchers and adders.
|
||||
|
||||
Test: `tests/features/test_rings.py`.
|
||||
@@ -0,0 +1,111 @@
|
||||
# PORT battle pass
|
||||
|
||||
A monthly mission pass, ported from AVA2's `ENABLE_BATTLE_PASS` (the window behind `uibattlepassex.py`). A season is a time window with up to ten missions. Each mission has its own reward, and a final reward unlocks once every mission is done. The pass is free for every player; AVA2 sold a ticket item (25150–25161), and this port has none.
|
||||
|
||||
Source:
|
||||
- `src/server/game/src/port_battlepass.h`: config, per-player state and bag fit; standard C++ only.
|
||||
- `port_battlepass_runtime.h`: game side, included only by cmd_general.cpp.
|
||||
- `port_battlepass_hooks.h`: hook declarations for the other files.
|
||||
|
||||
Tables: `tools/battlepass/schema.sql`. Season file: `tools/battlepass/port_battlepass.tsv`. Test: `tests/features/test_battlepass.py`.
|
||||
|
||||
## Season file
|
||||
|
||||
The file is `<locale base>/port_battlepass.tsv`, for example `share/locale/newcibn/port_battlepass.tsv`. Every core checks it at most once every 5 s and reloads it when its mtime, size or inode changes, the same rule the event calendar uses. Replace it atomically with a temporary file and `mv`.
|
||||
|
||||
```
|
||||
MTBATTLEPASS 1
|
||||
season ID START END unix seconds, [START, END)
|
||||
mission SLOT TYPE SUB TARGET [VNUM COUNT]x0..3
|
||||
final VNUM COUNT [VNUM COUNT]x0..5
|
||||
```
|
||||
|
||||
- Any error disables the whole file; the game logs `PORT_BP: port_battlepass.tsv disabled: line N: why`. Errors include:
|
||||
- a bad number or a duplicate slot;
|
||||
- overlapping seasons;
|
||||
- a season without missions;
|
||||
- a sub on a type that takes none.
|
||||
- Slot numbers are 1..10. A season ID must never be reused: progress and claims are stored per season ID.
|
||||
- A reward must be a bag item:
|
||||
- not a dragon soul stone;
|
||||
- size 1..3;
|
||||
- at most 24 stacks per claim.
|
||||
|
||||
A bad reward is caught when someone claims it: the answer is `config`, `sys_err` logs it, and the slot stays claimable after the file is fixed.
|
||||
|
||||
| Type | Counts | SUB |
|
||||
|---|---|---|
|
||||
| 1 | monster kills (not boss, not stone) | mob vnum or 0 |
|
||||
| 2 | boss kills (rank ≥ boss) | mob vnum or 0 |
|
||||
| 3 | metin stone kills | stone vnum or 0 |
|
||||
| 4 | seconds online | 0 |
|
||||
| 5 | fish caught | item vnum or 0 |
|
||||
| 6 | successful refines | resulting item vnum or 0 |
|
||||
| 7 | levels gained | 0 |
|
||||
| 8 | gold paid to NPC shops | 0 |
|
||||
| 9 | items sold to NPC shops | item vnum (required) |
|
||||
|
||||
A kill counts for the player that `CHARACTER::Reward` gives the quest kill event to, which is the `DistributeExp` attacker. As in AVA2, it counts only when the monster is within 20 levels of the player. A party member who is not that attacker gets nothing. Type 9 needs a vnum because selling any item could be farmed with cheap shop items.
|
||||
|
||||
The shipped file has seasons 202610–202712 (through 2028-01-01), starting at local midnight on the first of each month (Europe/Berlin, the server's zone). Each has:
|
||||
- eight missions, rewards taken from 40250 items;
|
||||
- a final reward of the three pearls and 70024.
|
||||
|
||||
The targets follow the scale of AVA2's month 10 (`player.battle_pass`).
|
||||
|
||||
## Storage
|
||||
|
||||
```
|
||||
player.mt_battlepass_progress (pid, season, slot, value, target) PRIMARY KEY (pid, season, slot)
|
||||
player.mt_battlepass_claim (pid, season, slot, claimed_at) PRIMARY KEY (pid, season, slot); slot 0 = final
|
||||
```
|
||||
|
||||
**Counting.** Events are counted in memory, as the delta per slot. `CHARACTER::SaveReal`, which covers the periodic save, logout and warp, adds play time, then queues one upsert on the game's ordered SQL connection:
|
||||
|
||||
`value = LEAST(value + delta, target)`
|
||||
|
||||
Because the write adds, a core does not need to have read the row first. Two cores that both see the player during a warp add their own deltas, with no overwrite.
|
||||
|
||||
**Loading.** At the first event or `/mt_bp`, a `FuncQuery` reads the stored values and claims. Flushes queued after that read are added on top. A generation number drops the answers of a session that has already ended.
|
||||
|
||||
**Season change.** The counts of the old season are written while that season is still in the file. The new season then loads its own rows.
|
||||
|
||||
**Claims.** A claim checks four things before writing anything:
|
||||
1. the state is loaded;
|
||||
2. the mission is complete;
|
||||
3. the slot is not claimed yet;
|
||||
4. all the stacks fit in the bag. The fit is first-fit in `GetEmptyInventory` order, and a size-2 or size-3 item stays inside one 45-cell page.
|
||||
|
||||
Only then does it run `INSERT IGNORE` into the claim table synchronously. Only the request whose insert affected a row creates the items, into the cells checked before. A double click, a retry or another core finds the row already there and gets `claimed`. Each item gets an `MT_BP_CLAIM` item log with the hint `SEASON SLOT`, and the character is saved right away.
|
||||
|
||||
Known limits:
|
||||
- If the core crashes between the claim row and the item save, that reward is lost. The claim row and the item log are there for a GM to compensate.
|
||||
- While a warp is in flight, the window can show slightly less progress than is stored. Nothing is lost or counted twice.
|
||||
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_bp 1 info | 1 claim SLOT | 1 close
|
||||
MTBP1 season ID START END NOW COUNT
|
||||
MTBP1 mission SLOT TYPE SUB TARGET VALUE CLAIMED [VNUM COUNT]...
|
||||
MTBP1 final CLAIMED ALLDONE [VNUM COUNT]...
|
||||
MTBP1 end
|
||||
MTBP1 none no season running (or no valid file)
|
||||
MTBP1 progress SLOT VALUE pushed while the window is open
|
||||
MTBP1 done SLOT a mission was finished (always sent)
|
||||
MTBP1 claimed SLOT the reward is in the bag; a full info follows
|
||||
MTBP1 error loading|slot|claimed|incomplete|space|config|db|rate|invalid
|
||||
```
|
||||
|
||||
- `info` before the load is answered as soon as the load arrives.
|
||||
- A `done` for a mission that an event finished before the load is sent when the load arrives.
|
||||
- `info` and `claim` share a 300 ms gap per player (`rate`).
|
||||
- A wrong version, more than three tokens, or a token longer than 10 characters gets no answer.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Apply `tools/battlepass/schema.sql` once.
|
||||
2. Copy `port_battlepass.tsv` to the locale base directory.
|
||||
3. Restart the cores with the new binary.
|
||||
|
||||
Without the file, every `/mt_bp` answers `none` and nothing is counted or written.
|
||||
@@ -0,0 +1,58 @@
|
||||
# PORT batch chest opening, v1
|
||||
|
||||
Date: 2026-10-15. AVA2-style batch opening of gift boxes (reference: AVA2 `ENABLE_MULTI_CHEST`, `/chest_drop`, `CHARACTER::OpenChest`). Source: `src/server/game/src/port_chest.h` (header-only, included from `cmd_general.cpp`), command `mt_chest` (cmd.cpp). It reuses the quiet-INFO hook (`m_portQuietInfo` / `m_portLastInfo`) (char.cpp; first added for the v1 switchbot, which no longer uses it). No packet header, no DB schema, no char.h/item.h change.
|
||||
|
||||
AVA2 rewrote the drop loop (`GiveItemFromSpecialItemGroupNew`, `AutoGiveItemChest`, cap 1000). That rewrite is not ported. Here every box goes through the original `CHARACTER::UseItem` → `UseItemEx` `ITEM_GIFTBOX` path, one box at a time, so the original checks, the `special_item_group` roll, gold/exp, `ItemLog` and consumption stay exactly as they are.
|
||||
|
||||
## Rules
|
||||
|
||||
- Only `ITEM_GIFTBOX` items whose special item group exists, is not empty and contains none of the give types `MOB`, `SLOW`, `DRAIN_HP`, `POISON`, `MOB_GROUP`. Boxes that spawn monsters or apply debuffs stay single-use (`error kind`). Other item types (e.g. `ITEM_USE` chests with quest scripts) are not batchable.
|
||||
- The chosen cell is opened first while it still holds the box vnum; after that, any other bag cell with the same vnum. Most gift boxes on 203 have no stack flag, so a batch normally spans many cells. Items being exchanged are skipped.
|
||||
- At most 200 boxes per command.
|
||||
- Before each box the character must still have 3 free bag cells (`GetEmptyInventory(3)`). This keeps room for any reward, so `AutoGiveItem` never has to drop one on the ground. The loop stops with reason `full`.
|
||||
- Busy: dead, stunned, warping, observer, `!CanHandleItem`, exchange, own shop, shop open, safebox, cube. Checked before the command and before each box.
|
||||
- A box counts as opened only when the bag count of its vnum went down by exactly one. Anything else (the original path refused it, e.g. the dragon soul qualification) stops the loop with reason `rejected`. The last INFO line of that refusal is forwarded once.
|
||||
- Per-box INFO lines are held back while the batch runs.
|
||||
- Throttle: one command per 500 ms per player id.
|
||||
|
||||
## Protocol (CHAT_TYPE_COMMAND, version 1)
|
||||
|
||||
```
|
||||
/mt_chest 1 open CELL COUNT CELL = bag cell, COUNT = 1..200, digits only (at most 5)
|
||||
MTCH1 got VNUM COUNT one line per gained vnum (box vnum excluded), at most 40 lines
|
||||
MTCH1 done VNUM ASKED OPENED REASON GOLD
|
||||
MTCH1 error rate|invalid|busy|item|kind|full
|
||||
```
|
||||
|
||||
- REASON: `done` (all asked boxes opened), `empty` (no box of this vnum left), `full` (fewer than 3 free cells), `busy`, `rejected`.
|
||||
- GOLD: gold balance change over the batch.
|
||||
- Gains are the difference between bag + dragon soul bag counts before and after the batch.
|
||||
- A request with a version other than `1`, a token longer than 10 characters or more than 5 tokens is ignored silently.
|
||||
|
||||
There is no MTF1 capability bit (the mask stays 511). The client marks the server unsupported when no `MTCH1` reply arrives within 3 s and falls back to normal single use.
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/features/test_chest.py` compiles the production header against stubs of the `UseItem` gift-box contract (consume one box, gold, stacking reward, dragon soul reward, INFO lines). It covers:
|
||||
- cross-cell order and the gains/gold summary with INFO held back;
|
||||
- a stack, fewer asked than held, more asked than held (`empty`);
|
||||
- the 3-free-cell stop (`full`, `error full`);
|
||||
- refusal by the original path (`rejected`, INFO forwarded once);
|
||||
- non-gift box, monster box, missing and empty group (`kind`);
|
||||
- missing/exchanging item, busy, invalid input, silently ignored version, throttle.
|
||||
- It also checks the cmd.cpp / cmd_general.cpp wiring.
|
||||
- All `tests/features/test_*.py` pass.
|
||||
- FreeBSD build of the game target in `/root/metin2-features-dev` (log `chest-build.log`, binary sha256 `412977c7d7fda073493533d5bee43812a8f48dcb63399f747db6180d24803853`). The live `/usr/metin2` binary was not replaced and no live service was restarted.
|
||||
- Live test on 2026-10-15 against the channel-5 test core (port 13040, isolated binary) with the macOS native client as [SA]Admin, boxes created with `/item`:
|
||||
- 50037 (stacking, 30 held), 10 asked → `done 50037 10 10 done 0`, 6 gained vnums matching the bag difference exactly;
|
||||
- 50070 (not stacking, 4 boxes in 4 cells), all → `done 50070 4 4 done 100000`, gold balance +100000;
|
||||
- 71036 (group spawns a monster) → `error kind`, nothing consumed; an immediate second command → `error rate`;
|
||||
- remaining 20 of 50037 → `done 50037 20 20 done 0`, 11 gained vnums;
|
||||
- plain right click without Ctrl still uses one box the original way.
|
||||
- `log.log` only has the original path's rows (`SYSTEM`, `TREASURE_EXP`, `TREASURE_GOLD`). syserr shows only the pre-existing `new_quest_lv52` LUA_ERROR.
|
||||
|
||||
## Production deployment
|
||||
|
||||
- Deployed 2026-10-15 16:43 with the user's approval, 0 players online. Server main bc32475, game sha256 `412977c7…` (the channel-5 tested binary), db unchanged. Package `/root/deploy-features/20261015-chest`, backup `/root/backup-bin/20261015-164314`, rollback `sh /root/deploy-features/20261015-chest/deploy.sh rollback`. `/usr/metin2/src` was synced (cmd.cpp, cmd_general.cpp, port_chest.h).
|
||||
- On the first start the db core exited at boot (`QueryLocaleSet: ... errno 2013 Lost connection to MySQL server during query`, db.core kept as `db.core.164339` in the package). MySQL itself had not restarted and the db binary is unchanged. A clean stop of every core and a db-first start (db, auth, CH1–CH4, game99, then channel5) came up normally: 14 game, 1 db, 1 auth, port 15000 listening. If this repeats, check `ps` for `./db` after every deploy, not only the game count.
|
||||
- CH1 (13000) acceptance with the channel-5 scenario: 50037 ×10 → `done 50037 10 10 done 0` (8 vnums, equal to the bag difference); 50070 ×4 in 4 cells → `done 50070 4 4 done 100000`; 71036 → `error kind`, then `error rate`; remaining 20 → `done 50037 20 20 done 0`; plain use unchanged. syserr only has the pre-existing `new_quest_lv52` LUA_ERROR.
|
||||
@@ -0,0 +1,57 @@
|
||||
# Level cap 120 + AVA2 105–120 content
|
||||
|
||||
The user decided on 2026-10-16:
|
||||
- raise the level cap from 105 to 120;
|
||||
- for 105–119, use a geometric exp curve that stays under the DWORD limit;
|
||||
- keep the level-delta exp/drop table (`aiPercentByDeltaLev*`) unchanged;
|
||||
- port AVA2's new maps and dungeons, with drops for their monsters.
|
||||
|
||||
## Why the cap alone is not enough
|
||||
|
||||
- **Exp curve.** On the newcibn locale `exp_table` = `exp_table_common`. Its 105–119 entries only moved from 2.33e9 to 2.49e9, so every level cost about the same as 104. AVA2 climbs to 2.05e10, but its table is DWORD, so from 107 on it wraps: 4.37e9 becomes about 7.5e7. That is not copied.
|
||||
- **No monsters.** On 203 the highest normal monster that spawns is level 103 (6006); bosses and stones top out at 105. `PERCENT_LVDELTA` applies to exp, drop chance and gold alike. A player 12 levels above the monster gets 20%, and 15 or more levels above gets 1%. So without new monsters, 105–120 cannot be levelled.
|
||||
- **AVA2 has the content.** 445 monster/stone vnums are AVA2-only, and 348 of them are level 100 or higher. AVA2 also re-levels 47 shared monsters, for example 2493 from 97 to 105 and 3091 from 105 to 115.
|
||||
|
||||
## Phases
|
||||
|
||||
| | What | Where |
|
||||
|---|---|---|
|
||||
| L1 | `MAX_LEVEL: 120`; exp table 105–119 = 2.33e9 → 4.2e9 geometric (constants.cpp); `player.exp` / `player_deleted.exp` → `INT UNSIGNED`. Points are already DWORD on the server, and the client reads exp unsigned. | server, `tools/server/level-120` (client repo) |
|
||||
| L2 | Monsters: AVA2-only rows from AVA2 `db/mob_proto.txt` (not `share/conf`, which is an older copy), zh names, client mob models/motions (Monster, Monster2, NPC2 packs), `npclist`. | server proto + client pack |
|
||||
| L3 | Maps, 100+ first: `plechito_desert_map_01` (101–115), `metin2_map_elemental_04_rework` (103–112), Yohara `eastplain_01–03` + `empirecastle` (85–125), `metin2_map_dawnmist_dungeon_01` (120). Server map dir + index + MAP_ALLOW on a core; client map pack, atlas, minimap, zh map names; reach them through the travel ring / NPC like AVA2's `anillotp` / `tp_npc1`. | both |
|
||||
| L4 | Dungeons: `flame` (107–120, our 351 retuned), `snow` (`n_snow_dungeon_01` 352, 100–120), `meleylair` (212, 113–123, level ≥ 110), `shipdefense` (`defensawe_hydra` 355, 100–120). They need quest functions we lack: `d.global_warp_all_to_base`, `d.mission_notice`, `d.track_update`, `d.spawn_mob_new`, `d.new_kill_all`, `game.check_event`, `npc.set_meley_hp`, `npc.set_protect_flag2`, `npc.set_protect_time`, `npc.get_protect_time`, `npc.set_statu_affect`, `npc.set_statu_clear_aff`, `npc.show_statu`, `npc.dead_by_vnum`. AVA2's `when X.chat.lc_quest("…")` and `lc_quest` strings must become zh literals for our qc. | both |
|
||||
| L5 | Drops: AVA2 gives only 8 of the new monsters drops (203 already has those groups), so the rest are designed in the client repo's `tools/server/ava2-maps/drops_maps.tsv` (tiers normal / elite / boss / stone / gold, plus per-map and per-vnum-range rows) and written by `make_drops_maps.py`. Every drop item must exist in item_proto first, otherwise the core won't boot. | server |
|
||||
| L6 | Test on the sbtest cluster, then deploy with the rest of feature/ava2-unlock (needs approval). | 203 |
|
||||
|
||||
Later, below 105 or separate systems: summer maps `a1/c1_summer`, `metin2_12zi_stage` (zodiac, C++), `kingdoomswar`, `battlefied`. The plechi dungeons (slime/duratus/gold/nightmare/troll/elephant) have maps but no quest in AVA2's quest_list, so they are skipped.
|
||||
|
||||
## Open
|
||||
|
||||
- Whether to take AVA2's new levels for the 47 shared monsters.
|
||||
- Which 203 core carries the new maps. The cores are i386 and each uses about 400 MB.
|
||||
|
||||
## Status
|
||||
|
||||
- L1 done on sbtest (2026-10-16). Exp table 106–120 in constants.cpp. The exp sum in `CHARACTER::PointChange(POINT_EXP)` is now 64-bit, as are the death exp-loss product (char_battle.cpp) and the quest reward check (questpc.cpp). Before that fix, 3.67e9 + 2e9 at level 119 wrapped to 1375032704. Tested with `/set exp` on [SA]Admin:
|
||||
- 105 → 106 at 2.33e9;
|
||||
- 3375032704 (> 2^31) saved to `player_sb.player` and survived `restart.sh`;
|
||||
- +2e9 at 119 → 120;
|
||||
- no more gain at 120.
|
||||
The live schema change and live `MAX_LEVEL: 120` are not applied.
|
||||
- L2/L3 on sbtest (2026-10-17): the 10 maps of `tools/server/ava2-maps/README.md` (client repo) are installed in channel5's own locale/data farm (`sbtest_locale.sh`) and reachable with `/warp x y` (global metres; `/goto #index` does not reach them). Hydra is moved from AVA2's 972800,153600 to 3276800,0, so AVA2 quest coordinates shift by (+2304000, −153600); its entry is `/warp 33089 116`. Mob models render.
|
||||
- Client fix found on the way: after `/warp`, a timer chat (`/bio status`, `/server_bonuses`) sent between the new socket coming online and the core's GC_PHASE reached the core's handshake phase and got the connection closed ("Handshake phase does not handle packet 3"). The client now leaves the "Game" phase on GC_WARP and drops chat outside it.
|
||||
- L5 on sbtest (2026-10-17): 99 drop groups appended (107 generated, the 8 existing kept). A kill test on plechito (`/m` + `/weaken all` + auto hunt) dropped the tier items, the lv115 armor, and the flame/hydra boss materials.
|
||||
- L4 on sbtest (2026-10-17): AVA2's snow / ship defence / Meley quests ported as `snow_dungeon`, `ShipDefense`, `MeleyDungeon` by the client repo's `tools/server/ava2-dungeons` (`make_quests.py` + `install.sh`, see its README). Server side: `port_ava2_dungeon.cpp` (the `d.*` / `npc.*` functions AVA2's quests call), `QUEST_ATTACK_EVENT` (`<vnum>.attack`, Meley's HP phases), the Meley and hydra HP helpers. `d.track_update`, `game.check_event` and the battle pass calls were dropped from the quests instead of ported. The game build is installed only as sbtest's `game.switchbot` (previous one kept as `game.switchbot.pre-l4`). Entry test on the Mac client (key + `/warp` to the NPC + quest dialog → solo → yes): all three dungeons warp in (352, 355, 212), the key is used, the dungeon timers and mob spawns start, and syserr shows no quest errors. Meley full run (2026-10-17, solo GM at level 120 with a temporary sbtest-only damage/HP buff quest, since removed): all 9 floors, the floor-10 chest, and the exit warp back to map 62 (5986,6573) in 837 s; the 3 h cooldown flag is written. Fixes found on the way: `char_battle.cpp` never lets a hit take a dragon statue (6230) below 1 HP, so only the quest's `npc.dead_by_vnum` kills it (AVA2 has the same stuck-lair bug on floor 8); the client's autohunt now skips a target that is hit but takes no damage for 4 s (it stays skipped for 60 s). The client's `mt_dungeon_timer` shows the AVA2 dungeon timer (boss portrait, floor/wave, countdown) in place of the minimap, plus the hydra mast HP bar.
|
||||
- Snow / ship / party runs (2026-10-17), with the fixes they needed:
|
||||
- QUEST_INFO desync: `SendQuestInfoPakcet` sent the header before the optional fields were added, so `qi.size` was short and the client read the rest as a new packet ("Unknown packet header: 212"). The fields are now built first. The client also takes the full size from the flags.
|
||||
- Hydra 6812 (KING, MAGIC) never took damage. The deck stops a player about 620 from its centre, and `battle_melee_attack` allowed only 300 (AVA2 600, still short of 620), so the server dropped every hit as VICTIM_FAR. For a non-PC victim of rank BOSS or higher the limit is now 800. The client gives a boss the 500 centre test of a huge race, like AVA2's `IsBoss()`.
|
||||
- Client autohunt: large targets (defending reach as body size, walk straight at a body in reach when the planner finds no path), escalating skip for a target it keeps stalling on, a new anchor after a teleport (snow floor changes move the player more than 2000), and the immune skip only counts an explicit 0-damage packet.
|
||||
- The snow driver used GM `/purge all` on floors 1/3/4 when a floor was still open after 300 s. This is a test accelerator for floors with 100+ mobs, not autohunt.
|
||||
- Party skill power crash: `CTableBySkill::GetSkillPowerByLevelFromType` indexed its table with `job * 2 + skill_group - 1` and only rejected skill_group 0. [SA]Admin has skill_group 50 (one live row has it too), so the party update event (`CParty::ComputeRolePoint`) crashed the core as soon as that character was in a party. Out-of-range skill groups and levels now return 0.
|
||||
- Results (sbtest, 2026-10-17, Mac client, autohunt):
|
||||
- Ship defence (test character): waves 1→3, the hydra dies, chest 9018 spawns, exit to CapeDragonHead in 450 s, the key is used.
|
||||
- Meley (test character): floors 1→10, the chest, exit to map 62 in 1362 s.
|
||||
- Snow ([SA]Admin): floors 1→10, Nemere dies, exit to map 61 in 3303 s. Floors 1/3/4 needed GM `/purge all` (see above). The quest's `item.remove()` takes the whole stack of seal keys 30331/30333 (same in AVA2), so the driver handed them out one at a time.
|
||||
- Party entry ([SA]Admin leads, Test joins): snow, ship and Meley all take both members in, and each member's key is used.
|
||||
- Deploy package: `/root/deploy-features/20261017-lv120` on 203 (`sh deploy.sh check|go|rollback`).
|
||||
- Follow-ups: client models/motions missing for the hydra chest (race 9018), `defensewave_hydra_boss` drop and minihydra `special_attack1`; autohunt is slow on floors with 200+ mobs; the new maps are reachable only by `/warp` (no travel NPC yet); the sash quest is not deployed; `new_quest_lv52` already raises `is_destination_village` Lua errors on live (questlib.lua's `dofile(GFquestlib.lua)` is commented out).
|
||||
@@ -1,6 +1,6 @@
|
||||
# PORT batch pickup, v1
|
||||
|
||||
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) added for the switchbot. No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
|
||||
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) (char.cpp; first added for the v1 switchbot, which no longer uses it). No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
|
||||
|
||||
## Rules
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ MTF1 end REQUEST ROW_COUNT
|
||||
MTF1 error REQUEST ERROR
|
||||
```
|
||||
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 switchbot (separate `/mt_switchbot` / `MTSB1` protocol, see FEATURE-SWITCHBOT.md), 256 world bosses (see FEATURE-BOSS-TRACK.md). The current mask is 511. Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 was the v1 switchbot (`/mt_switchbot` / `MTSB1`) and is no longer advertised, because the AVA2 switchbot uses its own packets (FEATURE-SWITCHBOT.md), 256 world bosses (see FEATURE-BOSS-TRACK.md). The current mask is 959. Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
|
||||
Each drop/chest/source page contains at most 8 rows, with consecutive absolute indices. TOTAL is capped at 4096; stats are one complete bounded snapshot (currently the named keys in kPortStats, less than 128). Client commits only a complete, matching begin/rows/end sequence. Unknown/stale request IDs cannot overwrite the current selection. Each line is bounded below 512 bytes; rows contain IDs and values, not server-provided script/names/markup.
|
||||
|
||||
@@ -39,7 +39,7 @@ Rules:
|
||||
|
||||
| RULE | Meaning of MIN/MAX and weights |
|
||||
|---|---|
|
||||
| 0 | rank common drop; MIN/MAX = eligible player levels |
|
||||
| 0 | rank common drop (common_drop_item.txt) or level-range common drop (common_drop_new.txt, MIN/MAX clipped to monster level ±20); MIN/MAX = eligible player levels |
|
||||
| 1 | independent monster drop group; weight is original configured threshold, not final probability |
|
||||
| 2 | weighted kill group; MIN = original kill-per-drop parameter; weight/group total describe the conditional selection |
|
||||
| 3 | level group; MIN = player minimum level; original denominator 1,000,000 |
|
||||
|
||||
+68
-74
@@ -1,93 +1,87 @@
|
||||
# PORT switchbot (automatic attribute change), v1
|
||||
# PORT switchbot (自动洗练), AVA2 port
|
||||
|
||||
AVA2-style automatic rerolling (reference: AVA2 `new_switchbot.cpp` / `uiswitchbot.py`), rebuilt so that the server stays authoritative and the existing reroll path is unchanged. Source: `src/server/game/src/port_switchbot.h`, command `mt_switchbot` (cmd.cpp), quiet-INFO hook in `CHARACTER::ChatPacket` (char.cpp), fields in char.h. No attribute lock, no DB schema, no packet header, no P2P transfer.
|
||||
AVA2 `ENABLE_SWITCHBOT` ported 1:1 (reference: AVA2 `game/src/new_switchbot.{h,cpp}`, client `PythonSwitchbot.cpp` and `root/uiswitchbot.py`). Classes, API, packets, the window and the 0.1 s roll speed are AVA2's. It replaces the v1 `/mt_switchbot` chat protocol (`MTSB1`, query capability bit 64). That command and its lock verb are gone.
|
||||
|
||||
## Rules
|
||||
Source:
|
||||
- `src/server/game/src/port_switchbot.{h,cpp}`: `SwitchbotHelper`, `CSwitchbot`, `CSwitchbotManager`, `PortSwitchbotBoot`.
|
||||
- `common/length.h`: `SWITCHBOT = 7` in `EWindows` (GROUND is now 8), `SWITCHBOT_SLOT_COUNT 6 / _REAL 5 / ALTERNATIVE_COUNT 2 / NORM_ATTR_NUM 5`, `TItemPos::IsSwitchbotPosition`.
|
||||
- `common/tables.h`: the switchbot tables.
|
||||
|
||||
- Each roll calls the original `CHARACTER::UseItem(scroll cell, target cell)`. All checks, probabilities, the addon handling, `ItemLog CHANGE_ATTRIBUTE` and scroll consumption are the manual path's. That includes the 71151/76023 restriction (weapon/body, level limit <= 40) and the GM quest flag. A roll counts only when exactly one scroll of the chosen vnum was consumed. Otherwise the bot stops with `rejected` and resends the original INFO line once.
|
||||
- The per-roll INFO lines (`属性已变更`) are held back while the bot calls UseItem (`m_portQuietInfo`); all other chat types pass through.
|
||||
- Only `ITEM_USE / USE_CHANGE_ATTRIBUTE` scrolls are accepted. `USE_CHANGE_ATTRIBUTE2` has no handler in this server's UseItemEx.
|
||||
- Target item: inventory cell, not costume, attribute set != -1, at least one attribute, not equipped or in an exchange. It is bound by item ID.
|
||||
- One bot per character. One roll every 250 ms (`PASSES_PER_SEC(1)/4`). Limit 1..1000 rolls.
|
||||
- Targets: up to 2 alternatives, each 1..5 distinct (apply, minimum). An alternative matches when every target is found among the 5 normal attribute slots with value >= minimum. Any matching alternative stops the bot (AVA2 CheckItem semantics). The bot also checks before it starts, so an item that already matches consumes nothing.
|
||||
- Allowed targets are the applies the attribute table can roll for this item's set, excluding the item's base proto applies. The maximum is `lValues[min(maxLevelBySet,5)-1]`. Items with an addon type also allow skill damage 30 / normal hit 65, the item_addon bounds.
|
||||
- Every tick re-checks the state and stops with a reason. This replaces AVA2's hooks into every move/trade path.
|
||||
- Character gone, VID changed (logout or warp) or descriptor lost: the bot is erased silently.
|
||||
- `busy`: dead, warping, `!CanHandleItem()`, exchange, own shop, shop, safebox or cube open.
|
||||
- `item_gone`: the item is missing, has another owner, has left the inventory window or is equipped.
|
||||
- `no_scroll`, `limit`, `matched`, `rejected`, `stopped`.
|
||||
- No offline rolling. Rolls stop when the player leaves, and every completed roll has already been saved and logged by the original path.
|
||||
## Window and items
|
||||
|
||||
## Protocol (CHAT_TYPE_COMMAND, version 1)
|
||||
- Items placed in the `SWITCHBOT` window (cells 0..4) are kept in `m_pointsInstant.pSwitchbotItems` and saved with `window = 'SWITCHBOT'`. The db loads, saves and deletes that window with SAFEBOX and DRAGON_SOUL_INVENTORY (three queries in `ClientManagerPlayer.cpp`).
|
||||
- At boot (game cores only), `PortSwitchbotBoot` adds `'SWITCHBOT'` to the `player.item.window` enum if it is missing. The deploy SQL carries the same ALTER.
|
||||
- `MoveItem` only accepts `SwitchbotHelper::IsValidItem` items into the window. That is AVA2's list: weapons, rings, and armour (body, head, shield, wrist, shoes, necklace, earrings, talisman). Cell 5 is rejected. The move hooks send:
|
||||
- `switchbot_error active` when the item is moved out of a running slot;
|
||||
- `switchbot_error invalid` when the item is not valid for the switchbot.
|
||||
- Drop, give, exchange and safebox refuse switchbot cells: the item has to go back to the inventory first. Shops sell only from the inventory.
|
||||
|
||||
Requests (250 ms per-character throttle; tokens <= 10 chars, <= 30 tokens):
|
||||
## Rolling
|
||||
|
||||
```
|
||||
/mt_switchbot 1 attrs CELL
|
||||
/mt_switchbot 1 start CELL SCROLL_VNUM LIMIT N1 (APPLY MIN)*N1 [N2 (APPLY MIN)*N2]
|
||||
/mt_switchbot 1 stop
|
||||
/mt_switchbot 1 status
|
||||
/mt_switchbot 1 lock CELL SLOT (attribute lock, see FEATURE-ATTR-LOCK.md)
|
||||
```
|
||||
- `CSwitchbot::SwitchItems` runs every 0.1 s (`c_fSpeed`). Each active slot takes one switcher per pass.
|
||||
- A slot finishes when one configured alternative fully matches within the first 5 attributes (AVA2 `CheckItem`). An alternative that isn't configured counts as a match.
|
||||
- Deviations from AVA2 (also listed at the top of `port_switchbot.cpp`):
|
||||
- Cell 5 (AVA2's hidden switcher cell) is never used. Switchers come from the inventory, skipping stacks that are being exchanged, locked or sold in the player's shop.
|
||||
- Which switcher is used follows the manual path:
|
||||
- a talisman takes only 71302;
|
||||
- a weapon or body armour with no level limit above 40 takes 71151 / 76023 first;
|
||||
- everything else takes 71084, then 39028.
|
||||
- A slot whose item has no attributes stops instead of rolling.
|
||||
- Every roll is written to ItemLog as `SWITCHBOT`, with the item id as the hint.
|
||||
- End and stop messages are server commands, which the client turns into localized text:
|
||||
- `switchbot_end <slot>`
|
||||
- `switchbot_stop noattr <slot>`
|
||||
- `switchbot_stop nochanger <slot>`
|
||||
|
||||
Replies:
|
||||
The slot is 0-based. AVA2 sent the locale ids `864` / `865` with slot+1.
|
||||
- Leaving the core deletes the table once it has been sent on. A logout that unregisters the last active slot also stops the event.
|
||||
- The attribute list has two pseudo sets after `ATTRIBUTE_SET_MAX_NUM`: 8 = rings (`port_rings.cpp`) and 9 = talismans (`port_pendant.cpp`).
|
||||
- Warp: `CHARACTER::WarpSet` sends the table over P2P (`HEADER_GG_SWITCHBOT 31`, `TPacketGGSwitchbot`) before `GC_WARP`. The target core keeps it, and `EnterGame` re-registers the slots whose item is still there and restarts the event.
|
||||
|
||||
```
|
||||
MTSB1 attrs CELL VNUM COUNT
|
||||
MTSB1 attr INDEX APPLY MAX (COUNT rows, INDEX 0..COUNT-1)
|
||||
MTSB1 attrs_end CELL COUNT
|
||||
MTSB1 state ACTIVE CELL VNUM ROLLS LIMIT SCROLL SCROLLS REASON
|
||||
MTSB1 lock CELL VNUM MASK (after every attrs_end, and as the reply to lock)
|
||||
MTSB1 error VERB CODE
|
||||
```
|
||||
## Protocol
|
||||
|
||||
`REASON` is one of `running matched limit no_scroll item_gone rejected busy stopped idle`. Error codes:
|
||||
Header numbers, subheaders and field order are AVA2's. The structs are `pack(1)`, and their sizes are pinned with `static_assert` in `port_switchbot.cpp` and in the client (`Packet.h`, `PythonSwitchbot.h`).
|
||||
|
||||
| Code | Meaning |
|
||||
| --- | --- |
|
||||
| `rate` | throttled |
|
||||
| `invalid` | malformed |
|
||||
| `item` | no item in that cell |
|
||||
| `equipped` | equipped or in an exchange |
|
||||
| `no_attr` | the item cannot be rerolled |
|
||||
| `scroll` | the scroll is missing or the wrong type |
|
||||
| `target` | the apply is not allowed, above the maximum or a duplicate |
|
||||
| `running` | this character already has a bot |
|
||||
| `busy` | see the busy states above |
|
||||
| Packet | Header | Layout |
|
||||
| --- | --- | --- |
|
||||
| CG | 171, dynamic | `BYTE header, int size, BYTE subheader, BYTE slot` (7) + `START`: `TSwitchbotAttributeAlternativeTable[2]` (15 each) / `STOP` |
|
||||
| GC | 171, dynamic | same 7-byte head + `UPDATE`: `TSwitchbotTable` (220) / `UPDATE_ITEM`: `TSwitchbotUpdateItem` (40: slot, vnum, count, 3 sockets, 7 attributes) / `SEND_ATTRIBUTE_INFORMATION`: `TSwitchbottAttributeTable[n]` (9) |
|
||||
| GG | 31 | `TPacketGGSwitchbot` (223) |
|
||||
|
||||
A state line is pushed after every roll and when the bot stops. When the reason is `item_gone`, CELL and VNUM are 0.
|
||||
CG is registered in `packet_info.cpp` with `Set(..., true)` and GG with `Set(..., false)`. The 40250 base packets are unchanged.
|
||||
|
||||
Capability: the MTF1 cap mask advertises bit 64 (63 -> 127). Clients that don't know it ignore it, and the client also times out to "unsupported" against old servers.
|
||||
**Version gate.** The client is built with `LOCALE_SERVICE_EUROPE`, so every locale sends `CG_CLIENT_VERSION2`. The new client's timestamp is `1215955205 mt20261016`. 203 is a europe locale and checks the version with `atoi`, which still reads 1215955205. Before `EnterGame` sends anything, it checks `SwitchbotHelper::IsClientSupported`, which looks for `mt<date>` in the timestamp with date >= `PORT_SWITCHBOT_CLIENT_VERSION`. An older client sends `1215955205` only and gets no GC_SWITCHBOT packet. It can't fill the window either. (The non-EU branch sends `mt20261016`.)
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/features/test_switchbot.py` compiles the production header against stubs of the UseItem/ChatPacket contract. It covers the allowed list (proto exclusion, set filter, level cap, addon), validation, two alternatives, the already-matched start, quiet INFO, limit, `no_scroll`, `rejected` (INFO resent once), `item_gone`, `busy`, stop/status/idle and silent erase on a VID change.
|
||||
- `tests/features/test_queries.py` was updated for cap mask 127.
|
||||
- FreeBSD build of the whole game target on 203 in `/root/metin2-features-dev` (BINDIR=GAMEDIR=`/root/metin2-features-dev/bin`), log `/root/metin2-features-dev/switchbot-build.log`, with no warnings from the new code. The live `/usr/metin2` binary was not replaced and no service was restarted.
|
||||
- Live test on 2026-10-15. 203 ran an extra core (`/usr/metin2/server/channel5/first`: CHANNEL 5, PORT 13040, P2P 14040, MAP_ALLOW 1 21 41) with its `game` symlinked to the isolated binary. The macOS native client (`--live-server 192.168.21.203:11000:13040`) drove [SA]Admin, sword 279, scroll 71084:
|
||||
- `attrs` returned 14 rows for the sword (18 for armor 12019), received complete.
|
||||
- limit 10 → `limit` after 10 rolls. State lines arrived about every 0.24 s (about 4 rolls/s); the scroll count fell 200 → 190.
|
||||
- Two alternatives with minimum 1 → `matched` after 18 rolls.
|
||||
- Start on an item that already matches → `matched` with 0 rolls and no scroll used.
|
||||
- Moving the item 33 → 90 mid-run → the run continued, the state line reported cell 90, and `stop` → `stopped`.
|
||||
- Client exit mid-run (8 rolls) → `log.log` stopped at the exit second. The CHANGE_ATTRIBUTE row count (72 = 10+18+12+12+12+8) stayed the same 20 s later.
|
||||
- Opening a private shop mid-run → `busy` about 1 s after the shop opened (6 rolls). The character needs a shop bundle (50200 or 71049); without one `OpenMyShop` returns before setting `m_pkMyShop`, so no shop opens and the bot correctly keeps rolling.
|
||||
- 76014 with 6 scrolls and limit 10 → `no_scroll` after 6 rolls.
|
||||
- 71151 on the level-90 sword (the original path allows limit level <= 40) → `rejected` with 0 rolls and the scroll kept.
|
||||
- Every roll wrote one `CHANGE_ATTRIBUTE` row. The core's syserr shows no new errors; the `new_quest_lv52` LUA_ERROR also appears on the live cores.
|
||||
- Live acceptance on CH1 (13000) after the deploy, sword 279 and scroll 71084:
|
||||
- two alternatives with minimum 1 → `matched` after 2 rolls;
|
||||
- three attributes at the maximum with limit 10 → `limit` after 10 rolls, scrolls 157 → 147;
|
||||
- `stop` after 1 s → `stopped` after 4 rolls.
|
||||
- Not done yet: Android device validation.
|
||||
- `tests/features/test_switchbot.py` checks:
|
||||
- the window enum, headers, subheaders, struct fields and sizes, on both the server and the client;
|
||||
- the window hooks, the P2P hand-over, the boot ALTER and the switcher choice;
|
||||
- the version gate;
|
||||
- that `/mt_switchbot` is gone.
|
||||
- Client: `metin2-client/tests/wiki/test_switchbot.py` checks that the window script is AVA2 `uiswitchbot.py` verbatim, plus its glue.
|
||||
- Live-tested on 203 on 2026-10-16 with the Mac client and a script driver. Weapons ran on channel5 against the live db. Rings and talismans ran on the isolated sbtest cluster (`metin2-client/tools/server/sbtest`), which has the unlocked protos. Results:
|
||||
- Move in, drag back, start/stop, auto-finish on target, refusal to move out while active, refusal of an invalid item; about 12 rolls/s, ItemLog matches the switchers consumed.
|
||||
- Rings roll from the ring pool with 71084; talismans roll from the talisman pool with 71302 only.
|
||||
- Relog keeps the items (from the db cache, and from MySQL after a restart). The bot stops and the targets are cleared, as in AVA2 (`UnregisterItem` on logout).
|
||||
- Same-core map change (1 → 21 → 1) keeps rolling with the targets kept; it only pauses during the warp.
|
||||
- Cross-core map hand-over was not tested in that initial run; see the later dual-core acceptance below.
|
||||
- The initial 2026-10-16 deployment note is superseded: on 2026-10-17 the live binary was confirmed to contain CSwitchbotManager/switchbot_end and the SWITCHBOT DB window. This does not deploy the later sbtest changes or prove live cross-channel operation.
|
||||
|
||||
## Production deployment
|
||||
## 2026-10-18 补充验收
|
||||
|
||||
- 2026-10-15 14:51, approved by the user. The 203 live cores now run main `3b7e158` (`game` sha256 `0d798ec0…`, the binary the channel-5 core was tested with). The db binary is unchanged. Live `/usr/metin2/src` was at `4577d86`, so the deploy also shipped `1a36719` (query protocol and calendar drop gates; the gates stay inert without `port_events.tsv`).
|
||||
- Package `/root/deploy-features/20261015-features` (`deploy.sh check|go|rollback`, `SHA256SUMS`). The previous `game`/`db` are in `/root/backup-bin/20261015-145122` (recorded in `LAST_BACKUP`), and the replaced `/usr/metin2/src` files are in `src-before/`. `sh deploy.sh rollback` restores both.
|
||||
- The first `go` stopped at `rebuild.sh stop_server` ("server still running" after about 38 s, cores still exiting) before any backup or copy; the second `go` succeeded. `start.sh` was answered with `1`, which starts only CH1 and game99, so CH2–CH4 were started afterwards with each `run.sh` in the `start.sh` order. The channel-5 test core was restarted too, giving the pre-deploy layout of 14 cores plus db and auth. The new syserr entries contain only the existing `new_quest_lv52` LUA_ERROR (present since 2026-09-21).
|
||||
独立 sbtest 的 QA1017,武器起初无类型9;所有备选均只设释放速度9≥1。未手动停止,实际消耗13个71084后,最终含 (9,10),active=0、finished=1,约1.315秒。客户端证据 switchbot-cast-natural.json。跨频道换线仍未验收,不能将本项扩大解释为全部洗练场景通过。
|
||||
|
||||
## Open items
|
||||
## 双核心地图传送验收
|
||||
|
||||
- Attribute lock: done separately in `FEATURE-ATTR-LOCK.md` (table `mt_item_attr_lock`, applied inside `CItem::ChangeAttribute`, so every bot roll keeps the locked slots). The bot's own item cannot be locked or unlocked while it rolls.
|
||||
- In 203 `player.item_proto`, 71084, 71151, 76014, 76023 and 39028 are USE/USE_CHANGE_ATTRIBUTE (subtype 18); 71302 (the AVA2 talisman scroll) does not exist. The bot accepts any `USE_CHANGE_ATTRIBUTE` scroll and leaves item rules to the original path.
|
||||
2026-10-18:临时测试核心13040/P2P14040载入地图1/62,独立13041/P2P14041载入地图61,均为频道5、仅连接db15040。原生追踪传送1→61→62,两次跨核心日志确认;两边均 active=1、两个备选目标相同,第4条锁定属性 (4,6) 不变,71084总数2069→1811→1595。已停止洗练、退回物品并解锁。
|
||||
|
||||
验收后恢复 channel5/first 原CONFIG(逐字节核对),关闭辅助核心并重启sbtest,QA1017离线位置恢复主城。生产game仍为40335e41…,正式服配置未改。日志和配置备份在 /root/deploy-features/20261018-ava2-parity/crosscore;不向版本库提交CONFIG或凭据。
|
||||
|
||||
此项仅验证同频道跨核心地图传送。该次测试时客户端换线仍使用退出重登;后续原生跨频道验收见下节。
|
||||
|
||||
## 原生跨频道续洗验收
|
||||
|
||||
2026-10-18,sbtest临时频道5:13040和频道6:13050均仅加载地图1。按 AVA2 启用的 do_cmd→MoveChannel、MoveChannelDialog 完成5→6→5,无额外人工查询辅助,active全程为1、两套目标表相同,第4条锁定属性 (4,6) 保持,71084总数1034→976→919。往返后主动停止,武器返回背包159格并解锁,数据库锁表记录为0。
|
||||
|
||||
同频道、未开放频道、倒计时取消和任务选择中拒绝均通过;另测换到6后退出重登仍在6/auth11040,回5后关闭辅助核心,列表只剩5且拒绝旧目标6。详见 FEATURE-AVA2-NATIVE-CHANNEL.md。恢复两个原CONFIG并关闭辅助核心,sbtest已重启;正式服game仍40335e41…,本轮换线没有正式部署,Android真机按用户要求暂停。
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# PORT VIP card
|
||||
|
||||
A card extends all seven original premium services of the account. 40250 has the services but no in-game way to grant them. Source: `src/server/game/src/port_premium.h`, the hook in `CHARACTER::UseItem` (char_item.cpp), the enter-game refresh in input_login.cpp, `CHARACTER::PortSetPremiumTime` (char.h) and `/mt_vip` (cmd_general.cpp, cmd.cpp). Item data (size, flags, names, shop): metin2-client `tools/server/vip-card`.
|
||||
|
||||
## Services
|
||||
|
||||
`account.account` holds one end time per service. The game keeps them in `m_aiPremiumTimes` and shows affect `AFFECT_PREMIUM_START + i` (500..506) as the icon.
|
||||
|
||||
| i | Premium | Column | Effect on newcibn |
|
||||
|---|---|---|---|
|
||||
| 0 | `PREMIUM_EXP` | `silver_expire` | monster exp ×1.2 × `mob_exp_buyer`/100 (char_battle.cpp) |
|
||||
| 1 | `PREMIUM_ITEM` | `gold_expire` | item drop rate |
|
||||
| 2 | `PREMIUM_SAFEBOX` | `safebox_expire` | safebox size 3 (input_db.cpp) |
|
||||
| 3 | `PREMIUM_AUTOLOOT` | `autoloot_expire` | gold goes straight to the bag (char_battle.cpp) |
|
||||
| 4 | `PREMIUM_FISH_MIND` | `fish_mind_expire` | fishing |
|
||||
| 5 | `PREMIUM_MARRIAGE_FAST` | `marriage_fast_expire` | marriage love points |
|
||||
| 6 | `PREMIUM_GOLD` | `money_drop_rate_expire` | gold drop rate |
|
||||
|
||||
## Cards
|
||||
|
||||
| Vnum | Days |
|
||||
|---|---|
|
||||
| 38001 | 7 |
|
||||
| 38002 | 30 |
|
||||
|
||||
Both are unused `ITEM_NONE` rows in 40250. `PortVipUseCard` runs in `UseItem` after the sex check, before any type handling, so the item type does not matter.
|
||||
|
||||
When a card is used:
|
||||
|
||||
1. The card is refused, and not consumed, in two cases:
|
||||
- the player used a card or `/mt_vip` less than 1 s ago (`rate`);
|
||||
- for any service, the remaining time plus the card would exceed 400 days (`full`). The `int` end times stay far below 2038.
|
||||
2. Otherwise one card is consumed, with an `MT_VIP_CARD` item log whose hint is the number of days.
|
||||
3. One `UPDATE` moves every column to `GREATEST(UNIX_TIMESTAMP(col), UNIX_TIMESTAMP()) + days × 86400`. A service that has expired restarts from now; a running one is extended.
|
||||
|
||||
## Freshness
|
||||
|
||||
Auth reads the columns only at login and passes them to the db core's `CLoginData`. Every later player load, such as a warp or a core change, fills `TPlayerTable.aiPremiumTimes` from that login-time copy. So after a card, and on every enter-game, the game reads the row itself.
|
||||
|
||||
`PortVipRefresh` handles this:
|
||||
- It queues `SELECT UNIX_TIMESTAMP(col)... FROM account.account WHERE id=` through `DBManager::FuncQuery`. That is the same ordered queue and connection as the card's `UPDATE`, so the read sees the update.
|
||||
- The answer finds the player again by PID and checks the account ID; if the player has left, nothing happens.
|
||||
- For each service whose end changed, it sets `m_aiPremiumTimes[i]`, then either adds the affect with the remaining duration or removes it if the service has expired.
|
||||
- It logs `PORT_VIP: <name> type <i> end <unix>`.
|
||||
|
||||
The db core is not changed.
|
||||
|
||||
## Protocol
|
||||
|
||||
```
|
||||
/mt_vip 1 status ask for the remaining time
|
||||
MTVIP1 times R0 R1 R2 R3 R4 R5 R6 remaining seconds per service (0 = none), PREMIUM_EXP .. PREMIUM_GOLD
|
||||
MTVIP1 added VNUM DAYS a card was consumed; a times line follows once the row is read back
|
||||
MTVIP1 error CODE rate full invalid
|
||||
```
|
||||
|
||||
- `status` and card use share the 1 s throttle per player.
|
||||
- A wrong version, or more than three tokens, gets no answer; an old client never sends one.
|
||||
- The client (metin2-client `src/platform/ScriptLib/VipScript.inc`, module `mt_vip`) treats a `status` with no answer within 3 s as a server without the feature.
|
||||
|
||||
## Exp bonus
|
||||
|
||||
On newcibn the premium exp branch multiplies by 1.2 and then by `GetMobExpRate`, which returns event flag `mob_exp_buyer` (default 100). `/e mob_exp_buyer 167` gives 1.2 × 1.67 ≈ 2.0, that is +100 %. Event flags live in `player.quest` (pid 0) and every core shares them, so the flag is set once, by a GM, at deploy.
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/features/test_vip.py` checks the wiring:
|
||||
- the command entry is at the end of `cmd_info`;
|
||||
- the include is outside the `__AUCTION__` block;
|
||||
- the hook sits between the sex check and the summon-item block;
|
||||
- the refresh runs after the login affect loop.
|
||||
- It also compiles the production header against a stub account table, the ordered SQL queue and the affects. It covers:
|
||||
- a 7-day card, the read-back and the icons;
|
||||
- the gap refusal, then a 30-day card stacked onto the current end;
|
||||
- the 400-day cap: no card consumed, no query;
|
||||
- other items left untouched;
|
||||
- the enter-game refresh over stale values;
|
||||
- a service expired by hand, and the `status` command;
|
||||
- a player who leaves before the answer, and a missing account row.
|
||||
- Live test, channel5 (2026-10-15), Admin account with all expire values reset to 0:
|
||||
- 38002 (30 days) set all seven columns to now + 30 days, added affects 500..506 and returned `times 2592000…`.
|
||||
- Two 38001 used through the inventory right-click, 2 s apart, extended to 44 days.
|
||||
- A same-map `/warp` reloaded the player with the login-time 30 days. The refresh logged the seven `PORT_VIP` corrections to 44 days, and the panel showed "剩余 43 天 23 小时" for every service.
|
||||
- Earlier, with premium, autoloot gold went straight to the bag; without it, the gold stayed on the ground.
|
||||
|
||||
## Production deployment
|
||||
|
||||
- Deployed 2026-10-16 (server clock 2026-10-15 20:44) with the user's approval, 0 players online. Server main 69e335b, which includes the `/m` command-prefix fix 3590a06. Game sha256 `8d0bf9f0…` (the channel-5 tested binary); db unchanged.
|
||||
- Package: `/root/deploy-features/20261016-vip` (metin2-client `tools/server` at main 32372c2a).
|
||||
- Binary backup: `/root/backup-bin/20261015-204352`.
|
||||
- Rollback: `sh /root/deploy-features/20261016-vip/deploy.sh rollback`. The data backups are in `/root/backup-vip-card/20261015-204353` and `/root/backup-npcshop/item_mall-20261015-204353`.
|
||||
- `/usr/metin2/src` was synced with the six changed files.
|
||||
- `deploy.sh go` stops every core, then installs the game. It runs `vip-card/install.sh` and the item-mall shop install while the db core is down, since db reads `item_proto.txt` at boot. Then it starts db alone, waits for port 15000, and starts auth, CH1–CH4, game99 and channel5: 14 game, 1 db, 1 auth.
|
||||
- At boot the db core rewrites `player.item_proto` from the txt, with `locale_name` `Noname` for every item; names come from `item_names.txt`. Both cards: size 1, flag 8196, antiflag 256.
|
||||
- `/e mob_exp_buyer 167` was set from CH1. Every core logged `QUEST eventflag mob_exp_buyer 167`, and the row is in `player.quest` (pid 0).
|
||||
- CH1 (13000) acceptance:
|
||||
- `/m 101` spawned and `/purge` removed it.
|
||||
- 9010 (map a1) lists 38001/38002. A buyer from another empire pays the original triple price (shop.cpp), 15 000 000 for a 7-day card.
|
||||
- Two 38001 bought: each takes one cell (a shop buy never merges), and dragging one onto the other gives a stack of 2.
|
||||
- Using one: `added 38001 7`, then `times 4400055…`. The panel shows 50 days 22 hours for all seven services.
|
||||
- syserr only has the pre-existing `new_quest_lv52` LUA_ERROR.
|
||||
@@ -76,6 +76,8 @@ enum EItemTypes
|
||||
ITEM_SECONDARY_COIN, //32 ?? 명도전??
|
||||
ITEM_RING, //33 반지
|
||||
ITEM_BELT, //34 벨트
|
||||
ITEM_SHINING, //35 AVA2 shining (not ported, keeps the AVA2 numbering)
|
||||
ITEM_NEW_RINGS, //36 AVA2 new rings (port_rings.cpp), worn in WEAR_RINGS_1/2
|
||||
};
|
||||
|
||||
enum EMetinSubTypes
|
||||
@@ -106,6 +108,7 @@ enum EArmorSubTypes
|
||||
ARMOR_FOOTS,
|
||||
ARMOR_NECK,
|
||||
ARMOR_EAR,
|
||||
ARMOR_PENDANT, // 7 AVA2 talisman (ITEM_TALISMAN_EQUIPMENT), worn in WEAR_PENDANT
|
||||
ARMOR_NUM_TYPES
|
||||
};
|
||||
|
||||
@@ -113,6 +116,9 @@ enum ECostumeSubTypes
|
||||
{
|
||||
COSTUME_BODY = ARMOR_BODY, // [중요!!] ECostumeSubTypes enum value는 종류별로 EArmorSubTypes의 그것과 같아야 함.
|
||||
COSTUME_HAIR = ARMOR_HEAD, // 이는 코스츔 아이템에 추가 속성을 붙이겠다는 사업부의 요청에 따라서 기존 로직을 활용하기 위함임.
|
||||
COSTUME_MOUNT = 2, // AVA2 mount costume (value0 = horse race)
|
||||
COSTUME_SASH = 3, // AVA2 sash (85001..85024)
|
||||
COSTUME_MOUNT_SKIN = 4, // AVA2 mount skin (value0 = horse race, needs COSTUME_MOUNT)
|
||||
COSTUME_NUM_TYPES,
|
||||
};
|
||||
|
||||
@@ -368,4 +374,30 @@ enum ERefineType
|
||||
REFINE_TYPE_BDRAGON,
|
||||
};
|
||||
|
||||
// AVA2 sash: combine two sashes of one grade into the next grade / absorb a weapon or body armor.
|
||||
enum ESashInfo
|
||||
{
|
||||
SASH_GRADE_VALUE_FIELD = 0, // item value0 = grade 1..4
|
||||
SASH_ABSORPTION_SOCKET = 0, // socket0 = absorption %
|
||||
SASH_ABSORBED_SOCKET = 1, // socket1 = vnum of the absorbed item
|
||||
SASH_GRADE_1_ABS = 1,
|
||||
SASH_GRADE_2_ABS = 5,
|
||||
SASH_GRADE_3_ABS = 10,
|
||||
SASH_GRADE_4_ABS_MIN = 11,
|
||||
SASH_GRADE_4_ABS_MAX = 25,
|
||||
SASH_GRADE_4_ABS_MAX_COMB = 19,
|
||||
SASH_GRADE_4_ABS_RANGE = 5,
|
||||
SASH_EFFECT_FROM_ABS = 19,
|
||||
SASH_CLEAN_ATTR_VALUE0 = 7,
|
||||
SASH_WINDOW_MAX_MATERIALS = 2,
|
||||
SASH_GRADE_1_PRICE = 100000,
|
||||
SASH_GRADE_2_PRICE = 200000,
|
||||
SASH_GRADE_3_PRICE = 300000,
|
||||
SASH_GRADE_4_PRICE = 500000,
|
||||
SASH_COMBINE_GRADE_1 = 80,
|
||||
SASH_COMBINE_GRADE_2 = 70,
|
||||
SASH_COMBINE_GRADE_3 = 50,
|
||||
SASH_COMBINE_GRADE_4 = 30,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -137,6 +137,12 @@ enum EWearPositions
|
||||
WEAR_RING2, // 22 : 신규 반지슬롯2 (오른쪽)
|
||||
|
||||
WEAR_BELT, // 23 : 신규 벨트슬롯
|
||||
WEAR_COSTUME_SASH, // 24 : AVA2 sash
|
||||
WEAR_COSTUME_MOUNT, // 25 : AVA2 mount costume
|
||||
WEAR_COSTUME_MOUNT_SKIN, // 26 : AVA2 mount skin
|
||||
WEAR_PENDANT, // 27 : AVA2 talisman (ARMOR_PENDANT)
|
||||
WEAR_RINGS_1, // 28 : AVA2 new ring (ITEM_NEW_RINGS)
|
||||
WEAR_RINGS_2, // 29 : AVA2 new ring
|
||||
|
||||
WEAR_MAX = 32 //
|
||||
};
|
||||
@@ -247,6 +253,7 @@ enum EParts
|
||||
PART_WEAPON,
|
||||
PART_HEAD,
|
||||
PART_HAIR,
|
||||
PART_SASH,
|
||||
|
||||
PART_MAX_NUM,
|
||||
PART_WEAPON_SUB,
|
||||
@@ -437,6 +444,18 @@ enum EApplyTypes
|
||||
APPLY_ANTI_PENETRATE_PCT, //91 관통타격 저항
|
||||
|
||||
|
||||
// PORT AVA2 bonus numbering (AVA2 common/length.h): 92-138 are AVA2 applies not ported yet,
|
||||
// kept free so later ports and the client item_proto keep AVA2's numbers.
|
||||
// AVA2 ELEMENT_NEW_BONUSES: attack bonus % against monsters of the element (RACE_FLAG_ATT_*), on the talismans.
|
||||
APPLY_ENCHANT_ELEC = 123,
|
||||
APPLY_ENCHANT_FIRE = 124,
|
||||
APPLY_ENCHANT_ICE = 125,
|
||||
APPLY_ENCHANT_WIND = 126,
|
||||
APPLY_ENCHANT_EARTH = 127,
|
||||
APPLY_ENCHANT_DARK = 128,
|
||||
APPLY_ATTBONUS_STONE = 139,
|
||||
APPLY_ATTBONUS_BOSS = 140,
|
||||
|
||||
MAX_APPLY_NUM, //
|
||||
};
|
||||
|
||||
@@ -455,6 +474,21 @@ enum EOnIdleEvents
|
||||
ON_IDLE_MAX_NUM
|
||||
};
|
||||
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT (port_switchbot.cpp). Slot 5 is AVA2's hidden scroll cell; this port keeps
|
||||
// the table width but never stores an item there.
|
||||
enum SwitchbotValues
|
||||
{
|
||||
SWITCHBOT_SLOT_COUNT = 6,
|
||||
SWITCHBOT_SLOT_COUNT_REAL = 5,
|
||||
SWITCHBOT_ALTERNATIVE_COUNT = 2,
|
||||
SWITCHBOT_NORM_ATTR_NUM = 5, // AVA2 MAX_NORM_ATTR_NUM
|
||||
//1 = Switching Item
|
||||
//2 = Yang
|
||||
SWITCHBOT_PRICE_TYPE = 1,
|
||||
//Amount Swtichting Items the Yang-Price
|
||||
SWITCHBOT_PRICE_AMOUNT = 1,
|
||||
};
|
||||
|
||||
enum EWindows
|
||||
{
|
||||
RESERVED_WINDOW,
|
||||
@@ -464,6 +498,7 @@ enum EWindows
|
||||
MALL,
|
||||
DRAGON_SOUL_INVENTORY,
|
||||
BELT_INVENTORY,
|
||||
SWITCHBOT, // PORT: 7 = player.item.window enum 'SWITCHBOT' (appended after BELT_INVENTORY)
|
||||
#ifdef __AUCTION__
|
||||
AUCTION,
|
||||
#endif
|
||||
@@ -670,6 +705,8 @@ enum SPECIAL_EFFECT
|
||||
SE_EQUIP_HALLOWEEN_CANDY, // 할로윈 사탕을 착용(-_-;)한 순간에 발동하는 이펙트
|
||||
SE_EQUIP_HAPPINESS_RING, // 크리스마스 행복의 반지(71143) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EQUIP_LOVE_PENDANT, // 발렌타인 사랑의 팬던트(71145) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||
SE_EFFECT_SASH_SUCCEDED, // AVA2 sash combine success
|
||||
SE_EFFECT_SASH_EQUIP,
|
||||
} ;
|
||||
|
||||
enum ETeenFlags
|
||||
@@ -736,6 +773,8 @@ typedef struct SItemPos
|
||||
return cell < INVENTORY_AND_EQUIP_SLOT_MAX;
|
||||
case DRAGON_SOUL_INVENTORY:
|
||||
return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
|
||||
case SWITCHBOT:
|
||||
return cell < SWITCHBOT_SLOT_COUNT;
|
||||
// 동적으로 크기가 정해지는 window는 valid 체크를 할 수가 없다.
|
||||
case SAFEBOX:
|
||||
case MALL:
|
||||
@@ -775,6 +814,11 @@ typedef struct SItemPos
|
||||
return INVENTORY == window_type && cell < INVENTORY_MAX_NUM;
|
||||
}
|
||||
|
||||
bool IsSwitchbotPosition() const
|
||||
{
|
||||
return SWITCHBOT == window_type && cell < SWITCHBOT_SLOT_COUNT;
|
||||
}
|
||||
|
||||
bool operator==(const struct SItemPos& rhs) const
|
||||
{
|
||||
return (window_type == rhs.window_type) && (cell == rhs.cell);
|
||||
|
||||
@@ -1484,5 +1484,51 @@ typedef struct SChannelStatus
|
||||
BYTE bStatus;
|
||||
} TChannelStatus;
|
||||
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT tables (port_switchbot.cpp). TSwitchbotTable goes to the client as is
|
||||
// (SUBHEADER_GC_SWITCHBOT_UPDATE) and between cores (HEADER_GG_SWITCHBOT): 220 bytes.
|
||||
struct TSwitchbotAttributeAlternativeTable
|
||||
{
|
||||
TPlayerItemAttribute attributes[SWITCHBOT_NORM_ATTR_NUM];
|
||||
|
||||
bool IsConfigured() const
|
||||
{
|
||||
|
||||
for (BYTE i = 0; i < SWITCHBOT_NORM_ATTR_NUM; ++i)
|
||||
{
|
||||
if (attributes[i].bType && attributes[i].sValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct TSwitchbotTable
|
||||
{
|
||||
DWORD player_id;
|
||||
bool active[SWITCHBOT_SLOT_COUNT];
|
||||
bool finished[SWITCHBOT_SLOT_COUNT];
|
||||
DWORD items[SWITCHBOT_SLOT_COUNT];
|
||||
TSwitchbotAttributeAlternativeTable alternatives[SWITCHBOT_SLOT_COUNT][SWITCHBOT_ALTERNATIVE_COUNT];
|
||||
|
||||
TSwitchbotTable() : player_id(0)
|
||||
{
|
||||
memset(&items, 0, sizeof(items));
|
||||
memset(&alternatives, 0, sizeof(alternatives));
|
||||
memset(&active, false, sizeof(active));
|
||||
memset(&finished, false, sizeof(finished));
|
||||
}
|
||||
};
|
||||
|
||||
// PORT: AVA2 declares max_value as long; int keeps the 4-byte wire width the client mirrors with LONG.
|
||||
struct TSwitchbottAttributeTable
|
||||
{
|
||||
BYTE attribute_set;
|
||||
int apply_num;
|
||||
int max_value;
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
@@ -322,8 +322,8 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
{
|
||||
snprintf(szQuery, sizeof(szQuery),
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)",
|
||||
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d)",
|
||||
GetTablePostfix(), pTab->id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
||||
|
||||
CDBManager::instance().ReturnQuery(szQuery,
|
||||
QID_ITEM,
|
||||
@@ -379,8 +379,8 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
|
||||
//--------------------------------------------------------------
|
||||
snprintf(queryStr, sizeof(queryStr),
|
||||
"SELECT id,window+0,pos,count,vnum,socket0,socket1,socket2,attrtype0,attrvalue0,attrtype1,attrvalue1,attrtype2,attrvalue2,attrtype3,attrvalue3,attrtype4,attrvalue4,attrtype5,attrvalue5,attrtype6,attrvalue6 "
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)",
|
||||
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
"FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d)",
|
||||
GetTablePostfix(), packet->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
||||
CDBManager::instance().ReturnQuery(queryStr, QID_ITEM, peer->GetHandle(), new ClientHandleInfo(dwHandle, packet->player_id));
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -1132,7 +1132,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM player%s WHERE id=%d", GetTablePostfix(), pi->player_id);
|
||||
delete CDBManager::instance().DirectQuery(queryStr);
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM item%s WHERE owner_id=%d AND (window < %d or window = %d)", GetTablePostfix(), pi->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY);
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM item%s WHERE owner_id=%d AND (window < %d or window = %d or window = %d)", GetTablePostfix(), pi->player_id, SAFEBOX, DRAGON_SOUL_INVENTORY, SWITCHBOT);
|
||||
delete CDBManager::instance().DirectQuery(queryStr);
|
||||
|
||||
snprintf(queryStr, sizeof(queryStr), "DELETE FROM quest%s WHERE dwPID=%d", GetTablePostfix(), pi->player_id);
|
||||
|
||||
@@ -79,6 +79,7 @@ int get_Item_Type_Value(string inputString)
|
||||
|
||||
"ITEM_RING",
|
||||
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
|
||||
"ITEM_SHINING", "ITEM_NEW_RINGS", // AVA2 35 (not ported), 36 new rings
|
||||
};
|
||||
|
||||
|
||||
@@ -103,7 +104,7 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
|
||||
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
|
||||
static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
|
||||
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
|
||||
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_PENDANT", "ARMOR_NUM_TYPES"};
|
||||
static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT",
|
||||
"USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR",
|
||||
"USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET",
|
||||
@@ -122,7 +123,7 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
"RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
|
||||
static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5",
|
||||
"UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};
|
||||
static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR" };
|
||||
static string arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };
|
||||
static string arSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
|
||||
static string arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
|
||||
|
||||
@@ -161,6 +162,8 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
0, //32
|
||||
0, //33 반지
|
||||
0, //34 벨트
|
||||
0, //35 ITEM_SHINING
|
||||
0, //36 ITEM_NEW_RINGS
|
||||
};
|
||||
static int arNumberOfSubtype[_countof(arSubType)] = {
|
||||
0,
|
||||
@@ -198,6 +201,8 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
||||
0, // 32
|
||||
0, // 33 반지
|
||||
0, // 34 벨트
|
||||
0, // 35
|
||||
0, // 36
|
||||
};
|
||||
|
||||
|
||||
@@ -393,6 +398,14 @@ int get_Item_ApplyType_Value(string inputString)
|
||||
"APPLY_EXTRACT_HP_PCT", "APPLY_RESIST_WARRIOR", "APPLY_RESIST_ASSASSIN", "APPLY_RESIST_SURA", "APPLY_RESIST_SHAMAN",
|
||||
"APPLY_ENERGY", "APPLY_DEF_GRADE", "APPLY_COSTUME_ATTR_BONUS", "APPLY_MAGIC_ATTBONUS_PER", "APPLY_MELEE_MAGIC_ATTBONUS_PER",
|
||||
"APPLY_RESIST_ICE", "APPLY_RESIST_EARTH", "APPLY_RESIST_DARK", "APPLY_ANTI_CRITICAL_PCT", "APPLY_ANTI_PENETRATE_PCT",
|
||||
// PORT AVA2 numbering: 92-138 not ported yet (common/length.h)
|
||||
"APPLY_RESERVED_92", "APPLY_RESERVED_93", "APPLY_RESERVED_94", "APPLY_RESERVED_95", "APPLY_RESERVED_96", "APPLY_RESERVED_97", "APPLY_RESERVED_98", "APPLY_RESERVED_99",
|
||||
"APPLY_RESERVED_100", "APPLY_RESERVED_101", "APPLY_RESERVED_102", "APPLY_RESERVED_103", "APPLY_RESERVED_104", "APPLY_RESERVED_105", "APPLY_RESERVED_106", "APPLY_RESERVED_107",
|
||||
"APPLY_RESERVED_108", "APPLY_RESERVED_109", "APPLY_RESERVED_110", "APPLY_RESERVED_111", "APPLY_RESERVED_112", "APPLY_RESERVED_113", "APPLY_RESERVED_114", "APPLY_RESERVED_115",
|
||||
"APPLY_RESERVED_116", "APPLY_RESERVED_117", "APPLY_RESERVED_118", "APPLY_RESERVED_119", "APPLY_RESERVED_120", "APPLY_RESERVED_121", "APPLY_RESERVED_122", "APPLY_ENCHANT_ELECT",
|
||||
"APPLY_ENCHANT_FIRE", "APPLY_ENCHANT_ICE", "APPLY_ENCHANT_WIND", "APPLY_ENCHANT_EARTH", "APPLY_ENCHANT_DARK", "APPLY_RESERVED_129", "APPLY_RESERVED_130", "APPLY_RESERVED_131",
|
||||
"APPLY_RESERVED_132", "APPLY_RESERVED_133", "APPLY_RESERVED_134", "APPLY_RESERVED_135", "APPLY_RESERVED_136", "APPLY_RESERVED_137", "APPLY_RESERVED_138",
|
||||
"APPLY_ATTBONUS_STONE", "APPLY_ATTBONUS_BOSS",
|
||||
};
|
||||
|
||||
int retInt = -1;
|
||||
|
||||
@@ -61,7 +61,7 @@ CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp
|
||||
desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
|
||||
entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
|
||||
guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp port_attr_lock.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp ava2_channel.cpp new_mob_timer.cpp ava2_track.cpp ava2_ticket_shop.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp port_ava2_dungeon.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
|
||||
locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
|
||||
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||
@@ -123,4 +123,23 @@ tag:
|
||||
dep:
|
||||
makedepend -f Depend $(INCDIR) -I/usr/include/c++/3.3 -I/usr/include/c++/4.2 -p$(OBJDIR)/ $(CPPFILE) $(CFILE) $(MAINCPP) 2> /dev/null > Depend
|
||||
|
||||
# Native AVA2 feature includes are not present in older generated Depend files.
|
||||
$(OBJDIR)/char_item.o: ava2_chest.inc
|
||||
$(OBJDIR)/cmd_general.o: ava2_chest_commands.h ava2_pickup_commands.h
|
||||
|
||||
sinclude Depend
|
||||
|
||||
$(OBJDIR)/cmd_general.o: ava2_track_commands.h
|
||||
|
||||
# New AVA2 includes are absent from old generated Depend files.
|
||||
$(OBJDIR)/new_mob_timer.o $(OBJDIR)/main.o $(OBJDIR)/char_battle.o $(OBJDIR)/char_manager.o $(OBJDIR)/input_db.o $(OBJDIR)/input_p2p.o $(OBJDIR)/cmd_general.o: new_mob_timer.h
|
||||
$(OBJDIR)/ava2_track.o $(OBJDIR)/questlua_dungeon.o $(OBJDIR)/input_db.o $(OBJDIR)/cmd_general.o: ava2_track.h
|
||||
$(OBJDIR)/ava2_ticket_shop.o $(OBJDIR)/shop_manager.o $(OBJDIR)/cmd_general.o: ava2_ticket_shop.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o $(OBJDIR)/ava2_track.o: port_dungeon_settings.h
|
||||
|
||||
$(OBJDIR)/cmd_general.o: ava2_attr_lock_commands.h port_attr_lock.h
|
||||
$(OBJDIR)/questlua_item.o: port_attr_lock.h
|
||||
|
||||
$(OBJDIR)/ava2_channel.o: ava2_channel.h ava2_channel_registry.h
|
||||
$(OBJDIR)/char.o $(OBJDIR)/cmd_general.o $(OBJDIR)/input_p2p.o $(OBJDIR)/p2p.o $(OBJDIR)/input_login.o: ava2_channel.h
|
||||
|
||||
@@ -18,6 +18,7 @@ class CAffect
|
||||
enum EAffectTypes
|
||||
{
|
||||
AFFECT_NONE,
|
||||
AFFECT_AUTO_PICK_UP = 705,
|
||||
|
||||
AFFECT_MOV_SPEED = 200,
|
||||
AFFECT_ATT_SPEED,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// Read-only presentation bridge: this port keeps AVA2 lock indices in an independent table.
|
||||
#include "port_attr_lock.h"
|
||||
#include <sstream>
|
||||
#include "exchange.h"
|
||||
#include "shop.h"
|
||||
#include "safebox.h"
|
||||
// Context IDs are presentation-only, never item window IDs or arbitrary owner IDs.
|
||||
static LPITEM Ava2AttrLockView(LPCHARACTER ch,unsigned view,unsigned cell,unsigned vid) {
|
||||
if (view==101 || view==102) {
|
||||
CExchange* own=ch->GetExchange();
|
||||
if (!own || own->GetOwner()!=ch || !own->GetCompany() || own->GetCompany()->GetCompany()!=own) return NULL;
|
||||
CExchange* side=view==101?own:own->GetCompany();
|
||||
LPITEM item=side->GetDisplayItem(cell);
|
||||
return item && item->GetOwner()==side->GetOwner() && item->IsExchanging()?item:NULL;
|
||||
}
|
||||
if (view==103) return ch->GetShop()?ch->GetShop()->GetGuestItem(ch,cell):NULL;
|
||||
if (view==104 || view==105) {
|
||||
CSafebox* box=view==104?ch->GetSafebox():ch->GetMall();
|
||||
return box && cell<SAFEBOX_MAX_NUM && box->IsValidPosition(cell)?box->Get(cell):NULL;
|
||||
}
|
||||
// do_view_equip is GM-only in the baseline. Never grant this to ordinary players.
|
||||
if (view==106 && ch->GetGMLevel()>GM_PLAYER && cell<WEAR_MAX_NUM) {
|
||||
LPCHARACTER owner=CHARACTER_MANAGER::instance().Find(vid);
|
||||
return owner && owner->IsPC()?owner->GetWear(cell):NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
ACMD(do_attr_lock_info) {
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
unsigned token=0,window=0,cell=0,vid=0;std::string extra;std::istringstream args(argument);
|
||||
if (!(args>>token>>window>>cell) || token>2147483647 || window>255 || cell>65535) return;
|
||||
const bool view=window>=101 && window<=106;
|
||||
if (view ? !(args>>vid) : (window!=INVENTORY && window!=EQUIPMENT && window!=SWITCHBOT)) return;
|
||||
if ((args>>extra) || (window!=106 && vid)) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
const int now=get_global_time();
|
||||
if (ch->GetProtectTime("attr_lock_query")>now) return;
|
||||
ch->SetProtectTime("attr_lock_query",now+1);
|
||||
const TItemPos pos{BYTE(window),WORD(cell)};
|
||||
if (!view && (window==SWITCHBOT ? cell>=SWITCHBOT_SLOT_COUNT : cell>=INVENTORY_AND_EQUIP_SLOT_MAX)) return;
|
||||
LPITEM target=view?Ava2AttrLockView(ch,window,cell,vid):ch->GetItem(pos);int mask=0;
|
||||
if (target && PortAttrFilled(target)) {
|
||||
mask=PortAttrLockEffective(PortAttrLockGet(target),PortAttrFilled(target),target->GetProto() && target->GetProto()->sAddonType);
|
||||
if (!target->m_portAttrLockLoaded) mask=-1; // SQL failure is not an unlocked item.
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"AttrLockInfo %u %u %u %u %d",token,window,cell,target?target->GetVnum():0,mask);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "char.h"
|
||||
#include "desc.h"
|
||||
#include "p2p.h"
|
||||
#include "packet.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_channel.h"
|
||||
#include "ava2_channel_registry.h"
|
||||
static Ava2ChannelRegistry s_channels;
|
||||
void Ava2ChannelTick(){
|
||||
static long next=0;const long now=get_global_time();if(now<next)return;next=now+5;
|
||||
if(g_bChannel<1 || g_bChannel>7)return;
|
||||
const auto payload=Ava2ChannelRegistry::Encode(g_bChannel,mother_port,p2p_port,map_allow_list());
|
||||
if(payload.size()>2048)return;
|
||||
std::string wire(sizeof(TPacketGGRelay),'\0');auto* head=reinterpret_cast<TPacketGGRelay*>(&wire[0]);
|
||||
head->bHeader=HEADER_GG_RELAY;strlcpy(head->szName,"#ava2_channels",sizeof(head->szName));head->lSize=payload.size();
|
||||
wire+=payload;P2P_MANAGER::instance().Send(wire.data(),wire.size());
|
||||
}
|
||||
bool Ava2ChannelRelay(LPDESC d,const char* name,const char* data,long size){
|
||||
if(strcmp(name,"#ava2_channels"))return false;
|
||||
if(!s_channels.Receive(d->GetP2PHost(),d->GetP2PChannel(),d->GetP2PPort(),data,size,get_global_time()))
|
||||
sys_err("invalid channel route from P2P peer");
|
||||
return true;
|
||||
}
|
||||
void Ava2ChannelForget(LPDESC d){s_channels.Forget(d->GetP2PHost(),d->GetP2PPort());}
|
||||
bool Ava2ChannelRouteFor(unsigned channel,unsigned map,long& address,WORD& port){
|
||||
Ava2ChannelRoute r;if(!s_channels.Find(channel,map,get_global_time(),r))return false;
|
||||
const auto ip=inet_addr(r.host.c_str());if(ip==INADDR_NONE)return false;address=ip;port=WORD(r.game);return true;
|
||||
}
|
||||
void Ava2ChannelList(LPCHARACTER ch){
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc())return;
|
||||
auto channels=g_bChannel==99 ? std::vector<unsigned>() : s_channels.Channels(ch->GetMapIndex(),get_global_time());
|
||||
// Always include the local channel, even in private maps: native UI must not fall back to logout switching.
|
||||
if((g_bChannel>=1 && g_bChannel<=7) || g_bChannel==99)channels.push_back(g_bChannel);
|
||||
std::sort(channels.begin(),channels.end());channels.erase(std::unique(channels.begin(),channels.end()),channels.end());
|
||||
std::string list;for(auto id:channels){if(!list.empty())list+=",";list+=std::to_string(id);}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"ChannelList %u %s",unsigned(g_bChannel),list.empty()?"0":list.c_str());
|
||||
}
|
||||
bool Ava2ChannelAllowed(LPCHARACTER ch,unsigned channel){
|
||||
if(!ch || !ch->GetDesc() || channel<1 || channel>7 || channel==g_bChannel || g_bChannel==99 ||
|
||||
ch->GetMapIndex()>=10000 || ch->GetDungeon() || ch->GetWarMap() || ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || !ch->CanWarp())return false;
|
||||
// AVA2 do_cmd's blocked event/war maps.
|
||||
static const unsigned blocked[]={113,81,110,111,114,118,119,120,121,122,123,124,125,126,127,128,181,182,183,24,44,211,90,91,92};
|
||||
for(auto map:blocked)if(unsigned(ch->GetMapIndex())==map)return false;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
long addr=0;WORD port=0;return pc && pc->IsLoaded() && !pc->IsRunning() && Ava2ChannelRouteFor(channel,ch->GetMapIndex(),addr,port);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef AVA2_CHANNEL_H
|
||||
#define AVA2_CHANNEL_H
|
||||
void Ava2ChannelTick();
|
||||
bool Ava2ChannelRelay(LPDESC,const char*,const char*,long);
|
||||
void Ava2ChannelForget(LPDESC);
|
||||
bool Ava2ChannelRouteFor(unsigned channel,unsigned map,long& address,WORD& port);
|
||||
void Ava2ChannelList(LPCHARACTER);
|
||||
bool Ava2ChannelAllowed(LPCHARACTER,unsigned channel);
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef AVA2_CHANNEL_REGISTRY_H
|
||||
#define AVA2_CHANNEL_REGISTRY_H
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
// Trusted P2P peers announce actual map ownership; no assumptions about the farm's port spacing.
|
||||
struct Ava2ChannelRoute { std::string host;unsigned channel=0,game=0,p2p=0;std::set<unsigned> maps;long long seen=0; };
|
||||
class Ava2ChannelRegistry {
|
||||
std::map<std::string,Ava2ChannelRoute> peers;
|
||||
static std::string Key(const std::string& h,unsigned p){return h+":"+std::to_string(p);}
|
||||
public:
|
||||
void Forget(const std::string& host,unsigned port){peers.erase(Key(host,port));}
|
||||
void Prune(long long now){for(auto i=peers.begin();i!=peers.end();)if(i->second.seen+30<=now)i=peers.erase(i);else ++i;}
|
||||
static std::string Encode(unsigned channel,unsigned game,unsigned p2p,const std::vector<int>& maps){
|
||||
std::ostringstream out;out<<1<<' '<<channel<<' '<<game<<' '<<p2p<<' '<<maps.size();
|
||||
for(int map:maps)out<<' '<<map;return out.str();
|
||||
}
|
||||
bool Receive(const std::string& host,unsigned peerChannel,unsigned peerPort,const char* data,long size,long long now){
|
||||
if(!data || size<=0 || size>2048 || host.empty())return false;
|
||||
std::istringstream in(std::string(data,size));Ava2ChannelRoute r;unsigned version=0,count=0;std::string extra;
|
||||
if(!(in>>version>>r.channel>>r.game>>r.p2p>>count) || version!=1 || r.channel<1 || r.channel>7 ||
|
||||
r.channel!=peerChannel || !r.game || r.game>65535 || !r.p2p || r.p2p>65535 ||
|
||||
r.p2p!=peerPort || r.game==r.p2p || count>128)return false;
|
||||
for(unsigned i=0;i<count;++i){unsigned map=0;if(!(in>>map) || !map || map>=10000 || !r.maps.insert(map).second)return false;}
|
||||
if(in>>extra)return false;
|
||||
Prune(now);const auto key=Key(host,r.p2p);
|
||||
if(peers.size()>=128 && peers.find(key)==peers.end())return false;
|
||||
r.host=host;r.seen=now;peers[key]=r;return true;
|
||||
}
|
||||
bool Find(unsigned channel,unsigned map,long long now,Ava2ChannelRoute& out){
|
||||
Prune(now);bool found=false;
|
||||
for(const auto& pair:peers){const auto& r=pair.second;if(r.channel!=channel || !r.maps.count(map))continue;
|
||||
if(found)return false;out=r;found=true;}
|
||||
return found;
|
||||
}
|
||||
std::vector<unsigned> Channels(unsigned map,long long now){
|
||||
std::vector<unsigned> result;Ava2ChannelRoute r;
|
||||
for(unsigned channel=1;channel<=7;++channel)if(Find(channel,map,now,r))result.push_back(channel);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,269 @@
|
||||
// PORT: AVA2 ENABLE_MULTI_CHEST; see docs/FEATURE-AVA2-CHEST.md for adaptations.
|
||||
void CHARACTER::OpenChest(LPITEM item, WORD openCount)
|
||||
{
|
||||
// Validate the client supplied position before entering AVA2's batch reward path.
|
||||
if (!item || item->GetOwner()!=this || !openCount || item->GetType()!=ITEM_GIFTBOX ||
|
||||
item->IsEquipped() || item->IsExchanging() || item->isLocked() ||
|
||||
IsDead() || IsStun() || IsWarping() || IsObserverMode() || !CanHandleItem() ||
|
||||
GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen()) return;
|
||||
|
||||
for(int i=0;i<ITEM_LIMIT_MAX_NUM;++i)
|
||||
if(item->GetLimitType(i)==LIMIT_LEVEL && GetLevel()<item->GetLimitValue(i)) return;
|
||||
if(CArenaManager::instance().IsLimitedItem(GetMapIndex(),item->GetVnum())) return;
|
||||
const DWORD vnum=item->GetVnum();
|
||||
if(((vnum>51500 && vnum<52000) || (vnum>=50255 && vnum<=50260)) && !DragonSoul_IsQualified()) return;
|
||||
if(openCount > item->GetCount())
|
||||
openCount = item->GetCount();
|
||||
|
||||
if(openCount > 1000)
|
||||
openCount =1000;
|
||||
|
||||
std::map<DWORD, DWORD> dwItemVnums;
|
||||
const WORD openCountCache = openCount;
|
||||
if (GiveItemFromSpecialItemGroupNew(item->GetVnum(), openCount))
|
||||
{
|
||||
if(openCount != 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_opened %u", unsigned(openCountCache-openCount));
|
||||
item->SetCount(item->GetCount() - (openCountCache-openCount));
|
||||
}
|
||||
else
|
||||
item->SetCount(item->GetCount() - openCountCache);
|
||||
}
|
||||
else
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_error full");
|
||||
}
|
||||
bool CHARACTER::AutoGiveItemChest(LPITEM item, DWORD& itemCount, std::map<LPITEM, WORD>& vecUpdateItems)
|
||||
{
|
||||
int cell = -1;
|
||||
if (item->IsDragonSoul())
|
||||
cell = GetEmptyDragonSoulInventory(item);
|
||||
else
|
||||
cell = GetEmptyInventory(item->GetSize());
|
||||
|
||||
if (cell == -1)
|
||||
return false;
|
||||
|
||||
const DWORD itemVnum = item->GetVnum();
|
||||
WORD wCount = item->GetCount();
|
||||
|
||||
if (item->IsStackable() && item->GetType() != ITEM_BLEND)
|
||||
{
|
||||
for (auto it = vecUpdateItems.begin(); it != vecUpdateItems.end(); ++it)
|
||||
{
|
||||
LPITEM item2 = it->first;
|
||||
if (itemVnum == item2->GetVnum())
|
||||
{
|
||||
bool same=true;
|
||||
for(int j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
if(item2->GetSocket(j)!=item->GetSocket(j)) same=false;
|
||||
if(!same) continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
wCount -= bCount2;
|
||||
item2->SetCount(item2Count + bCount2);
|
||||
if (wCount == 0)
|
||||
{
|
||||
itemCount = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
|
||||
{
|
||||
LPITEM item2 = GetInventoryItem(i);
|
||||
if (!item2)
|
||||
continue;
|
||||
if (item2->GetVnum() == itemVnum)
|
||||
{
|
||||
BYTE j;
|
||||
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
|
||||
if (item2->GetSocket(j) != item->GetSocket(j))
|
||||
break;
|
||||
if (j != ITEM_SOCKET_MAX_NUM)
|
||||
continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
const auto itItem = vecUpdateItems.find(item2);
|
||||
if(itItem == vecUpdateItems.end())
|
||||
vecUpdateItems.emplace(item2, item2Count);
|
||||
wCount -= bCount2;
|
||||
item2->SetUpdateStatus(true);
|
||||
item2->SetCount(item2Count + bCount2);
|
||||
if (wCount == 0)
|
||||
{
|
||||
itemCount = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wCount > 0)
|
||||
{
|
||||
item->SetCount(wCount);
|
||||
if (item->IsDragonSoul())
|
||||
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
|
||||
else
|
||||
item->AddToCharacter(this, TItemPos(INVENTORY, cell));
|
||||
|
||||
if(item->IsStackable())
|
||||
{
|
||||
const auto itItem = vecUpdateItems.find(item);
|
||||
if(itItem == vecUpdateItems.end())
|
||||
vecUpdateItems.emplace(item, wCount);
|
||||
}
|
||||
itemCount = wCount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CHARACTER::GiveItemFromSpecialItemGroupNew(DWORD dwGroupNum, WORD& loopCount)
|
||||
{
|
||||
const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwGroupNum);
|
||||
if (!pGroup)
|
||||
{
|
||||
sys_err("cannot find special item group %d", dwGroupNum);
|
||||
return false;
|
||||
}
|
||||
std::map<DWORD, DWORD> vecItemCounts;
|
||||
std::map<LPITEM, WORD> vecUpdateItems;
|
||||
const WORD constCount = loopCount;
|
||||
WORD workCount = loopCount;
|
||||
|
||||
int returnCount = 5;
|
||||
|
||||
for (DWORD j = 0; j < constCount; ++j)
|
||||
{
|
||||
if (returnCount <= 0 || workCount <= 0)
|
||||
break;
|
||||
std::vector <int> idxes;
|
||||
const int n = pGroup->GetMultiIndex(idxes);
|
||||
|
||||
bool isOkey = false;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (returnCount <= 0 || (workCount <= 0 && !isOkey))
|
||||
break;
|
||||
|
||||
const int idx = idxes[i];
|
||||
const DWORD dwVnum = pGroup->GetVnum(idx);
|
||||
const DWORD dwEarnCount = pGroup->GetCount(idx);
|
||||
DWORD dwCount = pGroup->GetCount(idx);
|
||||
|
||||
switch (dwVnum)
|
||||
{
|
||||
case CSpecialItemGroup::GOLD:
|
||||
PointChange(POINT_GOLD, dwCount);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::POISON:
|
||||
AttackedByPoison(NULL);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::EXP:
|
||||
PointChange(POINT_EXP, dwCount);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::MOB:
|
||||
{
|
||||
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), GetX() + number(-500, 500), GetY() + number(-500, 500), 0, true, -1);
|
||||
if (ch)
|
||||
ch->SetAggressive();
|
||||
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::MOB_GROUP:
|
||||
CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), GetX() - number(300, 500), GetY() - number(300, 500), GetX() + number(300, 500), GetY() + number(300, 500), NULL, true);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::SLOW:
|
||||
AddAffect(AFFECT_SLOW, POINT_MOV_SPEED, -(int)dwCount, AFF_SLOW, 300, 0, true);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
break;
|
||||
case CSpecialItemGroup::DRAIN_HP:
|
||||
{
|
||||
int iDropHP = GetMaxHP() * dwCount / 100;
|
||||
iDropHP = MIN(iDropHP, GetHP() - 1);
|
||||
PointChange(POINT_HP, -iDropHP);
|
||||
if(isOkey == false)
|
||||
{
|
||||
isOkey = true;
|
||||
workCount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
// The selected base has 200-count stacks and byte item-count packets.
|
||||
// AVA2 rewards larger than a stack must be split, never silently clamped by CreateItem.
|
||||
DWORD remaining=dwEarnCount;
|
||||
while(remaining) {
|
||||
LPITEM item=ITEM_MANAGER::Instance().CreateItem(dwVnum,MIN(remaining,ITEM_MAX_COUNT));
|
||||
if(!item) { --returnCount; break; }
|
||||
const DWORD created=item->GetCount();
|
||||
DWORD count=created;
|
||||
if(!created || !AutoGiveItemChest(item,count,vecUpdateItems)) {
|
||||
M2_DESTROY_ITEM(item); --returnCount; break;
|
||||
}
|
||||
if(!isOkey) { isOkey=true; --workCount; }
|
||||
vecItemCounts[dwVnum]+=created;
|
||||
remaining-=MIN(remaining,created); // Non-stackable count=1; MAKECOUNT prototypes may create a larger minimum.
|
||||
if(!count) M2_DESTROY_ITEM(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = vecUpdateItems.begin(); it != vecUpdateItems.end(); ++it)
|
||||
{
|
||||
LPITEM item = it->first;
|
||||
item->SetUpdateStatus(false);
|
||||
if (item->GetCount() != it->second)
|
||||
item->UpdatePacket();
|
||||
|
||||
if (item->GetType() == ITEM_QUEST || item->GetType() == ITEM_MATERIAL)
|
||||
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
|
||||
}
|
||||
|
||||
for (auto it = vecItemCounts.begin(); it != vecItemCounts.end(); ++it)
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "chest_reward %u %u", it->first, it->second);
|
||||
|
||||
loopCount = workCount;
|
||||
return (workCount != constCount);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
// PORT: native AVA2 chest commands; old mt_chest is retained for older clients.
|
||||
|
||||
ACMD(do_chest_drop) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
std::istringstream input(argument); std::string w,c,n,extra;
|
||||
unsigned window=0,cell=0,count=0;
|
||||
if(!(input>>w>>c>>n) || (input>>extra) || !PortChestNumber(w,window) ||
|
||||
!PortChestNumber(c,cell) || !PortChestNumber(n,count) ||
|
||||
window!=INVENTORY || cell>=INVENTORY_MAX_NUM || !count) return;
|
||||
DWORD& last=g_portChestLastCommand[ch->GetPlayerID()];
|
||||
if(last && get_dword_time()-last<kPortChestGapMs) return;
|
||||
last=get_dword_time();
|
||||
ch->OpenChest(ch->GetItem(TItemPos(INVENTORY,cell)),WORD(MIN(count,1000u)));
|
||||
}
|
||||
ACMD(do_chestdrop) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
std::istringstream input(argument); std::string n,extra; unsigned vnum=0;
|
||||
if(!(input>>n) || (input>>extra) || n.size()>10 || n.find_first_not_of("0123456789")!=std::string::npos) return;
|
||||
unsigned long long wide=strtoull(n.c_str(),NULL,10);
|
||||
if(wide>0xffffffffULL) return;
|
||||
vnum=DWORD(wide);
|
||||
const TItemTable* proto=ITEM_MANAGER::instance().GetTable(vnum);
|
||||
if(!proto || proto->bType!=ITEM_GIFTBOX) return;
|
||||
const CSpecialItemGroup* group=ITEM_MANAGER::instance().GetSpecialItemGroup(vnum);
|
||||
const DWORD count=group?group->GetGroupSize():0;
|
||||
if(count>8190) return;
|
||||
TEMP_BUFFER buffer;
|
||||
TPacketGCChestDrop p; p.header=HEADER_GC_CHESTDROP;
|
||||
p.size=sizeof(p)+8+count*8;
|
||||
buffer.write(&p,sizeof(p)); buffer.write(&vnum,4); buffer.write(&count,4);
|
||||
for(DWORD i=0;i<count;++i) {
|
||||
const DWORD reward=group->GetVnum(i), amount=group->GetCount(i);
|
||||
buffer.write(&reward,4); buffer.write(&amount,4);
|
||||
}
|
||||
ch->GetDesc()->Packet(buffer.read_peek(),buffer.size());
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "questpc.h"
|
||||
|
||||
ACMD(do_setpickupmode) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc()) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if(!pc || !pc->IsLoaded()) return; // QuestLoad sends the authoritative saved settings once ready.
|
||||
std::istringstream input(argument); std::string a,b,extra;
|
||||
if(!(input>>a)) { ch->ChatPacket(CHAT_TYPE_COMMAND,"PickUPMode %u %u",ch->GetPickUPMode(),ch->GetPickUPRarityMode());return; }
|
||||
if(!(input>>b) || (input>>extra) || a.size()>6 || b.size()>2 ||
|
||||
a.find_first_not_of("0123456789")!=std::string::npos || b.find_first_not_of("0123456789")!=std::string::npos) return;
|
||||
ch->ChangePickUPMode(strtoul(a.c_str(),NULL,10),strtoul(b.c_str(),NULL,10));
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// AVA2 player.shop/shop_item #12 snapshot. Isolated from existing NPC shop IDs.
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "char.h"
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "shop.h"
|
||||
#include "packet.h"
|
||||
#include "desc.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_ticket_shop.h"
|
||||
#include <memory>
|
||||
struct Ava2TicketOffer { DWORD vnum,count,currency,price; };
|
||||
static const Ava2TicketOffer kAva2Tickets[]={
|
||||
{25163,1,90011,10},{25164,1,90011,15},{25165,1,90012,15},{25166,1,90012,15},
|
||||
{25167,1,90010,20},{25168,1,90010,20},{25169,1,90010,30},{25170,1,90010,30}
|
||||
};
|
||||
#pragma pack(push,1)
|
||||
struct Ava2ShopPrice { DWORD vnum,count; };
|
||||
struct Ava2ShopStart { TPacketGCShopStart shop; Ava2ShopPrice prices[SHOP_HOST_ITEM_MAX_NUM]; };
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(Ava2ShopStart)==2044,"native currency shop payload");
|
||||
static_assert(sizeof(Ava2ShopPrice)==8,"AVA2 item price layout");
|
||||
class CAva2TicketShop : public CShop {
|
||||
public:
|
||||
bool Initialize() {
|
||||
TShopItemTable items[SHOP_HOST_ITEM_MAX_NUM]={};
|
||||
for (size_t i=0;i<sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0]);++i) {
|
||||
if (!ITEM_MANAGER::instance().GetTable(kAva2Tickets[i].vnum) || !ITEM_MANAGER::instance().GetTable(kAva2Tickets[i].currency)) return false;
|
||||
items[i].vnum=kAva2Tickets[i].vnum;items[i].count=kAva2Tickets[i].count;
|
||||
}
|
||||
if (!Create(12,20381,items)) return false;
|
||||
for (auto& item:m_itemVector) item.price=0; // Gold must never be charged for an item-currency offer.
|
||||
return true;
|
||||
}
|
||||
bool AddGuest(LPCHARACTER ch,DWORD,bool) override {
|
||||
if (!ch || ch->GetShop() || ch->GetExchange()) return false;
|
||||
Ava2ShopStart start={};
|
||||
for (size_t i=0;i<sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0]);++i) {
|
||||
// All eight original ticket prototypes occupy one grid cell.
|
||||
if (m_itemVector[i].vnum!=kAva2Tickets[i].vnum) return false;
|
||||
start.shop.items[i].vnum=kAva2Tickets[i].vnum;
|
||||
start.shop.items[i].count=kAva2Tickets[i].count;
|
||||
start.prices[i].vnum=kAva2Tickets[i].currency;
|
||||
start.prices[i].count=kAva2Tickets[i].price;
|
||||
}
|
||||
ch->SetShop(this);ch->SetShopOwner(ch);
|
||||
m_map_guest.insert(GuestMapType::value_type(ch,false));
|
||||
TPacketGCShop packet={};packet.header=HEADER_GC_SHOP;
|
||||
packet.subheader=SHOP_SUBHEADER_GC_START_ITEM_CURRENCY;packet.size=sizeof(packet)+sizeof(start);
|
||||
ch->GetDesc()->BufferedPacket(&packet,sizeof(packet));ch->GetDesc()->Packet(&start,sizeof(start));
|
||||
return true;
|
||||
}
|
||||
int Buy(LPCHARACTER ch,BYTE pos) override {
|
||||
if (!ch || ch->GetShop()!=this || ch->GetShopOwner()!=ch || m_map_guest.find(ch)==m_map_guest.end()) return SHOP_SUBHEADER_GC_END;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded() || pc->IsRunning() || !ch->CanHandleItem() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->GetExchange() || ch->GetMyShop() || ch->IsOpenSafebox() || ch->IsCubeOpen()) return SHOP_SUBHEADER_GC_END;
|
||||
if (pos>=sizeof(kAva2Tickets)/sizeof(kAva2Tickets[0])) return SHOP_SUBHEADER_GC_INVALID_POS;
|
||||
const auto& offer=kAva2Tickets[pos];
|
||||
// Same AVA2 item-currency branch, using the existing inventory range and item removal path.
|
||||
if (ch->CountSpecifyItem(offer.currency)<int(offer.price)) return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
|
||||
const int result=CShop::Buy(ch,pos);
|
||||
// CShop::Buy synchronously validates/creates/places the ticket; it performs no quest callbacks.
|
||||
// The reward and currency differ, and no network event can interleave this game-thread operation.
|
||||
if (result==SHOP_SUBHEADER_GC_OK) { ch->RemoveSpecifyItem(offer.currency,offer.price);ch->Save(); }
|
||||
return result;
|
||||
}
|
||||
};
|
||||
static std::unique_ptr<CAva2TicketShop> s_ava2Tickets;
|
||||
bool Ava2IsTicketShop(CShop* shop) { return shop && shop==s_ava2Tickets.get(); }
|
||||
void Ava2DestroyTicketShop() { s_ava2Tickets.reset(); }
|
||||
bool Ava2OpenTicketShop(LPCHARACTER ch) {
|
||||
if (!ch || !ch->IsPC()) return false;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded() || pc->IsRunning() || !ch->CanHandleItem() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->GetShop() || ch->GetExchange() || ch->GetMyShop() || ch->IsOpenSafebox() || ch->IsCubeOpen()) return false;
|
||||
if (!s_ava2Tickets) {
|
||||
std::unique_ptr<CAva2TicketShop> shop(new CAva2TicketShop);
|
||||
if (!shop->Initialize()) return false;
|
||||
s_ava2Tickets=std::move(shop);
|
||||
}
|
||||
return s_ava2Tickets->AddGuest(ch,0,false);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef AVA2_TICKET_SHOP_H
|
||||
#define AVA2_TICKET_SHOP_H
|
||||
class CShop;
|
||||
bool Ava2IsTicketShop(CShop* shop);
|
||||
bool Ava2OpenTicketShop(LPCHARACTER ch);
|
||||
void Ava2DestroyTicketShop();
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
// AVA2 CHARACTER::GetDungeonCooldown protocol and quest flag precedence.
|
||||
#include "stdafx.h"
|
||||
#include "char.h"
|
||||
#include "utils.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "ava2_track.h"
|
||||
#include "port_dungeon_settings.h"
|
||||
void Ava2TrackDungeonInfo(LPCHARACTER ch, WORD boss)
|
||||
{
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (!pc || !pc->IsLoaded()) return;
|
||||
const std::map<WORD,std::pair<std::string,std::string>> flags={
|
||||
{1093,{"deviltower_zone.cooldown","deviltower_zone.time"}},
|
||||
{2598,{"devilcatacomb_zone.cooldown","devilcatacomb_zone.time"}},
|
||||
{2493,{"dragonlair.cooldown","dragonlair.time"}},
|
||||
{6091,{"flame_dungeon.cooldown","flame_dungeon.time"}},
|
||||
{9018,{"ShipDefense.cooldown","ShipDefense.time"}},
|
||||
{6191,{"snow_dungeon.cooldown","snow_dungeon.time"}},
|
||||
{20442,{"MeleyDungeon.cooldown","MeleyDungeon.time"}},
|
||||
{2092,{"SpiderDungeon.cooldown","SpiderDungeon.time"}}
|
||||
};
|
||||
std::string text;
|
||||
for (const auto& row:flags) {
|
||||
if (boss!=65535 && boss!=row.first) continue;
|
||||
const int now=int(get_global_time());
|
||||
int cooldown=std::max(0,ch->GetQuestFlag(row.second.first)-now);
|
||||
const int reenter=std::max(0,ch->GetQuestFlag(row.second.second)-now);
|
||||
// Existing 40250 quests remain authoritative until their AVA2 replacements are installed.
|
||||
// These are cooldowns only: the entrance NPC still validates tickets, party and room ownership.
|
||||
auto& manager=quest::CQuestManager::instance();
|
||||
const char* legacyFlag=nullptr;int delay=0;
|
||||
if (row.first==2598 && manager.GetQuestIndexByName("devilcatacomb_zone")) {legacyFlag="devilcatacomb_zone.last_exit_time";delay=1800;}
|
||||
if (row.first==6091 && manager.GetQuestIndexByName("flame_dungeon")) {legacyFlag="flame_dungeon.exit_time";delay=1800;}
|
||||
if (row.first==2092 && manager.GetQuestIndexByName("spider_dungeon_3floor_boss")) legacyFlag="spider_dungeon_3floor_boss.retry_limit_time";
|
||||
if (legacyFlag) {
|
||||
const int flag=ch->GetQuestFlag(legacyFlag);
|
||||
if (flag>0) cooldown=std::max(cooldown,int(std::min(2147483647LL,std::max(0LL,static_cast<long long>(flag)+delay-now))));
|
||||
}
|
||||
if (row.first==2493 && !manager.GetQuestIndexByName("dragonlair") && manager.GetQuestIndexByName("dragon_lair_access")) {
|
||||
std::vector<unsigned> settings;
|
||||
// Do not execute Lua while the player is in a suspended quest coroutine.
|
||||
if (pc->IsRunning() || !PortDungeonSettings("dragon_lair_access","get_settings",{"cooldown_time"},settings) || !settings[0]) cooldown=-1;
|
||||
else cooldown=std::max(cooldown,int(std::min(2147483647LL,std::max(0LL,static_cast<long long>(manager.GetEventFlag("dragon_lair_time"))+settings[0]-now))));
|
||||
}
|
||||
// Send explicit zero as well, so an old/re-enter timer is cleared on refresh.
|
||||
const int left=cooldown<0?-1:cooldown?cooldown:reenter;
|
||||
text+=std::to_string(row.first)+"|"+std::to_string(left)+"|"+(cooldown>0?"0":reenter?"1":"0")+"#";
|
||||
if (text.size()+50>CHAT_MAX_LEN) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackDungeonInfo %s",text.c_str());text.clear();
|
||||
}
|
||||
}
|
||||
if (!text.empty()) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackDungeonInfo %s",text.c_str());
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef AVA2_TRACK_H
|
||||
#define AVA2_TRACK_H
|
||||
void Ava2TrackDungeonInfo(LPCHARACTER ch, WORD boss=65535);
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
// Original AVA2 /track_window load + teleport. GM debug mutations are deliberately not player commands.
|
||||
#include "new_mob_timer.h"
|
||||
#include "ava2_track.h"
|
||||
#include <sstream>
|
||||
ACMD(do_track_window)
|
||||
{
|
||||
if (!ch || !ch->IsPC()) return;
|
||||
std::istringstream in(argument);std::string action,extra;
|
||||
if (!(in>>action)) return;
|
||||
if (action=="load") {
|
||||
const int now=get_global_time();
|
||||
if (ch->GetProtectTime("track_query")>now) return;
|
||||
ch->SetProtectTime("track_query",now+1);
|
||||
ch->SetProtectTime("track_dungeon",1);
|
||||
Ava2TrackDungeonInfo(ch);
|
||||
// The five original native UI IDs; no client-controlled scan or unbounded output.
|
||||
for (WORD id=0;id<5;++id) CNewMobTimer::instance().GetTrackData(ch,id);
|
||||
} else if (action=="teleport") {
|
||||
unsigned boss=0; if (!(in>>boss) || (in>>extra)) return;
|
||||
const PortTrackDestination* d=PortTrackFind(boss);
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
const char* error=nullptr;
|
||||
if (!d) error="unsupported";
|
||||
else if (ch->GetLevel()<d->minLevel || ch->GetLevel()>d->maxLevel) error="level";
|
||||
else if (!pc || !pc->IsLoaded() || pc->IsRunning() || ch->IsDead() || ch->IsStun() || ch->IsWarping() || !ch->CanHandleItem() || !ch->CanWarp()) error="busy";
|
||||
else if (!ch->WarpSet(d->x*100,d->y*100,0)) error="unavailable";
|
||||
if (error) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackError %s",error);
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,12 @@ int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)
|
||||
// PC일 경우 상대가 melee 몹일 경우 몹의 공격 거리가 최대 공격 거리
|
||||
if (false == victim->IsPC() && BATTLE_TYPE_MELEE == victim->GetMobBattleType())
|
||||
max = MAX(300, (int) (victim->GetMobAttackRange() * 1.15f));
|
||||
|
||||
// A boss body can be far wider than 300 (the hydra 6812 is out on the water and the deck
|
||||
// stops a player about 620 from its centre). The client already allows 500 from a boss
|
||||
// centre on its odd x/z test, so the server allows 800 for a boss.
|
||||
if (false == victim->IsPC() && victim->GetMobRank() >= MOB_RANK_BOSS)
|
||||
max = MAX(max, 800);
|
||||
}
|
||||
|
||||
if (distance > max)
|
||||
@@ -287,6 +293,20 @@ int CalcAttBonus(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int iAtk)
|
||||
else if (pkVictim->IsRaceFlag(RACE_FLAG_TREE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_TREE)) / 100;
|
||||
|
||||
// PORT AVA2 ELEMENT_NEW_BONUSES (talisman enchant), each flag on its own like AVA2; AVA2 forgot ICE.
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ELEC))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ELEC)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_FIRE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_FIRE)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ICE))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ICE)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_WIND))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_WIND)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_EARTH))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_EARTH)) / 100;
|
||||
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_DARK))
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_DARK)) / 100;
|
||||
|
||||
if (pkVictim->GetMobRank() >= MOB_RANK_BOSS && !pkVictim->IsStone())
|
||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
|
||||
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
|
||||
@@ -389,6 +409,13 @@ void Item_GetDamage(LPITEM pkItem, int* pdamMin, int* pdamMax)
|
||||
|
||||
*pdamMin = pkItem->GetValue(3);
|
||||
*pdamMax = pkItem->GetValue(4);
|
||||
|
||||
int iMin, iMax, iMagMin, iMagMax;
|
||||
if (Sash_GetAbsorbedWeaponBonus(pkItem->GetOwner(), &iMin, &iMax, &iMagMin, &iMagMax))
|
||||
{
|
||||
*pdamMin += iMin;
|
||||
*pdamMax += iMax;
|
||||
}
|
||||
}
|
||||
|
||||
int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDefense, bool bIgnoreTargetRating)
|
||||
|
||||
@@ -21,6 +21,7 @@ extern float CalcAttackRating(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool
|
||||
extern bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim);
|
||||
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
||||
extern void battle_end(LPCHARACTER ch);
|
||||
extern bool Sash_GetAbsorbedWeaponBonus(LPCHARACTER ch, int * piMin, int * piMax, int * piMagMin, int * piMagMax);
|
||||
|
||||
extern bool battle_distance_valid_by_xy(long x, long y, long tx, long ty);
|
||||
extern bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim);
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
// #include "HackShield.h"
|
||||
#include "skill_power.h"
|
||||
#include "buff_on_attributes.h"
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "ava2_channel.h"
|
||||
|
||||
#ifdef __PET_SYSTEM__
|
||||
#include "PetSystem.h"
|
||||
@@ -265,6 +268,8 @@ void CHARACTER::Initialize()
|
||||
m_bPKMode = PK_MODE_PEACE;
|
||||
|
||||
m_dwQuestNPCVID = 0;
|
||||
m_dwQuestNPCVIDAttack = 0;
|
||||
m_protection_Time.clear();
|
||||
m_dwQuestByVnum = 0;
|
||||
m_pQuestItem = NULL;
|
||||
|
||||
@@ -382,6 +387,9 @@ void CHARACTER::Initialize()
|
||||
|
||||
memset(&m_tvLastSyncTime, 0, sizeof(m_tvLastSyncTime));
|
||||
m_iSyncHackCount = 0;
|
||||
|
||||
m_bSashCombination = false;
|
||||
m_bSashAbsorption = false;
|
||||
}
|
||||
|
||||
void CHARACTER::Create(const char * c_pszName, DWORD vid, bool isPC)
|
||||
@@ -902,6 +910,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity)
|
||||
addPacket.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
||||
addPacket.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
||||
addPacket.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
||||
addPacket.awPart[CHR_EQUIPPART_SASH] = GetPart(PART_SASH);
|
||||
|
||||
addPacket.bPKMode = m_bPKMode;
|
||||
addPacket.dwMountVnum = GetMountVnum();
|
||||
@@ -1031,6 +1040,7 @@ void CHARACTER::UpdatePacket()
|
||||
pack.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
||||
pack.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
||||
pack.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
||||
pack.awPart[CHR_EQUIPPART_SASH] = GetPart(PART_SASH);
|
||||
|
||||
pack.bMovingSpeed = GetLimitPoint(POINT_MOV_SPEED);
|
||||
pack.bAttackSpeed = GetLimitPoint(POINT_ATT_SPEED);
|
||||
@@ -1304,6 +1314,8 @@ void CHARACTER::SaveReal()
|
||||
marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
|
||||
if (pMarriage)
|
||||
pMarriage->Save();
|
||||
|
||||
PortBpSave(this); // PORT: battle pass progress
|
||||
}
|
||||
|
||||
void CHARACTER::FlushDelayedSaveItem()
|
||||
@@ -1393,6 +1405,7 @@ void CHARACTER::Disconnect(const char * c_pszReason)
|
||||
|
||||
SaveAffect();
|
||||
m_bIsLoadedAffect = false;
|
||||
PortBpLogout(this); // PORT: battle pass, after the last save
|
||||
|
||||
m_bSkipSave = true; // 이 이후에는 더이상 저장하면 안된다.
|
||||
|
||||
@@ -1769,6 +1782,7 @@ void CHARACTER::SetPlayerProto(const TPlayerTable * t)
|
||||
|
||||
m_pointsInstant.bBasePart = t->part_base;
|
||||
SetPart(PART_HAIR, t->parts[PART_HAIR]);
|
||||
SetPart(PART_SASH, 0); // not stored in the player table; the equipped sash sets it when the items load
|
||||
|
||||
m_points.iRandomHP = t->sRandomHP;
|
||||
m_points.iRandomSP = t->sRandomSP;
|
||||
@@ -2273,6 +2287,7 @@ void CHARACTER::ComputePoints()
|
||||
SetPart(PART_WEAPON, GetOriginalPart(PART_WEAPON));
|
||||
SetPart(PART_HEAD, GetOriginalPart(PART_HEAD));
|
||||
SetPart(PART_HAIR, GetOriginalPart(PART_HAIR));
|
||||
SetPart(PART_SASH, GetOriginalPart(PART_SASH));
|
||||
|
||||
SetPoint(POINT_PARTY_ATTACKER_BONUS, lAttackerBonus);
|
||||
SetPoint(POINT_PARTY_TANKER_BONUS, lTankerBonus);
|
||||
@@ -3063,6 +3078,8 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
|
||||
if (amount)
|
||||
{
|
||||
if (amount > 0)
|
||||
PortBpCount(this, PORT_BP_LEVEL_UP, 0, amount); // PORT: battle pass
|
||||
quest::CQuestManager::instance().LevelUp(GetPlayerID());
|
||||
|
||||
LogManager::instance().LevelLog(this, val, GetRealPoint(POINT_PLAYTIME) + (get_dword_time() - m_dwPlayStartTime) / 60000);
|
||||
@@ -3128,9 +3145,11 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
DWORD iExpBalance = 0;
|
||||
|
||||
// 레벨 업!
|
||||
if (exp + amount >= next_exp)
|
||||
// PORT: 64-bit sum; with next_exp up to 4.2e9 (docs/FEATURE-LEVEL-120.md) exp + amount wraps a DWORD
|
||||
const unsigned long long total = (unsigned long long) exp + (unsigned long long) amount;
|
||||
if (total >= next_exp)
|
||||
{
|
||||
iExpBalance = (exp + amount) - next_exp;
|
||||
iExpBalance = (DWORD) (total - next_exp);
|
||||
amount = next_exp - exp;
|
||||
|
||||
SetExp(0);
|
||||
@@ -3138,7 +3157,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
}
|
||||
else
|
||||
{
|
||||
SetExp(exp + amount);
|
||||
SetExp((DWORD) total);
|
||||
exp = GetExp();
|
||||
}
|
||||
|
||||
@@ -3436,6 +3455,12 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||
// PORT AVA2 biology points
|
||||
case POINT_ATTBONUS_STONE:
|
||||
case POINT_ATTBONUS_BOSS:
|
||||
case POINT_ENCHANT_ELEC:
|
||||
case POINT_ENCHANT_FIRE:
|
||||
case POINT_ENCHANT_ICE:
|
||||
case POINT_ENCHANT_WIND:
|
||||
case POINT_ENCHANT_EARTH:
|
||||
case POINT_ENCHANT_DARK:
|
||||
case POINT_RESIST_HUMAN:
|
||||
case POINT_ATTBONUS_MONSTER:
|
||||
case POINT_ATTBONUS_SURA:
|
||||
@@ -3821,6 +3846,14 @@ void CHARACTER::ApplyPoint(BYTE bApplyType, int iVal)
|
||||
case APPLY_DEF_GRADE: // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
||||
case APPLY_COSTUME_ATTR_BONUS: // 84 코스튬 아이템에 붙은 속성치 보너스
|
||||
case APPLY_MAGIC_ATTBONUS_PER: // 85 마법 공격력 +x%
|
||||
case APPLY_ATTBONUS_STONE:
|
||||
case APPLY_ATTBONUS_BOSS:
|
||||
case APPLY_ENCHANT_ELEC:
|
||||
case APPLY_ENCHANT_FIRE:
|
||||
case APPLY_ENCHANT_ICE:
|
||||
case APPLY_ENCHANT_WIND:
|
||||
case APPLY_ENCHANT_EARTH:
|
||||
case APPLY_ENCHANT_DARK:
|
||||
case APPLY_MELEE_MAGIC_ATTBONUS_PER: // 86 마법 + 밀리 공격력 +x%
|
||||
PointChange(aApplyInfo[bApplyType].bPointType, iVal);
|
||||
break;
|
||||
@@ -4170,6 +4203,9 @@ WORD CHARACTER::GetOriginalPart(BYTE bPartPos) const
|
||||
case PART_HAIR:
|
||||
return GetPart(PART_HAIR);
|
||||
|
||||
case PART_SASH:
|
||||
return GetPart(PART_SASH);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -5246,7 +5282,18 @@ void CHARACTER::ExitToSavedLocation()
|
||||
// 지금까진 privateMapIndex 가 현재 맵 인덱스와 같은지 체크 하는 것을 외부에서 하고,
|
||||
// 다르면 warpset을 불렀는데
|
||||
// 이를 warpset 안으로 넣자.
|
||||
// AVA2 MoveChannel delegates the shared warp bookkeeping and switchbot hand-over to WarpSet.
|
||||
void CHARACTER::MoveChannel(DWORD channel) {
|
||||
if (!Ava2ChannelAllowed(this,channel) || !WarpSet(GetX(),GetY(),0,BYTE(channel)))
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"ChannelError unavailable");
|
||||
}
|
||||
|
||||
bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex)
|
||||
{
|
||||
return WarpSet(x,y,lPrivateMapIndex,0);
|
||||
}
|
||||
|
||||
bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex, BYTE targetChannel)
|
||||
{
|
||||
if (!IsPC())
|
||||
return false;
|
||||
@@ -5290,6 +5337,8 @@ bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex)
|
||||
lMapIndex = lPrivateMapIndex;
|
||||
}
|
||||
|
||||
if (targetChannel && !Ava2ChannelRouteFor(targetChannel,lMapIndex,lAddr,wPort))return false;
|
||||
|
||||
Stop();
|
||||
Save();
|
||||
|
||||
@@ -5321,6 +5370,18 @@ bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex)
|
||||
|
||||
p.wPort = wPort;
|
||||
|
||||
// PORT: AVA2 switchbot: the table follows the player to the target core (port_switchbot.cpp).
|
||||
CSwitchbotManager::Instance().SetIsWarping(GetPlayerID(), true);
|
||||
|
||||
if (p.wPort != mother_port)
|
||||
CSwitchbotManager::Instance().P2PSendSwitchbot(GetPlayerID(), p.wPort);
|
||||
|
||||
if (targetChannel) {
|
||||
struct in_addr endpoint;endpoint.s_addr=p.lAddr;
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"UpdateServerInfo %u",unsigned(targetChannel));
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"ChannelEndpoint %u %s %u",unsigned(targetChannel),inet_ntoa(endpoint),unsigned(p.wPort));
|
||||
}
|
||||
|
||||
GetDesc()->Packet(&p, sizeof(TPacketGCWarp));
|
||||
|
||||
//if (!LC_IsNewCIBN())
|
||||
@@ -6135,6 +6196,36 @@ LPCHARACTER CHARACTER::GetQuestNPC() const
|
||||
return CHARACTER_MANAGER::instance().Find(m_dwQuestNPCVID);
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON
|
||||
LPCHARACTER CHARACTER::GetQuestNPCAttack() const
|
||||
{
|
||||
return CHARACTER_MANAGER::instance().Find(m_dwQuestNPCVIDAttack);
|
||||
}
|
||||
|
||||
void CHARACTER::SetProtectTime(const std::string& flagname, int value)
|
||||
{
|
||||
m_protection_Time[flagname] = value;
|
||||
}
|
||||
|
||||
int CHARACTER::GetProtectTime(const std::string& flagname) const
|
||||
{
|
||||
std::map<std::string, int>::const_iterator it = m_protection_Time.find(flagname);
|
||||
return it != m_protection_Time.end() ? it->second : 0;
|
||||
}
|
||||
|
||||
bool CHARACTER::IsMeley() const
|
||||
{
|
||||
switch (GetRaceNum())
|
||||
{
|
||||
case 6119:
|
||||
case 6230:
|
||||
case 6231:
|
||||
case 9563:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CHARACTER::SetQuestItemPtr(LPITEM item)
|
||||
{
|
||||
m_pQuestItem = item;
|
||||
|
||||
@@ -279,6 +279,13 @@ enum EPointTypes
|
||||
// PORT AVA2 biology points, within the existing 255-point packet.
|
||||
POINT_ATTBONUS_STONE = 240,
|
||||
POINT_ATTBONUS_BOSS = 241,
|
||||
// PORT AVA2 element enchant (talismans, APPLY_ENCHANT_*).
|
||||
POINT_ENCHANT_ELEC = 242,
|
||||
POINT_ENCHANT_FIRE = 243,
|
||||
POINT_ENCHANT_ICE = 244,
|
||||
POINT_ENCHANT_WIND = 245,
|
||||
POINT_ENCHANT_EARTH = 246,
|
||||
POINT_ENCHANT_DARK = 247,
|
||||
POINT_RESIST_HUMAN = 220,
|
||||
|
||||
// Ãß°¡ ¼Ó¼º ÀúÇ×
|
||||
@@ -405,9 +412,12 @@ typedef struct character_point_instant
|
||||
LPITEM pDSItems[DRAGON_SOUL_INVENTORY_MAX_NUM];
|
||||
WORD wDSItemGrid[DRAGON_SOUL_INVENTORY_MAX_NUM];
|
||||
|
||||
LPITEM pSwitchbotItems[SWITCHBOT_SLOT_COUNT]; // PORT: AVA2 switchbot window (port_switchbot.cpp)
|
||||
|
||||
// by mhh
|
||||
LPITEM pCubeItems[CUBE_MAX_NUM];
|
||||
LPCHARACTER pCubeNpc;
|
||||
LPITEM pSashMaterials[SASH_WINDOW_MAX_MATERIALS]; // AVA2 sash window
|
||||
|
||||
LPCHARACTER battle_victim;
|
||||
|
||||
@@ -507,6 +517,30 @@ enum e_overtime
|
||||
OT_5HOUR,
|
||||
};
|
||||
|
||||
enum eAutomaticPickUP
|
||||
{
|
||||
AUTOMATIC_PICK_UP_ACTIVATE = (1 << 0),
|
||||
|
||||
AUTOMATIC_PICK_UP_WEAPON = (1 << 1),
|
||||
AUTOMATIC_PICK_UP_ARMOR = (1 << 2),
|
||||
AUTOMATIC_PICK_UP_SHIELD = (1 << 3),
|
||||
AUTOMATIC_PICK_UP_RINGS = (1 << 4),
|
||||
AUTOMATIC_PICK_UP_HELMETS = (1 << 5),
|
||||
AUTOMATIC_PICK_UP_BRACELETS = (1 << 6),
|
||||
AUTOMATIC_PICK_UP_NECKLACE = (1 << 7),
|
||||
AUTOMATIC_PICK_UP_EARRINGS = (1 << 8),
|
||||
AUTOMATIC_PICK_UP_COSTUMES = (1 << 9),
|
||||
AUTOMATIC_PICK_UP_PET_MOUNT = (1 << 10),
|
||||
AUTOMATIC_PICK_UP_SASH = (1 << 11),
|
||||
AUTOMATIC_PICK_UP_TALISMAN = (1 << 12),
|
||||
AUTOMATIC_PICK_UP_BOOKS = (1 << 13),
|
||||
AUTOMATIC_PICK_UP_STONES = (1 << 14),
|
||||
AUTOMATIC_PICK_UP_YANG = (1 << 15),
|
||||
AUTOMATIC_PICK_UP_CHESTS = (1 << 16),
|
||||
AUTOMATIC_PICK_UP_SHOES = (1 << 17),
|
||||
AUTOMATIC_PICK_UP_BELTS = (1 << 18),
|
||||
};
|
||||
|
||||
class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
{
|
||||
protected:
|
||||
@@ -518,9 +552,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
public:
|
||||
DWORD m_portFeatureLastQuery = 0; // PORT: read-only query throttle, not persisted.
|
||||
DWORD m_portSwitchbotLastCommand = 0; // PORT: switchbot command throttle.
|
||||
bool m_portQuietInfo = false; // PORT: switchbot rolls hold back per-roll INFO lines...
|
||||
std::string m_portLastInfo; // ...keeping the last one to report a rejected roll.
|
||||
bool m_portQuietInfo = false; // PORT: batch actions hold back per-item INFO lines...
|
||||
std::string m_portLastInfo; // ...keeping the last one to report a rejected item.
|
||||
DWORD m_portPickupLastCommand = 0; // PORT: batch pickup throttle.
|
||||
|
||||
LPCHARACTER FindCharacterInView(const char * name, bool bFindPCOnly);
|
||||
@@ -841,6 +874,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
bool IsSyncOwner(LPCHARACTER ch) const;
|
||||
|
||||
bool WarpSet(long x, long y, long lRealMapIndex = 0);
|
||||
bool WarpSet(long x, long y, long lRealMapIndex, BYTE targetChannel);
|
||||
void MoveChannel(DWORD channel);
|
||||
void SetWarpLocation(long lMapIndex, long x, long y);
|
||||
void WarpEnd();
|
||||
const PIXEL_POSITION & GetWarpPosition() const { return m_posWarp; }
|
||||
@@ -1120,6 +1155,13 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
std::vector <DWORD> &dwItemCounts, std::vector <LPITEM> &item_gets, int &count);
|
||||
|
||||
bool MoveItem(TItemPos pos, TItemPos change_pos, BYTE num);
|
||||
DWORD GetPickUPMode() { return DWORD(GetQuestFlag("ava2_pickup.mode")); }
|
||||
DWORD GetPickUPRarityMode() { return DWORD(GetQuestFlag("ava2_pickup.rarity")); }
|
||||
void ChangePickUPMode(DWORD mode,DWORD rarity);
|
||||
bool CheckItemCanGet(LPITEM item);
|
||||
void OpenChest(LPITEM item, WORD count);
|
||||
bool AutoGiveItemChest(LPITEM item, DWORD& count, std::map<LPITEM, WORD>& updates);
|
||||
bool GiveItemFromSpecialItemGroupNew(DWORD group, WORD& count);
|
||||
bool PickupItem(DWORD vid);
|
||||
bool EquipItem(LPITEM item, int iCandidateCell = -1);
|
||||
bool UnequipItem(LPITEM item);
|
||||
@@ -1657,6 +1699,20 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
DWORD GetQuestNPCID() const { return m_dwQuestNPCVID; }
|
||||
LPCHARACTER GetQuestNPC() const;
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. The victim of the pc's last attack (npc.*(1, ...) in a
|
||||
// "when <vnum>.attack" handler), per-character int flags ("IsMeleyBlock" blocks all damage), and
|
||||
// the Meley races, which stand still and cast their mob skills every 5 s.
|
||||
void SetQuestNPCIDAttack(DWORD vid) { m_dwQuestNPCVIDAttack = vid; }
|
||||
LPCHARACTER GetQuestNPCAttack() const;
|
||||
void SetProtectTime(const std::string& flagname, int value);
|
||||
int GetProtectTime(const std::string& flagname) const;
|
||||
bool IsMeley() const;
|
||||
// PORT: AVA2 ENABLE_DEFENSAWE_SHIP. The hydra ship's mast (6801) survives d.kill_all/purge and can be
|
||||
// attacked; the hydra (6812) and its crew (6802-6809) ignore players and go for the mast.
|
||||
bool IsHydraNPC() const { return GetRaceNum() == 6801; }
|
||||
bool IsHydra() const { return GetRaceNum() == 6812; }
|
||||
bool IsHydraMob() const { return (GetRaceNum() >= 6802 && GetRaceNum() <= 6809) || IsHydra(); }
|
||||
|
||||
void SetQuestItemPtr(LPITEM item);
|
||||
void ClearQuestItemPtr();
|
||||
LPITEM GetQuestItemPtr() const;
|
||||
@@ -1671,6 +1727,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
private:
|
||||
DWORD m_dwQuestNPCVID;
|
||||
DWORD m_dwQuestNPCVIDAttack; // PORT: AVA2 meley lair
|
||||
std::map<std::string, int> m_protection_Time; // PORT: AVA2 meley lair
|
||||
DWORD m_dwQuestByVnum;
|
||||
LPITEM m_pQuestItem;
|
||||
|
||||
@@ -1746,6 +1804,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
public:
|
||||
int GetPremiumRemainSeconds(BYTE bType) const;
|
||||
// PORT: the VIP card re-reads the account end times (port_premium.h).
|
||||
void PortSetPremiumTime(BYTE bType, int iTime) { if (bType < PREMIUM_MAX_NUM) m_aiPremiumTimes[bType] = iTime; }
|
||||
|
||||
private:
|
||||
int m_aiPremiumTimes[PREMIUM_MAX_NUM];
|
||||
@@ -2068,6 +2128,36 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
protected:
|
||||
int m_iLastPMPulse;
|
||||
int m_iPMCounter;
|
||||
|
||||
// AVA2 sash: combine (bCombination) / absorb window opened by pc.open_sash
|
||||
protected:
|
||||
bool m_bSashCombination, m_bSashAbsorption;
|
||||
|
||||
public:
|
||||
bool isSashOpened(bool bCombination) { return bCombination ? m_bSashCombination : m_bSashAbsorption; }
|
||||
bool IsSashWindowOpen() const { return m_bSashCombination || m_bSashAbsorption; }
|
||||
void OpenSash(bool bCombination);
|
||||
void CloseSash();
|
||||
void ClearSashMaterials();
|
||||
LPITEM* GetSashMaterials() { return m_pointsInstant.pSashMaterials; }
|
||||
bool SashIsSameGrade(long lGrade);
|
||||
DWORD GetSashCombinePrice(long lGrade);
|
||||
void GetSashCombineResult(DWORD & dwItemVnum, DWORD & dwMinAbs, DWORD & dwMaxAbs);
|
||||
BYTE CheckEmptyMaterialSlot();
|
||||
void AddSashMaterial(TItemPos tPos, BYTE bPos);
|
||||
void RemoveSashMaterial(BYTE bPos);
|
||||
BYTE CanRefineSashMaterials();
|
||||
void RefineSashMaterials();
|
||||
|
||||
// AVA2 mount costume / skin (port_mount.cpp)
|
||||
public:
|
||||
bool MountCostumeCanEquip(LPITEM item);
|
||||
bool MountCostumeCanUnequip(LPITEM item);
|
||||
void MountCostumeEquipped(LPITEM item);
|
||||
void MountCostumeUnequipped(LPITEM item, bool bAlwaysSummon);
|
||||
void MountCostumeOnLogin();
|
||||
bool CostumeEnchantUse(LPITEM item, LPITEM item2);
|
||||
bool PendantScrollUse(LPITEM item, LPITEM item2);
|
||||
};
|
||||
|
||||
ESex GET_SEX(LPCHARACTER ch);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "desc.h"
|
||||
@@ -40,6 +41,7 @@
|
||||
#include "BlueDragon.h"
|
||||
#include "DragonLair.h"
|
||||
#include <random>
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include <algorithm>
|
||||
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
||||
{
|
||||
@@ -260,6 +262,13 @@ bool CHARACTER::Attack(LPCHARACTER pkVictim, BYTE bType)
|
||||
iRet = ComputeSkill(bType, pkVictim);
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON, "when <vnum>.attack" quest event.
|
||||
if (IsPC() && (pkVictim->IsMonster() || pkVictim->IsStone()))
|
||||
{
|
||||
SetQuestNPCIDAttack(pkVictim->GetVID());
|
||||
quest::CQuestManager::instance().Attack(GetPlayerID(), pkVictim->GetRaceNum());
|
||||
}
|
||||
|
||||
//if (test_server && IsPC())
|
||||
// sys_log(0, "%s Attack %s type %u ret %d", GetName(), pkVictim->GetName(), bType, iRet);
|
||||
if (iRet == BATTLE_DAMAGE || iRet == BATTLE_DEAD)
|
||||
@@ -282,6 +291,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||
sys_log(1, "DEATH_PERNALY_CHECK(%s) town(%d)", GetName(), bTown);
|
||||
|
||||
Cube_close(this);
|
||||
CloseSash();
|
||||
|
||||
if (CBattleArena::instance().IsBattleArenaMap(GetMapIndex()) == true)
|
||||
{
|
||||
@@ -329,7 +339,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||
}
|
||||
// END_OF_NO_DEATH_PENALTY_BUG_FIX
|
||||
|
||||
int iLoss = ((GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100);
|
||||
int iLoss = (int) (((unsigned long long) GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100); // PORT: 64-bit, next exp up to 4.2e9
|
||||
|
||||
if (true == LC_IsYMIR())
|
||||
{
|
||||
@@ -785,6 +795,8 @@ void CHARACTER::Reward(bool bItemDrop)
|
||||
pkAttacker->UpdateAlignment(2);
|
||||
|
||||
pkAttacker->SetQuestNPCID(GetVID());
|
||||
// PORT: battle pass kill, credited like the quest kill below (port_battlepass_runtime.h).
|
||||
PortBpKill(pkAttacker, this);
|
||||
quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());
|
||||
CHARACTER_MANAGER::instance().KillLog(GetRaceNum());
|
||||
|
||||
@@ -1197,6 +1209,7 @@ class FPartyAlignmentCompute
|
||||
|
||||
void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||
{
|
||||
if (!IsDead()) CNewMobTimer::instance().Dead(this,pkKiller);
|
||||
if (IsDead())
|
||||
return;
|
||||
|
||||
@@ -1522,6 +1535,9 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||
{
|
||||
Cube_close(this);
|
||||
}
|
||||
|
||||
if (IsPC())
|
||||
CloseSash();
|
||||
|
||||
CShopManager::instance().StopShopping(this);
|
||||
CloseMyShop();
|
||||
@@ -1606,6 +1622,7 @@ void CHARACTER::SendDamagePacket(LPCHARACTER pAttacker, int Damage, BYTE DamageF
|
||||
//
|
||||
bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // returns true if dead
|
||||
{
|
||||
if (!CNewMobTimer::instance().CheckDamage(pAttacker,this)) return false;
|
||||
if (DAMAGE_TYPE_MAGIC == type)
|
||||
{
|
||||
dam = (int)((float)dam * (100 + (pAttacker->GetPoint(POINT_MAGIC_ATT_BONUS_PER) + pAttacker->GetPoint(POINT_MELEE_MAGIC_ATT_BONUS_PER))) / 100.f + 0.5f);
|
||||
@@ -1700,6 +1717,13 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
DAMAGE_CRITICAL = (1 << 5),
|
||||
};
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. A Meley statue turned to stone (npc.set_protect_time "IsMeleyBlock").
|
||||
if (pAttacker && GetProtectTime("IsMeleyBlock") == 1)
|
||||
{
|
||||
SendDamagePacket(pAttacker, 0, DAMAGE_BLOCK);
|
||||
return false;
|
||||
}
|
||||
|
||||
//PROF_UNIT puAttr("Attr");
|
||||
|
||||
//
|
||||
@@ -2284,6 +2308,11 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||
//
|
||||
// !!!!!!!!! ½ÇÁ¦ HP¸¦ ÁÙÀÌ´Â ºÎºÐ !!!!!!!!!
|
||||
//
|
||||
// PORT: AVA2 meley lair. Only the quest kills a statue (npc.dead_by_vnum); one hit past the last
|
||||
// stage's 30000 HP threshold (MeleyDungeon 6230.attack) left it dead and the lair stuck.
|
||||
if (GetRaceNum() == 6230 && dam >= GetHP())
|
||||
dam = MAX(0, GetHP() - 1);
|
||||
|
||||
if (!cannot_dead)
|
||||
{
|
||||
PointChange(POINT_HP, -dam, false);
|
||||
@@ -3638,7 +3667,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (itFind != m_map_kDamage.end())
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(CHARACTER_MANAGER::instance().Find(itFind->first));
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
@@ -3647,7 +3677,8 @@ void CHARACTER::ChangeVictimByAggro(int iNewAggro, LPCHARACTER pNewVictim)
|
||||
if (m_iMaxAggro < iNewAggro)
|
||||
{
|
||||
m_iMaxAggro = iNewAggro;
|
||||
SetVictim(pNewVictim);
|
||||
if (!IsHydraMob()) // PORT: AVA2, hydra mobs keep hitting the mast
|
||||
SetVictim(pNewVictim);
|
||||
m_dwStateDuration = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +265,15 @@ DWORD CHARACTER::GetMyHorseVnum() const
|
||||
++delta;
|
||||
}
|
||||
|
||||
// AVA2 ENABLE_MOUNT_SKIN / ENABLE_MOUNT_COSTUME_SYSTEM: the worn skin, else the worn mount, is the horse
|
||||
LPITEM pkCostumeMountSkin = GetWear(WEAR_COSTUME_MOUNT_SKIN);
|
||||
if (pkCostumeMountSkin)
|
||||
return pkCostumeMountSkin->GetValue(0);
|
||||
|
||||
LPITEM pkCostumeMount = GetWear(WEAR_COSTUME_MOUNT);
|
||||
if (pkCostumeMount)
|
||||
return pkCostumeMount->GetValue(0);
|
||||
|
||||
return c_aHorseStat[GetHorseLevel()].iNPCRace + delta;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
#include "../../common/VnumHelper.h"
|
||||
#include "DragonSoul.h"
|
||||
#include "port_attr_lock.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "buff_on_attributes.h"
|
||||
#include "belt_inventory_helper.h"
|
||||
|
||||
@@ -50,6 +52,8 @@
|
||||
#ifdef __AUCTION__
|
||||
#include "auction_manager.h"
|
||||
#endif
|
||||
#include "port_premium.h"
|
||||
#include "port_battlepass_hooks.h"
|
||||
const int ITEM_BROKEN_METIN_VNUM = 28960;
|
||||
|
||||
// CHANGE_ITEM_ATTRIBUTES
|
||||
@@ -227,6 +231,9 @@ bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver)
|
||||
if (IsWarping())
|
||||
return false;
|
||||
|
||||
if (IsSashWindowOpen())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -257,6 +264,14 @@ LPITEM CHARACTER::GetItem(TItemPos Cell) const
|
||||
return NULL;
|
||||
}
|
||||
return m_pointsInstant.pDSItems[wCell];
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT window (port_switchbot.cpp).
|
||||
case SWITCHBOT:
|
||||
if (wCell >= SWITCHBOT_SLOT_COUNT)
|
||||
{
|
||||
sys_err("CHARACTER::GetInventoryItem: invalid switchbot item cell %d", wCell);
|
||||
return NULL;
|
||||
}
|
||||
return m_pointsInstant.pSwitchbotItems[wCell];
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
@@ -393,6 +408,32 @@ void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
|
||||
m_pointsInstant.pDSItems[wCell] = pItem;
|
||||
}
|
||||
break;
|
||||
case SWITCHBOT:
|
||||
{
|
||||
if (wCell >= SWITCHBOT_SLOT_COUNT)
|
||||
{
|
||||
sys_err("CHARACTER::SetItem: invalid switchbot item cell %d", wCell);
|
||||
return;
|
||||
}
|
||||
|
||||
LPITEM pOld = m_pointsInstant.pSwitchbotItems[wCell];
|
||||
if (pItem && pOld)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pItem)
|
||||
{
|
||||
CSwitchbotManager::Instance().RegisterItem(GetPlayerID(), pItem->GetID(), wCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSwitchbotManager::Instance().UnregisterItem(GetPlayerID(), wCell);
|
||||
}
|
||||
|
||||
m_pointsInstant.pSwitchbotItems[wCell] = pItem;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sys_err ("Invalid Inventory type %d", window_type);
|
||||
return;
|
||||
@@ -448,6 +489,9 @@ void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
|
||||
case DRAGON_SOUL_INVENTORY:
|
||||
pItem->SetWindow(DRAGON_SOUL_INVENTORY);
|
||||
break;
|
||||
case SWITCHBOT:
|
||||
pItem->SetWindow(SWITCHBOT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,6 +555,17 @@ void CHARACTER::ClearItem()
|
||||
item->SetSkipSave(true);
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
|
||||
item->RemoveFromCharacter();
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < SWITCHBOT_SLOT_COUNT; ++i)
|
||||
{
|
||||
if ((item = GetItem(TItemPos(SWITCHBOT, i))))
|
||||
{
|
||||
item->SetSkipSave(true);
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
|
||||
item->RemoveFromCharacter();
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
@@ -675,6 +730,18 @@ bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) c
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// PORT: AVA2 switchbot window; cell 5 (AVA2's hidden switcher cell) never takes an item here.
|
||||
case SWITCHBOT:
|
||||
{
|
||||
WORD wCell = Cell.cell;
|
||||
if (wCell >= SWITCHBOT_SLOT_COUNT_REAL)
|
||||
return false;
|
||||
|
||||
if (m_pointsInstant.pSwitchbotItems[wCell])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,6 +990,7 @@ bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
|
||||
{
|
||||
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
||||
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
||||
PortBpCount(this, PORT_BP_REFINE, pkNewItem->GetVnum(), 1); // PORT: battle pass
|
||||
|
||||
WORD bCell = item->GetCell();
|
||||
|
||||
@@ -1196,6 +1264,7 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
|
||||
{
|
||||
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
||||
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
||||
PortBpCount(this, PORT_BP_REFINE, pkNewItem->GetVnum(), 1); // PORT: battle pass
|
||||
|
||||
WORD bCell = item->GetCell();
|
||||
|
||||
@@ -1894,6 +1963,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
case ITEM_ROD:
|
||||
case ITEM_RING: // 신규 반지 아이템
|
||||
case ITEM_BELT: // 신규 벨트 아이템
|
||||
case ITEM_NEW_RINGS: // AVA2 new rings
|
||||
// MINING
|
||||
case ITEM_PICK:
|
||||
// END_OF_MINING
|
||||
@@ -2449,6 +2519,12 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
}
|
||||
break;
|
||||
case USE_SPECIAL:
|
||||
if(item->GetVnum()==70002) {
|
||||
if(FindAffect(AFFECT_AUTO_PICK_UP)) return false;
|
||||
AddAffect(AFFECT_AUTO_PICK_UP,POINT_NONE,0,AFF_NONE,60*60*24*30,0,false,true);
|
||||
item->SetCount(item->GetCount()-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (item->GetVnum())
|
||||
{
|
||||
@@ -4484,10 +4560,32 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
case USE_ADD_ATTRIBUTE:
|
||||
case USE_ADD_ATTRIBUTE2:
|
||||
{
|
||||
// AVA2: using a lock material without a destination selects its 1-based index in a quest.
|
||||
if ((item->GetVnum()==50348 || item->GetVnum()==50349) &&
|
||||
(!IsValidItemPosition(DestCell) || !GetItem(DestCell))) {
|
||||
quest::CQuestManager::instance().RegisterNPCVnum(item->GetVnum());
|
||||
quest::CQuestManager::instance().UseItem(GetPlayerID(),item,false);
|
||||
return true;
|
||||
}
|
||||
LPITEM item2;
|
||||
if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
|
||||
return false;
|
||||
|
||||
// AVA2 lock materials carry the selected 1-based attribute in socket 0.
|
||||
if (item->GetVnum() == 50348 || item->GetVnum() == 50349)
|
||||
{
|
||||
const long index = item->GetSocket(0);
|
||||
const char* error = index < 1 || index > 5 ? "slot" :
|
||||
PortAttrLockUse(this, item2, unsigned(index - 1), item);
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"AttrLockResult %s",error?error:"ok");
|
||||
return error == NULL;
|
||||
}
|
||||
if (item->IsCostumeEnchant())
|
||||
return CostumeEnchantUse(item, item2);
|
||||
|
||||
if (item->GetPendantScrollKind() || item2->IsTalisman())
|
||||
return PendantScrollUse(item, item2);
|
||||
|
||||
if (item2->IsEquipped())
|
||||
{
|
||||
BuffOnAttr_RemoveBuffsFromItem(item2);
|
||||
@@ -4551,7 +4649,8 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
break;
|
||||
|
||||
case USE_CHANGE_ATTRIBUTE :
|
||||
if (item2->GetAttributeSetIndex() == -1)
|
||||
|
||||
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||
return false;
|
||||
@@ -4656,7 +4755,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
break;
|
||||
|
||||
case USE_ADD_ATTRIBUTE :
|
||||
if (item2->GetAttributeSetIndex() == -1)
|
||||
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||
return false;
|
||||
@@ -4728,7 +4827,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
case USE_ADD_ATTRIBUTE2 :
|
||||
// 축복의 구슬
|
||||
// 재가비서를 통해 속성을 4개 추가 시킨 아이템에 대해서 하나의 속성을 더 붙여준다.
|
||||
if (item2->GetAttributeSetIndex() == -1)
|
||||
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||
return false;
|
||||
@@ -5064,19 +5163,16 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2))
|
||||
{
|
||||
// 석 확률
|
||||
if (number(1, 100) <= 30)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 성공하였습니다."));
|
||||
item2->SetSocket(i, item->GetVnum());
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 실패하였습니다."));
|
||||
item2->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
|
||||
}
|
||||
// PORT: AVA2 ENABLE_ADDSTONE_FAILURE is disabled: insertion always succeeds.
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 성공하였습니다."));
|
||||
item2->SetSocket(i, item->GetVnum());
|
||||
|
||||
LogManager::instance().ItemLog(this, item2, "SOCKET", item->GetName());
|
||||
ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (METIN)");
|
||||
// PORT: AVA2 consumes one stone, including stackable +0..+5 stones.
|
||||
if (item->GetCount() == 1)
|
||||
ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (METIN)");
|
||||
else
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5192,6 +5288,28 @@ bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
|
||||
if (item->IsExchanging())
|
||||
return false;
|
||||
|
||||
// PORT: AVA2 switchbot: using an idle switchbot item takes it back to the inventory.
|
||||
if (Cell.IsSwitchbotPosition())
|
||||
{
|
||||
if (CSwitchbotManager::Instance().IsActive(GetPlayerID(), Cell.cell))
|
||||
return false;
|
||||
|
||||
int iEmptyCell = GetEmptyInventory(item->GetSize());
|
||||
|
||||
if (iEmptyCell == -1)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지하고 있는 아이템이 너무 많습니다."));
|
||||
return false;
|
||||
}
|
||||
|
||||
MoveItem(Cell, TItemPos(INVENTORY, iEmptyCell), item->GetCount());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Switchbot items change only through the switchbot (CItem::UpdatePacket skips that window).
|
||||
if (DestCell.IsSwitchbotPosition())
|
||||
return false;
|
||||
|
||||
if (!item->CanUsedBy(this))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("군직이 맞지않아 이 아이템을 사용할 수 없습니다."));
|
||||
@@ -5207,6 +5325,10 @@ bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
|
||||
return false;
|
||||
}
|
||||
|
||||
// PORT: VIP card (port_premium.h)
|
||||
if (PortVipUseCard(this, item))
|
||||
return true;
|
||||
|
||||
//PREVENT_TRADE_WINDOW
|
||||
if (IS_SUMMON_ITEM(item->GetVnum()))
|
||||
{
|
||||
@@ -5377,6 +5499,9 @@ bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
if (IsDead())
|
||||
return false;
|
||||
|
||||
if (Cell.IsSwitchbotPosition()) // PORT: switchbot items go back to the inventory first
|
||||
return false;
|
||||
|
||||
if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
|
||||
return false;
|
||||
|
||||
@@ -5585,6 +5710,28 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
return false;
|
||||
}
|
||||
|
||||
// PORT: AVA2 switchbot: a running slot keeps its item; only switchbot items go in, and only between the
|
||||
// switchbot window and the main inventory (cell 5 is refused by IsEmptyItemGrid).
|
||||
if (Cell.IsSwitchbotPosition() || DestCell.IsSwitchbotPosition())
|
||||
{
|
||||
if (Cell.IsSwitchbotPosition() && CSwitchbotManager::Instance().IsActive(GetPlayerID(), Cell.cell))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "switchbot_error active");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DestCell.IsSwitchbotPosition() && !SwitchbotHelper::IsValidItem(item))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "switchbot_error invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
const TItemPos& other = Cell.IsSwitchbotPosition() ? DestCell : Cell;
|
||||
|
||||
if (!other.IsSwitchbotPosition() && !other.IsDefaultInventoryPosition())
|
||||
return false;
|
||||
}
|
||||
|
||||
// 이미 착용중인 아이템을 다른 곳으로 옮기는 경우, '장책 해제' 가능한 지 확인하고 옮김
|
||||
if (Cell.IsEquipPosition() && !CanUnequipNow(item))
|
||||
return false;
|
||||
@@ -5686,6 +5833,9 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
snprintf(szBuf, sizeof(szBuf), "%u %u %u %u ", item2->GetID(), item2->GetCount(), item->GetCount(), item->GetCount() + item2->GetCount());
|
||||
LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
|
||||
}
|
||||
|
||||
if (Cell.IsEquipPosition()) // AVA2 mount costume / skin taken off by drag
|
||||
MountCostumeUnequipped(item, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -6089,6 +6239,8 @@ bool CHARACTER::UnequipItem(LPITEM item)
|
||||
else
|
||||
item->AddToCharacter(this, TItemPos(INVENTORY, pos));
|
||||
|
||||
MountCostumeUnequipped(item, true); // AVA2 mount costume / skin
|
||||
|
||||
CheckMaximumPoints();
|
||||
|
||||
return true;
|
||||
@@ -6237,6 +6389,10 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
|
||||
{
|
||||
this->EffectPacket(SE_EQUIP_LOVE_PENDANT);
|
||||
}
|
||||
else if (ITEM_COSTUME == item->GetType() && COSTUME_SASH == item->GetSubType())
|
||||
{
|
||||
this->EffectPacket(SE_EFFECT_SASH_EQUIP);
|
||||
}
|
||||
// ITEM_UNIQUE의 경우, SpecialItemGroup에 정의되어 있고, (item->GetSIGVnum() != NULL)
|
||||
//
|
||||
else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
|
||||
@@ -6257,6 +6413,8 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
|
||||
{
|
||||
quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
|
||||
}
|
||||
|
||||
MountCostumeEquipped(item); // AVA2 mount costume / skin
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -6688,6 +6846,9 @@ bool CHARACTER::GiveItem(LPCHARACTER victim, TItemPos Cell)
|
||||
if (!CanHandleItem())
|
||||
return false;
|
||||
|
||||
if (Cell.IsSwitchbotPosition()) // PORT: switchbot items go back to the inventory first
|
||||
return false;
|
||||
|
||||
LPITEM item = GetItem(Cell);
|
||||
|
||||
if (item && !item->IsExchanging())
|
||||
@@ -7433,6 +7594,9 @@ bool CHARACTER::IsValidItemPosition(TItemPos Pos) const
|
||||
case DRAGON_SOUL_INVENTORY:
|
||||
return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
|
||||
|
||||
case SWITCHBOT:
|
||||
return cell < SWITCHBOT_SLOT_COUNT;
|
||||
|
||||
case SAFEBOX:
|
||||
if (NULL != m_pkSafebox)
|
||||
return m_pkSafebox->IsValidPosition(cell);
|
||||
@@ -7553,6 +7717,9 @@ bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TI
|
||||
|
||||
}
|
||||
|
||||
if (!MountCostumeCanEquip(item)) // AVA2 mount skin
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7567,6 +7734,9 @@ bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const
|
||||
if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
|
||||
return false;
|
||||
|
||||
if (!MountCostumeCanUnequip(item)) // AVA2 mount costume / skin
|
||||
return false;
|
||||
|
||||
// 아이템 unequip시 인벤토리로 옮길 때 빈 자리가 있는 지 확인
|
||||
{
|
||||
int pos = -1;
|
||||
@@ -7582,3 +7752,58 @@ bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "ava2_chest.inc"
|
||||
|
||||
bool CHARACTER::CheckItemCanGet(const LPITEM item)
|
||||
{
|
||||
const BYTE itemType = item->GetType();
|
||||
const BYTE itemSubType = item->GetSubType();
|
||||
if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_YANG) && item->GetVnum() == 1)
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_WEAPON) && (itemType == ITEM_WEAPON && itemSubType != WEAPON_ARROW))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_ARMOR) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_BODY))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_SHIELD) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_SHIELD))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_RINGS) && itemType == ITEM_NEW_RINGS)
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_HELMETS) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_HEAD))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_BRACELETS) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_WRIST))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_NECKLACE) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_NECK))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_EARRINGS) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_EAR))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_SHOES) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_FOOTS))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_COSTUMES) && (itemType == ITEM_COSTUME && !(itemSubType == COSTUME_MOUNT_SKIN || itemSubType == COSTUME_MOUNT || itemSubType == COSTUME_SASH)))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_PET_MOUNT) && (itemType == ITEM_COSTUME && (itemSubType == COSTUME_MOUNT_SKIN || itemSubType == COSTUME_MOUNT)))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_SASH) && (itemType == ITEM_COSTUME && (itemSubType == COSTUME_SASH)))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_TALISMAN) && (itemType == ITEM_ARMOR && itemSubType == ARMOR_PENDANT))
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_BOOKS) && itemType == ITEM_SKILLBOOK)
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_STONES) && itemType == ITEM_METIN)
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_CHESTS) && itemType == ITEM_GIFTBOX)
|
||||
return false;
|
||||
else if(IS_SET(GetPickUPMode(), AUTOMATIC_PICK_UP_BELTS) && itemType == ITEM_BELT)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "questpc.h"
|
||||
void CHARACTER::ChangePickUPMode(DWORD mode,DWORD rarity) {
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(GetPlayerID());
|
||||
if(!pc || !pc->IsLoaded()) return;
|
||||
mode&=((1u<<19)-1); rarity&=63;
|
||||
SetQuestFlag("ava2_pickup.mode",mode);
|
||||
SetQuestFlag("ava2_pickup.rarity",rarity);
|
||||
ChatPacket(CHAT_TYPE_COMMAND,"PickUPMode %u %u",mode,rarity);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "constants.h"
|
||||
#include "utils.h"
|
||||
#include "desc.h"
|
||||
@@ -128,6 +129,7 @@ void CHARACTER_MANAGER::DestroyCharacter(LPCHARACTER ch, const char* file, size_
|
||||
return;
|
||||
}
|
||||
|
||||
CNewMobTimer::instance().Dead(ch,NULL);
|
||||
m_map_pkChrByVID.erase(it);
|
||||
|
||||
if (true == ch->IsPC())
|
||||
|
||||
@@ -1043,6 +1043,13 @@ void SetPolyVarForAttack(LPCHARACTER ch, CSkillProto * pkSk, LPITEM pkWeapon)
|
||||
int iMtk = number(pkWeapon->GetValue(1), pkWeapon->GetValue(2));
|
||||
iMtk += pkWeapon->GetValue(5);
|
||||
|
||||
int iMin, iMax, iMagMin, iMagMax;
|
||||
if (Sash_GetAbsorbedWeaponBonus(ch, &iMin, &iMax, &iMagMin, &iMagMax))
|
||||
{
|
||||
iWep += number(iMin, iMax);
|
||||
iMtk += number(iMagMin, iMagMax);
|
||||
}
|
||||
|
||||
pkSk->SetPointVar("wep", iWep);
|
||||
pkSk->SetPointVar("mtk", iMtk);
|
||||
pkSk->SetPointVar("mwep", iMtk);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
BOOL g_test_server;
|
||||
extern LPCHARACTER FindVictim(LPCHARACTER pkChr, int iMaxDistance);
|
||||
extern LPCHARACTER FindVictimHydra(LPCHARACTER pkChr, int iMaxDistance); // PORT: AVA2 port_ava2_dungeon.cpp
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -620,6 +621,30 @@ void CHARACTER::__StateIdle_NPC()
|
||||
|
||||
void CHARACTER::__StateIdle_Monster()
|
||||
{
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. Meley and her statues never move or melee; Meley casts a
|
||||
// mob skill whenever one is ready, then idles 5 s.
|
||||
if (IsMeley())
|
||||
{
|
||||
if (!IsStone() && time(0) > GetProtectTime("MeleyTime"))
|
||||
{
|
||||
if (HasMobSkill())
|
||||
{
|
||||
for (unsigned int iSkillIdx = 0; iSkillIdx < MOB_SKILL_MAX_NUM; ++iSkillIdx)
|
||||
{
|
||||
if (CanUseMobSkill(iSkillIdx) && UseMobSkill(iSkillIdx))
|
||||
{
|
||||
SendMovePacket(FUNC_MOB_SKILL, iSkillIdx, GetX(), GetY(), 0, get_dword_time());
|
||||
float fDuration = CMotionManager::instance().GetMotionDuration(GetRaceNum(), MAKE_MOTION_KEY(MOTION_MODE_GENERAL, MOTION_SPECIAL_1 + iSkillIdx));
|
||||
m_dwStateDuration = (DWORD) (fDuration == 0.0f ? PASSES_PER_SEC(2) : PASSES_PER_SEC(fDuration));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
SetProtectTime("MeleyTime", time(0) + 5);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsStun())
|
||||
return;
|
||||
|
||||
@@ -665,7 +690,7 @@ void CHARACTER::__StateIdle_Monster()
|
||||
if (GetMapIndex() == 61 && quest::CQuestManager::instance().GetEventFlag("xmas_tree"));
|
||||
// 서한산에서 나무가 있으면 선공하지않는다.
|
||||
else
|
||||
victim = FindVictim(this, m_pkMobData->m_table.wAggressiveSight);
|
||||
victim = IsHydraMob() ? FindVictimHydra(this, 40000) : FindVictim(this, m_pkMobData->m_table.wAggressiveSight); // PORT: AVA2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,7 +974,7 @@ void CHARACTER::StateBattle()
|
||||
if (victim && victim->IsDead() &&
|
||||
!no_wander && IsAggressive() && (!GetParty() || GetParty()->GetLeader() == this))
|
||||
{
|
||||
LPCHARACTER new_victim = FindVictim(this, m_pkMobData->m_table.wAggressiveSight);
|
||||
LPCHARACTER new_victim = IsHydraMob() ? FindVictimHydra(this, 40000) : FindVictim(this, m_pkMobData->m_table.wAggressiveSight); // PORT: AVA2
|
||||
|
||||
SetVictim(new_victim);
|
||||
m_dwStateDuration = PASSES_PER_SEC(1);
|
||||
|
||||
@@ -10,8 +10,17 @@ ACMD(do_autohunt_pull);
|
||||
ACMD(do_server_bonuses);
|
||||
ACMD(do_port_biolog);
|
||||
ACMD(do_port_features);
|
||||
ACMD(do_port_switchbot);
|
||||
ACMD(do_port_pickup);
|
||||
ACMD(do_setpickupmode);
|
||||
ACMD(do_track_window);
|
||||
ACMD(do_channel_list);
|
||||
ACMD(do_attr_lock_info);
|
||||
ACMD(do_open_shop);
|
||||
ACMD(do_port_chest);
|
||||
ACMD(do_chest_drop);
|
||||
ACMD(do_chestdrop);
|
||||
ACMD(do_port_vip);
|
||||
ACMD(do_port_bp);
|
||||
ACMD(do_user_horse_ride);
|
||||
ACMD(do_user_horse_back);
|
||||
ACMD(do_user_horse_feed);
|
||||
@@ -285,10 +294,7 @@ ACMD (do_clear_affect);
|
||||
struct command_info cmd_info[] =
|
||||
{
|
||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_STANDING, GM_PLAYER },
|
||||
{ "mt_features", do_port_features, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "mt_switchbot", do_port_switchbot, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_FIGHTING, GM_PLAYER },
|
||||
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "biolog", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "server_bonuses", do_server_bonuses, 0, POS_DEAD, GM_PLAYER },
|
||||
@@ -601,6 +607,21 @@ struct command_info cmd_info[] =
|
||||
{ "ds_list", do_ds_list, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "do_clear_affect", do_clear_affect, 0, POS_DEAD, GM_LOW_WIZARD},
|
||||
|
||||
// PORT: feature commands stay at the end: commands are prefix matched in table order, so an entry placed
|
||||
// earlier would take over abbreviations of original commands (/m -> mob, /mt -> mto).
|
||||
{ "mt_features", do_port_features, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "open_shop",do_open_shop,0,POS_DEAD,GM_PLAYER },
|
||||
{ "track_window",do_track_window,0,POS_DEAD,GM_PLAYER },
|
||||
{ "channel_list",do_channel_list,0,POS_DEAD,GM_PLAYER },
|
||||
{ "move_channel",do_cmd,SCMD_CHANGE_CHANNEL,POS_DEAD,GM_PLAYER },
|
||||
{ "attr_lock_info",do_attr_lock_info,0,POS_DEAD,GM_PLAYER },
|
||||
{ "setpickupmode",do_setpickupmode,0,POS_DEAD,GM_PLAYER },
|
||||
{ "mt_pickup", do_port_pickup, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "chest_drop", do_chest_drop, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "chestdrop", do_chestdrop, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "mt_chest", do_port_chest, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "mt_vip", do_port_vip, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "mt_bp", do_port_bp, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ enum SCMD_CMD
|
||||
SCMD_QUIT,
|
||||
SCMD_PHASE_SELECT,
|
||||
SCMD_SHUTDOWN,
|
||||
SCMD_CHANGE_CHANNEL,
|
||||
};
|
||||
|
||||
enum SCMD_RESTART
|
||||
|
||||
@@ -41,10 +41,32 @@
|
||||
#include "autohunt_pull.h"
|
||||
#include "biolog_remote.h"
|
||||
#include "port_dungeons.h"
|
||||
#include "ava2_channel.h"
|
||||
#include <sstream>
|
||||
#include "port_calendar_runtime.h"
|
||||
#include "port_ava2_travel.h"
|
||||
#include "port_features.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "port_pickup.h"
|
||||
#include "ava2_pickup_commands.h"
|
||||
#include "port_chest.h"
|
||||
#include "ava2_chest_commands.h"
|
||||
#include "port_premium.h"
|
||||
#include "port_battlepass_runtime.h"
|
||||
|
||||
ACMD(do_port_vip)
|
||||
{
|
||||
if (!ch || !ch->IsPC() || !ch->GetDesc())
|
||||
return;
|
||||
PortVipCommand(ch, argument);
|
||||
}
|
||||
|
||||
// PORT: battle pass (port_battlepass_runtime.h)
|
||||
ACMD(do_port_bp)
|
||||
{
|
||||
if (!ch || !ch->IsPC() || !ch->GetDesc())
|
||||
return;
|
||||
PortBpCommand(ch, argument);
|
||||
}
|
||||
|
||||
extern int g_server_id;
|
||||
|
||||
@@ -86,6 +108,10 @@ ACMD(do_user_horse_back)
|
||||
if (ch->GetHorse() != NULL)
|
||||
{
|
||||
ch->HorseSummon(false);
|
||||
// AVA2 mount costume: sending the horse back also takes the costume off
|
||||
LPITEM pkCostumeMount = ch->GetWear(WEAR_COSTUME_MOUNT);
|
||||
if (pkCostumeMount)
|
||||
ch->UnequipItem(pkCostumeMount);
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¸»À» µ¹·Áº¸³Â½À´Ï´Ù."));
|
||||
}
|
||||
else if (ch->IsHorseRiding() == true)
|
||||
@@ -136,12 +162,14 @@ EVENTINFO(TimedEventInfo)
|
||||
DynamicCharacterPtr ch;
|
||||
int subcmd;
|
||||
int left_second;
|
||||
unsigned channel;
|
||||
char szReason[MAX_REASON_LEN];
|
||||
|
||||
TimedEventInfo()
|
||||
: ch()
|
||||
, subcmd( 0 )
|
||||
, left_second( 0 )
|
||||
, channel(0)
|
||||
{
|
||||
::memset( szReason, 0, MAX_REASON_LEN );
|
||||
}
|
||||
@@ -307,6 +335,9 @@ EVENTFUNC(timed_event)
|
||||
|
||||
switch (info->subcmd)
|
||||
{
|
||||
case SCMD_CHANGE_CHANNEL:
|
||||
ch->MoveChannel(info->channel);
|
||||
break;
|
||||
case SCMD_LOGOUT:
|
||||
if (d)
|
||||
d->SetPhase(PHASE_CLOSE);
|
||||
@@ -357,6 +388,14 @@ ACMD(do_cmd)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned channel=0;
|
||||
if (subcmd==SCMD_CHANGE_CHANNEL) {
|
||||
std::istringstream in(argument);std::string extra;
|
||||
if (!(in>>channel) || (in>>extra) || !Ava2ChannelAllowed(ch,channel)) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"ChannelError unavailable");return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (subcmd)
|
||||
{
|
||||
case SCMD_LOGOUT:
|
||||
@@ -386,6 +425,7 @@ ACMD(do_cmd)
|
||||
case SCMD_LOGOUT:
|
||||
case SCMD_QUIT:
|
||||
case SCMD_PHASE_SELECT:
|
||||
case SCMD_CHANGE_CHANNEL:
|
||||
{
|
||||
TimedEventInfo* info = AllocEventInfo<TimedEventInfo>();
|
||||
|
||||
@@ -398,6 +438,8 @@ ACMD(do_cmd)
|
||||
|
||||
info->ch = ch;
|
||||
info->subcmd = subcmd;
|
||||
info->channel=channel;
|
||||
if (subcmd==SCMD_CHANGE_CHANNEL)info->left_second=3;
|
||||
strlcpy(info->szReason, argument, sizeof(info->szReason));
|
||||
|
||||
ch->m_pkTimedEvent = event_create(timed_event, info, 1);
|
||||
@@ -2690,3 +2732,21 @@ ACMD (do_bid_cancel)
|
||||
AuctionManager::instance().bid_cancel (ch, strtoul(arg1, NULL, 10));
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "ava2_track_commands.h"
|
||||
|
||||
#include "ava2_ticket_shop.h"
|
||||
ACMD(do_open_shop)
|
||||
{
|
||||
std::istringstream in(argument);unsigned shop=0;std::string extra;
|
||||
if (!(in>>shop) || (in>>extra) || shop!=12) return;
|
||||
if (!Ava2OpenTicketShop(ch)) ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackError busy");
|
||||
}
|
||||
|
||||
#include "ava2_attr_lock_commands.h"
|
||||
|
||||
ACMD(do_channel_list) {
|
||||
if (!ch || !ch->IsPC())return;
|
||||
const int now=get_global_time();if(ch->GetProtectTime("channel_query")>now)return;
|
||||
ch->SetProtectTime("channel_query",now+1);Ava2ChannelList(ch);
|
||||
}
|
||||
|
||||
@@ -189,6 +189,8 @@ void map_allow_add(int index)
|
||||
s_set_map_allows.insert(index);
|
||||
}
|
||||
|
||||
std::vector<int> map_allow_list() { return std::vector<int>(s_set_map_allows.begin(),s_set_map_allows.end()); }
|
||||
|
||||
void map_allow_copy(long * pl, int size)
|
||||
{
|
||||
int iCount = 0;
|
||||
|
||||
@@ -40,6 +40,7 @@ extern bool g_bTrafficProfileOn; ///< true
|
||||
extern BYTE g_bChannel;
|
||||
|
||||
extern bool map_allow_find(int index);
|
||||
extern std::vector<int> map_allow_list();
|
||||
extern void map_allow_copy(long * pl, int size);
|
||||
extern bool no_wander;
|
||||
|
||||
|
||||
@@ -293,22 +293,22 @@ const DWORD exp_table_common[PLAYER_EXP_TABLE_MAX + 1] =
|
||||
2250000000,
|
||||
2280000000,
|
||||
2310000000,
|
||||
2330000000, // 105
|
||||
2350000000,
|
||||
2370000000,
|
||||
2390000000,
|
||||
2400000000,
|
||||
2410000000, // 110
|
||||
2420000000,
|
||||
2430000000,
|
||||
2440000000,
|
||||
2450000000,
|
||||
2460000000, // 115
|
||||
2470000000,
|
||||
2480000000,
|
||||
2490000000,
|
||||
2490000000,
|
||||
2500000000, // 120
|
||||
2330000000, // 105 // PORT: 105-119 rise geometrically to 4.2e9 (docs/FEATURE-LEVEL-120.md); DWORD, player.exp must be INT UNSIGNED
|
||||
2430000000u,
|
||||
2530000000u,
|
||||
2640000000u,
|
||||
2760000000u,
|
||||
2880000000u, // 110
|
||||
3000000000u,
|
||||
3130000000u,
|
||||
3260000000u,
|
||||
3400000000u,
|
||||
3550000000u, // 115
|
||||
3700000000u,
|
||||
3860000000u,
|
||||
4030000000u,
|
||||
4200000000u,
|
||||
4200000000u, // 120 (MAX_LEVEL; never needed)
|
||||
};
|
||||
|
||||
const DWORD exp_table_newcibn[PLAYER_EXP_TABLE_MAX + 1 ] =
|
||||
@@ -914,6 +914,56 @@ const TApplyInfo aApplyInfo[MAX_APPLY_NUM] =
|
||||
{ POINT_RESIST_DARK, }, // APPLY_RESIST_DARK, 89
|
||||
{ POINT_RESIST_CRITICAL, }, // APPLY_ANTI_CRITICAL_PCT, 90
|
||||
{ POINT_RESIST_PENETRATE, }, // APPLY_ANTI_PENETRATE_PCT, 91
|
||||
// PORT AVA2 applies 92-138, not ported yet
|
||||
{ POINT_NONE }, // 92
|
||||
{ POINT_NONE }, // 93
|
||||
{ POINT_NONE }, // 94
|
||||
{ POINT_NONE }, // 95
|
||||
{ POINT_NONE }, // 96
|
||||
{ POINT_NONE }, // 97
|
||||
{ POINT_NONE }, // 98
|
||||
{ POINT_NONE }, // 99
|
||||
{ POINT_NONE }, // 100
|
||||
{ POINT_NONE }, // 101
|
||||
{ POINT_NONE }, // 102
|
||||
{ POINT_NONE }, // 103
|
||||
{ POINT_NONE }, // 104
|
||||
{ POINT_NONE }, // 105
|
||||
{ POINT_NONE }, // 106
|
||||
{ POINT_NONE }, // 107
|
||||
{ POINT_NONE }, // 108
|
||||
{ POINT_NONE }, // 109
|
||||
{ POINT_NONE }, // 110
|
||||
{ POINT_NONE }, // 111
|
||||
{ POINT_NONE }, // 112
|
||||
{ POINT_NONE }, // 113
|
||||
{ POINT_NONE }, // 114
|
||||
{ POINT_NONE }, // 115
|
||||
{ POINT_NONE }, // 116
|
||||
{ POINT_NONE }, // 117
|
||||
{ POINT_NONE }, // 118
|
||||
{ POINT_NONE }, // 119
|
||||
{ POINT_NONE }, // 120
|
||||
{ POINT_NONE }, // 121
|
||||
{ POINT_NONE }, // 122
|
||||
{ POINT_ENCHANT_ELEC }, // APPLY_ENCHANT_ELEC 123
|
||||
{ POINT_ENCHANT_FIRE }, // APPLY_ENCHANT_FIRE 124
|
||||
{ POINT_ENCHANT_ICE }, // APPLY_ENCHANT_ICE 125
|
||||
{ POINT_ENCHANT_WIND }, // APPLY_ENCHANT_WIND 126
|
||||
{ POINT_ENCHANT_EARTH }, // APPLY_ENCHANT_EARTH 127
|
||||
{ POINT_ENCHANT_DARK }, // APPLY_ENCHANT_DARK 128
|
||||
{ POINT_NONE }, // 129
|
||||
{ POINT_NONE }, // 130
|
||||
{ POINT_NONE }, // 131
|
||||
{ POINT_NONE }, // 132
|
||||
{ POINT_NONE }, // 133
|
||||
{ POINT_NONE }, // 134
|
||||
{ POINT_NONE }, // 135
|
||||
{ POINT_NONE }, // 136
|
||||
{ POINT_NONE }, // 137
|
||||
{ POINT_NONE }, // 138
|
||||
{ POINT_ATTBONUS_STONE }, // APPLY_ATTBONUS_STONE 139
|
||||
{ POINT_ATTBONUS_BOSS }, // APPLY_ATTBONUS_BOSS 140
|
||||
};
|
||||
|
||||
const int aiItemMagicAttributePercentHigh[ITEM_ATTRIBUTE_MAX_LEVEL] =
|
||||
@@ -1281,6 +1331,14 @@ TValueName c_aApplyTypeNames[] =
|
||||
{ "MAGIC_ATTBONUS_PER", APPLY_MAGIC_ATTBONUS_PER },
|
||||
{ "MELEE_MAGIC_ATTBONUS_PER", APPLY_MELEE_MAGIC_ATTBONUS_PER },
|
||||
|
||||
{ "ATTBONUS_STONE", APPLY_ATTBONUS_STONE },
|
||||
{ "ATTBONUS_BOSS", APPLY_ATTBONUS_BOSS },
|
||||
{ "ENCHANT_ELEC", APPLY_ENCHANT_ELEC },
|
||||
{ "ENCHANT_FIRE", APPLY_ENCHANT_FIRE },
|
||||
{ "ENCHANT_ICE", APPLY_ENCHANT_ICE },
|
||||
{ "ENCHANT_WIND", APPLY_ENCHANT_WIND },
|
||||
{ "ENCHANT_EARTH", APPLY_ENCHANT_EARTH },
|
||||
{ "ENCHANT_DARK", APPLY_ENCHANT_DARK },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
// from import_item_proto.c
|
||||
|
||||
@@ -927,7 +927,7 @@ namespace
|
||||
{
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
|
||||
if (!ch->IsPC() && !ch->IsPet())
|
||||
if (!ch->IsPC() && !ch->IsPet() && !ch->IsHydraNPC()) // PORT: AVA2 hydra mast
|
||||
ch->Dead();
|
||||
}
|
||||
}
|
||||
@@ -942,7 +942,7 @@ namespace
|
||||
{
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
|
||||
if (!ch->IsPC() && !ch->IsPet()) {
|
||||
if (!ch->IsPC() && !ch->IsPet() && !ch->IsHydraNPC()) { // PORT: AVA2 hydra mast
|
||||
M2_DESTROY_CHARACTER(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,9 @@ bool CExchange::AddItem(TItemPos item_pos, BYTE display_pos)
|
||||
if (item_pos.IsEquipPosition())
|
||||
return false;
|
||||
|
||||
if (item_pos.IsSwitchbotPosition()) // PORT: switchbot items go back to the inventory first
|
||||
return false;
|
||||
|
||||
LPITEM item;
|
||||
|
||||
if (!(item = m_pOwner->GetItem(item_pos)))
|
||||
|
||||
@@ -22,6 +22,15 @@ class CExchange
|
||||
bool AddItem(TItemPos item_pos, BYTE display_pos);
|
||||
bool RemoveItem(BYTE pos);
|
||||
|
||||
// Tooltip cells are display positions, not m_apItems array indices.
|
||||
LPITEM GetDisplayItem(unsigned cell) const {
|
||||
if (cell >= EXCHANGE_ITEM_MAX_NUM) return NULL;
|
||||
for (unsigned i=0;i<EXCHANGE_ITEM_MAX_NUM;++i)
|
||||
if (m_apItems[i] && m_abItemDisplayPos[i]==cell) return m_apItems[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LPCHARACTER GetOwner() { return m_pOwner; }
|
||||
CExchange * GetCompany() { return m_pCompany; }
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "affect.h"
|
||||
#include "unique_item.h"
|
||||
#include "port_battlepass_hooks.h"
|
||||
#endif
|
||||
|
||||
namespace fishing
|
||||
@@ -634,6 +635,7 @@ void Take(fishing_event_info* info, LPCHARACTER ch)
|
||||
if (item_vnum)
|
||||
{
|
||||
FishingSuccess(ch);
|
||||
PortBpCount(ch, PORT_BP_CATCH_FISH, item_vnum, 1); // PORT: battle pass
|
||||
|
||||
TPacketGCFishing p;
|
||||
p.header = HEADER_GC_FISHING;
|
||||
|
||||
@@ -113,6 +113,7 @@ class CInputMain : public CInputProcessor
|
||||
void ItemDrop(LPCHARACTER ch, const char * data);
|
||||
void ItemDrop2(LPCHARACTER ch, const char * data);
|
||||
void ItemMove(LPCHARACTER ch, const char * data);
|
||||
int ItemsPickup(LPCHARACTER ch,const char* data,size_t bytes);
|
||||
void ItemPickup(LPCHARACTER ch, const char * data);
|
||||
void ItemToItem(LPCHARACTER ch, const char * pcData);
|
||||
void QuickslotAdd(LPCHARACTER ch, const char * data);
|
||||
@@ -156,6 +157,8 @@ class CInputMain : public CInputProcessor
|
||||
int MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes);
|
||||
|
||||
void Refine(LPCHARACTER ch, const char* c_pData);
|
||||
void Sash(LPCHARACTER ch, const char* c_pData);
|
||||
int Switchbot(LPCHARACTER ch, const char* data, size_t uiBytes); // AVA2 switchbot (port_switchbot.cpp)
|
||||
|
||||
void Roulette(LPCHARACTER ch, const char* c_pData);
|
||||
};
|
||||
@@ -353,6 +356,7 @@ class CInputP2P : public CInputProcessor
|
||||
void BlockChat(const char * c_pData);
|
||||
void PCBangUpdate(const char* c_pData);
|
||||
void IamAwake(LPDESC d, const char * c_pData);
|
||||
void Switchbot(LPDESC d, const char * c_pData); // AVA2 switchbot (port_switchbot.cpp)
|
||||
|
||||
protected:
|
||||
CPacketInfoGG m_packetInfoGG;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "ava2_track.h"
|
||||
#include "constants.h"
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
@@ -47,6 +49,7 @@
|
||||
// #include "HackShield.h"
|
||||
|
||||
#include "DragonSoul.h"
|
||||
#include "port_switchbot.h"
|
||||
|
||||
#ifdef __AUCTION__
|
||||
#include "auction_manager.h"
|
||||
@@ -963,6 +966,22 @@ void CInputDB::Boot(const char* data)
|
||||
return;
|
||||
}
|
||||
|
||||
// AVA2 NEW_COMMON_DROP; optional so the binary still runs on a locale without the file
|
||||
char szCommonDropNewFileName[FILE_NAME_LEN];
|
||||
snprintf(szCommonDropNewFileName, sizeof(szCommonDropNewFileName), "%s/common_drop_new.txt", LocaleService_GetBasePath().c_str());
|
||||
if (access(szCommonDropNewFileName, R_OK) != 0)
|
||||
sys_log(0, "LoadLocaleFile: CommonDropNew: %s absent", szCommonDropNewFileName);
|
||||
else
|
||||
{
|
||||
sys_log(0, "LoadLocaleFile: CommonDropNew: %s", szCommonDropNewFileName);
|
||||
if (!ITEM_MANAGER::instance().ReadCommonDropNewItemFile(szCommonDropNewFileName))
|
||||
{
|
||||
sys_err("cannot load CommonDropNew: %s", szCommonDropNewFileName);
|
||||
thecore_shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sys_log(0, "LoadLocaleFile: ETCDropItem: %s", szETCDropItemFileName);
|
||||
if (!ITEM_MANAGER::instance().ReadEtcDropItemFile(szETCDropItemFileName))
|
||||
{
|
||||
@@ -1022,6 +1041,8 @@ void CInputDB::Boot(const char* data)
|
||||
|
||||
building::CManager::instance().FinalizeBoot();
|
||||
|
||||
{ const std::string path=LocaleService_GetBasePath()+"/newregen.txt";
|
||||
if (access(path.c_str(),R_OK)==0) CNewMobTimer::instance().LoadFile(path.c_str()); }
|
||||
CMotionManager::instance().Build();
|
||||
|
||||
signal_timer_enable(30);
|
||||
@@ -1091,6 +1112,8 @@ EVENTFUNC(quest_login_event)
|
||||
{
|
||||
sys_log(0, "QUEST_LOAD: Login pc %d by event", ch->GetPlayerID());
|
||||
quest::CQuestManager::instance().Login(ch->GetPlayerID());
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"PickUPMode %u %u",ch->GetPickUPMode(),ch->GetPickUPRarityMode());
|
||||
if(ch->GetProtectTime("track_dungeon")) Ava2TrackDungeonInfo(ch);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -1156,6 +1179,8 @@ void CInputDB::QuestLoad(LPDESC d, const char * c_pData)
|
||||
{
|
||||
sys_log(0, "QUEST_LOAD: Login pc %d", pQuestTable[0].dwPID);
|
||||
quest::CQuestManager::instance().Login(pQuestTable[0].dwPID);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"PickUPMode %u %u",ch->GetPickUPMode(),ch->GetPickUPRarityMode());
|
||||
if(ch->GetProtectTime("track_dungeon")) Ava2TrackDungeonInfo(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1562,6 +1587,14 @@ void CInputDB::ItemLoad(LPDESC d, const char * c_pData)
|
||||
item->AddToCharacter(ch, TItemPos(p->window, p->pos));
|
||||
break;
|
||||
|
||||
// PORT: AVA2 switchbot window; an item that cannot go back there is restored like the others.
|
||||
case SWITCHBOT:
|
||||
if (ch->IsEmptyItemGrid(TItemPos(SWITCHBOT, p->pos), item->GetSize()) && SwitchbotHelper::IsValidItem(item))
|
||||
item->AddToCharacter(ch, TItemPos(SWITCHBOT, p->pos));
|
||||
else
|
||||
v.push_back(item);
|
||||
break;
|
||||
|
||||
case EQUIPMENT:
|
||||
if (item->CheckItemUseLevel(ch->GetLevel()) == true )
|
||||
{
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
#include "block_country.h"
|
||||
#include "dev_log.h"
|
||||
#include "log.h"
|
||||
#include "db.h"
|
||||
#include "item.h"
|
||||
#include "port_premium.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "ava2_channel.h"
|
||||
#include "horsename_manager.h"
|
||||
#include "MarkManager.h"
|
||||
// #include "HackShield.h"
|
||||
@@ -631,6 +636,8 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||
ch->SendGreetMessage();
|
||||
|
||||
_send_bonus_info(ch);
|
||||
|
||||
ch->MountCostumeOnLogin(); // AVA2 mount costume
|
||||
|
||||
for (int i = 0; i <= PREMIUM_MAX_NUM; ++i)
|
||||
{
|
||||
@@ -642,6 +649,10 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||
ch->AddAffect(AFFECT_PREMIUM_START + i, POINT_NONE, 0, 0, remain, 0, true);
|
||||
sys_log(0, "PREMIUM: %s type %d %dmin", ch->GetName(), i, remain);
|
||||
}
|
||||
// PORT: the db core keeps the login-time premium ends; a VIP card used since then is in the account table.
|
||||
PortVipRefresh(ch, false);
|
||||
CSwitchbotManager::Instance().EnterGame(ch); // PORT: AVA2 switchbot (port_switchbot.cpp)
|
||||
Ava2ChannelList(ch); // Authoritative channel after every login/warp, including same-map transfers.
|
||||
|
||||
if (LC_IsEurope())
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
// #include "HackShield.h"
|
||||
// #include "XTrapManager.h"
|
||||
#include "DragonSoul.h"
|
||||
#include "port_switchbot.h"
|
||||
|
||||
extern void SendShout(const char * szText, BYTE bEmpire);
|
||||
extern int g_nPortalLimitTime;
|
||||
@@ -2065,6 +2066,9 @@ void CInputMain::SafeboxCheckin(LPCHARACTER ch, const char * c_pData)
|
||||
if (!ch->CanHandleItem())
|
||||
return;
|
||||
|
||||
if (p->ItemPos.IsSwitchbotPosition()) // PORT: switchbot items go back to the inventory first
|
||||
return;
|
||||
|
||||
CSafebox * pkSafebox = ch->GetSafebox();
|
||||
LPITEM pkItem = ch->GetItem(p->ItemPos);
|
||||
|
||||
@@ -2136,6 +2140,9 @@ void CInputMain::SafeboxCheckout(LPCHARACTER ch, const char * c_pData, bool bMal
|
||||
if (!pkItem)
|
||||
return;
|
||||
|
||||
if (p->ItemPos.IsSwitchbotPosition()) // PORT: only MoveItem fills the switchbot window
|
||||
return;
|
||||
|
||||
if (!ch->IsEmptyItemGrid(p->ItemPos, pkItem->GetSize()))
|
||||
return;
|
||||
|
||||
@@ -3043,6 +3050,73 @@ void CInputMain::Refine(LPCHARACTER ch, const char* c_pData)
|
||||
ch->ClearRefineMode();
|
||||
}
|
||||
|
||||
// AVA2 CInputMain::Switchbot: START carries SWITCHBOT_ALTERNATIVE_COUNT alternative tables, STOP nothing.
|
||||
int CInputMain::Switchbot(LPCHARACTER ch, const char* data, size_t uiBytes)
|
||||
{
|
||||
const TPacketCGSwitchbot* p = reinterpret_cast<const TPacketCGSwitchbot*>(data);
|
||||
|
||||
if (uiBytes < sizeof(TPacketCGSwitchbot))
|
||||
return -1;
|
||||
|
||||
const char* c_pData = data + sizeof(TPacketCGSwitchbot);
|
||||
uiBytes -= sizeof(TPacketCGSwitchbot);
|
||||
|
||||
switch (p->subheader)
|
||||
{
|
||||
case SUBHEADER_CG_SWITCHBOT_START:
|
||||
{
|
||||
const size_t extraLen = sizeof(TSwitchbotAttributeAlternativeTable) * SWITCHBOT_ALTERNATIVE_COUNT;
|
||||
|
||||
if (uiBytes < extraLen)
|
||||
return -1;
|
||||
|
||||
std::vector<TSwitchbotAttributeAlternativeTable> vec_alternatives;
|
||||
|
||||
for (BYTE alternative = 0; alternative < SWITCHBOT_ALTERNATIVE_COUNT; ++alternative)
|
||||
{
|
||||
TSwitchbotAttributeAlternativeTable attr;
|
||||
memcpy(&attr, c_pData, sizeof(attr));
|
||||
c_pData += sizeof(TSwitchbotAttributeAlternativeTable);
|
||||
|
||||
vec_alternatives.push_back(attr);
|
||||
}
|
||||
|
||||
CSwitchbotManager::Instance().Start(ch->GetPlayerID(), p->slot, vec_alternatives);
|
||||
return extraLen;
|
||||
}
|
||||
|
||||
case SUBHEADER_CG_SWITCHBOT_STOP:
|
||||
CSwitchbotManager::Instance().Stop(ch->GetPlayerID(), p->slot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CInputMain::Sash(LPCHARACTER ch, const char* c_pData)
|
||||
{
|
||||
quest::PC * pPC = quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if (pPC && pPC->IsRunning())
|
||||
return;
|
||||
|
||||
const TPacketSash * p = reinterpret_cast<const TPacketSash *>(c_pData);
|
||||
switch (p->subheader)
|
||||
{
|
||||
case SASH_SUBHEADER_CG_CLOSE:
|
||||
ch->CloseSash();
|
||||
break;
|
||||
case SASH_SUBHEADER_CG_ADD:
|
||||
ch->AddSashMaterial(p->tPos, p->bPos);
|
||||
break;
|
||||
case SASH_SUBHEADER_CG_REMOVE:
|
||||
ch->RemoveSashMaterial(p->bPos);
|
||||
break;
|
||||
case SASH_SUBHEADER_CG_REFINE:
|
||||
ch->RefineSashMaterials();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
{
|
||||
LPCHARACTER ch;
|
||||
@@ -3141,6 +3215,9 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
ItemMove(ch, c_pData);
|
||||
break;
|
||||
|
||||
case HEADER_CG_ITEMS_PICKUP:
|
||||
if((iExtraLen=ItemsPickup(ch,c_pData,m_iBufferLeft))<0) return -1;
|
||||
break;
|
||||
case HEADER_CG_ITEM_PICKUP:
|
||||
if (!ch->IsObserverMode())
|
||||
ItemPickup(ch, c_pData);
|
||||
@@ -3324,6 +3401,15 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
// }
|
||||
// break;
|
||||
|
||||
case HEADER_CG_SASH:
|
||||
Sash(ch, c_pData);
|
||||
break;
|
||||
|
||||
case HEADER_CG_SWITCHBOT:
|
||||
if ((iExtraLen = Switchbot(ch, c_pData, m_iBufferLeft)) < 0)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case HEADER_CG_DRAGON_SOUL_REFINE:
|
||||
{
|
||||
TPacketCGDragonSoulRefine* p = reinterpret_cast <TPacketCGDragonSoulRefine*>((void*)c_pData);
|
||||
@@ -3400,3 +3486,19 @@ int CInputDead::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
return (iExtraLen);
|
||||
}
|
||||
|
||||
|
||||
// PORT: AVA2 ItemsPickup with checked framing and bounded hostile-client input.
|
||||
int CInputMain::ItemsPickup(LPCHARACTER ch,const char* data,size_t bytes) {
|
||||
TPacketCGItemsPickUp packet; memcpy(&packet,data,sizeof(packet));
|
||||
if(packet.count>4096) { ch->GetDesc()->SetPhase(PHASE_CLOSE); return 0; }
|
||||
const size_t extra=size_t(packet.count)*sizeof(DWORD);
|
||||
if(bytes<sizeof(packet)+extra) return -1;
|
||||
if(!(ch->GetPickUPMode()&1) || ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->IsObserverMode()) return int(extra);
|
||||
for(DWORD i=0;i<packet.count;++i) {
|
||||
DWORD vid;memcpy(&vid,data+sizeof(packet)+i*4,4);
|
||||
LPITEM item=ITEM_MANAGER::instance().FindByVID(vid);
|
||||
if(item && item->GetSectree() && item->DistanceValid(ch) && item->IsOwnership(ch) && ch->CheckItemCanGet(item))
|
||||
ch->PickupItem(vid);
|
||||
}
|
||||
return int(extra);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "../../common/billing.h"
|
||||
#include "config.h"
|
||||
#include "desc_client.h"
|
||||
@@ -21,6 +22,8 @@
|
||||
#include "pcbang.h"
|
||||
#include "skill.h"
|
||||
#include "threeway_war.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "ava2_channel.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -57,6 +60,15 @@ int CInputP2P::Relay(LPDESC d, const char * c_pData, size_t uiBytes)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(p->szName,"#ava2_regen")) {
|
||||
struct Wire { uint16_t id; uint8_t alive; uint8_t channel; } __attribute__((packed));
|
||||
if (p->lSize == sizeof(Wire)) {
|
||||
Wire w; memcpy(&w,c_pData+sizeof(TPacketGGRelay),sizeof(w));
|
||||
if (w.alive <= 1) CNewMobTimer::instance().UpdateNewRegen(w.id,w.alive,true,w.channel);
|
||||
}
|
||||
return p->lSize;
|
||||
}
|
||||
if (Ava2ChannelRelay(d,p->szName,c_pData+sizeof(TPacketGGRelay),p->lSize))return p->lSize;
|
||||
if (PortBossRelay(d, p->szName, c_pData + sizeof(TPacketGGRelay), p->lSize))
|
||||
return p->lSize;
|
||||
|
||||
@@ -416,6 +428,17 @@ void CInputP2P::IamAwake(LPDESC d, const char * c_pData)
|
||||
sys_log(0, "P2P Awakeness check from %s. My P2P connection number is %d. and details...\n%s", d->GetHostName(), P2P_MANAGER::instance().GetDescCount(), hostNames.c_str());
|
||||
}
|
||||
|
||||
// AVA2: every core gets the table; only the warp target keeps it.
|
||||
void CInputP2P::Switchbot(LPDESC d, const char * c_pData)
|
||||
{
|
||||
const TPacketGGSwitchbot* p = reinterpret_cast<const TPacketGGSwitchbot*>(c_pData);
|
||||
|
||||
if (p->wPort != mother_port)
|
||||
return;
|
||||
|
||||
CSwitchbotManager::Instance().P2PReceiveSwitchbot(p->table);
|
||||
}
|
||||
|
||||
int CInputP2P::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
{
|
||||
if (test_server)
|
||||
@@ -536,6 +559,10 @@ int CInputP2P::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
case HEADER_GG_CHECK_AWAKENESS:
|
||||
IamAwake(d, c_pData);
|
||||
break;
|
||||
|
||||
case HEADER_GG_SWITCHBOT:
|
||||
Switchbot(d, c_pData);
|
||||
break;
|
||||
}
|
||||
|
||||
return (iExtraLen);
|
||||
|
||||
+122
-10
@@ -64,6 +64,7 @@ void CItem::Initialize()
|
||||
m_pkAccessorySocketExpireEvent = NULL;
|
||||
|
||||
m_bSkipSave = false;
|
||||
m_deferChestUpdate = false;
|
||||
m_dwLastOwnerPID = 0;
|
||||
}
|
||||
|
||||
@@ -206,9 +207,14 @@ void CItem::AddFlag(long bit)
|
||||
|
||||
void CItem::UpdatePacket()
|
||||
{
|
||||
if(m_deferChestUpdate) return;
|
||||
if (!m_pOwner || !m_pOwner->GetDesc())
|
||||
return;
|
||||
|
||||
// PORT: AVA2 switchbot: rolls in that window reach the client as SUBHEADER_GC_SWITCHBOT_UPDATE_ITEM.
|
||||
if (m_bWindow == SWITCHBOT)
|
||||
return;
|
||||
|
||||
TPacketGCItemUpdate pack;
|
||||
|
||||
pack.header = HEADER_GC_ITEM_UPDATE;
|
||||
@@ -317,6 +323,13 @@ LPITEM CItem::RemoveFromCharacter()
|
||||
else
|
||||
pOwner->SetItem(TItemPos(m_bWindow, m_wCell), NULL);
|
||||
}
|
||||
else if (m_bWindow == SWITCHBOT) // PORT: AVA2 switchbot window
|
||||
{
|
||||
if (m_wCell >= SWITCHBOT_SLOT_COUNT)
|
||||
sys_err("CItem::RemoveFromCharacter: pos >= SWITCHBOT_SLOT_COUNT");
|
||||
else
|
||||
pOwner->SetItem(TItemPos(SWITCHBOT, m_wCell), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
TItemPos cell(INVENTORY, m_wCell);
|
||||
@@ -362,10 +375,32 @@ bool CItem::AddToCharacter(LPCHARACTER ch, TItemPos Cell)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (SWITCHBOT == window_type) // PORT: AVA2 switchbot window
|
||||
{
|
||||
if (pos >= SWITCHBOT_SLOT_COUNT_REAL)
|
||||
{
|
||||
sys_err("CItem::AddToCharacter: switchbot cell overflow: %s to %s cell %d", m_pProto->szName, ch->GetName(), pos);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch->GetDesc())
|
||||
m_dwLastOwnerPID = ch->GetPlayerID();
|
||||
|
||||
// AVA2 sash: a fresh sash gets the starting absorption of its grade
|
||||
if (GetType() == ITEM_COSTUME && GetSubType() == COSTUME_SASH && GetSocket(SASH_ABSORPTION_SOCKET) == 0)
|
||||
{
|
||||
long lVal;
|
||||
switch (GetValue(SASH_GRADE_VALUE_FIELD))
|
||||
{
|
||||
case 2: lVal = SASH_GRADE_2_ABS; break;
|
||||
case 3: lVal = SASH_GRADE_3_ABS; break;
|
||||
case 4: lVal = number(SASH_GRADE_4_ABS_MIN, SASH_GRADE_4_ABS_MAX_COMB); break;
|
||||
default: lVal = SASH_GRADE_1_ABS; break;
|
||||
}
|
||||
SetSocket(SASH_ABSORPTION_SOCKET, lVal);
|
||||
}
|
||||
|
||||
event_cancel(&m_pkDestroyEvent);
|
||||
|
||||
ch->SetItem(TItemPos(window_type, pos), this);
|
||||
@@ -473,9 +508,12 @@ bool CItem::CanUsedBy(LPCHARACTER ch)
|
||||
|
||||
int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
||||
{
|
||||
if (IsTalisman())
|
||||
return WEAR_PENDANT;
|
||||
|
||||
// 코스츔 아이템(ITEM_COSTUME)은 WearFlag 없어도 됨. (sub type으로 착용위치 구분. 귀찮게 또 wear flag 줄 필요가 있나..)
|
||||
// 용혼석(ITEM_DS, ITEM_SPECIAL_DS)도 SUB_TYPE으로 구분. 신규 반지, 벨트는 ITEM_TYPE으로 구분 -_-
|
||||
if ((0 == GetWearFlag() || ITEM_TOTEM == GetType()) && ITEM_COSTUME != GetType() && ITEM_DS != GetType() && ITEM_SPECIAL_DS != GetType() && ITEM_RING != GetType() && ITEM_BELT != GetType())
|
||||
if ((0 == GetWearFlag() || ITEM_TOTEM == GetType()) && ITEM_COSTUME != GetType() && ITEM_DS != GetType() && ITEM_SPECIAL_DS != GetType() && ITEM_RING != GetType() && ITEM_BELT != GetType() && ITEM_NEW_RINGS != GetType())
|
||||
return -1;
|
||||
|
||||
// 용혼석 슬롯을 WEAR로 처리할 수가 없어서(WEAR는 최대 32개까지 가능한데 용혼석을 추가하면 32가 넘는다.)
|
||||
@@ -507,6 +545,12 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
||||
return WEAR_COSTUME_BODY;
|
||||
else if (GetSubType() == COSTUME_HAIR)
|
||||
return WEAR_COSTUME_HAIR;
|
||||
else if (GetSubType() == COSTUME_SASH)
|
||||
return WEAR_COSTUME_SASH;
|
||||
else if (GetSubType() == COSTUME_MOUNT)
|
||||
return WEAR_COSTUME_MOUNT;
|
||||
else if (GetSubType() == COSTUME_MOUNT_SKIN)
|
||||
return WEAR_COSTUME_MOUNT_SKIN;
|
||||
}
|
||||
else if (GetType() == ITEM_RING)
|
||||
{
|
||||
@@ -517,6 +561,13 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
||||
}
|
||||
else if (GetType() == ITEM_BELT)
|
||||
return WEAR_BELT;
|
||||
else if (GetType() == ITEM_NEW_RINGS) // AVA2 new rings
|
||||
{
|
||||
if (ch->GetWear(WEAR_RINGS_1))
|
||||
return WEAR_RINGS_2;
|
||||
else
|
||||
return WEAR_RINGS_1;
|
||||
}
|
||||
else if (GetWearFlag() & WEARABLE_BODY)
|
||||
return WEAR_BODY;
|
||||
else if (GetWearFlag() & WEARABLE_HEAD)
|
||||
@@ -635,23 +686,54 @@ void CItem::ModifyPoints(bool bAdd)
|
||||
accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
||||
}
|
||||
|
||||
// AVA2 sash: the absorbed item's applies (and a body armor's defense) at the absorption %, instead of
|
||||
// the sash's own applies; its attributes count at the absorption % below
|
||||
const bool bSash = GetType() == ITEM_COSTUME && GetSubType() == COSTUME_SASH;
|
||||
const TItemTable * pkAbsorbed = bSash && GetSocket(SASH_ABSORBED_SOCKET) ? ITEM_MANAGER::instance().GetTable(GetSocket(SASH_ABSORBED_SOCKET)) : NULL;
|
||||
const long lAbsorption = bSash ? GetSocket(SASH_ABSORPTION_SOCKET) : 100;
|
||||
|
||||
if (pkAbsorbed && pkAbsorbed->bType == ITEM_ARMOR && pkAbsorbed->bSubType == ARMOR_BODY)
|
||||
{
|
||||
long lDefGrade = (long) ((pkAbsorbed->alValues[1] + pkAbsorbed->alValues[5] * 2) * lAbsorption / 100.0 + .5);
|
||||
if (pkAbsorbed->alValues[1] > 0 || pkAbsorbed->alValues[5] > 0)
|
||||
lDefGrade += 1;
|
||||
m_pOwner->ApplyPoint(APPLY_DEF_GRADE_BONUS, bAdd ? lDefGrade : -lDefGrade);
|
||||
|
||||
long lDefMagicBonus = (long) (pkAbsorbed->alValues[0] * lAbsorption / 100.0 + .5);
|
||||
if (pkAbsorbed->alValues[0] > 0)
|
||||
lDefMagicBonus += 1;
|
||||
m_pOwner->ApplyPoint(APPLY_MAGIC_DEF_GRADE, bAdd ? lDefMagicBonus : -lDefMagicBonus);
|
||||
}
|
||||
|
||||
for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
|
||||
{
|
||||
if (m_pProto->aApplies[i].bType == APPLY_NONE)
|
||||
continue;
|
||||
|
||||
BYTE bType = m_pProto->aApplies[i].bType;
|
||||
long value = m_pProto->aApplies[i].lValue;
|
||||
|
||||
if (m_pProto->aApplies[i].bType == APPLY_SKILL)
|
||||
if (bSash)
|
||||
{
|
||||
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : value ^ 0x00800000);
|
||||
if (!pkAbsorbed || pkAbsorbed->aApplies[i].bType == APPLY_NONE || pkAbsorbed->aApplies[i].lValue < 0)
|
||||
continue;
|
||||
|
||||
bType = pkAbsorbed->aApplies[i].bType;
|
||||
value = (long) (pkAbsorbed->aApplies[i].lValue * lAbsorption / 100.0 + .5);
|
||||
if (pkAbsorbed->aApplies[i].lValue > 0 && value <= 0)
|
||||
value += 1;
|
||||
}
|
||||
|
||||
if (bType == APPLY_NONE)
|
||||
continue;
|
||||
|
||||
if (bType == APPLY_SKILL)
|
||||
{
|
||||
m_pOwner->ApplyPoint(bType, bAdd ? value : value ^ 0x00800000);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != accessoryGrade)
|
||||
value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
|
||||
|
||||
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value);
|
||||
m_pOwner->ApplyPoint(bType, bAdd ? value : -value);
|
||||
}
|
||||
}
|
||||
// 초승달의 반지, 할로윈 사탕, 행복의 반지, 영원한 사랑의 펜던트의 경우
|
||||
@@ -672,11 +754,19 @@ void CItem::ModifyPoints(bool bAdd)
|
||||
if (GetAttributeType(i))
|
||||
{
|
||||
const TPlayerItemAttribute& ia = GetAttribute(i);
|
||||
long sValue = ia.sValue;
|
||||
|
||||
if (bSash)
|
||||
{
|
||||
sValue = (long) (ia.sValue * lAbsorption / 100.0 + .5);
|
||||
if (ia.sValue > 0 && sValue <= 0)
|
||||
sValue += 1;
|
||||
}
|
||||
|
||||
if (ia.bType == APPLY_SKILL)
|
||||
m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : ia.sValue ^ 0x00800000);
|
||||
m_pOwner->ApplyPoint(ia.bType, bAdd ? sValue : sValue ^ 0x00800000);
|
||||
else
|
||||
m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : -ia.sValue);
|
||||
m_pOwner->ApplyPoint(ia.bType, bAdd ? sValue : -sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -766,6 +856,13 @@ void CItem::ModifyPoints(bool bAdd)
|
||||
toSetValue = (true == bAdd) ? this->GetValue(3) : 0;
|
||||
}
|
||||
|
||||
// AVA2 sash: the client draws item (part + 85000)
|
||||
else if (GetSubType() == COSTUME_SASH)
|
||||
{
|
||||
toSetPart = PART_SASH;
|
||||
toSetValue = (true == bAdd) ? this->GetVnum() - 85000 : 0;
|
||||
}
|
||||
|
||||
if (PART_MAX_NUM != toSetPart)
|
||||
{
|
||||
m_pOwner->SetPart((BYTE)toSetPart, toSetValue);
|
||||
@@ -808,6 +905,7 @@ bool CItem::IsEquipable() const
|
||||
case ITEM_SPECIAL_DS:
|
||||
case ITEM_RING:
|
||||
case ITEM_BELT:
|
||||
case ITEM_NEW_RINGS:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1581,7 +1679,7 @@ int CItem::GetSpecialGroup() const
|
||||
bool CItem::IsAccessoryForSocket()
|
||||
{
|
||||
return (m_pProto->bType == ITEM_ARMOR && (m_pProto->bSubType == ARMOR_WRIST || m_pProto->bSubType == ARMOR_NECK || m_pProto->bSubType == ARMOR_EAR)) ||
|
||||
(m_pProto->bType == ITEM_BELT); // 2013년 2월 새로 추가된 '벨트' 아이템의 경우 기획팀에서 악세서리 소켓 시스템을 그대로 이용하자고 함.
|
||||
(m_pProto->bType == ITEM_BELT) || (m_pProto->bType == ITEM_NEW_RINGS); // 2013년 2월 새로 추가된 '벨트' 아이템의 경우 기획팀에서 악세서리 소켓 시스템을 그대로 이용하자고 함.
|
||||
}
|
||||
|
||||
void CItem::SetAccessorySocketGrade(int iGrade)
|
||||
@@ -1703,6 +1801,16 @@ bool CItem::IsRideItem()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CItem::IsCostumeMount()
|
||||
{
|
||||
return GetType() == ITEM_COSTUME && GetSubType() == COSTUME_MOUNT;
|
||||
}
|
||||
|
||||
bool CItem::IsCostumeMountSkin()
|
||||
{
|
||||
return GetType() == ITEM_COSTUME && GetSubType() == COSTUME_MOUNT_SKIN;
|
||||
}
|
||||
|
||||
bool CItem::IsRamadanRing()
|
||||
{
|
||||
if (GetVnum() == UNIQUE_ITEM_RAMADAN_RING)
|
||||
@@ -1788,6 +1896,10 @@ bool CItem::CanPutInto(LPITEM item)
|
||||
else if(item->GetType() == ITEM_RING)
|
||||
return CanPutIntoRing(item, this);
|
||||
|
||||
// AVA2 new rings take the jewel of the matching AVA2 accessory family (port_rings.cpp).
|
||||
else if (item->GetType() == ITEM_NEW_RINGS)
|
||||
return GetVnum() == GetNewRingJewelVnum(item->GetVnum());
|
||||
|
||||
else if (item->GetType() != ITEM_ARMOR)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ class CItem : public CEntity
|
||||
|
||||
bool DistanceValid(LPCHARACTER ch);
|
||||
|
||||
void SetUpdateStatus(bool deferred) { m_deferChestUpdate=deferred; }
|
||||
void UpdatePacket();
|
||||
void UsePacketEncode(LPCHARACTER ch, LPCHARACTER victim, struct packet_item_use * packet);
|
||||
|
||||
@@ -234,6 +235,14 @@ class CItem : public CEntity
|
||||
|
||||
public:
|
||||
bool IsRideItem();
|
||||
bool IsCostumeMount(); // AVA2 mount costume
|
||||
bool IsCostumeMountSkin();
|
||||
bool IsCostumeEnchant(); // AVA2 costume enchant (port_costume_attr.cpp)
|
||||
bool IsTalisman(); // AVA2 talisman (port_pendant.cpp)
|
||||
int GetPendantScrollKind();
|
||||
bool IsNewRing(); // AVA2 new rings (port_rings.cpp)
|
||||
void PutNewRingAttributeWithLevel(BYTE bLevel);
|
||||
void PutPendantAttributeWithLevel(BYTE bLevel); // port_pendant.cpp
|
||||
bool IsRamadanRing();
|
||||
|
||||
void ClearMountAttributeAndAffect();
|
||||
@@ -293,6 +302,7 @@ class CItem : public CEntity
|
||||
DWORD m_dwOwnershipPID;
|
||||
|
||||
bool m_bSkipSave;
|
||||
bool m_deferChestUpdate = false;
|
||||
|
||||
bool m_isLocked;
|
||||
|
||||
@@ -331,4 +341,8 @@ EVENTINFO(item_vid_event_info)
|
||||
}
|
||||
};
|
||||
|
||||
DWORD GetNewRingJewelVnum(DWORD dwRingVnum); // port_rings.cpp, 0 = none
|
||||
int GetNewRingAttrMaxValue(BYTE bApply); // port_rings.cpp, 0 = not in the ring pool
|
||||
int GetPendantAttrMaxValue(BYTE bApply); // port_pendant.cpp, 0 = not in the talisman pool
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,10 @@ int CItem::GetAttributeSetIndex()
|
||||
return ATTRIBUTE_SET_WEAPON;
|
||||
}
|
||||
|
||||
// AVA2 costume sub types reuse ARMOR_SHIELD/WRIST/FOOTS numbers but take no random attributes
|
||||
if (GetType() == ITEM_COSTUME && (GetSubType() == COSTUME_MOUNT || GetSubType() == COSTUME_SASH || GetSubType() == COSTUME_MOUNT_SKIN))
|
||||
return -1;
|
||||
|
||||
if (GetType() == ITEM_ARMOR || GetType() == ITEM_COSTUME)
|
||||
{
|
||||
switch (GetSubType())
|
||||
@@ -114,6 +118,19 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel)
|
||||
|
||||
void CItem::PutAttributeWithLevel(BYTE bLevel)
|
||||
{
|
||||
if (IsNewRing())
|
||||
{
|
||||
PutNewRingAttributeWithLevel(bLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
// PORT: talismans reroll from their own pool (port_pendant.cpp), as the switchbot's 71302 rolls need.
|
||||
if (IsTalisman())
|
||||
{
|
||||
PutPendantAttributeWithLevel(bLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
int iAttributeSet = GetAttributeSetIndex();
|
||||
|
||||
if (iAttributeSet < 0)
|
||||
|
||||
@@ -817,25 +817,26 @@ bool ITEM_MANAGER::GetDropPct(LPCHARACTER pkChr, LPCHARACTER pkKiller, OUT int&
|
||||
|
||||
//if (pkKiller->GetPoint(POINT_MALL_ITEMBONUS) > 0)
|
||||
//iDeltaPercent += iDeltaPercent * pkKiller->GetPoint(POINT_MALL_ITEMBONUS) / 100;
|
||||
// ADD_PREMIUM
|
||||
// ADD_PREMIUM (AVA2 rates: premium or a thief glove doubles, everyone else gets +50%)
|
||||
if (pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0 ||
|
||||
pkKiller->IsEquipUniqueGroup(UNIQUE_GROUP_DOUBLE_ITEM))
|
||||
iDeltaPercent += iDeltaPercent;
|
||||
else
|
||||
iDeltaPercent += iDeltaPercent / 2;
|
||||
// END_OF_ADD_PREMIUM
|
||||
|
||||
// PC_BANG_ITEM_ADD
|
||||
if (pkKiller->GetPoint(POINT_PC_BANG_DROP_BONUS) > 0)
|
||||
{
|
||||
if (pkKiller->IsPCBang() == true)
|
||||
iDeltaPercent += iDeltaPercent * pkKiller->GetPoint(POINT_PC_BANG_DROP_BONUS)/100;
|
||||
}
|
||||
// END_PC_BANG_ITEM_ADD
|
||||
// AVA2: the permanent glove adds 100 with premium and 50 alone (or a removable glove with premium). This also
|
||||
// fixes the original ternary without parentheses, which always made the divisor 100 and ignored PRIV_ITEM_DROP.
|
||||
int bonus = 0;
|
||||
if (pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM) && pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0)
|
||||
bonus = 100;
|
||||
else if (pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM) ||
|
||||
(pkKiller->IsEquipUniqueGroup(UNIQUE_GROUP_DOUBLE_ITEM) && pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0))
|
||||
bonus = 50;
|
||||
|
||||
iRandRange = 4000000;
|
||||
iRandRange = iRandRange * 100 /
|
||||
(100 +
|
||||
CPrivManager::instance().GetPriv(pkKiller, PRIV_ITEM_DROP) +
|
||||
pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM)?100:0);
|
||||
iRandRange = iRandRange * 100 /
|
||||
(100 + CPrivManager::instance().GetPriv(pkKiller, PRIV_ITEM_DROP) + bonus);
|
||||
|
||||
if (distribution_test_server) iRandRange /= 3;
|
||||
|
||||
@@ -926,6 +927,26 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
|
||||
}
|
||||
}
|
||||
|
||||
// AVA2 NEW_COMMON_DROP: killer level within a group's range and within 20 levels of the victim
|
||||
if (abs(pkChr->GetLevel() - iLevel) <= 20)
|
||||
{
|
||||
for (size_t g = 0; g < m_vec_pkCommonNewItemGroup.size(); ++g)
|
||||
{
|
||||
const CCommonDropNew* commonNew = m_vec_pkCommonNewItemGroup[g];
|
||||
if (iLevel < commonNew->minLevel || iLevel > commonNew->maxLevel || !commonNew->CanDropThisMap(pkKiller->GetMapIndex()))
|
||||
continue;
|
||||
for (size_t i = 0; i < commonNew->m_vecProbs.size(); ++i)
|
||||
{
|
||||
int iPercent = (commonNew->m_vecProbs[i] * iDeltaPercent) / 100;
|
||||
if (iPercent >= number(1, iRandRange))
|
||||
{
|
||||
item = CreateItem(commonNew->m_vecItems[i].first, commonNew->m_vecItems[i].second, 0, true);
|
||||
if (item) vec_item.push_back(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MobDropItem Group
|
||||
{
|
||||
itertype(m_map_pkMobItemGroup) it;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef __INC_ITEM_MANAGER__
|
||||
#define __INC_ITEM_MANAGER__
|
||||
#include "port_feature_types.h"
|
||||
#include <climits>
|
||||
|
||||
#ifdef M2_USE_POOL
|
||||
#include "pool.h"
|
||||
@@ -75,6 +76,8 @@ class CSpecialItemGroup
|
||||
m_vecItems.push_back(CSpecialItemInfo(vnum, count, rare));
|
||||
}
|
||||
|
||||
size_t GetGroupSize() const { return m_vecItems.size(); }
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return m_vecProbs.empty();
|
||||
@@ -273,6 +276,31 @@ class CDropItemGroup
|
||||
std::vector<SDropItemGroupInfo> m_vec_items;
|
||||
};
|
||||
|
||||
// AVA2 NEW_COMMON_DROP (common_drop_new.txt): level-ranged, optionally map-restricted groups replacing the
|
||||
// rank-based common_drop_item.txt. Probabilities are stored on the 40000-per-percent scale of the other drop tables.
|
||||
class CCommonDropNew
|
||||
{
|
||||
public:
|
||||
CCommonDropNew() : minLevel(0), maxLevel(INT_MAX) {}
|
||||
|
||||
bool CanDropThisMap(DWORD mapIndex) const
|
||||
{
|
||||
return m_vecMapIndex.empty() || std::find(m_vecMapIndex.begin(), m_vecMapIndex.end(), mapIndex) != m_vecMapIndex.end();
|
||||
}
|
||||
|
||||
void AddItem(DWORD dwItemVnum, DWORD iCount, DWORD iPartPct)
|
||||
{
|
||||
m_vecProbs.push_back(iPartPct);
|
||||
m_vecItems.push_back(std::make_pair(dwItemVnum, iCount));
|
||||
}
|
||||
|
||||
int minLevel;
|
||||
int maxLevel;
|
||||
std::vector<DWORD> m_vecMapIndex;
|
||||
std::vector<DWORD> m_vecProbs;
|
||||
std::vector<std::pair<DWORD, DWORD> > m_vecItems;
|
||||
};
|
||||
|
||||
class CLevelItemGroup
|
||||
{
|
||||
struct SLevelItemGroupInfo
|
||||
@@ -393,6 +421,7 @@ class ITEM_MANAGER : public singleton<ITEM_MANAGER>
|
||||
bool CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::vector<LPITEM> & vec_item);
|
||||
|
||||
bool ReadCommonDropItemFile(const char * c_pszFileName);
|
||||
bool ReadCommonDropNewItemFile(const char * c_pszFileName);
|
||||
bool ReadEtcDropItemFile(const char * c_pszFileName);
|
||||
bool ReadDropItemGroup(const char * c_pszFileName);
|
||||
bool ReadMonsterDropItemGroup(const char * c_pszFileName);
|
||||
@@ -444,6 +473,7 @@ class ITEM_MANAGER : public singleton<ITEM_MANAGER>
|
||||
std::map<DWORD, CMobItemGroup*> m_map_pkMobItemGroup;
|
||||
std::map<DWORD, CLevelItemGroup*> m_map_pkLevelItemGroup;
|
||||
std::map<DWORD, CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
|
||||
std::vector<CCommonDropNew*> m_vec_pkCommonNewItemGroup;
|
||||
|
||||
// CHECK_UNIQUE_GROUP
|
||||
std::map<DWORD, int> m_ItemToSpecialGroup;
|
||||
|
||||
@@ -169,9 +169,9 @@ bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName)
|
||||
if ("attr" == stType)
|
||||
{
|
||||
CSpecialAttrGroup * pkGroup = M2_NEW CSpecialAttrGroup(iVnum);
|
||||
for (int k = 1; k < 256; ++k)
|
||||
for (int k = 1; k < 1024; ++k) // AVA2 @fixme148: groups up to 1023 entries
|
||||
{
|
||||
char buf[4];
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "%d", k);
|
||||
|
||||
if (loader.GetTokenVector(buf, &pTok))
|
||||
@@ -212,9 +212,9 @@ bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName)
|
||||
else
|
||||
{
|
||||
CSpecialItemGroup * pkGroup = M2_NEW CSpecialItemGroup(iVnum, type);
|
||||
for (int k = 1; k < 256; ++k)
|
||||
for (int k = 1; k < 1024; ++k) // AVA2 @fixme148: groups up to 1023 entries
|
||||
{
|
||||
char buf[4];
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "%d", k);
|
||||
|
||||
if (loader.GetTokenVector(buf, &pTok))
|
||||
@@ -427,6 +427,96 @@ bool ITEM_MANAGER::ConvSpecialDropItemFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
// AVA2 NEW_COMMON_DROP. Each group: optional "map_index" list (0 = every map), optional "level_range MIN MAX" of the
|
||||
// killer, entries "N vnum count percent". A malformed group fails the whole file like the other drop tables.
|
||||
bool ITEM_MANAGER::ReadCommonDropNewItemFile(const char * c_pszFileName)
|
||||
{
|
||||
CTextFileLoader loader;
|
||||
if (!loader.Load(c_pszFileName))
|
||||
return false;
|
||||
|
||||
std::vector<CCommonDropNew*> groups;
|
||||
std::string stName;
|
||||
bool ok = true;
|
||||
|
||||
for (DWORD i = 0; i < loader.GetChildNodeCount() && ok; ++i)
|
||||
{
|
||||
CCommonDropNew* dropPtr = M2_NEW CCommonDropNew;
|
||||
TTokenVector* pTok = NULL;
|
||||
loader.SetChildNode(i);
|
||||
loader.GetCurrentNodeName(&stName);
|
||||
|
||||
if (loader.GetTokenVector("map_index", &pTok))
|
||||
{
|
||||
if (pTok->empty())
|
||||
ok = false;
|
||||
for (DWORD j = 0; ok && j < pTok->size(); ++j)
|
||||
{
|
||||
DWORD mapIndex = 0;
|
||||
str_to_number(mapIndex, pTok->at(j).c_str());
|
||||
if (mapIndex)
|
||||
dropPtr->m_vecMapIndex.push_back(mapIndex);
|
||||
}
|
||||
}
|
||||
if (ok && loader.GetTokenVector("level_range", &pTok))
|
||||
{
|
||||
if (pTok->size() != 2)
|
||||
ok = false;
|
||||
else
|
||||
{
|
||||
str_to_number(dropPtr->minLevel, pTok->at(0).c_str());
|
||||
str_to_number(dropPtr->maxLevel, pTok->at(1).c_str());
|
||||
}
|
||||
}
|
||||
for (int k = 1; ok && k < 256; ++k)
|
||||
{
|
||||
char buf[4];
|
||||
snprintf(buf, sizeof(buf), "%d", k);
|
||||
if (!loader.GetTokenVector(buf, &pTok))
|
||||
continue;
|
||||
DWORD itemVnum = 0, itemCount = 0;
|
||||
float itemPct = 0.0f;
|
||||
if (pTok->size() != 3)
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
str_to_number(itemVnum, pTok->at(0).c_str());
|
||||
str_to_number(itemCount, pTok->at(1).c_str());
|
||||
str_to_number(itemPct, pTok->at(2).c_str());
|
||||
if (!GetTable(itemVnum) || !itemCount)
|
||||
{
|
||||
sys_err("ReadCommonDropNewItemFile : no item %u (count %u) : node %s", itemVnum, itemCount, stName.c_str());
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
dropPtr->AddItem(itemVnum, itemCount, (DWORD)(40000.0f * itemPct));
|
||||
}
|
||||
loader.SetParentNode();
|
||||
|
||||
if (!ok)
|
||||
sys_err("ReadCommonDropNewItemFile : Syntax error %s : node %s", c_pszFileName, stName.c_str());
|
||||
if (!ok || dropPtr->m_vecItems.empty())
|
||||
{
|
||||
M2_DELETE(dropPtr);
|
||||
continue;
|
||||
}
|
||||
groups.push_back(dropPtr);
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
for (size_t i = 0; i < groups.size(); ++i)
|
||||
M2_DELETE(groups[i]);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_vec_pkCommonNewItemGroup.size(); ++i)
|
||||
M2_DELETE(m_vec_pkCommonNewItemGroup[i]);
|
||||
m_vec_pkCommonNewItemGroup.swap(groups);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName)
|
||||
{
|
||||
FILE * fp = fopen(c_pszFileName, "r");
|
||||
@@ -634,7 +724,7 @@ bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)
|
||||
else
|
||||
{
|
||||
bNew = false;
|
||||
CDropItemGroup* pkGroup = it->second;
|
||||
pkGroup = it->second;
|
||||
}
|
||||
|
||||
for (int k = 1; k < 256; ++k)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "constants.h"
|
||||
#include "config.h"
|
||||
#include "event.h"
|
||||
@@ -63,6 +64,7 @@
|
||||
#include "SpeedServer.h"
|
||||
// #include "XTrapManager.h"
|
||||
#include "DragonSoul.h"
|
||||
#include "port_switchbot.h"
|
||||
#include <boost/bind.hpp>
|
||||
#ifndef __WIN32__
|
||||
#include "limit_time.h"
|
||||
@@ -238,7 +240,9 @@ extern std::vector<TPlayerTable> g_vec_save;
|
||||
unsigned int save_idx = 0;
|
||||
|
||||
void PortBossTick();
|
||||
void Ava2ChannelTick();
|
||||
void PortAttrLockBoot();
|
||||
void PortSwitchbotBoot();
|
||||
|
||||
void heartbeat(LPHEART ht, int pulse)
|
||||
{
|
||||
@@ -266,6 +270,7 @@ void heartbeat(LPHEART ht, int pulse)
|
||||
if (!g_bAuthServer)
|
||||
{
|
||||
PortBossTick();
|
||||
Ava2ChannelTick();
|
||||
|
||||
TPlayerCountPacket pack;
|
||||
pack.dwCount = DESC_MANAGER::instance().GetLocalUserCount();
|
||||
@@ -520,7 +525,9 @@ int main(int argc, char **argv)
|
||||
// CXTrapManager XTManager;
|
||||
|
||||
CSpeedServerManager SSManager;
|
||||
CNewMobTimer mobTimer;
|
||||
DSManager dsManager;
|
||||
CSwitchbotManager switchbotManager; // PORT: AVA2 switchbot
|
||||
|
||||
#ifdef __AUCTION__
|
||||
AuctionManager auctionManager;
|
||||
@@ -661,6 +668,7 @@ int main(int argc, char **argv)
|
||||
sys_log(0, "<shutdown> Destroying CShopManager...");
|
||||
shop_manager.Destroy();
|
||||
sys_log(0, "<shutdown> Destroying CHARACTER_MANAGER...");
|
||||
mobTimer.Destroy();
|
||||
char_manager.Destroy();
|
||||
sys_log(0, "<shutdown> Destroying ITEM_MANAGER...");
|
||||
item_manager.Destroy();
|
||||
@@ -794,7 +802,10 @@ int start(int argc, char **argv)
|
||||
// END_OF_LOCALE_SERVICE
|
||||
|
||||
if (!g_bAuthServer)
|
||||
{
|
||||
PortAttrLockBoot();
|
||||
PortSwitchbotBoot();
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
// In Windows dev mode, "verbose" option is [on] by default.
|
||||
|
||||
@@ -0,0 +1,992 @@
|
||||
// AVA2 ultimate regen / tracker; optional newregen.txt. See docs/FEATURE-AVA2-TRACK.md.
|
||||
#include "stdafx.h"
|
||||
#include "constants.h"
|
||||
#include "config.h"
|
||||
#include "desc.h"
|
||||
#include "buffer_manager.h"
|
||||
#include "desc_manager.h"
|
||||
#include "p2p.h"
|
||||
#include "packet.h"
|
||||
#include "map_location.h"
|
||||
#include "start_position.h"
|
||||
#include "questmanager.h"
|
||||
#include "char.h"
|
||||
#include "char_manager.h"
|
||||
#include "sectree_manager.h"
|
||||
#include "new_mob_timer.h"
|
||||
#include "utils.h"
|
||||
#include <algorithm>
|
||||
#include "mob_manager.h"
|
||||
#include "dungeon.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
CNewMobTimer::CNewMobTimer() : m_pkMobRegenTimerEvent(NULL) {}
|
||||
CNewMobTimer::~CNewMobTimer() { Destroy(); }
|
||||
EVENTINFO(empty_event_info){empty_event_info(){}};
|
||||
EVENTFUNC(main_timer)
|
||||
{
|
||||
empty_event_info* info = dynamic_cast<empty_event_info*>(event->info);
|
||||
if (info == NULL)
|
||||
return 0;
|
||||
return PASSES_PER_SEC(CNewMobTimer::instance().Update());
|
||||
}
|
||||
|
||||
void CNewMobTimer::Destroy()
|
||||
{
|
||||
if (m_pkMobRegenTimerEvent)
|
||||
{
|
||||
event_cancel(&m_pkMobRegenTimerEvent);
|
||||
m_pkMobRegenTimerEvent = NULL;
|
||||
}
|
||||
|
||||
for (DWORD j=0;j< m_vecRegenData.size();++j)
|
||||
{
|
||||
const TNewRegen& newRegen = m_vecRegenData[j];
|
||||
if (newRegen.bossPtr)
|
||||
{
|
||||
LPCHARACTER boss = newRegen.bossPtr;
|
||||
m_vecRegenData[j].bossPtr = NULL;
|
||||
M2_DESTROY_CHARACTER(boss);
|
||||
}
|
||||
}
|
||||
m_vecRegenData.clear();
|
||||
m_vecHasVnums.clear();
|
||||
}
|
||||
|
||||
int CalculateForFindPerRegenTime(time_t calculatedTime, const TNewRegen* newRegen)
|
||||
{
|
||||
const struct tm vKey = *localtime(&calculatedTime);
|
||||
|
||||
int myear = vKey.tm_year;
|
||||
int mmon = vKey.tm_mon;
|
||||
int mday = vKey.tm_mday;
|
||||
int yday = vKey.tm_yday;
|
||||
int day = vKey.tm_wday;
|
||||
int hour = vKey.tm_hour;
|
||||
int minute = vKey.tm_min;
|
||||
int second = vKey.tm_sec;
|
||||
|
||||
const BYTE regenHour = newRegen->hour;
|
||||
const BYTE regenMinute = newRegen->minute;
|
||||
const BYTE regenSecond = newRegen->second;
|
||||
|
||||
bool isSucces = false;
|
||||
const int now = time(0) + 2;
|
||||
|
||||
while (true)
|
||||
{
|
||||
++second;
|
||||
if (second == 60)
|
||||
{
|
||||
minute += 1;
|
||||
second = 0;
|
||||
if (minute == 60)
|
||||
{
|
||||
minute = 0;
|
||||
hour += 1;
|
||||
if (hour == 24)
|
||||
{
|
||||
hour = 0;
|
||||
day += 1;
|
||||
if (day == 7)
|
||||
day = 0;
|
||||
mday += 1;
|
||||
yday += 1;
|
||||
if (mday == 32)
|
||||
{
|
||||
mday = 1;
|
||||
mmon += 1;
|
||||
if (mmon == 12)
|
||||
{
|
||||
mmon = 0;
|
||||
myear += 1;
|
||||
yday = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newRegen->days_range)
|
||||
{
|
||||
if ((day % newRegen->days_range) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (second == 0)
|
||||
{
|
||||
if (newRegen->hours_range)
|
||||
{
|
||||
const int realStartHour = regenHour ? 24+(24-regenHour) : 0 ;
|
||||
if (((hour+realStartHour) % newRegen->hours_range) == 0 && regenMinute == minute)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newRegen->minute_range)
|
||||
{
|
||||
if ((minute % newRegen->minute_range) == 0)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regenHour == hour && regenMinute == minute && regenSecond == second)
|
||||
{
|
||||
if (newRegen->day)
|
||||
{
|
||||
if (newRegen->day - 1 == day)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (time(0) > now)
|
||||
break;
|
||||
}
|
||||
if (isSucces)
|
||||
{
|
||||
struct tm tm = {};
|
||||
tm.tm_year = myear;
|
||||
tm.tm_mon = mmon;
|
||||
tm.tm_mday = mday;
|
||||
tm.tm_isdst = -1;
|
||||
tm.tm_wday = day;
|
||||
tm.tm_hour = hour;
|
||||
tm.tm_min = minute;
|
||||
tm.tm_sec = second;
|
||||
tm.tm_yday = yday;
|
||||
const time_t t = mktime(&tm);
|
||||
return t;
|
||||
}
|
||||
return 65535;
|
||||
}
|
||||
|
||||
static bool get_word(FILE* fp, char* buf)
|
||||
{
|
||||
int i = 0;
|
||||
int c;
|
||||
int semicolon_mode = 0;
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (c == '"')
|
||||
{
|
||||
semicolon_mode = 1;
|
||||
continue;
|
||||
}
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
||||
continue;
|
||||
}
|
||||
if (semicolon_mode)
|
||||
{
|
||||
if (c == '"')
|
||||
{
|
||||
buf[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
if (i >= 255) return false;
|
||||
buf[i++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((c == ' ' || c == '\t' || c == '\n' || c == '\r'))
|
||||
{
|
||||
buf[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
if (i >= 255) return false;
|
||||
buf[i++] = c;
|
||||
}
|
||||
if (i == 2 && buf[0] == '/' && buf[1] == '/')
|
||||
{
|
||||
buf[i] = '\0';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
buf[i] = '\0';
|
||||
return (i != 0);
|
||||
}
|
||||
|
||||
static void next_line(FILE* fp)
|
||||
{
|
||||
int c;
|
||||
while ((c = fgetc(fp)) != EOF)
|
||||
if (c == '\n')
|
||||
return;
|
||||
}
|
||||
|
||||
bool CNewMobTimer::ReadLine(FILE* fp, TNewRegen& regen)
|
||||
{
|
||||
char szTmp[256];
|
||||
|
||||
int mode = R_ID;
|
||||
int tmpTime;
|
||||
DWORD i;
|
||||
while (get_word(fp, szTmp))
|
||||
{
|
||||
if (!strncmp(szTmp, "//", 2))
|
||||
{
|
||||
next_line(fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case R_ID:
|
||||
str_to_number(regen.id, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_MAPINDEX:
|
||||
str_to_number(regen.mapIndex, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_MAPNAME:
|
||||
++mode;
|
||||
break;
|
||||
case R_X:
|
||||
str_to_number(regen.x, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_Y:
|
||||
str_to_number(regen.y, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_DIRECTION:
|
||||
str_to_number(regen.direction, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_CHANNEL:
|
||||
str_to_number(regen.channel, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
|
||||
case R_DAY:
|
||||
str_to_number(regen.day, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_HOUR:
|
||||
str_to_number(regen.hour, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_MINUTE:
|
||||
str_to_number(regen.minute, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_SECOND:
|
||||
str_to_number(regen.second, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
|
||||
case R_BROADCAST:
|
||||
int broadcast;
|
||||
str_to_number(broadcast, szTmp);
|
||||
regen.broadcast = broadcast?1:0;
|
||||
++mode;
|
||||
break;
|
||||
|
||||
case R_SAFE_RANGE:
|
||||
str_to_number(regen.safeRange, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_DAYS_RANGE:
|
||||
str_to_number(regen.days_range, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_HOURS_RANGE:
|
||||
str_to_number(regen.hours_range, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_MINUTE_RANGE:
|
||||
str_to_number(regen.minute_range, szTmp);
|
||||
++mode;
|
||||
break;
|
||||
case R_VNUM:
|
||||
str_to_number(regen.mob_vnum, szTmp);
|
||||
++mode;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DUNGEON_BOSS_ICON_IN_MAP
|
||||
int CalculateLeftTimeSpecial(TNewRegen* newRegen, int calculateTime)
|
||||
{
|
||||
const time_t cur_Time = calculateTime;
|
||||
const struct tm vKey = *localtime(&cur_Time);
|
||||
|
||||
int myear = vKey.tm_year;
|
||||
int mmon = vKey.tm_mon;
|
||||
int mday = vKey.tm_mday;
|
||||
int yday = vKey.tm_yday;
|
||||
int day = vKey.tm_wday;
|
||||
int hour = vKey.tm_hour;
|
||||
int minute = vKey.tm_min;
|
||||
int second = vKey.tm_sec;
|
||||
|
||||
const BYTE regenHour = newRegen->hour;
|
||||
const BYTE regenMinute = newRegen->minute;
|
||||
const BYTE regenSecond = newRegen->second;
|
||||
|
||||
DWORD startTime = get_dword_time();
|
||||
|
||||
bool isSucces = false;
|
||||
const int now = time(0) + 2;
|
||||
while (true)
|
||||
{
|
||||
++second;
|
||||
if (second == 60)
|
||||
{
|
||||
minute += 1;
|
||||
second = 0;
|
||||
if (minute == 60)
|
||||
{
|
||||
minute = 0;
|
||||
hour += 1;
|
||||
if (hour == 24)
|
||||
{
|
||||
hour = 0;
|
||||
day += 1;
|
||||
if (day == 7)
|
||||
day = 0;
|
||||
mday += 1;
|
||||
yday += 1;
|
||||
if (mday == 32)
|
||||
{
|
||||
mday = 1;
|
||||
mmon += 1;
|
||||
if (mmon == 12)
|
||||
{
|
||||
mmon = 0;
|
||||
myear += 1;
|
||||
yday = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newRegen->days_range)
|
||||
{
|
||||
if ((day % newRegen->days_range) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (second == 0)
|
||||
{
|
||||
if (newRegen->hours_range)
|
||||
{
|
||||
if ((hour % newRegen->hours_range) == 0 && regenMinute == minute)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newRegen->minute_range)
|
||||
{
|
||||
if ((minute % newRegen->minute_range) == 0)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regenHour == hour && regenMinute == minute && regenSecond == second)
|
||||
{
|
||||
if (newRegen->day)
|
||||
{
|
||||
if (newRegen->day - 1 == day)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (time(0) > now)
|
||||
break;
|
||||
}
|
||||
if (isSucces)
|
||||
{
|
||||
struct tm tm = {};
|
||||
tm.tm_year = myear;
|
||||
tm.tm_mon = mmon;
|
||||
tm.tm_mday = mday;
|
||||
tm.tm_isdst = -1;
|
||||
tm.tm_wday = day;
|
||||
tm.tm_hour = hour;
|
||||
tm.tm_min = minute;
|
||||
tm.tm_sec = second;
|
||||
tm.tm_yday = yday;
|
||||
const time_t t = mktime(&tm);
|
||||
return t;
|
||||
}
|
||||
return 65535;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool CNewMobTimer::LoadFile(const char* filename)
|
||||
{
|
||||
Destroy();
|
||||
FILE* fp = fopen(filename, "rt");
|
||||
if (NULL == fp)
|
||||
{
|
||||
sys_err("SYSTEM: load_new_regen: %s: file not found", filename);
|
||||
return false;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
TNewRegen tmp;
|
||||
memset(&tmp, 0, sizeof(tmp));
|
||||
tmp.bossPtr = NULL;
|
||||
if (!ReadLine(fp, tmp))
|
||||
break;
|
||||
if (tmp.hour > 23 || tmp.minute > 59 || tmp.second > 59 || tmp.day > 7 ||
|
||||
std::find_if(m_vecRegenData.begin(), m_vecRegenData.end(), [&](const TNewRegen& r){return r.id == tmp.id;}) != m_vecRegenData.end())
|
||||
{ sys_err("Invalid/duplicate AVA2 regen %u", tmp.id); continue; }
|
||||
const CMob* p = CMobManager::instance().Get(tmp.mob_vnum);
|
||||
if (!p)
|
||||
{
|
||||
sys_err("CNewMobTimer::Update %u unknown mob vnum!", tmp.mob_vnum);
|
||||
continue;
|
||||
}
|
||||
const long x = tmp.x, y = tmp.y;
|
||||
|
||||
const SECTREE_MAP* sectreeMap = SECTREE_MANAGER::instance().GetMap(tmp.mapIndex);
|
||||
if (sectreeMap)
|
||||
{
|
||||
|
||||
tmp.x = sectreeMap->m_setting.iBaseX + x * 100;
|
||||
tmp.y = sectreeMap->m_setting.iBaseY + y * 100;
|
||||
#ifdef ENABLE_DUNGEON_BOSS_ICON_IN_MAP
|
||||
int sx = x, ex = 0, sy = y, ey = 0;
|
||||
ex = sx + 0 * 2;
|
||||
sx *= 100;
|
||||
ex *= 100;
|
||||
ey = sy + 0 * 2;
|
||||
sy *= 100;
|
||||
ey *= 100;
|
||||
sx += sectreeMap->m_setting.iBaseX;
|
||||
ex += sectreeMap->m_setting.iBaseX;
|
||||
sy += sectreeMap->m_setting.iBaseY;
|
||||
ey += sectreeMap->m_setting.iBaseY;
|
||||
if (sx > ex)
|
||||
{
|
||||
sx ^= ex;
|
||||
ex ^= sx;
|
||||
sx ^= ex;
|
||||
}
|
||||
if (sy > ey)
|
||||
{
|
||||
sy ^= ey;
|
||||
ey ^= sy;
|
||||
sy ^= ey;
|
||||
}
|
||||
|
||||
int regenTime = 0;
|
||||
const int FirstTime = CalculateLeftTimeSpecial(&tmp, time(0));
|
||||
if (FirstTime != 65535)
|
||||
{
|
||||
const int SecondTime = CalculateLeftTimeSpecial(&tmp, FirstTime);
|
||||
if (SecondTime != 65535)
|
||||
regenTime = SecondTime - FirstTime;
|
||||
|
||||
}
|
||||
|
||||
SECTREE_MANAGER::instance().InsertNPCPosition(tmp.mapIndex,
|
||||
p->m_table.bType,
|
||||
tmp.mob_vnum,
|
||||
(sx+ex) / 2 - sectreeMap->m_setting.iBaseX,
|
||||
(sy+ey) / 2 - sectreeMap->m_setting.iBaseY, regenTime);
|
||||
#endif
|
||||
}
|
||||
CalculateLeftTimeReal(&tmp);
|
||||
m_vecRegenData.emplace_back(tmp);
|
||||
if (!HasMob(tmp.mob_vnum))
|
||||
m_vecHasVnums.emplace_back(tmp.mob_vnum);
|
||||
sys_log(0, "Insert mob %d mapIndex %d x %ld y %ld", tmp.mob_vnum, tmp.mapIndex, tmp.x, tmp.y);
|
||||
}
|
||||
fclose(fp);
|
||||
if (m_vecRegenData.size())
|
||||
Initialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNewMobTimer::Initialize()
|
||||
{
|
||||
if (g_bAuthServer)
|
||||
{
|
||||
sys_log(0, "CNewMobTimer: I am the master!");
|
||||
return;
|
||||
}
|
||||
|
||||
empty_event_info* info = AllocEventInfo<empty_event_info>();
|
||||
m_pkMobRegenTimerEvent = event_create(main_timer, info, PASSES_PER_SEC(0));
|
||||
}
|
||||
|
||||
long CNewMobTimer::Update()
|
||||
{
|
||||
const time_t cur_Time = time(NULL);
|
||||
const struct tm vKey = *localtime(&cur_Time);
|
||||
const int hour = vKey.tm_hour;
|
||||
const int minute = vKey.tm_min;
|
||||
const int second = vKey.tm_sec;
|
||||
for (auto j = 0; j < m_vecRegenData.size(); ++j)
|
||||
{
|
||||
TNewRegen& newRegen = m_vecRegenData[j];
|
||||
SECTREE_MAP* sectreeMap = SECTREE_MANAGER::instance().GetMap(newRegen.mapIndex);
|
||||
if (!sectreeMap)
|
||||
continue;
|
||||
if (newRegen.channel)
|
||||
{
|
||||
if (newRegen.channel != g_bChannel)
|
||||
continue;
|
||||
}
|
||||
const int leftTime = CalculateLeftTime(&newRegen);
|
||||
|
||||
const bool printMessage = leftTime == 30 ? true:false;
|
||||
const bool trySpawn = leftTime <= 0;
|
||||
if (trySpawn)
|
||||
SpawnBoss(sectreeMap, newRegen);
|
||||
else if(printMessage)
|
||||
{
|
||||
const CMob* p = CMobManager::instance().Get(newRegen.mob_vnum);
|
||||
if (!p)
|
||||
{
|
||||
sys_err("CNewMobTimer::Update %u unknown mob vnum!", newRegen.mob_vnum);
|
||||
continue;
|
||||
}
|
||||
|
||||
char buf[512];
|
||||
if (newRegen.bossPtr)
|
||||
{
|
||||
if (IsWorldBoss(newRegen.mob_vnum))
|
||||
snprintf(buf, sizeof(buf), "2500 M%d", newRegen.mob_vnum);
|
||||
//snprintf(buf, sizeof(buf), "2500 M%d %d", newRegen.mob_vnum, g_bChannel);
|
||||
//snprintf(buf, sizeof(buf), LC_TEXT("2500"), newRegen.bossPtr->GetName(), g_bChannel);
|
||||
// else
|
||||
// snprintf(buf, sizeof(buf), "2505 M%d", newRegen.mob_vnum);
|
||||
//snprintf(buf, sizeof(buf), "2505 M%d %d", newRegen.mob_vnum, g_bChannel);
|
||||
//snprintf(buf, sizeof(buf), LC_TEXT("2505"), newRegen.bossPtr->GetName(), g_bChannel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsWorldBoss(newRegen.mob_vnum))
|
||||
snprintf(buf, sizeof(buf), "2501 M%d", newRegen.mob_vnum);
|
||||
//snprintf(buf, sizeof(buf), "2501 M%d %d", newRegen.mob_vnum, g_bChannel);
|
||||
//snprintf(buf, sizeof(buf), LC_TEXT("2501"), p->m_table.szLocaleName, g_bChannel);
|
||||
// else
|
||||
// snprintf(buf, sizeof(buf), "2506 M%d", newRegen.mob_vnum);
|
||||
//snprintf(buf, sizeof(buf), "2506 M%d %d", newRegen.mob_vnum, g_bChannel);
|
||||
//snprintf(buf, sizeof(buf), LC_TEXT("2506"), p->m_table.szLocaleName, g_bChannel);
|
||||
}
|
||||
|
||||
if(IsWorldBoss(newRegen.mob_vnum))
|
||||
{
|
||||
if (newRegen.broadcast)
|
||||
BroadcastNotice(buf);
|
||||
else
|
||||
SendNoticeMap(buf, newRegen.mapIndex, false);
|
||||
}
|
||||
|
||||
newRegen.blockAttack = true;
|
||||
}
|
||||
|
||||
}
|
||||
static time_t lastHeartbeat=0;
|
||||
if (cur_Time-lastHeartbeat>=10) {
|
||||
lastHeartbeat=cur_Time;
|
||||
for (auto& row:m_vecRegenData) {
|
||||
if (!SECTREE_MANAGER::instance().GetMap(row.mapIndex) || (row.channel && row.channel!=g_bChannel)) continue;
|
||||
if (!row.bossPtr && row.p2pAlive && row.peerAliveUntil>cur_Time) continue;
|
||||
UpdateNewRegen(row.id,row.bossPtr!=NULL);
|
||||
}
|
||||
UpdatePlayers();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CNewMobTimer::SpawnBoss(const SECTREE_MAP* sectreeMap, TNewRegen& m_Regen)
|
||||
{
|
||||
m_Regen.blockAttack = false;
|
||||
|
||||
if (m_Regen.bossPtr)
|
||||
{
|
||||
sys_log(0, "CNewMobTimer::SpawnBoss - Channel: %d MapIndex: %ld BossVnum: %d - still alive!", m_Regen.channel, m_Regen.mapIndex, m_Regen.mob_vnum);
|
||||
return;
|
||||
}
|
||||
|
||||
LPCHARACTER spawnMob = CHARACTER_MANAGER::instance().SpawnMob(m_Regen.mob_vnum, m_Regen.mapIndex, m_Regen.x, m_Regen.y, 0, true, m_Regen.direction);
|
||||
if (spawnMob)
|
||||
{
|
||||
spawnMob->SetProtectTime("IAMBOSS", 1);
|
||||
|
||||
char szNotice[256];
|
||||
if (IsWorldBoss(m_Regen.mob_vnum))
|
||||
snprintf(szNotice, sizeof(szNotice), "2502 M%d", m_Regen.mob_vnum);
|
||||
//snprintf(szNotice, sizeof(szNotice), "2502 M%d %d", m_Regen.mob_vnum, g_bChannel);
|
||||
//snprintf(szNotice, sizeof(szNotice), LC_TEXT("2502"), spawnMob->GetName(), g_bChannel);
|
||||
// else
|
||||
// snprintf(szNotice, sizeof(szNotice), "2507 M%d", m_Regen.mob_vnum);
|
||||
//snprintf(szNotice, sizeof(szNotice), "2507 M%d %d", m_Regen.mob_vnum, g_bChannel);
|
||||
//snprintf(szNotice, sizeof(szNotice), LC_TEXT("2507"), spawnMob->GetName(), g_bChannel);
|
||||
|
||||
if (IsWorldBoss(m_Regen.mob_vnum))
|
||||
{
|
||||
if (m_Regen.broadcast)
|
||||
BroadcastNotice(szNotice);
|
||||
else
|
||||
SendNoticeMap(szNotice, m_Regen.mapIndex, false);
|
||||
}
|
||||
|
||||
|
||||
m_Regen.bossPtr = spawnMob;
|
||||
UpdateNewRegen(m_Regen.id, true);
|
||||
sys_log(0, "CNewMobTimer::SpawnBoss - Spawn successfully(mobvnum %d mapIndex %d)", m_Regen.mob_vnum, m_Regen.mapIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log(0, "CNewMobTimer::SpawnBoss - Spawn fail!!!!!!!!!!(mobvnum %d mapIndex %d)", m_Regen.mob_vnum, m_Regen.mapIndex);
|
||||
m_Regen.bossPtr = NULL;
|
||||
UpdateNewRegen(m_Regen.id, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool CNewMobTimer::HasMob(DWORD mobVnum)
|
||||
{
|
||||
const auto it = std::find(m_vecHasVnums.begin(), m_vecHasVnums.end(), mobVnum);
|
||||
if (it == m_vecHasVnums.end())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
void CNewMobTimer::Dead(LPCHARACTER pkBoss, LPCHARACTER pkKiller)
|
||||
{
|
||||
if (!pkBoss)
|
||||
return;
|
||||
if (pkBoss->GetProtectTime("IAMBOSS"))
|
||||
{
|
||||
for (auto j = 0; j < m_vecRegenData.size(); ++j)
|
||||
{
|
||||
TNewRegen& newRegen = m_vecRegenData[j];
|
||||
if (newRegen.bossPtr == pkBoss)
|
||||
{
|
||||
newRegen.bossPtr = NULL;
|
||||
UpdateNewRegen(newRegen.id, false);
|
||||
|
||||
char szNotice[256];
|
||||
if (IsWorldBoss(newRegen.mob_vnum))
|
||||
{
|
||||
const int leftTime = CalculateLeftTime(&newRegen);
|
||||
std::string timeText("");
|
||||
const int second = int(leftTime % 60);
|
||||
const int minute = int((leftTime / 60) % 60);
|
||||
const int hour = int((leftTime / 60) / 60);
|
||||
const int day = int(int((hour / 60) / 60) / 24);
|
||||
if (day > 0)
|
||||
{
|
||||
timeText += std::to_string(day);
|
||||
timeText += "d-";
|
||||
}
|
||||
if (hour > 0)
|
||||
{
|
||||
timeText += std::to_string(hour);
|
||||
timeText += "h-";
|
||||
}
|
||||
if (minute > 0)
|
||||
{
|
||||
timeText += std::to_string(minute);
|
||||
timeText += "m-";
|
||||
}
|
||||
if (second > 0)
|
||||
{
|
||||
timeText += std::to_string(second);
|
||||
timeText += "s";
|
||||
}
|
||||
if (timeText.length() == 0)
|
||||
timeText = "None";
|
||||
snprintf(szNotice, sizeof(szNotice), "2503 M%d %s", pkBoss->GetRaceNum(), timeText.c_str());
|
||||
//snprintf(szNotice, sizeof(szNotice), "2503 M%d %d %s", pkBoss->GetRaceNum(), g_bChannel, timeText.c_str());
|
||||
//snprintf(szNotice, sizeof(szNotice), LC_TEXT("2503"), pkBoss->GetName(), g_bChannel, CalculateLeftTime(&newRegen));
|
||||
|
||||
}
|
||||
else
|
||||
snprintf(szNotice, sizeof(szNotice), "2504 %s M%d", pkKiller ? pkKiller->GetName() : "Unknown", newRegen.mob_vnum);
|
||||
//snprintf(szNotice, sizeof(szNotice), "2504 %s M%d %d", pkKiller ? pkKiller->GetName() : "Unknown", newRegen.mob_vnum, g_bChannel);
|
||||
//snprintf(szNotice, sizeof(szNotice), LC_TEXT("2504"), pkKiller ? pkKiller->GetName() : "Unknown", pkBoss->GetName(), g_bChannel);
|
||||
|
||||
if (newRegen.broadcast)
|
||||
BroadcastNotice(szNotice);
|
||||
else
|
||||
SendNoticeMap(szNotice, newRegen.mapIndex, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CNewMobTimer::CheckDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim)
|
||||
{
|
||||
if (!(pkAttacker && pkVictim))
|
||||
return true;
|
||||
if (!pkVictim->IsPC() || !pkAttacker->IsPC())
|
||||
return true;
|
||||
|
||||
for (auto j = 0; j < m_vecRegenData.size(); ++j)
|
||||
{
|
||||
const TNewRegen& newRegen = m_vecRegenData[j];
|
||||
const LPCHARACTER mob = newRegen.bossPtr;
|
||||
if (mob)
|
||||
{
|
||||
const float fDist = DISTANCE_APPROX(pkAttacker->GetX() - mob->GetX(), pkAttacker->GetY() - mob->GetY());
|
||||
if (fDist <= float(newRegen.safeRange))
|
||||
return false;
|
||||
}
|
||||
else if (newRegen.blockAttack)
|
||||
{
|
||||
const float fDist = DISTANCE_APPROX(pkAttacker->GetX() - newRegen.x, pkAttacker->GetY() - newRegen.y);
|
||||
if (fDist <= float(newRegen.safeRange))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "p2p.h"
|
||||
#include "desc_manager.h"
|
||||
bool CNewMobTimer::IsWorldBoss(DWORD mobIndex)
|
||||
{
|
||||
switch(mobIndex)
|
||||
{
|
||||
case 9844:
|
||||
case 9836:
|
||||
case 9838:
|
||||
case 9840:
|
||||
case 9842:
|
||||
// case 4140:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void CNewMobTimer::UpdateNewRegen(WORD id, bool isAlive, bool isP2P, BYTE channel)
|
||||
{
|
||||
TNewRegen* newRegen = NULL;
|
||||
|
||||
for (auto& row : m_vecRegenData)
|
||||
if (row.id == id) { newRegen = &row; break; }
|
||||
if (!newRegen)
|
||||
return;
|
||||
|
||||
CalculateLeftTimeReal(newRegen);
|
||||
newRegen->p2pAlive = isP2P && isAlive;
|
||||
newRegen->peerAliveUntil = isP2P && isAlive ? time(0)+30 : 0;
|
||||
newRegen->aliveChannel = isP2P ? channel : g_bChannel;
|
||||
|
||||
if (!isP2P)
|
||||
{
|
||||
// Reuse length-delimited GG relay so older peers safely ignore this feature.
|
||||
struct Wire { uint16_t id; uint8_t alive; uint8_t channel; } __attribute__((packed));
|
||||
const Wire w = {id, uint8_t(isAlive),g_bChannel};
|
||||
TPacketGGRelay p = {};
|
||||
p.bHeader=HEADER_GG_RELAY; strlcpy(p.szName,"#ava2_regen",sizeof(p.szName)); p.lSize=sizeof(w);
|
||||
TEMP_BUFFER packet; packet.write(&p,sizeof(p)); packet.write(&w,sizeof(w));
|
||||
P2P_MANAGER::instance().Send(packet.read_peek(),packet.size());
|
||||
}
|
||||
|
||||
const int calculatedTime = CalculateLeftTime(newRegen);
|
||||
const DESC_MANAGER::DESC_SET& c_ref_set = DESC_MANAGER::instance().GetClientSet();
|
||||
for (auto it = c_ref_set.begin(); it != c_ref_set.end(); ++it)
|
||||
{
|
||||
LPCHARACTER ch = (*it)->GetCharacter();
|
||||
if (ch)
|
||||
{
|
||||
if (ch->GetProtectTime("track_dungeon") == 1)
|
||||
GetTrackData(ch,id);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CNewMobTimer::UpdatePlayers()
|
||||
{
|
||||
const DESC_MANAGER::DESC_SET& c_ref_set = DESC_MANAGER::instance().GetClientSet();
|
||||
for (auto j = 0; j < m_vecRegenData.size(); ++j)
|
||||
{
|
||||
TNewRegen* newRegen = &m_vecRegenData[j];
|
||||
const int calculatedTime = CalculateLeftTime(newRegen);
|
||||
for (auto it = c_ref_set.begin(); it != c_ref_set.end(); ++it)
|
||||
{
|
||||
LPCHARACTER ch = (*it)->GetCharacter();
|
||||
if (!ch)
|
||||
continue;
|
||||
if (ch->GetProtectTime("track_dungeon") == 1)
|
||||
GetTrackData(ch,newRegen->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CNewMobTimer::CalculateLeftTimeReal(TNewRegen* newRegen)
|
||||
{
|
||||
const time_t cur_Time = time(NULL);
|
||||
const struct tm vKey = *localtime(&cur_Time);
|
||||
|
||||
int myear = vKey.tm_year;
|
||||
int mmon = vKey.tm_mon;
|
||||
int mday = vKey.tm_mday;
|
||||
int yday = vKey.tm_yday;
|
||||
int day = vKey.tm_wday;
|
||||
int hour = vKey.tm_hour;
|
||||
int minute = vKey.tm_min;
|
||||
int second = vKey.tm_sec;
|
||||
|
||||
const BYTE regenHour = newRegen->hour;
|
||||
const BYTE regenMinute = newRegen->minute;
|
||||
const BYTE regenSecond = newRegen->second;
|
||||
|
||||
DWORD startTime = get_dword_time();
|
||||
|
||||
bool isSucces = false;
|
||||
const int now = time(0) + 2;
|
||||
while (true)
|
||||
{
|
||||
++second;
|
||||
if (second == 60)
|
||||
{
|
||||
minute += 1;
|
||||
second = 0;
|
||||
if (minute == 60)
|
||||
{
|
||||
minute = 0;
|
||||
hour += 1;
|
||||
if (hour == 24)
|
||||
{
|
||||
hour = 0;
|
||||
day += 1;
|
||||
if (day == 7)
|
||||
day = 0;
|
||||
mday += 1;
|
||||
yday += 1;
|
||||
if (mday == 32)
|
||||
{
|
||||
mday = 1;
|
||||
mmon += 1;
|
||||
if (mmon == 12)
|
||||
{
|
||||
mmon = 0;
|
||||
myear += 1;
|
||||
yday = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newRegen->days_range)
|
||||
{
|
||||
if ((day % newRegen->days_range) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (second == 0)
|
||||
{
|
||||
if (newRegen->hours_range)
|
||||
{
|
||||
const int realStartHour = regenHour ? 24+(24-regenHour) : 0 ;
|
||||
if (((hour+realStartHour) % newRegen->hours_range) == 0 && regenMinute == minute)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newRegen->minute_range)
|
||||
{
|
||||
if ((minute % newRegen->minute_range) == 0)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regenHour == hour && regenMinute == minute && regenSecond == second)
|
||||
{
|
||||
if (newRegen->day)
|
||||
{
|
||||
if (newRegen->day - 1 == day)
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isSucces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (time(0) > now)
|
||||
break;
|
||||
}
|
||||
if (isSucces)
|
||||
{
|
||||
struct tm tm = {};
|
||||
tm.tm_year = myear;
|
||||
tm.tm_mon = mmon;
|
||||
tm.tm_mday = mday;
|
||||
tm.tm_isdst = -1;
|
||||
tm.tm_wday = day;
|
||||
tm.tm_hour = hour;
|
||||
tm.tm_min = minute;
|
||||
tm.tm_sec = second;
|
||||
tm.tm_yday = yday;
|
||||
const time_t t = mktime(&tm);
|
||||
newRegen->leftTime = t;
|
||||
}
|
||||
else
|
||||
newRegen->leftTime = 65535;
|
||||
}
|
||||
int CNewMobTimer::CalculateLeftTime(TNewRegen* newRegen)
|
||||
{
|
||||
if (newRegen->p2pAlive && newRegen->peerAliveUntil<=time(0)) {
|
||||
newRegen->p2pAlive=false;
|
||||
CalculateLeftTimeReal(newRegen);
|
||||
}
|
||||
if (newRegen->p2pAlive == true || newRegen->bossPtr != NULL)
|
||||
newRegen->leftTime = 65535;
|
||||
return newRegen->leftTime != 65535 ? newRegen->leftTime-time(0) : 65535;
|
||||
}
|
||||
|
||||
void CNewMobTimer::GetTrackData(LPCHARACTER ch, WORD id)
|
||||
{
|
||||
if (!ch)
|
||||
return;
|
||||
|
||||
for (auto j = 0; j < m_vecRegenData.size(); ++j)
|
||||
{
|
||||
TNewRegen* newRegen = &m_vecRegenData[j];
|
||||
if (id == newRegen->id)
|
||||
{
|
||||
long addr=0; WORD port=0;
|
||||
const bool mapped=CMapLocation::instance().Get(int(newRegen->mapIndex),addr,port);
|
||||
int left=mapped?CalculateLeftTime(newRegen):-1;
|
||||
if (left==65535 && !newRegen->bossPtr && !newRegen->p2pAlive) ++left;
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackBossInfo %d %d %d",id,left,(newRegen->channel?newRegen->channel:newRegen->aliveChannel));
|
||||
return;
|
||||
}
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"TrackBossInfo %u -1 0",id);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
//EVERDAY = 0,//Hergün
|
||||
//SUNDAY = 1,// Pazar
|
||||
//MONDAY = 2,// Pazartesi
|
||||
//TUESDAY = 3,//Salý
|
||||
//WEDNESDAY = 4,//Çarþamba
|
||||
//THURSDAY = 5,//Perþembe
|
||||
//FRIDAY = 6,//Cuma
|
||||
//SATURDAY = 7,//Cumartesi
|
||||
|
||||
enum ENewRegenFile
|
||||
{
|
||||
R_ID,
|
||||
R_MAPINDEX,
|
||||
R_MAPNAME,
|
||||
R_X,
|
||||
R_Y,
|
||||
R_DIRECTION,
|
||||
R_CHANNEL,
|
||||
R_DAY,
|
||||
R_HOUR,
|
||||
R_MINUTE,
|
||||
R_SECOND,
|
||||
R_BROADCAST,
|
||||
R_SAFE_RANGE,
|
||||
R_DAYS_RANGE,
|
||||
R_HOURS_RANGE,
|
||||
R_MINUTE_RANGE,
|
||||
R_VNUM,
|
||||
};
|
||||
|
||||
typedef struct SNewRegen
|
||||
{
|
||||
WORD id;
|
||||
long mapIndex;
|
||||
long x, y;
|
||||
BYTE direction;
|
||||
BYTE channel;
|
||||
BYTE day, hour, minute, second;
|
||||
bool broadcast;
|
||||
long safeRange;
|
||||
DWORD mob_vnum;
|
||||
BYTE days_range;
|
||||
BYTE hours_range;
|
||||
BYTE minute_range;
|
||||
LPCHARACTER bossPtr;
|
||||
bool blockAttack;
|
||||
bool p2pAlive;
|
||||
int leftTime;
|
||||
BYTE aliveChannel;
|
||||
time_t peerAliveUntil;
|
||||
} TNewRegen;
|
||||
|
||||
class CNewMobTimer : public singleton<CNewMobTimer>
|
||||
{
|
||||
protected:
|
||||
LPEVENT m_pkMobRegenTimerEvent;
|
||||
std::vector<TNewRegen> m_vecRegenData;
|
||||
std::vector<DWORD> m_vecHasVnums;
|
||||
|
||||
public:
|
||||
CNewMobTimer();
|
||||
~CNewMobTimer();
|
||||
|
||||
void Destroy();
|
||||
void Initialize();
|
||||
long Update();
|
||||
|
||||
void CalculateLeftTimeReal(TNewRegen* newRegen);
|
||||
int CalculateLeftTime(TNewRegen* newRegen);
|
||||
void GetTrackData(LPCHARACTER ch, WORD id);
|
||||
void UpdateNewRegen(WORD id, bool isAlive, bool isP2P = false, BYTE channel = 0);
|
||||
void UpdatePlayers();
|
||||
bool IsWorldBoss(DWORD mobIndex);
|
||||
|
||||
bool HasMob(DWORD mobVnum);
|
||||
|
||||
bool LoadFile(const char* filename);
|
||||
bool ReadLine(FILE* fp, TNewRegen& regen);
|
||||
|
||||
bool CheckDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim);
|
||||
void Dead(LPCHARACTER pkBoss, LPCHARACTER pkKiller);
|
||||
|
||||
void SpawnBoss(const SECTREE_MAP* sectreeMap, TNewRegen& m_Regen);
|
||||
|
||||
};
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "constants.h"
|
||||
#include "config.h"
|
||||
#include "p2p.h"
|
||||
#include "ava2_channel.h"
|
||||
#include "desc_p2p.h"
|
||||
#include "char.h"
|
||||
#include "char_manager.h"
|
||||
@@ -71,6 +72,7 @@ void P2P_MANAGER::RegisterAcceptor(LPDESC d)
|
||||
|
||||
void P2P_MANAGER::UnregisterAcceptor(LPDESC d)
|
||||
{
|
||||
Ava2ChannelForget(d);
|
||||
sys_log(0, "P2P Acceptor closed (host %s)", d->GetHostName());
|
||||
EraseUserByDesc(d);
|
||||
m_set_pkPeers.erase(d);
|
||||
@@ -91,6 +93,7 @@ void P2P_MANAGER::RegisterConnector(LPDESC d)
|
||||
|
||||
void P2P_MANAGER::UnregisterConnector(LPDESC d)
|
||||
{
|
||||
Ava2ChannelForget(d);
|
||||
std::unordered_set<LPDESC>::iterator it = m_set_pkPeers.find(d);
|
||||
|
||||
if (it != m_set_pkPeers.end())
|
||||
|
||||
@@ -109,6 +109,9 @@ enum
|
||||
|
||||
HEADER_CG_DRAGON_SOUL_REFINE = 205,
|
||||
HEADER_CG_STATE_CHECKER = 206,
|
||||
HEADER_CG_SASH = 211, // AVA2 sash
|
||||
HEADER_CG_ITEMS_PICKUP = 235, // PORT: AVA2
|
||||
HEADER_CG_SWITCHBOT = 171, // AVA2 switchbot (port_switchbot.cpp)
|
||||
|
||||
HEADER_CG_CLIENT_VERSION = 0xfd,
|
||||
HEADER_CG_CLIENT_VERSION2 = 0xf1,
|
||||
@@ -295,6 +298,9 @@ enum
|
||||
|
||||
HEADER_GC_DRAGON_SOUL_REFINE = 209,
|
||||
HEADER_GC_RESPOND_CHANNELSTATUS = 210,
|
||||
HEADER_GC_SASH = 215, // AVA2 sash
|
||||
HEADER_GC_CHESTDROP = 66, // PORT: AVA2, DWORD dynamic length
|
||||
HEADER_GC_SWITCHBOT = 171, // AVA2 switchbot (port_switchbot.cpp)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -329,6 +335,7 @@ enum
|
||||
HEADER_GG_PCBANG_UPDATE = 28,
|
||||
|
||||
HEADER_GG_CHECK_AWAKENESS = 29,
|
||||
HEADER_GG_SWITCHBOT = 31, // AVA2 switchbot: table follows the player to another core
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
@@ -942,6 +949,7 @@ enum ECharacterEquipmentPart
|
||||
CHR_EQUIPPART_WEAPON,
|
||||
CHR_EQUIPPART_HEAD,
|
||||
CHR_EQUIPPART_HAIR,
|
||||
CHR_EQUIPPART_SASH,
|
||||
CHR_EQUIPPART_NUM,
|
||||
};
|
||||
|
||||
@@ -1144,6 +1152,85 @@ typedef struct packet_item_set
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
} TPacketGCItemSet;
|
||||
|
||||
// AVA2 sash window (HEADER_CG_SASH / HEADER_GC_SASH share the layout)
|
||||
enum
|
||||
{
|
||||
SASH_SUBHEADER_GC_OPEN = 0,
|
||||
SASH_SUBHEADER_GC_CLOSE,
|
||||
SASH_SUBHEADER_GC_ADDED,
|
||||
SASH_SUBHEADER_GC_REMOVED,
|
||||
SASH_SUBHEADER_CG_REFINED,
|
||||
SASH_SUBHEADER_CG_CLOSE = 0,
|
||||
SASH_SUBHEADER_CG_ADD,
|
||||
SASH_SUBHEADER_CG_REMOVE,
|
||||
SASH_SUBHEADER_CG_REFINE,
|
||||
};
|
||||
|
||||
typedef struct SPacketSash
|
||||
{
|
||||
BYTE header;
|
||||
BYTE subheader;
|
||||
bool bWindow; // true = combine, false = absorb
|
||||
DWORD dwPrice;
|
||||
BYTE bPos;
|
||||
TItemPos tPos;
|
||||
DWORD dwItemVnum;
|
||||
DWORD dwMinAbs;
|
||||
DWORD dwMaxAbs;
|
||||
} TPacketSash;
|
||||
|
||||
// AVA2 switchbot (port_switchbot.cpp). CG/GC: header, size, subheader, slot, then the subheader's payload.
|
||||
struct TPacketGGSwitchbot
|
||||
{
|
||||
BYTE bHeader;
|
||||
WORD wPort;
|
||||
TSwitchbotTable table;
|
||||
|
||||
TPacketGGSwitchbot() : bHeader(HEADER_GG_SWITCHBOT), wPort(0)
|
||||
{
|
||||
//table = {};
|
||||
}
|
||||
};
|
||||
|
||||
enum ECGSwitchbotSubheader
|
||||
{
|
||||
SUBHEADER_CG_SWITCHBOT_START, // + TSwitchbotAttributeAlternativeTable[SWITCHBOT_ALTERNATIVE_COUNT]
|
||||
SUBHEADER_CG_SWITCHBOT_STOP,
|
||||
};
|
||||
|
||||
struct TPacketCGSwitchbot
|
||||
{
|
||||
BYTE header;
|
||||
int size;
|
||||
BYTE subheader;
|
||||
BYTE slot;
|
||||
};
|
||||
|
||||
enum EGCSwitchbotSubheader
|
||||
{
|
||||
SUBHEADER_GC_SWITCHBOT_UPDATE, // + TSwitchbotTable
|
||||
SUBHEADER_GC_SWITCHBOT_UPDATE_ITEM, // + TSwitchbotUpdateItem
|
||||
SUBHEADER_GC_SWITCHBOT_SEND_ATTRIBUTE_INFORMATION, // + TSwitchbottAttributeTable[n]
|
||||
};
|
||||
|
||||
struct TPacketGCSwitchbot
|
||||
{
|
||||
BYTE header;
|
||||
int size;
|
||||
BYTE subheader;
|
||||
BYTE slot;
|
||||
};
|
||||
|
||||
// Our item layout (3 sockets, 7 attributes), as in TPacketGCItemSet.
|
||||
struct TSwitchbotUpdateItem
|
||||
{
|
||||
BYTE slot;
|
||||
DWORD vnum;
|
||||
WORD count;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
};
|
||||
|
||||
typedef struct packet_item_del
|
||||
{
|
||||
BYTE header;
|
||||
@@ -1238,6 +1325,8 @@ enum EPacketShopSubHeaders
|
||||
SHOP_SUBHEADER_GC_SOLD_OUT,
|
||||
SHOP_SUBHEADER_GC_START_EX,
|
||||
SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY_EX,
|
||||
SHOP_SUBHEADER_GC_START_ITEM_CURRENCY,
|
||||
SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
|
||||
};
|
||||
|
||||
struct packet_shop_item
|
||||
@@ -2388,5 +2477,12 @@ typedef struct SPacketGCStateCheck
|
||||
unsigned char state;
|
||||
} TPacketGCStateCheck;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct TPacketCGItemsPickUp { uint8_t header; uint32_t count; };
|
||||
struct TPacketGCChestDrop { uint8_t header; uint32_t size; };
|
||||
static_assert(sizeof(TPacketCGItemsPickUp)==5,"AVA2 CG235 header size");
|
||||
static_assert(sizeof(TPacketGCChestDrop)==5,"AVA2 GC66 header size");
|
||||
#pragma pack(pop)
|
||||
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
@@ -228,6 +228,9 @@ CPacketInfoCG::CPacketInfoCG()
|
||||
// Set(HEADER_CG_XTRAP_ACK, sizeof(TPacketXTrapCSVerify), "XTrapResponse", false);
|
||||
Set(HEADER_CG_DRAGON_SOUL_REFINE, sizeof(TPacketCGDragonSoulRefine), "DragonSoulRefine", false);
|
||||
Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false);
|
||||
Set(HEADER_CG_SASH, sizeof(TPacketSash), "Sash", true);
|
||||
Set(HEADER_CG_ITEMS_PICKUP,sizeof(TPacketCGItemsPickUp),"ItemsPickup",true);
|
||||
Set(HEADER_CG_SWITCHBOT, sizeof(TPacketCGSwitchbot), "Switchbot", true);
|
||||
|
||||
}
|
||||
|
||||
@@ -270,6 +273,7 @@ CPacketInfoGG::CPacketInfoGG()
|
||||
Set(HEADER_GG_MONARCH_TRANSFER, sizeof(TPacketMonarchGGTransfer), "MonarchTransfer", false);
|
||||
Set(HEADER_GG_PCBANG_UPDATE, sizeof(TPacketPCBangUpdate), "PCBangUpdate", false);
|
||||
Set(HEADER_GG_CHECK_AWAKENESS, sizeof(TPacketGGCheckAwakeness), "CheckAwakeness", false);
|
||||
Set(HEADER_GG_SWITCHBOT, sizeof(TPacketGGSwitchbot), "Switchbot", false);
|
||||
}
|
||||
|
||||
CPacketInfoGG::~CPacketInfoGG()
|
||||
|
||||
@@ -36,3 +36,29 @@ bool PortAttrLockSet(CHARACTER* ch,CItem* item,unsigned mask) {
|
||||
if(ch)LogManager::instance().ItemLog(ch,item,"ATTR_LOCK",hint);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* PortAttrLockUse(CHARACTER* ch,CItem* item,unsigned slot,CItem* material) {
|
||||
if(!item || item->GetOwner()!=ch || item->IsEquipped() || item->IsExchanging() || item->isLocked())return "item";
|
||||
if(!material || material==item || material->GetOwner()!=ch || material->IsExchanging() || material->isLocked() ||
|
||||
material->IsEquipped() || material->GetCount()<1)return "material";
|
||||
const bool addon=item->GetProto() && item->GetProto()->sAddonType;
|
||||
const unsigned stored=PortAttrLockGet(item);
|
||||
if (!item->m_portAttrLockLoaded)return "db";
|
||||
const unsigned old=PortAttrLockEffective(stored,PortAttrFilled(item),addon);
|
||||
const bool removing=slot<5 && (old>>slot&1);
|
||||
if(material->GetVnum()!=(removing?50349u:50348u))return "material";
|
||||
unsigned mask=0;
|
||||
if(const char* error=PortAttrLockToggle(old,slot,PortAttrFilled(item),addon,mask))return error;
|
||||
if(!PortAttrLockSet(ch,item,mask))return "db";
|
||||
material->SetCount(material->GetCount()-1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Quest selection changes only the material's index; dragging it remains the sole lock mutation path.
|
||||
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index) {
|
||||
if (!ch || !material || material->GetOwner()!=ch || material->GetWindow()!=INVENTORY ||
|
||||
(material->GetVnum()!=50348 && material->GetVnum()!=50349) || index<1 || index>5 ||
|
||||
material->GetCount()<1 || material->IsEquipped() || material->IsExchanging() || material->isLocked() ||
|
||||
ch->IsDead() || ch->IsStun() || !ch->CanHandleItem() || ch->GetShop() || ch->GetExchange() || ch->IsOpenSafebox()) return false;
|
||||
material->SetSocket(0,index);material->Save();return true;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
||||
mask=PortAttrLockEffective(mask,filled,addon);
|
||||
const unsigned bit=addon && slot<2?kPortAttrLockAddonPair&filled:1u<<slot;
|
||||
if(mask&bit){out=mask&~bit;return 0;}
|
||||
// AVA2 char_item.cpp: adding a lock requires all five normal attributes.
|
||||
// Removing an existing lock does not have this requirement.
|
||||
if(filled!=31)return "five_attr";
|
||||
const unsigned next=mask|bit;
|
||||
if(PortAttrLockGroupCount(next,addon)>kPortAttrLockGroups || next==filled)return "max";
|
||||
out=next;return 0;
|
||||
@@ -44,8 +47,12 @@ inline const char* PortAttrLockToggle(unsigned mask,unsigned slot,unsigned fille
|
||||
class CItem;
|
||||
class CHARACTER;
|
||||
void PortAttrLockBoot();
|
||||
bool PortAttrLockSelect(CHARACTER* ch,CItem* material,unsigned index);
|
||||
// Cached on the item after the first lookup. A failed lookup returns 0 and is retried next time.
|
||||
unsigned PortAttrLockGet(CItem* item);
|
||||
// Writes synchronously (a following warp loads the new value on the next core); false on SQL error.
|
||||
bool PortAttrLockSet(CHARACTER* ch,CItem* item,unsigned mask);
|
||||
// MATERIAL is 50348 (add) or 50349 (remove); SLOT is zero based. Only a
|
||||
// successful persistent change consumes one material. Used by manual and UI paths.
|
||||
const char* PortAttrLockUse(CHARACTER* ch,CItem* item,unsigned slot,CItem* material);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
// PORT: AVA2 dungeon quest functions (questlua_dungeon.cpp dracaryS_DUNGEON_LIB + ENABLE_DEFENSAWE_SHIP,
|
||||
// questlua_npc.cpp ENABLE_MELEY_LAIR_DUNGEON, trigger.cpp FindVictimHydra) for the snow dungeon, the hydra
|
||||
// ship defence and Meley's lair (tools/server/ava2-dungeons in the client repo).
|
||||
// Differences from AVA2: d.mission_notice sends a big notice (no CHAT_TYPE_MISSION here); the statue affect
|
||||
// has no visual (AFFECT_STATUE does not exist), the statues only block damage; the npc.*(1|2, ...) selector
|
||||
// reads the number (AVA2 used lua_isnumber, so it always picked the attack victim).
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "char.h"
|
||||
#include "char_manager.h"
|
||||
#include "dungeon.h"
|
||||
#include "event.h"
|
||||
#include "sectree_manager.h"
|
||||
#include "questmanager.h"
|
||||
#include "questlua.h"
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
|
||||
extern void SendNoticeMap(const char* c_pszBuf, int nMapIndex, bool bBigFont);
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class F> void ForEachCharInMap(long mapIndex, F f)
|
||||
{
|
||||
LPSECTREE_MAP map = SECTREE_MANAGER::instance().GetMap(mapIndex);
|
||||
if (!map)
|
||||
return;
|
||||
struct Each
|
||||
{
|
||||
F& f;
|
||||
void operator () (LPENTITY ent) { if (ent->IsType(ENTITY_CHARACTER)) f((LPCHARACTER) ent); }
|
||||
} each = { f };
|
||||
map->for_each(each);
|
||||
}
|
||||
|
||||
LPDUNGEON CurrentDungeon() { return quest::CQuestManager::instance().GetCurrentDungeon(); }
|
||||
|
||||
// npc.*(1, ...) = the victim of the pc's last attack, npc.*(2, ...) = the quest npc
|
||||
LPCHARACTER SelectNPC(lua_State* L)
|
||||
{
|
||||
quest::CQuestManager& q = quest::CQuestManager::instance();
|
||||
switch ((int) lua_tonumber(L, 1))
|
||||
{
|
||||
case 1: return q.GetCurrentNPCAttackCharacterPtr();
|
||||
case 2: return q.GetCurrentNPCCharacterPtr();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EVENTINFO(warp_all_to_base_event_info)
|
||||
{
|
||||
int x, y;
|
||||
long mapIndex;
|
||||
warp_all_to_base_event_info() : x(0), y(0), mapIndex(0) {}
|
||||
};
|
||||
|
||||
EVENTFUNC(warp_all_to_base_event)
|
||||
{
|
||||
warp_all_to_base_event_info* info = dynamic_cast<warp_all_to_base_event_info*>(event->info);
|
||||
if (!info)
|
||||
return 0;
|
||||
const int x = info->x, y = info->y;
|
||||
ForEachCharInMap(info->mapIndex, [x, y](LPCHARACTER ch) { if (ch->IsPC()) ch->WarpSet(x, y); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WarpAllToBase(int x, int y, long mapIndex, int sec)
|
||||
{
|
||||
warp_all_to_base_event_info* info = AllocEventInfo<warp_all_to_base_event_info>();
|
||||
info->x = x;
|
||||
info->y = y;
|
||||
info->mapIndex = mapIndex;
|
||||
event_create(warp_all_to_base_event, info, PASSES_PER_SEC(sec));
|
||||
}
|
||||
|
||||
// The hydra ship's mast: every 2 s its hp goes to the players ("gethydrahp", AVA2's client bar); once it
|
||||
// is gone the defence failed and everyone is sent back to the cape after 15 s.
|
||||
EVENTINFO(hydra_mast_event_info)
|
||||
{
|
||||
DWORD vid;
|
||||
long mapIndex;
|
||||
hydra_mast_event_info() : vid(0), mapIndex(0) {}
|
||||
};
|
||||
|
||||
EVENTFUNC(hydra_mast_event)
|
||||
{
|
||||
hydra_mast_event_info* info = dynamic_cast<hydra_mast_event_info*>(event->info);
|
||||
if (!info || !SECTREE_MANAGER::instance().GetMap(info->mapIndex))
|
||||
return 0;
|
||||
LPCHARACTER mast = CHARACTER_MANAGER::instance().Find(info->vid);
|
||||
if (!mast)
|
||||
{
|
||||
WarpAllToBase(1108200, 1782400, info->mapIndex, 15);
|
||||
// "15秒后将传送出副本。" (GB2312)
|
||||
SendNoticeMap("15\xc3\xeb\xba\xf3\xbd\xab\xb4\xab\xcb\xcd\xb3\xf6\xb8\xb1\xb1\xbe\xa1\xa3", info->mapIndex, false);
|
||||
sys_log(0, "%ld MapIndex defensawe ship unsuccess", info->mapIndex);
|
||||
if (LPDUNGEON dungeon = CDungeonManager::instance().FindByMapIndex(info->mapIndex))
|
||||
dungeon->SetFlag("Complete", 1);
|
||||
return 0;
|
||||
}
|
||||
const int hp = mast->GetHP();
|
||||
ForEachCharInMap(info->mapIndex, [hp](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_COMMAND, "gethydrahp %d", hp); });
|
||||
return PASSES_PER_SEC(2);
|
||||
}
|
||||
}
|
||||
|
||||
// The hydra and its crew only go for the mast (AVA2 FuncFindMobHydraVictim without the building case).
|
||||
LPCHARACTER FindVictimHydra(LPCHARACTER pkChr, int iMaxDistance)
|
||||
{
|
||||
struct Find
|
||||
{
|
||||
LPCHARACTER self, victim;
|
||||
int best, max;
|
||||
void operator () (LPENTITY ent)
|
||||
{
|
||||
if (!ent->IsType(ENTITY_CHARACTER))
|
||||
return;
|
||||
LPCHARACTER ch = (LPCHARACTER) ent;
|
||||
if (!ch->IsHydraNPC() || ch->IsDead())
|
||||
return;
|
||||
const int d = DISTANCE_APPROX(self->GetX() - ch->GetX(), self->GetY() - ch->GetY());
|
||||
if (d < best && d <= max)
|
||||
{
|
||||
victim = ch;
|
||||
best = d;
|
||||
}
|
||||
}
|
||||
} f = { pkChr, NULL, INT_MAX, iMaxDistance };
|
||||
if (pkChr->GetSectree())
|
||||
pkChr->GetSectree()->ForEachAround(f);
|
||||
return f.victim;
|
||||
}
|
||||
|
||||
namespace quest
|
||||
{
|
||||
// d.mission_notice(map index, text)
|
||||
int dungeon_mission_notice(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isstring(L, 2))
|
||||
return 0;
|
||||
const std::string text = lua_tostring(L, 2);
|
||||
ForEachCharInMap(lua_isnumber(L, 1) ? (long) lua_tonumber(L, 1) : dungeon->GetMapIndex(),
|
||||
[&text](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_BIG_NOTICE, "%s", text.c_str()); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.global_warp_all_to_base(x, y, map index, seconds)
|
||||
int dungeon_global_warp_all_to_base(lua_State* L)
|
||||
{
|
||||
WarpAllToBase((int) lua_tonumber(L, 1), (int) lua_tonumber(L, 2), (long) lua_tonumber(L, 3), (int) lua_tonumber(L, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.new_kill_all(): kill_all that spares the hydra mast
|
||||
int dungeon_new_kill_all(lua_State* L)
|
||||
{
|
||||
if (LPDUNGEON dungeon = CurrentDungeon())
|
||||
dungeon->KillAll();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.command(cmd): a CHAT_TYPE_COMMAND line to every player in the dungeon
|
||||
int dungeon_command(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isstring(L, 1))
|
||||
return 0;
|
||||
const std::string text = lua_tostring(L, 1);
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [&text](LPCHARACTER ch) { if (ch->IsPC()) ch->ChatPacket(CHAT_TYPE_COMMAND, "%s", text.c_str()); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.dungeon_remove_all(vnum): takes up to 99 of the item from every player in the dungeon
|
||||
int dungeon_remove_all_item(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1))
|
||||
return 0;
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 1);
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [vnum](LPCHARACTER ch) { if (ch->IsPC()) ch->RemoveSpecifyItem(vnum, 99); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.kill_area(x1, y1, x2, y2): destroys the monsters and stones inside the global rectangle
|
||||
int dungeon_kill_area(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4))
|
||||
return 0;
|
||||
const long x1 = (long) lua_tonumber(L, 1), y1 = (long) lua_tonumber(L, 2), x2 = (long) lua_tonumber(L, 3), y2 = (long) lua_tonumber(L, 4);
|
||||
LPCHARACTER except = CQuestManager::instance().GetCurrentNPCCharacterPtr();
|
||||
std::vector<LPCHARACTER> victims;
|
||||
ForEachCharInMap(dungeon->GetMapIndex(), [&](LPCHARACTER ch) {
|
||||
if (ch != except && !ch->IsPet() && !ch->GetRider() && (ch->IsMonster() || ch->IsStone()) &&
|
||||
x1 <= ch->GetX() && ch->GetX() <= x2 && y1 <= ch->GetY() && ch->GetY() <= y2)
|
||||
victims.push_back(ch);
|
||||
});
|
||||
for (LPCHARACTER ch : victims)
|
||||
M2_DESTROY_CHARACTER(ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// d.spawn_mob_new(vnum, x, y[, radius[, count]]): d.spawn_mob plus the hydra mast watch; returns the last vid
|
||||
int dungeon_spawn_mob_new(lua_State* L)
|
||||
{
|
||||
LPDUNGEON dungeon = CurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
|
||||
return 0;
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 1);
|
||||
const long x = (long) lua_tonumber(L, 2), y = (long) lua_tonumber(L, 3);
|
||||
const float radius = lua_isnumber(L, 4) ? (float) lua_tonumber(L, 4) : 0;
|
||||
DWORD count = lua_isnumber(L, 5) ? (DWORD) lua_tonumber(L, 5) : 1;
|
||||
DWORD vid = 0;
|
||||
for (count = count ? count : 1; count--; )
|
||||
{
|
||||
long nx = x, ny = y;
|
||||
if (radius >= 1)
|
||||
{
|
||||
const float angle = number(0, 999) * M_PI * 2 / 1000, r = number(0, 999) * radius / 1000;
|
||||
nx += (long) (r * cos(angle));
|
||||
ny += (long) (r * sin(angle));
|
||||
}
|
||||
LPCHARACTER mob = dungeon->SpawnMob(vnum, nx, ny);
|
||||
if (!mob)
|
||||
continue;
|
||||
vid = mob->GetVID();
|
||||
hydra_mast_event_info* info = AllocEventInfo<hydra_mast_event_info>();
|
||||
info->vid = vid;
|
||||
info->mapIndex = dungeon->GetMapIndex();
|
||||
event_create(hydra_mast_event, info, PASSES_PER_SEC(1));
|
||||
}
|
||||
lua_pushnumber(L, vid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.get_protect_time(1|2, flag)
|
||||
int npc_get_protect_time(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = lua_isstring(L, 2) ? SelectNPC(L) : NULL;
|
||||
lua_pushnumber(L, ch ? ch->GetProtectTime(lua_tostring(L, 2)) : 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.set_protect_time(1|2, flag, value)
|
||||
int npc_set_protect_time(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = lua_isstring(L, 2) && lua_isnumber(L, 3) ? SelectNPC(L) : NULL;
|
||||
if (ch)
|
||||
ch->SetProtectTime(lua_tostring(L, 2), (int) rint(lua_tonumber(L, 3)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_statu_affect(1|2, look): AVA2 turns the statue to stone; only remembered here
|
||||
int npc_set_statu_affect(lua_State* L)
|
||||
{
|
||||
if (LPCHARACTER ch = lua_isnumber(L, 2) ? SelectNPC(L) : NULL)
|
||||
ch->SetProtectTime("Statue", (int) lua_tonumber(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_statu_clear_aff(map index)
|
||||
int npc_set_statu_clear_aff(lua_State* L)
|
||||
{
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime("Statue", 0); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.show_end_statu(map index)
|
||||
int npc_show_end_statu(lua_State* L)
|
||||
{
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime("Statue", 3); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.dead_by_vnum(map index, vnum)
|
||||
int npc_dead_by_vnum(lua_State* L)
|
||||
{
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 2);
|
||||
std::vector<LPCHARACTER> victims;
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (!ch->IsPC() && ch->GetRaceNum() == vnum && !ch->IsDead()) victims.push_back(ch); });
|
||||
for (LPCHARACTER ch : victims)
|
||||
ch->Dead();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.show_statu(map index): re-sends every monster and stone to the players around it
|
||||
int npc_show_statu(lua_State* L)
|
||||
{
|
||||
std::vector<LPCHARACTER> mobs;
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) mobs.push_back(ch); });
|
||||
for (LPCHARACTER ch : mobs)
|
||||
ch->Show(ch->GetMapIndex(), ch->GetX(), ch->GetY(), ch->GetZ(), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_meley_hp(map index, vnum, hp)
|
||||
int npc_set_meley_hp(lua_State* L)
|
||||
{
|
||||
const DWORD vnum = (DWORD) lua_tonumber(L, 2);
|
||||
const int hp = (int) lua_tonumber(L, 3);
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [vnum, hp](LPCHARACTER ch) {
|
||||
if (!ch->IsPC() && ch->GetRaceNum() == vnum)
|
||||
{
|
||||
ch->SetHP(hp);
|
||||
ch->UpdatePacket();
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
// npc.set_protect_flag2(map index, flag, value): on every monster and stone
|
||||
int npc_set_protect_flag2(lua_State* L)
|
||||
{
|
||||
if (!lua_isnumber(L, 1) || !lua_isstring(L, 2) || !lua_isnumber(L, 3))
|
||||
return 0;
|
||||
const std::string flag = lua_tostring(L, 2);
|
||||
const int value = (int) lua_tonumber(L, 3);
|
||||
ForEachCharInMap((long) lua_tonumber(L, 1), [&](LPCHARACTER ch) { if (ch->IsStone() || ch->IsMonster()) ch->SetProtectTime(flag, value); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCHARACTER HPTarget(lua_State* L)
|
||||
{
|
||||
switch ((int) lua_tonumber(L, 1))
|
||||
{
|
||||
case 1: return CQuestManager::instance().GetCurrentNPCAttackCharacterPtr();
|
||||
case 2: return CHARACTER_MANAGER::instance().Find((DWORD) lua_tonumber(L, 2));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// npc.get_hp(1) = attack victim, npc.get_hp(2, vid)
|
||||
int npc_get_hp(lua_State* L)
|
||||
{
|
||||
LPCHARACTER ch = HPTarget(L);
|
||||
if (!ch)
|
||||
return 0;
|
||||
lua_pushnumber(L, ch->GetHP());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// npc.set_hp(1, _, hp) / npc.set_hp(2, vid, hp)
|
||||
int npc_set_hp(lua_State* L)
|
||||
{
|
||||
if (LPCHARACTER ch = HPTarget(L))
|
||||
{
|
||||
ch->SetHP((int) lua_tonumber(L, 3));
|
||||
ch->UpdatePacket();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AddLuaFunctions(lua_State* L, const char* table, const luaL_reg* reg)
|
||||
{
|
||||
lua_getglobal(L, table);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
sys_err("AVA2 dungeon functions: no lua table %s", table);
|
||||
return;
|
||||
}
|
||||
for (; reg->name; ++reg)
|
||||
{
|
||||
lua_pushstring(L, reg->name);
|
||||
lua_pushcfunction(L, reg->func);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
// Called after RegisterDungeonFunctionTable/RegisterNPCFunctionTable built the d and npc tables.
|
||||
void RegisterAva2DungeonFunctionTable()
|
||||
{
|
||||
static const luaL_reg dungeon_functions[] =
|
||||
{
|
||||
{ "mission_notice", dungeon_mission_notice },
|
||||
{ "global_warp_all_to_base", dungeon_global_warp_all_to_base },
|
||||
{ "new_kill_all", dungeon_new_kill_all },
|
||||
{ "command", dungeon_command },
|
||||
{ "dungeon_remove_all", dungeon_remove_all_item },
|
||||
{ "kill_area", dungeon_kill_area },
|
||||
{ "spawn_mob_new", dungeon_spawn_mob_new },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
static const luaL_reg npc_functions[] =
|
||||
{
|
||||
{ "get_protect_time", npc_get_protect_time },
|
||||
{ "set_protect_time", npc_set_protect_time },
|
||||
{ "set_statu_affect", npc_set_statu_affect },
|
||||
{ "set_statu_clear_aff", npc_set_statu_clear_aff },
|
||||
{ "show_statu", npc_show_statu },
|
||||
{ "set_meley_hp", npc_set_meley_hp },
|
||||
{ "show_end_statu", npc_show_end_statu },
|
||||
{ "set_protect_flag2", npc_set_protect_flag2 },
|
||||
{ "dead_by_vnum", npc_dead_by_vnum },
|
||||
{ "set_hp", npc_set_hp },
|
||||
{ "get_hp", npc_get_hp },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
lua_State* L = CQuestManager::instance().GetLuaState();
|
||||
AddLuaFunctions(L, "d", dungeon_functions);
|
||||
AddLuaFunctions(L, "npc", npc_functions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef PORT_AVA2_TRAVEL_H
|
||||
#define PORT_AVA2_TRAVEL_H
|
||||
// AVA2 cmd_general.cpp do_track_window's m_TeleportData. Coordinates are
|
||||
// WORLD coordinates in metres, not the local coordinates of a regen snapshot.
|
||||
struct PortTrackDestination {unsigned boss;long x,y;unsigned minLevel,maxLevel;};
|
||||
static const PortTrackDestination kPortTrackDestinations[]={
|
||||
{9844,3840,14323,40,60},{9836,3327,14848,65,85},{9838,3840,14861,80,100},
|
||||
{9840,4350,14850,95,115},{9842,3327,15384,105,120},
|
||||
{1093,5905,1105,40,120},{2092,689,6111,70,120},{2493,1800,12199,75,120},
|
||||
{2598,5918,993,80,120},{6091,5984,7073,90,120},{6191,4319,1647,90,120},
|
||||
{9018,11082,17824,105,120},{20442,7358,6237,110,120}
|
||||
};
|
||||
inline const PortTrackDestination* PortTrackFind(unsigned boss) {
|
||||
for(const auto& destination:kPortTrackDestinations)if(destination.boss==boss)return &destination;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void PortTrackTravel(LPCHARACTER ch,unsigned request,unsigned boss) {
|
||||
const PortTrackDestination* destination=PortTrackFind(boss);
|
||||
const char* error=nullptr;
|
||||
quest::PC* pc=quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
if(!destination)error="unsupported";
|
||||
else if(ch->GetLevel()<destination->minLevel || ch->GetLevel()>destination->maxLevel)error="level";
|
||||
else if(!pc || !pc->IsLoaded() || pc->IsRunning() || ch->IsDead() || ch->IsStun() || ch->IsWarping() ||
|
||||
!ch->CanHandleItem() || !ch->CanWarp())error="busy";
|
||||
// WarpSet resolves the destination's core and refuses missing maps. Never
|
||||
// bypass dungeon admission or consume a dungeon ticket here.
|
||||
else if(!ch->WarpSet(destination->x*100,destination->y*100,0))error="unavailable";
|
||||
if(error){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 error %u %s",request,error);return;}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 begin %u travel %u 0 0 0 %lld",request,boss,(long long)get_global_time());
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 end %u 0",request);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,226 @@
|
||||
#ifndef PORT_BATTLEPASS_H
|
||||
#define PORT_BATTLEPASS_H
|
||||
// PORT: battle pass, from AVA2's ENABLE_BATTLE_PASS (the monthly mission pass behind uibattlepassex.py). A season
|
||||
// is a time window from port_battlepass.tsv with up to ten missions, each with its own reward, and a final reward
|
||||
// once every mission is done. Only real server events count: kills, fishing, refines, level ups, NPC shop trades
|
||||
// and play time; the client only asks and claims. Progress and claims live in player.mt_battlepass_progress and
|
||||
// player.mt_battlepass_claim (unique per player, season and slot). Design: docs/FEATURE-BATTLEPASS.md.
|
||||
// This header holds the game-independent part: the config, the per-player state and the bag fit.
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
enum PortBpType {
|
||||
PORT_BP_NONE,
|
||||
PORT_BP_KILL_MONSTER, // sub: mob vnum, 0 = any normal monster (not a boss or a stone)
|
||||
PORT_BP_KILL_BOSS, // sub: mob vnum, 0 = any boss
|
||||
PORT_BP_KILL_STONE, // sub: stone vnum, 0 = any metin stone
|
||||
PORT_BP_PLAYTIME, // seconds online
|
||||
PORT_BP_CATCH_FISH, // sub: caught item vnum, 0 = any
|
||||
PORT_BP_REFINE, // successful refines; sub: resulting item vnum, 0 = any
|
||||
PORT_BP_LEVEL_UP, // levels gained
|
||||
PORT_BP_NPC_SPEND, // gold paid to NPC shops
|
||||
PORT_BP_NPC_SELL, // items sold to NPC shops; sub (required): item vnum
|
||||
PORT_BP_TYPE_MAX
|
||||
};
|
||||
static const unsigned kPortBpSlots=10; // mission slots 1..10; slot 0 is the final reward
|
||||
static const unsigned kPortBpMissionRewards=3; // AVA2 BATTLE_SUB_REWARD
|
||||
static const unsigned kPortBpFinalRewards=6; // AVA2 BATTLE_REWARD_MAX
|
||||
static const unsigned long long kPortBpMaxTarget=1000000000000ULL;
|
||||
static const unsigned kPortBpMaxRewardCount=10000;
|
||||
|
||||
struct PortBpReward {unsigned vnum,count;};
|
||||
struct PortBpMission {
|
||||
unsigned slot,type,sub;unsigned long long target;std::vector<PortBpReward> rewards;
|
||||
bool Matches(unsigned kind,unsigned what)const{return type==kind && (!sub || sub==what);}
|
||||
};
|
||||
struct PortBpSeason {
|
||||
unsigned id,start,end;std::vector<PortBpMission> missions;std::vector<PortBpReward> final;
|
||||
const PortBpMission* Slot(unsigned slot)const {
|
||||
for(const auto& m:missions)if(m.slot==slot)return &m;
|
||||
return nullptr;
|
||||
}
|
||||
bool Has(unsigned kind)const {
|
||||
for(const auto& m:missions)if(m.type==kind)return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Whole-file config: any error disables the battle pass rather than running half a season.
|
||||
class PortBpConfig {
|
||||
public:
|
||||
std::vector<PortBpSeason> seasons;
|
||||
bool valid=false;
|
||||
std::string error;
|
||||
bool Parse(std::istream& input) {
|
||||
std::vector<PortBpSeason> next;std::string line;unsigned bytes=0,number=0;bool header=false;
|
||||
error.clear();
|
||||
auto fail=[&](const char* why){error="line "+std::to_string(number)+": "+why;return false;};
|
||||
auto run=[&]()->bool {
|
||||
while(std::getline(input,line)) {
|
||||
++number;bytes+=unsigned(line.size()+1);
|
||||
if(bytes>65536)return fail("file too large");
|
||||
if(!line.empty() && line.back()=='\r')line.pop_back();
|
||||
if(line.empty() || line[0]=='#')continue;
|
||||
if(!header){if(line!="MTBATTLEPASS 1")return fail("header");header=true;continue;}
|
||||
std::istringstream row(line);std::string word,token;std::vector<unsigned long long> v;
|
||||
row>>word;
|
||||
while(row>>token) {
|
||||
unsigned long long value=0;
|
||||
if(token.size()>13)return fail("number too long");
|
||||
for(char c:token){if(c<'0'||c>'9')return fail("not a number");value=value*10+unsigned(c-'0');}
|
||||
v.push_back(value);
|
||||
}
|
||||
if(word=="season") {
|
||||
if(v.size()!=3 || !v[0] || v[0]>0xffffffffULL || v[1]>=v[2] || v[2]>0xffffffffULL)return fail("season ID START END");
|
||||
if(next.size()>=64)return fail("too many seasons");
|
||||
for(const auto& s:next)if(s.id==v[0])return fail("duplicate season id");
|
||||
next.push_back(PortBpSeason{unsigned(v[0]),unsigned(v[1]),unsigned(v[2]),{},{}});
|
||||
continue;
|
||||
}
|
||||
if(next.empty())return fail("mission or final before season");
|
||||
PortBpSeason& season=next.back();
|
||||
std::vector<PortBpReward> rewards;
|
||||
auto pairs=[&](size_t from,unsigned most)->bool {
|
||||
if((v.size()-from)%2 || (v.size()-from)/2>most)return false;
|
||||
for(size_t i=from;i<v.size();i+=2) {
|
||||
if(!v[i] || v[i]>0xffffffffULL || !v[i+1] || v[i+1]>kPortBpMaxRewardCount)return false;
|
||||
rewards.push_back(PortBpReward{unsigned(v[i]),unsigned(v[i+1])});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if(word=="mission") {
|
||||
if(v.size()<4 || !pairs(4,kPortBpMissionRewards))return fail("mission SLOT TYPE SUB TARGET [VNUM COUNT]x0..3");
|
||||
if(!v[0] || v[0]>kPortBpSlots || season.Slot(unsigned(v[0])))return fail("slot 1..10, once per season");
|
||||
if(!v[1] || v[1]>=PORT_BP_TYPE_MAX)return fail("type");
|
||||
if(v[2]>0xffffffffULL)return fail("sub");
|
||||
const unsigned type=unsigned(v[1]);
|
||||
const bool subAllowed=type!=PORT_BP_PLAYTIME && type!=PORT_BP_LEVEL_UP && type!=PORT_BP_NPC_SPEND;
|
||||
if(v[2] && !subAllowed)return fail("this type takes sub 0");
|
||||
if(!v[2] && type==PORT_BP_NPC_SELL)return fail("NPC sell needs an item vnum");
|
||||
if(!v[3] || v[3]>kPortBpMaxTarget)return fail("target");
|
||||
season.missions.push_back(PortBpMission{unsigned(v[0]),type,unsigned(v[2]),v[3],rewards});
|
||||
continue;
|
||||
}
|
||||
if(word=="final") {
|
||||
if(!season.final.empty() || !pairs(0,kPortBpFinalRewards) || rewards.empty())return fail("final VNUM COUNT x1..6, once per season");
|
||||
season.final=rewards;
|
||||
continue;
|
||||
}
|
||||
return fail("unknown line");
|
||||
}
|
||||
if(input.bad())return fail("read error");
|
||||
if(!header)return fail("header");
|
||||
if(next.empty())return fail("no season");
|
||||
std::sort(next.begin(),next.end(),[](const PortBpSeason& a,const PortBpSeason& b){return a.start<b.start;});
|
||||
for(size_t i=0;i<next.size();++i) {
|
||||
if(next[i].missions.empty()){number=0;return fail("season without missions");}
|
||||
if(i && next[i].start<next[i-1].end){number=0;return fail("seasons overlap");}
|
||||
std::sort(next[i].missions.begin(),next[i].missions.end(),[](const PortBpMission& a,const PortBpMission& b){return a.slot<b.slot;});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
valid=run();
|
||||
if(valid)seasons.swap(next);
|
||||
else seasons.clear();
|
||||
return valid;
|
||||
}
|
||||
const PortBpSeason* Active(long long now)const {
|
||||
if(!valid)return nullptr;
|
||||
for(const auto& s:seasons)if(now>=s.start && now<s.end)return &s;
|
||||
return nullptr;
|
||||
}
|
||||
// Same contract as the event calendar: an atomic file replacement is picked up by every core within 5 s.
|
||||
bool Refresh(const std::string& path,unsigned tick) {
|
||||
if(checked && unsigned(tick-lastCheck)<5000)return false;
|
||||
checked=true;lastCheck=tick;
|
||||
struct stat info;
|
||||
if(stat(path.c_str(),&info)!=0){const bool had=loaded;valid=false;seasons.clear();loaded=false;error="missing";return had;}
|
||||
if(loaded && info.st_mtime==modified && info.st_size==size && info.st_ino==inode)return false;
|
||||
loaded=true;modified=info.st_mtime;size=info.st_size;inode=info.st_ino;
|
||||
if(size>65536 || size<0){valid=false;seasons.clear();error="file too large";return true;}
|
||||
std::ifstream file(path);Parse(file);
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
bool checked=false,loaded=false;unsigned lastCheck=0;time_t modified=0;off_t size=0;ino_t inode=0;
|
||||
};
|
||||
|
||||
// One player's view of the active season. base is what the database held when the load was queued, plus every
|
||||
// flush queued after it; delta is counted here and not flushed yet. Flushes add, so a missed load never loses
|
||||
// progress and the stored value is capped at the target by the database itself.
|
||||
struct PortBpState {
|
||||
unsigned season=0,generation=0;
|
||||
bool loaded=false,watching=false,wantInfo=false;
|
||||
unsigned long long base[kPortBpSlots+1]={},delta[kPortBpSlots+1]={},inflight[kPortBpSlots+1]={};
|
||||
std::set<unsigned> claimed; // slots; 0 = final
|
||||
unsigned playtimeMark=0; // get_dword_time() up to which play time has been counted
|
||||
unsigned lastCommand=0;
|
||||
unsigned long long Value(const PortBpMission& m)const {return std::min(m.target,base[m.slot]+delta[m.slot]);}
|
||||
bool Done(const PortBpMission& m)const {return base[m.slot]+delta[m.slot]>=m.target;}
|
||||
bool AllDone(const PortBpSeason& s)const {
|
||||
for(const auto& m:s.missions)if(!Done(m))return false;
|
||||
return true;
|
||||
}
|
||||
void Reset(unsigned id) {
|
||||
season=id;loaded=false;wantInfo=false;claimed.clear();
|
||||
std::fill(base,base+kPortBpSlots+1,0ULL);std::fill(delta,delta+kPortBpSlots+1,0ULL);std::fill(inflight,inflight+kPortBpSlots+1,0ULL);
|
||||
}
|
||||
};
|
||||
|
||||
// Adds amount to every unfinished mission of this kind; returns the slots that changed and those it finished.
|
||||
inline void PortBpAdd(const PortBpSeason& season,PortBpState& state,unsigned kind,unsigned what,unsigned long long amount,
|
||||
std::vector<unsigned>& changed,std::vector<unsigned>& finished) {
|
||||
if(!amount)return;
|
||||
for(const auto& m:season.missions) {
|
||||
if(!m.Matches(kind,what) || state.Done(m))continue;
|
||||
const unsigned long long left=m.target-(state.base[m.slot]+state.delta[m.slot]);
|
||||
state.delta[m.slot]+=std::min(left,amount);
|
||||
changed.push_back(m.slot);
|
||||
if(state.Done(m))finished.push_back(m.slot);
|
||||
}
|
||||
}
|
||||
|
||||
// Why a claim of slot (0 = final) cannot go ahead, or nullptr.
|
||||
inline const char* PortBpClaimError(const PortBpSeason& season,const PortBpState& state,unsigned slot) {
|
||||
if(!state.loaded)return "loading";
|
||||
if(slot>kPortBpSlots)return "slot";
|
||||
if(slot) {
|
||||
const PortBpMission* m=season.Slot(slot);
|
||||
if(!m)return "slot";
|
||||
if(state.claimed.count(slot))return "claimed";
|
||||
if(!state.Done(*m))return "incomplete";
|
||||
if(m->rewards.empty())return "slot";
|
||||
} else {
|
||||
if(season.final.empty())return "slot";
|
||||
if(state.claimed.count(0))return "claimed";
|
||||
if(!state.AllDone(season))return "incomplete";
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// First-fit placement of item sizes into a bag of pages, the order CHARACTER::GetEmptyInventory searches: an item
|
||||
// of size s at cell c takes c, c+width, ... c+width*(s-1), all in c's page. free is updated with the cells taken.
|
||||
inline bool PortBpFit(std::vector<bool>& free,unsigned page,unsigned width,const std::vector<unsigned>& sizes,std::vector<unsigned>& cells) {
|
||||
cells.clear();
|
||||
for(unsigned size:sizes) {
|
||||
bool placed=false;
|
||||
for(unsigned c=0;c<free.size() && !placed;++c) {
|
||||
if(!size || c%page+width*(size-1)>=page)continue;
|
||||
bool ok=true;
|
||||
for(unsigned k=0;k<size && ok;++k)ok=c+width*k<free.size() && free[c+width*k];
|
||||
if(!ok)continue;
|
||||
for(unsigned k=0;k<size;++k)free[c+width*k]=false;
|
||||
cells.push_back(c);placed=true;
|
||||
}
|
||||
if(!placed)return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef PORT_BATTLEPASS_HOOKS_H
|
||||
#define PORT_BATTLEPASS_HOOKS_H
|
||||
// PORT: battle pass event hooks; defined in port_battlepass_runtime.h (cmd_general.cpp). docs/FEATURE-BATTLEPASS.md.
|
||||
#include "port_battlepass.h"
|
||||
class CHARACTER;
|
||||
void PortBpCount(CHARACTER* ch,unsigned kind,unsigned what,unsigned long long amount); // a real event, never rate-scaled
|
||||
void PortBpKill(CHARACTER* attacker,CHARACTER* victim); // CHARACTER::Reward, the quest kill attacker
|
||||
void PortBpSave(CHARACTER* ch); // CHARACTER::SaveReal
|
||||
void PortBpLogout(CHARACTER* ch); // CHARACTER::Disconnect, after the last save
|
||||
#endif
|
||||
@@ -0,0 +1,292 @@
|
||||
#ifndef PORT_BATTLEPASS_RUNTIME_H
|
||||
#define PORT_BATTLEPASS_RUNTIME_H
|
||||
// PORT: battle pass, game side (port_battlepass.h has the config and state). Protocol: docs/FEATURE-BATTLEPASS.md.
|
||||
// Included once, by cmd_general.cpp; the hooks in other files go through port_battlepass_hooks.h.
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include "port_battlepass_hooks.h"
|
||||
|
||||
static const unsigned kPortBpGapMs=300; // per-player gap between /mt_bp commands
|
||||
static const unsigned kPortBpMaxStacks=24; // reward items one claim may put in the bag
|
||||
static const int kPortBpKillLevelDelta=20; // AVA2: kills count only within 20 levels of the monster
|
||||
|
||||
inline PortBpConfig& PortBpConfigFile() {static PortBpConfig config;return config;}
|
||||
inline const PortBpSeason* PortBpSeasonNow() {
|
||||
PortBpConfig& config=PortBpConfigFile();
|
||||
if(config.Refresh(LocaleService_GetBasePath()+"/port_battlepass.tsv",get_dword_time()) && !config.valid && config.error!="missing")
|
||||
sys_err("PORT_BP: port_battlepass.tsv disabled: %s",config.error.c_str());
|
||||
return config.Active(get_global_time());
|
||||
}
|
||||
inline std::map<DWORD,PortBpState>& PortBpStates() {static std::map<DWORD,PortBpState> states;return states;}
|
||||
|
||||
// AVA2 ENABLE_BATTLE_PASS / battlePass quest: 25150..25161, value[0]
|
||||
// selects the calendar month. Keep the year as well, so last year's pass cannot
|
||||
// accidentally become active again. 0=locked, 1=active, 2=final reward claimed.
|
||||
inline unsigned PortBpAccess(LPCHARACTER ch) {
|
||||
const time_t now=time_t(get_global_time());
|
||||
struct tm date;localtime_r(&now,&date);
|
||||
if(ch->GetQuestFlag("mt_bp.ticket_period")!=(date.tm_year+1900)*100+date.tm_mon+1)return 0;
|
||||
return unsigned(ch->GetQuestFlag("mt_bp.ticket_status"));
|
||||
}
|
||||
|
||||
inline void PortBpSendRewards(std::string& line,const std::vector<PortBpReward>& rewards) {
|
||||
for(const auto& r:rewards)line+=" "+std::to_string(r.vnum)+" "+std::to_string(r.count);
|
||||
}
|
||||
|
||||
inline void PortBpSendInfo(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||
state.watching=true;state.wantInfo=false;
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 season %u %u %u %lld %u",season.id,season.start,season.end,(long long)get_global_time(),unsigned(season.missions.size()));
|
||||
const time_t serverNow=time_t(get_global_time());struct tm date;localtime_r(&serverNow,&date);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 access %u %u",PortBpAccess(ch),unsigned(date.tm_mon+1));
|
||||
for(const auto& m:season.missions) {
|
||||
std::string line="MTBP1 mission "+std::to_string(m.slot)+" "+std::to_string(m.type)+" "+std::to_string(m.sub)+" "+
|
||||
std::to_string(m.target)+" "+std::to_string(state.Value(m))+" "+std::to_string(state.claimed.count(m.slot));
|
||||
PortBpSendRewards(line,m.rewards);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"%s",line.c_str());
|
||||
}
|
||||
std::string line="MTBP1 final "+std::to_string(state.claimed.count(0))+" "+std::to_string(int(state.AllDone(season)));
|
||||
PortBpSendRewards(line,season.final);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"%s",line.c_str());
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 end");
|
||||
}
|
||||
|
||||
// Queues the deltas as one additive, capped upsert on the game's ordered SQL connection.
|
||||
inline void PortBpFlush(DWORD pid,PortBpState& state,const PortBpSeason* season) {
|
||||
if(!state.season || !season || season->id!=state.season)return;
|
||||
std::string values;
|
||||
for(const auto& m:season->missions) {
|
||||
const unsigned long long d=state.delta[m.slot];
|
||||
if(!d)continue;
|
||||
values+=std::string(values.empty()?"":",")+"("+std::to_string(pid)+","+std::to_string(state.season)+","+std::to_string(m.slot)+","+
|
||||
std::to_string(std::min(d,m.target))+","+std::to_string(m.target)+")";
|
||||
state.base[m.slot]+=d;state.delta[m.slot]=0;
|
||||
if(!state.loaded)state.inflight[m.slot]+=d;
|
||||
}
|
||||
if(values.empty())return;
|
||||
DBManager::instance().Query("INSERT INTO player.mt_battlepass_progress (pid,season,slot,value,target) VALUES %s "
|
||||
"ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)",values.c_str());
|
||||
}
|
||||
|
||||
inline void PortBpLoad(DWORD pid,PortBpState& state) {
|
||||
static unsigned generations=0;
|
||||
state.generation=++generations;
|
||||
std::fill(state.inflight,state.inflight+kPortBpSlots+1,0ULL);
|
||||
const unsigned season=state.season,generation=state.generation;
|
||||
DBManager::instance().FuncQuery([pid,season,generation](SQLMsg* msg) {
|
||||
auto it=PortBpStates().find(pid);
|
||||
if(it==PortBpStates().end() || it->second.generation!=generation || it->second.season!=season)return;
|
||||
PortBpState& state=it->second;
|
||||
if(!msg->Get()){sys_err("PORT_BP: load failed pid %u season %u",pid,season);return;}
|
||||
unsigned long long stored[kPortBpSlots+1]={};
|
||||
for(unsigned i=0;i<msg->Get()->uiNumRows;++i) {
|
||||
MYSQL_ROW row=mysql_fetch_row(msg->Get()->pSQLResult);
|
||||
if(!row || !row[0] || !row[1] || !row[2])continue;
|
||||
const unsigned slot=unsigned(strtoul(row[1],nullptr,10));
|
||||
if(slot>kPortBpSlots)continue;
|
||||
if(row[0][0]=='p')state.base[slot]=(stored[slot]=strtoull(row[2],nullptr,10))+state.inflight[slot];
|
||||
else state.claimed.insert(slot);
|
||||
}
|
||||
state.loaded=true;
|
||||
LPCHARACTER ch=CHARACTER_MANAGER::instance().FindByPID(pid);
|
||||
const PortBpSeason* now=PortBpConfigFile().Active(get_global_time());
|
||||
if(!ch || !now || now->id!=season)return;
|
||||
// PortBpNotify held back the done notices of events counted before the load; send those now.
|
||||
for(const auto& m:now->missions)
|
||||
if(stored[m.slot]<m.target && state.Done(m))ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",m.slot);
|
||||
if(state.wantInfo)PortBpSendInfo(ch,*now,state);
|
||||
},"SELECT 'p',slot,value FROM player.mt_battlepass_progress WHERE pid=%u AND season=%u "
|
||||
"UNION ALL SELECT 'c',slot,0 FROM player.mt_battlepass_claim WHERE pid=%u AND season=%u",pid,season,pid,season);
|
||||
}
|
||||
|
||||
inline const PortBpSeason* PortBpFindSeason(unsigned id) {
|
||||
for(const auto& s:PortBpConfigFile().seasons)if(s.id==id)return &s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The player's state for the active season, or nullptr when no season runs. A season change first writes what
|
||||
// was counted for the old season, while its definition is still in the file, then starts a fresh load.
|
||||
inline PortBpState* PortBpSync(LPCHARACTER ch,const PortBpSeason*& season) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc())return nullptr;
|
||||
season=PortBpSeasonNow();
|
||||
const DWORD pid=ch->GetPlayerID();
|
||||
auto& states=PortBpStates();
|
||||
auto it=states.find(pid);
|
||||
if(!season && it==states.end())return nullptr;
|
||||
if(it==states.end()) {
|
||||
it=states.emplace(pid,PortBpState()).first;
|
||||
it->second.playtimeMark=get_dword_time();
|
||||
}
|
||||
PortBpState& state=it->second;
|
||||
const unsigned id=season?season->id:0;
|
||||
if(state.season!=id) {
|
||||
if(state.season)PortBpFlush(pid,state,PortBpFindSeason(state.season));
|
||||
const bool watching=state.watching;
|
||||
state.Reset(id);state.watching=watching;
|
||||
state.playtimeMark=get_dword_time();
|
||||
if(id)PortBpLoad(pid,state);
|
||||
}
|
||||
return season?&state:nullptr;
|
||||
}
|
||||
|
||||
inline void PortBpNotify(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,const std::vector<unsigned>& changed,const std::vector<unsigned>& finished) {
|
||||
if(state.watching)
|
||||
for(unsigned slot:changed)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 progress %u %llu",slot,state.Value(*season.Slot(slot)));
|
||||
if(!state.loaded)return; // values are not known yet; the window shows them once it is loaded
|
||||
for(unsigned slot:finished)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 done %u",slot);
|
||||
}
|
||||
|
||||
inline void PortBpAccruePlaytime(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state) {
|
||||
const unsigned now=get_dword_time(),seconds=(now-state.playtimeMark)/1000;
|
||||
if(!seconds)return;
|
||||
state.playtimeMark+=seconds*1000;
|
||||
if(PortBpAccess(ch)!=1 || !season.Has(PORT_BP_PLAYTIME))return;
|
||||
std::vector<unsigned> changed,finished;
|
||||
PortBpAdd(season,state,PORT_BP_PLAYTIME,0,seconds,changed,finished);
|
||||
PortBpNotify(ch,season,state,changed,finished);
|
||||
}
|
||||
|
||||
// Every hook calls this with a real event; amount is a count, gold or levels, never scaled by an event rate.
|
||||
void PortBpCount(LPCHARACTER ch,unsigned kind,unsigned what,unsigned long long amount) {
|
||||
const PortBpSeason* season=nullptr;
|
||||
PortBpState* state=PortBpSync(ch,season);
|
||||
if(!state || PortBpAccess(ch)!=1 || !amount || !season->Has(kind))return;
|
||||
std::vector<unsigned> changed,finished;
|
||||
PortBpAdd(*season,*state,kind,what,amount,changed,finished);
|
||||
PortBpNotify(ch,*season,*state,changed,finished);
|
||||
}
|
||||
|
||||
// CHARACTER::Reward: the attacker DistributeExp picked, the one the quest kill event goes to.
|
||||
void PortBpKill(LPCHARACTER attacker,LPCHARACTER victim) {
|
||||
if(!attacker || !victim || !attacker->IsPC() || victim->IsPC())return;
|
||||
const int gap=int(victim->GetLevel())-int(attacker->GetLevel());
|
||||
if(gap>kPortBpKillLevelDelta || gap<-kPortBpKillLevelDelta)return;
|
||||
const unsigned kind=victim->IsStone()?PORT_BP_KILL_STONE:victim->GetMobRank()>=MOB_RANK_BOSS?PORT_BP_KILL_BOSS:PORT_BP_KILL_MONSTER;
|
||||
PortBpCount(attacker,kind,victim->GetRaceNum(),1);
|
||||
}
|
||||
|
||||
// CHARACTER::SaveReal: the periodic and logout save also writes the battle pass.
|
||||
void PortBpSave(LPCHARACTER ch) {
|
||||
const PortBpSeason* season=nullptr;
|
||||
PortBpState* state=PortBpSync(ch,season);
|
||||
if(!state)return;
|
||||
PortBpAccruePlaytime(ch,*season,*state);
|
||||
PortBpFlush(ch->GetPlayerID(),*state,season);
|
||||
}
|
||||
|
||||
// CHARACTER::Disconnect, after the last save.
|
||||
void PortBpLogout(LPCHARACTER ch) {
|
||||
if(ch && ch->IsPC())PortBpStates().erase(ch->GetPlayerID());
|
||||
}
|
||||
|
||||
struct PortBpStack {unsigned vnum,count,size;};
|
||||
inline const char* PortBpStacks(const std::vector<PortBpReward>& rewards,std::vector<PortBpStack>& stacks) {
|
||||
stacks.clear();
|
||||
for(const auto& r:rewards) {
|
||||
const TItemTable* table=ITEM_MANAGER::instance().GetTable(r.vnum);
|
||||
if(!table || table->bType==ITEM_DS || !table->bSize || table->bSize>3)return "config";
|
||||
const bool stackable=IS_SET(table->dwFlags,ITEM_FLAG_STACKABLE) && !IS_SET(table->dwAntiFlags,ITEM_ANTIFLAG_STACK);
|
||||
for(unsigned left=r.count;left;) {
|
||||
const unsigned count=stackable?std::min<unsigned>(left,ITEM_MAX_COUNT):1;
|
||||
stacks.push_back(PortBpStack{r.vnum,count,table->bSize});left-=count;
|
||||
if(stacks.size()>kPortBpMaxStacks)return "config";
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// /mt_bp 1 claim SLOT. The claim row is written first and synchronously; only the request that inserted it hands
|
||||
// out the items, into cells checked free beforehand, so retries, double clicks and other cores cannot pay twice.
|
||||
inline void PortBpClaim(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,unsigned slot) {
|
||||
if(PortBpAccess(ch)!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error ticket");return;}
|
||||
if(const char* error=PortBpClaimError(season,state,slot)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error %s",error);return;}
|
||||
const std::vector<PortBpReward>& rewards=slot?season.Slot(slot)->rewards:season.final;
|
||||
std::vector<PortBpStack> stacks;
|
||||
if(const char* error=PortBpStacks(rewards,stacks)){
|
||||
sys_err("PORT_BP: season %u slot %u has a reward that cannot go to the bag",season.id,slot);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error %s",error);return;
|
||||
}
|
||||
std::vector<bool> free(INVENTORY_MAX_NUM);
|
||||
for(unsigned c=0;c<INVENTORY_MAX_NUM;++c)free[c]=ch->IsEmptyItemGrid(TItemPos(INVENTORY,c),1);
|
||||
std::vector<unsigned> sizes,cells;
|
||||
for(const auto& s:stacks)sizes.push_back(s.size);
|
||||
if(!PortBpFit(free,INVENTORY_PAGE_SIZE,5,sizes,cells)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error space");return;}
|
||||
const DWORD pid=ch->GetPlayerID();
|
||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(
|
||||
"INSERT IGNORE INTO player.mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",pid,season.id,slot,(long long)get_global_time()));
|
||||
if(!msg || !msg->Get()){sys_err("PORT_BP: claim insert failed pid %u season %u slot %u",pid,season.id,slot);ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error db");return;}
|
||||
state.claimed.insert(slot);
|
||||
if(msg->Get()->uiAffectedRows!=1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error claimed");return;}
|
||||
const std::string hint=std::to_string(season.id)+" "+std::to_string(slot);
|
||||
for(size_t i=0;i<stacks.size();++i) {
|
||||
LPITEM item=ITEM_MANAGER::instance().CreateItem(stacks[i].vnum,stacks[i].count);
|
||||
if(!item){sys_err("PORT_BP: cannot create %u x%u for pid %u season %u slot %u",stacks[i].vnum,stacks[i].count,pid,season.id,slot);continue;}
|
||||
item->AddToCharacter(ch,TItemPos(INVENTORY,cells[i]));
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
LogManager::instance().ItemLog(ch,item,"MT_BP_CLAIM",hint.c_str());
|
||||
}
|
||||
sys_log(0,"PORT_BP: %s claimed season %u slot %u (%u stacks)",ch->GetName(),season.id,slot,unsigned(stacks.size()));
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 claimed %u",slot);
|
||||
if(!slot)ch->SetQuestFlag("mt_bp.ticket_status",2);
|
||||
ch->Save();
|
||||
}
|
||||
|
||||
// Explicit confirmation comes from the client; all identity, month, eligibility
|
||||
// and consumption checks are authoritative here. Never turn an arbitrary quest
|
||||
// item into a ticket just because its value[0] happens to match the month.
|
||||
inline void PortBpActivate(LPCHARACTER ch,const PortBpSeason& season,PortBpState& state,unsigned cell,unsigned vnum) {
|
||||
if(ch->IsDead() || ch->IsWarping() || !ch->CanHandleItem() || ch->GetExchange() || ch->GetMyShop() ||
|
||||
ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen()){
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error busy");return;
|
||||
}
|
||||
if(!state.loaded){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error loading");return;}
|
||||
if(PortBpAccess(ch)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error activated");return;}
|
||||
LPITEM ticket=cell<INVENTORY_MAX_NUM?ch->GetItem(TItemPos(INVENTORY,cell)):nullptr;
|
||||
if(!ticket || ticket->GetVnum()!=vnum || vnum<25150 || vnum>25161 || ticket->IsExchanging() || ticket->isLocked()){
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error ticket");return;
|
||||
}
|
||||
const time_t now=time_t(get_global_time());struct tm date;localtime_r(&now,&date);
|
||||
if(ticket->GetValue(0)!=date.tm_mon+1){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error month");return;}
|
||||
// A free-pass installation may have old progress. Activation starts fresh,
|
||||
// as clear_old_battlepass() does in the AVA2 quest. The ordered connection
|
||||
// runs the deletes before the new load, including across a quick reconnect.
|
||||
DBManager::instance().Query("DELETE FROM player.mt_battlepass_progress WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
||||
DBManager::instance().Query("DELETE FROM player.mt_battlepass_claim WHERE pid=%u AND season=%u",ch->GetPlayerID(),season.id);
|
||||
state.Reset(season.id);state.playtimeMark=get_dword_time();state.wantInfo=true;
|
||||
ch->SetQuestFlag("mt_bp.ticket_period",(date.tm_year+1900)*100+date.tm_mon+1);
|
||||
ch->SetQuestFlag("mt_bp.ticket_status",1);
|
||||
ITEM_MANAGER::instance().RemoveItem(ticket,"MT_BP_ACTIVATE");
|
||||
PortBpLoad(ch->GetPlayerID(),state);
|
||||
ch->Save();
|
||||
}
|
||||
|
||||
// /mt_bp 1 info | /mt_bp 1 claim SLOT | /mt_bp 1 close
|
||||
inline void PortBpCommand(LPCHARACTER ch,const char* argument) {
|
||||
std::istringstream input(argument);std::vector<std::string> args;std::string token;
|
||||
while(input>>token){if(token.size()>10 || args.size()>=4)return;args.push_back(token);}
|
||||
if(args.empty() || args[0]!="1")return;
|
||||
const PortBpSeason* season=nullptr;
|
||||
PortBpState* state=PortBpSync(ch,season);
|
||||
const bool info=args.size()==2 && args[1]=="info",close=args.size()==2 && args[1]=="close";
|
||||
const bool claim=args.size()==3 && args[1]=="claim" && args[2].size()<=2 && args[2].find_first_not_of("0123456789")==std::string::npos;
|
||||
const bool activate=args.size()==4 && args[1]=="activate" && args[2].size()<=3 && args[3].size()<=5 &&
|
||||
args[2].find_first_not_of("0123456789")==std::string::npos && args[3].find_first_not_of("0123456789")==std::string::npos;
|
||||
if(!info && !close && !claim && !activate){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error invalid");return;}
|
||||
if(!state){if(!close)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 none");return;}
|
||||
if(close){state->watching=false;return;}
|
||||
if(state->lastCommand && get_dword_time()-state->lastCommand<kPortBpGapMs){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTBP1 error rate");return;}
|
||||
state->lastCommand=get_dword_time();
|
||||
PortBpAccruePlaytime(ch,*season,*state);
|
||||
if(activate){PortBpActivate(ch,*season,*state,unsigned(atoi(args[2].c_str())),unsigned(atoi(args[3].c_str())));return;}
|
||||
if(info) {
|
||||
if(state->loaded)PortBpSendInfo(ch,*season,*state);
|
||||
else {state->wantInfo=true;state->watching=true;}
|
||||
return;
|
||||
}
|
||||
PortBpClaim(ch,*season,*state,unsigned(atoi(args[2].c_str())));
|
||||
if(state->loaded)PortBpSendInfo(ch,*season,*state);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
#ifndef METIN2_PORT_CHEST_H
|
||||
#define METIN2_PORT_CHEST_H
|
||||
// PORT: AVA2-style batch chest opening (ENABLE_MULTI_CHEST /chest_drop). AVA2 rewrote the drop loop
|
||||
// (GiveItemFromSpecialItemGroupNew); here every box goes through the original CHARACTER::UseItem gift-box path,
|
||||
// so its checks, special_item_group roll, gold/exp, ItemLog and consumption are unchanged. Boxes of one vnum are
|
||||
// opened from the chosen cell first, then from any other cell (most gift boxes do not stack). Per-box INFO lines
|
||||
// are held back and the gains are reported once as MTCH1 lines. Protocol: docs/FEATURE-CHEST.md.
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static const unsigned kPortChestMax=200, kPortChestReportVnums=40, kPortChestFreeCells=3;
|
||||
static const DWORD kPortChestGapMs=500;
|
||||
static std::map<DWORD,DWORD> g_portChestLastCommand;
|
||||
|
||||
static bool PortChestNumber(const std::string& text,unsigned& value) {
|
||||
if(text.empty() || text.size()>5)return false;
|
||||
value=0;
|
||||
for(char c:text){if(c<'0'||c>'9')return false;value=value*10+unsigned(c-'0');}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Gift boxes whose group only hands out items, gold or exp. Groups that spawn monsters, slow, poison or drain
|
||||
// HP stay single-use: opening a stack of them at once would spawn every group around the player in one tick.
|
||||
static bool PortChestBatchable(LPITEM item) {
|
||||
if(item->GetType()!=ITEM_GIFTBOX)return false;
|
||||
const CSpecialItemGroup* group=ITEM_MANAGER::instance().GetSpecialItemGroup(item->GetVnum());
|
||||
if(!group || group->IsEmpty())return false;
|
||||
const DWORD unsafe[]={CSpecialItemGroup::MOB,CSpecialItemGroup::SLOW,CSpecialItemGroup::DRAIN_HP,
|
||||
CSpecialItemGroup::POISON,CSpecialItemGroup::MOB_GROUP};
|
||||
for(DWORD kind:unsafe)if(group->Contains(kind))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool PortChestBusy(LPCHARACTER ch) {
|
||||
return ch->IsDead() || ch->IsStun() || ch->IsWarping() || ch->IsObserverMode() || !ch->CanHandleItem() ||
|
||||
ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen();
|
||||
}
|
||||
|
||||
// Item counts by vnum over the bag and the dragon soul bag, where AutoGiveItem puts what a box gives.
|
||||
static std::map<DWORD,long long> PortChestSnapshot(LPCHARACTER ch) {
|
||||
std::map<DWORD,long long> counts;
|
||||
for(int i=0;i<INVENTORY_MAX_NUM;++i)if(LPITEM item=ch->GetInventoryItem(i))counts[item->GetVnum()]+=item->GetCount();
|
||||
for(int i=0;i<DRAGON_SOUL_INVENTORY_MAX_NUM;++i)
|
||||
if(LPITEM item=ch->GetItem(TItemPos(DRAGON_SOUL_INVENTORY,i)))counts[item->GetVnum()]+=item->GetCount();
|
||||
return counts;
|
||||
}
|
||||
|
||||
// The box to open next: the chosen cell while it still holds this vnum, otherwise any bag cell that does.
|
||||
static LPITEM PortChestNext(LPCHARACTER ch,unsigned cell,DWORD vnum) {
|
||||
LPITEM item=ch->GetInventoryItem(cell);
|
||||
if(item && item->GetVnum()==vnum && !item->IsExchanging())return item;
|
||||
for(int i=0;i<INVENTORY_MAX_NUM;++i) {
|
||||
item=ch->GetInventoryItem(i);
|
||||
if(item && item->GetVnum()==vnum && !item->IsExchanging())return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* PortChestOpen(LPCHARACTER ch,unsigned cell,unsigned asked) {
|
||||
if(cell>=unsigned(INVENTORY_MAX_NUM) || !asked || asked>kPortChestMax)return "invalid";
|
||||
if(PortChestBusy(ch))return "busy";
|
||||
LPITEM first=ch->GetInventoryItem(cell);
|
||||
if(!first || first->IsExchanging())return "item";
|
||||
if(!PortChestBatchable(first))return "kind";
|
||||
if(ch->GetEmptyInventory(kPortChestFreeCells)==-1)return "full";
|
||||
const DWORD vnum=first->GetVnum();
|
||||
const std::map<DWORD,long long> before=PortChestSnapshot(ch);
|
||||
const long long goldBefore=ch->GetGold();
|
||||
unsigned opened=0;const char* reason="done";std::string rejection;
|
||||
while(opened<asked) {
|
||||
if(PortChestBusy(ch)){reason="busy";break;}
|
||||
// Stop while a whole weapon still fits, so AutoGiveItem never has to drop a reward on the ground.
|
||||
if(ch->GetEmptyInventory(kPortChestFreeCells)==-1){reason="full";break;}
|
||||
LPITEM box=PortChestNext(ch,cell,vnum);
|
||||
if(!box){reason="empty";break;}
|
||||
const int count=ch->CountSpecifyItem(vnum);
|
||||
ch->m_portQuietInfo=true;ch->m_portLastInfo.clear();
|
||||
ch->UseItem(TItemPos(INVENTORY,box->GetCell()));
|
||||
ch->m_portQuietInfo=false;
|
||||
// Success is judged by the original path consuming exactly one box, not by its return value.
|
||||
if(ch->CountSpecifyItem(vnum)!=count-1){reason="rejected";rejection=ch->m_portLastInfo;break;}
|
||||
++opened;
|
||||
}
|
||||
if(!rejection.empty())ch->ChatPacket(CHAT_TYPE_INFO,"%s",rejection.c_str());
|
||||
const std::map<DWORD,long long> after=PortChestSnapshot(ch);
|
||||
unsigned reported=0;
|
||||
for(const auto& entry:after) {
|
||||
if(entry.first==vnum)continue;
|
||||
auto it=before.find(entry.first);
|
||||
const long long gained=entry.second-(it==before.end()?0:it->second);
|
||||
if(gained<=0)continue;
|
||||
if(++reported>kPortChestReportVnums)break;
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTCH1 got %u %lld",unsigned(entry.first),gained);
|
||||
}
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTCH1 done %u %u %u %s %lld",unsigned(vnum),asked,opened,reason,
|
||||
(long long)ch->GetGold()-goldBefore);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ACMD(do_port_chest) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc())return;
|
||||
std::istringstream input(argument);std::vector<std::string> args;std::string token;
|
||||
while(input>>token){if(token.size()>10 || args.size()>=5)return;args.push_back(token);}
|
||||
if(args.size()<2 || args[0]!="1")return;
|
||||
DWORD& last=g_portChestLastCommand[ch->GetPlayerID()];
|
||||
if(last && get_dword_time()-last<kPortChestGapMs){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTCH1 error rate");return;}
|
||||
last=get_dword_time();
|
||||
unsigned cell=0,count=0;const char* error="invalid";
|
||||
if(args[1]=="open" && args.size()==4 && PortChestNumber(args[2],cell) && PortChestNumber(args[3],count))
|
||||
error=PortChestOpen(ch,cell,count);
|
||||
if(error)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTCH1 error %s",error);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
// AVA2 costume enchant items (ENABLE_SPECIAL_COSTUME_ATTR, char_item.cpp USE_CHANGE_ATTRIBUTE case):
|
||||
// ITEM_USE / USE_CHANGE_ATTRIBUTE rows whose value0 = apply type, value1 = apply value and
|
||||
// value2 = target mask (1 << bonus flag). Dragged onto a costume they add that one fixed attribute,
|
||||
// at most three per costume; they never reroll anything, and gear is refused (they would otherwise be
|
||||
// free 40250 switchers, so the switchbot skips them too).
|
||||
// Only the costume kinds 40250 has are mapped: body (flag 1), hair (2) and mount skin (4). AVA2's
|
||||
// weapon costume (3), sash skin (5) and shining (6) items stay locked in tools/server/ava2-items.
|
||||
// Messages go to the client as "MTCATTR <code>" commands (rendered by the client's mt_costume_attr
|
||||
// script) instead of AVA2's locale strings 1056 / 1057 / 1061 / 1062 / 1063.
|
||||
#include "stdafx.h"
|
||||
#include "char.h"
|
||||
#include "item.h"
|
||||
#include "log.h"
|
||||
|
||||
enum
|
||||
{
|
||||
COSTUME_ENCHANT_VNUM_MIN = 54001,
|
||||
COSTUME_ENCHANT_VNUM_MAX = 54267,
|
||||
COSTUME_ENCHANT_MAX_ATTR = 3, // AVA2 GetBonusMaxAttr: every limit is 3
|
||||
};
|
||||
|
||||
bool CItem::IsCostumeEnchant()
|
||||
{
|
||||
return GetType() == ITEM_USE && GetSubType() == USE_CHANGE_ATTRIBUTE && GetValue(2) != 0 &&
|
||||
GetVnum() >= COSTUME_ENCHANT_VNUM_MIN && GetVnum() <= COSTUME_ENCHANT_VNUM_MAX;
|
||||
}
|
||||
|
||||
// AVA2 CItem::GetBonusFlag for the costume kinds that exist here; 0 = cannot be enchanted.
|
||||
static int CostumeEnchantFlag(LPITEM item)
|
||||
{
|
||||
if (item->GetType() != ITEM_COSTUME)
|
||||
return 0;
|
||||
|
||||
switch (item->GetSubType())
|
||||
{
|
||||
case COSTUME_BODY:
|
||||
return 1;
|
||||
case COSTUME_HAIR:
|
||||
return 2;
|
||||
case COSTUME_MOUNT_SKIN:
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CHARACTER::CostumeEnchantUse(LPITEM item, LPITEM item2)
|
||||
{
|
||||
if (item2->IsExchanging())
|
||||
return false;
|
||||
|
||||
const int flag = CostumeEnchantFlag(item2);
|
||||
const BYTE applyType = static_cast<BYTE>(item->GetValue(0));
|
||||
const short applyValue = static_cast<short>(item->GetValue(1));
|
||||
|
||||
if (!flag || !(item->GetValue(2) & (1 << flag)))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR target");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (applyType == APPLY_NONE || applyValue == 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR none");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 40250 equipped items are never touched by attribute items (the "Fix" in the switcher path):
|
||||
// the new attribute would not be applied to the character until the next re-equip.
|
||||
if (item2->IsEquipped())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR equipped");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item2->GetAttributeCount() >= COSTUME_ENCHANT_MAX_ATTR)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR full");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item2->HasAttr(applyType))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR has");
|
||||
return false;
|
||||
}
|
||||
|
||||
item2->AddAttribute(applyType, applyValue);
|
||||
|
||||
{
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%u %u %d", item2->GetID(), applyType, applyValue);
|
||||
LogManager::instance().ItemLog(this, item, "COSTUME_ENCHANT", buf);
|
||||
}
|
||||
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTCATTR done");
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef PORT_DUNGEON_SETTINGS_H
|
||||
#define PORT_DUNGEON_SETTINGS_H
|
||||
#include <cmath>
|
||||
// Only audited settings functions are invoked; never switch quest/player context.
|
||||
// They read event flags and return settings, without RNG, items, warps or quest writes.
|
||||
static bool PortDungeonSettings(const char* questName,const char* function,
|
||||
const std::vector<const char*>& fields,std::vector<unsigned>& out) {
|
||||
lua_State* L=quest::CQuestManager::instance().GetLuaState();
|
||||
if(!L)return false;
|
||||
const int top=lua_gettop(L);
|
||||
lua_getglobal(L,questName);
|
||||
if(!lua_istable(L,-1)){lua_settop(L,top);return false;}
|
||||
lua_pushstring(L,function);lua_rawget(L,-2);
|
||||
if(!lua_isfunction(L,-1) || lua_pcall(L,0,1,0)!=0 || !lua_istable(L,-1)) {
|
||||
lua_settop(L,top);return false;
|
||||
}
|
||||
out.clear();bool valid=true;
|
||||
for(const char* field:fields) {
|
||||
lua_pushstring(L,field);lua_rawget(L,-2);
|
||||
const double value=lua_tonumber(L,-1);
|
||||
if(lua_type(L,-1)!=LUA_TNUMBER || !std::isfinite(value) || value<0 || value>2147483647 || std::floor(value)!=value)valid=false;
|
||||
out.push_back(valid?unsigned(value):0);lua_pop(L,1);
|
||||
}
|
||||
lua_settop(L,top);return valid;
|
||||
}
|
||||
#endif
|
||||
@@ -3,28 +3,7 @@
|
||||
#include "port_dungeon_rules.h"
|
||||
#include "questpc.h"
|
||||
#include <cmath>
|
||||
// Only audited settings functions are invoked; never switch quest/player context.
|
||||
// They read event flags and return settings, without RNG, items, warps or quest writes.
|
||||
static bool PortDungeonSettings(const char* questName,const char* function,
|
||||
const std::vector<const char*>& fields,std::vector<unsigned>& out) {
|
||||
lua_State* L=quest::CQuestManager::instance().GetLuaState();
|
||||
if(!L)return false;
|
||||
const int top=lua_gettop(L);
|
||||
lua_getglobal(L,questName);
|
||||
if(!lua_istable(L,-1)){lua_settop(L,top);return false;}
|
||||
lua_pushstring(L,function);lua_rawget(L,-2);
|
||||
if(!lua_isfunction(L,-1) || lua_pcall(L,0,1,0)!=0 || !lua_istable(L,-1)) {
|
||||
lua_settop(L,top);return false;
|
||||
}
|
||||
out.clear();bool valid=true;
|
||||
for(const char* field:fields) {
|
||||
lua_pushstring(L,field);lua_rawget(L,-2);
|
||||
const double value=lua_tonumber(L,-1);
|
||||
if(lua_type(L,-1)!=LUA_TNUMBER || !std::isfinite(value) || value<0 || value>2147483647 || std::floor(value)!=value)valid=false;
|
||||
out.push_back(valid?unsigned(value):0);lua_pop(L,1);
|
||||
}
|
||||
lua_settop(L,top);return valid;
|
||||
}
|
||||
#include "port_dungeon_settings.h"
|
||||
static bool PortDungeonQuery(LPCHARACTER ch,unsigned request) {
|
||||
auto& manager=quest::CQuestManager::instance();
|
||||
quest::PC* pc=manager.GetPCForce(ch->GetPlayerID());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
static void PortTrackTravel(LPCHARACTER ch,unsigned request,unsigned boss);
|
||||
// Own-player read-only protocol v1. Capability bits: drops, chests, stats, reverse sources, dungeon snapshots; 256 = world bosses.
|
||||
void PortBossQuery(LPCHARACTER ch,unsigned request);
|
||||
static bool PortFeatureNumber(const std::string& text,unsigned& value) {
|
||||
@@ -44,7 +45,7 @@ ACMD(do_port_features) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 error %u rate",request);return;
|
||||
}
|
||||
ch->m_portFeatureLastQuery=get_dword_time();
|
||||
if(kind=="cap" && args.size()==3) {ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 cap %u 1 511 %lld",request,(long long)get_global_time());return;}
|
||||
if(kind=="cap" && args.size()==3) {ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 cap %u 1 959 %lld",request,(long long)get_global_time());return;}
|
||||
if(kind=="dungeons" && args.size()==3) {PortDungeonQuery(ch,request);return;}
|
||||
if(kind=="bosses" && args.size()==3) {PortBossQuery(ch,request);return;}
|
||||
if(kind=="stats" && args.size()==3) {
|
||||
@@ -61,6 +62,7 @@ ACMD(do_port_features) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTF1 error %u invalid",request);return;
|
||||
}
|
||||
if(kind=="calendar" && subject==1) {PortCalendarQuery(ch,request,offset);return;}
|
||||
if(kind=="travel" && !offset) {PortTrackTravel(ch,request,subject);return;}
|
||||
std::vector<PortWikiRow> rows;
|
||||
unsigned mode=0;
|
||||
auto& manager=ITEM_MANAGER::instance();
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// AVA2 mount costume + mount skin (ENABLE_MOUNT_COSTUME_SYSTEM / ENABLE_MOUNT_SKIN), ported onto the
|
||||
// 40250 horse: the worn costume (or its skin) only replaces the horse race in GetMyHorseVnum, so
|
||||
// riding still needs horse level >= 1 and uses horse stamina, exactly as on AVA2.
|
||||
// Messages go to the client as "MTMOUNT <code>" commands (rendered by the client's mt_mount script)
|
||||
// instead of AVA2's numeric locale strings 334 / 1097 / 1098.
|
||||
#include "stdafx.h"
|
||||
#include "char.h"
|
||||
#include "item.h"
|
||||
|
||||
// AVA2 CanEquipNow: a skin needs a worn mount and cannot be put on while riding.
|
||||
bool CHARACTER::MountCostumeCanEquip(LPITEM item)
|
||||
{
|
||||
if (!item->IsCostumeMountSkin())
|
||||
return true;
|
||||
|
||||
if (IsRiding())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTMOUNT riding");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetWear(WEAR_COSTUME_MOUNT))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTMOUNT need_mount");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// AVA2 CanUnequipNow: neither piece comes off while riding; the mount stays while a skin is worn.
|
||||
bool CHARACTER::MountCostumeCanUnequip(LPITEM item)
|
||||
{
|
||||
if (!item->IsCostumeMount() && !item->IsCostumeMountSkin())
|
||||
return true;
|
||||
|
||||
if (IsRiding())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTMOUNT riding");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->IsCostumeMount() && GetWear(WEAR_COSTUME_MOUNT_SKIN))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTMOUNT has_skin");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// AVA2 EquipItem tail: re-summon so the horse takes the new race.
|
||||
void CHARACTER::MountCostumeEquipped(LPITEM item)
|
||||
{
|
||||
if (!item->IsCostumeMount() && !item->IsCostumeMountSkin())
|
||||
return;
|
||||
|
||||
if (GetHorseLevel() <= 0)
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTMOUNT need_horse");
|
||||
|
||||
if (GetHorse())
|
||||
HorseSummon(false);
|
||||
HorseSummon(true);
|
||||
}
|
||||
|
||||
// AVA2 UnequipItem / MoveItem: taking the mount off sends the horse away, taking the skin off
|
||||
// re-summons it with the mount's race (bAlwaysSummon: UnequipItem summons even without a horse out).
|
||||
void CHARACTER::MountCostumeUnequipped(LPITEM item, bool bAlwaysSummon)
|
||||
{
|
||||
if (item->IsCostumeMount())
|
||||
{
|
||||
if (GetHorse())
|
||||
HorseSummon(false);
|
||||
}
|
||||
else if (item->IsCostumeMountSkin())
|
||||
{
|
||||
if (GetHorse())
|
||||
{
|
||||
HorseSummon(false);
|
||||
HorseSummon(true);
|
||||
}
|
||||
else if (bAlwaysSummon)
|
||||
HorseSummon(true);
|
||||
}
|
||||
}
|
||||
|
||||
// AVA2 input_login: a worn mount comes out on login.
|
||||
void CHARACTER::MountCostumeOnLogin()
|
||||
{
|
||||
if (!GetWear(WEAR_COSTUME_MOUNT))
|
||||
return;
|
||||
|
||||
if (!IsRiding() && !GetHorse())
|
||||
HorseSummon(true);
|
||||
else
|
||||
StopRiding();
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// AVA2 talisman (ITEM_TALISMAN_EQUIPMENT + ELEMENT_NEW_BONUSES): ITEM_ARMOR / ARMOR_PENDANT, worn in WEAR_PENDANT.
|
||||
// A talisman's APPLY_ENCHANT_<element> (= its refine level, +0..+200) adds that % to attacks on monsters with the
|
||||
// matching RACE_FLAG_ATT_* (battle.cpp).
|
||||
// Its random attributes come from AVA2's item_attr "pendant" column. That column is not added to 203's item_attr
|
||||
// table and ATTRIBUTE_SET_*, which would change the db -> game boot packet. Instead the pool lives here and
|
||||
// GetAttributeSetIndex() stays -1, so the 40250 switchers and the attribute lock never touch a talisman, and drops
|
||||
// carry no magic attributes. The switchbot (port_switchbot.cpp) rerolls it with 71302 through ChangeAttribute,
|
||||
// which PutAttributeWithLevel routes to PutPendantAttributeWithLevel.
|
||||
// Only the talisman items change its attributes; AVA2 uses 71302 (reroll) and 71301 (add, up to 5). The
|
||||
// imported 53996 / 53997 (AVA2 generic switcher / adder, which would be free 40250 gear rerolls) act as the same
|
||||
// talisman reroll / add here, as their zh names say. Messages go to the client as "MTPENDANT <code>"
|
||||
// (rendered by the client's mt_pendant script) instead of AVA2's locale strings 1056 / 1057 / 1067.
|
||||
#include "stdafx.h"
|
||||
#include "constants.h"
|
||||
#include "char.h"
|
||||
#include "item.h"
|
||||
#include "log.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct PendantAttr
|
||||
{
|
||||
BYTE bApply;
|
||||
DWORD dwProb;
|
||||
short asValues[ITEM_ATTRIBUTE_MAX_LEVEL];
|
||||
};
|
||||
|
||||
// AVA2 player.item_attr rows whose pendant column is set (all with max level 5).
|
||||
const PendantAttr s_aPendantAttr[] =
|
||||
{
|
||||
{ APPLY_MAX_HP, 35, { 1500, 1500, 1500, 2000, 2000 } },
|
||||
{ APPLY_MAX_SP, 35, { 50, 50, 50, 80, 80 } },
|
||||
{ APPLY_CON, 11, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_INT, 11, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_STR, 11, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_DEX, 11, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_HP_REGEN, 60, { 20, 20, 20, 30, 30 } },
|
||||
{ APPLY_SP_REGEN, 60, { 20, 20, 20, 30, 30 } },
|
||||
{ APPLY_STEAL_HP, 50, { 5, 5, 5, 10, 10 } },
|
||||
{ APPLY_STEAL_SP, 50, { 5, 5, 5, 10, 10 } },
|
||||
{ APPLY_MANA_BURN_PCT, 18, { 5, 5, 5, 10, 10 } },
|
||||
{ APPLY_DODGE, 15, { 8, 8, 8, 10, 10 } },
|
||||
{ APPLY_POISON_REDUCE, 15, { 5, 5, 5, 8, 8 } },
|
||||
{ APPLY_KILL_SP_RECOVER, 10, { 5, 5, 5, 10, 10 } },
|
||||
{ APPLY_EXP_DOUBLE_BONUS, 10, { 10, 10, 10, 20, 20 } },
|
||||
{ APPLY_GOLD_DOUBLE_BONUS, 10, { 10, 10, 10, 20, 20 } },
|
||||
{ APPLY_ITEM_DROP_BONUS, 10, { 10, 10, 10, 20, 20 } },
|
||||
{ APPLY_KILL_HP_RECOVER, 10, { 5, 5, 5, 10, 10 } },
|
||||
{ APPLY_ANTI_CRITICAL_PCT, 10, { 4, 4, 4, 10, 10 } },
|
||||
{ APPLY_ANTI_PENETRATE_PCT, 10, { 4, 4, 4, 10, 10 } },
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PENDANT_MAX_ATTR = 5, // AVA2: 71301 adds while GetAttributeCount() < 5
|
||||
};
|
||||
|
||||
// 203 CItem::ChangeAttribute / AddAttribute level tables (AVA2 has the same).
|
||||
const int s_aiChangeLevel[ITEM_ATTRIBUTE_MAX_LEVEL] = { 0, 10, 40, 35, 15 };
|
||||
const int s_aiAddLevel[ITEM_ATTRIBUTE_MAX_LEVEL] = { 40, 50, 10, 0, 0 };
|
||||
|
||||
int PendantLevel(const int * aiPercent)
|
||||
{
|
||||
int iPercent = number(1, 100);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ITEM_ATTRIBUTE_MAX_LEVEL - 1; ++i)
|
||||
{
|
||||
if (iPercent <= aiPercent[i])
|
||||
break;
|
||||
|
||||
iPercent -= aiPercent[i];
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// CItem::PutAttributeWithLevel over the talisman pool.
|
||||
void PendantPutAttribute(LPITEM item, const int * aiPercent)
|
||||
{
|
||||
DWORD dwTotal = 0;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
|
||||
if (!item->HasAttr(s_aPendantAttr[i].bApply))
|
||||
dwTotal += s_aPendantAttr[i].dwProb;
|
||||
|
||||
if (!dwTotal)
|
||||
return;
|
||||
|
||||
DWORD dwProb = number(1, dwTotal);
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
|
||||
{
|
||||
const PendantAttr & r = s_aPendantAttr[i];
|
||||
|
||||
if (item->HasAttr(r.bApply))
|
||||
continue;
|
||||
|
||||
if (dwProb <= r.dwProb)
|
||||
{
|
||||
item->AddAttribute(r.bApply, r.asValues[PendantLevel(aiPercent)]);
|
||||
return;
|
||||
}
|
||||
|
||||
dwProb -= r.dwProb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Highest value of a talisman attribute, for the switchbot attribute list (port_switchbot.cpp).
|
||||
int GetPendantAttrMaxValue(BYTE bApply)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
|
||||
if (s_aPendantAttr[i].bApply == bApply)
|
||||
return s_aPendantAttr[i].asValues[ITEM_ATTRIBUTE_MAX_LEVEL - 1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CItem::PutAttributeWithLevel over the talisman pool (bLevel 1..5): CItem::ChangeAttribute, so the switchbot
|
||||
// rerolls a talisman with 71302 like a 40250 item with a switcher.
|
||||
void CItem::PutPendantAttributeWithLevel(BYTE bLevel)
|
||||
{
|
||||
if (bLevel < 1 || bLevel > ITEM_ATTRIBUTE_MAX_LEVEL)
|
||||
return;
|
||||
|
||||
DWORD dwTotal = 0;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
|
||||
if (!HasAttr(s_aPendantAttr[i].bApply))
|
||||
dwTotal += s_aPendantAttr[i].dwProb;
|
||||
|
||||
if (!dwTotal)
|
||||
return;
|
||||
|
||||
DWORD dwProb = number(1, dwTotal);
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
|
||||
{
|
||||
const PendantAttr & r = s_aPendantAttr[i];
|
||||
|
||||
if (HasAttr(r.bApply))
|
||||
continue;
|
||||
|
||||
if (dwProb <= r.dwProb)
|
||||
{
|
||||
AddAttribute(r.bApply, r.asValues[bLevel - 1]);
|
||||
return;
|
||||
}
|
||||
|
||||
dwProb -= r.dwProb;
|
||||
}
|
||||
}
|
||||
|
||||
bool CItem::IsTalisman()
|
||||
{
|
||||
return GetType() == ITEM_ARMOR && GetSubType() == ARMOR_PENDANT;
|
||||
}
|
||||
|
||||
// 1 = reroll, 2 = add, 0 = not a talisman attribute item.
|
||||
int CItem::GetPendantScrollKind()
|
||||
{
|
||||
if (GetType() != ITEM_USE)
|
||||
return 0;
|
||||
|
||||
switch (GetVnum())
|
||||
{
|
||||
case 71302:
|
||||
case 53996:
|
||||
return GetSubType() == USE_CHANGE_ATTRIBUTE ? 1 : 0;
|
||||
|
||||
case 71301:
|
||||
case 53997:
|
||||
return GetSubType() == USE_ADD_ATTRIBUTE ? 2 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CHARACTER::PendantScrollUse(LPITEM item, LPITEM item2)
|
||||
{
|
||||
if (item2->IsExchanging())
|
||||
return false;
|
||||
|
||||
const int kind = item->GetPendantScrollKind();
|
||||
|
||||
if (!kind || !item2->IsTalisman())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT target");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 40250 never changes the attributes of a worn item (the "Fix" in the switcher path).
|
||||
if (item2->IsEquipped())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT equipped");
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[21];
|
||||
snprintf(buf, sizeof(buf), "%u", item2->GetID());
|
||||
|
||||
if (kind == 1)
|
||||
{
|
||||
const int iCount = item2->GetAttributeCount();
|
||||
|
||||
if (!iCount)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
item2->ClearAttribute();
|
||||
|
||||
for (int i = 0; i < iCount; ++i)
|
||||
PendantPutAttribute(item2, s_aiChangeLevel);
|
||||
|
||||
LogManager::instance().ItemLog(this, item, "PENDANT_CHANGE", buf);
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT changed");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item2->GetAttributeCount() >= PENDANT_MAX_ATTR)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT full");
|
||||
return false;
|
||||
}
|
||||
|
||||
PendantPutAttribute(item2, s_aiAddLevel);
|
||||
LogManager::instance().ItemLog(this, item, "PENDANT_ADD", buf);
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT added");
|
||||
}
|
||||
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef METIN2_PORT_PREMIUM_H
|
||||
#define METIN2_PORT_PREMIUM_H
|
||||
// PORT: VIP card. Using card 38001 (7 days) or 38002 (30 days) extends all seven premium services of the account
|
||||
// (account.account *_expire) from the later of now and their current end. The original server reads these columns
|
||||
// only when auth logs the account in, and the db core hands those login-time values to every later player load
|
||||
// (CLoginData), so after a card and on every enter-game the game re-reads them and updates m_aiPremiumTimes and the
|
||||
// AFFECT_PREMIUM_START+i icons. Protocol: docs/FEATURE-VIP.md.
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static const int kPortVipTypes=7; // PREMIUM_EXP .. PREMIUM_GOLD, in account column order
|
||||
static const char* const kPortVipColumns[kPortVipTypes]={"silver_expire","gold_expire","safebox_expire",
|
||||
"autoloot_expire","fish_mind_expire","marriage_fast_expire","money_drop_rate_expire"};
|
||||
static const DWORD kPortVipCards[][2]={{38001,7},{38002,30}};
|
||||
static const int kPortVipMaxDays=400; // remaining time a card may reach, far from the 2038 limit of the int times
|
||||
static const DWORD kPortVipGapMs=1000;
|
||||
|
||||
inline int PortVipCardDays(DWORD vnum) {
|
||||
for(const auto& card:kPortVipCards)if(card[0]==vnum)return int(card[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// One throttle per player id for card use and status requests: both queue a query whose answer updates memory.
|
||||
inline bool PortVipThrottled(LPCHARACTER ch) {
|
||||
static std::map<DWORD,DWORD> last;
|
||||
DWORD& at=last[ch->GetPlayerID()];
|
||||
if(at && get_dword_time()-at<kPortVipGapMs)return true;
|
||||
at=get_dword_time();
|
||||
return false;
|
||||
}
|
||||
|
||||
// The account's end times (unix seconds) are the truth: premium state, icons, and on request the client.
|
||||
inline void PortVipApply(LPCHARACTER ch,const int* times,bool report) {
|
||||
const int now=get_global_time();
|
||||
std::string line="MTVIP1 times";
|
||||
for(int i=0;i<kPortVipTypes;++i) {
|
||||
const int remain=times[i]-now;
|
||||
if(times[i]!=ch->GetPremiumRemainSeconds(i)+now) {
|
||||
ch->PortSetPremiumTime(i,times[i]);
|
||||
if(remain>0)ch->AddAffect(AFFECT_PREMIUM_START+i,POINT_NONE,0,0,remain,0,true);
|
||||
else ch->RemoveAffect(AFFECT_PREMIUM_START+i);
|
||||
sys_log(0,"PORT_VIP: %s type %d end %d",ch->GetName(),i,times[i]);
|
||||
}
|
||||
line+=" "+std::to_string(remain>0?remain:0);
|
||||
}
|
||||
if(report)ch->ChatPacket(CHAT_TYPE_COMMAND,"%s",line.c_str());
|
||||
}
|
||||
|
||||
inline void PortVipRefresh(LPCHARACTER ch,bool report) {
|
||||
if(!ch->GetDesc())return;
|
||||
const DWORD pid=ch->GetPlayerID(),account=ch->GetDesc()->GetAccountTable().id;
|
||||
std::string columns;
|
||||
for(int i=0;i<kPortVipTypes;++i)columns+=std::string(i?",":"")+"UNIX_TIMESTAMP("+kPortVipColumns[i]+")";
|
||||
DBManager::instance().FuncQuery([pid,account,report](SQLMsg* msg) {
|
||||
LPCHARACTER ch=CHARACTER_MANAGER::instance().FindByPID(pid);
|
||||
if(!ch || !ch->GetDesc() || ch->GetDesc()->GetAccountTable().id!=account)return;
|
||||
if(!msg->Get() || msg->Get()->uiNumRows!=1){sys_err("PORT_VIP: account %u not found",account);return;}
|
||||
MYSQL_ROW row=mysql_fetch_row(msg->Get()->pSQLResult);
|
||||
int times[kPortVipTypes];
|
||||
for(int i=0;i<kPortVipTypes;++i)times[i]=row[i]?atoi(row[i]):0;
|
||||
PortVipApply(ch,times,report);
|
||||
},"SELECT %s FROM account.account WHERE id=%u",columns.c_str(),account);
|
||||
}
|
||||
|
||||
// Called by CHARACTER::UseItem before the original item handling: true when the item is a VIP card, used or not.
|
||||
inline bool PortVipUseCard(LPCHARACTER ch,LPITEM item) {
|
||||
const int days=PortVipCardDays(item->GetVnum());
|
||||
if(!days)return false;
|
||||
if(!ch->IsPC() || !ch->GetDesc())return true;
|
||||
if(PortVipThrottled(ch)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTVIP1 error rate");return true;}
|
||||
for(int i=0;i<kPortVipTypes;++i) {
|
||||
const int remain=ch->GetPremiumRemainSeconds(i);
|
||||
if((remain>0?remain:0)+days*86400>kPortVipMaxDays*86400){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTVIP1 error full");return true;}
|
||||
}
|
||||
const DWORD vnum=item->GetVnum(),account=ch->GetDesc()->GetAccountTable().id;
|
||||
std::string sets;
|
||||
for(int i=0;i<kPortVipTypes;++i) {
|
||||
const std::string column=kPortVipColumns[i];
|
||||
sets+=(i?",":"")+column+"=FROM_UNIXTIME(GREATEST(UNIX_TIMESTAMP("+column+"),UNIX_TIMESTAMP())+"+
|
||||
std::to_string(days*86400)+")";
|
||||
}
|
||||
LogManager::instance().ItemLog(ch,item,"MT_VIP_CARD",std::to_string(days).c_str());
|
||||
item->SetCount(item->GetCount()-1);
|
||||
// Same connection as the refresh, which therefore reads the updated row.
|
||||
DBManager::instance().Query("UPDATE account.account SET %s WHERE id=%u",sets.c_str(),account);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTVIP1 added %u %d",unsigned(vnum),days);
|
||||
PortVipRefresh(ch,true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// /mt_vip 1 status -> MTVIP1 times (seven remaining seconds, PREMIUM_EXP .. PREMIUM_GOLD)
|
||||
inline void PortVipCommand(LPCHARACTER ch,const char* argument) {
|
||||
std::istringstream input(argument);std::vector<std::string> args;std::string token;
|
||||
while(input>>token){if(token.size()>10 || args.size()>=3)return;args.push_back(token);}
|
||||
if(args.empty() || args[0]!="1")return;
|
||||
if(args.size()!=2 || args[1]!="status"){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTVIP1 error invalid");return;}
|
||||
if(PortVipThrottled(ch)){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTVIP1 error rate");return;}
|
||||
PortVipRefresh(ch,true);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
// AVA2 new rings (ENABLE_NEW_RINGS): ITEM_NEW_RINGS (36), worn in WEAR_RINGS_1 / WEAR_RINGS_2 (item.cpp
|
||||
// FindEquipCell). They are socket accessories like the 40250 bracelets / necklaces / earrings (IsAccessoryForSocket):
|
||||
// drills add sockets, and each ring family takes the jewel of the matching AVA2 accessory family (CanPutInto).
|
||||
// Their random attributes come from AVA2's item_attr_rings table. As with the talismans (port_pendant.cpp), that
|
||||
// table is not added to 203's item_attr / ATTRIBUTE_SET_*, which would change the db -> game boot packet: the pool
|
||||
// lives here, GetAttributeSetIndex() stays -1 and PutAttributeWithLevel() branches to it, and the 40250 switchers /
|
||||
// adders accept rings (char_item.cpp). The rare (6th / 7th) attributes skip rings; AVA2's
|
||||
// item_attr_rare_rings is not ported. Rings drop without attributes (AlterToMagicItem only handles weapons / armor).
|
||||
#include "stdafx.h"
|
||||
#include "constants.h"
|
||||
#include "item.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct RingAttr
|
||||
{
|
||||
BYTE bApply;
|
||||
DWORD dwProb;
|
||||
short asValues[ITEM_ATTRIBUTE_MAX_LEVEL];
|
||||
};
|
||||
|
||||
// AVA2 player.item_attr_rings (all with max level 5).
|
||||
const RingAttr s_aRingAttr[] =
|
||||
{
|
||||
{ APPLY_MAX_HP, 35, { 200, 300, 300, 500, 500 } },
|
||||
{ APPLY_MAX_SP, 35, { 200, 200, 200, 350, 350 } },
|
||||
{ APPLY_PENETRATE_PCT, 20, { 3, 3, 3, 5, 5 } },
|
||||
{ APPLY_REFLECT_MELEE, 15, { 2, 2, 2, 3, 3 } },
|
||||
{ APPLY_STEAL_SP, 15, { 2, 2, 2, 3, 3 } },
|
||||
{ APPLY_STEAL_HP, 15, { 2, 2, 2, 3, 3 } },
|
||||
{ APPLY_GOLD_DOUBLE_BONUS, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_POISON_REDUCE, 15, { 2, 2, 2, 3, 3 } },
|
||||
{ APPLY_RESIST_MAGIC, 15, { 2, 3, 3, 5, 5 } },
|
||||
{ APPLY_ATTBONUS_DEVIL, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_ATTBONUS_UNDEAD, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_ATTBONUS_MILGYO, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_ATTBONUS_ORC, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_ATTBONUS_ANIMAL, 20, { 4, 4, 4, 8, 8 } },
|
||||
{ APPLY_ATTBONUS_HUMAN, 15, { 3, 3, 3, 5, 5 } },
|
||||
{ APPLY_CRITICAL_PCT, 20, { 3, 3, 3, 5, 5 } },
|
||||
{ APPLY_HP_REGEN, 20, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_SP_REGEN, 20, { 8, 8, 8, 12, 12 } },
|
||||
{ APPLY_POISON_PCT, 15, { 3, 3, 3, 5, 5 } },
|
||||
{ APPLY_SLOW_PCT, 15, { 3, 3, 3, 5, 5 } },
|
||||
};
|
||||
|
||||
// AVA2 CItem::CanPutInto / GetAccessorySocketVnumRings: ring family (vnum / 10 * 10) -> jewel.
|
||||
const struct { DWORD dwRing, dwJewel; } s_aRingJewel[] =
|
||||
{
|
||||
{ 19220, 50634 },
|
||||
{ 19500, 50635 },
|
||||
{ 19520, 50636 },
|
||||
{ 19540, 50637 },
|
||||
{ 19560, 50638 },
|
||||
};
|
||||
}
|
||||
|
||||
bool CItem::IsNewRing()
|
||||
{
|
||||
return GetType() == ITEM_NEW_RINGS;
|
||||
}
|
||||
|
||||
DWORD GetNewRingJewelVnum(DWORD dwRingVnum)
|
||||
{
|
||||
const DWORD dwFamily = dwRingVnum / 10 * 10;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aRingJewel) / sizeof(s_aRingJewel[0]); ++i)
|
||||
if (s_aRingJewel[i].dwRing == dwFamily)
|
||||
return s_aRingJewel[i].dwJewel;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Highest value of a ring attribute, for the switchbot attribute list (port_switchbot.cpp).
|
||||
int GetNewRingAttrMaxValue(BYTE bApply)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(s_aRingAttr) / sizeof(s_aRingAttr[0]); ++i)
|
||||
if (s_aRingAttr[i].bApply == bApply)
|
||||
return s_aRingAttr[i].asValues[ITEM_ATTRIBUTE_MAX_LEVEL - 1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CItem::PutAttributeWithLevel over the ring pool (bLevel 1..5).
|
||||
void CItem::PutNewRingAttributeWithLevel(BYTE bLevel)
|
||||
{
|
||||
if (bLevel < 1 || bLevel > ITEM_ATTRIBUTE_MAX_LEVEL)
|
||||
return;
|
||||
|
||||
DWORD dwTotal = 0;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aRingAttr) / sizeof(s_aRingAttr[0]); ++i)
|
||||
if (!HasAttr(s_aRingAttr[i].bApply))
|
||||
dwTotal += s_aRingAttr[i].dwProb;
|
||||
|
||||
if (!dwTotal)
|
||||
return;
|
||||
|
||||
DWORD dwProb = number(1, dwTotal);
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_aRingAttr) / sizeof(s_aRingAttr[0]); ++i)
|
||||
{
|
||||
const RingAttr & r = s_aRingAttr[i];
|
||||
|
||||
if (HasAttr(r.bApply))
|
||||
continue;
|
||||
|
||||
if (dwProb <= r.dwProb)
|
||||
{
|
||||
AddAttribute(r.bApply, r.asValues[bLevel - 1]);
|
||||
return;
|
||||
}
|
||||
|
||||
dwProb -= r.dwProb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
// AVA2 sash window (combine / absorb), ported from the AVA2 __SASH_SYSTEM__ char.cpp block.
|
||||
// Messages go to the client as "MTSASH <code> [arg]" commands (rendered by the client's mt_sash
|
||||
// script) instead of AVA2's numeric locale strings; AVA2's sash log table is replaced by ItemLog.
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
#include "char.h"
|
||||
#include "desc.h"
|
||||
#include "db.h"
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "log.h"
|
||||
#include "packet.h"
|
||||
|
||||
static void SendSashPacket(LPCHARACTER ch, BYTE bSubHeader, bool bWindow, DWORD dwPrice, BYTE bPos, TItemPos tPos,
|
||||
DWORD dwItemVnum, DWORD dwMinAbs, DWORD dwMaxAbs)
|
||||
{
|
||||
if (!ch->GetDesc())
|
||||
return;
|
||||
|
||||
TPacketSash sPacket;
|
||||
sPacket.header = HEADER_GC_SASH;
|
||||
sPacket.subheader = bSubHeader;
|
||||
sPacket.bWindow = bWindow;
|
||||
sPacket.dwPrice = dwPrice;
|
||||
sPacket.bPos = bPos;
|
||||
sPacket.tPos = tPos;
|
||||
sPacket.dwItemVnum = dwItemVnum;
|
||||
sPacket.dwMinAbs = dwMinAbs;
|
||||
sPacket.dwMaxAbs = dwMaxAbs;
|
||||
ch->GetDesc()->Packet(&sPacket, sizeof(TPacketSash));
|
||||
}
|
||||
|
||||
static TItemPos SashNoPos()
|
||||
{
|
||||
return TItemPos(INVENTORY, 0);
|
||||
}
|
||||
|
||||
void CHARACTER::OpenSash(bool bCombination)
|
||||
{
|
||||
if (isSashOpened(bCombination))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH already_open");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bCombination)
|
||||
{
|
||||
if (m_bSashAbsorption)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH absorb_open");
|
||||
return;
|
||||
}
|
||||
|
||||
m_bSashCombination = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bSashCombination)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH combine_open");
|
||||
return;
|
||||
}
|
||||
|
||||
m_bSashAbsorption = true;
|
||||
}
|
||||
|
||||
SendSashPacket(this, SASH_SUBHEADER_GC_OPEN, bCombination, 0, 0, SashNoPos(), 0, 0, 0);
|
||||
ClearSashMaterials();
|
||||
}
|
||||
|
||||
void CHARACTER::CloseSash()
|
||||
{
|
||||
if (!m_bSashCombination && !m_bSashAbsorption)
|
||||
return;
|
||||
|
||||
bool bWindow = m_bSashCombination;
|
||||
SendSashPacket(this, SASH_SUBHEADER_GC_CLOSE, bWindow, 0, 0, SashNoPos(), 0, 0, 0);
|
||||
|
||||
if (bWindow)
|
||||
m_bSashCombination = false;
|
||||
else
|
||||
m_bSashAbsorption = false;
|
||||
|
||||
ClearSashMaterials();
|
||||
}
|
||||
|
||||
void CHARACTER::ClearSashMaterials()
|
||||
{
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
for (int i = 0; i < SASH_WINDOW_MAX_MATERIALS; ++i)
|
||||
{
|
||||
if (!pkItemMaterial[i])
|
||||
continue;
|
||||
|
||||
pkItemMaterial[i]->Lock(false);
|
||||
pkItemMaterial[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool CHARACTER::SashIsSameGrade(long lGrade)
|
||||
{
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
if (!pkItemMaterial[0])
|
||||
return false;
|
||||
|
||||
return pkItemMaterial[0]->GetValue(SASH_GRADE_VALUE_FIELD) == lGrade;
|
||||
}
|
||||
|
||||
DWORD CHARACTER::GetSashCombinePrice(long lGrade)
|
||||
{
|
||||
switch (lGrade)
|
||||
{
|
||||
case 2: return SASH_GRADE_2_PRICE;
|
||||
case 3: return SASH_GRADE_3_PRICE;
|
||||
case 4: return SASH_GRADE_4_PRICE;
|
||||
default: return SASH_GRADE_1_PRICE;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE CHARACTER::CheckEmptyMaterialSlot()
|
||||
{
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
for (int i = 0; i < SASH_WINDOW_MAX_MATERIALS; ++i)
|
||||
{
|
||||
if (!pkItemMaterial[i])
|
||||
return i;
|
||||
}
|
||||
|
||||
return 255;
|
||||
}
|
||||
|
||||
void CHARACTER::GetSashCombineResult(DWORD & dwItemVnum, DWORD & dwMinAbs, DWORD & dwMaxAbs)
|
||||
{
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
dwItemVnum = 0;
|
||||
dwMinAbs = 0;
|
||||
dwMaxAbs = 0;
|
||||
|
||||
if (!pkItemMaterial[0] || !pkItemMaterial[1])
|
||||
return;
|
||||
|
||||
if (m_bSashCombination)
|
||||
{
|
||||
long lVal = pkItemMaterial[0]->GetValue(SASH_GRADE_VALUE_FIELD);
|
||||
if (lVal == 4)
|
||||
{
|
||||
dwItemVnum = pkItemMaterial[0]->GetOriginalVnum();
|
||||
dwMinAbs = pkItemMaterial[0]->GetSocket(SASH_ABSORPTION_SOCKET);
|
||||
dwMaxAbs = MIN(dwMinAbs + SASH_GRADE_4_ABS_RANGE, (DWORD) SASH_GRADE_4_ABS_MAX);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwMaskVnum = pkItemMaterial[0]->GetOriginalVnum();
|
||||
if (ITEM_MANAGER::instance().GetTable(dwMaskVnum + 1))
|
||||
dwMaskVnum += 1;
|
||||
|
||||
dwItemVnum = dwMaskVnum;
|
||||
switch (lVal)
|
||||
{
|
||||
case 2:
|
||||
dwMinAbs = dwMaxAbs = SASH_GRADE_3_ABS;
|
||||
break;
|
||||
case 3:
|
||||
dwMinAbs = SASH_GRADE_4_ABS_MIN;
|
||||
dwMaxAbs = SASH_GRADE_4_ABS_MAX_COMB;
|
||||
break;
|
||||
default:
|
||||
dwMinAbs = dwMaxAbs = SASH_GRADE_2_ABS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dwItemVnum = pkItemMaterial[0]->GetOriginalVnum();
|
||||
dwMinAbs = dwMaxAbs = pkItemMaterial[0]->GetSocket(SASH_ABSORPTION_SOCKET);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsSash(LPITEM pkItem)
|
||||
{
|
||||
return pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_SASH;
|
||||
}
|
||||
|
||||
static bool IsSashAbsorbable(LPITEM pkItem)
|
||||
{
|
||||
return pkItem->GetType() == ITEM_WEAPON || (pkItem->GetType() == ITEM_ARMOR && pkItem->GetSubType() == ARMOR_BODY);
|
||||
}
|
||||
|
||||
void CHARACTER::AddSashMaterial(TItemPos tPos, BYTE bPos)
|
||||
{
|
||||
if (!m_bSashCombination && !m_bSashAbsorption)
|
||||
return;
|
||||
|
||||
if (bPos >= SASH_WINDOW_MAX_MATERIALS)
|
||||
{
|
||||
if (bPos != 255)
|
||||
return;
|
||||
|
||||
bPos = CheckEmptyMaterialSlot();
|
||||
if (bPos >= SASH_WINDOW_MAX_MATERIALS)
|
||||
return;
|
||||
}
|
||||
|
||||
if (tPos.window_type != INVENTORY)
|
||||
return;
|
||||
|
||||
LPITEM pkItem = GetItem(tPos);
|
||||
if (!pkItem)
|
||||
return;
|
||||
if (pkItem->GetCell() >= INVENTORY_MAX_NUM || pkItem->IsEquipped() || tPos.IsBeltInventoryPosition() || pkItem->IsDragonSoul() || pkItem->IsExchanging())
|
||||
return;
|
||||
|
||||
// the sash slot (0) and both combine slots take sashes only
|
||||
if ((m_bSashCombination || bPos == 0) && !IsSash(pkItem))
|
||||
return;
|
||||
|
||||
if (pkItem->isLocked())
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH locked");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bSashCombination)
|
||||
{
|
||||
if (bPos == 1 && !SashIsSameGrade(pkItem->GetValue(SASH_GRADE_VALUE_FIELD)))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH grade");
|
||||
return;
|
||||
}
|
||||
if (pkItem->GetSocket(SASH_ABSORPTION_SOCKET) >= SASH_GRADE_4_ABS_MAX)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH max_abs");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (bPos == 1)
|
||||
{
|
||||
if (!IsSashAbsorbable(pkItem))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH absorb_type");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (pkItem->GetSocket(SASH_ABSORBED_SOCKET) > 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH absorbed");
|
||||
return;
|
||||
}
|
||||
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
if (bPos == 1 && !pkItemMaterial[0])
|
||||
return;
|
||||
|
||||
if (pkItemMaterial[bPos])
|
||||
return;
|
||||
|
||||
pkItemMaterial[bPos] = pkItem;
|
||||
pkItem->Lock(true);
|
||||
|
||||
DWORD dwItemVnum, dwMinAbs, dwMaxAbs;
|
||||
GetSashCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs);
|
||||
SendSashPacket(this, SASH_SUBHEADER_GC_ADDED, m_bSashCombination, GetSashCombinePrice(pkItem->GetValue(SASH_GRADE_VALUE_FIELD)),
|
||||
bPos, tPos, dwItemVnum, dwMinAbs, dwMaxAbs);
|
||||
}
|
||||
|
||||
void CHARACTER::RemoveSashMaterial(BYTE bPos)
|
||||
{
|
||||
if (bPos >= SASH_WINDOW_MAX_MATERIALS)
|
||||
return;
|
||||
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
DWORD dwPrice = 0;
|
||||
|
||||
if (bPos == 1)
|
||||
{
|
||||
if (pkItemMaterial[bPos])
|
||||
{
|
||||
pkItemMaterial[bPos]->Lock(false);
|
||||
pkItemMaterial[bPos] = NULL;
|
||||
}
|
||||
|
||||
if (pkItemMaterial[0])
|
||||
dwPrice = GetSashCombinePrice(pkItemMaterial[0]->GetValue(SASH_GRADE_VALUE_FIELD));
|
||||
}
|
||||
else
|
||||
ClearSashMaterials();
|
||||
|
||||
SendSashPacket(this, SASH_SUBHEADER_GC_REMOVED, m_bSashCombination, dwPrice, bPos, SashNoPos(), 0, 0, 0);
|
||||
}
|
||||
|
||||
BYTE CHARACTER::CanRefineSashMaterials()
|
||||
{
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
if (!pkItemMaterial[0] || !pkItemMaterial[1])
|
||||
return 0;
|
||||
|
||||
if (m_bSashCombination)
|
||||
return (IsSash(pkItemMaterial[0]) && IsSash(pkItemMaterial[1])) ? 1 : 0;
|
||||
|
||||
if (m_bSashAbsorption)
|
||||
{
|
||||
// AVA2 overwrote the sash check with the target check; both must hold
|
||||
if (!IsSash(pkItemMaterial[0]) || !IsSashAbsorbable(pkItemMaterial[1]))
|
||||
return 0;
|
||||
if (pkItemMaterial[0]->GetSocket(SASH_ABSORBED_SOCKET) > 0)
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CHARACTER::RefineSashMaterials()
|
||||
{
|
||||
BYTE bCan = CanRefineSashMaterials();
|
||||
if (bCan == 0)
|
||||
return;
|
||||
|
||||
LPITEM * pkItemMaterial = GetSashMaterials();
|
||||
|
||||
DWORD dwItemVnum, dwMinAbs, dwMaxAbs;
|
||||
GetSashCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs);
|
||||
long long llPrice = GetSashCombinePrice(pkItemMaterial[0]->GetValue(SASH_GRADE_VALUE_FIELD));
|
||||
|
||||
if (bCan == 1)
|
||||
{
|
||||
int iSuccessChance;
|
||||
long lVal = pkItemMaterial[0]->GetValue(SASH_GRADE_VALUE_FIELD);
|
||||
switch (lVal)
|
||||
{
|
||||
case 2: iSuccessChance = SASH_COMBINE_GRADE_2; break;
|
||||
case 3: iSuccessChance = SASH_COMBINE_GRADE_3; break;
|
||||
case 4: iSuccessChance = SASH_COMBINE_GRADE_4; break;
|
||||
default: iSuccessChance = SASH_COMBINE_GRADE_1; break;
|
||||
}
|
||||
|
||||
if (GetGold() < llPrice)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH gold");
|
||||
return;
|
||||
}
|
||||
|
||||
bool bSuccess = number(1, 100) <= iSuccessChance;
|
||||
if (bSuccess)
|
||||
{
|
||||
LPITEM pkItem = ITEM_MANAGER::instance().CreateItem(dwItemVnum, 1, 0, false);
|
||||
if (!pkItem)
|
||||
{
|
||||
sys_err("sash combine: %u can't be created.", dwItemVnum);
|
||||
return;
|
||||
}
|
||||
|
||||
ITEM_MANAGER::CopyAllAttrTo(pkItemMaterial[0], pkItem);
|
||||
DWORD dwAbs = (dwMinAbs == dwMaxAbs ? dwMinAbs : number(dwMinAbs + 1, dwMaxAbs));
|
||||
pkItem->SetSocket(SASH_ABSORPTION_SOCKET, dwAbs);
|
||||
pkItem->SetSocket(SASH_ABSORBED_SOCKET, pkItemMaterial[0]->GetSocket(SASH_ABSORBED_SOCKET));
|
||||
|
||||
PointChange(POINT_GOLD, -llPrice);
|
||||
DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice);
|
||||
|
||||
WORD wCell = pkItemMaterial[0]->GetCell();
|
||||
ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[0], "SASH COMBINE (REFINE SUCCESS)");
|
||||
ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "SASH COMBINE (REFINE SUCCESS)");
|
||||
pkItemMaterial[0] = pkItemMaterial[1] = NULL;
|
||||
|
||||
pkItem->AddToCharacter(this, TItemPos(INVENTORY, wCell));
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(pkItem);
|
||||
pkItem->AttrLog();
|
||||
LogManager::instance().ItemLog(this, pkItem, "SASH COMBINE SUCCESS", pkItem->GetName());
|
||||
|
||||
if (lVal == 4)
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH abs %u", dwAbs);
|
||||
else
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH success");
|
||||
|
||||
EffectPacket(SE_EFFECT_SASH_SUCCEDED);
|
||||
}
|
||||
else
|
||||
{
|
||||
PointChange(POINT_GOLD, -llPrice);
|
||||
DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice);
|
||||
|
||||
LogManager::instance().ItemLog(this, pkItemMaterial[1], "SASH COMBINE FAIL", pkItemMaterial[1]->GetName());
|
||||
ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "SASH COMBINE (REFINE FAIL)");
|
||||
pkItemMaterial[1] = NULL;
|
||||
|
||||
if (lVal == 4)
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH abs %ld", pkItemMaterial[0]->GetSocket(SASH_ABSORPTION_SOCKET));
|
||||
else
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH fail");
|
||||
}
|
||||
|
||||
SendSashPacket(this, SASH_SUBHEADER_CG_REFINED, m_bSashCombination, (DWORD) llPrice, 0, SashNoPos(), 0, 0, bSuccess ? 100 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
LPITEM pkSash = pkItemMaterial[0];
|
||||
LPITEM pkTarget = pkItemMaterial[1];
|
||||
|
||||
pkTarget->CopyAttributeTo(pkSash);
|
||||
pkSash->SetSocket(SASH_ABSORBED_SOCKET, pkTarget->GetOriginalVnum());
|
||||
for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i)
|
||||
{
|
||||
if (pkSash->GetAttributeValue(i) < 0)
|
||||
pkSash->SetForceAttribute(i, pkSash->GetAttributeType(i), 0);
|
||||
}
|
||||
|
||||
LogManager::instance().ItemLog(this, pkSash, "SASH ABSORB", pkTarget->GetName());
|
||||
ITEM_MANAGER::instance().RemoveItem(pkTarget, "SASH ABSORBED (REFINE SUCCESS)");
|
||||
pkItemMaterial[1] = NULL;
|
||||
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(pkSash);
|
||||
pkSash->AttrLog();
|
||||
|
||||
ChatPacket(CHAT_TYPE_COMMAND, "MTSASH success");
|
||||
ClearSashMaterials();
|
||||
|
||||
SendSashPacket(this, SASH_SUBHEADER_CG_REFINED, m_bSashCombination, (DWORD) llPrice, 255, SashNoPos(), 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// An absorbed weapon adds its attack (values 3/4 + 5) and magic attack (1/2 + 5) at the absorption %.
|
||||
bool Sash_GetAbsorbedWeaponBonus(LPCHARACTER ch, int * piMin, int * piMax, int * piMagMin, int * piMagMax)
|
||||
{
|
||||
LPITEM pkSash = ch ? ch->GetWear(WEAR_COSTUME_SASH) : NULL;
|
||||
if (!pkSash)
|
||||
return false;
|
||||
|
||||
const TItemTable * pkAbsorbed = ITEM_MANAGER::instance().GetTable(pkSash->GetSocket(SASH_ABSORBED_SOCKET));
|
||||
if (!pkAbsorbed || pkAbsorbed->bType != ITEM_WEAPON)
|
||||
return false;
|
||||
|
||||
const double dPct = pkSash->GetSocket(SASH_ABSORPTION_SOCKET) / 100.0;
|
||||
*piMin = (int) ((pkAbsorbed->alValues[3] + pkAbsorbed->alValues[5]) * dPct + .5);
|
||||
*piMax = (int) ((pkAbsorbed->alValues[4] + pkAbsorbed->alValues[5]) * dPct + .5);
|
||||
*piMagMin = (int) ((pkAbsorbed->alValues[1] + pkAbsorbed->alValues[5]) * dPct + .5);
|
||||
*piMagMax = (int) ((pkAbsorbed->alValues[2] + pkAbsorbed->alValues[5]) * dPct + .5);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,808 @@
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT, from AVA2 game/src/new_switchbot.cpp. Classes, API, packets, the 0.1 s roll
|
||||
// speed and the CheckItem rule (one configured alternative fully matched within the first 5 attributes; no
|
||||
// configured alternative counts as a match) are AVA2's. Deviations:
|
||||
// - Cell 5 (AVA2's hidden 71084 cell) is never used; MoveItem rejects it. Switchers stay in the inventory and
|
||||
// are taken one per roll, skipping stacks that are being exchanged, locked or sold in the player's shop.
|
||||
// - Switcher choice follows the manual path (char_item.cpp USE_CHANGE_ATTRIBUTE): a talisman takes only 71302;
|
||||
// a weapon or body armour without a level limit above 40 takes 71151 / 76023 first; everything else takes
|
||||
// 71084, then 39028. AVA2 could pick 71151 / 76023 for high-level items and never consumed 39028.
|
||||
// - A slot stops instead of rolling when its item has no attributes (the manual path refuses that too).
|
||||
// - Every roll is in ItemLog as SWITCHBOT, with the item id as hint, like CHANGE_ATTRIBUTE.
|
||||
// - The end / stop messages go to the client as server commands ("switchbot_end <slot>",
|
||||
// "switchbot_stop <reason>") for localeInfo text, instead of AVA2's numeric locale ids 864 / 865.
|
||||
// - Leaving the core deletes the table after it is sent (AVA2 leaked it), and a logout that unregisters the last
|
||||
// active slot stops the roll event.
|
||||
// - Version gate: EnterGame sends nothing unless the CG_CLIENT_VERSION(2) timestamp carries "mt<date>" with
|
||||
// date >= PORT_SWITCHBOT_CLIENT_VERSION. The EU client sends "1215955205 mt<date>": the europe version
|
||||
// check reads the timestamp with atoi, so it still sees 1215955205. Older clients send "1215955205" only.
|
||||
// - The attribute list has two pseudo sets after ATTRIBUTE_SET_MAX_NUM: 8 = rings (port_rings.cpp) and
|
||||
// 9 = talismans (port_pendant.cpp), whose pools are not in item_attr.
|
||||
#include "stdafx.h"
|
||||
#include "constants.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "desc.h"
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "char_manager.h"
|
||||
#include "buffer_manager.h"
|
||||
#include "char.h"
|
||||
#include "config.h"
|
||||
#include "p2p.h"
|
||||
#include "packet.h"
|
||||
#include "shop.h"
|
||||
#include "log.h"
|
||||
#include "db.h"
|
||||
|
||||
// Wire sizes the client (UserInterface/Packet.h) mirrors byte for byte.
|
||||
static_assert(sizeof(TSwitchbotTable) == 220, "TSwitchbotTable");
|
||||
static_assert(sizeof(TSwitchbotAttributeAlternativeTable) == 15, "TSwitchbotAttributeAlternativeTable");
|
||||
static_assert(sizeof(TSwitchbottAttributeTable) == 9, "TSwitchbottAttributeTable");
|
||||
static_assert(sizeof(TSwitchbotUpdateItem) == 40, "TSwitchbotUpdateItem");
|
||||
static_assert(sizeof(TPacketCGSwitchbot) == 7 && sizeof(TPacketGCSwitchbot) == 7, "switchbot packet header");
|
||||
static_assert(sizeof(TPacketGGSwitchbot) == 223, "TPacketGGSwitchbot");
|
||||
|
||||
namespace
|
||||
{
|
||||
const float c_fSpeed = 0.1f;
|
||||
|
||||
enum
|
||||
{
|
||||
SWITCHBOT_ATTRIBUTE_SET_NEW_RINGS = ATTRIBUTE_SET_MAX_NUM, // 8
|
||||
SWITCHBOT_ATTRIBUTE_SET_PENDANT, // 9
|
||||
};
|
||||
|
||||
bool ValidPosition(DWORD wCell)
|
||||
{
|
||||
return wCell < SWITCHBOT_SLOT_COUNT_REAL;
|
||||
}
|
||||
|
||||
long SwitchbotPasses()
|
||||
{
|
||||
const long lPasses = long(PASSES_PER_SEC(c_fSpeed));
|
||||
return lPasses > 0 ? lPasses : 1;
|
||||
}
|
||||
|
||||
bool IsLowLevelSwitchTarget(LPITEM pkItem)
|
||||
{
|
||||
if (!(pkItem->GetType() == ITEM_WEAPON || (pkItem->GetType() == ITEM_ARMOR && pkItem->GetSubType() == ARMOR_BODY)))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
|
||||
if (pkItem->GetLimitType(i) == LIMIT_LEVEL && pkItem->GetLimitValue(i) > 40)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// CHARACTER::FindSpecifyItem over stacks the player can spend right now.
|
||||
LPITEM FindUsableSwitcher(LPCHARACTER ch, DWORD dwVnum)
|
||||
{
|
||||
LPSHOP pkShop = ch->GetMyShop();
|
||||
|
||||
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
|
||||
{
|
||||
LPITEM item = ch->GetInventoryItem(i);
|
||||
|
||||
if (!item || item->GetVnum() != dwVnum || item->GetCount() < SWITCHBOT_PRICE_AMOUNT)
|
||||
continue;
|
||||
|
||||
if (item->IsExchanging() || item->isLocked())
|
||||
continue;
|
||||
|
||||
if (pkShop && pkShop->IsSellingItem(item->GetID()))
|
||||
continue;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LPITEM SelectSwitcher(LPCHARACTER ch, LPITEM pkItem)
|
||||
{
|
||||
if (pkItem->IsTalisman())
|
||||
return FindUsableSwitcher(ch, 71302);
|
||||
|
||||
static const DWORD s_adwLow[] = { 71151, 76023 };
|
||||
static const DWORD s_adwNormal[] = { 71084, 39028 };
|
||||
|
||||
if (IsLowLevelSwitchTarget(pkItem))
|
||||
for (size_t i = 0; i < sizeof(s_adwLow) / sizeof(s_adwLow[0]); ++i)
|
||||
if (LPITEM scroll = FindUsableSwitcher(ch, s_adwLow[i]))
|
||||
return scroll;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_adwNormal) / sizeof(s_adwNormal[0]); ++i)
|
||||
if (LPITEM scroll = FindUsableSwitcher(ch, s_adwNormal[i]))
|
||||
return scroll;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void WriteAttribute(TEMP_BUFFER& buf, BYTE bSet, int iApply, int iMax)
|
||||
{
|
||||
TSwitchbottAttributeTable table = {};
|
||||
table.attribute_set = bSet;
|
||||
table.apply_num = iApply;
|
||||
table.max_value = iMax;
|
||||
buf.write(&table, sizeof(table));
|
||||
}
|
||||
}
|
||||
|
||||
bool SwitchbotHelper::IsValidItem(LPITEM pkItem)
|
||||
{
|
||||
if (!pkItem)
|
||||
return false;
|
||||
|
||||
switch (pkItem->GetType())
|
||||
{
|
||||
case ITEM_NEW_RINGS:
|
||||
case ITEM_WEAPON:
|
||||
return true;
|
||||
|
||||
case ITEM_ARMOR:
|
||||
switch (pkItem->GetSubType())
|
||||
{
|
||||
case ARMOR_BODY:
|
||||
case ARMOR_HEAD:
|
||||
case ARMOR_SHIELD:
|
||||
case ARMOR_WRIST:
|
||||
case ARMOR_FOOTS:
|
||||
case ARMOR_NECK:
|
||||
case ARMOR_EAR:
|
||||
case ARMOR_PENDANT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CSwitchbot::CSwitchbot() : m_pkSwitchEvent(NULL), m_isWarping(false)
|
||||
{
|
||||
}
|
||||
|
||||
CSwitchbot::~CSwitchbot()
|
||||
{
|
||||
if (m_pkSwitchEvent)
|
||||
event_cancel(&m_pkSwitchEvent);
|
||||
|
||||
m_pkSwitchEvent = NULL;
|
||||
}
|
||||
|
||||
void CSwitchbot::RegisterItem(WORD wCell, DWORD item_id)
|
||||
{
|
||||
if (!ValidPosition(wCell))
|
||||
return;
|
||||
|
||||
m_table.items[wCell] = item_id;
|
||||
}
|
||||
|
||||
void CSwitchbot::UnregisterItem(WORD wCell)
|
||||
{
|
||||
if (!ValidPosition(wCell))
|
||||
return;
|
||||
|
||||
m_table.items[wCell] = 0;
|
||||
m_table.active[wCell] = false;
|
||||
m_table.finished[wCell] = false;
|
||||
memset(&m_table.alternatives[wCell], 0, sizeof(m_table.alternatives[wCell]));
|
||||
}
|
||||
|
||||
void CSwitchbot::SetAttributes(BYTE slot, const std::vector<TSwitchbotAttributeAlternativeTable>& vec_alternatives)
|
||||
{
|
||||
if (!ValidPosition(slot) || vec_alternatives.size() < SWITCHBOT_ALTERNATIVE_COUNT)
|
||||
return;
|
||||
|
||||
for (BYTE alternative = 0; alternative < SWITCHBOT_ALTERNATIVE_COUNT; ++alternative)
|
||||
{
|
||||
for (BYTE attrIdx = 0; attrIdx < SWITCHBOT_NORM_ATTR_NUM; ++attrIdx)
|
||||
{
|
||||
m_table.alternatives[slot][alternative].attributes[attrIdx].bType = vec_alternatives[alternative].attributes[attrIdx].bType;
|
||||
m_table.alternatives[slot][alternative].attributes[attrIdx].sValue = vec_alternatives[alternative].attributes[attrIdx].sValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSwitchbot::SetActive(BYTE slot, bool active)
|
||||
{
|
||||
if (!ValidPosition(slot))
|
||||
return;
|
||||
|
||||
m_table.active[slot] = active;
|
||||
m_table.finished[slot] = false;
|
||||
}
|
||||
|
||||
EVENTINFO(TSwitchbotEventInfo)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot;
|
||||
|
||||
TSwitchbotEventInfo() : pkSwitchbot(NULL)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
EVENTFUNC(switchbot_event)
|
||||
{
|
||||
TSwitchbotEventInfo* info = dynamic_cast<TSwitchbotEventInfo*>(event->info);
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
sys_err("switchbot_event> <Factor> Info Null pointer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!info->pkSwitchbot)
|
||||
{
|
||||
sys_err("switchbot_event> <Factor> Switchbot Null pointer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
info->pkSwitchbot->SwitchItems();
|
||||
|
||||
return SwitchbotPasses();
|
||||
}
|
||||
|
||||
void CSwitchbot::Start()
|
||||
{
|
||||
TSwitchbotEventInfo* info = AllocEventInfo<TSwitchbotEventInfo>();
|
||||
info->pkSwitchbot = this;
|
||||
|
||||
m_pkSwitchEvent = event_create(switchbot_event, info, SwitchbotPasses());
|
||||
|
||||
CSwitchbotManager::Instance().SendSwitchbotUpdate(m_table.player_id);
|
||||
}
|
||||
|
||||
void CSwitchbot::Stop()
|
||||
{
|
||||
if (m_pkSwitchEvent)
|
||||
{
|
||||
event_cancel(&m_pkSwitchEvent);
|
||||
m_pkSwitchEvent = NULL;
|
||||
}
|
||||
|
||||
memset(&m_table.active, 0, sizeof(m_table.active));
|
||||
|
||||
CSwitchbotManager::Instance().SendSwitchbotUpdate(m_table.player_id);
|
||||
|
||||
for (BYTE bSlot = 0; bSlot < SWITCHBOT_SLOT_COUNT_REAL; ++bSlot)
|
||||
{
|
||||
LPITEM pkItem = ITEM_MANAGER::Instance().Find(m_table.items[bSlot]);
|
||||
|
||||
if (!pkItem)
|
||||
continue;
|
||||
|
||||
LPCHARACTER pkOwner = pkItem->GetOwner();
|
||||
|
||||
if (!pkOwner)
|
||||
return;
|
||||
|
||||
SendItemUpdate(pkOwner, bSlot, pkItem);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwitchbot::Pause()
|
||||
{
|
||||
if (m_pkSwitchEvent)
|
||||
{
|
||||
event_cancel(&m_pkSwitchEvent);
|
||||
m_pkSwitchEvent = NULL;
|
||||
}
|
||||
|
||||
for (BYTE bSlot = 0; bSlot < SWITCHBOT_SLOT_COUNT_REAL; ++bSlot)
|
||||
{
|
||||
LPITEM pkItem = ITEM_MANAGER::Instance().Find(m_table.items[bSlot]);
|
||||
|
||||
if (!pkItem)
|
||||
continue;
|
||||
|
||||
LPCHARACTER pkOwner = pkItem->GetOwner();
|
||||
|
||||
if (!pkOwner)
|
||||
return;
|
||||
|
||||
SendItemUpdate(pkOwner, bSlot, pkItem);
|
||||
}
|
||||
}
|
||||
|
||||
bool CSwitchbot::IsActive(BYTE slot)
|
||||
{
|
||||
if (!ValidPosition(slot))
|
||||
return false;
|
||||
|
||||
return m_table.active[slot];
|
||||
}
|
||||
|
||||
bool CSwitchbot::HasActiveSlots()
|
||||
{
|
||||
for (int i = 0; i < SWITCHBOT_SLOT_COUNT_REAL; ++i)
|
||||
if (m_table.active[i])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSwitchbot::IsSwitching()
|
||||
{
|
||||
return m_pkSwitchEvent != NULL;
|
||||
}
|
||||
|
||||
// AVA2's success / out-of-switchers tail: deactivate the slot, stop when it was the last one, refresh the client.
|
||||
void CSwitchbot::FinishSlot(LPCHARACTER ch, BYTE slot, LPITEM item, bool finished)
|
||||
{
|
||||
SetActive(slot, false);
|
||||
m_table.finished[slot] = finished;
|
||||
|
||||
if (!HasActiveSlots())
|
||||
Stop();
|
||||
else
|
||||
CSwitchbotManager::Instance().SendSwitchbotUpdate(m_table.player_id);
|
||||
|
||||
SendItemUpdate(ch, slot, item);
|
||||
}
|
||||
|
||||
void CSwitchbot::SwitchItems()
|
||||
{
|
||||
for (BYTE bSlot = 0; bSlot < SWITCHBOT_SLOT_COUNT_REAL; ++bSlot)
|
||||
{
|
||||
if (!m_table.active[bSlot])
|
||||
continue;
|
||||
|
||||
m_table.finished[bSlot] = false;
|
||||
|
||||
LPITEM pkItem = ITEM_MANAGER::Instance().Find(m_table.items[bSlot]);
|
||||
|
||||
if (!pkItem)
|
||||
continue;
|
||||
|
||||
LPCHARACTER pkOwner = pkItem->GetOwner();
|
||||
|
||||
if (!pkOwner)
|
||||
return;
|
||||
|
||||
if (pkOwner->GetPlayerID() != m_table.player_id || pkItem->GetWindow() != SWITCHBOT || pkItem->GetCell() != bSlot)
|
||||
{
|
||||
sys_err("switchbot: item %u is no longer in slot %d of player %u", m_table.items[bSlot], bSlot, m_table.player_id);
|
||||
UnregisterItem(bSlot);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CheckItem(pkItem, bSlot))
|
||||
{
|
||||
pkOwner->ChatPacket(CHAT_TYPE_COMMAND, "switchbot_end %d", bSlot);
|
||||
FinishSlot(pkOwner, bSlot, pkItem, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pkItem->GetAttributeCount() || (pkItem->GetAttributeSetIndex() < 0 && !pkItem->IsNewRing() && !pkItem->IsTalisman()))
|
||||
{
|
||||
pkOwner->ChatPacket(CHAT_TYPE_COMMAND, "switchbot_stop noattr %d", bSlot);
|
||||
FinishSlot(pkOwner, bSlot, pkItem, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
LPITEM pkScroll = SelectSwitcher(pkOwner, pkItem);
|
||||
|
||||
if (!pkScroll)
|
||||
{
|
||||
pkOwner->ChatPacket(CHAT_TYPE_COMMAND, "switchbot_stop nochanger %d", bSlot);
|
||||
FinishSlot(pkOwner, bSlot, pkItem, false);
|
||||
return;
|
||||
}
|
||||
|
||||
char szHint[21];
|
||||
snprintf(szHint, sizeof(szHint), "%u", pkItem->GetID());
|
||||
LogManager::instance().ItemLog(pkOwner, pkScroll, "SWITCHBOT", szHint);
|
||||
|
||||
pkScroll->SetCount(pkScroll->GetCount() - SWITCHBOT_PRICE_AMOUNT);
|
||||
pkItem->ChangeAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
bool CSwitchbot::CheckItem(LPITEM pkItem, BYTE slot)
|
||||
{
|
||||
if (!ValidPosition(slot) || !pkItem)
|
||||
return false;
|
||||
|
||||
bool checked = false;
|
||||
|
||||
for (int i = 0; i < SWITCHBOT_ALTERNATIVE_COUNT; ++i)
|
||||
{
|
||||
const TSwitchbotAttributeAlternativeTable& alternative = m_table.alternatives[slot][i];
|
||||
|
||||
if (!alternative.IsConfigured())
|
||||
continue;
|
||||
|
||||
BYTE configuredAttrCount = 0;
|
||||
BYTE correctAttrCount = 0;
|
||||
|
||||
for (int j = 0; j < SWITCHBOT_NORM_ATTR_NUM; ++j)
|
||||
{
|
||||
const TPlayerItemAttribute& destAttr = alternative.attributes[j];
|
||||
|
||||
if (!destAttr.bType || !destAttr.sValue)
|
||||
continue;
|
||||
|
||||
++configuredAttrCount;
|
||||
|
||||
for (BYTE attrIdx = 0; attrIdx < SWITCHBOT_NORM_ATTR_NUM; ++attrIdx)
|
||||
{
|
||||
const TPlayerItemAttribute& curAttr = pkItem->GetAttribute(attrIdx);
|
||||
|
||||
if (curAttr.bType != destAttr.bType || curAttr.sValue < destAttr.sValue)
|
||||
continue;
|
||||
|
||||
++correctAttrCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checked = true;
|
||||
|
||||
if (configuredAttrCount == correctAttrCount)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!checked)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSwitchbot::SendItemUpdate(LPCHARACTER ch, BYTE slot, LPITEM item)
|
||||
{
|
||||
LPDESC desc = ch->GetDesc();
|
||||
|
||||
if (!desc)
|
||||
return;
|
||||
|
||||
TPacketGCSwitchbot pack;
|
||||
pack.header = HEADER_GC_SWITCHBOT;
|
||||
pack.subheader = SUBHEADER_GC_SWITCHBOT_UPDATE_ITEM;
|
||||
pack.size = sizeof(TPacketGCSwitchbot) + sizeof(TSwitchbotUpdateItem);
|
||||
pack.slot = slot;
|
||||
|
||||
TSwitchbotUpdateItem update = {};
|
||||
update.slot = slot;
|
||||
update.vnum = item->GetVnum();
|
||||
update.count = item->GetCount();
|
||||
thecore_memcpy(update.alSockets, item->GetSockets(), sizeof(update.alSockets));
|
||||
thecore_memcpy(update.aAttr, item->GetAttributes(), sizeof(update.aAttr));
|
||||
|
||||
TEMP_BUFFER tmp_buf;
|
||||
tmp_buf.write(&pack, sizeof(pack));
|
||||
tmp_buf.write(&update, sizeof(update));
|
||||
desc->Packet(tmp_buf.read_peek(), tmp_buf.size());
|
||||
}
|
||||
|
||||
CSwitchbotManager::~CSwitchbotManager()
|
||||
{
|
||||
for (std::map<DWORD, CSwitchbot*>::iterator it = m_map_Switchbots.begin(); it != m_map_Switchbots.end(); ++it)
|
||||
delete it->second;
|
||||
|
||||
m_map_Switchbots.clear();
|
||||
}
|
||||
|
||||
void CSwitchbotManager::RegisterItem(DWORD player_id, DWORD item_id, WORD wCell)
|
||||
{
|
||||
if (!ValidPosition(wCell))
|
||||
return;
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
{
|
||||
pkSwitchbot = new CSwitchbot();
|
||||
pkSwitchbot->SetPlayerId(player_id);
|
||||
m_map_Switchbots.insert(std::make_pair(player_id, pkSwitchbot));
|
||||
}
|
||||
|
||||
if (pkSwitchbot->IsWarping())
|
||||
return;
|
||||
|
||||
pkSwitchbot->RegisterItem(wCell, item_id);
|
||||
SendSwitchbotUpdate(player_id);
|
||||
}
|
||||
|
||||
void CSwitchbotManager::UnregisterItem(DWORD player_id, WORD wCell)
|
||||
{
|
||||
if (!ValidPosition(wCell))
|
||||
return;
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return;
|
||||
|
||||
if (pkSwitchbot->IsWarping())
|
||||
return;
|
||||
|
||||
pkSwitchbot->UnregisterItem(wCell);
|
||||
|
||||
if (!pkSwitchbot->HasActiveSlots() && pkSwitchbot->IsSwitching())
|
||||
pkSwitchbot->Stop();
|
||||
else
|
||||
SendSwitchbotUpdate(player_id);
|
||||
}
|
||||
|
||||
void CSwitchbotManager::Start(DWORD player_id, BYTE slot, const std::vector<TSwitchbotAttributeAlternativeTable>& vec_alternatives)
|
||||
{
|
||||
if (!ValidPosition(slot))
|
||||
return;
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
{
|
||||
sys_err("No Switchbot found for player_id %u slot %d", player_id, slot);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pkSwitchbot->IsActive(slot))
|
||||
{
|
||||
sys_err("Switchbot slot %d already running for player_id %u", slot, player_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pkSwitchbot->GetTable().items[slot])
|
||||
return;
|
||||
|
||||
pkSwitchbot->SetActive(slot, true);
|
||||
pkSwitchbot->SetAttributes(slot, vec_alternatives);
|
||||
|
||||
if (pkSwitchbot->HasActiveSlots() && !pkSwitchbot->IsSwitching())
|
||||
pkSwitchbot->Start();
|
||||
else
|
||||
SendSwitchbotUpdate(player_id);
|
||||
}
|
||||
|
||||
void CSwitchbotManager::Stop(DWORD player_id, BYTE slot)
|
||||
{
|
||||
if (!ValidPosition(slot))
|
||||
return;
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
{
|
||||
sys_err("No Switchbot found for player_id %u slot %d", player_id, slot);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pkSwitchbot->IsActive(slot))
|
||||
{
|
||||
sys_err("Switchbot slot %d is not running for player_id %u", slot, player_id);
|
||||
return;
|
||||
}
|
||||
|
||||
pkSwitchbot->SetActive(slot, false);
|
||||
|
||||
if (!pkSwitchbot->HasActiveSlots() && pkSwitchbot->IsSwitching())
|
||||
pkSwitchbot->Stop();
|
||||
else
|
||||
SendSwitchbotUpdate(player_id);
|
||||
}
|
||||
|
||||
bool CSwitchbotManager::IsActive(DWORD player_id, BYTE slot)
|
||||
{
|
||||
if (!ValidPosition(slot))
|
||||
return false;
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return false;
|
||||
|
||||
return pkSwitchbot->IsActive(slot);
|
||||
}
|
||||
|
||||
bool CSwitchbotManager::IsWarping(DWORD player_id)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return false;
|
||||
|
||||
return pkSwitchbot->IsWarping();
|
||||
}
|
||||
|
||||
void CSwitchbotManager::SetIsWarping(DWORD player_id, bool warping)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return;
|
||||
|
||||
// PORT: the warp logout destroys the items; EnterGame starts the event again.
|
||||
if (warping)
|
||||
pkSwitchbot->Pause();
|
||||
|
||||
pkSwitchbot->SetIsWarping(warping);
|
||||
}
|
||||
|
||||
CSwitchbot* CSwitchbotManager::FindSwitchbot(DWORD player_id)
|
||||
{
|
||||
std::map<DWORD, CSwitchbot*>::iterator it = m_map_Switchbots.find(player_id);
|
||||
|
||||
if (it == m_map_Switchbots.end())
|
||||
return NULL;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void CSwitchbotManager::P2PSendSwitchbot(DWORD player_id, WORD wTargetPort)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return;
|
||||
|
||||
pkSwitchbot->Pause();
|
||||
m_map_Switchbots.erase(player_id);
|
||||
|
||||
TPacketGGSwitchbot pack;
|
||||
pack.wPort = wTargetPort;
|
||||
pack.table = pkSwitchbot->GetTable();
|
||||
P2P_MANAGER::Instance().Send(&pack, sizeof(pack));
|
||||
|
||||
delete pkSwitchbot;
|
||||
}
|
||||
|
||||
void CSwitchbotManager::P2PReceiveSwitchbot(const TSwitchbotTable& table)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(table.player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
{
|
||||
pkSwitchbot = new CSwitchbot();
|
||||
m_map_Switchbots.insert(std::make_pair(table.player_id, pkSwitchbot));
|
||||
}
|
||||
|
||||
pkSwitchbot->SetTable(table);
|
||||
// The items arrive with the login before EnterGame clears this; RegisterItem keeps the received table.
|
||||
pkSwitchbot->SetIsWarping(true);
|
||||
}
|
||||
|
||||
void CSwitchbotManager::SendItemAttributeInformations(LPCHARACTER ch)
|
||||
{
|
||||
if (!ch)
|
||||
return;
|
||||
|
||||
LPDESC desc = ch->GetDesc();
|
||||
|
||||
if (!desc)
|
||||
return;
|
||||
|
||||
TPacketGCSwitchbot pack;
|
||||
pack.header = HEADER_GC_SWITCHBOT;
|
||||
pack.subheader = SUBHEADER_GC_SWITCHBOT_SEND_ATTRIBUTE_INFORMATION;
|
||||
pack.size = sizeof(TPacketGCSwitchbot);
|
||||
pack.slot = 0;
|
||||
|
||||
TEMP_BUFFER buf;
|
||||
|
||||
for (BYTE bAttributeSet = 0; bAttributeSet < ATTRIBUTE_SET_MAX_NUM; ++bAttributeSet)
|
||||
{
|
||||
for (int iApplyNum = 0; iApplyNum < MAX_APPLY_NUM; ++iApplyNum)
|
||||
{
|
||||
const TItemAttrTable& r = g_map_itemAttr[iApplyNum];
|
||||
const BYTE max = r.bMaxLevelBySet[bAttributeSet];
|
||||
|
||||
if (max > 0)
|
||||
WriteAttribute(buf, bAttributeSet, iApplyNum, r.lValues[MIN(max, ITEM_ATTRIBUTE_MAX_LEVEL) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int iApplyNum = 0; iApplyNum < MAX_APPLY_NUM; ++iApplyNum)
|
||||
if (const int iMax = GetNewRingAttrMaxValue(BYTE(iApplyNum)))
|
||||
WriteAttribute(buf, SWITCHBOT_ATTRIBUTE_SET_NEW_RINGS, iApplyNum, iMax);
|
||||
|
||||
for (int iApplyNum = 0; iApplyNum < MAX_APPLY_NUM; ++iApplyNum)
|
||||
if (const int iMax = GetPendantAttrMaxValue(BYTE(iApplyNum)))
|
||||
WriteAttribute(buf, SWITCHBOT_ATTRIBUTE_SET_PENDANT, iApplyNum, iMax);
|
||||
|
||||
if (buf.size())
|
||||
{
|
||||
pack.size += buf.size();
|
||||
desc->BufferedPacket(&pack, sizeof(pack));
|
||||
desc->Packet(buf.read_peek(), buf.size());
|
||||
}
|
||||
else
|
||||
desc->Packet(&pack, sizeof(pack));
|
||||
}
|
||||
|
||||
void CSwitchbotManager::SendSwitchbotUpdate(DWORD player_id)
|
||||
{
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
|
||||
|
||||
if (!pkSwitchbot)
|
||||
return;
|
||||
|
||||
LPCHARACTER ch = CHARACTER_MANAGER::Instance().FindByPID(player_id);
|
||||
|
||||
if (!ch)
|
||||
return;
|
||||
|
||||
LPDESC d = ch->GetDesc();
|
||||
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
const TSwitchbotTable& table = pkSwitchbot->GetTable();
|
||||
|
||||
TPacketGCSwitchbot pack;
|
||||
pack.header = HEADER_GC_SWITCHBOT;
|
||||
pack.subheader = SUBHEADER_GC_SWITCHBOT_UPDATE;
|
||||
pack.size = sizeof(TPacketGCSwitchbot) + sizeof(TSwitchbotTable);
|
||||
pack.slot = 0;
|
||||
d->BufferedPacket(&pack, sizeof(pack));
|
||||
d->Packet(&table, sizeof(table));
|
||||
}
|
||||
|
||||
bool SwitchbotHelper::IsClientSupported(LPCHARACTER ch)
|
||||
{
|
||||
LPDESC d = ch ? ch->GetDesc() : NULL;
|
||||
const char* c_pszMark = d ? strstr(d->GetClientVersion(), "mt") : NULL;
|
||||
return c_pszMark && atoi(c_pszMark + 2) >= PORT_SWITCHBOT_CLIENT_VERSION;
|
||||
}
|
||||
|
||||
void CSwitchbotManager::EnterGame(LPCHARACTER ch)
|
||||
{
|
||||
SetIsWarping(ch->GetPlayerID(), false);
|
||||
|
||||
// PORT: version gate. An older client has no GC_SWITCHBOT handler; it never fills the window either.
|
||||
if (!SwitchbotHelper::IsClientSupported(ch))
|
||||
return;
|
||||
|
||||
SendItemAttributeInformations(ch);
|
||||
|
||||
// A table kept over a warp (or received from another core) only keeps slots whose item is still there.
|
||||
if (CSwitchbot* pkSwitchbot = FindSwitchbot(ch->GetPlayerID()))
|
||||
{
|
||||
for (BYTE bSlot = 0; bSlot < SWITCHBOT_SLOT_COUNT_REAL; ++bSlot)
|
||||
{
|
||||
LPITEM pkItem = ch->GetItem(TItemPos(SWITCHBOT, bSlot));
|
||||
|
||||
if (!pkItem)
|
||||
pkSwitchbot->UnregisterItem(bSlot);
|
||||
else if (pkSwitchbot->GetTable().items[bSlot] != pkItem->GetID())
|
||||
{
|
||||
pkSwitchbot->UnregisterItem(bSlot);
|
||||
pkSwitchbot->RegisterItem(bSlot, pkItem->GetID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendSwitchbotUpdate(ch->GetPlayerID());
|
||||
|
||||
CSwitchbot* pkSwitchbot = FindSwitchbot(ch->GetPlayerID());
|
||||
|
||||
if (pkSwitchbot && pkSwitchbot->HasActiveSlots() && !pkSwitchbot->IsSwitching())
|
||||
pkSwitchbot->Start();
|
||||
}
|
||||
|
||||
void PortSwitchbotBoot()
|
||||
{
|
||||
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("SHOW COLUMNS FROM item LIKE 'window'"));
|
||||
|
||||
if (msg->uiSQLErrno || !msg->Get()->uiNumRows)
|
||||
{
|
||||
sys_err("PortSwitchbotBoot: cannot read item.window (errno %u)", msg->uiSQLErrno);
|
||||
return;
|
||||
}
|
||||
|
||||
MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult);
|
||||
|
||||
if (row[1] && strstr(row[1], "'SWITCHBOT'"))
|
||||
return;
|
||||
|
||||
std::unique_ptr<SQLMsg> alter(DBManager::instance().DirectQuery(
|
||||
"ALTER TABLE item MODIFY window enum('INVENTORY','EQUIPMENT','SAFEBOX','MALL','DRAGON_SOUL_INVENTORY',"
|
||||
"'BELT_INVENTORY','SWITCHBOT') NOT NULL DEFAULT 'INVENTORY'"));
|
||||
|
||||
if (alter->uiSQLErrno)
|
||||
sys_err("PortSwitchbotBoot: cannot add SWITCHBOT to item.window (errno %u)", alter->uiSQLErrno);
|
||||
else
|
||||
sys_log(0, "PortSwitchbotBoot: added SWITCHBOT to item.window");
|
||||
}
|
||||
@@ -1,246 +1,91 @@
|
||||
#ifndef METIN2_PORT_SWITCHBOT_H
|
||||
#define METIN2_PORT_SWITCHBOT_H
|
||||
// PORT: AVA2-style automatic attribute change. Every roll goes through the original
|
||||
// CHARACTER::UseItem change-attribute path, so its checks, probabilities, log and consumption apply unchanged.
|
||||
// One bound item per character; not persisted; stops on logout, warp, busy windows or any rejected roll.
|
||||
// The lock verb toggles the attribute lock (port_attr_lock.h) that ChangeAttribute applies to every reroll.
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "port_attr_lock.h"
|
||||
// PORT: AVA2 ENABLE_SWITCHBOT (new_switchbot.{h,cpp}): items placed in the SWITCHBOT window (cells 0..4) are
|
||||
// rerolled with switchers from the inventory until one configured alternative matches. Same classes, API,
|
||||
// packets and speed as AVA2; the deviations are listed at the top of port_switchbot.cpp.
|
||||
#include "../../common/tables.h"
|
||||
|
||||
static const unsigned kPortSwitchAlternatives=2, kPortSwitchTargets=5, kPortSwitchLimit=1000;
|
||||
static const unsigned kPortSwitchAddonSkillMax=30, kPortSwitchAddonNormalMax=65; // CItemAddonManager::ApplyAddonTo bounds.
|
||||
// PORT: clients from this protocol date on send "mt<date>" as their CG_CLIENT_VERSION timestamp
|
||||
// (metin2-client PythonNetworkStreamPhaseGame.cpp SendClientVersionPacket).
|
||||
enum { PORT_SWITCHBOT_CLIENT_VERSION = 20261016 };
|
||||
|
||||
struct PortSwitchTarget {unsigned apply;int value;};
|
||||
struct PortSwitchbot {
|
||||
DWORD pid=0,item=0,scroll=0;unsigned limit=0,rolls=0;VID vid;
|
||||
std::vector<PortSwitchTarget> alternatives[kPortSwitchAlternatives];
|
||||
LPEVENT event;
|
||||
class SwitchbotHelper
|
||||
{
|
||||
public:
|
||||
static bool IsValidItem(LPITEM pkItem);
|
||||
static bool IsClientSupported(LPCHARACTER ch); // PORT: CG_CLIENT_VERSION timestamp gate
|
||||
};
|
||||
static std::map<DWORD,PortSwitchbot> g_portSwitchbots;
|
||||
|
||||
static bool PortSwitchNumber(const std::string& text,unsigned& value) {
|
||||
if(text.empty() || text.size()>10)return false;
|
||||
unsigned long long result=0;
|
||||
for(char c:text){if(c<'0'||c>'9')return false;result=result*10+(c-'0');}
|
||||
if(result>0xffffffffull)return false;
|
||||
value=unsigned(result);return true;
|
||||
}
|
||||
class CSwitchbot
|
||||
{
|
||||
public:
|
||||
CSwitchbot();
|
||||
~CSwitchbot();
|
||||
|
||||
// Attribute types a reroll of this item can produce, with the highest value each can reach.
|
||||
static std::vector<std::pair<unsigned,int> > PortSwitchAllowed(LPITEM item) {
|
||||
std::vector<std::pair<unsigned,int> > allowed;
|
||||
const int set=item->GetAttributeSetIndex();
|
||||
if(set<0)return allowed;
|
||||
const TItemTable* proto=item->GetProto();
|
||||
for(unsigned apply=0;apply<MAX_APPLY_NUM;++apply) {
|
||||
auto it=g_map_itemAttr.find(apply);
|
||||
if(it==g_map_itemAttr.end())continue;
|
||||
const unsigned level=it->second.bMaxLevelBySet[set];
|
||||
if(!level)continue;
|
||||
bool base=false;
|
||||
for(int i=0;i<ITEM_APPLY_MAX_NUM;++i)base|=proto && proto->aApplies[i].bType==apply;
|
||||
const long value=it->second.lValues[(level>5?5:level)-1];
|
||||
if(!base && value>0)allowed.push_back(std::make_pair(apply,int(value)));
|
||||
}
|
||||
if(proto && proto->sAddonType) {
|
||||
allowed.push_back(std::make_pair(unsigned(APPLY_SKILL_DAMAGE_BONUS),int(kPortSwitchAddonSkillMax)));
|
||||
allowed.push_back(std::make_pair(unsigned(APPLY_NORMAL_HIT_DAMAGE_BONUS),int(kPortSwitchAddonNormalMax)));
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
void SetTable(const TSwitchbotTable& table) { m_table = table; }
|
||||
const TSwitchbotTable& GetTable() const { return m_table; }
|
||||
|
||||
// AVA2 CheckItem semantics over the five normal slots: any one configured alternative fully satisfied.
|
||||
static bool PortSwitchMatches(LPITEM item,const PortSwitchbot& bot) {
|
||||
for(const auto& alternative:bot.alternatives) {
|
||||
if(alternative.empty())continue;
|
||||
bool all=true;
|
||||
for(const auto& target:alternative) {
|
||||
bool found=false;
|
||||
for(int i=0;i<ITEM_MANAGER::MAX_NORM_ATTR_NUM && !found;++i) {
|
||||
const TPlayerItemAttribute& attr=item->GetAttribute(i);
|
||||
found=attr.bType==target.apply && attr.sValue>=target.value;
|
||||
}
|
||||
all&=found;
|
||||
}
|
||||
if(all)return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void SetPlayerId(DWORD player_id) { m_table.player_id = player_id; }
|
||||
DWORD GetPlayerId() const { return m_table.player_id; }
|
||||
|
||||
static bool PortSwitchBusy(LPCHARACTER ch) {
|
||||
return ch->IsDead() || ch->IsWarping() || !ch->CanHandleItem() || ch->GetExchange() || ch->GetMyShop() ||
|
||||
ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen();
|
||||
}
|
||||
void RegisterItem(WORD wCell, DWORD item_id);
|
||||
void UnregisterItem(WORD wCell);
|
||||
void SetAttributes(BYTE slot, const std::vector<TSwitchbotAttributeAlternativeTable>& vec_alternatives);
|
||||
|
||||
static LPITEM PortSwitchItem(LPCHARACTER ch,const PortSwitchbot& bot) {
|
||||
LPITEM item=ITEM_MANAGER::instance().Find(bot.item);
|
||||
if(!item || item->GetOwner()!=ch || item->GetWindow()!=INVENTORY || item->GetCell()>=INVENTORY_MAX_NUM || item->IsEquipped())return NULL;
|
||||
return item;
|
||||
}
|
||||
void SetActive(BYTE slot, bool active);
|
||||
bool IsActive(BYTE slot);
|
||||
bool HasActiveSlots();
|
||||
bool IsSwitching();
|
||||
bool IsWarping() { return m_isWarping; }
|
||||
void SetIsWarping(bool warping) { m_isWarping = warping; }
|
||||
|
||||
static bool PortSwitchScroll(LPITEM scroll) {
|
||||
return scroll && scroll->GetType()==ITEM_USE && scroll->GetSubType()==USE_CHANGE_ATTRIBUTE;
|
||||
}
|
||||
void Start();
|
||||
void Stop();
|
||||
void Pause();
|
||||
|
||||
static void PortSwitchState(LPCHARACTER ch,const PortSwitchbot* bot,bool active,const char* reason) {
|
||||
LPITEM item=bot?PortSwitchItem(ch,*bot):NULL;
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 state %u %u %u %u %u %u %d %s",unsigned(active),item?unsigned(item->GetCell()):0u,
|
||||
item?unsigned(item->GetVnum()):0u,bot?bot->rolls:0u,bot?bot->limit:0u,bot?unsigned(bot->scroll):0u,
|
||||
bot?ch->CountSpecifyItem(bot->scroll):0,reason);
|
||||
}
|
||||
void SwitchItems();
|
||||
bool CheckItem(LPITEM pkItem, BYTE slot);
|
||||
|
||||
// One roll. Returns NULL to keep running, otherwise the stop reason.
|
||||
static const char* PortSwitchStep(LPCHARACTER ch,PortSwitchbot& bot) {
|
||||
if(PortSwitchBusy(ch))return "busy";
|
||||
LPITEM item=PortSwitchItem(ch,bot);
|
||||
if(!item)return "item_gone";
|
||||
if(PortSwitchMatches(item,bot))return "matched";
|
||||
if(bot.rolls>=bot.limit)return "limit";
|
||||
LPITEM scroll=ch->FindSpecifyItem(bot.scroll);
|
||||
if(!PortSwitchScroll(scroll))return "no_scroll";
|
||||
const int before=ch->CountSpecifyItem(bot.scroll);
|
||||
ch->m_portQuietInfo=true;ch->m_portLastInfo.clear();
|
||||
ch->UseItem(TItemPos(INVENTORY,scroll->GetCell()),TItemPos(INVENTORY,item->GetCell()));
|
||||
ch->m_portQuietInfo=false;
|
||||
// Success is judged by the original path consuming exactly one scroll, not by its return value.
|
||||
if(ch->CountSpecifyItem(bot.scroll)!=before-1) {
|
||||
if(!ch->m_portLastInfo.empty())ch->ChatPacket(CHAT_TYPE_INFO,"%s",ch->m_portLastInfo.c_str());
|
||||
return "rejected";
|
||||
}
|
||||
++bot.rolls;
|
||||
item=PortSwitchItem(ch,bot);
|
||||
if(!item)return "item_gone";
|
||||
return PortSwitchMatches(item,bot)?"matched":bot.rolls>=bot.limit?"limit":NULL;
|
||||
}
|
||||
void SendItemUpdate(LPCHARACTER ch, BYTE slot, LPITEM item);
|
||||
|
||||
EVENTINFO(PortSwitchbotInfo){DWORD pid;PortSwitchbotInfo():pid(0){}};
|
||||
protected:
|
||||
void FinishSlot(LPCHARACTER ch, BYTE slot, LPITEM item, bool finished);
|
||||
|
||||
EVENTFUNC(port_switchbot_event) {
|
||||
PortSwitchbotInfo* info=dynamic_cast<PortSwitchbotInfo*>(event->info);
|
||||
if(!info)return 0;
|
||||
auto it=g_portSwitchbots.find(info->pid);
|
||||
if(it==g_portSwitchbots.end())return 0;
|
||||
PortSwitchbot& bot=it->second;
|
||||
LPCHARACTER ch=CHARACTER_MANAGER::instance().Find(bot.vid);
|
||||
// A new instance after logout or warp carries a new VID; the bot does not follow it.
|
||||
if(!ch || ch->GetPlayerID()!=bot.pid || !ch->GetDesc()) {bot.event=NULL;g_portSwitchbots.erase(it);return 0;}
|
||||
const char* reason=PortSwitchStep(ch,bot);
|
||||
if(!reason) {PortSwitchState(ch,&bot,true,"running");return PASSES_PER_SEC(1)/4;}
|
||||
PortSwitchState(ch,&bot,false,reason);
|
||||
bot.event=NULL;g_portSwitchbots.erase(it);
|
||||
return 0;
|
||||
}
|
||||
TSwitchbotTable m_table;
|
||||
LPEVENT m_pkSwitchEvent;
|
||||
bool m_isWarping;
|
||||
};
|
||||
|
||||
static void PortSwitchStop(LPCHARACTER ch,const char* reason) {
|
||||
auto it=g_portSwitchbots.find(ch->GetPlayerID());
|
||||
if(it==g_portSwitchbots.end()) {PortSwitchState(ch,NULL,false,"idle");return;}
|
||||
if(it->second.event)event_cancel(&it->second.event);
|
||||
PortSwitchState(ch,&it->second,false,reason);
|
||||
g_portSwitchbots.erase(it);
|
||||
}
|
||||
class CSwitchbotManager : public singleton<CSwitchbotManager>
|
||||
{
|
||||
public:
|
||||
CSwitchbotManager() { Initialize(); }
|
||||
virtual ~CSwitchbotManager();
|
||||
|
||||
static void PortSwitchLockLine(LPCHARACTER ch,LPITEM item) {
|
||||
const bool addon=item->GetProto() && item->GetProto()->sAddonType;
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 lock %u %u %u",unsigned(item->GetCell()),unsigned(item->GetVnum()),
|
||||
PortAttrLockEffective(PortAttrLockGet(item),PortAttrFilled(item),addon));
|
||||
}
|
||||
void Initialize() { m_map_Switchbots.clear(); }
|
||||
void RegisterItem(DWORD player_id, DWORD item_id, WORD wCell);
|
||||
void UnregisterItem(DWORD player_id, WORD wCell);
|
||||
void Start(DWORD player_id, BYTE slot, const std::vector<TSwitchbotAttributeAlternativeTable>& vec_alternatives);
|
||||
void Stop(DWORD player_id, BYTE slot);
|
||||
|
||||
// lock CELL SLOT: toggle the lock on one normal slot; not while the bot rolls this item.
|
||||
static const char* PortSwitchLock(LPCHARACTER ch,unsigned cell,unsigned slot) {
|
||||
if(PortSwitchBusy(ch))return "busy";
|
||||
LPITEM item=cell<INVENTORY_MAX_NUM?ch->GetItem(TItemPos(INVENTORY,cell)):NULL;
|
||||
if(!item)return "item";
|
||||
if(item->IsEquipped() || item->IsExchanging())return "equipped";
|
||||
if(item->GetType()==ITEM_COSTUME || item->GetAttributeSetIndex()<0)return "no_attr";
|
||||
auto it=g_portSwitchbots.find(ch->GetPlayerID());
|
||||
if(it!=g_portSwitchbots.end() && it->second.item==item->GetID())return "running";
|
||||
const bool addon=item->GetProto() && item->GetProto()->sAddonType;
|
||||
unsigned mask=0;
|
||||
if(const char* error=PortAttrLockToggle(PortAttrLockGet(item),slot,PortAttrFilled(item),addon,mask))return error;
|
||||
if(!PortAttrLockSet(ch,item,mask))return "db";
|
||||
PortSwitchLockLine(ch,item);
|
||||
return NULL;
|
||||
}
|
||||
bool IsActive(DWORD player_id, BYTE slot);
|
||||
bool IsWarping(DWORD player_id);
|
||||
void SetIsWarping(DWORD player_id, bool warping);
|
||||
|
||||
static void PortSwitchAttrs(LPCHARACTER ch,unsigned cell) {
|
||||
LPITEM item=cell<INVENTORY_MAX_NUM?ch->GetItem(TItemPos(INVENTORY,cell)):NULL;
|
||||
if(!item){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error attrs item");return;}
|
||||
if(item->GetType()==ITEM_COSTUME || item->GetAttributeSetIndex()<0){ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error attrs no_attr");return;}
|
||||
auto allowed=PortSwitchAllowed(item);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 attrs %u %u %u",cell,unsigned(item->GetVnum()),unsigned(allowed.size()));
|
||||
for(unsigned i=0;i<allowed.size();++i)
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 attr %u %u %d",i,allowed[i].first,allowed[i].second);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 attrs_end %u %u",cell,unsigned(allowed.size()));
|
||||
PortSwitchLockLine(ch,item);
|
||||
}
|
||||
CSwitchbot* FindSwitchbot(DWORD player_id);
|
||||
|
||||
// start CELL SCROLL LIMIT N1 (APPLY VALUE)*N1 [N2 (APPLY VALUE)*N2]
|
||||
static const char* PortSwitchStart(LPCHARACTER ch,const std::vector<std::string>& args) {
|
||||
unsigned cell=0,scrollVnum=0,limit=0;
|
||||
if(args.size()<6 || !PortSwitchNumber(args[2],cell) || !PortSwitchNumber(args[3],scrollVnum) ||
|
||||
!PortSwitchNumber(args[4],limit) || !limit || limit>kPortSwitchLimit)return "invalid";
|
||||
if(g_portSwitchbots.count(ch->GetPlayerID()))return "running";
|
||||
if(PortSwitchBusy(ch))return "busy";
|
||||
LPITEM item=cell<INVENTORY_MAX_NUM?ch->GetItem(TItemPos(INVENTORY,cell)):NULL;
|
||||
if(!item)return "item";
|
||||
if(item->IsEquipped() || item->IsExchanging())return "equipped";
|
||||
if(item->GetType()==ITEM_COSTUME || item->GetAttributeSetIndex()<0 || !item->GetAttributeCount())return "no_attr";
|
||||
if(!PortSwitchScroll(ch->FindSpecifyItem(scrollVnum)))return "scroll";
|
||||
PortSwitchbot bot;bot.pid=ch->GetPlayerID();bot.vid=ch->GetVID();bot.item=item->GetID();bot.scroll=scrollVnum;bot.limit=limit;
|
||||
const auto allowed=PortSwitchAllowed(item);
|
||||
size_t at=5;
|
||||
for(unsigned alt=0;alt<kPortSwitchAlternatives && at<args.size();++alt) {
|
||||
unsigned count=0;
|
||||
if(!PortSwitchNumber(args[at++],count) || !count || count>kPortSwitchTargets || at+count*2>args.size())return "invalid";
|
||||
for(unsigned i=0;i<count;++i,at+=2) {
|
||||
unsigned apply=0,value=0;
|
||||
if(!PortSwitchNumber(args[at],apply) || !PortSwitchNumber(args[at+1],value) || !value)return "invalid";
|
||||
int max=0;
|
||||
for(const auto& a:allowed)if(a.first==apply)max=a.second;
|
||||
if(!max || value>unsigned(max))return "target";
|
||||
for(const auto& t:bot.alternatives[alt])if(t.apply==apply)return "target";
|
||||
bot.alternatives[alt].push_back(PortSwitchTarget{apply,int(value)});
|
||||
}
|
||||
}
|
||||
if(at!=args.size())return "invalid";
|
||||
if(PortSwitchMatches(item,bot)) {PortSwitchState(ch,&bot,false,"matched");return NULL;}
|
||||
PortSwitchbot& stored=g_portSwitchbots[bot.pid];stored=bot;
|
||||
PortSwitchbotInfo* info=AllocEventInfo<PortSwitchbotInfo>();info->pid=bot.pid;
|
||||
stored.event=event_create(port_switchbot_event,info,PASSES_PER_SEC(1)/4);
|
||||
PortSwitchState(ch,&stored,true,"running");
|
||||
return NULL;
|
||||
}
|
||||
void P2PSendSwitchbot(DWORD player_id, WORD wTargetPort);
|
||||
void P2PReceiveSwitchbot(const TSwitchbotTable& table);
|
||||
|
||||
void SendItemAttributeInformations(LPCHARACTER ch);
|
||||
void SendSwitchbotUpdate(DWORD player_id);
|
||||
|
||||
void EnterGame(LPCHARACTER ch);
|
||||
|
||||
protected:
|
||||
std::map<DWORD, CSwitchbot*> m_map_Switchbots;
|
||||
};
|
||||
|
||||
void PortSwitchbotBoot(); // adds 'SWITCHBOT' to player.item.window when it is missing
|
||||
|
||||
ACMD(do_port_switchbot) {
|
||||
if(!ch || !ch->IsPC() || !ch->GetDesc())return;
|
||||
std::istringstream input(argument);std::vector<std::string> args;std::string token;
|
||||
while(input>>token){if(token.size()>10 || args.size()>=30)return;args.push_back(token);}
|
||||
if(args.size()<2 || args[0]!="1")return;
|
||||
const std::string& verb=args[1];
|
||||
if(get_dword_time()-ch->m_portSwitchbotLastCommand<250 && ch->m_portSwitchbotLastCommand) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error %s rate",verb.c_str());return;
|
||||
}
|
||||
ch->m_portSwitchbotLastCommand=get_dword_time();
|
||||
unsigned cell=0,slot=0;
|
||||
if(verb=="attrs" && args.size()==3 && PortSwitchNumber(args[2],cell)) PortSwitchAttrs(ch,cell);
|
||||
else if(verb=="lock" && args.size()==4 && PortSwitchNumber(args[2],cell) && PortSwitchNumber(args[3],slot)) {
|
||||
const char* error=PortSwitchLock(ch,cell,slot);
|
||||
if(error)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error lock %s",error);
|
||||
}
|
||||
else if(verb=="stop" && args.size()==2) PortSwitchStop(ch,"stopped");
|
||||
else if(verb=="status" && args.size()==2) {
|
||||
auto it=g_portSwitchbots.find(ch->GetPlayerID());
|
||||
if(it==g_portSwitchbots.end())PortSwitchState(ch,NULL,false,"idle");
|
||||
else PortSwitchState(ch,&it->second,true,"running");
|
||||
}
|
||||
else if(verb=="start") {
|
||||
const char* error=PortSwitchStart(ch,args);
|
||||
if(error)ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error start %s",error);
|
||||
}
|
||||
else ch->ChatPacket(CHAT_TYPE_COMMAND,"MTSB1 error %s invalid",verb.size()<=10?verb.c_str():"unknown");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,13 @@ std::vector<PortWikiRow> ITEM_MANAGER::PortWikiDrops(DWORD race) {
|
||||
if (mob->m_table.bRank<MOB_RANK_MAX_NUM)
|
||||
for (const auto& row:g_vec_pkCommonDropItem[mob->m_table.bRank])
|
||||
add(row.m_dwVnum,1,WIKI_COMMON,row.m_iLevelStart,row.m_iLevelEnd,row.m_iPercent,0);
|
||||
// common_drop_new.txt: the player range narrowed to the killers within 20 levels of this mob; map lists are not shown
|
||||
for (const CCommonDropNew* group:m_vec_pkCommonNewItemGroup) {
|
||||
int low=std::max(group->minLevel,int(mob->m_table.bLevel)-20),high=std::min(group->maxLevel,int(mob->m_table.bLevel)+20);
|
||||
if (low>high) continue;
|
||||
for (size_t i=0;i<group->m_vecItems.size() && i<group->m_vecProbs.size();++i)
|
||||
add(group->m_vecItems[i].first,group->m_vecItems[i].second,WIKI_COMMON,unsigned(std::max(low,0)),unsigned(high),group->m_vecProbs[i],0);
|
||||
}
|
||||
auto drop=m_map_pkDropItemGroup.find(race);
|
||||
if (drop!=m_map_pkDropItemGroup.end() && drop->second)
|
||||
for (const auto& row:drop->second->GetVector()) add(row.dwVnum,row.iCount,WIKI_DROP,0,0,row.dwPct,0);
|
||||
|
||||
@@ -349,6 +349,7 @@ bool CPVPManager::CanAttack(LPCHARACTER pkChr, LPCHARACTER pkVictim)
|
||||
switch (pkVictim->GetCharType())
|
||||
{
|
||||
case CHAR_TYPE_NPC:
|
||||
return pkVictim->IsHydraNPC(); // PORT: AVA2 hydra mast, the ship's monsters attack it
|
||||
case CHAR_TYPE_WARP:
|
||||
case CHAR_TYPE_GOTO:
|
||||
return false;
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace quest
|
||||
QUEST_ITEM_PICK_EVENT,
|
||||
QUEST_SIG_USE_EVENT,
|
||||
QUEST_ITEM_INFORMER_EVENT,
|
||||
QUEST_ATTACK_EVENT, // PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON (when <vnum>.attack)
|
||||
QUEST_EVENT_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -490,6 +490,7 @@ namespace quest
|
||||
RegisterDragonLairFunctionTable();
|
||||
RegisterSpeedServerFunctionTable();
|
||||
RegisterDragonSoulFunctionTable();
|
||||
RegisterAva2DungeonFunctionTable(); // PORT: after the d and npc tables
|
||||
|
||||
{
|
||||
luaL_reg member_functions[] =
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace quest
|
||||
extern void RegisterDragonLairFunctionTable();
|
||||
extern void RegisterSpeedServerFunctionTable();
|
||||
extern void RegisterDragonSoulFunctionTable();
|
||||
extern void RegisterAva2DungeonFunctionTable(); // PORT: AVA2 port_ava2_dungeon.cpp, extends d and npc
|
||||
|
||||
extern void combine_lua_string(lua_State* L, std::ostringstream &s);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "ava2_track.h"
|
||||
#include "constants.h"
|
||||
#include "questmanager.h"
|
||||
#include "questlua.h"
|
||||
@@ -1425,10 +1426,31 @@ namespace quest
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct FAva2TrackUpdate {
|
||||
WORD boss;
|
||||
void operator()(LPENTITY ent) {
|
||||
if (ent->IsType(ENTITY_CHARACTER)) {
|
||||
LPCHARACTER ch=static_cast<LPCHARACTER>(ent);
|
||||
if (ch->IsPC() && ch->GetProtectTime("track_dungeon")) Ava2TrackDungeonInfo(ch,boss);
|
||||
}
|
||||
}
|
||||
};
|
||||
int dungeon_track_update(lua_State* L) {
|
||||
CQuestManager& q=CQuestManager::instance();
|
||||
LPDUNGEON dungeon=q.GetCurrentDungeon();
|
||||
if (!dungeon || !lua_isnumber(L,1)) return 0;
|
||||
// AVA2 quests call the one-argument form; original C++ required two by mistake.
|
||||
const long map=lua_isnumber(L,2)?long(lua_tonumber(L,1)):dungeon->GetMapIndex();
|
||||
const WORD boss=WORD(lua_tonumber(L,lua_isnumber(L,2)?2:1));
|
||||
LPSECTREE_MAP sectree=SECTREE_MANAGER::instance().GetMap(map);
|
||||
if (sectree) { FAva2TrackUpdate f={boss};sectree->for_each(f); }
|
||||
return 0;
|
||||
}
|
||||
void RegisterDungeonFunctionTable()
|
||||
{
|
||||
luaL_reg dungeon_functions[] =
|
||||
{
|
||||
{ "track_update",dungeon_track_update },
|
||||
{ "join", dungeon_join },
|
||||
{ "exit", dungeon_exit },
|
||||
{ "exit_all", dungeon_exit_all },
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "item_manager.h"
|
||||
#include "over9refine.h"
|
||||
#include "log.h"
|
||||
#include "port_attr_lock.h"
|
||||
|
||||
#undef sys_err
|
||||
#ifndef __WIN32__
|
||||
@@ -467,6 +468,15 @@ namespace quest
|
||||
return 1;
|
||||
}
|
||||
|
||||
int item_select_attr_lock(lua_State* L) {
|
||||
// The quest can yield while the original item moves or is destroyed. Resolve its ID again.
|
||||
const double index=lua_tonumber(L,1),id=lua_tonumber(L,2);
|
||||
if (!lua_isnumber(L,1) || !lua_isnumber(L,2) || !(index>=1 && index<=5) || index!=int(index) ||
|
||||
!(id>0 && id<=4294967295.0) || id!=DWORD(id)) {lua_pushboolean(L,0);return 1;}
|
||||
LPITEM material=ITEM_MANAGER::instance().Find(DWORD(id));
|
||||
lua_pushboolean(L,PortAttrLockSelect(CQuestManager::instance().GetCurrentCharacterPtr(),material,unsigned(index)));return 1;
|
||||
}
|
||||
|
||||
void RegisterITEMFunctionTable()
|
||||
{
|
||||
|
||||
@@ -479,6 +489,7 @@ namespace quest
|
||||
{ "remove", item_remove },
|
||||
{ "get_socket", item_get_socket },
|
||||
{ "set_socket", item_set_socket },
|
||||
{ "select_attr_lock",item_select_attr_lock },
|
||||
{ "set_attribute", item_set_attribute },
|
||||
{ "get_vnum", item_get_vnum },
|
||||
{ "has_flag", item_has_flag },
|
||||
|
||||
@@ -1158,6 +1158,21 @@ namespace quest
|
||||
return 0;
|
||||
}
|
||||
|
||||
// AVA2 sash: pc.open_sash(true) = combine window, pc.open_sash(false) = absorb window
|
||||
int pc_open_sash(lua_State* L)
|
||||
{
|
||||
if (!lua_isboolean(L, 1))
|
||||
{
|
||||
sys_err("pc.open_sash: arg1 must be boolean");
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
|
||||
if (ch)
|
||||
ch->OpenSash(lua_toboolean(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pc_get_empire(lua_State* L)
|
||||
{
|
||||
lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetEmpire());
|
||||
@@ -2885,6 +2900,7 @@ teleport_area:
|
||||
{ "in_dungeon", pc_in_dungeon },
|
||||
{ "getempire", pc_get_empire },
|
||||
{ "get_empire", pc_get_empire },
|
||||
{ "open_sash", pc_open_sash },
|
||||
{ "get_skill_group", pc_get_skillgroup },
|
||||
{ "set_skill_group", pc_set_skillgroup },
|
||||
{ "warp", pc_warp },
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace quest
|
||||
m_mapEventName.insert(TEventNameMap::value_type("pick", QUEST_ITEM_PICK_EVENT)); // 떨어져있는 아이템을 습득함.
|
||||
m_mapEventName.insert(TEventNameMap::value_type("sig_use", QUEST_SIG_USE_EVENT)); // Special item group에 속한 아이템을 사용함.
|
||||
m_mapEventName.insert(TEventNameMap::value_type("item_informer", QUEST_ITEM_INFORMER_EVENT)); // 독일선물기능테스트
|
||||
m_mapEventName.insert(TEventNameMap::value_type("attack", QUEST_ATTACK_EVENT)); // PORT: AVA2 meley lair
|
||||
|
||||
m_bNoSend = false;
|
||||
|
||||
@@ -1078,6 +1079,27 @@ namespace quest
|
||||
return GetCurrentCharacterPtr() ? GetCurrentCharacterPtr()->GetQuestNPC() : NULL;
|
||||
}
|
||||
|
||||
// PORT: AVA2 ENABLE_MELEY_LAIR_DUNGEON. The monster/stone the current pc just attacked (when <vnum>.attack).
|
||||
LPCHARACTER CQuestManager::GetCurrentNPCAttackCharacterPtr()
|
||||
{
|
||||
return GetCurrentCharacterPtr() ? GetCurrentCharacterPtr()->GetQuestNPCAttack() : NULL;
|
||||
}
|
||||
|
||||
void CQuestManager::Attack(unsigned int pc, unsigned int npc)
|
||||
{
|
||||
PC * pPC;
|
||||
|
||||
if ((pPC = GetPC(pc)))
|
||||
{
|
||||
if (!CheckQuestLoaded(pPC))
|
||||
return;
|
||||
|
||||
m_mapNPC[npc].OnAttack(*pPC);
|
||||
}
|
||||
else
|
||||
sys_err("QUEST: no such pc id : %d", pc);
|
||||
}
|
||||
|
||||
const string & CQuestManager::GetCurrentQuestName()
|
||||
{
|
||||
return GetCurrentPC()->GetCurrentQuestName();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user