AVA2 unlock P4: sash (COSTUME_SASH, WEAR 24, PART_SASH, CG 211/GC 215, pc.open_sash)
Ports AVA2's sash system into port_sash.cpp: combine and absorb windows, absorbed bonuses scaled by absorption, and a fifth character equip part. The character packets grow by one WORD, so old clients break. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
14c4491469
commit
c30258ef5e
@@ -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" };' 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')
|
||||
Reference in New Issue
Block a user