Files
metin2-server/tests/features/test_applies.py
T
shenleiandClaude Opus 5.5 f09ffd8a35 AVA2 unlock P7: talismans (ARMOR_PENDANT / WEAR_PENDANT, element enchants)
- ARMOR_PENDANT subtype, WEAR_PENDANT=27, APPLY_ENCHANT_ELEC..DARK (123-128)
  and POINT_ENCHANT_* (242-247); battle.cpp adds the enchant % vs element mobs
- port_pendant.cpp: talisman attribute pool (AVA2 item_attr pendant column),
  71302/53996 reroll and 71301/53997 add (max 5), MTPENDANT client messages
- switchbot skips talisman scrolls; tests for pendant + applies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:28:35 +09:00

42 lines
2.7 KiB
Python

#!/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')