AVA2 unlock P7: talismans (ARMOR_PENDANT / WEAR_PENDANT, element enchants)

- ARMOR_PENDANT subtype, WEAR_PENDANT=27, APPLY_ENCHANT_ELEC..DARK (123-128)
  and POINT_ENCHANT_* (242-247); battle.cpp adds the enchant % vs element mobs
- port_pendant.cpp: talisman attribute pool (AVA2 item_attr pendant column),
  71302/53996 reroll and 71301/53997 add (max 5), MTPENDANT client messages
- switchbot skips talisman scrolls; tests for pendant + applies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-16 14:28:35 +09:00
co-authored by Claude Opus 5.5
parent 6199b2cbff
commit f09ffd8a35
17 changed files with 326 additions and 14 deletions
+1
View File
@@ -106,6 +106,7 @@ enum EArmorSubTypes
ARMOR_FOOTS,
ARMOR_NECK,
ARMOR_EAR,
ARMOR_PENDANT, // 7 AVA2 talisman (ITEM_TALISMAN_EQUIPMENT), worn in WEAR_PENDANT
ARMOR_NUM_TYPES
};
+8
View File
@@ -140,6 +140,7 @@ enum EWearPositions
WEAR_COSTUME_SASH, // 24 : AVA2 sash
WEAR_COSTUME_MOUNT, // 25 : AVA2 mount costume
WEAR_COSTUME_MOUNT_SKIN, // 26 : AVA2 mount skin
WEAR_PENDANT, // 27 : AVA2 talisman (ARMOR_PENDANT)
WEAR_MAX = 32 //
};
@@ -443,6 +444,13 @@ enum EApplyTypes
// PORT AVA2 bonus numbering (AVA2 common/length.h): 92-138 are AVA2 applies not ported yet,
// kept free so later ports and the client item_proto keep AVA2's numbers.
// AVA2 ELEMENT_NEW_BONUSES: attack bonus % against monsters of the element (RACE_FLAG_ATT_*), on the talismans.
APPLY_ENCHANT_ELEC = 123,
APPLY_ENCHANT_FIRE = 124,
APPLY_ENCHANT_ICE = 125,
APPLY_ENCHANT_WIND = 126,
APPLY_ENCHANT_EARTH = 127,
APPLY_ENCHANT_DARK = 128,
APPLY_ATTBONUS_STONE = 139,
APPLY_ATTBONUS_BOSS = 140,
+3 -3
View File
@@ -103,7 +103,7 @@ int get_Item_SubType_Value(int type_value, string inputString)
static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_MOUNT_SPEAR"};
static string arSub2[] = { "ARMOR_BODY", "ARMOR_HEAD", "ARMOR_SHIELD", "ARMOR_WRIST", "ARMOR_FOOTS",
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_NUM_TYPES"};
"ARMOR_NECK", "ARMOR_EAR", "ARMOR_PENDANT", "ARMOR_NUM_TYPES"};
static string arSub3[] = { "USE_POTION", "USE_TALISMAN", "USE_TUNING", "USE_MOVE", "USE_TREASURE_BOX", "USE_MONEYBAG", "USE_BAIT",
"USE_ABILITY_UP", "USE_AFFECT", "USE_CREATE_STONE", "USE_SPECIAL", "USE_POTION_NODELAY", "USE_CLEAR",
"USE_INVISIBILITY", "USE_DETACHMENT", "USE_BUCKET", "USE_POTION_CONTINUE", "USE_CLEAN_SOCKET",
@@ -397,8 +397,8 @@ int get_Item_ApplyType_Value(string inputString)
"APPLY_RESERVED_92", "APPLY_RESERVED_93", "APPLY_RESERVED_94", "APPLY_RESERVED_95", "APPLY_RESERVED_96", "APPLY_RESERVED_97", "APPLY_RESERVED_98", "APPLY_RESERVED_99",
"APPLY_RESERVED_100", "APPLY_RESERVED_101", "APPLY_RESERVED_102", "APPLY_RESERVED_103", "APPLY_RESERVED_104", "APPLY_RESERVED_105", "APPLY_RESERVED_106", "APPLY_RESERVED_107",
"APPLY_RESERVED_108", "APPLY_RESERVED_109", "APPLY_RESERVED_110", "APPLY_RESERVED_111", "APPLY_RESERVED_112", "APPLY_RESERVED_113", "APPLY_RESERVED_114", "APPLY_RESERVED_115",
"APPLY_RESERVED_116", "APPLY_RESERVED_117", "APPLY_RESERVED_118", "APPLY_RESERVED_119", "APPLY_RESERVED_120", "APPLY_RESERVED_121", "APPLY_RESERVED_122", "APPLY_RESERVED_123",
"APPLY_RESERVED_124", "APPLY_RESERVED_125", "APPLY_RESERVED_126", "APPLY_RESERVED_127", "APPLY_RESERVED_128", "APPLY_RESERVED_129", "APPLY_RESERVED_130", "APPLY_RESERVED_131",
"APPLY_RESERVED_116", "APPLY_RESERVED_117", "APPLY_RESERVED_118", "APPLY_RESERVED_119", "APPLY_RESERVED_120", "APPLY_RESERVED_121", "APPLY_RESERVED_122", "APPLY_ENCHANT_ELECT",
"APPLY_ENCHANT_FIRE", "APPLY_ENCHANT_ICE", "APPLY_ENCHANT_WIND", "APPLY_ENCHANT_EARTH", "APPLY_ENCHANT_DARK", "APPLY_RESERVED_129", "APPLY_RESERVED_130", "APPLY_RESERVED_131",
"APPLY_RESERVED_132", "APPLY_RESERVED_133", "APPLY_RESERVED_134", "APPLY_RESERVED_135", "APPLY_RESERVED_136", "APPLY_RESERVED_137", "APPLY_RESERVED_138",
"APPLY_ATTBONUS_STONE", "APPLY_ATTBONUS_BOSS",
};
+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 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 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\
+14
View File
@@ -287,6 +287,20 @@ int CalcAttBonus(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int iAtk)
else if (pkVictim->IsRaceFlag(RACE_FLAG_TREE))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_TREE)) / 100;
// PORT AVA2 ELEMENT_NEW_BONUSES (talisman enchant), each flag on its own like AVA2; AVA2 forgot ICE.
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ELEC))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ELEC)) / 100;
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_FIRE))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_FIRE)) / 100;
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ICE))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_ICE)) / 100;
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_WIND))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_WIND)) / 100;
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_EARTH))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_EARTH)) / 100;
if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_DARK))
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ENCHANT_DARK)) / 100;
if (pkVictim->GetMobRank() >= MOB_RANK_BOSS && !pkVictim->IsStone())
iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_BOSS)) / 100;
int monsterBonus = pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER);
+12
View File
@@ -3449,6 +3449,12 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
// PORT AVA2 biology points
case POINT_ATTBONUS_STONE:
case POINT_ATTBONUS_BOSS:
case POINT_ENCHANT_ELEC:
case POINT_ENCHANT_FIRE:
case POINT_ENCHANT_ICE:
case POINT_ENCHANT_WIND:
case POINT_ENCHANT_EARTH:
case POINT_ENCHANT_DARK:
case POINT_RESIST_HUMAN:
case POINT_ATTBONUS_MONSTER:
case POINT_ATTBONUS_SURA:
@@ -3836,6 +3842,12 @@ void CHARACTER::ApplyPoint(BYTE bApplyType, int iVal)
case APPLY_MAGIC_ATTBONUS_PER: // 85 마법 공격력 +x%
case APPLY_ATTBONUS_STONE:
case APPLY_ATTBONUS_BOSS:
case APPLY_ENCHANT_ELEC:
case APPLY_ENCHANT_FIRE:
case APPLY_ENCHANT_ICE:
case APPLY_ENCHANT_WIND:
case APPLY_ENCHANT_EARTH:
case APPLY_ENCHANT_DARK:
case APPLY_MELEE_MAGIC_ATTBONUS_PER: // 86 마법 + 밀리 공격력 +x%
PointChange(aApplyInfo[bApplyType].bPointType, iVal);
break;
+8
View File
@@ -279,6 +279,13 @@ enum EPointTypes
// PORT AVA2 biology points, within the existing 255-point packet.
POINT_ATTBONUS_STONE = 240,
POINT_ATTBONUS_BOSS = 241,
// PORT AVA2 element enchant (talismans, APPLY_ENCHANT_*).
POINT_ENCHANT_ELEC = 242,
POINT_ENCHANT_FIRE = 243,
POINT_ENCHANT_ICE = 244,
POINT_ENCHANT_WIND = 245,
POINT_ENCHANT_EARTH = 246,
POINT_ENCHANT_DARK = 247,
POINT_RESIST_HUMAN = 220,
// 추가 속성 저항
@@ -2100,6 +2107,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
void MountCostumeUnequipped(LPITEM item, bool bAlwaysSummon);
void MountCostumeOnLogin();
bool CostumeEnchantUse(LPITEM item, LPITEM item2);
bool PendantScrollUse(LPITEM item, LPITEM item2);
};
ESex GET_SEX(LPCHARACTER ch);
+3
View File
@@ -4498,6 +4498,9 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
if (item->IsCostumeEnchant())
return CostumeEnchantUse(item, item2);
if (item->GetPendantScrollKind() || item2->IsTalisman())
return PendantScrollUse(item, item2);
if (item2->IsEquipped())
{
BuffOnAttr_RemoveBuffsFromItem(item2);
+12 -6
View File
@@ -946,12 +946,12 @@ const TApplyInfo aApplyInfo[MAX_APPLY_NUM] =
{ POINT_NONE }, // 120
{ POINT_NONE }, // 121
{ POINT_NONE }, // 122
{ POINT_NONE }, // 123
{ POINT_NONE }, // 124
{ POINT_NONE }, // 125
{ POINT_NONE }, // 126
{ POINT_NONE }, // 127
{ POINT_NONE }, // 128
{ POINT_ENCHANT_ELEC }, // APPLY_ENCHANT_ELEC 123
{ POINT_ENCHANT_FIRE }, // APPLY_ENCHANT_FIRE 124
{ POINT_ENCHANT_ICE }, // APPLY_ENCHANT_ICE 125
{ POINT_ENCHANT_WIND }, // APPLY_ENCHANT_WIND 126
{ POINT_ENCHANT_EARTH }, // APPLY_ENCHANT_EARTH 127
{ POINT_ENCHANT_DARK }, // APPLY_ENCHANT_DARK 128
{ POINT_NONE }, // 129
{ POINT_NONE }, // 130
{ POINT_NONE }, // 131
@@ -1333,6 +1333,12 @@ TValueName c_aApplyTypeNames[] =
{ "ATTBONUS_STONE", APPLY_ATTBONUS_STONE },
{ "ATTBONUS_BOSS", APPLY_ATTBONUS_BOSS },
{ "ENCHANT_ELEC", APPLY_ENCHANT_ELEC },
{ "ENCHANT_FIRE", APPLY_ENCHANT_FIRE },
{ "ENCHANT_ICE", APPLY_ENCHANT_ICE },
{ "ENCHANT_WIND", APPLY_ENCHANT_WIND },
{ "ENCHANT_EARTH", APPLY_ENCHANT_EARTH },
{ "ENCHANT_DARK", APPLY_ENCHANT_DARK },
{ NULL, 0 }
};
// from import_item_proto.c
+3
View File
@@ -487,6 +487,9 @@ bool CItem::CanUsedBy(LPCHARACTER ch)
int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
{
if (IsTalisman())
return WEAR_PENDANT;
// 코스츔 아이템(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())
+2
View File
@@ -237,6 +237,8 @@ class CItem : public CEntity
bool IsCostumeMount(); // AVA2 mount costume
bool IsCostumeMountSkin();
bool IsCostumeEnchant(); // AVA2 costume enchant (port_costume_attr.cpp)
bool IsTalisman(); // AVA2 talisman (port_pendant.cpp)
int GetPendantScrollKind();
bool IsRamadanRing();
void ClearMountAttributeAndAffect();
+190
View File
@@ -0,0 +1,190 @@
// AVA2 talisman (ITEM_TALISMAN_EQUIPMENT + ELEMENT_NEW_BONUSES): ITEM_ARMOR / ARMOR_PENDANT, worn in WEAR_PENDANT.
// A talisman's APPLY_ENCHANT_<element> (= its refine level, +0..+200) adds that % to attacks on monsters with the
// matching RACE_FLAG_ATT_* (battle.cpp).
// Its random attributes come from AVA2's item_attr "pendant" column. That column is not added to 203's item_attr
// table and ATTRIBUTE_SET_*, which would change the db -> game boot packet. Instead the pool lives here and
// GetAttributeSetIndex() stays -1, so the 40250 switchers, the switchbot and the attribute lock never touch a
// talisman, and drops carry no magic attributes.
// Only the talisman items change its attributes; AVA2 uses 71302 (reroll) and 71301 (add, up to 5). The
// imported 53996 / 53997 (AVA2 generic switcher / adder, which would be free 40250 gear rerolls) act as the same
// talisman reroll / add here, as their zh names say. Messages go to the client as "MTPENDANT <code>"
// (rendered by the client's mt_pendant script) instead of AVA2's locale strings 1056 / 1057 / 1067.
#include "stdafx.h"
#include "constants.h"
#include "char.h"
#include "item.h"
#include "log.h"
namespace
{
struct PendantAttr
{
BYTE bApply;
DWORD dwProb;
short asValues[ITEM_ATTRIBUTE_MAX_LEVEL];
};
// AVA2 player.item_attr rows whose pendant column is set (all with max level 5).
const PendantAttr s_aPendantAttr[] =
{
{ APPLY_MAX_HP, 35, { 1500, 1500, 1500, 2000, 2000 } },
{ APPLY_MAX_SP, 35, { 50, 50, 50, 80, 80 } },
{ APPLY_CON, 11, { 8, 8, 8, 12, 12 } },
{ APPLY_INT, 11, { 8, 8, 8, 12, 12 } },
{ APPLY_STR, 11, { 8, 8, 8, 12, 12 } },
{ APPLY_DEX, 11, { 8, 8, 8, 12, 12 } },
{ APPLY_HP_REGEN, 60, { 20, 20, 20, 30, 30 } },
{ APPLY_SP_REGEN, 60, { 20, 20, 20, 30, 30 } },
{ APPLY_STEAL_HP, 50, { 5, 5, 5, 10, 10 } },
{ APPLY_STEAL_SP, 50, { 5, 5, 5, 10, 10 } },
{ APPLY_MANA_BURN_PCT, 18, { 5, 5, 5, 10, 10 } },
{ APPLY_DODGE, 15, { 8, 8, 8, 10, 10 } },
{ APPLY_POISON_REDUCE, 15, { 5, 5, 5, 8, 8 } },
{ APPLY_KILL_SP_RECOVER, 10, { 5, 5, 5, 10, 10 } },
{ APPLY_EXP_DOUBLE_BONUS, 10, { 10, 10, 10, 20, 20 } },
{ APPLY_GOLD_DOUBLE_BONUS, 10, { 10, 10, 10, 20, 20 } },
{ APPLY_ITEM_DROP_BONUS, 10, { 10, 10, 10, 20, 20 } },
{ APPLY_KILL_HP_RECOVER, 10, { 5, 5, 5, 10, 10 } },
{ APPLY_ANTI_CRITICAL_PCT, 10, { 4, 4, 4, 10, 10 } },
{ APPLY_ANTI_PENETRATE_PCT, 10, { 4, 4, 4, 10, 10 } },
};
enum
{
PENDANT_MAX_ATTR = 5, // AVA2: 71301 adds while GetAttributeCount() < 5
};
// 203 CItem::ChangeAttribute / AddAttribute level tables (AVA2 has the same).
const int s_aiChangeLevel[ITEM_ATTRIBUTE_MAX_LEVEL] = { 0, 10, 40, 35, 15 };
const int s_aiAddLevel[ITEM_ATTRIBUTE_MAX_LEVEL] = { 40, 50, 10, 0, 0 };
int PendantLevel(const int * aiPercent)
{
int iPercent = number(1, 100);
int i;
for (i = 0; i < ITEM_ATTRIBUTE_MAX_LEVEL - 1; ++i)
{
if (iPercent <= aiPercent[i])
break;
iPercent -= aiPercent[i];
}
return i;
}
// CItem::PutAttributeWithLevel over the talisman pool.
void PendantPutAttribute(LPITEM item, const int * aiPercent)
{
DWORD dwTotal = 0;
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
if (!item->HasAttr(s_aPendantAttr[i].bApply))
dwTotal += s_aPendantAttr[i].dwProb;
if (!dwTotal)
return;
DWORD dwProb = number(1, dwTotal);
for (size_t i = 0; i < sizeof(s_aPendantAttr) / sizeof(s_aPendantAttr[0]); ++i)
{
const PendantAttr & r = s_aPendantAttr[i];
if (item->HasAttr(r.bApply))
continue;
if (dwProb <= r.dwProb)
{
item->AddAttribute(r.bApply, r.asValues[PendantLevel(aiPercent)]);
return;
}
dwProb -= r.dwProb;
}
}
}
bool CItem::IsTalisman()
{
return GetType() == ITEM_ARMOR && GetSubType() == ARMOR_PENDANT;
}
// 1 = reroll, 2 = add, 0 = not a talisman attribute item.
int CItem::GetPendantScrollKind()
{
if (GetType() != ITEM_USE)
return 0;
switch (GetVnum())
{
case 71302:
case 53996:
return GetSubType() == USE_CHANGE_ATTRIBUTE ? 1 : 0;
case 71301:
case 53997:
return GetSubType() == USE_ADD_ATTRIBUTE ? 2 : 0;
}
return 0;
}
bool CHARACTER::PendantScrollUse(LPITEM item, LPITEM item2)
{
if (item2->IsExchanging())
return false;
const int kind = item->GetPendantScrollKind();
if (!kind || !item2->IsTalisman())
{
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT target");
return false;
}
// 40250 never changes the attributes of a worn item (the "Fix" in the switcher path).
if (item2->IsEquipped())
{
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT equipped");
return false;
}
char buf[21];
snprintf(buf, sizeof(buf), "%u", item2->GetID());
if (kind == 1)
{
const int iCount = item2->GetAttributeCount();
if (!iCount)
{
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT empty");
return false;
}
item2->ClearAttribute();
for (int i = 0; i < iCount; ++i)
PendantPutAttribute(item2, s_aiChangeLevel);
LogManager::instance().ItemLog(this, item, "PENDANT_CHANGE", buf);
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT changed");
}
else
{
if (item2->GetAttributeCount() >= PENDANT_MAX_ATTR)
{
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT full");
return false;
}
PendantPutAttribute(item2, s_aiAddLevel);
LogManager::instance().ItemLog(this, item, "PENDANT_ADD", buf);
ChatPacket(CHAT_TYPE_COMMAND, "MTPENDANT added");
}
item->SetCount(item->GetCount() - 1);
return true;
}
+1 -1
View File
@@ -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 && !scroll->IsCostumeEnchant();
return scroll && scroll->GetType()==ITEM_USE && scroll->GetSubType()==USE_CHANGE_ATTRIBUTE && !scroll->IsCostumeEnchant() && !scroll->GetPendantScrollKind();
}
static void PortSwitchState(LPCHARACTER ch,const PortSwitchbot* bot,bool active,const char* reason) {