Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e313d9ea85 | ||
|
|
f09ffd8a35 | ||
|
|
6199b2cbff | ||
|
|
fb066e7046 | ||
|
|
c30258ef5e | ||
|
|
14c4491469 | ||
|
|
5ad07886ea | ||
|
|
89261fdf8a | ||
|
|
38b62cfdbd | ||
|
|
cd395c73b7 | ||
|
|
7f4e8b3f76 | ||
|
|
1bdaae8807 | ||
|
|
69e335ba9c | ||
|
|
3590a06946 | ||
|
|
06b96c62d1 | ||
|
|
bc32475742 | ||
|
|
4b4f32ed58 | ||
|
|
bcd318791e |
@@ -68,4 +68,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);
|
- a new client session showed `lock 19 11209 10` (reloaded from the table);
|
||||||
- unlocking → 8 → 0, and the row was deleted;
|
- unlocking → 8 → 0, and the row was deleted;
|
||||||
- `log` has four `ATTR_LOCK` rows (hints 2, 10, 8, 0).
|
- `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,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,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 does not accept enchants as scrolls, on either the server (`PortSwitchScroll`) or the client.
|
||||||
|
- 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, the switchbot and the attribute lock refuse them.
|
||||||
|
- 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 and 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`) added for the switchbot. 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.
|
||||||
@@ -39,7 +39,7 @@ Rules:
|
|||||||
|
|
||||||
| RULE | Meaning of MIN/MAX and weights |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 3 | level group; MIN = player minimum level; original denominator 1,000,000 |
|
||||||
|
|||||||
@@ -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_SECONDARY_COIN, //32 ?? 명도전??
|
||||||
ITEM_RING, //33 반지
|
ITEM_RING, //33 반지
|
||||||
ITEM_BELT, //34 벨트
|
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
|
enum EMetinSubTypes
|
||||||
@@ -106,6 +108,7 @@ enum EArmorSubTypes
|
|||||||
ARMOR_FOOTS,
|
ARMOR_FOOTS,
|
||||||
ARMOR_NECK,
|
ARMOR_NECK,
|
||||||
ARMOR_EAR,
|
ARMOR_EAR,
|
||||||
|
ARMOR_PENDANT, // 7 AVA2 talisman (ITEM_TALISMAN_EQUIPMENT), worn in WEAR_PENDANT
|
||||||
ARMOR_NUM_TYPES
|
ARMOR_NUM_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,6 +116,9 @@ enum ECostumeSubTypes
|
|||||||
{
|
{
|
||||||
COSTUME_BODY = ARMOR_BODY, // [중요!!] ECostumeSubTypes enum value는 종류별로 EArmorSubTypes의 그것과 같아야 함.
|
COSTUME_BODY = ARMOR_BODY, // [중요!!] ECostumeSubTypes enum value는 종류별로 EArmorSubTypes의 그것과 같아야 함.
|
||||||
COSTUME_HAIR = ARMOR_HEAD, // 이는 코스츔 아이템에 추가 속성을 붙이겠다는 사업부의 요청에 따라서 기존 로직을 활용하기 위함임.
|
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,
|
COSTUME_NUM_TYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -368,4 +374,30 @@ enum ERefineType
|
|||||||
REFINE_TYPE_BDRAGON,
|
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
|
#endif
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ enum EWearPositions
|
|||||||
WEAR_RING2, // 22 : 신규 반지슬롯2 (오른쪽)
|
WEAR_RING2, // 22 : 신규 반지슬롯2 (오른쪽)
|
||||||
|
|
||||||
WEAR_BELT, // 23 : 신규 벨트슬롯
|
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 //
|
WEAR_MAX = 32 //
|
||||||
};
|
};
|
||||||
@@ -247,6 +253,7 @@ enum EParts
|
|||||||
PART_WEAPON,
|
PART_WEAPON,
|
||||||
PART_HEAD,
|
PART_HEAD,
|
||||||
PART_HAIR,
|
PART_HAIR,
|
||||||
|
PART_SASH,
|
||||||
|
|
||||||
PART_MAX_NUM,
|
PART_MAX_NUM,
|
||||||
PART_WEAPON_SUB,
|
PART_WEAPON_SUB,
|
||||||
@@ -437,6 +444,18 @@ enum EApplyTypes
|
|||||||
APPLY_ANTI_PENETRATE_PCT, //91 관통타격 저항
|
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, //
|
MAX_APPLY_NUM, //
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -670,6 +689,8 @@ enum SPECIAL_EFFECT
|
|||||||
SE_EQUIP_HALLOWEEN_CANDY, // 할로윈 사탕을 착용(-_-;)한 순간에 발동하는 이펙트
|
SE_EQUIP_HALLOWEEN_CANDY, // 할로윈 사탕을 착용(-_-;)한 순간에 발동하는 이펙트
|
||||||
SE_EQUIP_HAPPINESS_RING, // 크리스마스 행복의 반지(71143) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
SE_EQUIP_HAPPINESS_RING, // 크리스마스 행복의 반지(71143) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||||
SE_EQUIP_LOVE_PENDANT, // 발렌타인 사랑의 팬던트(71145) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
SE_EQUIP_LOVE_PENDANT, // 발렌타인 사랑의 팬던트(71145) 착용할 때 이펙트 (발동이펙트임, 지속이펙트 아님)
|
||||||
|
SE_EFFECT_SASH_SUCCEDED, // AVA2 sash combine success
|
||||||
|
SE_EFFECT_SASH_EQUIP,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
enum ETeenFlags
|
enum ETeenFlags
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ int get_Item_Type_Value(string inputString)
|
|||||||
|
|
||||||
"ITEM_RING",
|
"ITEM_RING",
|
||||||
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
|
"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",
|
static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
|
||||||
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
|
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
|
||||||
static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
|
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",
|
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_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",
|
"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" };
|
"RESOURCE_STONE", "RESOURCE_METIN", "RESOURCE_ORE" };
|
||||||
static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_3", "UNIQUE_4", "UNIQUE_5",
|
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"};
|
"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 arSub29[] = { "DS_SLOT1", "DS_SLOT2", "DS_SLOT3", "DS_SLOT4", "DS_SLOT5", "DS_SLOT6" };
|
||||||
static string arSub31[] = { "EXTRACT_DRAGON_SOUL", "EXTRACT_DRAGON_HEART" };
|
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, //32
|
||||||
0, //33 반지
|
0, //33 반지
|
||||||
0, //34 벨트
|
0, //34 벨트
|
||||||
|
0, //35 ITEM_SHINING
|
||||||
|
0, //36 ITEM_NEW_RINGS
|
||||||
};
|
};
|
||||||
static int arNumberOfSubtype[_countof(arSubType)] = {
|
static int arNumberOfSubtype[_countof(arSubType)] = {
|
||||||
0,
|
0,
|
||||||
@@ -198,6 +201,8 @@ int get_Item_SubType_Value(int type_value, string inputString)
|
|||||||
0, // 32
|
0, // 32
|
||||||
0, // 33 반지
|
0, // 33 반지
|
||||||
0, // 34 벨트
|
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_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_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",
|
"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;
|
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\
|
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\
|
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\
|
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 port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.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\
|
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\
|
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\
|
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||||
|
|||||||
@@ -287,6 +287,20 @@ int CalcAttBonus(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int iAtk)
|
|||||||
else if (pkVictim->IsRaceFlag(RACE_FLAG_TREE))
|
else if (pkVictim->IsRaceFlag(RACE_FLAG_TREE))
|
||||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_TREE)) / 100;
|
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())
|
if (pkVictim->GetMobRank() >= MOB_RANK_BOSS && !pkVictim->IsStone())
|
||||||
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
|
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
|
||||||
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
|
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
|
||||||
@@ -389,6 +403,13 @@ void Item_GetDamage(LPITEM pkItem, int* pdamMin, int* pdamMax)
|
|||||||
|
|
||||||
*pdamMin = pkItem->GetValue(3);
|
*pdamMin = pkItem->GetValue(3);
|
||||||
*pdamMax = pkItem->GetValue(4);
|
*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)
|
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 bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
extern void battle_end(LPCHARACTER ch);
|
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_by_xy(long x, long y, long tx, long ty);
|
||||||
extern bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim);
|
extern bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
// #include "HackShield.h"
|
// #include "HackShield.h"
|
||||||
#include "skill_power.h"
|
#include "skill_power.h"
|
||||||
#include "buff_on_attributes.h"
|
#include "buff_on_attributes.h"
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
|
|
||||||
#ifdef __PET_SYSTEM__
|
#ifdef __PET_SYSTEM__
|
||||||
#include "PetSystem.h"
|
#include "PetSystem.h"
|
||||||
@@ -382,6 +383,9 @@ void CHARACTER::Initialize()
|
|||||||
|
|
||||||
memset(&m_tvLastSyncTime, 0, sizeof(m_tvLastSyncTime));
|
memset(&m_tvLastSyncTime, 0, sizeof(m_tvLastSyncTime));
|
||||||
m_iSyncHackCount = 0;
|
m_iSyncHackCount = 0;
|
||||||
|
|
||||||
|
m_bSashCombination = false;
|
||||||
|
m_bSashAbsorption = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHARACTER::Create(const char * c_pszName, DWORD vid, bool isPC)
|
void CHARACTER::Create(const char * c_pszName, DWORD vid, bool isPC)
|
||||||
@@ -902,6 +906,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity)
|
|||||||
addPacket.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
addPacket.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
||||||
addPacket.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
addPacket.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
||||||
addPacket.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
addPacket.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
||||||
|
addPacket.awPart[CHR_EQUIPPART_SASH] = GetPart(PART_SASH);
|
||||||
|
|
||||||
addPacket.bPKMode = m_bPKMode;
|
addPacket.bPKMode = m_bPKMode;
|
||||||
addPacket.dwMountVnum = GetMountVnum();
|
addPacket.dwMountVnum = GetMountVnum();
|
||||||
@@ -1031,6 +1036,7 @@ void CHARACTER::UpdatePacket()
|
|||||||
pack.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
pack.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON);
|
||||||
pack.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
pack.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD);
|
||||||
pack.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
pack.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR);
|
||||||
|
pack.awPart[CHR_EQUIPPART_SASH] = GetPart(PART_SASH);
|
||||||
|
|
||||||
pack.bMovingSpeed = GetLimitPoint(POINT_MOV_SPEED);
|
pack.bMovingSpeed = GetLimitPoint(POINT_MOV_SPEED);
|
||||||
pack.bAttackSpeed = GetLimitPoint(POINT_ATT_SPEED);
|
pack.bAttackSpeed = GetLimitPoint(POINT_ATT_SPEED);
|
||||||
@@ -1304,6 +1310,8 @@ void CHARACTER::SaveReal()
|
|||||||
marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
|
marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
|
||||||
if (pMarriage)
|
if (pMarriage)
|
||||||
pMarriage->Save();
|
pMarriage->Save();
|
||||||
|
|
||||||
|
PortBpSave(this); // PORT: battle pass progress
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHARACTER::FlushDelayedSaveItem()
|
void CHARACTER::FlushDelayedSaveItem()
|
||||||
@@ -1393,6 +1401,7 @@ void CHARACTER::Disconnect(const char * c_pszReason)
|
|||||||
|
|
||||||
SaveAffect();
|
SaveAffect();
|
||||||
m_bIsLoadedAffect = false;
|
m_bIsLoadedAffect = false;
|
||||||
|
PortBpLogout(this); // PORT: battle pass, after the last save
|
||||||
|
|
||||||
m_bSkipSave = true; // 이 이후에는 더이상 저장하면 안된다.
|
m_bSkipSave = true; // 이 이후에는 더이상 저장하면 안된다.
|
||||||
|
|
||||||
@@ -1769,6 +1778,7 @@ void CHARACTER::SetPlayerProto(const TPlayerTable * t)
|
|||||||
|
|
||||||
m_pointsInstant.bBasePart = t->part_base;
|
m_pointsInstant.bBasePart = t->part_base;
|
||||||
SetPart(PART_HAIR, t->parts[PART_HAIR]);
|
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.iRandomHP = t->sRandomHP;
|
||||||
m_points.iRandomSP = t->sRandomSP;
|
m_points.iRandomSP = t->sRandomSP;
|
||||||
@@ -2273,6 +2283,7 @@ void CHARACTER::ComputePoints()
|
|||||||
SetPart(PART_WEAPON, GetOriginalPart(PART_WEAPON));
|
SetPart(PART_WEAPON, GetOriginalPart(PART_WEAPON));
|
||||||
SetPart(PART_HEAD, GetOriginalPart(PART_HEAD));
|
SetPart(PART_HEAD, GetOriginalPart(PART_HEAD));
|
||||||
SetPart(PART_HAIR, GetOriginalPart(PART_HAIR));
|
SetPart(PART_HAIR, GetOriginalPart(PART_HAIR));
|
||||||
|
SetPart(PART_SASH, GetOriginalPart(PART_SASH));
|
||||||
|
|
||||||
SetPoint(POINT_PARTY_ATTACKER_BONUS, lAttackerBonus);
|
SetPoint(POINT_PARTY_ATTACKER_BONUS, lAttackerBonus);
|
||||||
SetPoint(POINT_PARTY_TANKER_BONUS, lTankerBonus);
|
SetPoint(POINT_PARTY_TANKER_BONUS, lTankerBonus);
|
||||||
@@ -3063,6 +3074,8 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
|||||||
|
|
||||||
if (amount)
|
if (amount)
|
||||||
{
|
{
|
||||||
|
if (amount > 0)
|
||||||
|
PortBpCount(this, PORT_BP_LEVEL_UP, 0, amount); // PORT: battle pass
|
||||||
quest::CQuestManager::instance().LevelUp(GetPlayerID());
|
quest::CQuestManager::instance().LevelUp(GetPlayerID());
|
||||||
|
|
||||||
LogManager::instance().LevelLog(this, val, GetRealPoint(POINT_PLAYTIME) + (get_dword_time() - m_dwPlayStartTime) / 60000);
|
LogManager::instance().LevelLog(this, val, GetRealPoint(POINT_PLAYTIME) + (get_dword_time() - m_dwPlayStartTime) / 60000);
|
||||||
@@ -3436,6 +3449,12 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
|||||||
// PORT AVA2 biology points
|
// PORT AVA2 biology points
|
||||||
case POINT_ATTBONUS_STONE:
|
case POINT_ATTBONUS_STONE:
|
||||||
case POINT_ATTBONUS_BOSS:
|
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_RESIST_HUMAN:
|
||||||
case POINT_ATTBONUS_MONSTER:
|
case POINT_ATTBONUS_MONSTER:
|
||||||
case POINT_ATTBONUS_SURA:
|
case POINT_ATTBONUS_SURA:
|
||||||
@@ -3821,6 +3840,14 @@ void CHARACTER::ApplyPoint(BYTE bApplyType, int iVal)
|
|||||||
case APPLY_DEF_GRADE: // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
case APPLY_DEF_GRADE: // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
||||||
case APPLY_COSTUME_ATTR_BONUS: // 84 코스튬 아이템에 붙은 속성치 보너스
|
case APPLY_COSTUME_ATTR_BONUS: // 84 코스튬 아이템에 붙은 속성치 보너스
|
||||||
case APPLY_MAGIC_ATTBONUS_PER: // 85 마법 공격력 +x%
|
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%
|
case APPLY_MELEE_MAGIC_ATTBONUS_PER: // 86 마법 + 밀리 공격력 +x%
|
||||||
PointChange(aApplyInfo[bApplyType].bPointType, iVal);
|
PointChange(aApplyInfo[bApplyType].bPointType, iVal);
|
||||||
break;
|
break;
|
||||||
@@ -4170,6 +4197,9 @@ WORD CHARACTER::GetOriginalPart(BYTE bPartPos) const
|
|||||||
case PART_HAIR:
|
case PART_HAIR:
|
||||||
return GetPart(PART_HAIR);
|
return GetPart(PART_HAIR);
|
||||||
|
|
||||||
|
case PART_SASH:
|
||||||
|
return GetPart(PART_SASH);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,6 +279,13 @@ enum EPointTypes
|
|||||||
// PORT AVA2 biology points, within the existing 255-point packet.
|
// PORT AVA2 biology points, within the existing 255-point packet.
|
||||||
POINT_ATTBONUS_STONE = 240,
|
POINT_ATTBONUS_STONE = 240,
|
||||||
POINT_ATTBONUS_BOSS = 241,
|
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,
|
POINT_RESIST_HUMAN = 220,
|
||||||
|
|
||||||
// 추가 속성 저항
|
// 추가 속성 저항
|
||||||
@@ -408,6 +415,7 @@ typedef struct character_point_instant
|
|||||||
// by mhh
|
// by mhh
|
||||||
LPITEM pCubeItems[CUBE_MAX_NUM];
|
LPITEM pCubeItems[CUBE_MAX_NUM];
|
||||||
LPCHARACTER pCubeNpc;
|
LPCHARACTER pCubeNpc;
|
||||||
|
LPITEM pSashMaterials[SASH_WINDOW_MAX_MATERIALS]; // AVA2 sash window
|
||||||
|
|
||||||
LPCHARACTER battle_victim;
|
LPCHARACTER battle_victim;
|
||||||
|
|
||||||
@@ -1746,6 +1754,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int GetPremiumRemainSeconds(BYTE bType) const;
|
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:
|
private:
|
||||||
int m_aiPremiumTimes[PREMIUM_MAX_NUM];
|
int m_aiPremiumTimes[PREMIUM_MAX_NUM];
|
||||||
@@ -2068,6 +2078,36 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
|||||||
protected:
|
protected:
|
||||||
int m_iLastPMPulse;
|
int m_iLastPMPulse;
|
||||||
int m_iPMCounter;
|
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);
|
ESex GET_SEX(LPCHARACTER ch);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "BlueDragon.h"
|
#include "BlueDragon.h"
|
||||||
#include "DragonLair.h"
|
#include "DragonLair.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
DWORD AdjustExpByLevel(const LPCHARACTER ch, const DWORD exp)
|
||||||
{
|
{
|
||||||
@@ -282,6 +283,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
|||||||
sys_log(1, "DEATH_PERNALY_CHECK(%s) town(%d)", GetName(), bTown);
|
sys_log(1, "DEATH_PERNALY_CHECK(%s) town(%d)", GetName(), bTown);
|
||||||
|
|
||||||
Cube_close(this);
|
Cube_close(this);
|
||||||
|
CloseSash();
|
||||||
|
|
||||||
if (CBattleArena::instance().IsBattleArenaMap(GetMapIndex()) == true)
|
if (CBattleArena::instance().IsBattleArenaMap(GetMapIndex()) == true)
|
||||||
{
|
{
|
||||||
@@ -785,6 +787,8 @@ void CHARACTER::Reward(bool bItemDrop)
|
|||||||
pkAttacker->UpdateAlignment(2);
|
pkAttacker->UpdateAlignment(2);
|
||||||
|
|
||||||
pkAttacker->SetQuestNPCID(GetVID());
|
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());
|
quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());
|
||||||
CHARACTER_MANAGER::instance().KillLog(GetRaceNum());
|
CHARACTER_MANAGER::instance().KillLog(GetRaceNum());
|
||||||
|
|
||||||
@@ -1522,6 +1526,9 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
|||||||
{
|
{
|
||||||
Cube_close(this);
|
Cube_close(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsPC())
|
||||||
|
CloseSash();
|
||||||
|
|
||||||
CShopManager::instance().StopShopping(this);
|
CShopManager::instance().StopShopping(this);
|
||||||
CloseMyShop();
|
CloseMyShop();
|
||||||
|
|||||||
@@ -265,6 +265,15 @@ DWORD CHARACTER::GetMyHorseVnum() const
|
|||||||
++delta;
|
++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;
|
return c_aHorseStat[GetHorseLevel()].iNPCRace + delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#ifdef __AUCTION__
|
#ifdef __AUCTION__
|
||||||
#include "auction_manager.h"
|
#include "auction_manager.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "port_premium.h"
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
const int ITEM_BROKEN_METIN_VNUM = 28960;
|
const int ITEM_BROKEN_METIN_VNUM = 28960;
|
||||||
|
|
||||||
// CHANGE_ITEM_ATTRIBUTES
|
// CHANGE_ITEM_ATTRIBUTES
|
||||||
@@ -227,6 +229,9 @@ bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver)
|
|||||||
if (IsWarping())
|
if (IsWarping())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (IsSashWindowOpen())
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,6 +928,7 @@ bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
|
|||||||
{
|
{
|
||||||
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
||||||
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
||||||
|
PortBpCount(this, PORT_BP_REFINE, pkNewItem->GetVnum(), 1); // PORT: battle pass
|
||||||
|
|
||||||
WORD bCell = item->GetCell();
|
WORD bCell = item->GetCell();
|
||||||
|
|
||||||
@@ -1196,6 +1202,7 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
|
|||||||
{
|
{
|
||||||
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
|
||||||
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
|
||||||
|
PortBpCount(this, PORT_BP_REFINE, pkNewItem->GetVnum(), 1); // PORT: battle pass
|
||||||
|
|
||||||
WORD bCell = item->GetCell();
|
WORD bCell = item->GetCell();
|
||||||
|
|
||||||
@@ -1894,6 +1901,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
|||||||
case ITEM_ROD:
|
case ITEM_ROD:
|
||||||
case ITEM_RING: // 신규 반지 아이템
|
case ITEM_RING: // 신규 반지 아이템
|
||||||
case ITEM_BELT: // 신규 벨트 아이템
|
case ITEM_BELT: // 신규 벨트 아이템
|
||||||
|
case ITEM_NEW_RINGS: // AVA2 new rings
|
||||||
// MINING
|
// MINING
|
||||||
case ITEM_PICK:
|
case ITEM_PICK:
|
||||||
// END_OF_MINING
|
// END_OF_MINING
|
||||||
@@ -4488,6 +4496,12 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
|||||||
if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
|
if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (item->IsCostumeEnchant())
|
||||||
|
return CostumeEnchantUse(item, item2);
|
||||||
|
|
||||||
|
if (item->GetPendantScrollKind() || item2->IsTalisman())
|
||||||
|
return PendantScrollUse(item, item2);
|
||||||
|
|
||||||
if (item2->IsEquipped())
|
if (item2->IsEquipped())
|
||||||
{
|
{
|
||||||
BuffOnAttr_RemoveBuffsFromItem(item2);
|
BuffOnAttr_RemoveBuffsFromItem(item2);
|
||||||
@@ -4551,7 +4565,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USE_CHANGE_ATTRIBUTE :
|
case USE_CHANGE_ATTRIBUTE :
|
||||||
if (item2->GetAttributeSetIndex() == -1)
|
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||||
{
|
{
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||||
return false;
|
return false;
|
||||||
@@ -4656,7 +4670,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USE_ADD_ATTRIBUTE :
|
case USE_ADD_ATTRIBUTE :
|
||||||
if (item2->GetAttributeSetIndex() == -1)
|
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||||
{
|
{
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||||
return false;
|
return false;
|
||||||
@@ -4728,7 +4742,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
|||||||
case USE_ADD_ATTRIBUTE2 :
|
case USE_ADD_ATTRIBUTE2 :
|
||||||
// 축복의 구슬
|
// 축복의 구슬
|
||||||
// 재가비서를 통해 속성을 4개 추가 시킨 아이템에 대해서 하나의 속성을 더 붙여준다.
|
// 재가비서를 통해 속성을 4개 추가 시킨 아이템에 대해서 하나의 속성을 더 붙여준다.
|
||||||
if (item2->GetAttributeSetIndex() == -1)
|
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
|
||||||
{
|
{
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
|
||||||
return false;
|
return false;
|
||||||
@@ -5207,6 +5221,10 @@ bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PORT: VIP card (port_premium.h)
|
||||||
|
if (PortVipUseCard(this, item))
|
||||||
|
return true;
|
||||||
|
|
||||||
//PREVENT_TRADE_WINDOW
|
//PREVENT_TRADE_WINDOW
|
||||||
if (IS_SUMMON_ITEM(item->GetVnum()))
|
if (IS_SUMMON_ITEM(item->GetVnum()))
|
||||||
{
|
{
|
||||||
@@ -5686,6 +5704,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());
|
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);
|
LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Cell.IsEquipPosition()) // AVA2 mount costume / skin taken off by drag
|
||||||
|
MountCostumeUnequipped(item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -6089,6 +6110,8 @@ bool CHARACTER::UnequipItem(LPITEM item)
|
|||||||
else
|
else
|
||||||
item->AddToCharacter(this, TItemPos(INVENTORY, pos));
|
item->AddToCharacter(this, TItemPos(INVENTORY, pos));
|
||||||
|
|
||||||
|
MountCostumeUnequipped(item, true); // AVA2 mount costume / skin
|
||||||
|
|
||||||
CheckMaximumPoints();
|
CheckMaximumPoints();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -6237,6 +6260,10 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
|
|||||||
{
|
{
|
||||||
this->EffectPacket(SE_EQUIP_LOVE_PENDANT);
|
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)
|
// ITEM_UNIQUE의 경우, SpecialItemGroup에 정의되어 있고, (item->GetSIGVnum() != NULL)
|
||||||
//
|
//
|
||||||
else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
|
else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
|
||||||
@@ -6257,6 +6284,8 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
|
|||||||
{
|
{
|
||||||
quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
|
quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MountCostumeEquipped(item); // AVA2 mount costume / skin
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -7553,6 +7582,9 @@ bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!MountCostumeCanEquip(item)) // AVA2 mount skin
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7567,6 +7599,9 @@ bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const
|
|||||||
if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
|
if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!MountCostumeCanUnequip(item)) // AVA2 mount costume / skin
|
||||||
|
return false;
|
||||||
|
|
||||||
// 아이템 unequip시 인벤토리로 옮길 때 빈 자리가 있는 지 확인
|
// 아이템 unequip시 인벤토리로 옮길 때 빈 자리가 있는 지 확인
|
||||||
{
|
{
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
|
|||||||
@@ -1043,6 +1043,13 @@ void SetPolyVarForAttack(LPCHARACTER ch, CSkillProto * pkSk, LPITEM pkWeapon)
|
|||||||
int iMtk = number(pkWeapon->GetValue(1), pkWeapon->GetValue(2));
|
int iMtk = number(pkWeapon->GetValue(1), pkWeapon->GetValue(2));
|
||||||
iMtk += pkWeapon->GetValue(5);
|
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("wep", iWep);
|
||||||
pkSk->SetPointVar("mtk", iMtk);
|
pkSk->SetPointVar("mtk", iMtk);
|
||||||
pkSk->SetPointVar("mwep", iMtk);
|
pkSk->SetPointVar("mwep", iMtk);
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ ACMD(do_port_biolog);
|
|||||||
ACMD(do_port_features);
|
ACMD(do_port_features);
|
||||||
ACMD(do_port_switchbot);
|
ACMD(do_port_switchbot);
|
||||||
ACMD(do_port_pickup);
|
ACMD(do_port_pickup);
|
||||||
|
ACMD(do_port_chest);
|
||||||
|
ACMD(do_port_vip);
|
||||||
|
ACMD(do_port_bp);
|
||||||
ACMD(do_user_horse_ride);
|
ACMD(do_user_horse_ride);
|
||||||
ACMD(do_user_horse_back);
|
ACMD(do_user_horse_back);
|
||||||
ACMD(do_user_horse_feed);
|
ACMD(do_user_horse_feed);
|
||||||
@@ -286,9 +289,6 @@ struct command_info cmd_info[] =
|
|||||||
{
|
{
|
||||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_STANDING, GM_PLAYER },
|
{ "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 },
|
|
||||||
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "biolog", 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 },
|
{ "server_bonuses", do_server_bonuses, 0, POS_DEAD, GM_PLAYER },
|
||||||
@@ -601,6 +601,14 @@ struct command_info cmd_info[] =
|
|||||||
{ "ds_list", do_ds_list, 0, POS_DEAD, GM_PLAYER },
|
{ "ds_list", do_ds_list, 0, POS_DEAD, GM_PLAYER },
|
||||||
{ "do_clear_affect", do_clear_affect, 0, POS_DEAD, GM_LOW_WIZARD},
|
{ "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 },
|
||||||
|
{ "mt_switchbot", do_port_switchbot, 0, POS_DEAD, GM_PLAYER },
|
||||||
|
{ "mt_pickup", do_port_pickup, 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 } /* 반드시 이 것이 마지막이어야 한다. */
|
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,24 @@
|
|||||||
#include "port_features.h"
|
#include "port_features.h"
|
||||||
#include "port_switchbot.h"
|
#include "port_switchbot.h"
|
||||||
#include "port_pickup.h"
|
#include "port_pickup.h"
|
||||||
|
#include "port_chest.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;
|
extern int g_server_id;
|
||||||
|
|
||||||
@@ -86,6 +104,10 @@ ACMD(do_user_horse_back)
|
|||||||
if (ch->GetHorse() != NULL)
|
if (ch->GetHorse() != NULL)
|
||||||
{
|
{
|
||||||
ch->HorseSummon(false);
|
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("말을 돌려보냈습니다."));
|
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("말을 돌려보냈습니다."));
|
||||||
}
|
}
|
||||||
else if (ch->IsHorseRiding() == true)
|
else if (ch->IsHorseRiding() == true)
|
||||||
|
|||||||
@@ -914,6 +914,56 @@ const TApplyInfo aApplyInfo[MAX_APPLY_NUM] =
|
|||||||
{ POINT_RESIST_DARK, }, // APPLY_RESIST_DARK, 89
|
{ POINT_RESIST_DARK, }, // APPLY_RESIST_DARK, 89
|
||||||
{ POINT_RESIST_CRITICAL, }, // APPLY_ANTI_CRITICAL_PCT, 90
|
{ POINT_RESIST_CRITICAL, }, // APPLY_ANTI_CRITICAL_PCT, 90
|
||||||
{ POINT_RESIST_PENETRATE, }, // APPLY_ANTI_PENETRATE_PCT, 91
|
{ 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] =
|
const int aiItemMagicAttributePercentHigh[ITEM_ATTRIBUTE_MAX_LEVEL] =
|
||||||
@@ -1281,6 +1331,14 @@ TValueName c_aApplyTypeNames[] =
|
|||||||
{ "MAGIC_ATTBONUS_PER", APPLY_MAGIC_ATTBONUS_PER },
|
{ "MAGIC_ATTBONUS_PER", APPLY_MAGIC_ATTBONUS_PER },
|
||||||
{ "MELEE_MAGIC_ATTBONUS_PER", APPLY_MELEE_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 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
// from import_item_proto.c
|
// from import_item_proto.c
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "affect.h"
|
#include "affect.h"
|
||||||
#include "unique_item.h"
|
#include "unique_item.h"
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fishing
|
namespace fishing
|
||||||
@@ -634,6 +635,7 @@ void Take(fishing_event_info* info, LPCHARACTER ch)
|
|||||||
if (item_vnum)
|
if (item_vnum)
|
||||||
{
|
{
|
||||||
FishingSuccess(ch);
|
FishingSuccess(ch);
|
||||||
|
PortBpCount(ch, PORT_BP_CATCH_FISH, item_vnum, 1); // PORT: battle pass
|
||||||
|
|
||||||
TPacketGCFishing p;
|
TPacketGCFishing p;
|
||||||
p.header = HEADER_GC_FISHING;
|
p.header = HEADER_GC_FISHING;
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ class CInputMain : public CInputProcessor
|
|||||||
int MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes);
|
int MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes);
|
||||||
|
|
||||||
void Refine(LPCHARACTER ch, const char* c_pData);
|
void Refine(LPCHARACTER ch, const char* c_pData);
|
||||||
|
void Sash(LPCHARACTER ch, const char* c_pData);
|
||||||
|
|
||||||
void Roulette(LPCHARACTER ch, const char* c_pData);
|
void Roulette(LPCHARACTER ch, const char* c_pData);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -963,6 +963,22 @@ void CInputDB::Boot(const char* data)
|
|||||||
return;
|
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);
|
sys_log(0, "LoadLocaleFile: ETCDropItem: %s", szETCDropItemFileName);
|
||||||
if (!ITEM_MANAGER::instance().ReadEtcDropItemFile(szETCDropItemFileName))
|
if (!ITEM_MANAGER::instance().ReadEtcDropItemFile(szETCDropItemFileName))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,9 @@
|
|||||||
#include "block_country.h"
|
#include "block_country.h"
|
||||||
#include "dev_log.h"
|
#include "dev_log.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "db.h"
|
||||||
|
#include "item.h"
|
||||||
|
#include "port_premium.h"
|
||||||
#include "horsename_manager.h"
|
#include "horsename_manager.h"
|
||||||
#include "MarkManager.h"
|
#include "MarkManager.h"
|
||||||
// #include "HackShield.h"
|
// #include "HackShield.h"
|
||||||
@@ -631,6 +634,8 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
|||||||
ch->SendGreetMessage();
|
ch->SendGreetMessage();
|
||||||
|
|
||||||
_send_bonus_info(ch);
|
_send_bonus_info(ch);
|
||||||
|
|
||||||
|
ch->MountCostumeOnLogin(); // AVA2 mount costume
|
||||||
|
|
||||||
for (int i = 0; i <= PREMIUM_MAX_NUM; ++i)
|
for (int i = 0; i <= PREMIUM_MAX_NUM; ++i)
|
||||||
{
|
{
|
||||||
@@ -642,6 +647,8 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
|||||||
ch->AddAffect(AFFECT_PREMIUM_START + i, POINT_NONE, 0, 0, remain, 0, true);
|
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);
|
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);
|
||||||
|
|
||||||
if (LC_IsEurope())
|
if (LC_IsEurope())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3043,6 +3043,30 @@ void CInputMain::Refine(LPCHARACTER ch, const char* c_pData)
|
|||||||
ch->ClearRefineMode();
|
ch->ClearRefineMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
{
|
{
|
||||||
LPCHARACTER ch;
|
LPCHARACTER ch;
|
||||||
@@ -3324,6 +3348,10 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
|||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
|
case HEADER_CG_SASH:
|
||||||
|
Sash(ch, c_pData);
|
||||||
|
break;
|
||||||
|
|
||||||
case HEADER_CG_DRAGON_SOUL_REFINE:
|
case HEADER_CG_DRAGON_SOUL_REFINE:
|
||||||
{
|
{
|
||||||
TPacketCGDragonSoulRefine* p = reinterpret_cast <TPacketCGDragonSoulRefine*>((void*)c_pData);
|
TPacketCGDragonSoulRefine* p = reinterpret_cast <TPacketCGDragonSoulRefine*>((void*)c_pData);
|
||||||
|
|||||||
+101
-10
@@ -366,6 +366,20 @@ bool CItem::AddToCharacter(LPCHARACTER ch, TItemPos Cell)
|
|||||||
if (ch->GetDesc())
|
if (ch->GetDesc())
|
||||||
m_dwLastOwnerPID = ch->GetPlayerID();
|
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);
|
event_cancel(&m_pkDestroyEvent);
|
||||||
|
|
||||||
ch->SetItem(TItemPos(window_type, pos), this);
|
ch->SetItem(TItemPos(window_type, pos), this);
|
||||||
@@ -473,9 +487,12 @@ bool CItem::CanUsedBy(LPCHARACTER ch)
|
|||||||
|
|
||||||
int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
||||||
{
|
{
|
||||||
|
if (IsTalisman())
|
||||||
|
return WEAR_PENDANT;
|
||||||
|
|
||||||
// 코스츔 아이템(ITEM_COSTUME)은 WearFlag 없어도 됨. (sub type으로 착용위치 구분. 귀찮게 또 wear flag 줄 필요가 있나..)
|
// 코스츔 아이템(ITEM_COSTUME)은 WearFlag 없어도 됨. (sub type으로 착용위치 구분. 귀찮게 또 wear flag 줄 필요가 있나..)
|
||||||
// 용혼석(ITEM_DS, ITEM_SPECIAL_DS)도 SUB_TYPE으로 구분. 신규 반지, 벨트는 ITEM_TYPE으로 구분 -_-
|
// 용혼석(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;
|
return -1;
|
||||||
|
|
||||||
// 용혼석 슬롯을 WEAR로 처리할 수가 없어서(WEAR는 최대 32개까지 가능한데 용혼석을 추가하면 32가 넘는다.)
|
// 용혼석 슬롯을 WEAR로 처리할 수가 없어서(WEAR는 최대 32개까지 가능한데 용혼석을 추가하면 32가 넘는다.)
|
||||||
@@ -507,6 +524,12 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
|||||||
return WEAR_COSTUME_BODY;
|
return WEAR_COSTUME_BODY;
|
||||||
else if (GetSubType() == COSTUME_HAIR)
|
else if (GetSubType() == COSTUME_HAIR)
|
||||||
return WEAR_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)
|
else if (GetType() == ITEM_RING)
|
||||||
{
|
{
|
||||||
@@ -517,6 +540,13 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
|
|||||||
}
|
}
|
||||||
else if (GetType() == ITEM_BELT)
|
else if (GetType() == ITEM_BELT)
|
||||||
return WEAR_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)
|
else if (GetWearFlag() & WEARABLE_BODY)
|
||||||
return WEAR_BODY;
|
return WEAR_BODY;
|
||||||
else if (GetWearFlag() & WEARABLE_HEAD)
|
else if (GetWearFlag() & WEARABLE_HEAD)
|
||||||
@@ -635,23 +665,54 @@ void CItem::ModifyPoints(bool bAdd)
|
|||||||
accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
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)
|
for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
|
||||||
{
|
{
|
||||||
if (m_pProto->aApplies[i].bType == APPLY_NONE)
|
BYTE bType = m_pProto->aApplies[i].bType;
|
||||||
continue;
|
|
||||||
|
|
||||||
long value = m_pProto->aApplies[i].lValue;
|
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
|
else
|
||||||
{
|
{
|
||||||
if (0 != accessoryGrade)
|
if (0 != accessoryGrade)
|
||||||
value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
|
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 +733,19 @@ void CItem::ModifyPoints(bool bAdd)
|
|||||||
if (GetAttributeType(i))
|
if (GetAttributeType(i))
|
||||||
{
|
{
|
||||||
const TPlayerItemAttribute& ia = GetAttribute(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)
|
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
|
else
|
||||||
m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : -ia.sValue);
|
m_pOwner->ApplyPoint(ia.bType, bAdd ? sValue : -sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,6 +835,13 @@ void CItem::ModifyPoints(bool bAdd)
|
|||||||
toSetValue = (true == bAdd) ? this->GetValue(3) : 0;
|
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)
|
if (PART_MAX_NUM != toSetPart)
|
||||||
{
|
{
|
||||||
m_pOwner->SetPart((BYTE)toSetPart, toSetValue);
|
m_pOwner->SetPart((BYTE)toSetPart, toSetValue);
|
||||||
@@ -808,6 +884,7 @@ bool CItem::IsEquipable() const
|
|||||||
case ITEM_SPECIAL_DS:
|
case ITEM_SPECIAL_DS:
|
||||||
case ITEM_RING:
|
case ITEM_RING:
|
||||||
case ITEM_BELT:
|
case ITEM_BELT:
|
||||||
|
case ITEM_NEW_RINGS:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1581,7 +1658,7 @@ int CItem::GetSpecialGroup() const
|
|||||||
bool CItem::IsAccessoryForSocket()
|
bool CItem::IsAccessoryForSocket()
|
||||||
{
|
{
|
||||||
return (m_pProto->bType == ITEM_ARMOR && (m_pProto->bSubType == ARMOR_WRIST || m_pProto->bSubType == ARMOR_NECK || m_pProto->bSubType == ARMOR_EAR)) ||
|
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)
|
void CItem::SetAccessorySocketGrade(int iGrade)
|
||||||
@@ -1703,6 +1780,16 @@ bool CItem::IsRideItem()
|
|||||||
return false;
|
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()
|
bool CItem::IsRamadanRing()
|
||||||
{
|
{
|
||||||
if (GetVnum() == UNIQUE_ITEM_RAMADAN_RING)
|
if (GetVnum() == UNIQUE_ITEM_RAMADAN_RING)
|
||||||
@@ -1788,6 +1875,10 @@ bool CItem::CanPutInto(LPITEM item)
|
|||||||
else if(item->GetType() == ITEM_RING)
|
else if(item->GetType() == ITEM_RING)
|
||||||
return CanPutIntoRing(item, this);
|
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)
|
else if (item->GetType() != ITEM_ARMOR)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,13 @@ class CItem : public CEntity
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsRideItem();
|
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);
|
||||||
bool IsRamadanRing();
|
bool IsRamadanRing();
|
||||||
|
|
||||||
void ClearMountAttributeAndAffect();
|
void ClearMountAttributeAndAffect();
|
||||||
@@ -331,4 +338,6 @@ EVENTINFO(item_vid_event_info)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DWORD GetNewRingJewelVnum(DWORD dwRingVnum); // port_rings.cpp, 0 = none
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ int CItem::GetAttributeSetIndex()
|
|||||||
return ATTRIBUTE_SET_WEAPON;
|
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)
|
if (GetType() == ITEM_ARMOR || GetType() == ITEM_COSTUME)
|
||||||
{
|
{
|
||||||
switch (GetSubType())
|
switch (GetSubType())
|
||||||
@@ -114,6 +118,12 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel)
|
|||||||
|
|
||||||
void CItem::PutAttributeWithLevel(BYTE bLevel)
|
void CItem::PutAttributeWithLevel(BYTE bLevel)
|
||||||
{
|
{
|
||||||
|
if (IsNewRing())
|
||||||
|
{
|
||||||
|
PutNewRingAttributeWithLevel(bLevel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int iAttributeSet = GetAttributeSetIndex();
|
int iAttributeSet = GetAttributeSetIndex();
|
||||||
|
|
||||||
if (iAttributeSet < 0)
|
if (iAttributeSet < 0)
|
||||||
|
|||||||
@@ -817,25 +817,26 @@ bool ITEM_MANAGER::GetDropPct(LPCHARACTER pkChr, LPCHARACTER pkKiller, OUT int&
|
|||||||
|
|
||||||
//if (pkKiller->GetPoint(POINT_MALL_ITEMBONUS) > 0)
|
//if (pkKiller->GetPoint(POINT_MALL_ITEMBONUS) > 0)
|
||||||
//iDeltaPercent += iDeltaPercent * pkKiller->GetPoint(POINT_MALL_ITEMBONUS) / 100;
|
//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 ||
|
if (pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0 ||
|
||||||
pkKiller->IsEquipUniqueGroup(UNIQUE_GROUP_DOUBLE_ITEM))
|
pkKiller->IsEquipUniqueGroup(UNIQUE_GROUP_DOUBLE_ITEM))
|
||||||
iDeltaPercent += iDeltaPercent;
|
iDeltaPercent += iDeltaPercent;
|
||||||
|
else
|
||||||
|
iDeltaPercent += iDeltaPercent / 2;
|
||||||
// END_OF_ADD_PREMIUM
|
// END_OF_ADD_PREMIUM
|
||||||
|
|
||||||
// PC_BANG_ITEM_ADD
|
// AVA2: the permanent glove adds 100 with premium and 50 alone (or a removable glove with premium). This also
|
||||||
if (pkKiller->GetPoint(POINT_PC_BANG_DROP_BONUS) > 0)
|
// fixes the original ternary without parentheses, which always made the divisor 100 and ignored PRIV_ITEM_DROP.
|
||||||
{
|
int bonus = 0;
|
||||||
if (pkKiller->IsPCBang() == true)
|
if (pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM) && pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0)
|
||||||
iDeltaPercent += iDeltaPercent * pkKiller->GetPoint(POINT_PC_BANG_DROP_BONUS)/100;
|
bonus = 100;
|
||||||
}
|
else if (pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM) ||
|
||||||
// END_PC_BANG_ITEM_ADD
|
(pkKiller->IsEquipUniqueGroup(UNIQUE_GROUP_DOUBLE_ITEM) && pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0))
|
||||||
|
bonus = 50;
|
||||||
|
|
||||||
iRandRange = 4000000;
|
iRandRange = 4000000;
|
||||||
iRandRange = iRandRange * 100 /
|
iRandRange = iRandRange * 100 /
|
||||||
(100 +
|
(100 + CPrivManager::instance().GetPriv(pkKiller, PRIV_ITEM_DROP) + bonus);
|
||||||
CPrivManager::instance().GetPriv(pkKiller, PRIV_ITEM_DROP) +
|
|
||||||
pkKiller->IsEquipUniqueItem(UNIQUE_ITEM_DOUBLE_ITEM)?100:0);
|
|
||||||
|
|
||||||
if (distribution_test_server) iRandRange /= 3;
|
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
|
// MobDropItem Group
|
||||||
{
|
{
|
||||||
itertype(m_map_pkMobItemGroup) it;
|
itertype(m_map_pkMobItemGroup) it;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef __INC_ITEM_MANAGER__
|
#ifndef __INC_ITEM_MANAGER__
|
||||||
#define __INC_ITEM_MANAGER__
|
#define __INC_ITEM_MANAGER__
|
||||||
#include "port_feature_types.h"
|
#include "port_feature_types.h"
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
#ifdef M2_USE_POOL
|
#ifdef M2_USE_POOL
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
@@ -273,6 +274,31 @@ class CDropItemGroup
|
|||||||
std::vector<SDropItemGroupInfo> m_vec_items;
|
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
|
class CLevelItemGroup
|
||||||
{
|
{
|
||||||
struct SLevelItemGroupInfo
|
struct SLevelItemGroupInfo
|
||||||
@@ -393,6 +419,7 @@ class ITEM_MANAGER : public singleton<ITEM_MANAGER>
|
|||||||
bool CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::vector<LPITEM> & vec_item);
|
bool CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::vector<LPITEM> & vec_item);
|
||||||
|
|
||||||
bool ReadCommonDropItemFile(const char * c_pszFileName);
|
bool ReadCommonDropItemFile(const char * c_pszFileName);
|
||||||
|
bool ReadCommonDropNewItemFile(const char * c_pszFileName);
|
||||||
bool ReadEtcDropItemFile(const char * c_pszFileName);
|
bool ReadEtcDropItemFile(const char * c_pszFileName);
|
||||||
bool ReadDropItemGroup(const char * c_pszFileName);
|
bool ReadDropItemGroup(const char * c_pszFileName);
|
||||||
bool ReadMonsterDropItemGroup(const char * c_pszFileName);
|
bool ReadMonsterDropItemGroup(const char * c_pszFileName);
|
||||||
@@ -444,6 +471,7 @@ class ITEM_MANAGER : public singleton<ITEM_MANAGER>
|
|||||||
std::map<DWORD, CMobItemGroup*> m_map_pkMobItemGroup;
|
std::map<DWORD, CMobItemGroup*> m_map_pkMobItemGroup;
|
||||||
std::map<DWORD, CLevelItemGroup*> m_map_pkLevelItemGroup;
|
std::map<DWORD, CLevelItemGroup*> m_map_pkLevelItemGroup;
|
||||||
std::map<DWORD, CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
|
std::map<DWORD, CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
|
||||||
|
std::vector<CCommonDropNew*> m_vec_pkCommonNewItemGroup;
|
||||||
|
|
||||||
// CHECK_UNIQUE_GROUP
|
// CHECK_UNIQUE_GROUP
|
||||||
std::map<DWORD, int> m_ItemToSpecialGroup;
|
std::map<DWORD, int> m_ItemToSpecialGroup;
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName)
|
|||||||
if ("attr" == stType)
|
if ("attr" == stType)
|
||||||
{
|
{
|
||||||
CSpecialAttrGroup * pkGroup = M2_NEW CSpecialAttrGroup(iVnum);
|
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);
|
snprintf(buf, sizeof(buf), "%d", k);
|
||||||
|
|
||||||
if (loader.GetTokenVector(buf, &pTok))
|
if (loader.GetTokenVector(buf, &pTok))
|
||||||
@@ -212,9 +212,9 @@ bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CSpecialItemGroup * pkGroup = M2_NEW CSpecialItemGroup(iVnum, type);
|
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);
|
snprintf(buf, sizeof(buf), "%d", k);
|
||||||
|
|
||||||
if (loader.GetTokenVector(buf, &pTok))
|
if (loader.GetTokenVector(buf, &pTok))
|
||||||
@@ -427,6 +427,96 @@ bool ITEM_MANAGER::ConvSpecialDropItemFile()
|
|||||||
return true;
|
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)
|
bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName)
|
||||||
{
|
{
|
||||||
FILE * fp = fopen(c_pszFileName, "r");
|
FILE * fp = fopen(c_pszFileName, "r");
|
||||||
@@ -634,7 +724,7 @@ bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bNew = false;
|
bNew = false;
|
||||||
CDropItemGroup* pkGroup = it->second;
|
pkGroup = it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 1; k < 256; ++k)
|
for (int k = 1; k < 256; ++k)
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ enum
|
|||||||
|
|
||||||
HEADER_CG_DRAGON_SOUL_REFINE = 205,
|
HEADER_CG_DRAGON_SOUL_REFINE = 205,
|
||||||
HEADER_CG_STATE_CHECKER = 206,
|
HEADER_CG_STATE_CHECKER = 206,
|
||||||
|
HEADER_CG_SASH = 211, // AVA2 sash
|
||||||
|
|
||||||
HEADER_CG_CLIENT_VERSION = 0xfd,
|
HEADER_CG_CLIENT_VERSION = 0xfd,
|
||||||
HEADER_CG_CLIENT_VERSION2 = 0xf1,
|
HEADER_CG_CLIENT_VERSION2 = 0xf1,
|
||||||
@@ -295,6 +296,7 @@ enum
|
|||||||
|
|
||||||
HEADER_GC_DRAGON_SOUL_REFINE = 209,
|
HEADER_GC_DRAGON_SOUL_REFINE = 209,
|
||||||
HEADER_GC_RESPOND_CHANNELSTATUS = 210,
|
HEADER_GC_RESPOND_CHANNELSTATUS = 210,
|
||||||
|
HEADER_GC_SASH = 215, // AVA2 sash
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -942,6 +944,7 @@ enum ECharacterEquipmentPart
|
|||||||
CHR_EQUIPPART_WEAPON,
|
CHR_EQUIPPART_WEAPON,
|
||||||
CHR_EQUIPPART_HEAD,
|
CHR_EQUIPPART_HEAD,
|
||||||
CHR_EQUIPPART_HAIR,
|
CHR_EQUIPPART_HAIR,
|
||||||
|
CHR_EQUIPPART_SASH,
|
||||||
CHR_EQUIPPART_NUM,
|
CHR_EQUIPPART_NUM,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1144,6 +1147,33 @@ typedef struct packet_item_set
|
|||||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
} TPacketGCItemSet;
|
} 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;
|
||||||
|
|
||||||
typedef struct packet_item_del
|
typedef struct packet_item_del
|
||||||
{
|
{
|
||||||
BYTE header;
|
BYTE header;
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ CPacketInfoCG::CPacketInfoCG()
|
|||||||
// Set(HEADER_CG_XTRAP_ACK, sizeof(TPacketXTrapCSVerify), "XTrapResponse", false);
|
// Set(HEADER_CG_XTRAP_ACK, sizeof(TPacketXTrapCSVerify), "XTrapResponse", false);
|
||||||
Set(HEADER_CG_DRAGON_SOUL_REFINE, sizeof(TPacketCGDragonSoulRefine), "DragonSoulRefine", false);
|
Set(HEADER_CG_DRAGON_SOUL_REFINE, sizeof(TPacketCGDragonSoulRefine), "DragonSoulRefine", false);
|
||||||
Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false);
|
Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false);
|
||||||
|
Set(HEADER_CG_SASH, sizeof(TPacketSash), "Sash", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,245 @@
|
|||||||
|
#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 "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;}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
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(!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 || !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(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);
|
||||||
|
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()>=3)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;
|
||||||
|
if(!info && !close && !claim){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(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,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,190 @@
|
|||||||
|
// 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, the switchbot and the attribute lock never touch a
|
||||||
|
// talisman, and drops carry no magic attributes.
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,106 @@
|
|||||||
|
// 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 switchbot and 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
@@ -83,7 +83,7 @@ static LPITEM PortSwitchItem(LPCHARACTER ch,const PortSwitchbot& bot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool PortSwitchScroll(LPITEM scroll) {
|
static bool PortSwitchScroll(LPITEM scroll) {
|
||||||
return scroll && scroll->GetType()==ITEM_USE && scroll->GetSubType()==USE_CHANGE_ATTRIBUTE;
|
return scroll && scroll->GetType()==ITEM_USE && scroll->GetSubType()==USE_CHANGE_ATTRIBUTE && !scroll->IsCostumeEnchant() && !scroll->GetPendantScrollKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PortSwitchState(LPCHARACTER ch,const PortSwitchbot* bot,bool active,const char* reason) {
|
static void PortSwitchState(LPCHARACTER ch,const PortSwitchbot* bot,bool active,const char* reason) {
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ std::vector<PortWikiRow> ITEM_MANAGER::PortWikiDrops(DWORD race) {
|
|||||||
if (mob->m_table.bRank<MOB_RANK_MAX_NUM)
|
if (mob->m_table.bRank<MOB_RANK_MAX_NUM)
|
||||||
for (const auto& row:g_vec_pkCommonDropItem[mob->m_table.bRank])
|
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);
|
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);
|
auto drop=m_map_pkDropItemGroup.find(race);
|
||||||
if (drop!=m_map_pkDropItemGroup.end() && drop->second)
|
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);
|
for (const auto& row:drop->second->GetVector()) add(row.dwVnum,row.iCount,WIKI_DROP,0,0,row.dwPct,0);
|
||||||
|
|||||||
@@ -1158,6 +1158,21 @@ namespace quest
|
|||||||
return 0;
|
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)
|
int pc_get_empire(lua_State* L)
|
||||||
{
|
{
|
||||||
lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetEmpire());
|
lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetEmpire());
|
||||||
@@ -2885,6 +2900,7 @@ teleport_area:
|
|||||||
{ "in_dungeon", pc_in_dungeon },
|
{ "in_dungeon", pc_in_dungeon },
|
||||||
{ "getempire", pc_get_empire },
|
{ "getempire", pc_get_empire },
|
||||||
{ "get_empire", pc_get_empire },
|
{ "get_empire", pc_get_empire },
|
||||||
|
{ "open_sash", pc_open_sash },
|
||||||
{ "get_skill_group", pc_get_skillgroup },
|
{ "get_skill_group", pc_get_skillgroup },
|
||||||
{ "set_skill_group", pc_set_skillgroup },
|
{ "set_skill_group", pc_set_skillgroup },
|
||||||
{ "warp", pc_warp },
|
{ "warp", pc_warp },
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "mob_manager.h"
|
#include "mob_manager.h"
|
||||||
#include "locale_service.h"
|
#include "locale_service.h"
|
||||||
#include "unique_item.h"
|
#include "unique_item.h"
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
|
|
||||||
// MT: the sockets ITEM_MANAGER::CreateItem gives a new item of this vnum (its remaining time), sent
|
// MT: the sockets ITEM_MANAGER::CreateItem gives a new item of this vnum (its remaining time), sent
|
||||||
// with an NPC shop's items so the client tooltip shows how long a bought one lasts instead of 0.
|
// with an NPC shop's items so the client tooltip shows how long a bought one lasts instead of 0.
|
||||||
@@ -341,6 +342,8 @@ int CShop::Buy(LPCHARACTER ch, BYTE pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch->PointChange(POINT_GOLD, -dwPrice, false);
|
ch->PointChange(POINT_GOLD, -dwPrice, false);
|
||||||
|
if (!m_pkPC)
|
||||||
|
PortBpCount(ch, PORT_BP_NPC_SPEND, 0, dwPrice); // PORT: battle pass, NPC shops only
|
||||||
|
|
||||||
//¼¼±Ý °è»ê
|
//¼¼±Ý °è»ê
|
||||||
DWORD dwTax = 0;
|
DWORD dwTax = 0;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include "shop_manager.h"
|
#include "shop_manager.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include "port_battlepass_hooks.h"
|
||||||
|
|
||||||
CShopManager::CShopManager()
|
CShopManager::CShopManager()
|
||||||
{
|
{
|
||||||
@@ -347,6 +348,7 @@ void CShopManager::Sell(LPCHARACTER ch, BYTE bCell, BYTE bCount)
|
|||||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("판매금액의 %d %% 가 세금으로 나가게됩니다"), iVal);
|
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("판매금액의 %d %% 가 세금으로 나가게됩니다"), iVal);
|
||||||
|
|
||||||
DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), dwPrice);
|
DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), dwPrice);
|
||||||
|
PortBpCount(ch, PORT_BP_NPC_SELL, item->GetVnum(), bCount); // PORT: battle pass
|
||||||
|
|
||||||
if (bCount == item->GetCount())
|
if (bCount == item->GetCount())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 bonus numbering: the stone/boss applies the AVA2 stones and guardian weapons carry (docs/FEATURE-AVA2-UNLOCK.md)."""
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
|
||||||
|
length=source('common/length.h')
|
||||||
|
enum=length[length.index('enum EApplyTypes'):] if 'enum EApplyTypes' in length else length[length.index('APPLY_NONE'):]
|
||||||
|
enum=enum[:enum.index('MAX_APPLY_NUM')]
|
||||||
|
assert 'APPLY_ATTBONUS_STONE = 139,' in enum and 'APPLY_ATTBONUS_BOSS = 140,' in enum and enum.rstrip().endswith('= 140,')
|
||||||
|
|
||||||
|
# the db reads apply names by position, so the array index is the apply number
|
||||||
|
reader=source('db/src/ProtoReader.cpp')
|
||||||
|
names=re.findall(r'"([^"]+)"',re.search(r'arApplyType\[\]\s*=\s*\{(.*?)\};',reader,re.S).group(1))
|
||||||
|
assert len(names)==141 and names[91]=='APPLY_ANTI_PENETRATE_PCT' and names[139:]==['APPLY_ATTBONUS_STONE','APPLY_ATTBONUS_BOSS'],names[88:]
|
||||||
|
|
||||||
|
# aApplyInfo is indexed by apply number: 141 rows, the two new ones mapped to the biolog points
|
||||||
|
constants=source('game/src/constants.cpp')
|
||||||
|
table=constants[constants.index('aApplyInfo[MAX_APPLY_NUM]'):]
|
||||||
|
table=table[table.index('{')+1:table.index('};')]
|
||||||
|
rows=re.findall(r'\{\s*(POINT_[A-Z_]+)',table)
|
||||||
|
assert len(rows)==141 and rows[139:]==['POINT_ATTBONUS_STONE','POINT_ATTBONUS_BOSS'] and set(rows[92:123]+rows[129:139])=={'POINT_NONE'},len(rows)
|
||||||
|
ELEM=('ELEC','FIRE','ICE','WIND','EARTH','DARK')
|
||||||
|
# P7 talisman: APPLY_ENCHANT_* 123-128 (AVA2 names, ELECT for the db) -> POINT_ENCHANT_* 242-247
|
||||||
|
assert rows[123:129]==['POINT_ENCHANT_'+e for e in ELEM],rows[123:129]
|
||||||
|
assert names[123:129]==['APPLY_ENCHANT_'+('ELECT' if e=='ELEC' else e) for e in ELEM],names[123:129]
|
||||||
|
assert '"ATTBONUS_STONE",\tAPPLY_ATTBONUS_STONE' in constants and '"ATTBONUS_BOSS",\tAPPLY_ATTBONUS_BOSS' in constants
|
||||||
|
|
||||||
|
char=source('game/src/char.cpp')
|
||||||
|
apply=char[char.index('void CHARACTER::ApplyPoint('):char.index('void CHARACTER::MotionPacketEncode(')]
|
||||||
|
assert all('case APPLY_ENCHANT_%s:'%e in apply for e in ELEM)
|
||||||
|
assert 'case APPLY_ATTBONUS_STONE:' in apply and 'case APPLY_ATTBONUS_BOSS:' in apply
|
||||||
|
points=source('game/src/char.h')
|
||||||
|
assert all('POINT_ENCHANT_%s = %d,'%(e,242+i) in points for i,e in enumerate(ELEM)),'enchant points'
|
||||||
|
assert 'POINT_ATTBONUS_STONE = 240,' in points and 'POINT_ATTBONUS_BOSS = 241,' in points
|
||||||
|
battle=source('game/src/battle.cpp')
|
||||||
|
assert all('GetPoint(POINT_ENCHANT_%s)'%e in battle for e in ELEM) and 'RACE_FLAG_ATT_ICE' in battle
|
||||||
|
assert 'GetPoint(POINT_ATTBONUS_STONE)' in battle and 'GetPoint(POINT_ATTBONUS_BOSS)' in battle
|
||||||
|
print('PASS: stone/boss applies 139/140 in the db reader, aApplyInfo, apply names and ApplyPoint')
|
||||||
@@ -0,0 +1,272 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Battle pass: the wiring of the hooks, then the production headers compiled against stubs of the characters,
|
||||||
|
the bag, the item table and an in-memory player database (ordered async queue plus synchronous direct queries)."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server/game/src'
|
||||||
|
TSV=ROOT/'tools/battlepass/port_battlepass.tsv'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
cmd=source('cmd.cpp')
|
||||||
|
assert 'ACMD(do_port_bp);' in cmd
|
||||||
|
entry=cmd.index('{ "mt_bp", do_port_bp, 0, POS_DEAD, GM_PLAYER },')
|
||||||
|
assert entry<cmd.index('{ "\\n",',entry) and cmd.count('"mt_bp"')==1
|
||||||
|
general=source('cmd_general.cpp')
|
||||||
|
assert '#include "port_battlepass_runtime.h"' in general and 'PortBpCommand(ch, argument);' in general
|
||||||
|
for name in ('char.cpp','char_battle.cpp','char_item.cpp','fishing.cpp','shop.cpp','shop_manager.cpp'):
|
||||||
|
assert '#include "port_battlepass_hooks.h"' in source(name),name
|
||||||
|
assert '#include "port_battlepass_runtime.h"' not in source(name),name
|
||||||
|
battle=source('char_battle.cpp')
|
||||||
|
reward=battle.index('void CHARACTER::Reward(bool bItemDrop)')
|
||||||
|
assert reward<battle.index('PortBpKill(pkAttacker, this);')<battle.index('quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());',reward)
|
||||||
|
assert battle.count('PortBpKill(')==1
|
||||||
|
item=source('char_item.cpp')
|
||||||
|
assert item.count('PortBpCount(this, PORT_BP_REFINE, pkNewItem->GetVnum(), 1);')==2==item.count('"REFINE SUCCESS"')
|
||||||
|
assert '#endif\n#include "port_premium.h"\n#include "port_battlepass_hooks.h"\n' in item # outside __AUCTION__
|
||||||
|
fishing=source('fishing.cpp')
|
||||||
|
assert fishing.index('FishingSuccess(ch);\n\t\t\t\t\tPortBpCount(ch, PORT_BP_CATCH_FISH, item_vnum, 1);')>fishing.index('void Take(')
|
||||||
|
shop=source('shop.cpp')
|
||||||
|
assert 'ch->PointChange(POINT_GOLD, -dwPrice, false);\n\tif (!m_pkPC)\n\t\tPortBpCount(ch, PORT_BP_NPC_SPEND, 0, dwPrice);' in shop
|
||||||
|
sell=source('shop_manager.cpp')
|
||||||
|
assert sell.index('void CShopManager::Sell(')<sell.index('PortBpCount(ch, PORT_BP_NPC_SELL, item->GetVnum(), bCount);')
|
||||||
|
char=source('char.cpp')
|
||||||
|
save=char.index('void CHARACTER::SaveReal()')
|
||||||
|
assert save<char.index('PortBpSave(this);')<char.index('void CHARACTER::FlushDelayedSaveItem()')
|
||||||
|
disc=char.index('void CHARACTER::Disconnect(')
|
||||||
|
assert char.index('SaveAffect();',disc)<char.index('PortBpLogout(this);',disc)<char.index('m_bSkipSave = true;',disc)
|
||||||
|
level=char.index('case POINT_LEVEL:')
|
||||||
|
assert level<char.index('PortBpCount(this, PORT_BP_LEVEL_UP, 0, amount);',level)<char.index('quest::CQuestManager::instance().LevelUp(GetPlayerID());',level)
|
||||||
|
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <deque>
|
||||||
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
#include <vector>
|
||||||
|
using DWORD=unsigned;using BYTE=unsigned char;using WORD=unsigned short;
|
||||||
|
enum {CHAT_TYPE_INFO=1,CHAT_TYPE_COMMAND=5,MOB_RANK_BOSS=4,ITEM_DS=29,ITEM_FLAG_STACKABLE=1<<2,ITEM_ANTIFLAG_STACK=1<<15,
|
||||||
|
ITEM_MAX_COUNT=200,INVENTORY=1,INVENTORY_PAGE_SIZE=45,INVENTORY_MAX_NUM=225};
|
||||||
|
#define IS_SET(flag,bit) ((flag)&(bit))
|
||||||
|
static long long now=1790900000;static DWORD clockms=1000;
|
||||||
|
long long get_global_time(){return now;}DWORD get_dword_time(){return clockms;}
|
||||||
|
static std::string basePath;std::string LocaleService_GetBasePath(){return basePath;}
|
||||||
|
static std::vector<std::string> logs;
|
||||||
|
void sys_log(int,const char* f,...){char o[1024];va_list a;va_start(a,f);vsnprintf(o,sizeof(o),f,a);va_end(a);logs.push_back(o);}
|
||||||
|
void sys_err(const char* f,...){char o[1024];va_list a;va_start(a,f);vsnprintf(o,sizeof(o),f,a);va_end(a);logs.push_back(std::string("ERR ")+o);}
|
||||||
|
static std::string format(const char* f,va_list a){char o[8192];vsnprintf(o,sizeof(o),f,a);return o;}
|
||||||
|
struct TItemPos{BYTE window_type;WORD cell;TItemPos(BYTE w,WORD c):window_type(w),cell(c){}};
|
||||||
|
struct TItemTable{BYTE bType,bSize;DWORD dwFlags,dwAntiFlags;};
|
||||||
|
// --- player database
|
||||||
|
static std::map<std::tuple<DWORD,DWORD,DWORD>,std::pair<unsigned long long,unsigned long long>> progress; // value,target
|
||||||
|
static std::set<std::tuple<DWORD,DWORD,DWORD>> claims;
|
||||||
|
static bool dbDown=false;
|
||||||
|
using MYSQL_ROW=char**;
|
||||||
|
struct Result{std::vector<std::vector<std::string>> rows;size_t next=0;std::vector<char*> cells;};
|
||||||
|
struct SQLResult{unsigned uiNumRows=0,uiAffectedRows=0;Result* pSQLResult=nullptr;};
|
||||||
|
struct SQLMsg{SQLResult result;Result data;bool ok=true;SQLResult* Get(){return ok?&result:nullptr;}};
|
||||||
|
MYSQL_ROW mysql_fetch_row(Result* r){
|
||||||
|
if(r->next>=r->rows.size())return nullptr;auto& row=r->rows[r->next++];r->cells.clear();
|
||||||
|
for(auto& c:row)r->cells.push_back(&c[0]);return r->cells.data();}
|
||||||
|
static int selects=0;
|
||||||
|
struct DBManager{
|
||||||
|
std::deque<std::function<void()>> queue;std::vector<std::string> queries;
|
||||||
|
static DBManager& instance(){static DBManager m;return m;}
|
||||||
|
void Query(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
||||||
|
queue.push_back([q]{
|
||||||
|
assert(q.rfind("INSERT INTO player.mt_battlepass_progress (pid,season,slot,value,target) VALUES (",0)==0);
|
||||||
|
assert(q.find("ON DUPLICATE KEY UPDATE value=LEAST(value+VALUES(value),VALUES(target)),target=VALUES(target)")!=std::string::npos);
|
||||||
|
const char* p=q.c_str()+q.find("VALUES (")+7;unsigned pid,season,slot;unsigned long long v,t;int n;
|
||||||
|
while(sscanf(p,"(%u,%u,%u,%llu,%llu)%n",&pid,&season,&slot,&v,&t,&n)==5){
|
||||||
|
auto& row=progress[std::make_tuple(pid,season,slot)];row.first=std::min(row.first+v,t);row.second=t;p+=n;if(*p==',')++p;else break;}
|
||||||
|
});}
|
||||||
|
template<class F> void FuncQuery(F f,const char* fmt,...){va_list a;va_start(a,fmt);std::string q=format(fmt,a);va_end(a);queries.push_back(q);++selects;
|
||||||
|
queue.push_back([f,q]{unsigned pid,season,pid2,season2;
|
||||||
|
assert(sscanf(q.c_str(),"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,&pid2,&season2)==4);
|
||||||
|
assert(pid==pid2 && season==season2);
|
||||||
|
SQLMsg m;m.ok=!dbDown;m.result.pSQLResult=&m.data;
|
||||||
|
for(auto& e:progress)if(std::get<0>(e.first)==pid && std::get<1>(e.first)==season)
|
||||||
|
m.data.rows.push_back({"p",std::to_string(std::get<2>(e.first)),std::to_string(e.second.first)});
|
||||||
|
for(auto& e:claims)if(std::get<0>(e)==pid && std::get<1>(e)==season)m.data.rows.push_back({"c",std::to_string(std::get<2>(e)),"0"});
|
||||||
|
m.result.uiNumRows=unsigned(m.data.rows.size());f(&m);});}
|
||||||
|
SQLMsg* DirectQuery(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
||||||
|
SQLMsg* m=new SQLMsg;m->ok=!dbDown;unsigned pid,season,slot;long long at;
|
||||||
|
assert(sscanf(q.c_str(),"INSERT IGNORE INTO player.mt_battlepass_claim (pid,season,slot,claimed_at) VALUES (%u,%u,%u,%lld)",&pid,&season,&slot,&at)==4 && at==now);
|
||||||
|
if(m->ok)m->result.uiAffectedRows=claims.insert(std::make_tuple(pid,season,slot)).second?1:0;
|
||||||
|
return m;}
|
||||||
|
void Run(){while(!queue.empty()){auto job=queue.front();queue.pop_front();job();}}
|
||||||
|
};
|
||||||
|
// --- characters, bag and items
|
||||||
|
class CHARACTER;
|
||||||
|
struct CItem{DWORD vnum,count;CHARACTER* owner=nullptr;unsigned cell=0;bool AddToCharacter(CHARACTER* ch,TItemPos pos);DWORD GetVnum(){return vnum;}};
|
||||||
|
using LPITEM=CItem*;
|
||||||
|
struct DESC{};
|
||||||
|
class CHARACTER{public:
|
||||||
|
DESC desc;bool online=true,pc=true,stone=false;DWORD pid=7,race=101;int level=50;BYTE rank=0;int saves=0;
|
||||||
|
std::vector<std::string> messages;std::vector<bool> used=std::vector<bool>(INVENTORY_MAX_NUM,false);std::vector<CItem*> bag;
|
||||||
|
const char* GetName(){return "Admin";}bool IsPC(){return pc;}DESC* GetDesc(){return online?&desc:nullptr;}DWORD GetPlayerID(){return pid;}
|
||||||
|
int GetLevel(){return level;}bool IsStone(){return stone;}BYTE GetMobRank(){return rank;}DWORD GetRaceNum(){return race;}
|
||||||
|
bool IsEmptyItemGrid(TItemPos p,BYTE size){assert(p.window_type==INVENTORY && size==1);return !used[p.cell];}
|
||||||
|
void Save(){++saves;}
|
||||||
|
void ChatPacket(BYTE type,const char* f,...){va_list a;va_start(a,f);std::string s=format(f,a);va_end(a);assert(type==CHAT_TYPE_COMMAND);messages.push_back(s);}
|
||||||
|
};
|
||||||
|
using LPCHARACTER=CHARACTER*;
|
||||||
|
static std::map<DWORD,TItemTable> tables={{70043,{1,1,0,0}},{71153,{3,1,ITEM_FLAG_STACKABLE,0}},{25041,{3,1,ITEM_FLAG_STACKABLE,0}},
|
||||||
|
{71032,{3,1,ITEM_FLAG_STACKABLE,0}},{50513,{3,1,ITEM_FLAG_STACKABLE,0}},{27992,{3,1,ITEM_FLAG_STACKABLE,0}},{27993,{3,1,ITEM_FLAG_STACKABLE,0}},
|
||||||
|
{27994,{3,1,ITEM_FLAG_STACKABLE,0}},{70024,{3,1,ITEM_FLAG_STACKABLE,0}},{19,{1,2,0,0}},{11299,{2,3,0,0}},{110000,{ITEM_DS,1,0,0}},
|
||||||
|
{71084,{3,1,ITEM_FLAG_STACKABLE,ITEM_ANTIFLAG_STACK}},{71094,{3,1,ITEM_FLAG_STACKABLE,0}},{27987,{3,1,ITEM_FLAG_STACKABLE,0}},
|
||||||
|
{25040,{3,1,ITEM_FLAG_STACKABLE,0}}};
|
||||||
|
bool CItem::AddToCharacter(CHARACTER* ch,TItemPos pos){
|
||||||
|
const unsigned size=tables[vnum].bSize;
|
||||||
|
for(unsigned k=0;k<size;++k){assert(pos.cell+5*k<INVENTORY_MAX_NUM && !ch->used[pos.cell+5*k]);ch->used[pos.cell+5*k]=true;}
|
||||||
|
assert(pos.cell/45==(pos.cell+5*(size-1))/45);owner=ch;cell=pos.cell;ch->bag.push_back(this);return true;}
|
||||||
|
static int flushedItems=0;
|
||||||
|
struct ITEM_MANAGER{static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;}
|
||||||
|
TItemTable* GetTable(DWORD v){auto it=tables.find(v);return it==tables.end()?nullptr:&it->second;}
|
||||||
|
LPITEM CreateItem(DWORD v,DWORD c){return new CItem{v,c};}
|
||||||
|
void FlushDelayedSave(LPITEM){++flushedItems;}};
|
||||||
|
static std::vector<std::string> itemlog;
|
||||||
|
struct LogManager{static LogManager& instance(){static LogManager m;return m;}
|
||||||
|
void ItemLog(LPCHARACTER,LPITEM item,const char* what,const char* hint){itemlog.push_back(std::string(what)+" "+std::to_string(item->vnum)+"x"+std::to_string(item->count)+" "+hint);}};
|
||||||
|
static std::map<DWORD,CHARACTER*> online;
|
||||||
|
struct CHARACTER_MANAGER{static CHARACTER_MANAGER& instance(){static CHARACTER_MANAGER m;return m;}
|
||||||
|
LPCHARACTER FindByPID(DWORD pid){auto it=online.find(pid);return it==online.end()?nullptr:it->second;}};
|
||||||
|
#include "port_battlepass_runtime.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
static DBManager& db=DBManager::instance();
|
||||||
|
static void tick(unsigned ms=1000){clockms+=ms;}
|
||||||
|
static std::string Last(CHARACTER* c){return c->messages.empty()?"":c->messages.back();}
|
||||||
|
static bool Said(CHARACTER* c,const std::string& line,size_t from=0){for(size_t i=from;i<c->messages.size();++i)if(c->messages[i]==line)return true;return false;}
|
||||||
|
static void WriteConfig(const std::string& text){std::ofstream(basePath+"/port_battlepass.tsv.tmp")<<text;
|
||||||
|
std::rename((basePath+"/port_battlepass.tsv.tmp").c_str(),(basePath+"/port_battlepass.tsv").c_str());tick(5001);}
|
||||||
|
static void Kill(CHARACTER* a,DWORD race,BYTE rank=0,bool stone=false,int level=50){CHARACTER m;m.pc=false;m.race=race;m.rank=rank;m.stone=stone;m.level=level;PortBpKill(a,&m);}
|
||||||
|
static bool Parses(const std::string& text){PortBpConfig c;std::istringstream in(text);return c.Parse(in);}
|
||||||
|
|
||||||
|
int main(int argc,char** argv){
|
||||||
|
basePath=argv[1];
|
||||||
|
// --- the shipped config
|
||||||
|
{PortBpConfig c;std::ifstream in(argv[2]);assert(c.Parse(in));assert(c.seasons.size()==15 && c.seasons[0].id==202610 && c.seasons.back().id==202712);
|
||||||
|
for(auto& s:c.seasons){assert(s.missions.size()==8 && s.final.size()==4);for(auto& m:s.missions)for(auto& r:m.rewards)assert(tables.count(r.vnum));
|
||||||
|
for(auto& r:s.final)assert(tables.count(r.vnum));}
|
||||||
|
assert(c.seasons[0].end==c.seasons[1].start && c.Active(1790805600)==&c.seasons[0] && !c.Active(1790805599));}
|
||||||
|
// --- config validation: any bad line disables the whole file
|
||||||
|
const std::string H="MTBATTLEPASS 1\nseason 1 100 200\n";
|
||||||
|
assert(Parses(H+"mission 1 1 0 10\n") && Parses(H+"mission 1 9 27992 10 1 1\nfinal 1 1\n"));
|
||||||
|
for(auto bad:{"mission 1 9 0 10\n","mission 1 4 5 10\n","mission 11 1 0 10\n","mission 1 1 0 10\nmission 1 2 0 10\n","mission 1 1 0 10 1 1 2 2 3 3 4 4\n",
|
||||||
|
"mission 1 1 0 10\nfinal 1 1\nfinal 1 1\n","mission 1 1 0 0\n","mission 1 10 0 10\n","mission 1 1 0 10\nbogus\n","mission 1 1 0 10 5\n",
|
||||||
|
"mission 1 1 0 10 5 0\n","mission 1 1 0 x\n","mission 1 1 0 10\nfinal\n"})assert(!Parses(H+bad));
|
||||||
|
assert(!Parses("MTBATTLEPASS 2\n") && !Parses(H) && !Parses("MTBATTLEPASS 1\nmission 1 1 0 10\n"));
|
||||||
|
assert(!Parses(H+"mission 1 1 0 10\nseason 2 150 300\nmission 1 1 0 10\n") && Parses(H+"mission 1 1 0 10\nseason 2 200 300\nmission 1 1 0 10\n"));
|
||||||
|
// --- bag fit: first fit in GetEmptyInventory order, a tall item stays inside its page
|
||||||
|
{std::vector<bool> free(90,true);std::vector<unsigned> cells;
|
||||||
|
for(unsigned c=0;c<45;++c)if(c<40)free[c]=false; // first page: only its last row (40..44) is free
|
||||||
|
assert(PortBpFit(free,45,5,{1,3,1},cells) && cells==std::vector<unsigned>({40,45,41}));
|
||||||
|
std::vector<bool> none(45,false);none[44]=true;assert(!PortBpFit(none,45,5,{2},cells));}
|
||||||
|
|
||||||
|
// --- no file: no season
|
||||||
|
CHARACTER* a=new CHARACTER;online[7]=a;
|
||||||
|
PortBpCommand(a,"1 info");assert(Last(a)=="MTBP1 none");Kill(a,101);db.Run();assert(progress.empty() && PortBpStates().empty());
|
||||||
|
// --- a season running now with small targets
|
||||||
|
const std::string cfg="MTBATTLEPASS 1\nseason 77 "+std::to_string(now-100)+" "+std::to_string(now+100000)+"\n"
|
||||||
|
"mission 1 1 0 5 70043 1 71153 450\nmission 2 2 0 2 25041 2\nmission 3 3 0 1 11299 1\nmission 4 4 0 3600 71032 1\n"
|
||||||
|
"mission 5 1 2493 2 19 3\nmission 6 7 0 2 110000 1\nfinal 27992 2 27993 1 27994 1 70024 1\n"
|
||||||
|
"season 78 "+std::to_string(now+100000)+" "+std::to_string(now+200000)+"\nmission 1 1 0 5 70043 1\n";
|
||||||
|
WriteConfig(cfg);
|
||||||
|
// info before the load answers once it arrives; counting before the load is kept
|
||||||
|
PortBpCommand(a,"1 info");assert(a->messages.size()==1 && PortBpStates()[7].wantInfo);
|
||||||
|
Kill(a,101);Kill(a,101);
|
||||||
|
db.Run();assert(Said(a,"MTBP1 season 77 "+std::to_string(now-100)+" "+std::to_string(now+100000)+" "+std::to_string(now)+" 6"));
|
||||||
|
assert(Said(a,"MTBP1 mission 1 1 0 5 2 0 70043 1 71153 450") && Said(a,"MTBP1 final 0 0 27992 2 27993 1 27994 1 70024 1") && Last(a)=="MTBP1 end");
|
||||||
|
// kill kinds: normal / boss / stone / level gap / specific vnum / a player victim
|
||||||
|
size_t mark=a->messages.size();
|
||||||
|
Kill(a,101);assert(Last(a)=="MTBP1 progress 1 3");
|
||||||
|
Kill(a,691,MOB_RANK_BOSS);assert(Last(a)=="MTBP1 progress 2 1");
|
||||||
|
Kill(a,8001,0,true);assert(Said(a,"MTBP1 progress 3 1",mark) && Last(a)=="MTBP1 done 3");
|
||||||
|
Kill(a,101,0,false,71);Kill(a,101,0,false,29);assert(PortBpStates()[7].Value(*PortBpConfigFile().seasons[0].Slot(1))==3);
|
||||||
|
Kill(a,101,0,false,70);assert(Last(a)=="MTBP1 progress 1 4");
|
||||||
|
Kill(a,2493,MOB_RANK_BOSS);assert(Said(a,"MTBP1 progress 2 2",mark) && Last(a)=="MTBP1 done 2" && !Said(a,"MTBP1 progress 5 1",mark));
|
||||||
|
{CHARACTER pc;pc.pid=8;PortBpKill(a,&pc);CHARACTER mob;mob.pc=false;PortBpKill(&mob,a);}
|
||||||
|
// a boss of the specific vnum counts for slot 5 only through its own kind: slot 5 is "kill monster 2493"
|
||||||
|
assert(PortBpStates()[7].Value(*PortBpConfigFile().seasons[0].Slot(5))==0);
|
||||||
|
// close stops the progress pushes; a finished mission is still announced
|
||||||
|
PortBpCommand(a,"1 close");mark=a->messages.size();Kill(a,101);assert(Last(a)=="MTBP1 done 1" && a->messages.size()==mark+1);
|
||||||
|
// 2493 counts for its own slot (any-monster slot 1 is full already)
|
||||||
|
mark=a->messages.size();Kill(a,2493);Kill(a,2493);Kill(a,2493);
|
||||||
|
assert(PortBpStates()[7].Value(*PortBpConfigFile().seasons[0].Slot(5))==2 && a->messages.size()==mark+1 && Last(a)=="MTBP1 done 5");
|
||||||
|
// --- save writes deltas additively, capped in the database
|
||||||
|
a->saves=0;PortBpSave(a);db.Run();
|
||||||
|
assert(progress[std::make_tuple(7u,77u,1u)].first==5 && progress[std::make_tuple(7u,77u,2u)].first==2 && progress[std::make_tuple(7u,77u,3u)].first==1);
|
||||||
|
const size_t queries=db.queries.size();PortBpSave(a);db.Run();assert(db.queries.size()==queries); // nothing new, no query
|
||||||
|
// play time: an hour online
|
||||||
|
tick(3600*1000);PortBpSave(a);db.Run();assert(progress[std::make_tuple(7u,77u,4u)].first==3600);
|
||||||
|
// --- claims
|
||||||
|
tick();PortBpCommand(a,"1 claim 6");assert(Said(a,"MTBP1 error incomplete"));
|
||||||
|
tick();PortBpCommand(a,"1 claim 1");
|
||||||
|
assert(Said(a,"MTBP1 claimed 1") && claims.count(std::make_tuple(7u,77u,1u)) && a->bag.size()==1+3); // 70043 + 200,200,50
|
||||||
|
assert(a->bag[1]->vnum==71153 && a->bag[1]->count==200 && a->bag[3]->count==50 && itemlog.back()=="MT_BP_CLAIM 71153x50 77 1" && flushedItems==4);
|
||||||
|
assert(Said(a,"MTBP1 mission 1 1 0 5 5 1 70043 1 71153 450"));
|
||||||
|
PortBpCommand(a,"1 claim 1");assert(Last(a)=="MTBP1 error rate");
|
||||||
|
tick();PortBpCommand(a,"1 claim 1");assert(Said(a,"MTBP1 error claimed") && a->bag.size()==4);
|
||||||
|
// another core already paid slot 2: the insert finds the row and nothing is given
|
||||||
|
claims.insert(std::make_tuple(7u,77u,2u));tick();PortBpCommand(a,"1 claim 2");assert(Said(a,"MTBP1 error claimed") && a->bag.size()==4);
|
||||||
|
// the database is down: no items
|
||||||
|
dbDown=true;tick();PortBpCommand(a,"1 claim 3");assert(Said(a,"MTBP1 error db") && a->bag.size()==4);dbDown=false;
|
||||||
|
claims.erase(std::make_tuple(7u,77u,3u));PortBpStates()[7].claimed.erase(3);
|
||||||
|
// full bag: the size-3 armor does not fit, no claim row
|
||||||
|
for(unsigned c=0;c<INVENTORY_MAX_NUM;++c)if(c%45<35)a->used[c]=true;
|
||||||
|
tick();PortBpCommand(a,"1 claim 3");assert(Said(a,"MTBP1 error space") && !claims.count(std::make_tuple(7u,77u,3u)));
|
||||||
|
for(unsigned c=0;c<INVENTORY_MAX_NUM;++c)if(c%45<35 && c>=45)a->used[c]=false;
|
||||||
|
tick();PortBpCommand(a,"1 claim 3");assert(Said(a,"MTBP1 claimed 3") && a->bag.back()->vnum==11299 && a->bag.back()->cell==45);
|
||||||
|
// a dragon soul stone in the config is refused at claim time (and logged), the slot stays claimable
|
||||||
|
{PortBpState& s=PortBpStates()[7];s.delta[6]=2;}
|
||||||
|
tick();PortBpCommand(a,"1 claim 6");assert(Said(a,"MTBP1 error config") && !claims.count(std::make_tuple(7u,77u,6u)));
|
||||||
|
assert(logs.back()=="ERR PORT_BP: season 77 slot 6 has a reward that cannot go to the bag");
|
||||||
|
// the final reward needs every mission
|
||||||
|
tick();PortBpCommand(a,"1 claim 0");assert(Said(a,"MTBP1 error incomplete"));
|
||||||
|
tick();PortBpCommand(a,"1 claim 11");assert(Said(a,"MTBP1 error slot"));
|
||||||
|
for(auto bad:{"1 claim","1 claim x","1 claim 123","1 open"}){tick();mark=a->messages.size();PortBpCommand(a,bad);assert(a->messages.size()==mark+1 && Last(a)=="MTBP1 error invalid");}
|
||||||
|
mark=a->messages.size();PortBpCommand(a,"2 info");PortBpCommand(a,"1 a b c");PortBpCommand(a,"1 claim 1 2");PortBpCommand(a,"1 claim 12345678901");assert(a->messages.size()==mark);
|
||||||
|
{PortBpState& s=PortBpStates()[7];for(unsigned i=1;i<=6;++i)s.delta[i]+=100000;} // everything done
|
||||||
|
tick();PortBpCommand(a,"1 claim 0");assert(Said(a,"MTBP1 claimed 0") && Said(a,"MTBP1 final 1 1 27992 2 27993 1 27994 1 70024 1"));
|
||||||
|
// --- logout writes and forgets; a new session loads the claims
|
||||||
|
PortBpSave(a);PortBpLogout(a);db.Run();assert(!PortBpStates().count(7) && progress[std::make_tuple(7u,77u,6u)].first==2);
|
||||||
|
assert(progress[std::make_tuple(7u,77u,4u)].first==3600);
|
||||||
|
tick();mark=a->messages.size();PortBpCommand(a,"1 info");db.Run();
|
||||||
|
assert(Said(a,"MTBP1 mission 1 1 0 5 5 1 70043 1 71153 450",mark) && Said(a,"MTBP1 mission 3 3 0 1 1 1 11299 1",mark) && Said(a,"MTBP1 final 1 1 27992 2 27993 1 27994 1 70024 1",mark));
|
||||||
|
// --- a flush queued before the load answers is not counted twice
|
||||||
|
CHARACTER* b=new CHARACTER;b->pid=9;online[9]=b;
|
||||||
|
progress[std::make_tuple(9u,77u,1u)]={2,5};
|
||||||
|
Kill(b,101);PortBpSave(b);Kill(b,101);db.Run();
|
||||||
|
assert(progress[std::make_tuple(9u,77u,1u)].first==3 && PortBpStates()[9].Value(*PortBpConfigFile().seasons[0].Slot(1))==4);
|
||||||
|
// a stale load (logout and back before the answer) is ignored
|
||||||
|
PortBpLogout(b);Kill(b,101);PortBpLogout(b);Kill(b,101);db.Run();
|
||||||
|
assert(PortBpStates()[9].loaded && PortBpStates()[9].Value(*PortBpConfigFile().seasons[0].Slot(1))==4); // 3 stored + 1, the lost delta of the dropped session aside
|
||||||
|
// a mission finished before the load answers is announced once the load arrives; one already stored done is not
|
||||||
|
{CHARACTER* c=new CHARACTER;c->pid=10;online[10]=c;progress[std::make_tuple(10u,77u,2u)]={2,2};
|
||||||
|
Kill(c,8001,0,true);Kill(c,691,MOB_RANK_BOSS);assert(!Said(c,"MTBP1 done 3") && !Said(c,"MTBP1 done 2"));
|
||||||
|
db.Run();assert(Said(c,"MTBP1 done 3") && !Said(c,"MTBP1 done 2"));}
|
||||||
|
// --- season change: the old season's deltas are written, the new one starts from its own rows
|
||||||
|
Kill(b,101);now+=100000;tick(5001);Kill(b,101);db.Run();
|
||||||
|
assert(progress[std::make_tuple(9u,77u,1u)].first==5 && progress.count(std::make_tuple(9u,78u,1u))==0 && PortBpStates()[9].season==78);
|
||||||
|
PortBpSave(b);db.Run();assert(progress[std::make_tuple(9u,78u,1u)].first==1);
|
||||||
|
// --- the file is removed: no season, nothing counted
|
||||||
|
std::remove((basePath+"/port_battlepass.tsv").c_str());tick(5001);mark=b->messages.size();
|
||||||
|
PortBpCommand(b,"1 info");assert(Last(b)=="MTBP1 none");
|
||||||
|
WriteConfig("MTBATTLEPASS 1\nseason 1 1 2\n");tick();PortBpCommand(b,"1 info");assert(Last(b)=="MTBP1 none" && logs.back().find("ERR PORT_BP: port_battlepass.tsv disabled: ")==0);
|
||||||
|
puts("PASS: config, fit, kills, pushes, save, play time, claims (idempotent, space, db, config), final, reload, load race, season change");
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory(prefix='mt-bp-') as folder:
|
||||||
|
path=Path(folder);(path/'test.cpp').write_text(code);(path/'locale').mkdir()
|
||||||
|
subprocess.run(['c++','-std=c++17','-Wall','-I'+str(SRC),str(path/'test.cpp'),'-o',str(path/'test')],check=True)
|
||||||
|
subprocess.run([str(path/'test'),str(path/'locale'),str(TSV)],check=True)
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compile the production batch-chest header against stubs of the original UseItem gift-box contract."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server/game/src'
|
||||||
|
cmd=(SRC/'cmd.cpp').read_bytes().decode('latin1')
|
||||||
|
assert 'ACMD(do_port_chest);' in cmd and '"mt_chest", do_port_chest, 0, POS_DEAD, GM_PLAYER' in cmd
|
||||||
|
assert '#include "port_chest.h"' in (SRC/'cmd_general.cpp').read_bytes().decode('latin1')
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using DWORD=unsigned;using BYTE=unsigned char;using WORD=unsigned short;using INT=int;
|
||||||
|
enum {ITEM_USE=3,ITEM_GIFTBOX=23,INVENTORY=1,DRAGON_SOUL_INVENTORY=3,INVENTORY_MAX_NUM=10,DRAGON_SOUL_INVENTORY_MAX_NUM=4};
|
||||||
|
enum {CHAT_TYPE_INFO=1,CHAT_TYPE_COMMAND=5};
|
||||||
|
static DWORD clockms=1000;DWORD get_dword_time(){return clockms;}
|
||||||
|
struct TItemPos{BYTE window_type;WORD cell;TItemPos(BYTE w,WORD c):window_type(w),cell(c){}};
|
||||||
|
struct CItem{DWORD vnum;int count;BYTE type;bool exchanging=false;WORD cell=0;
|
||||||
|
DWORD GetVnum(){return vnum;}int GetCount(){return count;}BYTE GetType(){return type;}bool IsExchanging(){return exchanging;}WORD GetCell(){return cell;}};
|
||||||
|
using LPITEM=CItem*;
|
||||||
|
struct CSpecialItemGroup{
|
||||||
|
enum EGiveType{NONE,GOLD,EXP,MOB,SLOW,DRAIN_HP,POISON,MOB_GROUP};
|
||||||
|
std::vector<DWORD> vnums;bool IsEmpty()const{return vnums.empty();}
|
||||||
|
bool Contains(DWORD v)const{for(DWORD x:vnums)if(x==v)return true;return false;}
|
||||||
|
};
|
||||||
|
static std::map<DWORD,CSpecialItemGroup> groups;
|
||||||
|
struct ITEM_MANAGER{static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;}
|
||||||
|
const CSpecialItemGroup* GetSpecialItemGroup(DWORD v){auto it=groups.find(v);return it==groups.end()?nullptr:&it->second;}};
|
||||||
|
struct CHARACTER{
|
||||||
|
bool m_portQuietInfo=false;std::string m_portLastInfo;
|
||||||
|
LPITEM bag[INVENTORY_MAX_NUM]={};LPITEM ds[DRAGON_SOUL_INVENTORY_MAX_NUM]={};std::vector<CItem*> owned;
|
||||||
|
int gold=0;bool dead=false,shop=false,refuse=false;int uses=0;std::vector<std::string> messages,info;
|
||||||
|
bool IsPC(){return true;}void* GetDesc(){return this;}DWORD GetPlayerID(){return 7;}
|
||||||
|
bool IsDead(){return dead;}bool IsStun()const{return false;}bool IsWarping()const{return false;}bool IsObserverMode(){return false;}
|
||||||
|
bool CanHandleItem(){return true;}void* GetExchange(){return nullptr;}void* GetMyShop(){return shop?this:nullptr;}
|
||||||
|
void* GetShopOwner(){return nullptr;}bool IsOpenSafebox(){return false;}bool IsCubeOpen(){return false;}
|
||||||
|
INT GetGold()const{return gold;}
|
||||||
|
LPITEM GetInventoryItem(WORD c)const{return c<INVENTORY_MAX_NUM?bag[c]:nullptr;}
|
||||||
|
LPITEM GetItem(TItemPos p){return p.window_type==DRAGON_SOUL_INVENTORY?ds[p.cell]:bag[p.cell];}
|
||||||
|
int GetEmptyInventory(BYTE size)const{int free=0;for(auto* i:bag)free+=!i;return free>=size?0:-1;}
|
||||||
|
int CountSpecifyItem(DWORD v)const{int n=0;for(auto* i:bag)if(i&&i->vnum==v)n+=i->count;return n;}
|
||||||
|
LPITEM Put(DWORD v,int n,BYTE t=ITEM_USE,int at=-1){
|
||||||
|
for(int c=0;c<INVENTORY_MAX_NUM;++c)if(at<0?!bag[c]:c==at){CItem* i=new CItem{v,n,t};i->cell=c;bag[c]=i;owned.push_back(i);return i;}
|
||||||
|
return nullptr;}
|
||||||
|
void ChatPacket(BYTE type,const char* format,...){
|
||||||
|
char out[513];va_list a;va_start(a,format);vsnprintf(out,sizeof(out),format,a);va_end(a);
|
||||||
|
if(m_portQuietInfo&&type==CHAT_TYPE_INFO){m_portLastInfo=out;return;}
|
||||||
|
(type==CHAT_TYPE_INFO?info:messages).emplace_back(out);
|
||||||
|
}
|
||||||
|
// Original gift-box contract: one box consumed, 100 gold + one 27001 (stacking) + a dragon soul for box 50100,
|
||||||
|
// one INFO line per reward; the DS-quest style refusal returns false with an INFO line and consumes nothing.
|
||||||
|
bool UseItem(TItemPos p){
|
||||||
|
++uses;LPITEM box=GetItem(p);assert(box && p.window_type==INVENTORY && m_portQuietInfo);
|
||||||
|
if(refuse){ChatPacket(CHAT_TYPE_INFO,"finish the dragon soul quest first");return false;}
|
||||||
|
gold+=100;ChatPacket(CHAT_TYPE_INFO,"gold 100");
|
||||||
|
if(--box->count==0)bag[p.cell]=nullptr;
|
||||||
|
bool stacked=false;for(auto* i:bag)if(i&&i->vnum==27001){++i->count;stacked=true;break;}
|
||||||
|
if(!stacked)Put(27001,1);
|
||||||
|
if(box->vnum==50100)for(auto*& d:ds)if(!d){d=new CItem{110000,1,ITEM_USE};owned.push_back(d);break;}
|
||||||
|
ChatPacket(CHAT_TYPE_INFO,"got potion");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
using LPCHARACTER=CHARACTER*;
|
||||||
|
#define ACMD(name) void name(LPCHARACTER ch,const char* argument)
|
||||||
|
#include "port_chest.h"
|
||||||
|
static CHARACTER* ch;
|
||||||
|
static void cmd(const char* text){clockms+=600;ch->messages.clear();ch->info.clear();ch->uses=0;do_port_chest(ch,text);}
|
||||||
|
static const std::string& last(){return ch->messages.back();}
|
||||||
|
static void fresh(){ch=new CHARACTER;}
|
||||||
|
int main(){
|
||||||
|
groups[50100].vnums={27001,1,110000};groups[50200].vnums={27001,CSpecialItemGroup::MOB};groups[50300].vnums={};
|
||||||
|
// Non-stacking boxes spread over cells: chosen cell first, then the others; gains summed, INFO held back.
|
||||||
|
fresh();ch->Put(50100,1,ITEM_GIFTBOX,0);ch->Put(50100,1,ITEM_GIFTBOX,4);ch->Put(50100,1,ITEM_GIFTBOX,5);
|
||||||
|
cmd("1 open 4 3");
|
||||||
|
assert(ch->messages.size()==3 && ch->messages[0]=="MTCH1 got 27001 3" && ch->messages[1]=="MTCH1 got 110000 3");
|
||||||
|
assert(last()=="MTCH1 done 50100 3 3 done 300" && ch->info.empty() && !ch->m_portQuietInfo && ch->CountSpecifyItem(50100)==0);
|
||||||
|
// Stacked box, fewer asked than held; then more asked than held -> empty.
|
||||||
|
fresh();ch->Put(50100,5,ITEM_GIFTBOX);cmd("1 open 0 2");assert(last()=="MTCH1 done 50100 2 2 done 200" && ch->bag[0]->count==3);
|
||||||
|
cmd("1 open 0 200");assert(last()=="MTCH1 done 50100 200 3 empty 300" && ch->uses==3);
|
||||||
|
// Single boxes free their own cell for the reward, so free space never shrinks.
|
||||||
|
fresh();for(int i=0;i<7;++i)ch->Put(50100,1,ITEM_GIFTBOX);
|
||||||
|
cmd("1 open 0 7");assert(last()=="MTCH1 done 50100 7 7 done 700");
|
||||||
|
// A stack + 6 fillers leaves exactly 3 free cells: the first reward takes one, then it stops at 2 free.
|
||||||
|
fresh();ch->Put(50100,7,ITEM_GIFTBOX);for(int i=0;i<6;++i)ch->Put(1,1);
|
||||||
|
cmd("1 open 0 7");assert(last()=="MTCH1 done 50100 7 1 full 100" && ch->uses==1);
|
||||||
|
cmd("1 open 0 1");assert(last()=="MTCH1 error full" && ch->uses==0);
|
||||||
|
// Refusal by the original path: stops, forwards its INFO once.
|
||||||
|
fresh();ch->Put(50100,3,ITEM_GIFTBOX);ch->refuse=true;cmd("1 open 0 3");
|
||||||
|
assert(last()=="MTCH1 done 50100 3 0 rejected 0" && ch->info.size()==1 && ch->info[0]=="finish the dragon soul quest first");
|
||||||
|
// Kinds: not a gift box, monster group box, no/empty group.
|
||||||
|
fresh();ch->Put(27001,5);cmd("1 open 0 1");assert(last()=="MTCH1 error kind");
|
||||||
|
ch->Put(50200,2,ITEM_GIFTBOX);cmd("1 open 1 1");assert(last()=="MTCH1 error kind");
|
||||||
|
ch->Put(50300,2,ITEM_GIFTBOX);cmd("1 open 2 1");assert(last()=="MTCH1 error kind");
|
||||||
|
ch->Put(50400,2,ITEM_GIFTBOX);cmd("1 open 3 1");assert(last()=="MTCH1 error kind" && ch->uses==0);
|
||||||
|
// Item, exchange, busy, validation, throttle.
|
||||||
|
cmd("1 open 9 1");assert(last()=="MTCH1 error item");
|
||||||
|
LPITEM box=ch->Put(50100,2,ITEM_GIFTBOX);box->exchanging=true;cmd("1 open 4 1");assert(last()=="MTCH1 error item");box->exchanging=false;
|
||||||
|
ch->shop=true;cmd("1 open 4 1");assert(last()=="MTCH1 error busy");ch->shop=false;
|
||||||
|
for(auto bad:{"1 open 4 0","1 open 4 201","1 open 10 1","1 open 4","1 open x 1","1 open 4 1 1","1 close 4 1","1 open 4 999999"}){cmd(bad);assert(last()=="MTCH1 error invalid");}
|
||||||
|
cmd("2 open 4 1");assert(ch->messages.empty());
|
||||||
|
cmd("1 open 4 1");assert(last()=="MTCH1 done 50100 1 1 done 100");
|
||||||
|
do_port_chest(ch,"1 open 4 1");assert(last()=="MTCH1 error rate" && ch->CountSpecifyItem(50100)==1);
|
||||||
|
cmd("1 open 4 1");assert(last()=="MTCH1 done 50100 1 1 done 100");
|
||||||
|
puts("PASS: cross-cell order, stacks, gains summary, free-cell stop, refusal, kinds, item/busy/validation/throttle");
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory(prefix='mt-chest-') as folder:
|
||||||
|
path=Path(folder);(path/'test.cpp').write_text(code)
|
||||||
|
subprocess.run(['c++','-std=c++17','-Wall','-I'+str(SRC),str(path/'test.cpp'),'-o',str(path/'test')],check=True)
|
||||||
|
subprocess.run([str(path/'test')],check=True)
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Port commands must not take over abbreviations of the original commands.
|
||||||
|
|
||||||
|
interpret_command (cmd.cpp) picks the first table entry whose name starts with the typed command
|
||||||
|
(strncmp over the typed length; do_cmd entries need an exact match). A port command placed before an
|
||||||
|
original one would steal its abbreviations, as mt_features once did with /m (mob) and /mt (mto).
|
||||||
|
"""
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
text=(ROOT/'src/server/game/src/cmd.cpp').read_bytes().decode('latin1')
|
||||||
|
table=text.split('struct command_info cmd_info[] =',1)[1]
|
||||||
|
entries=re.findall(r'\{\s*"((?:[^"\\]|\\.)*)",\s*([A-Za-z_0-9]+|NULL)',table)
|
||||||
|
assert entries[0][0]=='!RESERVED!'
|
||||||
|
end=[i for i,(name,_) in enumerate(entries) if name=='\\n']
|
||||||
|
assert end,'table sentinel not found'
|
||||||
|
entries=entries[1:end[0]]
|
||||||
|
PORT=lambda name:name.startswith('mt_')
|
||||||
|
port=[name for name,_ in entries if PORT(name)]
|
||||||
|
assert {'mt_features','mt_switchbot','mt_pickup','mt_chest'}<=set(port),port
|
||||||
|
|
||||||
|
def resolve(rows,cmd):
|
||||||
|
for name,fn in rows:
|
||||||
|
if fn=='do_cmd':
|
||||||
|
if name==cmd:return name
|
||||||
|
elif name.startswith(cmd):return name
|
||||||
|
return None
|
||||||
|
|
||||||
|
original=[(name,fn) for name,fn in entries if not PORT(name)]
|
||||||
|
for name in port:assert resolve(entries,name)==name,name
|
||||||
|
for name,_ in original:
|
||||||
|
for k in range(1,len(name)+1):
|
||||||
|
typed=name[:k]
|
||||||
|
assert resolve(entries,typed)==resolve(original,typed),'/%s now runs %s instead of %s'%(typed,resolve(entries,typed),resolve(original,typed))
|
||||||
|
for typed in ('m','mt','mo'):assert not PORT(resolve(entries,typed) or ''),typed
|
||||||
|
assert resolve(entries,'m')=='mob' and resolve(entries,'mt')=='mto'
|
||||||
|
print('cmd prefix ok: %d commands, %d port'%(len(entries),len(port)))
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 costume enchants (docs/FEATURE-AVA2-UNLOCK.md P6): 54001-54267 add one fixed attribute to a
|
||||||
|
body/hair/mount-skin costume, are routed before the 40250 switcher path and are no switchbot scroll."""
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server/game/src'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
|
||||||
|
items=source('char_item.cpp')
|
||||||
|
case=items[items.index('case USE_CHANGE_ATTRIBUTE2 :'):]
|
||||||
|
hook=case.index('if (item->IsCostumeEnchant())\n\t\t\t\t\t\t\t\treturn CostumeEnchantUse(item, item2);')
|
||||||
|
assert hook<case.index('BuffOnAttr_RemoveBuffsFromItem(item2)')<case.index('ITEM_COSTUME == item2->GetType()'),'hook must run before the costume refusal'
|
||||||
|
assert '!scroll->IsCostumeEnchant()' in source('port_switchbot.h')
|
||||||
|
assert 'port_costume_attr.cpp' in source('Makefile')
|
||||||
|
port=source('port_costume_attr.cpp')
|
||||||
|
for text in ('COSTUME_ENCHANT_VNUM_MIN = 54001','COSTUME_ENCHANT_VNUM_MAX = 54267','COSTUME_ENCHANT_MAX_ATTR = 3',
|
||||||
|
'case COSTUME_BODY:\n\t\t\treturn 1;','case COSTUME_HAIR:\n\t\t\treturn 2;','case COSTUME_MOUNT_SKIN:\n\t\t\treturn 4;',
|
||||||
|
'GetValue(2) & (1 << flag)','item->SetCount(item->GetCount() - 1);'):
|
||||||
|
assert text in port,text
|
||||||
|
codes=('target','none','equipped','full','has','done')
|
||||||
|
for code in codes:assert '"MTCATTR %s"'%code in port,code
|
||||||
|
# the add must come after every refusal
|
||||||
|
assert all(port.index('"MTCATTR %s"'%c)<port.index('item2->AddAttribute') for c in codes[:-1])
|
||||||
|
script=ROOT.parent/'metin2-client/src/platform/ScriptLib/CostumeAttrScript.inc'
|
||||||
|
if script.is_file():
|
||||||
|
s=script.read_text()
|
||||||
|
for code in codes:assert "'%s':"%code in s,code
|
||||||
|
print('PASS: costume enchant hook before switcher path, body/hair/mount-skin masks, max 3, switchbot excluded, MTCATTR codes')
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 drop tables: the table builder on fixtures, then the wiring of the ported drop code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import tempfile
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server/game/src'
|
||||||
|
spec=importlib.util.spec_from_file_location('make_drops',ROOT/'tools/ava2-drops/make_drops.py')
|
||||||
|
make_drops=importlib.util.module_from_spec(spec);spec.loader.exec_module(make_drops)
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory(prefix='mt-drops-') as folder:
|
||||||
|
base=Path(folder);ava=base/'ava';live=base/'live';out=base/'out';ava.mkdir();live.mkdir()
|
||||||
|
(ava/'mob_drop_item.txt').write_bytes(b'Group\tA\n{\n\tMob\t101\n\tType\tdrop\n\t1\t19\t1\t100\n\t2\t99999\t1\t100\n\t3\t110005\t1\t50\n}\n'
|
||||||
|
b'Group\tB\n{\n\tMob\t102\n\tType\tdrop\n\t1\t99999\t1\t100\n}\n')
|
||||||
|
(ava/'common_drop_new.txt').write_bytes(b'Group\tW\n{\n\tmap_index\t0\n\tlevel_range\t1\t12\n\t1\t19\t1\t0.03\n}\n')
|
||||||
|
(ava/'special_item_group.txt').write_bytes(b'Group\tX\r\n{\r\n\tVnum\t50011\r\n\t1\t19\t5\t2\r\n}\r\n'
|
||||||
|
b'Group\tGM\n{\n\tVnum\t50035\n\tType\tPct\n\t1\t19\t2000\t100\n}\n'
|
||||||
|
b'Group\tNew\n{\n\tVnum\t77900\n\t1\t99999\t1\t30\n\t2\t19\t1\t30\n}\n')
|
||||||
|
(live/'special_item_group.txt').write_bytes(b'Group\t\xc0\xcc\n{\n\tVnum\t50011\n\t1\t\xb0\xe6 \xc7\xe8\t1\t1\n}\n'
|
||||||
|
b'Group\tKid\n{\n\tVnum\t50035\n\t1\t19\t1\t1\n}\n'
|
||||||
|
b'Group\tOld\n{\n\tVnum\t10000\n\t1\t19\t1\t1\n}\n')
|
||||||
|
(base/'proto.txt').write_bytes(b'VNUM\tNAME\n19\tsword\n110000~110099\tds\n')
|
||||||
|
report=make_drops.build(ava,live,out,[base/'proto.txt'])
|
||||||
|
mob=(out/'mob_drop_item.txt').read_bytes()
|
||||||
|
# unknown items removed, entries renumbered (the reader stops at the first gap), empty groups skipped, ranges known
|
||||||
|
assert mob==b'Group\tA\n{\n\tMob\t101\n\tType\tdrop\n\t1\t19\t1\t100\n\t2\t110005\t1\t50\n}\n',mob
|
||||||
|
assert report['mob_dropped']=={'99999':2}
|
||||||
|
assert b'level_range\t1\t12' in (out/'common_drop_new.txt').read_bytes()
|
||||||
|
special=(out/'special_item_group.txt').read_bytes()
|
||||||
|
assert b'Vnum\t50011\n\t1\t19\t5\t2' in special and b'\xb0\xe6' not in special # AVA2 replaces the same vnum
|
||||||
|
assert b'Kid' in special and b'2000' not in special # 50035 is a different box on 203
|
||||||
|
assert b'Old' in special and b'Vnum\t77900\n\t1\t19\t1\t30' in special
|
||||||
|
assert (out/'common_drop_item.txt').read_bytes()==b''==(out/'etc_drop_item.txt').read_bytes()
|
||||||
|
assert json.loads((out/'report.json').read_text())['special_replaced']==[50011]
|
||||||
|
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
manager=source('item_manager.cpp')
|
||||||
|
pct=manager[manager.index('bool ITEM_MANAGER::GetDropPct('):manager.index('bool ITEM_MANAGER::CreateDropItem(')]
|
||||||
|
assert '?100:0' not in pct.replace(' ','') # the precedence bug that pinned the denominator to 100
|
||||||
|
assert 'else\n\t\tiDeltaPercent += iDeltaPercent / 2;' in pct
|
||||||
|
assert '(100 + CPrivManager::instance().GetPriv(pkKiller, PRIV_ITEM_DROP) + bonus)' in pct
|
||||||
|
drop=manager[manager.index('bool ITEM_MANAGER::CreateDropItem('):]
|
||||||
|
assert drop.index('// Drop Item Group')<drop.index('m_vec_pkCommonNewItemGroup')<drop.index('// MobDropItem Group')
|
||||||
|
assert 'abs(pkChr->GetLevel() - iLevel) <= 20' in drop
|
||||||
|
tables=source('item_manager_read_tables.cpp')
|
||||||
|
assert 'CDropItemGroup* pkGroup = it->second;' not in tables # second group of a mob used an uninitialised pointer
|
||||||
|
special=tables[tables.index('bool ITEM_MANAGER::ReadSpecialDropItemFile('):tables.index('bool ITEM_MANAGER::ReadCommonDropNewItemFile(')]
|
||||||
|
assert special.count('k < 1024')==2 and 'char buf[4]' not in special.split('ConvSpecialDropItemFile')[0]
|
||||||
|
db=source('input_db.cpp')
|
||||||
|
assert db.index('ReadCommonDropItemFile(')<db.index('ReadCommonDropNewItemFile(')<db.index('ReadEtcDropItemFile(')
|
||||||
|
print('PASS: drop table builder (filter, renumber, ranges, merge, kept 203 box) and AVA2 drop code wiring')
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 mount costume + skin (docs/FEATURE-AVA2-UNLOCK.md P5): subtype/wear numbering shared with the client,
|
||||||
|
the horse race override and the equip/unequip/login hooks."""
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server'
|
||||||
|
CLIENT=ROOT.parent/'metin2-client/src/port'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
def enum_after(text,start,end):
|
||||||
|
body=text[text.index(start):];body=body[:body.index(end)]
|
||||||
|
return re.findall(r'^\s*([A-Z_0-9]+)\s*[,=]',body,re.M)
|
||||||
|
|
||||||
|
item=source('common/item_length.h')
|
||||||
|
assert 'COSTUME_MOUNT = 2,' in item and 'COSTUME_MOUNT_SKIN = 4,' in item
|
||||||
|
reader=source('db/src/ProtoReader.cpp')
|
||||||
|
assert '"COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };' in reader
|
||||||
|
wear=enum_after(source('common/length.h'),'WEAR_BODY','WEAR_MAX_NUM')
|
||||||
|
assert wear.index('WEAR_COSTUME_MOUNT')==25 and wear.index('WEAR_COSTUME_MOUNT_SKIN')==26,wear
|
||||||
|
if CLIENT.is_dir():
|
||||||
|
gametype=(CLIENT/'UserInterface/GameType.h').read_text()
|
||||||
|
assert 'c_Costume_Slot_Mount = c_Equipment_Start + 25;' in gametype and 'c_Costume_Slot_MountSkin = c_Equipment_Start + 26;' in gametype
|
||||||
|
itemdata=(CLIENT/'GameLib/ItemData.h').read_text()
|
||||||
|
assert 'COSTUME_MOUNT = 2,' in itemdata and 'COSTUME_MOUNT_SKIN = 4,' in itemdata
|
||||||
|
|
||||||
|
horse=source('game/src/char_horse.cpp')
|
||||||
|
body=horse[horse.index('DWORD CHARACTER::GetMyHorseVnum'):];body=body[:body.index('\n}\n')]
|
||||||
|
assert body.index('WEAR_COSTUME_MOUNT_SKIN')<body.index('GetWear(WEAR_COSTUME_MOUNT)')<body.index('c_aHorseStat'),body
|
||||||
|
assert 'return WEAR_COSTUME_MOUNT;' in source('game/src/item.cpp') and 'return WEAR_COSTUME_MOUNT_SKIN;' in source('game/src/item.cpp')
|
||||||
|
attr=source('game/src/item_attribute.cpp')
|
||||||
|
assert 'GetSubType() == COSTUME_MOUNT || GetSubType() == COSTUME_SASH || GetSubType() == COSTUME_MOUNT_SKIN))\n\t\treturn -1;' in attr
|
||||||
|
|
||||||
|
items=source('game/src/char_item.cpp')
|
||||||
|
for hook in ('MountCostumeCanEquip(item)','MountCostumeCanUnequip(item)','MountCostumeEquipped(item);',
|
||||||
|
'MountCostumeUnequipped(item, true);','MountCostumeUnequipped(item, false);'):
|
||||||
|
assert items.count(hook)==1,hook
|
||||||
|
assert 'ch->MountCostumeOnLogin();' in source('game/src/input_login.cpp')
|
||||||
|
assert 'ch->UnequipItem(pkCostumeMount);' in source('game/src/cmd_general.cpp')
|
||||||
|
assert 'port_mount.cpp' in source('game/src/Makefile')
|
||||||
|
mount=source('game/src/port_mount.cpp')
|
||||||
|
for code in ('riding','need_mount','has_skin','need_horse'):assert '"MTMOUNT %s"'%code in mount,code
|
||||||
|
script=ROOT.parent/'metin2-client/src/platform/ScriptLib/MountScript.inc'
|
||||||
|
if script.is_file():
|
||||||
|
s=script.read_text()
|
||||||
|
for code in ('riding','need_mount','has_skin','need_horse'):assert "'%s':"%code in s,code
|
||||||
|
print('PASS: mount subtypes 2/4, WEAR 25/26, horse race = skin > mount > horse level, hooks, MTMOUNT codes')
|
||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 talisman (docs/FEATURE-AVA2-UNLOCK.md P7): ARMOR_PENDANT worn in WEAR_PENDANT, element enchant applies,
|
||||||
|
its own attribute pool changed only by 71301/71302/53996/53997, which are no switchbot scrolls."""
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
|
||||||
|
il=source('common/item_length.h');assert il.index('ARMOR_EAR,')<il.index('ARMOR_PENDANT,')<il.index('ARMOR_NUM_TYPES')
|
||||||
|
length=source('common/length.h')
|
||||||
|
assert length.index('WEAR_COSTUME_MOUNT_SKIN,\t// 26')<length.index('WEAR_PENDANT,\t\t// 27')
|
||||||
|
reader=source('db/src/ProtoReader.cpp')
|
||||||
|
assert '"ARMOR_NECK", "ARMOR_EAR", "ARMOR_PENDANT", "ARMOR_NUM_TYPES"' in reader
|
||||||
|
item=source('game/src/item.cpp')
|
||||||
|
fec=item[item.index('int CItem::FindEquipCell('):]
|
||||||
|
assert fec.index('if (IsTalisman())\n\t\treturn WEAR_PENDANT;')<fec.index('0 == GetWearFlag()'),'talisman has no wear flag'
|
||||||
|
items=source('game/src/char_item.cpp')
|
||||||
|
case=items[items.index('case USE_CHANGE_ATTRIBUTE2 :'):]
|
||||||
|
assert case.index('return CostumeEnchantUse(item, item2);')<case.index('if (item->GetPendantScrollKind() || item2->IsTalisman())\n\t\t\t\t\t\t\t\treturn PendantScrollUse(item, item2);')<case.index('BuffOnAttr_RemoveBuffsFromItem(item2)')
|
||||||
|
assert '!scroll->GetPendantScrollKind()' in source('game/src/port_switchbot.h')
|
||||||
|
assert 'port_pendant.cpp' in source('game/src/Makefile')
|
||||||
|
port=source('game/src/port_pendant.cpp')
|
||||||
|
pool=port[port.index('s_aPendantAttr[] ='):];pool=pool[:pool.index('};')]
|
||||||
|
assert pool.count('{ APPLY_')==20 and 'APPLY_ATTBONUS' not in pool and 'APPLY_ENCHANT' not in pool
|
||||||
|
for text in ('PENDANT_MAX_ATTR = 5','{ 0, 10, 40, 35, 15 }','{ 40, 50, 10, 0, 0 }','case 71302:\n\t\tcase 53996:','case 71301:\n\t\tcase 53997:',
|
||||||
|
'if (item->HasAttr(r.bApply))','item->SetCount(item->GetCount() - 1);'):
|
||||||
|
assert text in port,text
|
||||||
|
codes=('target','equipped','empty','changed','full','added')
|
||||||
|
for code in codes:assert '"MTPENDANT %s"'%code in port,code
|
||||||
|
assert port.index('"MTPENDANT equipped"')<port.index('item2->ClearAttribute()')
|
||||||
|
assert port.index('"MTPENDANT full"')<port.index('PendantPutAttribute(item2, s_aiAddLevel)')
|
||||||
|
script=ROOT.parent/'metin2-client/src/platform/ScriptLib/PendantScript.inc'
|
||||||
|
if script.is_file():
|
||||||
|
s=script.read_text()
|
||||||
|
for code in codes:assert "'%s':"%code in s,code
|
||||||
|
print('PASS: talisman slot/equip, enchant switch routing before the switcher path, 20-row pool, max 5, switchbot excluded, MTPENDANT codes')
|
||||||
@@ -12,6 +12,7 @@ points=sorted(set(re.findall(r'\bPOINT_[A-Z_]+', (SRC/'port_features.h').read_te
|
|||||||
code=r'''
|
code=r'''
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <climits>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -28,7 +29,7 @@ GROUPS
|
|||||||
#include "item_manager_private_types.h"
|
#include "item_manager_private_types.h"
|
||||||
std::vector<CItemDropInfo> g_vec_pkCommonDropItem[MOB_RANK_MAX_NUM];
|
std::vector<CItemDropInfo> g_vec_pkCommonDropItem[MOB_RANK_MAX_NUM];
|
||||||
struct TItemTable{unsigned dwVnum;unsigned bType=0;};
|
struct TItemTable{unsigned dwVnum;unsigned bType=0;};
|
||||||
struct MobTable{unsigned bType=0,bRank=0,dwPolymorphItemVnum=0,dwDropItemVnum=0;};
|
struct MobTable{unsigned bType=0,bRank=0,dwPolymorphItemVnum=0,dwDropItemVnum=0;unsigned char bLevel=0;};
|
||||||
struct CMob{MobTable m_table;};
|
struct CMob{MobTable m_table;};
|
||||||
class CMobManager {
|
class CMobManager {
|
||||||
public:std::map<DWORD,CMob*> mobs;
|
public:std::map<DWORD,CMob*> mobs;
|
||||||
@@ -44,6 +45,7 @@ class ITEM_MANAGER {
|
|||||||
std::map<DWORD,CLevelItemGroup*> m_map_pkLevelItemGroup;
|
std::map<DWORD,CLevelItemGroup*> m_map_pkLevelItemGroup;
|
||||||
std::map<DWORD,CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
|
std::map<DWORD,CBuyerThiefGlovesItemGroup*> m_map_pkGloveItemGroup;
|
||||||
std::map<DWORD,DWORD> m_map_dwEtcItemDropProb;
|
std::map<DWORD,DWORD> m_map_dwEtcItemDropProb;
|
||||||
|
std::vector<CCommonDropNew*> m_vec_pkCommonNewItemGroup;
|
||||||
std::map<DWORD,CSpecialItemGroup*> special;
|
std::map<DWORD,CSpecialItemGroup*> special;
|
||||||
static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;}
|
static ITEM_MANAGER& instance(){static ITEM_MANAGER m;return m;}
|
||||||
TItemTable* GetTable(unsigned id){for(auto& t:tables)if(t.dwVnum==id)return &t;return nullptr;}
|
TItemTable* GetTable(unsigned id){for(auto& t:tables)if(t.dwVnum==id)return &t;return nullptr;}
|
||||||
@@ -100,6 +102,13 @@ int main(){
|
|||||||
assert(items.PortWikiDrops(9001).empty() && items.PortWikiDrops(99999).empty());
|
assert(items.PortWikiDrops(9001).empty() && items.PortWikiDrops(99999).empty());
|
||||||
drop.AddItem(30220,25,1);assert(items.PortWikiDrops(101).size()==8);
|
drop.AddItem(30220,25,1);assert(items.PortWikiDrops(101).size()==8);
|
||||||
drop.AddItem(70104,1,1);assert(items.PortWikiDrops(101).size()==9); // Non-common groups retain configured polymorph candidates. // Sees active changes, not exported text.
|
drop.AddItem(70104,1,1);assert(items.PortWikiDrops(101).size()==9); // Non-common groups retain configured polymorph candidates. // Sees active changes, not exported text.
|
||||||
|
// common_drop_new: player range clipped to the mob level +-20; groups out of reach are left out
|
||||||
|
mob.m_table.bLevel=10;CCommonDropNew low,high;low.minLevel=1;low.maxLevel=40;low.AddItem(30006,3,1200);high.minLevel=31;high.maxLevel=60;high.AddItem(19,1,1200);
|
||||||
|
items.m_vec_pkCommonNewItemGroup={&low,&high};rows=items.PortWikiDrops(101);assert(rows.size()==10);
|
||||||
|
assert(rows[1].item==30006 && rows[1].count==3 && rows[1].rule==WIKI_COMMON && rows[1].minimum==1 && rows[1].maximum==30 && rows[1].weight==1200);
|
||||||
|
high.minLevel=30;assert(items.PortWikiDrops(101).size()==11 && items.PortWikiDrops(101)[2].minimum==30);
|
||||||
|
assert(low.CanDropThisMap(41));low.m_vecMapIndex={1};assert(low.CanDropThisMap(1) && !low.CanDropThisMap(41));
|
||||||
|
items.m_vec_pkCommonNewItemGroup.clear();mob.m_table.bLevel=0;
|
||||||
CSpecialItemGroup chest(50011);chest.AddItem(19,1,80,0);chest.AddItem(1,500,20,0);items.special[50011]=&chest;
|
CSpecialItemGroup chest(50011);chest.AddItem(19,1,80,0);chest.AddItem(1,500,20,0);items.special[50011]=&chest;
|
||||||
CSpecialItemGroup multi(50012,CSpecialItemGroup::PCT);multi.AddItem(19,2,20,0);multi.AddItem(3,101,150,0);items.special[50012]=&multi;
|
CSpecialItemGroup multi(50012,CSpecialItemGroup::PCT);multi.AddItem(19,2,20,0);multi.AddItem(3,101,150,0);items.special[50012]=&multi;
|
||||||
CSpecialItemGroup attr(50013,CSpecialItemGroup::SPECIAL);attr.AddItem(19,1,100,0);items.special[50013]=&attr;
|
CSpecialItemGroup attr(50013,CSpecialItemGroup::SPECIAL);attr.AddItem(19,1,100,0);items.special[50013]=&attr;
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 new rings (docs/FEATURE-AVA2-UNLOCK.md P8): ITEM_NEW_RINGS (36) worn in WEAR_RINGS_1/2, socket accessories
|
||||||
|
with AVA2's jewels, their own 20-row attribute pool reached through the 40250 switchers / adders."""
|
||||||
|
from pathlib import Path
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
|
||||||
|
il=source('common/item_length.h')
|
||||||
|
assert il.index('ITEM_BELT,')<il.index('ITEM_SHINING,')<il.index('ITEM_NEW_RINGS,')<il.index('enum EMetinSubTypes'),'AVA2 numbering 35/36'
|
||||||
|
length=source('common/length.h')
|
||||||
|
assert length.index('WEAR_PENDANT,\t\t// 27')<length.index('WEAR_RINGS_1,\t\t// 28')<length.index('WEAR_RINGS_2,\t\t// 29')<length.index('WEAR_MAX = 32')
|
||||||
|
reader=source('db/src/ProtoReader.cpp')
|
||||||
|
types=reader[reader.index('string arType[]'):];types=types[:types.index('};')]
|
||||||
|
assert types.index('"ITEM_BELT"')<types.index('"ITEM_SHINING", "ITEM_NEW_RINGS"')
|
||||||
|
for name,rows in (('arSubType[] =',36),('arNumberOfSubtype[_countof(arSubType)] =',37)): # item types 0..36
|
||||||
|
arr=reader[reader.index(name):];arr=arr[:arr.index('};')]
|
||||||
|
assert arr.count('\n\t\t')==rows,(name,arr.count('\n\t\t'))
|
||||||
|
item=source('game/src/item.cpp')
|
||||||
|
fec=item[item.index('int CItem::FindEquipCell('):item.index('void CItem::ModifyPoints(')]
|
||||||
|
assert 'ITEM_BELT != GetType() && ITEM_NEW_RINGS != GetType())' in fec
|
||||||
|
assert 'if (ch->GetWear(WEAR_RINGS_1))\n\t\t\treturn WEAR_RINGS_2;\n\t\telse\n\t\t\treturn WEAR_RINGS_1;' in fec
|
||||||
|
assert '\tcase ITEM_BELT:\n\tcase ITEM_NEW_RINGS:\n\t\treturn true;' in item
|
||||||
|
assert '(m_pProto->bType == ITEM_BELT) || (m_pProto->bType == ITEM_NEW_RINGS);' in item
|
||||||
|
assert 'return GetVnum() == GetNewRingJewelVnum(item->GetVnum());' in item
|
||||||
|
items=source('game/src/char_item.cpp')
|
||||||
|
assert '\t\tcase ITEM_NEW_RINGS:\t// AVA2 new rings\n' in items
|
||||||
|
assert items.count('if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())')==3
|
||||||
|
assert items.count('if (item2->GetAttributeSetIndex() == -1)\n')==2 # 71051 / 71052 rare attributes stay closed
|
||||||
|
attr=source('game/src/item_attribute.cpp')
|
||||||
|
put=attr[attr.index('void CItem::PutAttributeWithLevel('):]
|
||||||
|
assert put.index('PutNewRingAttributeWithLevel(bLevel);')<put.index('GetAttributeSetIndex()')
|
||||||
|
assert 'port_rings.cpp' in source('game/src/Makefile')
|
||||||
|
port=source('game/src/port_rings.cpp')
|
||||||
|
pool=port[port.index('s_aRingAttr[] ='):];pool=pool[:pool.index('};')]
|
||||||
|
assert pool.count('{ APPLY_')==20 and '{ APPLY_MAX_HP,\t\t\t35,\t{ 200, 300, 300, 500, 500 } }' in pool
|
||||||
|
for ring,jewel in ((19500,50635),(19520,50636),(19540,50637),(19560,50638)):assert '{ %d, %d }'%(ring,jewel) in port
|
||||||
|
assert 'dwRingVnum / 10 * 10' in port and 'AddAttribute(r.bApply, r.asValues[bLevel - 1]);' in port
|
||||||
|
print('PASS: ring type 36 + WEAR_RINGS_1/2, accessory sockets + jewels, switchers/adders via the 20-row ring pool, rare attrs closed')
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""AVA2 sash (docs/FEATURE-AVA2-UNLOCK.md P4): item/wear/part numbering, packet headers shared with the client,
|
||||||
|
and the quest hook."""
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server'
|
||||||
|
CLIENT=ROOT.parent/'metin2-client/src/port/UserInterface/Packet.h'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
def enum_after(text,start,end):
|
||||||
|
body=text[text.index(start):];body=body[:body.index(end)]
|
||||||
|
return re.findall(r'^\s*([A-Z_0-9]+)\s*[,=]',body,re.M)
|
||||||
|
|
||||||
|
item=source('common/item_length.h')
|
||||||
|
assert 'COSTUME_SASH = 3,' in item
|
||||||
|
for k,v in (('SASH_ABSORPTION_SOCKET',0),('SASH_ABSORBED_SOCKET',1),('SASH_GRADE_4_ABS_MIN',11),('SASH_GRADE_4_ABS_MAX',25),
|
||||||
|
('SASH_GRADE_4_ABS_MAX_COMB',19),('SASH_EFFECT_FROM_ABS',19),('SASH_GRADE_4_PRICE',500000),('SASH_COMBINE_GRADE_4',30)):
|
||||||
|
assert re.search(r'\b%s = %d,'%(k,v),item),k
|
||||||
|
reader=source('db/src/ProtoReader.cpp')
|
||||||
|
assert 'arSub28[] = { "COSTUME_BODY", "COSTUME_HAIR", "COSTUME_MOUNT", "COSTUME_SASH", "COSTUME_MOUNT_SKIN" };' in reader
|
||||||
|
|
||||||
|
length=source('common/length.h')
|
||||||
|
wear=enum_after(length,'WEAR_BODY','WEAR_MAX_NUM')
|
||||||
|
assert wear.index('WEAR_COSTUME_SASH')==24,wear
|
||||||
|
parts=enum_after(length,'PART_MAIN','PART_MAX_NUM')
|
||||||
|
assert parts[parts.index('PART_HAIR')+1]=='PART_SASH',parts
|
||||||
|
se=enum_after(length,'SE_EQUIP_LOVE_PENDANT','} ;')
|
||||||
|
assert se[se.index('SE_EQUIP_LOVE_PENDANT')+1:se.index('SE_EQUIP_LOVE_PENDANT')+3]==['SE_EFFECT_SASH_SUCCEDED','SE_EFFECT_SASH_EQUIP'],se
|
||||||
|
|
||||||
|
packet=source('game/src/packet.h')
|
||||||
|
assert re.search(r'HEADER_CG_SASH\s*= 211,',packet) and re.search(r'HEADER_GC_SASH\s*= 215,',packet)
|
||||||
|
equip=enum_after(packet,'CHR_EQUIPPART_ARMOR','CHR_EQUIPPART_NUM')
|
||||||
|
assert equip==['CHR_EQUIPPART_ARMOR','CHR_EQUIPPART_WEAPON','CHR_EQUIPPART_HEAD','CHR_EQUIPPART_HAIR','CHR_EQUIPPART_SASH'],equip
|
||||||
|
if CLIENT.is_file(): # the character packets grow by one WORD: both sides must agree
|
||||||
|
client=CLIENT.read_bytes().decode('latin1')
|
||||||
|
assert re.search(r'HEADER_CG_SASH\s*= 211,',client) and re.search(r'HEADER_GC_SASH\s*= 215,',client)
|
||||||
|
cequip=re.findall(r'(CHR_EQUIPPART_[A-Z]+)',client[client.index('CHR_EQUIPPART_ARMOR'):client.index('CHR_EQUIPPART_NUM')])
|
||||||
|
assert cequip==equip,cequip
|
||||||
|
|
||||||
|
char=source('game/src/char.cpp')
|
||||||
|
assert 'SetPart(PART_SASH, 0);' in char # not stored in the player table
|
||||||
|
assert char.count('awPart[CHR_EQUIPPART_SASH] = GetPart(PART_SASH);')==2
|
||||||
|
assert 'port_sash.cpp' in source('game/src/Makefile')
|
||||||
|
assert '{ "open_sash",\t\tpc_open_sash\t\t},' in source('game/src/questlua_pc.cpp')
|
||||||
|
sash=source('game/src/port_sash.cpp')
|
||||||
|
assert '* dPct + .5);' in sash and 'MTSASH abs %u' in sash
|
||||||
|
|
||||||
|
quest=ROOT.parent/'metin2-client/tools/server/sash/sash.quest'
|
||||||
|
if quest.is_file():
|
||||||
|
q=quest.read_text()
|
||||||
|
assert q.count('when 20016.chat.')==3 and 'pc.open_sash(true)' in q and 'pc.open_sash(false)' in q
|
||||||
|
print('PASS: sash subtype 3, WEAR 24, PART_SASH, CG 211 / GC 215, 5 equip parts on both sides, pc.open_sash')
|
||||||
@@ -45,6 +45,7 @@ class CHARACTER;
|
|||||||
class CItem {public:
|
class CItem {public:
|
||||||
DWORD id,vnum;BYTE type,subtype;int set=0;unsigned cell;BYTE window=INVENTORY;bool equipped=false,exchanging=false;int count=1;
|
DWORD id,vnum;BYTE type,subtype;int set=0;unsigned cell;BYTE window=INVENTORY;bool equipped=false,exchanging=false;int count=1;
|
||||||
CHARACTER* owner=nullptr;TItemTable proto{};TPlayerItemAttribute attrs[7];
|
CHARACTER* owner=nullptr;TItemTable proto{};TPlayerItemAttribute attrs[7];
|
||||||
|
long value2=0;bool IsCostumeEnchant(){return vnum>=54001 && vnum<=54267 && value2;}int GetPendantScrollKind(){return vnum==71302||vnum==53996;}
|
||||||
DWORD GetID(){return id;}DWORD GetVnum(){return vnum;}BYTE GetType(){return type;}BYTE GetSubType(){return subtype;}
|
DWORD GetID(){return id;}DWORD GetVnum(){return vnum;}BYTE GetType(){return type;}BYTE GetSubType(){return subtype;}
|
||||||
int GetAttributeSetIndex(){return set;}const TItemTable* GetProto(){return &proto;}
|
int GetAttributeSetIndex(){return set;}const TItemTable* GetProto(){return &proto;}
|
||||||
const TPlayerItemAttribute& GetAttribute(int i){return attrs[i];}BYTE GetAttributeType(int i){return attrs[i].bType;}
|
const TPlayerItemAttribute& GetAttribute(int i){return attrs[i];}BYTE GetAttributeType(int i){return attrs[i].bType;}
|
||||||
@@ -131,6 +132,9 @@ int main(){
|
|||||||
cmd("1 start 10 71084 5 2 3 1 3 2");assert(last()=="MTSB1 error start target"); // duplicate
|
cmd("1 start 10 71084 5 2 3 1 3 2");assert(last()=="MTSB1 error start target"); // duplicate
|
||||||
cmd("1 start 10 71085 5 1 3 4");assert(last()=="MTSB1 error start scroll");
|
cmd("1 start 10 71085 5 1 3 4");assert(last()=="MTSB1 error start scroll");
|
||||||
cmd("1 start 10 50001 5 1 3 4");assert(last()=="MTSB1 error start scroll");
|
cmd("1 start 10 50001 5 1 3 4");assert(last()=="MTSB1 error start scroll");
|
||||||
|
// AVA2 costume enchants share USE_CHANGE_ATTRIBUTE but are no switchers (port_costume_attr.cpp).
|
||||||
|
CItem enchant{2004,54001,ITEM_USE,USE_CHANGE_ATTRIBUTE,-1,23};enchant.owner=&ch;enchant.value2=2;ch.inventory.push_back(&enchant);
|
||||||
|
cmd("1 start 10 54001 5 1 3 4");assert(last()=="MTSB1 error start scroll");
|
||||||
cmd("1 start 30 71084 5 1 3 4");assert(last()=="MTSB1 error start no_attr");
|
cmd("1 start 30 71084 5 1 3 4");assert(last()=="MTSB1 error start no_attr");
|
||||||
armor.equipped=true;cmd("1 start 10 71084 5 1 3 4");assert(last()=="MTSB1 error start equipped");armor.equipped=false;
|
armor.equipped=true;cmd("1 start 10 71084 5 1 3 4");assert(last()=="MTSB1 error start equipped");armor.equipped=false;
|
||||||
cmd("1 start 10 71084 5 1 3 2");assert(last()=="MTSB1 state 0 10 11209 0 5 71084 3 matched" && events.empty()); // already satisfied
|
cmd("1 start 10 71084 5 1 3 2");assert(last()=="MTSB1 state 0 10 11209 0 5 71084 3 matched" && events.empty()); // already satisfied
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compile the production VIP card header against stubs of the account table, the ordered async SQL queue and
|
||||||
|
the premium affects."""
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
ROOT=Path(__file__).resolve().parents[2]
|
||||||
|
SRC=ROOT/'src/server/game/src'
|
||||||
|
def source(name):return (SRC/name).read_bytes().decode('latin1')
|
||||||
|
cmd=source('cmd.cpp')
|
||||||
|
assert 'ACMD(do_port_vip);' in cmd and '"mt_vip", do_port_vip, 0, POS_DEAD, GM_PLAYER' in cmd
|
||||||
|
general=source('cmd_general.cpp')
|
||||||
|
assert '#include "port_premium.h"' in general and 'PortVipCommand(ch, argument);' in general
|
||||||
|
item=source('char_item.cpp')
|
||||||
|
use=item.index('bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)')
|
||||||
|
hook=item.index('if (PortVipUseCard(this, item))',use)
|
||||||
|
assert '#endif\n#include "port_premium.h"\n' in item # not inside the __AUCTION__ block
|
||||||
|
assert item.index('FN_check_item_sex(this, item)',use)<hook<item.index('IS_SUMMON_ITEM(item->GetVnum())',use)
|
||||||
|
login=source('input_login.cpp')
|
||||||
|
assert login.index('AFFECT_PREMIUM_START + i')<login.index('PortVipRefresh(ch, false);')
|
||||||
|
assert 'void\t\t\t\tPortSetPremiumTime(BYTE bType, int iTime)' in source('char.h')
|
||||||
|
code=r'''
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
#include <deque>
|
||||||
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using DWORD=unsigned;using BYTE=unsigned char;
|
||||||
|
enum {CHAT_TYPE_INFO=1,CHAT_TYPE_COMMAND=5,POINT_NONE=0,AFFECT_PREMIUM_START=500,PREMIUM_MAX_NUM=9};
|
||||||
|
static int now=1700000000;static DWORD clockms=1000;
|
||||||
|
int get_global_time(){return now;}DWORD get_dword_time(){return clockms;}
|
||||||
|
static std::vector<std::string> logs;
|
||||||
|
void sys_log(int,const char* format,...){char out[512];va_list a;va_start(a,format);vsnprintf(out,sizeof(out),format,a);va_end(a);logs.push_back(out);}
|
||||||
|
void sys_err(const char* format,...){char out[512];va_list a;va_start(a,format);vsnprintf(out,sizeof(out),format,a);va_end(a);logs.push_back(std::string("ERR ")+out);}
|
||||||
|
static std::string format(const char* f,va_list a){char out[4096];vsnprintf(out,sizeof(out),f,a);return out;}
|
||||||
|
// Account table: id -> seven end times (0 = never), as UNIX_TIMESTAMP reads them.
|
||||||
|
static std::map<DWORD,std::vector<int>> accounts;
|
||||||
|
using MYSQL_ROW=char**;
|
||||||
|
struct Rows{char* cells[7];char text[7][16];};
|
||||||
|
struct SQLResult{unsigned uiNumRows;Rows* pSQLResult;Rows rows;};
|
||||||
|
struct SQLMsg{SQLResult result;bool ok=true;SQLResult* Get(){return ok?&result:nullptr;}};
|
||||||
|
MYSQL_ROW mysql_fetch_row(Rows* r){return r->cells;}
|
||||||
|
struct DBManager{
|
||||||
|
std::deque<std::function<void()>> queue;std::vector<std::string> queries;
|
||||||
|
static DBManager& instance(){static DBManager m;return m;}
|
||||||
|
void Query(const char* f,...){va_list a;va_start(a,f);std::string q=format(f,a);va_end(a);queries.push_back(q);
|
||||||
|
queue.push_back([q]{DWORD id;int secs;
|
||||||
|
const char* where=strstr(q.c_str()," WHERE id=");assert(where && sscanf(where," WHERE id=%u",&id)==1);
|
||||||
|
const char* add=strstr(q.c_str(),"UNIX_TIMESTAMP())+");assert(add && sscanf(add,"UNIX_TIMESTAMP())+%d)",&secs)==1);
|
||||||
|
for(int& t:accounts[id])t=(t>now?t:now)+secs;});}
|
||||||
|
template<class F> void FuncQuery(F f,const char* fmt,...){va_list a;va_start(a,fmt);std::string q=format(fmt,a);va_end(a);queries.push_back(q);
|
||||||
|
queue.push_back([f,q]{DWORD id;assert(sscanf(strstr(q.c_str()," WHERE id="), " WHERE id=%u",&id)==1);
|
||||||
|
SQLMsg m{};auto it=accounts.find(id);m.result.uiNumRows=it==accounts.end()?0:1;m.result.pSQLResult=&m.result.rows;
|
||||||
|
for(int i=0;i<7;++i){m.result.rows.cells[i]=m.result.rows.text[i];snprintf(m.result.rows.text[i],16,"%d",it==accounts.end()?0:it->second[i]);}
|
||||||
|
f(&m);});}
|
||||||
|
void Run(){while(!queue.empty()){auto job=queue.front();queue.pop_front();job();}}
|
||||||
|
};
|
||||||
|
struct CItem{DWORD vnum;int count;DWORD GetVnum(){return vnum;}int GetCount(){return count;}void SetCount(int c){count=c;}};
|
||||||
|
using LPITEM=CItem*;
|
||||||
|
struct TAccountTable{DWORD id;};
|
||||||
|
struct DESC{TAccountTable table;TAccountTable& GetAccountTable(){return table;}};
|
||||||
|
struct CHARACTER{
|
||||||
|
DESC desc;bool online=true;int premium[PREMIUM_MAX_NUM]={};std::map<DWORD,long> affects;std::vector<std::string> messages;
|
||||||
|
const char* GetName(){return "Admin";}bool IsPC(){return true;}DESC* GetDesc(){return online?&desc:nullptr;}DWORD GetPlayerID(){return 7;}
|
||||||
|
int GetPremiumRemainSeconds(BYTE t)const{return t<PREMIUM_MAX_NUM?premium[t]-now:0;}
|
||||||
|
void PortSetPremiumTime(BYTE t,int v){if(t<PREMIUM_MAX_NUM)premium[t]=v;}
|
||||||
|
bool AddAffect(DWORD type,BYTE,long,DWORD,long duration,long,bool override){assert(override);affects[type]=duration;return true;}
|
||||||
|
bool RemoveAffect(DWORD type){return affects.erase(type)>0;}
|
||||||
|
void ChatPacket(BYTE type,const char* f,...){va_list a;va_start(a,f);std::string s=format(f,a);va_end(a);assert(type==CHAT_TYPE_COMMAND);messages.push_back(s);}
|
||||||
|
};
|
||||||
|
using LPCHARACTER=CHARACTER*;
|
||||||
|
static CHARACTER* player=nullptr;
|
||||||
|
struct CHARACTER_MANAGER{static CHARACTER_MANAGER& instance(){static CHARACTER_MANAGER m;return m;}
|
||||||
|
LPCHARACTER FindByPID(DWORD pid){return player && pid==7?player:nullptr;}};
|
||||||
|
static std::vector<std::string> itemlog;
|
||||||
|
struct LogManager{static LogManager& instance(){static LogManager m;return m;}
|
||||||
|
void ItemLog(LPCHARACTER,LPITEM item,const char* how,const char* hint){assert(item->count>0);itemlog.push_back(std::string(how)+" "+std::to_string(item->vnum)+" "+hint);}};
|
||||||
|
#include "port_premium.h"
|
||||||
|
static DBManager& db=DBManager::instance();
|
||||||
|
static const std::string& last(){return player->messages.back();}
|
||||||
|
static void tick(){clockms+=1100;}
|
||||||
|
int main(){
|
||||||
|
const int DAY=86400;
|
||||||
|
accounts[1]=std::vector<int>(7,0);
|
||||||
|
player=new CHARACTER;player->desc.table.id=1;
|
||||||
|
// Fresh account: 7 days from now on all seven columns, one card consumed, icons 500..506 for 7 days.
|
||||||
|
CItem card{38001,2};
|
||||||
|
assert(PortVipUseCard(player,&card) && card.count==1 && itemlog.back()=="MT_VIP_CARD 38001 7");
|
||||||
|
assert(db.queries[0].rfind("UPDATE account.account SET silver_expire=FROM_UNIXTIME(GREATEST(UNIX_TIMESTAMP(silver_expire),UNIX_TIMESTAMP())+604800),gold_expire=",0)==0);
|
||||||
|
assert(db.queries[0].find("money_drop_rate_expire=FROM_UNIXTIME(GREATEST(UNIX_TIMESTAMP(money_drop_rate_expire),UNIX_TIMESTAMP())+604800) WHERE id=1")!=std::string::npos);
|
||||||
|
assert(db.queries[1]=="SELECT UNIX_TIMESTAMP(silver_expire),UNIX_TIMESTAMP(gold_expire),UNIX_TIMESTAMP(safebox_expire),UNIX_TIMESTAMP(autoloot_expire),UNIX_TIMESTAMP(fish_mind_expire),UNIX_TIMESTAMP(marriage_fast_expire),UNIX_TIMESTAMP(money_drop_rate_expire) FROM account.account WHERE id=1");
|
||||||
|
assert(last()=="MTVIP1 added 38001 7" && player->premium[0]==0); // memory waits for the read-back
|
||||||
|
db.Run();
|
||||||
|
assert(last()=="MTVIP1 times 604800 604800 604800 604800 604800 604800 604800");
|
||||||
|
for(int i=0;i<7;++i)assert(player->premium[i]==now+7*DAY && player->affects[500+i]==7*DAY && accounts[1][i]==now+7*DAY);
|
||||||
|
assert(!player->affects.count(507) && player->premium[7]==0);
|
||||||
|
// A second card inside the gap is refused and kept; after it, 30 days add to the current end.
|
||||||
|
CItem month{38002,1};
|
||||||
|
assert(PortVipUseCard(player,&month) && last()=="MTVIP1 error rate" && month.count==1);
|
||||||
|
tick();now+=DAY;assert(PortVipUseCard(player,&month) && month.count==0);db.Run();
|
||||||
|
assert(last()=="MTVIP1 times 3110400 3110400 3110400 3110400 3110400 3110400 3110400" && player->premium[3]==now-DAY+37*DAY);
|
||||||
|
// Past the 400-day cap: refused before anything is consumed or queried.
|
||||||
|
const size_t queries=db.queries.size();CItem many{38002,20};
|
||||||
|
for(int k=0;k<13;++k){tick();assert(PortVipUseCard(player,&many));db.Run();} // 36 days left: 12 cards reach 396
|
||||||
|
assert(last()=="MTVIP1 error full" && many.count==8 && db.queries.size()==queries+24);
|
||||||
|
// Not a card: untouched, nothing queried.
|
||||||
|
CItem other{27001,5};assert(!PortVipUseCard(player,&other) && other.count==5 && db.queries.size()==queries+24);
|
||||||
|
// Enter-game on another core: the db core still has the login-time ends (here, none); the refresh restores them.
|
||||||
|
tick();const auto stale=player->messages.size();
|
||||||
|
for(int i=0;i<PREMIUM_MAX_NUM;++i)player->premium[i]=0;player->affects.clear();
|
||||||
|
PortVipRefresh(player,false);db.Run();
|
||||||
|
assert(player->messages.size()==stale && player->premium[6]==accounts[1][6] && player->affects[506]==accounts[1][6]-now);
|
||||||
|
// Expired in the account (edited by hand): state and icon go away; unchanged types keep their icon untouched.
|
||||||
|
accounts[1][2]=now-5;player->affects[502]=1;player->affects[503]=12345;
|
||||||
|
PortVipRefresh(player,false);db.Run();
|
||||||
|
assert(player->GetPremiumRemainSeconds(2)<0 && !player->affects.count(502) && player->affects[503]==12345);
|
||||||
|
// Status command: version, validation, throttle, report of remaining seconds (0 when expired).
|
||||||
|
tick();PortVipCommand(player,"1 status");db.Run();assert(last().rfind("MTVIP1 times ",0)==0 && last().find(" 0 ")!=std::string::npos);
|
||||||
|
PortVipCommand(player,"1 status");assert(last()=="MTVIP1 error rate");
|
||||||
|
for(auto bad:{"1 stats","1","1 status x"}){tick();PortVipCommand(player,bad);assert(last()=="MTVIP1 error invalid");}
|
||||||
|
const auto quiet=player->messages.size();tick();PortVipCommand(player,"2 status");PortVipCommand(player,"1 status x y z");
|
||||||
|
assert(player->messages.size()==quiet);
|
||||||
|
// The player left before the read-back: nothing is touched.
|
||||||
|
tick();PortVipCommand(player,"1 status");CHARACTER* gone=player;player=nullptr;db.Run();assert(gone->messages.size()==quiet);
|
||||||
|
// Missing account row: logged, no state change.
|
||||||
|
player=gone;player->desc.table.id=99;tick();PortVipRefresh(player,true);db.Run();assert(logs.back()=="ERR PORT_VIP: account 99 not found");
|
||||||
|
puts("PASS: card use and read-back, stacking, gap, cap, other items, enter-game refresh, expiry, status command");
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
with tempfile.TemporaryDirectory(prefix='mt-vip-') as folder:
|
||||||
|
path=Path(folder);(path/'test.cpp').write_text(code)
|
||||||
|
subprocess.run(['c++','-std=c++17','-Wall','-I'+str(SRC),str(path/'test.cpp'),'-o',str(path/'test')],check=True)
|
||||||
|
subprocess.run([str(path/'test')],check=True)
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Build the 203 drop tables from AVA2's (docs/FEATURE-AVA2-DROPS.md).
|
||||||
|
|
||||||
|
mob_drop_item.txt AVA2's, entries whose item 203 lacks are dropped and the rest renumbered
|
||||||
|
(the reader stops at the first missing index and fails on an unknown item)
|
||||||
|
common_drop_new.txt AVA2's NEW_COMMON_DROP groups, filtered the same way
|
||||||
|
special_item_group.txt 203's groups with AVA2's groups replacing those of the same vnum; AVA2-only groups added
|
||||||
|
common_drop_item.txt empty, like AVA2 (common drops come from common_drop_new.txt)
|
||||||
|
etc_drop_item.txt empty, like AVA2
|
||||||
|
|
||||||
|
Usage: make_drops.py <AVA2 locale dir> <203 locale dir> <output dir> <item_proto.txt>...
|
||||||
|
The item_proto files are every row the servers will load (the live one plus ava2-items' items-server.tsv).
|
||||||
|
"""
|
||||||
|
import json,re,sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# AVA2 reused these vnums for a different box: 50035 is 203's children's day gift box but AVA2's GM-only
|
||||||
|
# 'Pct' box handing out thousands of items, so 203's group stays.
|
||||||
|
KEEP_203={50035}
|
||||||
|
|
||||||
|
def vnums(paths):
|
||||||
|
result=set()
|
||||||
|
for p in paths:
|
||||||
|
for line in Path(p).read_bytes().splitlines():
|
||||||
|
head=line.split(b'\t',1)[0].strip()
|
||||||
|
if head.isdigit():result.add(int(head))
|
||||||
|
elif re.fullmatch(rb'\d+~\d+',head): # dragon soul rows cover a vnum range
|
||||||
|
lo,hi=map(int,head.split(b'~'));result.update(range(lo,hi+1))
|
||||||
|
return result
|
||||||
|
|
||||||
|
def groups(data):
|
||||||
|
"""[(name bytes, [body line bytes])] of a CTextFileLoader file ('Group <name>' then a braced body)."""
|
||||||
|
lines=data.replace(b'\r\n',b'\n').split(b'\n');result=[];i=0
|
||||||
|
while i<len(lines):
|
||||||
|
m=re.match(rb'\s*group\s+(.*?)\s*$',lines[i],re.I)
|
||||||
|
if not m:
|
||||||
|
if lines[i].strip() and not lines[i].strip().startswith((b'#',b'//')):raise SystemExit('unexpected line %r'%lines[i])
|
||||||
|
i+=1;continue
|
||||||
|
assert lines[i+1].strip()==b'{',lines[i:i+2]
|
||||||
|
j=i+2;body=[]
|
||||||
|
while lines[j].strip()!=b'}':body.append(lines[j]);j+=1
|
||||||
|
result.append((m.group(1),body));i=j+1
|
||||||
|
return result
|
||||||
|
|
||||||
|
def key(body,name):
|
||||||
|
for line in body:
|
||||||
|
t=line.split()
|
||||||
|
if t and t[0].lower()==name.encode():return t[1:]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def entries(body):
|
||||||
|
return [line.split() for line in body if line.split() and line.split()[0].isdigit()]
|
||||||
|
|
||||||
|
def render(name,head,items):
|
||||||
|
out=[b'Group\t'+name,b'{']+[b'\t'+b'\t'.join(t) for t in head]
|
||||||
|
out+=[b'\t'+b'\t'.join([str(k).encode()]+t[1:]) for k,t in enumerate(items,1)]
|
||||||
|
return out+[b'}']
|
||||||
|
|
||||||
|
def filtered(gs,known,item_column,dropped):
|
||||||
|
"""Groups with unknown items removed and indexes renumbered; groups left empty are skipped."""
|
||||||
|
out=[]
|
||||||
|
for name,body in gs:
|
||||||
|
head=[line.split() for line in body if line.split() and not line.split()[0].isdigit()]
|
||||||
|
items=[]
|
||||||
|
for t in entries(body):
|
||||||
|
token=t[item_column]
|
||||||
|
if token.isdigit() and int(token) not in known:dropped.setdefault(int(token),0);dropped[int(token)]+=1;continue
|
||||||
|
items.append(t)
|
||||||
|
if items:out+=render(name,head,items)
|
||||||
|
return out
|
||||||
|
|
||||||
|
def build(ava,live,output,protos):
|
||||||
|
known=vnums(protos);report={}
|
||||||
|
output.mkdir(parents=True,exist_ok=True)
|
||||||
|
mob=groups((ava/'mob_drop_item.txt').read_bytes())
|
||||||
|
assert all(key(b,'type')[0].lower()==b'drop' for _,b in mob) # every AVA2 group is a 'drop' group
|
||||||
|
assert max(len(entries(b)) for _,b in mob)<256
|
||||||
|
dropped={};text=filtered(mob,known,1,dropped)
|
||||||
|
(output/'mob_drop_item.txt').write_bytes(b'\n'.join(text)+b'\n')
|
||||||
|
report['mob_groups']=sum(1 for l in text if l==b'{');report['mob_dropped']=dropped
|
||||||
|
common=groups((ava/'common_drop_new.txt').read_bytes())
|
||||||
|
dropped={};text=filtered(common,known,1,dropped)
|
||||||
|
(output/'common_drop_new.txt').write_bytes(b'\n'.join(text)+b'\n')
|
||||||
|
report['common_new_groups']=sum(1 for l in text if l==b'{');report['common_new_dropped']=dropped
|
||||||
|
theirs=groups((ava/'special_item_group.txt').read_bytes());ours=groups((live/'special_item_group.txt').read_bytes())
|
||||||
|
assert all((key(b,'type') or [b'x'])[0].lower()!=b'attr' for _,b in theirs)
|
||||||
|
theirs=[(n,b) for n,b in theirs if int(key(b,'vnum')[0]) not in KEEP_203]
|
||||||
|
replaced={int(key(b,'vnum')[0]) for _,b in theirs}
|
||||||
|
dropped={};text=[]
|
||||||
|
for name,body in ours:
|
||||||
|
if int(key(body,'vnum')[0]) in replaced:continue
|
||||||
|
text+=[b'Group\t'+name,b'{']+body+[b'}']
|
||||||
|
text+=filtered(theirs,known,1,dropped)
|
||||||
|
(output/'special_item_group.txt').write_bytes(b'\n'.join(text)+b'\n')
|
||||||
|
kept=[int(key(b,'vnum')[0]) for _,b in ours if int(key(b,'vnum')[0]) not in replaced]
|
||||||
|
report.update(special_kept_203=len(kept),special_from_ava2=len(replaced),
|
||||||
|
special_replaced=sorted(replaced&{int(key(b,'vnum')[0]) for _,b in ours}),special_dropped=dropped)
|
||||||
|
for name in ('common_drop_item.txt','etc_drop_item.txt'):(output/name).write_bytes(b'')
|
||||||
|
for k in [k for k in report if k.endswith('_dropped')]:report[k]={str(v):n for v,n in sorted(report[k].items())}
|
||||||
|
(output/'report.json').write_text(json.dumps(report,indent=1)+'\n')
|
||||||
|
return report
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
if len(sys.argv)<5:sys.exit(__doc__)
|
||||||
|
r=build(Path(sys.argv[1]),Path(sys.argv[2]),Path(sys.argv[3]),sys.argv[4:])
|
||||||
|
print(json.dumps({k:(len(v) if isinstance(v,(list,dict)) else v) for k,v in r.items()}))
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
# PORT battle pass seasons (docs/FEATURE-BATTLEPASS.md). Installed as share/locale/newcibn/port_battlepass.tsv;
|
||||||
|
# every core rereads it within 5 s of an atomic replace. Any error disables the battle pass (see syserr PORT_BP).
|
||||||
|
#
|
||||||
|
# season ID START END unix seconds, START inclusive, END exclusive; seasons must not overlap
|
||||||
|
# mission SLOT TYPE SUB TARGET [VNUM COUNT]x0..3
|
||||||
|
# SLOT 1..10. Progress and claims are stored per season and slot: do not reuse a slot for another mission
|
||||||
|
# within a running season.
|
||||||
|
# TYPE 1 kill monster (SUB mob vnum or 0 = any normal monster) 2 kill boss (SUB vnum or 0)
|
||||||
|
# 3 kill metin stone (SUB vnum or 0) 4 seconds online 5 catch fish (SUB item vnum or 0)
|
||||||
|
# 6 successful refine (SUB result vnum or 0) 7 levels gained 8 gold paid to NPC shops
|
||||||
|
# 9 items sold to NPC shops (SUB item vnum, required)
|
||||||
|
# Kills count for the player the quest kill goes to, within 20 levels of the monster.
|
||||||
|
# final VNUM COUNT x1..6 once every mission of the season is done
|
||||||
|
MTBATTLEPASS 1
|
||||||
|
|
||||||
|
# 2026-10 (Europe/Berlin)
|
||||||
|
season 202610 1790805600 1793487600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2026-11 (Europe/Berlin)
|
||||||
|
season 202611 1793487600 1796079600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2026-12 (Europe/Berlin)
|
||||||
|
season 202612 1796079600 1798758000
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-01 (Europe/Berlin)
|
||||||
|
season 202701 1798758000 1801436400
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-02 (Europe/Berlin)
|
||||||
|
season 202702 1801436400 1803855600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-03 (Europe/Berlin)
|
||||||
|
season 202703 1803855600 1806530400
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-04 (Europe/Berlin)
|
||||||
|
season 202704 1806530400 1809122400
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-05 (Europe/Berlin)
|
||||||
|
season 202705 1809122400 1811800800
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-06 (Europe/Berlin)
|
||||||
|
season 202706 1811800800 1814392800
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-07 (Europe/Berlin)
|
||||||
|
season 202707 1814392800 1817071200
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-08 (Europe/Berlin)
|
||||||
|
season 202708 1817071200 1819749600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-09 (Europe/Berlin)
|
||||||
|
season 202709 1819749600 1822341600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-10 (Europe/Berlin)
|
||||||
|
season 202710 1822341600 1825023600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-11 (Europe/Berlin)
|
||||||
|
season 202711 1825023600 1827615600
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
|
||||||
|
# 2027-12 (Europe/Berlin)
|
||||||
|
season 202712 1827615600 1830294000
|
||||||
|
mission 1 1 0 20000 70043 1 71153 5
|
||||||
|
mission 2 2 0 30 25041 2 71032 1
|
||||||
|
mission 3 3 0 300 50513 3
|
||||||
|
mission 4 4 0 172800 71094 2
|
||||||
|
mission 5 5 0 100 27987 5
|
||||||
|
mission 6 6 0 50 25040 2
|
||||||
|
mission 7 7 0 5 71153 5
|
||||||
|
mission 8 8 0 50000000 71084 20
|
||||||
|
final 27992 2 27993 1 27994 1 70024 1
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
-- PORT: battle pass tables (docs/FEATURE-BATTLEPASS.md). Idempotent; run once on the player database.
|
||||||
|
-- Progress: one row per player, season and mission slot; the game adds deltas and MySQL caps them at target.
|
||||||
|
CREATE TABLE IF NOT EXISTS player.mt_battlepass_progress (
|
||||||
|
pid INT UNSIGNED NOT NULL,
|
||||||
|
season INT UNSIGNED NOT NULL,
|
||||||
|
slot TINYINT UNSIGNED NOT NULL,
|
||||||
|
value BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
target BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (pid, season, slot)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
|
-- Claims: the primary key is the idempotency guard; only the request whose INSERT IGNORE adds the row pays out.
|
||||||
|
-- slot 0 is the final reward.
|
||||||
|
CREATE TABLE IF NOT EXISTS player.mt_battlepass_claim (
|
||||||
|
pid INT UNSIGNED NOT NULL,
|
||||||
|
season INT UNSIGNED NOT NULL,
|
||||||
|
slot TINYINT UNSIGNED NOT NULL,
|
||||||
|
claimed_at INT UNSIGNED NOT NULL,
|
||||||
|
PRIMARY KEY (pid, season, slot)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
Reference in New Issue
Block a user