AVA2 unlock P8: new rings (ITEM_NEW_RINGS, WEAR_RINGS_1/2)

Rings are socket accessories with AVA2's jewel per family and the
item_attr_rings pool (port_rings.cpp); the 40250 switchers / adders accept
them, the switchbot and rare attributes skip them. New ProtoReader type,
so the db binary changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-16 14:40:26 +09:00
co-authored by Claude Opus 5.5
parent f09ffd8a35
commit e313d9ea85
11 changed files with 200 additions and 6 deletions
+17
View File
@@ -11,6 +11,7 @@ The 478 AVA2 drop items come from metin2-client `tools/server/ava2-items` (see F
| 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
@@ -121,3 +122,19 @@ AVA2's `ITEM_TALISMAN_EQUIPMENT` + `ELEMENT_NEW_BONUSES`, in `game/src/port_pend
- 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`.
+2
View File
@@ -76,6 +76,8 @@ enum EItemTypes
ITEM_SECONDARY_COIN, //32 ?? 명도전??
ITEM_RING, //33 반지
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
+2
View File
@@ -141,6 +141,8 @@ enum EWearPositions
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 //
};
+5
View File
@@ -79,6 +79,7 @@ int get_Item_Type_Value(string inputString)
"ITEM_RING",
"ITEM_BELT", //35개 (EItemTypes 값으로 치면 34)
"ITEM_SHINING", "ITEM_NEW_RINGS", // AVA2 35 (not ported), 36 new rings
};
@@ -161,6 +162,8 @@ int get_Item_SubType_Value(int type_value, string inputString)
0, //32
0, //33 반지
0, //34 벨트
0, //35 ITEM_SHINING
0, //36 ITEM_NEW_RINGS
};
static int arNumberOfSubtype[_countof(arSubType)] = {
0,
@@ -198,6 +201,8 @@ int get_Item_SubType_Value(int type_value, string inputString)
0, // 32
0, // 33 반지
0, // 34 벨트
0, // 35
0, // 36
};
+1 -1
View File
@@ -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 port_costume_attr.cpp port_pendant.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\
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\
+4 -3
View File
@@ -1901,6 +1901,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
case ITEM_ROD:
case ITEM_RING: // 신규 반지 아이템
case ITEM_BELT: // 신규 벨트 아이템
case ITEM_NEW_RINGS: // AVA2 new rings
// MINING
case ITEM_PICK:
// END_OF_MINING
@@ -4564,7 +4565,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
break;
case USE_CHANGE_ATTRIBUTE :
if (item2->GetAttributeSetIndex() == -1)
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
return false;
@@ -4669,7 +4670,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
break;
case USE_ADD_ATTRIBUTE :
if (item2->GetAttributeSetIndex() == -1)
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
return false;
@@ -4741,7 +4742,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
case USE_ADD_ATTRIBUTE2 :
// 축복의 구슬
// 재가비서를 통해 속성을 4개 추가 시킨 아이템에 대해서 하나의 속성을 더 붙여준다.
if (item2->GetAttributeSetIndex() == -1)
if (item2->GetAttributeSetIndex() == -1 && !item2->IsNewRing())
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
return false;
+14 -2
View File
@@ -492,7 +492,7 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
// 코스츔 아이템(ITEM_COSTUME)은 WearFlag 없어도 됨. (sub type으로 착용위치 구분. 귀찮게 또 wear flag 줄 필요가 있나..)
// 용혼석(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;
// 용혼석 슬롯을 WEAR로 처리할 수가 없어서(WEAR는 최대 32개까지 가능한데 용혼석을 추가하면 32가 넘는다.)
@@ -540,6 +540,13 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
}
else if (GetType() == ITEM_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)
return WEAR_BODY;
else if (GetWearFlag() & WEARABLE_HEAD)
@@ -877,6 +884,7 @@ bool CItem::IsEquipable() const
case ITEM_SPECIAL_DS:
case ITEM_RING:
case ITEM_BELT:
case ITEM_NEW_RINGS:
return true;
}
@@ -1650,7 +1658,7 @@ int CItem::GetSpecialGroup() const
bool CItem::IsAccessoryForSocket()
{
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)
@@ -1867,6 +1875,10 @@ bool CItem::CanPutInto(LPITEM item)
else if(item->GetType() == ITEM_RING)
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)
return false;
+4
View File
@@ -239,6 +239,8 @@ class CItem : public CEntity
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();
void ClearMountAttributeAndAffect();
@@ -336,4 +338,6 @@ EVENTINFO(item_vid_event_info)
}
};
DWORD GetNewRingJewelVnum(DWORD dwRingVnum); // port_rings.cpp, 0 = none
#endif
+6
View File
@@ -118,6 +118,12 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel)
void CItem::PutAttributeWithLevel(BYTE bLevel)
{
if (IsNewRing())
{
PutNewRingAttributeWithLevel(bLevel);
return;
}
int iAttributeSet = GetAttributeSetIndex();
if (iAttributeSet < 0)
+106
View File
@@ -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;
}
}
+39
View File
@@ -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')