Guía Main 5.2: Cómo resaltar slots del inventario para ítems compatibles - Source Mu - Mu Server Files
 

Guía Main 5.2: Cómo resaltar slots del inventario para ítems compatibles

Publicado por Dakosmu, Feb 20, 2026, 07:40 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Dakosmu

Guía Main 5.2: Cómo resaltar slots del inventario para ítems compatibles

Regístrate para ver el enlace

Bienvenidos a esta guía detallada para el Main 5.2. Hoy aprenderemos a implementar una mejora visual en el sistema de equipo: Colocar a los slots del inventario un resaltado dinámico.

Esta modificación permite que, al arrastrar cualquier objeto, el juego detecte automáticamente qué posición es válida, facilitando el uso del inventario para los jugadores de tu servidor.



Beneficios de esta implementación

  • Mejora la UX: Los usuarios nuevos sabrán exactamente dónde va cada ítem.
  • Estética Profesional: Dale a tu Main 5.2 un toque moderno y funcional.
  • Optimización: Código limpio que no afecta los FPS del cliente.

Instalación paso a paso en C++

Sigue estos pasos para modificar el renderizado de tu inventario. Debes editar el archivo NewUIMyInventory.cpp en tu proyecto del Main.

Código Fuente Completo:

void SEASON3B::CNewUIMyInventory::RenderEquippedItem()
{
for (int i : EquipmentInven)
{
if (i == EQUIPMENT_HELM && Hero->GetBaseClass() == Magic_Gladiator)
{
continue;
}

if (i == EQUIPMENT_GLOVES && Hero->GetBaseClass() == Rage_Fighter)
{
continue;
}

if (m_Equipment[i].index == -1 || !m_Equipment[i].CheckRender)
{
continue;
}

EnableAlphaTest();

EQUIPMENT_ITEM* info = &m_Equipment[i];
#if MAIN_UPDATE > 603
float uv = 67.f;
float vh = 68.f;

if (i == 0 || i == 1 || i == 3 || i == 18)
{
uv = 142.f;
vh = 220.f;
}
else if (i == 2 || i == 4 || i == 5 || i == 6 || i == 8)
{
uv = 142.f;
vh = 143.f;
}
else if (i == 7 || i == 17)
{
uv = 220.f;
vh = 143.f;
}

RenderImageF(info->dwBgImage, info->x, info->y, info->width, info->height, 0.0f, 0.0f, uv, vh);
#else
RenderImageF(info->dwBgImage, info->x, info->y, info->width, info->height);
#endif
DisableAlphaBlend();

ITEM* pEquipmentItemSlot = &CharacterMachine->Equipment[i];

if (pEquipmentItemSlot->Type != -1)
{
Script_Item* pItemAttr = GMItemMng->find(pEquipmentItemSlot->Type);
int iLevel = (pEquipmentItemSlot->Level >> 3) & 15;
int iMaxDurability = calcMaxDurability(pEquipmentItemSlot, pItemAttr, iLevel);

if (i == EQUIPMENT_RING_LEFT || i == EQUIPMENT_RING_RIGHT)
{
if (pEquipmentItemSlot->Type == ITEM_HELPER + 20 && iLevel == 1
|| iLevel == 2)
{
continue;
}
}

if ((pEquipmentItemSlot->bPeriodItem == true) && (pEquipmentItemSlot->bExpiredPeriod == false))
continue;

if (pEquipmentItemSlot->Durability <= 0)
glColor4f(1.f, 0.f, 0.f, 0.25f);
else if (pEquipmentItemSlot->Durability <= (iMaxDurability * 0.2f))
glColor4f(1.f, 0.15f, 0.f, 0.25f);
else if (pEquipmentItemSlot->Durability <= (iMaxDurability * 0.3f))
glColor4f(1.f, 0.5f, 0.f, 0.25f);
else if (pEquipmentItemSlot->Durability <= (iMaxDurability * 0.5f))
glColor4f(1.f, 1.f, 0.f, 0.25f);
else if (this->IsEquipable(EquipmentClientToServer(i), pEquipmentItemSlot) == false)
glColor4f(1.f, 0.f, 0.f, 0.25f);
else
continue;

EnableAlphaTest();

if (gmProtect->checkold_school())
RenderColor(info->x + 2, info->y, info->width - 2, info->height - 2);
else
RenderColor(info->x + 1, info->y, info->width - 4, info->height - 4);

EndRenderColor();
}
}

// --- INICIO SEO: Resaltar slots compatibles para Main 5.2 ---
CNewUIPickedItem* pPickedItem = CNewUIInventoryCtrl::GetPickedItem();

if (pPickedItem)
{
ITEM* pItemObj = pPickedItem->GetItem();
if (pItemObj)
{
for (int i : EquipmentInven)
{
if (m_Equipment[i].index == -1) continue;

if (i == EQUIPMENT_HELM && Hero->GetBaseClass() == Magic_Gladiator)
{
continue;
}

ITEM* pCurrentSlot = &CharacterMachine->Equipment[i];

// Validamos si el slot está libre y si el ítem es compatible
if (pCurrentSlot->Type == -1 && this->IsEquipable(EquipmentClientToServer(i), pItemObj))
{
EnableAlphaTest();
glColor4f(0.1f, 0.9f, 0.1f, 0.4f); // Resaltado Verde

EQUIPMENT_ITEM* info = &m_Equipment[i];

if (gmProtect->checkold_school())
RenderColor(info->x + 2, info->y, info->width - 2, info->height - 2);
else
RenderColor(info->x + 1, info->y, info->width - 4, info->height - 4);

EndRenderColor();
}
}
}
}
// --- FIN ---

if (CNewUIInventoryCtrl::GetPickedItem() && m_iPointedSlot != -1)
{
ITEM* pItemObj = CNewUIInventoryCtrl::GetPickedItem()->GetItem();
ITEM* pEquipmentItemSlot = &CharacterMachine->Equipment[m_iPointedSlot];

if (pItemObj && (pEquipmentItemSlot->Type != -1 || false == this->IsEquipable(EquipmentClientToServer(m_iPointedSlot), pItemObj)) && !((Hero->GetBaseClass() == CLASS_RAGEFIGHTER) && (m_iPointedSlot == EQUIPMENT_GLOVES)))
{
EQUIPMENT_ITEM* info = &m_Equipment[m_iPointedSlot];

if (info->index != -1)
{
EnableAlphaTest();
glColor4f(0.9f, 0.1f, 0.1f, 0.4f); // Rojo (No equipable u ocupado)

if (gmProtect->checkold_school())
RenderColor(info->x + 2, info->y, info->width - 2, info->height - 2);
else
RenderColor(info->x + 1, info->y, info->width - 4, info->height - 4);

EndRenderColor();
}
}
}

if (m_iPointedSlot != -1 && m_pNewUI3DRenderMng)
{
if (m_iPointedSlot != m_iBackPointed)
{
if (m_iPointedSlot == EQUIPMENT_HELPER)
{
if (CharacterMachine->Equipment[EQUIPMENT_HELPER].Type == ITEM_HELPER + 4
|| CharacterMachine->Equipment[EQUIPMENT_HELPER].Kind3 == ItemKind3::PET_GAIN_EXPERIENCE)
{
SendRequestPetInfo(PET_TYPE_DARK_HORSE, 0, EQUIPMENT_HELPER);
}
}
if (m_iPointedSlot == EQUIPMENT_WEAPON_LEFT)
{
if (CharacterMachine->Equipment[EQUIPMENT_WEAPON_LEFT].Type == ITEM_HELPER + 5)
{
SendRequestPetInfo(PET_TYPE_DARK_SPIRIT, 0, EQUIPMENT_WEAPON_LEFT);
}
}
}
m_pNewUI3DRenderMng->RenderUI2DEffect(TOOLTIP_CAMERA_Z_ORDER, UI2DEffectCallback, this, m_iPointedSlot, 0);
}
m_iBackPointed = m_iPointedSlot;
}

Detalles Técnicos Finales

  • Compatibilidad: Funciona perfectamente en versiones basadas en Season 6 y adaptaciones para Main 5.2.
  • Lógica de Colores: El código utiliza glColor4f para generar una transparencia suave sobre los slots.
  • Seguridad: Incluye los checks de clase (MG/RF) para evitar errores de renderizado en slots no permitidos.

Descargas y Recursos

Regístrate para ver el enlace

Si te gustó este aporte para los slots del inventario, no olvides dejar tu comentario y unirte a nuestra comunidad.
Bon Dia

🡱 🡳
Real Time Web Analytics