AVA2 unlock P4: sash (COSTUME_SASH, WEAR 24, PART_SASH, CG 211/GC 215, pc.open_sash)

Ports AVA2's sash system into port_sash.cpp: combine and absorb windows,
absorbed bonuses scaled by absorption, and a fifth character equip part.
The character packets grow by one WORD, so old clients break.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-16 13:44:49 +09:00
co-authored by Claude Opus 5.5
parent 14c4491469
commit c30258ef5e
20 changed files with 743 additions and 10 deletions
+70 -8
View File
@@ -366,6 +366,20 @@ bool CItem::AddToCharacter(LPCHARACTER ch, TItemPos Cell)
if (ch->GetDesc())
m_dwLastOwnerPID = ch->GetPlayerID();
// AVA2 sash: a fresh sash gets the starting absorption of its grade
if (GetType() == ITEM_COSTUME && GetSubType() == COSTUME_SASH && GetSocket(SASH_ABSORPTION_SOCKET) == 0)
{
long lVal;
switch (GetValue(SASH_GRADE_VALUE_FIELD))
{
case 2: lVal = SASH_GRADE_2_ABS; break;
case 3: lVal = SASH_GRADE_3_ABS; break;
case 4: lVal = number(SASH_GRADE_4_ABS_MIN, SASH_GRADE_4_ABS_MAX_COMB); break;
default: lVal = SASH_GRADE_1_ABS; break;
}
SetSocket(SASH_ABSORPTION_SOCKET, lVal);
}
event_cancel(&m_pkDestroyEvent);
ch->SetItem(TItemPos(window_type, pos), this);
@@ -507,6 +521,8 @@ int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
return WEAR_COSTUME_BODY;
else if (GetSubType() == COSTUME_HAIR)
return WEAR_COSTUME_HAIR;
else if (GetSubType() == COSTUME_SASH)
return WEAR_COSTUME_SASH;
}
else if (GetType() == ITEM_RING)
{
@@ -635,23 +651,54 @@ void CItem::ModifyPoints(bool bAdd)
accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
}
// AVA2 sash: the absorbed item's applies (and a body armor's defense) at the absorption %, instead of
// the sash's own applies; its attributes count at the absorption % below
const bool bSash = GetType() == ITEM_COSTUME && GetSubType() == COSTUME_SASH;
const TItemTable * pkAbsorbed = bSash && GetSocket(SASH_ABSORBED_SOCKET) ? ITEM_MANAGER::instance().GetTable(GetSocket(SASH_ABSORBED_SOCKET)) : NULL;
const long lAbsorption = bSash ? GetSocket(SASH_ABSORPTION_SOCKET) : 100;
if (pkAbsorbed && pkAbsorbed->bType == ITEM_ARMOR && pkAbsorbed->bSubType == ARMOR_BODY)
{
long lDefGrade = (long) ((pkAbsorbed->alValues[1] + pkAbsorbed->alValues[5] * 2) * lAbsorption / 100.0 + .5);
if (pkAbsorbed->alValues[1] > 0 || pkAbsorbed->alValues[5] > 0)
lDefGrade += 1;
m_pOwner->ApplyPoint(APPLY_DEF_GRADE_BONUS, bAdd ? lDefGrade : -lDefGrade);
long lDefMagicBonus = (long) (pkAbsorbed->alValues[0] * lAbsorption / 100.0 + .5);
if (pkAbsorbed->alValues[0] > 0)
lDefMagicBonus += 1;
m_pOwner->ApplyPoint(APPLY_MAGIC_DEF_GRADE, bAdd ? lDefMagicBonus : -lDefMagicBonus);
}
for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
{
if (m_pProto->aApplies[i].bType == APPLY_NONE)
continue;
BYTE bType = m_pProto->aApplies[i].bType;
long value = m_pProto->aApplies[i].lValue;
if (m_pProto->aApplies[i].bType == APPLY_SKILL)
if (bSash)
{
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : value ^ 0x00800000);
if (!pkAbsorbed || pkAbsorbed->aApplies[i].bType == APPLY_NONE || pkAbsorbed->aApplies[i].lValue < 0)
continue;
bType = pkAbsorbed->aApplies[i].bType;
value = (long) (pkAbsorbed->aApplies[i].lValue * lAbsorption / 100.0 + .5);
if (pkAbsorbed->aApplies[i].lValue > 0 && value <= 0)
value += 1;
}
if (bType == APPLY_NONE)
continue;
if (bType == APPLY_SKILL)
{
m_pOwner->ApplyPoint(bType, bAdd ? value : value ^ 0x00800000);
}
else
{
if (0 != accessoryGrade)
value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value);
m_pOwner->ApplyPoint(bType, bAdd ? value : -value);
}
}
// 초승달의 반지, 할로윈 사탕, 행복의 반지, 영원한 사랑의 펜던트의 경우
@@ -672,11 +719,19 @@ void CItem::ModifyPoints(bool bAdd)
if (GetAttributeType(i))
{
const TPlayerItemAttribute& ia = GetAttribute(i);
long sValue = ia.sValue;
if (bSash)
{
sValue = (long) (ia.sValue * lAbsorption / 100.0 + .5);
if (ia.sValue > 0 && sValue <= 0)
sValue += 1;
}
if (ia.bType == APPLY_SKILL)
m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : ia.sValue ^ 0x00800000);
m_pOwner->ApplyPoint(ia.bType, bAdd ? sValue : sValue ^ 0x00800000);
else
m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : -ia.sValue);
m_pOwner->ApplyPoint(ia.bType, bAdd ? sValue : -sValue);
}
}
}
@@ -766,6 +821,13 @@ void CItem::ModifyPoints(bool bAdd)
toSetValue = (true == bAdd) ? this->GetValue(3) : 0;
}
// AVA2 sash: the client draws item (part + 85000)
else if (GetSubType() == COSTUME_SASH)
{
toSetPart = PART_SASH;
toSetValue = (true == bAdd) ? this->GetVnum() - 85000 : 0;
}
if (PART_MAX_NUM != toSetPart)
{
m_pOwner->SetPart((BYTE)toSetPart, toSetValue);