AVA2 unlock P6: costume enchants (USE_CHANGE_ATTRIBUTE 54001-54267)
Enchant stones add one fixed attribute to an unequipped body / hair / mount-skin costume (max 3, no duplicates); gear and the switchbot refuse them. MTCATTR chat commands report the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fb066e7046
commit
6199b2cbff
@@ -9,6 +9,7 @@ The 478 AVA2 drop items come from metin2-client `tools/server/ava2-items` (see F
|
||||
| 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 |
|
||||
|
||||
## P1: boxes and keys
|
||||
|
||||
@@ -73,3 +74,28 @@ AVA2's `ENABLE_MOUNT_COSTUME_SYSTEM` + `ENABLE_MOUNT_SKIN`, ported 1:1 into `gam
|
||||
- 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 (talisman) waits for 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`.
|
||||
|
||||
@@ -61,7 +61,7 @@ CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp
|
||||
desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
|
||||
entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
|
||||
guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp port_attr_lock.cpp port_sash.cpp port_mount.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 input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
|
||||
locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
|
||||
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||
|
||||
@@ -2099,6 +2099,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
void MountCostumeEquipped(LPITEM item);
|
||||
void MountCostumeUnequipped(LPITEM item, bool bAlwaysSummon);
|
||||
void MountCostumeOnLogin();
|
||||
bool CostumeEnchantUse(LPITEM item, LPITEM item2);
|
||||
};
|
||||
|
||||
ESex GET_SEX(LPCHARACTER ch);
|
||||
|
||||
@@ -4495,6 +4495,9 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
|
||||
return false;
|
||||
|
||||
if (item->IsCostumeEnchant())
|
||||
return CostumeEnchantUse(item, item2);
|
||||
|
||||
if (item2->IsEquipped())
|
||||
{
|
||||
BuffOnAttr_RemoveBuffsFromItem(item2);
|
||||
|
||||
@@ -236,6 +236,7 @@ class CItem : public CEntity
|
||||
bool IsRideItem();
|
||||
bool IsCostumeMount(); // AVA2 mount costume
|
||||
bool IsCostumeMountSkin();
|
||||
bool IsCostumeEnchant(); // AVA2 costume enchant (port_costume_attr.cpp)
|
||||
bool IsRamadanRing();
|
||||
|
||||
void ClearMountAttributeAndAffect();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ static LPITEM PortSwitchItem(LPCHARACTER ch,const PortSwitchbot& bot) {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
static void PortSwitchState(LPCHARACTER ch,const PortSwitchbot* bot,bool active,const char* reason) {
|
||||
|
||||
@@ -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')
|
||||
@@ -45,6 +45,7 @@ class CHARACTER;
|
||||
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;
|
||||
CHARACTER* owner=nullptr;TItemTable proto{};TPlayerItemAttribute attrs[7];
|
||||
long value2=0;bool IsCostumeEnchant(){return vnum>=54001 && vnum<=54267 && value2;}
|
||||
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;}
|
||||
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 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");
|
||||
// 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");
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user