Yahallo
Haven't seen this released yet(I think? cba to look any further) and multiple servers have it already. This was taken from the Duelists source.
Feel free to do whatever you want with it.
Make sure to read the code blocks carefully, as I have left some comments and instructipns!
MMatchItem.h
MMatchItemDescMgr:: ParseItem
MMatchItem.cpp
ZItemSlotView::OnDraw
ZShopEquipItem.h
ZShopEquipItem.cpp
ZShopEquipItem_Match::FillItemDesc
ZShopEquipListItem::OnDraw
Example usage of rarity attribute in zitem.xml
Just add the rarity attribute to an item, and set a rarity from the enum.
May have missed a step or two lol, just let me know
Shouts to the gang- Jetman, Doko, Malik b0ss, and Prolib
Cheers
Haven't seen this released yet(I think? cba to look any further) and multiple servers have it already. This was taken from the Duelists source.
Feel free to do whatever you want with it.
Make sure to read the code blocks carefully, as I have left some comments and instructipns!
MMatchItem.h
Code:
enum MMatchItemRarity
{
MMIR_COMMON = 0,
MMIR_UNCOMMON,
MMIR_RARE,
MMIR_EPIC,
MMIR_LEGENDARY,
MMIR_UNIQUE,
MMIR_EVENT,
MMIR_STAFF
};
enum MMatchItemRarityColor
{
MMIRC_COMMON = 0xFFC0C0C0, //maiet white
MMIRC_UNCOMMON = 0xFF33CC33, //green
MMIRC_RARE = 0xFF0066FF, //blue
MMIRC_EPIC = 0xFF9933FF, //purple
MMIRC_LEGENDARY = 0xFFFF9900, //orange
MMIRC_UNIQUE = 0xFFFF3300, //orange-red
MMIRC_EVENT = 0xFFFF3399, //pink
MMIRC_STAFF = 0xFF00BFFF //cyan
};
In MMatchItemDesc struct:
MMatchItemRarity m_nRarity;
MMatchItemRarity GetItemRarity() { return m_nRarity; }
MMatchItemRarityColor GetColorByRarity();
MMatchItemDescMgr:: ParseItem
Code:
After
else if (!_stricmp(szAttrName, "angle"))
{
pNewDesc->m_nAngle.Set(atoi(szAttrValue));
pNewDesc->m_nAngle.MakeCrc();
}
Add
else if (!_stricmp(szAttrName, "rarity"))
{
pNewDesc->m_nRarity = ((MMatchItemRarity)atoi(szAttrValue));
}
MMatchItem.cpp
Code:
MMatchItemRarityColor MMatchItemDesc::GetColorByRarity()
{
MMatchItemRarityColor color;
switch (m_nRarity)
{
case MMIR_COMMON:
color = MMIRC_COMMON;
break;
case MMIR_UNCOMMON:
color = MMIRC_UNCOMMON;
break;
case MMIR_RARE:
color = MMIRC_RARE;
break;
case MMIR_EPIC:
color = MMIRC_EPIC;
break;
case MMIR_LEGENDARY:
color = MMIRC_LEGENDARY;
break;
case MMIR_UNIQUE:
color = MMIRC_UNIQUE;
break;
case MMIR_EVENT:
color = MMIRC_EVENT;
break;
case MMIR_STAFF:
color = MMIRC_STAFF;
break;
default:
color = MMIRC_COMMON;
break;
}
return color;
}
ZItemSlotView::OnDraw
Code:
After
if (m_nItemID != -1) {
nItemID = m_nItemID;
} else {
nItemID = ZGetMyInfo()->GetItemList()->GetEquipedItemID(m_nParts);
}
Add
MMatchItemDesc* pItemDesc = NULL;
MCOLOR rarityColor = (MCOLOR)MMIRC_COMMON;
if (nItemID != 0)
{
pItemDesc = MGetMatchItemDescMgr()->GetItemDesc(nItemID);
if (pItemDesc)
rarityColor = (MCOLOR)pItemDesc->GetColorByRarity();
}
In the same function, look for
pDC->SetColor( MCOLOR(0xFFC0C0C0));
Replace with
pDC->SetColor(rarityColor);
ZShopEquipItem.h
Code:
In the ZShopEquipItem class, add
virtual MMatchItemRarityColor GetRarityColor() = 0;
In ZShopEquipItem_Gamble, ZShopEquipItem_Match, ZShopEquipItem_Quest, and ZShopEquipItem_Set classes, add
virtual MMatchItemRarityColor GetRarityColor();
ZShopEquipItem.cpp
Code:
-- Gamble items not supported yet.
MMatchItemRarityColor ZShopEquipItem_Gamble::GetRarityColor()
{
return MMIRC_COMMON;
}
-- Quest items not supported yet.
MMatchItemRarityColor ZShopEquipItem_Quest::GetRarityColor()
{
return MMIRC_COMMON;
}
-- Set items not supported yet.
MMatchItemRarityColor ZShopEquipItem_Set::GetRarityColor()
{
return MMIRC_COMMON;
}
MMatchItemRarityColor ZShopEquipItem_Match::GetRarityColor()
{
return m_pItemDesc->GetColorByRarity();
}
ZShopEquipItem_Match::FillItemDesc
Code:
After
if(!pTextArea) return;
Add/replace
MMatchItemRarityColor rarityColor = pItemDesc->GetColorByRarity();
pTextArea->SetTextColor( MCOLOR(rarityColor));
pTextArea->SetText( pItemDesc->m_pMItemName->Ref().m_szItemName);
ZShopEquipListItem::OnDraw
Code:
Add/replace with
if (bSelected)
pDC->SetColor(220, 220, 220);
else if (bMouseOver)
{
auto rgb = (MCOLOR)m_pItemData->GetRarityColor();
rgb.a = 40;
pDC->SetColor(rgb);
}
else if (bMouseOver)
pDC->SetColor(60, 60, 60);
else
pDC->SetColor(30, 30, 30);
pDC->FillRectangle(r);
if (bSelected)
pDC->SetColor(104, 191, 255);
else if (bMouseOver)
pDC->SetColor(MCOLOR(m_pItemData->GetRarityColor()));
else
pDC->SetColor(64, 64, 64, 255);
pDC->Rectangle(r.x, r.y, r.w, r.h);
MRECT rcIcon;
GetIconRect(rcIcon, r);
rcIcon.x += r.x;
rcIcon.y += r.y;
pDC->SetColor(15, 15, 15);
pDC->FillRectangle(rcIcon);
pDC->SetBitmap(m_pItemData->GetIcon());
pDC->Draw(rcIcon);
MRECT rc;
rc.x = rcIcon.x + rcIcon.w + 2;
rc.w = r.w - rcIcon.w - 6;
rc.y = r.y + 2;
rc.h = r.h - 4;
//if (!bSelected)
// pDC->SetColor(200, 200, 200);
//else
// pDC->SetColor(20, 20, 20);
if (!bSelected)
pDC->SetColor(100, 100, 100);
else
pDC->SetColor(20, 20, 20);
MCOLOR oldColor = pDC->GetColor();
pDC->SetColor((MCOLOR)m_pItemData->GetRarityColor());
pDC->TextMultiLine2(rc, GetString(), CONVERT600(2), true, MAM_LEFT | MAM_TOP);
pDC->SetColor(oldColor);
pDC->Text(rc, m_szPrice, MAM_RIGHT | MAM_BOTTOM);
pDC->SetColor(20, 20, 20);
pDC->Text(MRECT(rcIcon.x+1, rcIcon.y, rcIcon.w, rcIcon.h), m_szLevel, MAM_LEFT | MAM_BOTTOM);
pDC->Text(MRECT(rcIcon.x-1, rcIcon.y, rcIcon.w, rcIcon.h), m_szLevel, MAM_LEFT | MAM_BOTTOM);
pDC->Text(MRECT(rcIcon.x, rcIcon.y, rcIcon.w, rcIcon.h+1), m_szLevel, MAM_LEFT | MAM_BOTTOM);
pDC->Text(MRECT(rcIcon.x, rcIcon.y, rcIcon.w, rcIcon.h-1), m_szLevel, MAM_LEFT | MAM_BOTTOM);
if (ZGetMyInfo()->GetLevel() < m_pItemData->GetLevelRes())
pDC->SetColor(200, 10, 10);
else
pDC->SetColor(200, 200, 200);
pDC->Text(rcIcon, m_szLevel, MAM_LEFT | MAM_BOTTOM);
Example usage of rarity attribute in zitem.xml
Just add the rarity attribute to an item, and set a rarity from the enum.
Code:
<ITEM id="524541" name="Magician Shoes (Women)" mesh_name="eq_feet_magician" rarity="3" .... />
May have missed a step or two lol, just let me know
Shouts to the gang- Jetman, Doko, Malik b0ss, and Prolib
Cheers
Last edited:

