29 lines
1.9 KiB
Python
29 lines
1.9 KiB
Python
#!/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 never taken by the switchbot."""
|
|
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 'IsCostumeEnchant' not in source('port_switchbot.cpp') and 's_adwNormal[] = { 71084, 39028 };' in source('port_switchbot.cpp')
|
|
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:','case COSTUME_HAIR:','case COSTUME_WEAPON:','case COSTUME_MOUNT_SKIN:','case COSTUME_NEW_SASH:','case SHINING_WEAPON:',
|
|
'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')
|