diff --git a/docs/FEATURE-AVA2-UNLOCK.md b/docs/FEATURE-AVA2-UNLOCK.md index 94fc3f7f..47e6d844 100644 --- a/docs/FEATURE-AVA2-UNLOCK.md +++ b/docs/FEATURE-AVA2-UNLOCK.md @@ -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`. diff --git a/src/server/common/item_length.h b/src/server/common/item_length.h index 523cac95..66574b76 100755 --- a/src/server/common/item_length.h +++ b/src/server/common/item_length.h @@ -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 diff --git a/src/server/common/length.h b/src/server/common/length.h index bbd203cf..2f41aaec 100755 --- a/src/server/common/length.h +++ b/src/server/common/length.h @@ -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 // }; diff --git a/src/server/db/src/ProtoReader.cpp b/src/server/db/src/ProtoReader.cpp index bcd49787..85223efe 100755 --- a/src/server/db/src/ProtoReader.cpp +++ b/src/server/db/src/ProtoReader.cpp @@ -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 }; diff --git a/src/server/game/src/Makefile b/src/server/game/src/Makefile index 9fbf6323..6c94b1a4 100755 --- a/src/server/game/src/Makefile +++ b/src/server/game/src/Makefile @@ -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\ diff --git a/src/server/game/src/char_item.cpp b/src/server/game/src/char_item.cpp index f768503f..cceb854f 100755 --- a/src/server/game/src/char_item.cpp +++ b/src/server/game/src/char_item.cpp @@ -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; diff --git a/src/server/game/src/item.cpp b/src/server/game/src/item.cpp index 75adb0e7..991b84c9 100755 --- a/src/server/game/src/item.cpp +++ b/src/server/game/src/item.cpp @@ -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; diff --git a/src/server/game/src/item.h b/src/server/game/src/item.h index 408097c1..d13d9597 100755 --- a/src/server/game/src/item.h +++ b/src/server/game/src/item.h @@ -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 diff --git a/src/server/game/src/item_attribute.cpp b/src/server/game/src/item_attribute.cpp index 89bda813..61b8f2f4 100755 --- a/src/server/game/src/item_attribute.cpp +++ b/src/server/game/src/item_attribute.cpp @@ -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) diff --git a/src/server/game/src/port_rings.cpp b/src/server/game/src/port_rings.cpp new file mode 100644 index 00000000..0beda935 --- /dev/null +++ b/src/server/game/src/port_rings.cpp @@ -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; + } +} diff --git a/tests/features/test_rings.py b/tests/features/test_rings.py new file mode 100644 index 00000000..99228b37 --- /dev/null +++ b/tests/features/test_rings.py @@ -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,')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);')