This commit is contained in:
Lenheart 2022-04-06 09:58:47 +08:00
parent 01a3e912bf
commit 517b5f947d
3 changed files with 199 additions and 89 deletions

View File

@ -11,6 +11,15 @@ static std::map<std::string, std::string>String_STL;
//构造bool类型容器 //构造bool类型容器
static std::map<std::string, bool>Bool_STL; static std::map<std::string, bool>Bool_STL;
struct TimeSTLStruct
{
std::string Name;
int Max_Time;
int Now_Time;
};
//构造Time类型容器
static std::map<std::string, TimeSTLStruct>Time_STL;
//构造intarr类型容器 //构造intarr类型容器
static std::map<std::string, std::map<int, int>>IntArr_STL; static std::map<std::string, std::map<int, int>>IntArr_STL;
//构造floatarr类型容器 //构造floatarr类型容器
@ -21,6 +30,7 @@ static std::map<std::string, std::map<int, std::string>>StringArr_STL;
static std::map<std::string, std::map<int, bool>>BoolArr_STL; static std::map<std::string, std::map<int, bool>>BoolArr_STL;
//构造 抽奖 类型容器 //构造 抽奖 类型容器
struct Dargonresult struct Dargonresult
{ {

View File

@ -71,7 +71,7 @@ int squirrel::SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool pr
} }
//Test //Test
static int sq_Test(uint32_t v) int squirrel::sq_Test(uint32_t v)
{ {
//GMNotice((char*)u"我的天"); //GMNotice((char*)u"我的天");
@ -82,7 +82,7 @@ static int sq_Test(uint32_t v)
return 1; return 1;
} }
//读人物 或 装备属性 //读人物 或 装备属性
static int GetCharacterAttribute(uint32_t v) int squirrel::GetCharacterAttribute(uint32_t v)
{ {
int n1, n2; int n1, n2;
int num = SQGetTop(v); int num = SQGetTop(v);
@ -113,7 +113,7 @@ static int GetCharacterAttribute(uint32_t v)
return 1; return 1;
} }
//写人物 或 装备属性 //写人物 或 装备属性
static int SetCharacterAttribute(uint32_t v) int squirrel::SetCharacterAttribute(uint32_t v)
{ {
int n1, n2, n3; int n1, n2, n3;
@ -151,31 +151,31 @@ static int SetCharacterAttribute(uint32_t v)
return 1; return 1;
} }
//获取城镇编号 //获取城镇编号
static int GetTownIndex(uint32_t v) int squirrel::GetTownIndex(uint32_t v)
{ {
SQPushInt(v, DNFTOOL::GetHook(0x1A5E258, "0xAC+0xD4+")); SQPushInt(v, DNFTOOL::GetHook(0x1A5E258, "0xAC+0xD4+"));
return 1; return 1;
} }
//获取城镇区域编号 //获取城镇区域编号
static int GetRegionIndex(uint32_t v) int squirrel::GetRegionIndex(uint32_t v)
{ {
SQPushInt(v, *(int*)(DNFTOOL::GetHook(0x1A5E258, "0xAC+0xD8+"))); SQPushInt(v, *(int*)(DNFTOOL::GetHook(0x1A5E258, "0xAC+0xD8+")));
return 1; return 1;
} }
//获取城镇X坐标 //获取城镇X坐标
static int GetTownXpos(uint32_t v) int squirrel::GetTownXpos(uint32_t v)
{ {
SQPushInt(v, DNFTOOL::GetHook(0x1AB7CE0, "0x2BC+")); SQPushInt(v, DNFTOOL::GetHook(0x1AB7CE0, "0x2BC+"));
return 1; return 1;
} }
//获取城镇Y坐标 //获取城镇Y坐标
static int GetTownYpos(uint32_t v) int squirrel::GetTownYpos(uint32_t v)
{ {
SQPushInt(v, DNFTOOL::GetHook(0x1AB7CE0, "0x2C0+")); SQPushInt(v, DNFTOOL::GetHook(0x1AB7CE0, "0x2C0+"));
return 1; return 1;
} }
//获取疲劳值 //获取疲劳值
static int GetFatigue(uint32_t v) int squirrel::GetFatigue(uint32_t v)
{ {
int Type; int Type;
@ -200,7 +200,7 @@ static int GetFatigue(uint32_t v)
return 1; return 1;
} }
//获取经验值 //获取经验值
static int GetExp(uint32_t v) int squirrel::GetExp(uint32_t v)
{ {
int Type; int Type;
@ -225,8 +225,12 @@ static int GetExp(uint32_t v)
return 1; return 1;
} }
//发包类型 //发包类型
static int SendPackType(uint32_t v) int squirrel::SendPackType(uint32_t v)
{ {
int n1; int n1;
SQGetInt(v, 2, &n1); SQGetInt(v, 2, &n1);
@ -235,9 +239,8 @@ static int SendPackType(uint32_t v)
SQPushInt(v, 1); SQPushInt(v, 1);
return 1; return 1;
} }
//发包Byte //发包Byte
static int SendPackByte(uint32_t v) int squirrel::SendPackByte(uint32_t v)
{ {
int n1; int n1;
SQGetInt(v, 2, &n1); SQGetInt(v, 2, &n1);
@ -246,9 +249,8 @@ static int SendPackByte(uint32_t v)
SQPushInt(v, 1); SQPushInt(v, 1);
return 1; return 1;
} }
//发包Word //发包Word
static int SendPackWord(uint32_t v) int squirrel::SendPackWord(uint32_t v)
{ {
int n1; int n1;
SQGetInt(v, 2, &n1); SQGetInt(v, 2, &n1);
@ -257,9 +259,8 @@ static int SendPackWord(uint32_t v)
SQPushInt(v, 1); SQPushInt(v, 1);
return 1; return 1;
} }
//发包DWord //发包DWord
static int SendPackDWord(uint32_t v) int squirrel::SendPackDWord(uint32_t v)
{ {
int n1; int n1;
SQGetInt(v, 2, &n1); SQGetInt(v, 2, &n1);
@ -268,17 +269,17 @@ static int SendPackDWord(uint32_t v)
SQPushInt(v, 1); SQPushInt(v, 1);
return 1; return 1;
} }
//发包 //发包
static int SendPack(uint32_t v) int squirrel::SendPack(uint32_t v)
{ {
_SendPacks(); _SendPacks();
SQPushInt(v, 1); SQPushInt(v, 1);
return 1; return 1;
} }
//发物品给玩家 //发物品给玩家
static int GivePlayerItem(uint32_t v) int squirrel::GivePlayerItem(uint32_t v)
{ {
int n1, n2; int n1, n2;
@ -304,9 +305,8 @@ static int GivePlayerItem(uint32_t v)
return 1; return 1;
} }
//发装备给玩家 //发装备给玩家
static int GivePlayerEqu(uint32_t v) int squirrel::GivePlayerEqu(uint32_t v)
{ {
int n1, n2; int n1, n2;
@ -334,7 +334,7 @@ static int GivePlayerEqu(uint32_t v)
} }
//去副本 //去副本
static int GoDungeon(uint32_t v) int squirrel::GoDungeon(uint32_t v)
{ {
int n1 = 0; int n1 = 0;
int n2 = 0; int n2 = 0;
@ -373,9 +373,8 @@ static int GoDungeon(uint32_t v)
SQPushBool(v, true); SQPushBool(v, true);
return 1; return 1;
} }
//回城 //回城
static int GoTown(uint32_t v) int squirrel::GoTown(uint32_t v)
{ {
int num = SQGetTop(v); int num = SQGetTop(v);
if (num == 1) if (num == 1)
@ -390,9 +389,41 @@ static int GoTown(uint32_t v)
} }
return 1; return 1;
} }
//移动城镇
int squirrel::MoveTown(uint32_t v)
{
int TownIndex;
int ReIndex;
int XPos;
int YPos;
int num = SQGetTop(v);
if (num == 5)
{
SQGetInt(v, 2, &TownIndex);
SQGetInt(v, 3, &ReIndex);
SQGetInt(v, 4, &XPos);
SQGetInt(v, 5, &YPos);
_SendpacksType(*_SendClass, 0, 38);
_SendPacksByte(*_SendClass, 0, TownIndex);
_SendPacksByte(*_SendClass, 0, ReIndex);
_SendPacksWord(*_SendClass, 0, XPos);
_SendPacksWord(*_SendClass, 0, YPos);
_SendPacksByte(*_SendClass, 0, 5);
_SendPacksWord(*_SendClass, 0, 0);
_SendPacksWord(*_SendClass, 0, 0);
_SendPacks();
SQPushBool(v, true);
}
else
{
SQPushBool(v, false);
}
return 1;
}
//Ldofile //Ldofile
static int LDofile(uint32_t v) int squirrel::LDofile(uint32_t v)
{ {
wchar_t* n1; wchar_t* n1;
@ -420,9 +451,8 @@ static int LDofile(uint32_t v)
return 1; return 1;
} }
//Lcout //Lcout
static int Lcout(uint32_t v) int squirrel::Lcout(uint32_t v)
{ {
char* str = NULL; char* str = NULL;
int type = NULL; int type = NULL;
@ -460,9 +490,8 @@ static int Lcout(uint32_t v)
return 1; return 1;
} }
//新建窗口
//Lcout int squirrel::NewWindows(uint32_t v)
static int NewWindows(uint32_t v)
{ {
char* str = NULL; char* str = NULL;
int type = NULL; int type = NULL;
@ -500,9 +529,8 @@ static int NewWindows(uint32_t v)
return 1; return 1;
} }
//设置UI槽坐标
//Lcout int squirrel::SetSlot(uint32_t v)
static int SetSlot(uint32_t v)
{ {
int Type = NULL; int Type = NULL;
int Index = NULL; int Index = NULL;
@ -611,7 +639,7 @@ static int SetSlot(uint32_t v)
//查询 类型容器 //查询 类型容器
static int Get_STL(uint32_t v) int squirrel::Get_STL(uint32_t v)
{ {
char* Name; char* Name;
int Type; int Type;
@ -668,9 +696,8 @@ static int Get_STL(uint32_t v)
return 0; return 0;
} }
} }
//设置 类型容器 //设置 类型容器
static int Set_STL(uint32_t v) int squirrel::Set_STL(uint32_t v)
{ {
char* Name; char* Name;
int Type; int Type;
@ -738,9 +765,8 @@ static int Set_STL(uint32_t v)
} }
return 1; return 1;
} }
//new 类型容器 //new 类型容器
static int New_STL(uint32_t v) int squirrel::New_STL(uint32_t v)
{ {
char* Name; char* Name;
int Type; int Type;
@ -796,27 +822,67 @@ static int New_STL(uint32_t v)
return 1; return 1;
} }
void TimeSTL(LPVOID lpParam)
{
TimeSTLStruct *pack = (TimeSTLStruct*)lpParam;
int F_Time = (int)GetTickCount64();
while (true)
{
int N_Time = (int)GetTickCount64() - F_Time;
if (N_Time < Time_STL[pack->Name].Max_Time)
{
Time_STL[pack->Name].Now_Time = N_Time;
}
else
{
break;
}
}
}
//时间容器 //时间容器
int squirrel::Timer_STL(uint32_t v) int squirrel::Timer_STL(uint32_t v)
{ {
char* Name; char* Name;
int MaxTime;
int Type; int Type;
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
if (ParameterNum == 3) if (ParameterNum == 4)
{ {
//获取容器名字 //获取容器名字
SQGetStringc(v, 2, &Name); SQGetStringc(v, 2, &Name);
//获取最大值
SQGetInt(v, 3, &MaxTime);
//获取容器类型 //获取容器类型
SQGetInt(v, 3, &Type); SQGetInt(v, 4, &Type);
if (STL::Check_STL(Name, Type) != 0)
{
SQPushBool(v, false);
return 1;
}
switch (Type) switch (Type)
{ {
case 0: case 0: {
Int_STL[Name] = 0;//单Int容器 if (Time_STL.count(Name) != 0)//如果这个标识容器存在 就返回 否则创建
{
SQPushBool(v, false);
return 1;
}
TimeSTLStruct pack;
pack.Name = Name;//设置容器标识名称
pack.Max_Time = MaxTime;//设置 标识时间容器最大时间
pack.Now_Time = 0;//设置 标识时间容器当前时间
Time_STL[Name] = pack;//设置包给标识时间容器
break; }
case 1: {
DWORD threadID;
std::cout << Time_STL[Name].Name << std::endl;
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TimeSTL, &Time_STL[Name], 0, &threadID);
break; }
case 2:
SQPushInt(v, Time_STL[Name].Now_Time);
return 1;
break;
default:
SQPushBool(v, false);
return 1;
break; break;
} }
SQPushBool(v, true); SQPushBool(v, true);
@ -829,7 +895,7 @@ int squirrel::Timer_STL(uint32_t v)
} }
//同步 龙盒数据包 //同步 龙盒数据包
static int Sync_Dragon_Pack(uint32_t v) int squirrel::Sync_Dragon_Pack(uint32_t v)
{ {
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
if (ParameterNum == 1) if (ParameterNum == 1)
@ -843,10 +909,8 @@ static int Sync_Dragon_Pack(uint32_t v)
} }
return 1; return 1;
} }
//获取 龙盒数据包 //获取 龙盒数据包
static int Get_Dragon_Pack(uint32_t v) int squirrel::Get_Dragon_Pack(uint32_t v)
{ {
int Type; int Type;
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
@ -880,10 +944,8 @@ static int Get_Dragon_Pack(uint32_t v)
return 1; return 1;
} }
//发送 开龙盒 //发送 开龙盒
static int Redom_Dragon(uint32_t v) int squirrel::Redom_Dragon(uint32_t v)
{ {
int Type; int Type;
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
@ -912,7 +974,7 @@ static int Redom_Dragon(uint32_t v)
} }
//获取 龙盒 模式 //获取 龙盒 模式
static int Get_DragonModel(uint32_t v) int squirrel::Get_DragonModel(uint32_t v)
{ {
int Type; int Type;
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
@ -929,7 +991,7 @@ static int Get_DragonModel(uint32_t v)
return 1; return 1;
} }
//设置 龙盒 模式 //设置 龙盒 模式
static int Set_DragonModel(uint32_t v) int squirrel::Set_DragonModel(uint32_t v)
{ {
int Model; int Model;
int ParameterNum = SQGetTop(v); int ParameterNum = SQGetTop(v);
@ -966,40 +1028,41 @@ void squirrel::RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t
void squirrel::R_Register_Nut() void squirrel::R_Register_Nut()
{ {
RegisterNutApi(L"L_sq_Test", sq_Test); RegisterNutApi(L"L_sq_Test", squirrel::sq_Test);
RegisterNutApi(L"L_sq_GetCharacterAttribute", GetCharacterAttribute);//获取人物或装备属性 RegisterNutApi(L"L_sq_GetCharacterAttribute", squirrel::GetCharacterAttribute);//获取人物或装备属性
RegisterNutApi(L"L_sq_SetCharacterAttribute", SetCharacterAttribute);//设置人物或装备属性 RegisterNutApi(L"L_sq_SetCharacterAttribute", squirrel::SetCharacterAttribute);//设置人物或装备属性
RegisterNutApi(L"L_sq_GetTownIndex", GetTownIndex);//获取城镇编号 RegisterNutApi(L"L_sq_GetTownIndex", squirrel::GetTownIndex);//获取城镇编号
RegisterNutApi(L"L_sq_GetRegionIndex", GetRegionIndex);//获取区域编号 RegisterNutApi(L"L_sq_GetRegionIndex", squirrel::GetRegionIndex);//获取区域编号
RegisterNutApi(L"L_sq_GetTownXpos", GetTownXpos);//获取城镇X坐标 RegisterNutApi(L"L_sq_GetTownXpos", squirrel::GetTownXpos);//获取城镇X坐标
RegisterNutApi(L"L_sq_GetTownYpos", GetTownYpos);//获取城镇Y坐标 RegisterNutApi(L"L_sq_GetTownYpos", squirrel::GetTownYpos);//获取城镇Y坐标
RegisterNutApi(L"L_sq_GetFatigue", GetFatigue);//获取疲劳值 RegisterNutApi(L"L_sq_GetFatigue", squirrel::GetFatigue);//获取疲劳值
RegisterNutApi(L"L_sq_GetExp", GetExp);//获取经验值 RegisterNutApi(L"L_sq_GetExp", squirrel::GetExp);//获取经验值
RegisterNutApi(L"L_sq_SendPackType", SendPackType);//发包类型 RegisterNutApi(L"L_sq_SendPackType", squirrel::SendPackType);//发包类型
RegisterNutApi(L"L_sq_SendPackByte", SendPackByte);//包数据Byte RegisterNutApi(L"L_sq_SendPackByte", squirrel::SendPackByte);//包数据Byte
RegisterNutApi(L"L_sq_SendPackWord", SendPackWord);//包数据Word RegisterNutApi(L"L_sq_SendPackWord", squirrel::SendPackWord);//包数据Word
RegisterNutApi(L"L_sq_SendPackDWord", SendPackDWord);//包数据DWord RegisterNutApi(L"L_sq_SendPackDWord", squirrel::SendPackDWord);//包数据DWord
RegisterNutApi(L"L_sq_SendPack", SendPack);//发包 RegisterNutApi(L"L_sq_SendPack", squirrel::SendPack);//发包
RegisterNutApi(L"L_sq_GivePlayerItem", GivePlayerItem);//给用户物品 RegisterNutApi(L"L_sq_GivePlayerItem", squirrel::GivePlayerItem);//给用户物品
RegisterNutApi(L"L_sq_GivePlayerEqu", GivePlayerEqu);//给用户装备 RegisterNutApi(L"L_sq_GivePlayerEqu", squirrel::GivePlayerEqu);//给用户装备
RegisterNutApi(L"L_sq_GoDungeon", GoDungeon);//去副本 RegisterNutApi(L"L_sq_GoDungeon", squirrel::GoDungeon);//去副本
RegisterNutApi(L"L_sq_GoTown", GoTown);//去城镇 RegisterNutApi(L"L_sq_GoTown", squirrel::GoTown);//去城镇
RegisterNutApi(L"L_sq_Dofile", LDofile);//加密读取 RegisterNutApi(L"L_sq_MoveTown", squirrel::MoveTown);//去城镇
RegisterNutApi(L"L_cout", Lcout);//输出公告 RegisterNutApi(L"L_sq_Dofile", squirrel::LDofile);//加密读取
RegisterNutApi(L"L_NewWindows", NewWindows);//创建窗口 RegisterNutApi(L"L_cout", squirrel::Lcout);//输出公告
RegisterNutApi(L"L_SetSlot", SetSlot);//设置槽坐标 RegisterNutApi(L"L_NewWindows", squirrel::NewWindows);//创建窗口
RegisterNutApi(L"L_SetSlot", squirrel::SetSlot);//设置槽坐标
RegisterNutApi(L"L_New_STL", New_STL);//新建容器 RegisterNutApi(L"L_New_STL", squirrel::New_STL);//新建容器
RegisterNutApi(L"L_Set_STL", Set_STL);//设置容器 RegisterNutApi(L"L_Set_STL", squirrel::Set_STL);//设置容器
RegisterNutApi(L"L_Get_STL", Get_STL);//获取容器 RegisterNutApi(L"L_Get_STL", squirrel::Get_STL);//获取容器
RegisterNutApi(L"L_Timer_STL", Timer_STL);//获取容器 RegisterNutApi(L"L_Timer_STL", squirrel::Timer_STL);//时间容器
RegisterNutApi(L"L_Get_DragonModel", Get_DragonModel);//获取龙盒模式 RegisterNutApi(L"L_Get_DragonModel", squirrel::Get_DragonModel);//获取龙盒模式
RegisterNutApi(L"L_Set_DragonModel", Set_DragonModel);//设置龙盒模式 RegisterNutApi(L"L_Set_DragonModel", squirrel::Set_DragonModel);//设置龙盒模式
RegisterNutApi(L"L_Redom_Dragon", Redom_Dragon);//抽奖 RegisterNutApi(L"L_Redom_Dragon", squirrel::Redom_Dragon);//抽奖
RegisterNutApi(L"L_Get_Dragon_Pack", Get_Dragon_Pack);//查询龙盒包 RegisterNutApi(L"L_Get_Dragon_Pack", squirrel::Get_Dragon_Pack);//查询龙盒包
RegisterNutApi(L"L_Sync_Dragon_Pack", Sync_Dragon_Pack);//同步龙盒包 RegisterNutApi(L"L_Sync_Dragon_Pack", squirrel::Sync_Dragon_Pack);//同步龙盒包
} }

View File

@ -139,15 +139,52 @@ class squirrel
private: private:
public: public://加载
//╪сть
static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror); static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror);
static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror); static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror);
public://NUT API 接口
static int sq_Test(uint32_t v);//测试接口
static int GetCharacterAttribute(uint32_t v);//读人物或装备属性
static int SetCharacterAttribute(uint32_t v);//写人物或装备属性
static int GetTownIndex(uint32_t v);//获取城镇编号
static int GetRegionIndex(uint32_t v);//获取城镇区域编号
static int GetTownXpos(uint32_t v);//获取城镇X坐标
static int GetTownYpos(uint32_t v);//获取城镇Y坐标
static int GetFatigue(uint32_t v);//获取疲劳值
static int GetExp(uint32_t v);//获取经验值
static int GoDungeon(uint32_t v);//去副本
static int GoTown(uint32_t v);//回城
static int MoveTown(uint32_t v);//回城
static int LDofile(uint32_t v);//Ldofile
static int Lcout(uint32_t v);//Lcout
static int NewWindows(uint32_t v);//新建窗口
static int SetSlot(uint32_t v);//设置UI槽坐标
public://发包 API
static int SendPackType(uint32_t v);//发包类型
static int SendPackByte(uint32_t v);//发包Byte
static int SendPackWord(uint32_t v);//发包Word
static int SendPackDWord(uint32_t v);//发包DWord
static int SendPack(uint32_t v);//发包
static int GivePlayerItem(uint32_t v);//发物品给玩家
static int GivePlayerEqu(uint32_t v);//发装备给玩家
public://容器类接口 public://容器类接口
static int Get_STL(uint32_t v);//查询 类型容器
static int Set_STL(uint32_t v);//设置 类型容器
static int New_STL(uint32_t v);//new 类型容器
static int Timer_STL(uint32_t v);//时间容器 static int Timer_STL(uint32_t v);//时间容器
public://龙盒
static int Sync_Dragon_Pack(uint32_t v);//同步 龙盒数据包
static int Get_Dragon_Pack(uint32_t v);//获取 龙盒数据包
static int Redom_Dragon(uint32_t v);//发送 开龙盒
static int Get_DragonModel(uint32_t v);//获取 龙盒 模式
static int Set_DragonModel(uint32_t v);//设置 龙盒 模式
public: public:
//新增nut接口funcName绑定C语言函数funcAddr //新增nut接口funcName绑定C语言函数funcAddr