#include "stdafx.h"
#include "FixLimitItem.h"
#include "ToolKit.h"
char * ItemDir = "Data\\Item\\";
char * ItemFolder = "Item\\";
char * PlayerDir = "Data\\Player\\";
char * PlayerFolder = "Player\\";
char Item[15];
char Sets[30];
int i;
int z;
void InitModel(int ItemID, char* ModelName, char* Folder, char* Form)
{
_asm
{
PUSH - 1
PUSH ModelName
PUSH Form
PUSH ItemID
mov eax, BMDModelLoad
CALL eax
PUSH 1
PUSH 0x2600
PUSH 0x2901
PUSH Folder
PUSH ItemID
mov eax, OpenTexture
CALL eax
}
}
void InitSets(int ItemID, char* ModelName, char* Folder, char* Form)
{
_asm
{
PUSH - 1
PUSH ModelName
PUSH Form
PUSH ItemID
mov eax, BMDModelLoad
CALL eax
PUSH 1
PUSH 0x2600
PUSH 0x2901
PUSH Folder
PUSH ItemID
mov eax, OpenTexture
CALL eax
}
}
__declspec(naked) void PatchNewModel()
{
// Load Items Models
for (i = 9; i < 511; i++)
{
if (i > 36)//Swords
{
sprintf_s(Item, "Sword%d", i + 1);
InitModel(ITEM2(0, i), Item, ItemFolder, ItemDir);
}
if (i > 9)//Axes
{
sprintf_s(Item, "Axe%d", i + 1);
InitModel(ITEM2(1, i), Item, ItemFolder, ItemDir);
}
if (i > 19)//Maces
{
sprintf_s(Item, "Mace%d", i + 1);
InitModel(ITEM2(2, i), Item, ItemFolder, ItemDir);
}
if (i > 12)//Spears
{
sprintf_s(Item, "Spear%d", i + 1);
InitModel(ITEM2(3, i), Item, ItemFolder, ItemDir);
}
if (i > 25)//Bow
{
sprintf_s(Item, "Bow%d", i + 1);
InitModel(ITEM2(4, i), Item, ItemFolder, ItemDir);
}
if (i > 35)//Staffs
{
sprintf_s(Item, "Staff%d", i + 1);
InitModel(ITEM2(5, i), Item, ItemFolder, ItemDir);
}
if (i > 22)//Shields
{
sprintf_s(Item, "Shield%d", i + 1);
InitModel(ITEM2(6, i), Item, ItemFolder, ItemDir);
}
}
_asm
{
PUSH - 1
PUSH 0x00D2F7C4
PUSH 0x00D2F7CC
PUSH 0x20B2
mov eax, BMDModelLoad
CALL eax
ADD ESP, 0x10
mov eax, ReturnOffset
JMP eax
}
}
__declspec(naked) void PatchNewSets()
{
for (i = 5; i < 512; i++)
{
if(i > 73)//helms
{
sprintf_s(Sets, "HelmMale%d", i+1);
InitSets(LOAD_ITEM(7, i), Sets, PlayerFolder, PlayerDir);
}
if(i > 73)//armors
{
sprintf_s(Sets, "ArmorMale%d", i+1);
InitSets(LOAD_ITEM(8, i), Sets, PlayerFolder, PlayerDir);
}
if(i > 72)//pants (fix Phoenix soul pants)
{
sprintf_s(Sets, "PantMale%d", i+1);
InitSets(LOAD_ITEM(9, i), Sets, PlayerFolder, PlayerDir);
}
if(i > 73)//gloves
{
sprintf_s(Sets, "GloveMale%d", i+1);
InitSets(LOAD_ITEM(10, i), Sets, PlayerFolder, PlayerDir);
}
if(i > 73)//boots
{
sprintf_s(Sets, "BootMale%d", i+1);
InitSets(LOAD_ITEM(11, i), Sets, PlayerFolder, PlayerDir);
}
}
_asm
{
PUSH - 1
PUSH 0x00D2D790
PUSH 0x00D2D79C
PUSH 0x14DC
mov eax, BMDModelLoad
CALL eax
ADD ESP, 0x10
mov eax, ReturnSetOffset
JMP eax
}
}
void InitItems()
{
//Patch new model in game
PatchJMP g_ModelPatch;
ToolKit.SetNop(LoadModel, 25);
g_ModelPatch.Command = 0xE9;
g_ModelPatch.Pointer = (DWORD)&PatchNewModel;
memcpy((int*)LoadModel, &g_ModelPatch, sizeof(g_ModelPatch));
ToolKit.HookThis((DWORD)&PatchNewModel, LoadModel);
}
void InitSets()
{
//Patch new sets in game
PatchJMP g_SetsPatch;
ToolKit.SetNop(LoadSetModel, 25);
g_SetsPatch.Command = 0xE9;
g_SetsPatch.Pointer = (DWORD)&PatchNewSets;
memcpy((int*)LoadSetModel, &g_SetsPatch, sizeof(g_SetsPatch));
ToolKit.HookThis((DWORD)&PatchNewSets, LoadSetModel);
}