200 lines
6.3 KiB
Plaintext
200 lines
6.3 KiB
Plaintext
/*
|
|
文件名:Hacker_RegApi.nut
|
|
路径:Base/_Tool/Hacker_RegApi.nut
|
|
创建日期:2024-09-25 18:31
|
|
文件用途:注册API
|
|
*/
|
|
//工具类
|
|
class R_Utils {
|
|
|
|
String = {
|
|
FindLastSubstring = function(str, substring) {
|
|
local strLen = str.len();
|
|
local subLen = substring.len();
|
|
local lastIndex = -1;
|
|
for (local i = 0; i <= strLen - subLen; i++) {
|
|
local found = true;
|
|
for (local j = 0; j< subLen; j++) {
|
|
if (str[i + j] != substring[j]) {
|
|
found = false;
|
|
break;
|
|
}
|
|
}
|
|
if (found) {
|
|
lastIndex = i;
|
|
}
|
|
}
|
|
return lastIndex;
|
|
}
|
|
}
|
|
//播放音效
|
|
function PlaySound(SoundName) {
|
|
L_Sq_CallFunc(0x75BD70, "void", FFI_MS_CDECL, ["pointer", "int", "int", "int"], Memory.allocUtf8String(SoundName).C_Object, -1, 0, 0);
|
|
}
|
|
|
|
//读取文件内容
|
|
function ReadScript(Path, Size, CodePage) {
|
|
local ReadPath = L_sq_P2I(Memory.allocUtf8String(Path).C_Object);
|
|
local Reader = Memory.alloc(Size);
|
|
local ReadBuffer = L_sq_P2I(Reader.C_Object);
|
|
L_Sq_CallFunc(0x11A2030, "int", FFI_FASTCALL, ["int", "int", "int", "int", "int", "int"], 0x1D17638, 0, ReadPath, ReadBuffer, 0x100000, 0x19DAF4);
|
|
|
|
|
|
if (CodePage == "utf8")
|
|
return Reader.readUtf8String();
|
|
if (CodePage == "unicode")
|
|
return Reader.readUnicodeString();
|
|
if (CodePage == "big5")
|
|
return Reader.readBig5String();
|
|
}
|
|
|
|
//读取文件
|
|
function GetScriptFileReader(Path, ...) {
|
|
local AllocSize = 102400;
|
|
if (vargc > 0) AllocSize = vargv[0];
|
|
//读取路径
|
|
local ReadPath = L_sq_P2I(Memory.allocUtf8String(Path).C_Object);
|
|
//读取缓存
|
|
local Reader = Memory.alloc(AllocSize);
|
|
local ReadBuffer = L_sq_P2I(Reader.C_Object);
|
|
//实际读取大小
|
|
local ReadSizeer = Memory.alloc(4);
|
|
local ReadSizeBuffer = L_sq_P2I(ReadSizeer.C_Object);
|
|
|
|
local Flag = L_Sq_CallFunc(0x59E3D0, "bool", FFI_MS_CDECL, ["int", "int", "int", "int"], ReadPath, ReadBuffer, AllocSize, ReadSizeBuffer);
|
|
if (Flag) {
|
|
return {
|
|
Buffer = Reader,
|
|
Size = ReadSizeer.readInt()
|
|
};
|
|
} else return null;
|
|
}
|
|
|
|
//读取配置表
|
|
function ReadScriptConfig(Path, Size, ...) {
|
|
local CodePage = "utf8";
|
|
if (vargc > 0) CodePage = vargv[0];
|
|
local Script = R_Utils.ReadScript(Path, Size, CodePage);
|
|
local Func = compilestring("return " + Script);
|
|
local Ret = Func();
|
|
return Ret;
|
|
}
|
|
|
|
//获取一个指定装备的角色对象
|
|
function GetCharacByEqu(Job, GrowType, Equ) {
|
|
local Obj = sq_CreateCharacter(Job, GrowType);
|
|
local ObjAddress = L_Sq_GetObjectAddress(Obj);
|
|
foreach(value in Equ) {
|
|
local ItemObject = L_sq_GetItem(value);
|
|
// L_Sq_CallFunc(0x825570, "void", FFI_THISCALL, ["int", "int"], ObjAddress, ItemObject);
|
|
L_Sq_CallFunc(0x8265A0, "void", FFI_THISCALL, ["int", "int", "int"], ObjAddress, ItemObject, -1);
|
|
}
|
|
return sq_GetCNRDObjectToSQRCharacter(Obj);
|
|
}
|
|
|
|
//获取装备编号的得文件路径
|
|
function GetEquPath(Equ) {
|
|
local EquPathAddress = L_Sq_CallFunc(0x1219E80, "int", FFI_THISCALL, ["int", "int"], 0x1d7993c, Equ);
|
|
if (EquPathAddress) {
|
|
return NativePointer(EquPathAddress).readUnicodeString();
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据List读取文件地址
|
|
// Rindro_Haker.LoadHook(0x1219E80, ["int", "int", "int"],
|
|
// function(args) {
|
|
// // print(format("%02x", args[0]));
|
|
|
|
// // print(args[2]);
|
|
// return null;
|
|
// },
|
|
// function(args) {
|
|
// // print(666);
|
|
// // print(format("%02x", args.pop()));
|
|
// // TTTAni <- args.pop();
|
|
|
|
|
|
// // local Path = NativePointer(L_sq_I2P(args.pop())).readUnicodeString();
|
|
// // if (Path != "character/swordman/weapon/katana/kat_lowkogaras.equ" && Path != "new_elvengard.twn") {
|
|
// // print(args[0]);
|
|
// // print(args[1]);
|
|
// // // print(format("%02x", args[1]));
|
|
// // print(Path);
|
|
// // }
|
|
// return null;
|
|
// });
|
|
|
|
//可能是构造装备以及构造其他东西
|
|
// Rindro_Haker.LoadHook(0x972220, ["int", "int", "int", "int"],
|
|
// function(args) {
|
|
// // print(format("%02x", args[0]));
|
|
// // local AniPath = NativePointer(L_sq_I2P(args[0])).readUnicodeString();
|
|
// if (args[0] == 10402) {
|
|
// print(args[0]);
|
|
// print(args[1]);
|
|
// print(args[2]);
|
|
// }
|
|
// // print(args[2]);
|
|
// return null;
|
|
// },
|
|
// function(args) {
|
|
// // print(666);
|
|
// // print(format("%02x", args.pop()));
|
|
// // TTTAni <- args.pop();
|
|
// return null;
|
|
// });
|
|
|
|
//绘制字符
|
|
getroottable().DrawCodeCallBackFunc <- {};
|
|
// Rindro_Haker.LoadHook(0x1206BD0, ["int", "int", "int", "pointer", "int", "void"],
|
|
// function(args) {
|
|
// // print("nut:" + format("%02x", args[3]));
|
|
|
|
// if (args[3]) {
|
|
// local DrawCode = NativePointer((args[3])).readUnicodeString();
|
|
// // print(DrawCode);
|
|
// if (DrawCode in DrawCodeCallBackFunc)
|
|
// DrawCodeCallBackFunc[DrawCode](args);
|
|
// // print(args[3]);
|
|
// }
|
|
// return null;
|
|
// },
|
|
// function(args) {
|
|
// // print(666);
|
|
// // print(format("%02x", args.pop()));
|
|
// // TTTAni <- args.pop();
|
|
// return null;
|
|
// });
|
|
|
|
//绘制城镇回调
|
|
getroottable().DrawTownCallBackFunc <- {};
|
|
Rindro_Haker.LoadHook(0x1108700, ["int", "void"],
|
|
function(args) {
|
|
// print("nut:" + format("%02x", args[3]));
|
|
// print(format("%02x", args[0]));
|
|
foreach(Func in DrawTownCallBackFunc) {
|
|
Func();
|
|
}
|
|
return null;
|
|
},
|
|
function(args) {
|
|
// print(666);
|
|
// print(format("%02x", args.pop()));
|
|
// TTTAni <- args.pop();
|
|
return null;
|
|
});
|
|
|
|
|
|
//顺图
|
|
function Rindro_Gm_MoveMap()
|
|
{
|
|
|
|
}
|
|
getroottable()["LenheartFuncTab"].rawset("Rindro_Gm_MoveMapFuncN", Rindro_Gm_MoveMap); |