DNF_DLL/test/函数块.cpp

733 lines
14 KiB
C++
Raw Normal View History

2022-02-07 03:31:00 +08:00
#include "pch.h"
//<2F><>ȡEXEʹ<45><CAB9>ͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
int GetExeNutWrtNum(int Pos)
{
int num = *(int*)(0x40079F + (Pos * 4));
return num;
}
//дEXEʹ<45><CAB9>ͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
void SetExeNutWrtNum(int Pos, int num)
{
int* p = (int*)(0x40079F + (Pos * 4));
*p = num;
}
//<2F><>ȡNutͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
int GetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos )
{
int num = *(int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8));
return num;
}
//дNutͷ <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
void SetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos, int num)
{
int* p = (int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8));
*p = num;
}
//<2F><><EFBFBD>ڴ<EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
int GetHook(int Addr, std::string <EFBFBD><EFBFBD>ַ)
{
size_t pos = <EFBFBD><EFBFBD>ַ.find("+");
size_t size = <EFBFBD><EFBFBD>ַ.size();
int GetHookArr[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
int i = 0;
while (pos != std::string::npos)
{
std::string x = <EFBFBD><EFBFBD>ַ.substr(0, pos);
GetHookArr[i] = stoi(x, 0, 16);
i++;
<EFBFBD><EFBFBD>ַ = <EFBFBD><EFBFBD>ַ.substr(pos + 1, size);
pos = <EFBFBD><EFBFBD>ַ.find("+");
}
int num;
num = *(int*)(Addr);
if (num != 0)
{
for (int z = 0; z < i; z++)
{
num = *(int*)(num + GetHookArr[z]);
}
}
return num;
}
2022-02-10 14:14:08 +08:00
//<2F><><EFBFBD>ܶ<EFBFBD>ȡ <20><><EFBFBD><EFBFBD> <20><>ַ
int DNFDeCode(int Address)
{
DWORD nEax, nEcx8, nEsi, nEdx, nTmp;
nEax = *(int*)(Address);
if (nEax == -1)
return nEax;
nEcx8 = *(int*)(Address + 8);
if (nEcx8 == -1)
return nEcx8;
nEsi = *(int*)(0x1AF8D78);
nEdx = nEax >> 16;
nTmp = (nEdx << 2) + nEsi + 36;
nEdx = *(int*)(nTmp);
if (nEdx == -1)
return nEdx;
nEax = nEax & 65535;
nTmp = (nEax << 2) + nEdx + 8468;
nEax = *(int*)(nTmp);
if (nEax == -1)
return nEax;
_asm
{
mov eax, nEax
movzx edx, ax
mov nEdx, edx
}
nEsi = nEdx << 16;
nEsi = nEsi | nEdx;
nEax = nEsi ^ nEcx8;
return nEax;
return 0;
}
//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
void DNFEnCode(int AddreSs, int Data)
{
long JEdi, JEcx, JEax, JEsi, JEdx, JSs;
JEcx = AddreSs;
JEax = *(int*)(0x1AF8DB8);
JEax = JEax + 1;
*(int*)(0x1AF8DB8) = JEax;
JEdx = JEax;
JEdx = JEdx >> 8;
JEdx = JEdx << 24;
JEdx = JEdx >> 24;
JEdx = *(int*)(JEdx * 2 + 0x1843F58);
JEdx = JEdx & 0xFFFF;
JEax = JEax << 24;
JEax = JEax >> 24;
JSs = *(int*)(JEax * 2 + 0x1844158);
JSs = JSs & 0xFFFF;
JEdx = JEdx ^ JSs;
JEax = JEdx;
JEax = JEax & 0xFFFF;
JEsi = Data;
JEdx = JEsi >> 16;
Sleep(10);
JSs = JEsi & 0xFFFF;
JEdx = JEdx + JSs;
JEdx = JEdx ^ JEax;
JEdi = JEdx;
JEdx = JEax;
JEax = JEax << 16;
JEax = JEax + JEdx;
JEsi = Data;
JEax = JEax ^ JEsi;
JEsi = AddreSs + 8;
*(int*)(JEsi) = JEax;
JEax = *(int*)(AddreSs);
JEsi = *(int*)(0x1AF8D78);
JEcx = JEdi;
JEcx = JEcx << 16;
JEcx = JEcx + JEdx;
JEdx = JEax;
JEdx = JEdx >> 16;
JEdx = *(int*)(JEsi + JEdx * 4 + 36);
JEax = JEax & 0xFFFF;
*(int*)(JEdx + JEax * 4 + 8468) = JEcx;
}
int GetEquAddr(int addr)
{
switch (addr)
{
case 1:
return 0x3038;
break;
case 2:
return 0x304C;
break;
case 3:
return 0x3048;
break;
case 4:
return 0x3050;
break;
case 5:
return 0x3044;
break;
case 6:
return 0x3040;
break;
case 7:
return 0x3058;
break;
case 8:
return 0x305C;
break;
case 9:
return 0x3054;
break;
case 10:
return 0x3060;
break;
case 11:
return 0x3064;
break;
case 12:
return 0x3038;
break;
case 13:
return 0x3008;
break;
case 14:
return 0x300C;
break;
case 15:
return 0x3010;
break;
case 16:
return 0x3014;
break;
case 17:
return 0x3018;
break;
case 18:
return 0x301C;
break;
case 19:
return 0x3020;
break;
case 20:
return 0x3024;
break;
case 21:
return 0x3028;
break;
case 22:
return 0x302C;
break;
case 23:
return 0x3030;
break;
case 24:
return 0x3068;
break;
case 25:
return 0x306C;
break;
case 26:
return 0x3070;
break;
case 27:
return 0x3074;
break;
}
return -1;
}
2022-02-28 00:14:53 +08:00
char* UnicodeToAnsi(const wchar_t* szStr, char* pResult, int maxLen)
{
if (NULL == pResult)
return NULL;
int nLen = WideCharToMultiByte(CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL);
if (0 == nLen)
{
return NULL;
}
if (nLen >= maxLen)
nLen = maxLen;
WideCharToMultiByte(CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL);
return pResult;
}
wchar_t* AnsiToUnicode(const char* szStr, wchar_t* pResult, int maxLen)
{
if (NULL == pResult)
return NULL;
int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0);
if (0 == nLen)
{
return NULL;
}
if (nLen >= maxLen)
nLen = maxLen;
nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen);
if (0 == nLen)
{
return NULL;
}
return pResult;
}
2022-02-14 23:35:11 +08:00
//<2F><><EFBFBD><EFBFBD>
static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
{
2022-02-28 00:14:53 +08:00
//wchar_t* ת char*
int size = wcslen(filename);
char* fname = (char*)new char[size];
UnicodeToAnsi(filename, fname, size);
FILE* file;
file = fopen(fname, "rb+");
2022-02-14 23:35:11 +08:00
LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
if (file)
{
2022-02-28 00:14:53 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С
fseek(file, 0, SEEK_END);
int size = ftell(file);
rewind(file);
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ŀռ<C4BF>
char* ar = (char*)malloc(sizeof(char) * size);
//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ÿ<EFBFBD>ζ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>size<7A><65>
fread(ar, 1, size, file);
int skey[] = { 5,2,3,5,0 };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Cutecode(ar, skey);//<2F><><EFBFBD><EFBFBD>
FILE* outfile;
outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+");
int da = strlen(ar);
fwrite(ar, 1, da, outfile);
fclose(outfile);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
free(ar);//<2F>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD><C4BC><EFBFBD>
SQfseek(newfile, 0, 2);//<2F><>λ<EFBFBD><CEBB>ͷ
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
2022-02-14 23:35:11 +08:00
{
2022-02-28 00:14:53 +08:00
fclose(file);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
SQ__Fclose(newfile);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
remove("ImagePacks2/sprite_interface_teart_zero.npk");//ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
return 0;
2022-02-14 23:35:11 +08:00
}
2022-02-28 00:14:53 +08:00
fclose(file);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
2022-02-14 23:35:11 +08:00
return -1;
}
2022-02-28 00:14:53 +08:00
return -1;
2022-02-14 23:35:11 +08:00
}
static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror)
{
if (SQloadfile(v, filename, printerror) >= 0)
{
SQPush(v, -2);
if ((int)SQ_Call(v, 1, retval, 1) >= 0)
{
SQ_Remove(v, -(retval != 0) - 1);
return 1;
}
SQPop(v, 1);
}
return -1;
}
2022-02-28 00:14:53 +08:00
/*
void gonggao(char* str,int ctype,int ccolor)
2022-02-26 19:07:14 +08:00
{
2022-02-28 00:14:53 +08:00
int shop, gonggao, type, color;
char*addr;
if (ctype == NULL)
ctype = 16;
if (ccolor == NULL)
ccolor = 0x65535;
shop = 0x1A5FB20;
gonggao = 0x9536c0;
type = ctype;
color = ccolor;
addr = str;
2022-02-26 19:07:14 +08:00
_asm
{
pushad
mov ecx, dword ptr[ebp - 0x04]
mov ecx, dword ptr[ecx]
mov ecx, dword ptr[ecx + 0x40]
push 0x00000000
push 0x00000000
push 0x00000000
push 0x00000000
push dword ptr[ebp - 0x0c]
push dword ptr[ebp - 0x10]
push dword ptr[ebp - 0x14]
call dword ptr[ebp - 0x08]
popad
}
}
2022-02-28 00:14:53 +08:00
*/
2022-02-14 23:35:11 +08:00
2022-02-28 00:14:53 +08:00
//<2F><><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD>
void WindowsNotice(char* str ,int type = 0x10d ,int b = 0x0)
{
DWORD thisc = 0x1A5FB20;
thisc = *(DWORD*)thisc;
_NoticeTcall(thisc, 0, type, str, b);
}
2022-02-14 23:35:11 +08:00
2022-02-10 14:14:08 +08:00
//-------------------------------------------------------------------------------------------Squirrel
//<2F><>ȡSquirrel v <20><>ַ
inline uint32_t GetSqVm()
{
return *(uint32_t*)0x1AF3544;
}
//<2F><><EFBFBD><EFBFBD>nut<75>ӿ<EFBFBD>funcName<6D><65><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>funcAddr
void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
{
if (!v)
v = GetSqVm();
SQPushRootTable(v);
2022-02-13 19:54:59 +08:00
SQPushString(v, funcName, -1);
2022-02-10 14:14:08 +08:00
RealSqNewClosure(v, funcAddr, 0);
SQNewSlot(v, -3, false);
SQPopTop(v);
}
2022-02-13 10:09:55 +08:00
//Test
2022-02-14 23:35:11 +08:00
static int sq_Test(uint32_t v)
2022-02-13 10:09:55 +08:00
{
2022-02-26 19:07:14 +08:00
2022-02-28 00:14:53 +08:00
/*
DWORD thisc = 0x1A5FB20;
2022-02-26 19:07:14 +08:00
2022-02-28 00:14:53 +08:00
thisc = *(DWORD*)thisc;
thisc = *(DWORD*)(thisc + 0x40);
2022-02-26 19:07:14 +08:00
2022-02-28 00:14:53 +08:00
char *str = (char*)u"test";
_Noticecall(thisc, NULL, str, 0x66535, 14, 0, 0, 0, 0);
*/
//char* str = (char*)u"test";
//gonggao(str, 14,NULL);
WindowsNotice((char*)u"<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>");
SQPopTop(v);
SQPushInt(v, 1);
return 1;
2022-02-13 10:09:55 +08:00
}
2022-02-10 14:14:08 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetCharacterAttribute(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1 ,n2 ;
int num = SQGetTop(v);
2022-02-10 14:14:08 +08:00
int CharAddr = *(int*)(0x1AB7CDC);
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-10 14:14:08 +08:00
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
int SValue = (TValue + n1);
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
2022-02-14 23:35:11 +08:00
SQPushInt(v, (DNFDeCode(SValue)));
2022-02-10 14:14:08 +08:00
else
2022-02-14 23:35:11 +08:00
SQPushInt(v, (*(int*)(SValue)));
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
else if (num == 2)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
int Value = (CharAddr + n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, (DNFDeCode(Value)));
2022-02-10 14:14:08 +08:00
}
else
{
2022-02-14 23:35:11 +08:00
SQPushString(v, L"parameter error",-1);
2022-02-10 14:14:08 +08:00
}
return 1;
}
//д<><D0B4><EFBFBD><EFBFBD> <20><> װ<><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SetCharacterAttribute(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1, n2, n3;
int num = SQGetTop(v);
2022-02-10 14:14:08 +08:00
int CharAddr = *(int*)(0x1AB7CDC);
2022-02-14 23:35:11 +08:00
if (num == 4)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
SQGetInt(v, 4, &n3);
2022-02-10 14:14:08 +08:00
int TValue = *(int*)(CharAddr + GetEquAddr(n2));
int SValue = (TValue + n1);
if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
DNFEnCode(SValue, n3);
else
*(int*)SValue = n3;
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
else if (num == 3)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-10 14:14:08 +08:00
int Value = (CharAddr + n1);
DNFEnCode(Value, n2);
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-10 14:14:08 +08:00
}
else
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-10 14:14:08 +08:00
}
2022-02-14 23:35:11 +08:00
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownIndex(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1A5E258, "0xAC+0xD4+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetRegionIndex(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, *(int*)(GetHook(0x1A5E258, "0xAC+0xD8+")));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownXpos(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1AB7CE0, "0x2BC+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GetTownYpos(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushInt(v, GetHook(0x1AB7CE0, "0x2C0+"));
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SendPackType(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendpacksType(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>Byte
2022-02-14 23:35:11 +08:00
static int SendPackByte(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksByte(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>Word
2022-02-14 23:35:11 +08:00
static int SendPackWord(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksWord(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>DWord
2022-02-14 23:35:11 +08:00
static int SendPackDWord(uint32_t v)
2022-02-10 14:14:08 +08:00
{
2022-02-14 23:35:11 +08:00
int n1;
SQGetInt(v, 2, &n1);
2022-02-10 14:14:08 +08:00
_SendPacksDWord(*_SendClass, 0, n1);
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
//<2F><><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int SendPack(uint32_t v)
2022-02-10 14:14:08 +08:00
{
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushInt(v, 1);
2022-02-10 14:14:08 +08:00
return 1;
}
2022-02-13 10:09:55 +08:00
//<2F><><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GivePlayerItem(uint32_t v)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
int n1,n2;
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-13 10:09:55 +08:00
_SendpacksType(*_SendClass, 0, 65);
_SendPacksDWord(*_SendClass, 0, 1);
_SendPacksDWord(*_SendClass, 0, n1);
_SendPacksDWord(*_SendClass, 0, n2);
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-13 10:09:55 +08:00
}
2022-02-14 23:35:11 +08:00
else
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-13 10:09:55 +08:00
}
return 1;
}
//<2F><>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-02-14 23:35:11 +08:00
static int GivePlayerEqu(uint32_t v)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
int n1, n2;
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 10:09:55 +08:00
2022-02-14 23:35:11 +08:00
if (num == 3)
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
2022-02-13 10:09:55 +08:00
_SendpacksType(*_SendClass, 0, 65);
_SendPacksDWord(*_SendClass, 0, 2);
_SendPacksDWord(*_SendClass, 0, n1);
_SendPacksDWord(*_SendClass, 0, n2);
_SendPacks();
2022-02-14 23:35:11 +08:00
SQPushBool(v, true);
2022-02-13 10:09:55 +08:00
}
2022-02-14 23:35:11 +08:00
else
2022-02-13 10:09:55 +08:00
{
2022-02-14 23:35:11 +08:00
SQPushBool(v, false);
2022-02-13 10:09:55 +08:00
}
return 1;
}
2022-02-13 19:54:59 +08:00
//ȥ<><C8A5><EFBFBD><EFBFBD>
static int GoDungeon(uint32_t v)
{
int n1 = 0;
int n2 = 0;
int n3 = 0;
int n4 = 0;
2022-02-14 23:35:11 +08:00
int num = SQGetTop(v);
2022-02-13 19:54:59 +08:00
if (num == 2)
{
SQGetInt(v, 2, &n1);
}
else if (num == 5)
{
SQGetInt(v, 2, &n1);
SQGetInt(v, 3, &n2);
SQGetInt(v, 4, &n3);
SQGetInt(v, 5, &n4);
}
else
{
SQPushBool(v, false);
return 1;
}
_SendpacksType(*_SendClass, 0, 15);
_SendPacks();
_SendpacksType(*_SendClass, 0, 16);
_SendPacksWord(*_SendClass, 0, n1);
_SendPacksByte(*_SendClass, 0, n2);
_SendPacksByte(*_SendClass, 0, n3);
_SendPacksByte(*_SendClass, 0, n4);
_SendPacks();
SQPushBool(v, true);
return 1;
}
2022-02-14 23:35:11 +08:00
//Ldofile
static int LDofile(uint32_t v)
{
wchar_t* n1;
int num = SQGetTop(v);
if (num == 2)
{
SQGetString(v, 2, &n1);
SQPopTop(v);
2022-02-15 20:31:51 +08:00
/*
size_t len = wcslen(n1) + 1;
size_t converted = 0;
char* CStr;
CStr = (char*)malloc(len * sizeof(char));
wcstombs_s(&converted, CStr, len, n1, _TRUNCATE);
*/
2022-02-14 23:35:11 +08:00
SQdofile(v, n1, false, false);
SQPushBool(v, true);
}
else
{
SQPushBool(v, false);
}
return 1;
}
2022-02-10 14:14:08 +08:00
void RegisterNut()
{
2022-02-13 10:09:55 +08:00
RegisterNutApi(L"L_sq_Test", sq_Test);
2022-02-10 14:14:08 +08:00
RegisterNutApi(L"L_sq_GetCharacterAttribute", GetCharacterAttribute);
RegisterNutApi(L"L_sq_SetCharacterAttribute", SetCharacterAttribute);
RegisterNutApi(L"L_sq_GetTownIndex", GetTownIndex);
RegisterNutApi(L"L_sq_GetRegionIndex", GetRegionIndex);
RegisterNutApi(L"L_sq_GetTownXpos", GetTownXpos);
RegisterNutApi(L"L_sq_GetTownYpos", GetTownYpos);
RegisterNutApi(L"L_sq_SendPackType", SendPackType);
RegisterNutApi(L"L_sq_SendPackByte", SendPackByte);
RegisterNutApi(L"L_sq_SendPackWord", SendPackWord);
RegisterNutApi(L"L_sq_SendPackDWord", SendPackDWord);
RegisterNutApi(L"L_sq_SendPack", SendPack);
2022-02-13 10:09:55 +08:00
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
2022-02-13 19:54:59 +08:00
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
2022-02-14 23:35:11 +08:00
RegisterNutApi(L"L_sq_Dofile", LDofile);
2022-02-10 14:14:08 +08:00
}