Source ItemConvert 1.04E MU Online: Función del Código en el MMORPG
El Source ItemConvert 1.04E es una parte esencial del código en MU Online, un popular MMORPG. Este código, contenido en ItemConvert.cpp, maneja la conversión y optimización de ítems dentro del juego, asegurando que cada uno tenga atributos y características alineados con las expectativas de los jugadores.
Principales Funciones del Código ItemConvert 1.04E
- Conversión de Ítems:
- El método ItemConvert se encarga de modificar los atributos de un ítem durante su conversión, ajustando su nivel, daño, defensa y poder mágico.
- Aplicación de Atributos:
- Calcula y aplica atributos especiales a los ítems, como bonificaciones por «excelencia» y opciones extendidas, enriqueciendo la experiencia de juego.
- Requisitos de Equipamiento:
- Gestiona los requisitos necesarios para equipar ciertos ítems, añadiendo un nivel de estrategia al juego. Los jugadores deben cumplir con estos requisitos para utilizar ítems avanzados.
- Verificación de Ítems Especiales:
- Incluye lógica para identificar ítems especiales, como cetros, asegurando que se comporten de manera única en el juego.
- Optimización del Juego:
- Establece hooks en el juego para garantizar que las conversiones de ítems se realicen en momentos clave, optimizando el rendimiento y la jugabilidad.
Conclusión sobre Source ItemConvert 1.04E
En resumen, el código ItemConvert.cpp en MU Online es fundamental para la gestión de ítems, permitiendo a los jugadores disfrutar de una experiencia de juego rica y dinámica. Al manejar la conversión y optimización de ítems, este código contribuye significativamente al equilibrio y la estrategia del juego.
ItemConvert.h
#pragma once #include "stdafx.h" #include "Util.h" #include "struct.h" // Funciones externas #define CheckIsLuckyItem ((bool(__cdecl*)(int a1, int a2)) 0x005C9370) #define GetPetInfo ((PET_INFO*(__cdecl*)(ITEM* ip)) 0x004F9930) #define SetPetItemConvert ((void(__cdecl*)(ITEM* ip, PET_INFO* pPetInfo)) 0x004F9B50) // Tipos de opciones para los ítems enum OptionType { ImproveDamage = 80, ImproveMagic = 81, ImproveBlocking = 82, ImproveDefense = 83, Luck = 84, LifeRegeneration = 85, ImproveLife = 86, ImproveMana = 87, DecreaseDamage = 88, ReflectionDamage = 89, ImproveBlockingPerc = 90, ImproveGainGold = 91, ExcellentDamage = 92, ImproveDamageLevel = 93, ImproveDamagePerc = 94, ImproveMagicLevel = 95, ImproveMagicPerc = 96, ImproveAttackSpeed = 97, ImproveGainLife = 98, ImproveGainMana = 99, ImproveHPMax = 100, ImproveMPMax = 101, OnePercentDamage = 102, ImproveAGMax = 103, DamageAbsorb = 104, ImproveCharismaSet = 144, ImproveDamageSet = 148, ImproveDefenseSet = 150, ImproveMaxMana = 175, ImproveMaxAG = 176, }; // Clase para la conversión de ítems class NewItemConvert { public: // Hook para la conversión de ítems void NewItemConvertHook(); // Método para convertir ítems void ItemConvert(ITEM* ip, BYTE Attribute1, BYTE Attribute2, BYTE Attribute3); }; // Instancia global de NewItemConvert extern NewItemConvert gNewItemConvert;
ItemConvert.cpp
#include "stdafx.h" #include "ItemConvert.h" #include "struct.h" #include "Item.h" #include "Object.h" // Instancia global de NewItemConvert NewItemConvert gNewItemConvert; // Hook para la conversión de ítems void NewItemConvert::NewItemConvertHook() { SetCompleteHook(0xE8, 0x0058B77E, &NewItemConvert::ItemConvert); SetCompleteHook(0xE8, 0x005C7833, &NewItemConvert::ItemConvert); SetCompleteHook(0xE8, 0x005C7D71, &NewItemConvert::ItemConvert); SetCompleteHook(0xE8, 0x005C7F1B, &NewItemConvert::ItemConvert); SetCompleteHook(0xE8, 0x005C80BE, &NewItemConvert::ItemConvert); SetCompleteHook(0xE8, 0x007E22BA, &NewItemConvert::ItemConvert); } // Verifica si el ítem es un cetro bool isScepterItem(int Type) { return (Type >= GET_ITEM(2, 8) && Type <= GET_ITEM(2, 15)) || (Type == GET_ITEM(2, 17) || Type == GET_ITEM(2, 18)); } // Método para convertir ítems void NewItemConvert::ItemConvert(ITEM* ip, BYTE Attribute1, BYTE Attribute2, BYTE Attribute3) { ip->Level = Attribute1; int Level = (Attribute1 >> 3) & 0xF; int Excellent = Attribute2 & 0x3F; int ExcellentWing = Excellent; int ExcellentAddValue = 0; bool bExtOption = false; // Lógica para determinar el valor de Excellent if (ip->Type >= 6147 && ip->Type <= 6150 || ip->Type >= 6180 && ip->Type <= 6184 || ip->Type >= 6186 && ip->Type <= 6187 || ip->Type == 19 || ip->Type == 2066 || ip->Type == 2570 || ip->Type == 1037 || ip->Type == 6686 || (ip->Type >= 6274 && ip->Type <= 6278) || (ip->Type >= 6193 && ip->Type <= 6194) || ip->Type == 6279 || ip->Type == 2596) { Excellent = 0; } if ((Attribute3 & 3) == 1 || (Attribute3 & 3) == 2) { Excellent = 1; bExtOption = true; } // Obtener atributos del ítem ITEM_ATTRIBUTE* p = ItemAttribute(ip->Type); ip->TwoHand = p->TwoHand; ip->WeaponSpeed = p->WeaponSpeed; // Configurar daño mínimo y máximo if (ip->Type == GET_ITEM(0, 0)) { ip->DamageMin = p->DamageMin + 400; ip->DamageMax = p->DamageMax + 800; } else { ip->DamageMin = p->DamageMin; ip->DamageMax = p->DamageMax; } ip->SuccessfulBlocking = p->SuccessfulBlocking; ip->Defense = p->Defense; ip->MagicDefense = p->MagicDefense; ip->WalkSpeed = p->WalkSpeed; ip->MagicPower = p->MagicPower; int SetItemDropLevel = p->Level + 30; // Lógica para el daño adicional switch (ip->Type) { case 1030: ExcellentAddValue = 15; break; case 2054: ExcellentAddValue = 30; break; case 2567: ExcellentAddValue = 25; break; } // Calcular daño mínimo if (p->DamageMin) { if (Excellent > 0 && p->Level) { ip->DamageMin += ExcellentAddValue ? ExcellentAddValue : p->DamageMin * 25 / p->Level + 5; } if (bExtOption) { ip->DamageMin += SetItemDropLevel / 40 + 5; } int v17 = (Level <= 9) ? Level : 9; ip->DamageMin += 3 * v17; switch (Level) { case 10: ip->DamageMin += 4; break; case 11: ip->DamageMin += 5; break; case 12: ip->DamageMin += 6; break; case 13: ip->DamageMin += 7; break; case 14: ip->DamageMin += 8; break; case 15: ip->DamageMin += 9; break; } } // Calcular daño máximo if (p->DamageMax) { if (Excellent > 0 && p->Level) { ip->DamageMax += ExcellentAddValue ? ExcellentAddValue : p->DamageMin * 25 / p->Level + 5; } if (bExtOption) { ip->DamageMax += SetItemDropLevel / 40 + 5; } int v16 = (Level <= 9) ? Level : 9; ip->DamageMax += 3 * v16; switch (Level) { case 10: ip->DamageMax += 4; break; case 11: ip->DamageMax += 5; break; case 12: ip->DamageMax += 6; break; case 13: ip->DamageMax += 7; break; case 14: ip->DamageMax += 8; break; case 15: ip->DamageMax += 9; break; } } // Calcular poder mágico if (p->MagicPower) { if (Excellent > 0 && p->Level) { ip->MagicPower += ExcellentAddValue ? ExcellentAddValue : p->MagicPower * 25 / p->Level + 5; } if (bExtOption) { ip->MagicPower += SetItemDropLevel / 60 + 2; } int v15 = (Level <= 9) ? Level : 9; ip->MagicPower += 3 * v15; switch (Level) { case 10: ip->MagicPower += 4; break; case 11: ip->MagicPower += 5; break; case 12: ip->MagicPower += 6; break; case 13: ip->MagicPower += 7; break; case 14: ip->MagicPower += 8; break; case 15: ip->MagicPower += 9; break; } ip->MagicPower /= 2; if (!isScepterItem(ip->Type)) { ip->MagicPower += 2 * Level; } } // Actualiza SuccessfulBlocking if (p->SuccessfulBlocking) { if (Excellent > 0 && p->Level) { ip->SuccessfulBlocking += 25 * p->SuccessfulBlocking / p->Level + 5; } int v14 = (Level <= 9) ? Level : 9; ip->SuccessfulBlocking += 3 * v14; switch (Level) { case 10: ip->SuccessfulBlocking += 4; break; case 11: ip->SuccessfulBlocking += 5; break; case 12: ip->SuccessfulBlocking += 6; break; case 13: ip->SuccessfulBlocking += 7; break; case 14: ip->SuccessfulBlocking += 8; break; case 15: ip->SuccessfulBlocking += 9; break; } } // Calcular defensa if (ip->Type == 6686) { p->Defense = 15; ip->Defense = 15; } if (p->Defense) { if (ip->Type < 3072 || ip->Type >= 3584) { if (Excellent > 0 && p->Level) { ip->Defense += 12 * p->Defense / p->Level + p->Level / 5 + 4; } if (bExtOption) { ip->Defense += 3 * ip->Defense / SetItemDropLevel + SetItemDropLevel / 30 + 2; } if (ip->Type >= 6147 && ip->Type <= 6150 || ip->Type == 6186) { ip->Defense += (Level <= 9) ? 2 * Level : 2 * 9; } else if (ip->Type == 6686 || ip->Type == 6193) { ip->Defense += (Level <= 9) ? 2 * Level : 2 * 9; } else if (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) { ip->Defense += (Level <= 9) ? 4 * Level : 4 * 9; } else { ip->Defense += (Level <= 9) ? 3 * Level : 3 * 9; } // Incremento de defensa por nivel switch (Level) { case 10: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 5 : 4; break; case 11: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 6 : 5; break; case 12: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 7 : 6; break; case 13: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 8 : 7; break; case 14: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 9 : 8; break; case 15: ip->Defense += (ip->Type >= 6180 && ip->Type <= 6184 || ip->Type == 6187 || ip->Type == 6194) ? 10 : 9; break; } } else { ip->Defense += Level; if (bExtOption) { ip->Defense += 20 * ip->Defense / SetItemDropLevel + 2; } } } // Calcular defensa mágica if (p->MagicDefense) { int v13 = (Level <= 9) ? Level : 9; ip->MagicDefense += 3 * v13; switch (Level) { case 10: ip->MagicDefense += 4; break; case 11: ip->MagicDefense += 5; break; case 12: ip->MagicDefense += 6; break; case 13: ip->MagicDefense += 7; break; case 14: ip->MagicDefense += 8; break; case 15: ip->MagicDefense += 9; break; } } // Configurar requisitos de nivel y atributos int ItemLevel = p->Level; if (Excellent) { ItemLevel = p->Level + 25; } else if (bExtOption) { ItemLevel = p->Level + 30; } int addValue = (ip->Type >= 6147 && ip->Type <= 6150 || ip->Type == 6186) ? 5 : 4; if (p->RequireLevel && ip->Type < 6144 || ip->Type == 6693 || (ip->Type >= 6151 && ip->Type <= 6184) || (ip->Type >= 6187 && ip->Type < 6656 && ip->Type != 6193)) { ip->RequireLevel = p->RequireLevel; } else if (p->RequireLevel && (ip->Type >= 6144 && ip->Type <= 6151 || ip->Type >= 6185 && ip->Type <= 6186 || ip->Type == 6193 || ip->Type >= 6656)) { ip->RequireLevel = addValue * Level + p->RequireLevel; } else { ip->RequireLevel = 0; } // Requisitos de atributos if (p->RequireStrength) { ip->RequireStrength = 3 * (ItemLevel + 3 * Level) * p->RequireStrength / 100 + 20; } else { ip->RequireStrength = 0; } if (p->RequireDexterity) { ip->RequireDexterity = 3 * (ItemLevel + 3 * Level) * p->RequireDexterity / 100 + 20; } else { ip->RequireDexterity = 0; } if (p->RequireVitality) { ip->RequireVitality = 3 * (ItemLevel + 3 * Level) * p->RequireVitality / 100 + 20; } else { ip->RequireVitality = 0; } if (p->RequireEnergy) { if (ip->Type >= 2581 && ip->Type <= 2589 || ip->Type == 2600) { ip->RequireEnergy = 3 * (Level + ItemLevel) * p->RequireEnergy / 100 + 20; } else if (p->RequireLevel && ip->Type >= 7680 && ip->Type < 8192) { ip->RequireEnergy = 4 * p->RequireLevel * p->RequireEnergy / 100 + 20; } else { ip->RequireEnergy = 4 * (Level + 3 * ItemLevel) * p->RequireEnergy / 100 + 20; } } else { ip->RequireEnergy = 0; } if (p->RequireCharisma) { ip->RequireCharisma = 3 * (Level + 3 * ItemLevel) * p->RequireCharisma / 100 + 20; } else { ip->RequireCharisma = 0; } // Configuraciones específicas para tipos de ítem if (ip->Type == 6155) { WORD Energy = 0; switch (Level) { case 0: Energy = 30; break; case 1: Energy = 60; break; case 2: Energy = 90; break; case 3: Energy = 130; break; case 4: Energy = 170; break; case 5: Energy = 210; break; case 6: Energy = 300; break; } ip->RequireEnergy = Energy; } if (p->RequireCharisma) { if (ip->Type == 7832) { ip->RequireCharisma = 15 * p->RequireCharisma + 185; } else { ip->RequireCharisma = p->RequireCharisma; } } if (ip->Type == 6666) { ip->RequireLevel = (Level > 2) ? 50 : 20; } // Verificar si es un ítem afortunado if (ip->Type >= 3613 && ip->Type <= 3617 || ip->Type >= 4125 && ip->Type <= 4129 || ip->Type >= 4637 && ip->Type <= 4641 || ip->Type >= 5149 && ip->Type <= 5153 || ip->Type >= 5661 && ip->Type <= 5665 || ip->Type == 22 || ip->Type == 23 || ip->Type == 2572 || ip->Type == 2069 || ip->Type == 1038 || ip->Type == 2579 || ip->Type == 3627 || ip->Type == 4139 || ip->Type == 4651 || ip->Type == 5163 || ip->Type == 5675 || CheckIsLuckyItem(ip->Type, 0)) { Excellent = 0; } if (Excellent > 0 && ip->RequireLevel && ip->Type != 6693) { ip->RequireLevel += 20; } ip->SpecialNum = 0; // Configurar valores especiales if (ip->Type >= 6147 && ip->Type <= 6150 || ip->Type == 6186) { if ((ExcellentWing & 1) != 0) { ip->SpecialValue[ip->SpecialNum] = 5 * Level + 50; ip->Special[ip->SpecialNum] = ImproveMPMax; ip->SpecialNum++; } if (((ExcellentWing >> 1) & 1) != 0) { ip->SpecialValue[ip->SpecialNum] = 5 * Level + 50; ip->Special[ip->SpecialNum] = OnePercentDamage; ip->SpecialNum++; } if (((ExcellentWing >> 2) & 1) != 0) { ip->SpecialValue[ip->SpecialNum] = 3; ip->Special[ip->SpecialNum] = ImproveAGMax; ip->SpecialNum++; } if (((ExcellentWing >> 3) & 1) != 0) { ip->SpecialValue[ip->
Enlaces Internos y Salientes
- Enlaces Internos:
- Enlaces Salientes:
Creditos joaovithor1