883 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			883 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C++
		
	
	
	
| #include "pch.h"
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| //鳳龰EXE妏蚚芛 瘍弇杅擂
 | ||
| int GetExeNutWrtNum(int Pos)
 | ||
| {
 | ||
|     int num = *(int*)(0x40079F + (Pos * 4));
 | ||
|     return num;
 | ||
| }
 | ||
| 
 | ||
| //迡EXE妏蚚芛 瘍弇杅擂
 | ||
| void SetExeNutWrtNum(int Pos, int num)
 | ||
| {
 | ||
|     int* p = (int*)(0x40079F + (Pos * 4));
 | ||
|     *p = num;
 | ||
| }
 | ||
| 
 | ||
| //鳳龰Nut芛 瘍弇杅擂
 | ||
| int GetNutArrNum(int Nut芛華硊, int Pos )
 | ||
| {
 | ||
|     int num = *(int*)(Nut芛華硊 + (Pos * 8));
 | ||
|     return num;
 | ||
| }
 | ||
| 
 | ||
| //迡Nut芛 瘍弇杅擂
 | ||
| void SetNutArrNum(int Nut芛華硊, int Pos, int num)
 | ||
| {
 | ||
|     int* p = (int*)(Nut芛華硊 + (Pos * 8));
 | ||
|     *p = num;
 | ||
| }
 | ||
| 
 | ||
| //黍囀湔⑴痄華硊
 | ||
| int GetHook(int Addr, std::string 華硊)
 | ||
| {
 | ||
|     size_t pos = 華硊.find("+");
 | ||
|     size_t size = 華硊.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 = 華硊.substr(0, pos);
 | ||
|         GetHookArr[i] = stoi(x, 0, 16);
 | ||
|         i++;
 | ||
|         華硊 = 華硊.substr(pos + 1, size);
 | ||
|         pos = 華硊.find("+");
 | ||
|     }
 | ||
| 
 | ||
|     int num;
 | ||
|     num = *(int*)(Addr);
 | ||
| 
 | ||
|     if (num != 0)
 | ||
|     {
 | ||
|         for (int z = 0; z < i; z++)
 | ||
|         {
 | ||
|             num = *(int*)(num + GetHookArr[z]);
 | ||
|         }
 | ||
|     }
 | ||
|     return num;
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| //賤躇黍龰      曆梟              華硊
 | ||
| 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;
 | ||
| }
 | ||
| //樓躇迡⻌
 | ||
| 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;
 | ||
| }
 | ||
| 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;
 | ||
| }
 | ||
| 
 | ||
| //樓婥
 | ||
| static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
 | ||
| {
 | ||
|     //wchar_t* 蛌 char*
 | ||
|     int size = wcslen(filename);
 | ||
|     char* fname = (char*)new char[size];
 | ||
|     UnicodeToAnsi(filename, fname, size);
 | ||
| 
 | ||
|     FILE* file;
 | ||
|     file = fopen(fname, "rb+");
 | ||
|     LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
 | ||
|     if (file)
 | ||
|     {
 | ||
|         //А腕恅璃腔湮苤
 | ||
|         fseek(file, 0, SEEK_END);
 | ||
|         int size = ftell(file);
 | ||
|         rewind(file);
 | ||
| 
 | ||
|         //扠ワ珨輸夔蚾狟淕跺恅璃腔諾潔 
 | ||
|         char* ar = (char*)malloc(sizeof(char) * size);
 | ||
|         //黍恅璃ㄛ藩棒黍珨跺ㄛ僕黍size棒 
 | ||
|         fread(ar, 1, size, file);
 | ||
| 
 | ||
|         int skey[] = { 5,2,3,5,0 };//隅砱賤躇杅郪
 | ||
| 
 | ||
|         Cutecode(ar, skey);//賤躇
 | ||
| 
 | ||
|         FILE* outfile;
 | ||
|         outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+");
 | ||
|         int da = strlen(ar);
 | ||
|         fwrite(ar, 1, da, outfile);
 | ||
| 
 | ||
|         fclose(outfile);//壽敕恅璃
 | ||
|         free(ar);//庋溫囀湔
 | ||
| 
 | ||
|         SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//隅砱陔腔恅璃霜
 | ||
| 
 | ||
|         SQfseek(newfile, 0, 2);//隅弇善芛
 | ||
|         if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
 | ||
|         {
 | ||
|             fclose(file);//壽敕恅璃
 | ||
|             SQ__Fclose(newfile);//壽敕恅璃
 | ||
|             remove("ImagePacks2/sprite_interface_teart_zero.npk");//刉壺恅璃
 | ||
|             return 0;
 | ||
|         }
 | ||
| 
 | ||
|         fclose(file);//壽敕恅璃
 | ||
|         return -1;
 | ||
|     }
 | ||
|     return -1;
 | ||
| }
 | ||
| 
 | ||
| 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;
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| //敦諳鼠豢 0x10d
 | ||
| void WindowsNotice(char* str ,int type = 0x10d ,int b = 0x0)
 | ||
| {
 | ||
|     DWORD thisc = 0x1A5FB20;
 | ||
|     thisc = *(DWORD*)thisc;
 | ||
|     _NoticeTcall(thisc, 0, type, str, b);
 | ||
| }
 | ||
| //GM鼠豢
 | ||
| void GMNotice(char* str, int type,int color)
 | ||
| {
 | ||
|     if (type == NULL)type = 14;
 | ||
|     if (color == NULL)color = 0x65535;
 | ||
|     DWORD thisc = 0x1A5FB20;
 | ||
|     thisc = *(DWORD*)thisc;
 | ||
|     thisc = *(DWORD*)(thisc + 0x40);
 | ||
|     _Noticecall(thisc, 0, str, color, type, 0, 0, 0);
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| //-------------------------------------------------------------------------------------------Squirrel
 | ||
| //鳳龰Squirrel v 價硊
 | ||
| inline uint32_t GetSqVm()
 | ||
| {
 | ||
|     return *(uint32_t*)0x1AF3544;
 | ||
| }
 | ||
| //陔崝nut諉諳funcName堂隅C逄晟滲杅funcAddr
 | ||
| void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
 | ||
| {
 | ||
|     if (!v)
 | ||
|         v = GetSqVm();
 | ||
|     SQPushRootTable(v);
 | ||
|     SQPushString(v, funcName, -1);
 | ||
|     RealSqNewClosure(v, funcAddr, 0);
 | ||
|     SQNewSlot(v, -3, false);
 | ||
|     SQPopTop(v);
 | ||
| }
 | ||
| //Test
 | ||
| static int sq_Test(uint32_t v)
 | ||
| {
 | ||
| 
 | ||
|     //GMNotice((char*)u"扂腔毞");
 | ||
|     //WindowsNotice((char*)u"扂腔毞");
 | ||
| 
 | ||
|     SQPopTop(v);
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| //黍<>昜 麼 蚾掘扽俶
 | ||
| static int GetCharacterAttribute(uint32_t v)
 | ||
| {
 | ||
|     int n1 ,n2 ;
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     int CharAddr = *(int*)(0x1AB7CDC);
 | ||
|     if (num == 3)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         SQGetInt(v, 3, &n2);
 | ||
|         int TValue = *(int*)(CharAddr + GetEquAddr(n2));
 | ||
|         int SValue = (TValue + n1);
 | ||
|         if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
 | ||
|             SQPushInt(v, (DNFDeCode(SValue)));
 | ||
|         else
 | ||
|             SQPushInt(v, (*(int*)(SValue)));
 | ||
|     }
 | ||
|     else if (num == 2)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         int Value = (CharAddr + n1);
 | ||
| 
 | ||
|         SQPushInt(v, (DNFDeCode(Value)));
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushString(v, L"parameter error",-1);
 | ||
|     }
 | ||
|     return 1;
 | ||
| }
 | ||
| //迡<>昜 麼 蚾掘扽俶
 | ||
| static int SetCharacterAttribute(uint32_t v)
 | ||
| {
 | ||
|     int n1, n2, n3;
 | ||
| 
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     int CharAddr = *(int*)(0x1AB7CDC);
 | ||
|     if (num == 4)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         SQGetInt(v, 3, &n2);
 | ||
|         SQGetInt(v, 4, &n3);
 | ||
| 
 | ||
|         int TValue = *(int*)(CharAddr + GetEquAddr(n2));
 | ||
|         int SValue = (TValue + n1);
 | ||
|         if (n1 != 0x8 && n1 != 0x1C && n1 != 0xF4)
 | ||
|             DNFEnCode(SValue, n3);
 | ||
|         else
 | ||
|             *(int*)SValue = n3;
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else if (num == 3)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         SQGetInt(v, 3, &n2);
 | ||
| 
 | ||
|         int Value = (CharAddr + n1);
 | ||
|         DNFEnCode(Value, n2);
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| //鳳龰傑淜晤瘍
 | ||
| static int GetTownIndex(uint32_t v)
 | ||
| {
 | ||
|     SQPushInt(v, GetHook(0x1A5E258, "0xAC+0xD4+"));
 | ||
|     return 1;
 | ||
| }
 | ||
| //鳳龰傑淜Е郖晤瘍
 | ||
| static int GetRegionIndex(uint32_t v)
 | ||
| {
 | ||
|     SQPushInt(v, *(int*)(GetHook(0x1A5E258, "0xAC+0xD8+")));
 | ||
|     return 1;
 | ||
| }
 | ||
| //鳳龰傑淜X釴梓
 | ||
| static int GetTownXpos(uint32_t v)
 | ||
| {
 | ||
|     SQPushInt(v, GetHook(0x1AB7CE0, "0x2BC+"));
 | ||
|     return 1;
 | ||
| }
 | ||
| //鳳龰傑淜Y釴梓
 | ||
| static int GetTownYpos(uint32_t v)
 | ||
| {
 | ||
|     SQPushInt(v, GetHook(0x1AB7CE0, "0x2C0+"));
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷婦濬倰
 | ||
| static int SendPackType(uint32_t v)
 | ||
| {
 | ||
|     int n1;
 | ||
|     SQGetInt(v, 2, &n1);
 | ||
|     _SendpacksType(*_SendClass, 0, n1);
 | ||
| 
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷婦Byte
 | ||
| static int SendPackByte(uint32_t v)
 | ||
| {
 | ||
|     int n1;
 | ||
|     SQGetInt(v, 2, &n1);
 | ||
|     _SendPacksByte(*_SendClass, 0, n1);
 | ||
| 
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷婦Word
 | ||
| static int SendPackWord(uint32_t v)
 | ||
| {
 | ||
|     int n1;
 | ||
|     SQGetInt(v, 2, &n1);
 | ||
|     _SendPacksWord(*_SendClass, 0, n1);
 | ||
| 
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷婦DWord
 | ||
| static int SendPackDWord(uint32_t v)
 | ||
| {
 | ||
|     int n1;
 | ||
|     SQGetInt(v, 2, &n1);
 | ||
|     _SendPacksDWord(*_SendClass, 0, n1);
 | ||
| 
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷婦
 | ||
| static int SendPack(uint32_t v)
 | ||
| {
 | ||
|     _SendPacks();
 | ||
|     SQPushInt(v, 1);
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷昜ⅲ跤俙模
 | ||
| static int GivePlayerItem(uint32_t v)
 | ||
| {
 | ||
|     int n1,n2;
 | ||
| 
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     if (num == 3)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         SQGetInt(v, 3, &n2);
 | ||
| 
 | ||
|         _SendpacksType(*_SendClass, 0, 65);
 | ||
|         _SendPacksDWord(*_SendClass, 0, 1);
 | ||
|         _SendPacksDWord(*_SendClass, 0, n1);
 | ||
|         _SendPacksDWord(*_SendClass, 0, n2);
 | ||
|         _SendPacks();
 | ||
| 
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //楷蚾掘跤俙模
 | ||
| static int GivePlayerEqu(uint32_t v)
 | ||
| {
 | ||
|     int n1, n2;
 | ||
| 
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     if (num == 3)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &n1);
 | ||
|         SQGetInt(v, 3, &n2);
 | ||
| 
 | ||
|         _SendpacksType(*_SendClass, 0, 65);
 | ||
|         _SendPacksDWord(*_SendClass, 0, 2);
 | ||
|         _SendPacksDWord(*_SendClass, 0, n1);
 | ||
|         _SendPacksDWord(*_SendClass, 0, n2);
 | ||
|         _SendPacks();
 | ||
| 
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //<2F>萵掛
 | ||
| static int GoDungeon(uint32_t v)
 | ||
| {
 | ||
|     int n1 = 0;
 | ||
|     int n2 = 0;
 | ||
|     int n3 = 0;
 | ||
|     int n4 = 0;
 | ||
| 
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     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;
 | ||
| }
 | ||
| 
 | ||
| //Ldofile
 | ||
| static int LDofile(uint32_t v)
 | ||
| {
 | ||
|     wchar_t* n1;
 | ||
|     
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     if (num == 2)
 | ||
|     {
 | ||
|         SQGetString(v, 2, &n1);
 | ||
|         SQPopTop(v);
 | ||
|         /*
 | ||
|         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);
 | ||
|         */
 | ||
| 
 | ||
|         SQdofile(v, n1, false, false);
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
|     
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //Lcout
 | ||
| static int Lcout(uint32_t v)
 | ||
| {
 | ||
|     char* str = NULL;
 | ||
|     int type = NULL;
 | ||
|     int color = NULL;
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     if (num == 2 || num == 3 || num == 4)
 | ||
|     {
 | ||
|         switch (num)
 | ||
|         {
 | ||
|         case 2:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             break;
 | ||
|         case 3:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             SQGetInt(v, 3, &type);
 | ||
|             break;
 | ||
|         case 4:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             SQGetInt(v, 3, &type);
 | ||
|             SQGetInt(v, 4, &color);
 | ||
|             break;
 | ||
|         }
 | ||
| 
 | ||
|         SQPopTop(v);
 | ||
| 
 | ||
|         GMNotice(str, type, color);
 | ||
|         
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //Lcout
 | ||
| static int NewWindows(uint32_t v)
 | ||
| {
 | ||
|     char* str = NULL;
 | ||
|     int type = NULL;
 | ||
|     int color = NULL;
 | ||
|     int num = SQGetTop(v);
 | ||
| 
 | ||
|     if (num == 2 || num == 3 || num == 4)
 | ||
|     {
 | ||
|         switch (num)
 | ||
|         {
 | ||
|         case 2:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             break;
 | ||
|         case 3:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             SQGetInt(v, 3, &type);
 | ||
|             break;
 | ||
|         case 4:
 | ||
|             SQGetStringc(v, 2, &str);
 | ||
|             SQGetInt(v, 3, &type);
 | ||
|             SQGetInt(v, 4, &color);
 | ||
|             break;
 | ||
|         }
 | ||
| 
 | ||
|         SQPopTop(v);
 | ||
|         
 | ||
|         WindowsNotice(str, type, color);
 | ||
| 
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| //Lcout
 | ||
| static int SetSlot(uint32_t v)
 | ||
| {
 | ||
|     int Type = NULL;
 | ||
|     int Index = NULL;
 | ||
|     int Xpos = NULL;
 | ||
|     int Ypos = NULL;
 | ||
| 
 | ||
| 
 | ||
|     int OneAddr = NULL;
 | ||
|     int* xpos = NULL;
 | ||
|     int* ypos = NULL;
 | ||
| 
 | ||
|     int ParameterNum = SQGetTop(v);
 | ||
| 
 | ||
|     if (ParameterNum == 5)
 | ||
|     {
 | ||
|         SQGetInt(v, 2, &Type);
 | ||
|         SQGetInt(v, 3, &Index);
 | ||
|         SQGetInt(v, 4, &Xpos);
 | ||
|         SQGetInt(v, 5, &Ypos);
 | ||
| 
 | ||
|         SQPopTop(v);
 | ||
| 
 | ||
|         switch (Type)
 | ||
|         {
 | ||
|         case 0://阹桯撮夔戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + (0x60 + (4 * Index)));
 | ||
|             xpos = (int*)(OneAddr + (0x14));
 | ||
|             ypos = (int*)(OneAddr + (0x18));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 1://價插撮夔戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + (0x30 + (4 * Index)));
 | ||
|             xpos = (int*)(OneAddr + (0x14));
 | ||
|             ypos = (int*)(OneAddr + (0x18));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 2://ピ遙撮夔戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + (0x124 + (4 * Index)));
 | ||
|             xpos = (int*)(OneAddr + (0x14));
 | ||
|             ypos = (int*)(OneAddr + (0x18));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 3://辦豎昜ⅲ戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + (0x18 + (4 * Index)));
 | ||
|             xpos = (int*)(OneAddr + (0x14));
 | ||
|             ypos = (int*)(OneAddr + (0x18));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 4://杻俶撮夔桯羲戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + 0xC);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x4);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x0);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x34);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x4);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x28);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x4);
 | ||
| 
 | ||
|             xpos = (int*)(OneAddr + (0x394));
 | ||
|             ypos = (int*)(OneAddr + (0x398));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 5://杻俶撮夔撮夔戲
 | ||
|             OneAddr = *(int*)(0x16E95AC + 0x400000);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x68);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x0);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x8);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x64);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x0);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x1C);
 | ||
|             OneAddr = *(int*)(OneAddr + 0x0);
 | ||
| 
 | ||
|             xpos = (int*)(OneAddr + (0x1794));
 | ||
|             ypos = (int*)(OneAddr + (0x1798));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         case 6://粕等戲
 | ||
|             OneAddr = *(int*)0x1ADE0CC;
 | ||
|             OneAddr = *(int*)(OneAddr + (0x84 + (4 * Index)));
 | ||
|             xpos = (int*)(OneAddr + (0x14));
 | ||
|             ypos = (int*)(OneAddr + (0x18));
 | ||
|             *xpos = Xpos;
 | ||
|             *ypos = Ypos;
 | ||
|             break;
 | ||
|         }
 | ||
| 
 | ||
|         SQPushBool(v, true);
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|         SQPushBool(v, false);
 | ||
|     }
 | ||
| 
 | ||
|     return 1;
 | ||
| }
 | ||
| 
 | ||
| void RegisterNut()
 | ||
| {
 | ||
|     RegisterNutApi(L"L_sq_Test", sq_Test);
 | ||
|     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);
 | ||
|     RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);
 | ||
|     RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);
 | ||
|     RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);
 | ||
|     RegisterNutApi(L"L_sq_Dofile", LDofile);
 | ||
|     RegisterNutApi(L"L_cout", Lcout);
 | ||
|     RegisterNutApi(L"L_NewWindows", NewWindows);
 | ||
|     RegisterNutApi(L"L_SetSlot", SetSlot);
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| 
 |