111
This commit is contained in:
@@ -279,8 +279,7 @@ class GameManager extends Base_C_Object {
|
||||
function FixInvasion() {
|
||||
NativePointer("0x81DB4EA").writeS8(0x00);
|
||||
|
||||
getroottable()._TH_MEM_K_ <- Memory.allocUtf8String("/");
|
||||
{
|
||||
getroottable()._TH_MEM_K_ <- Memory.allocUtf8String("/"); {
|
||||
local _Execve_Address = Module.getExportByName(null, "execve");
|
||||
local _Execve_Address_Str = "" + _Execve_Address;
|
||||
_Execve_Address_Str = _Execve_Address_Str.slice(_Execve_Address_Str.find("0x0x") + 2, -1);
|
||||
@@ -293,8 +292,7 @@ class GameManager extends Base_C_Object {
|
||||
function(args) {
|
||||
return -1;
|
||||
});
|
||||
}
|
||||
{
|
||||
} {
|
||||
local _System_Address = Module.getExportByName(null, "system");
|
||||
local _System_Address_Str = "" + _System_Address;
|
||||
_System_Address_Str = _System_Address_Str.slice(_System_Address_Str.find("0x0x") + 2, -1);
|
||||
@@ -310,6 +308,30 @@ class GameManager extends Base_C_Object {
|
||||
}
|
||||
}
|
||||
|
||||
//修复练习模式
|
||||
function FixPracticemode() {
|
||||
Sq_WriteByteArr(S_Ptr("0x81C820A"), [0xE9, 0xC6, 0x0, 0x0, 0x0, 0x90]);
|
||||
}
|
||||
|
||||
//修复黑暗武士技能
|
||||
function FixDarkWarriorSkillBar()
|
||||
{
|
||||
Cb_CheckMoveComboSkillSlot_Leave_Func["DPSOFF"] <- function (args)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// //调用群助手发送消息
|
||||
// function GroupAssistantSendAMessage() {
|
||||
// //私有方法 发送带参数的Post请求
|
||||
// local SO = Http("129.211.27.104", "9080");
|
||||
// local Res = SO.Post("/dof/chat", Json.Encode({
|
||||
// username = "倾泪寒",
|
||||
// text = "倾泪寒爆史诗了!",
|
||||
// groupId = 416424738
|
||||
// }), "application/json");
|
||||
// }
|
||||
}
|
||||
//热重载
|
||||
getroottable()._HotFixPath_ <- {};
|
||||
@@ -318,22 +340,34 @@ getroottable()._HotFixPathChangeTimer_ <- {};
|
||||
function _Reload_List_Write_(Path) {
|
||||
local NowTime = Sq_GetTimestampString().slice(-9).tointeger();
|
||||
if (!getroottable()._HotFixPathChangeTimer_.rawin(Path) || NowTime - getroottable()._HotFixPathChangeTimer_[Path] > 1000) {
|
||||
//判断类型
|
||||
if (endswith(Path, ".nut")) {
|
||||
dofile(Path);
|
||||
print("位于 [" + Path + "] 的脚本已重载")
|
||||
} else if (endswith(Path, ".json")) {
|
||||
try {
|
||||
local PArr = split(Path, "/");
|
||||
local RealName = PArr[PArr.len() - 1];
|
||||
GlobalConfig.LoadJson(RealName, Path);
|
||||
Timer.SetTimeOut(function() {
|
||||
//判断类型
|
||||
if (endswith(Path, ".nut")) {
|
||||
dofile(Path);
|
||||
print("位于 [" + Path + "] 的脚本已重载")
|
||||
} else if (endswith(Path, ".json")) {
|
||||
try {
|
||||
local PArr = split(Path, "/");
|
||||
local RealName = PArr[PArr.len() - 1];
|
||||
|
||||
print("位于 [" + Path + "] 的配置已重载");
|
||||
//在载入新配置之前 先拿到旧配置保存起来
|
||||
local OldConfig = GlobalConfig.Get(RealName);
|
||||
GlobalConfig.LoadJson(RealName, Path);
|
||||
|
||||
} catch (exception) {
|
||||
//如果存在项目 并且有重载入口 则调用重载入口
|
||||
if (_GlobalOfficial_Project.ReloadProjectMap.rawin(RealName)) {
|
||||
local ProjectStartFunc = _GlobalOfficial_Project.ReloadProjectMap[RealName];
|
||||
if (getroottable().rawin(ProjectStartFunc + "Reload_")) {
|
||||
getroottable()[ProjectStartFunc + "Reload_"](OldConfig);
|
||||
}
|
||||
}
|
||||
print("位于 [" + Path + "] 的配置已重载");
|
||||
|
||||
} catch (exception) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
getroottable()._HotFixPathChangeTimer_[Path] <- NowTime;
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,12 @@ class Http {
|
||||
return encoded;
|
||||
}
|
||||
|
||||
function Request(Type, Url, Content) {
|
||||
function Request(Type, Url, Content, DataType) {
|
||||
local RequestBuffer = Type + " " + Url + " HTTP/1.1\r\nHost: " + Host + "\r\n";
|
||||
|
||||
if (Content) {
|
||||
RequestBuffer += "Content-Length: " + Content.len() + "\r\n";
|
||||
RequestBuffer += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
RequestBuffer += "Content-Type: " + DataType + "\r\n";
|
||||
RequestBuffer += "\r\n";
|
||||
RequestBuffer += Content;
|
||||
} else {
|
||||
@@ -39,16 +39,19 @@ class Http {
|
||||
}
|
||||
|
||||
// 发送请求
|
||||
function Post(Url, params = null) {
|
||||
function Post(Url, params = null, DataType = "application/x-www-form-urlencoded") {
|
||||
local content = null;
|
||||
if (params != null && typeof params == "table") {
|
||||
content = _EncodeParams(params); // 编码参数
|
||||
}
|
||||
return Request("POST", Url, content);
|
||||
else if (params != null && typeof params == "string") {
|
||||
content = params;
|
||||
}
|
||||
return Request("POST", Url, content, DataType);
|
||||
}
|
||||
|
||||
function Get(Url, Content = null) {
|
||||
return Request("GET", Url, Content);
|
||||
function Get(Url, Content = null, DataType = "application/x-www-form-urlencoded") {
|
||||
return Request("GET", Url, Content, DataType);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,8 +246,7 @@ class HttpResponse {
|
||||
response += "Content-Length: " + JsonString.len() + "\r\n";
|
||||
response += "\r\n";
|
||||
response += JsonString;
|
||||
}
|
||||
else if(typeof Msg == "string") {
|
||||
} else if (typeof Msg == "string") {
|
||||
response += "Content-Type: text/plain\r\n";
|
||||
response += "Content-Length: " + Msg.len() + "\r\n";
|
||||
response += "\r\n";
|
||||
|
||||
@@ -33,6 +33,11 @@ class Inven extends Base_C_Object {
|
||||
return Sq_Inven_GetItemById(this.C_Object, Idx);
|
||||
}
|
||||
|
||||
//获取金币
|
||||
function GetMoney() {
|
||||
return Sq_CallFunc(S_Ptr("0x817a188"), "int", ["pointer"], SUser.C_Object);
|
||||
}
|
||||
|
||||
//检查背包是否拥有指定数量的指定道具
|
||||
function CheckItemCount(ItemId, ItemCount) {
|
||||
if (ItemId == 0) {
|
||||
|
||||
@@ -4,41 +4,60 @@
|
||||
创建日期:2025-03-30 00:03
|
||||
文件用途:官方项目
|
||||
*/
|
||||
function _Start_Official_Project_() {
|
||||
// 定义 ANSI 颜色代码
|
||||
local COLOR_RESET = "\x1b[0m";
|
||||
local COLOR_MAGENTA = "\x1b[95m";
|
||||
local COLOR_CYAN = "\x1b[96m";
|
||||
local COLOR_YELLOW = "\x1b[93m";
|
||||
local COLOR_RED = "\x1b[91m";
|
||||
class _Official_Project_ {
|
||||
ReloadProjectMap = null;
|
||||
|
||||
constructor() {
|
||||
//在全局中注册自己
|
||||
getroottable()._GlobalOfficial_Project <- this;
|
||||
ReloadProjectMap = {};
|
||||
|
||||
|
||||
local WorkPath = "/dp_s/OfficialProject";
|
||||
local Dirs = sq_GetListDirs(WorkPath);
|
||||
if (Dirs.len() > 0) {
|
||||
print(format("\n\n\t\t\t\t%s开始加载DP-S插件市场项目%s", COLOR_YELLOW, COLOR_RESET));
|
||||
Init();
|
||||
}
|
||||
foreach(DirPath in Dirs) {
|
||||
local FilePaths = sq_GetListFiles(WorkPath + "/" + DirPath);
|
||||
|
||||
foreach(FilePath in FilePaths) {
|
||||
//找到项目文件
|
||||
if (FilePath == "Proj.ifo") {
|
||||
local Config = sq_ReadJsonFile(WorkPath + "/" + DirPath + "/" + FilePath);
|
||||
if (Config) {
|
||||
try {
|
||||
local ProjectFiles = Config.ProjectFiles;
|
||||
//载入所有项目文件
|
||||
foreach(ProjectFile in ProjectFiles) {
|
||||
sq_RunScript("OfficialProject/" + DirPath + "/" + ProjectFile);
|
||||
function Init() {
|
||||
// 定义 ANSI 颜色代码
|
||||
local COLOR_RESET = "\x1b[0m";
|
||||
local COLOR_MAGENTA = "\x1b[95m";
|
||||
local COLOR_CYAN = "\x1b[96m";
|
||||
local COLOR_YELLOW = "\x1b[93m";
|
||||
local COLOR_RED = "\x1b[91m";
|
||||
|
||||
|
||||
local WorkPath = "/dp_s/OfficialProject";
|
||||
local Dirs = sq_GetListDirs(WorkPath);
|
||||
if (Dirs.len() > 0) {
|
||||
print(format("\n\n\t\t\t\t%s开始加载DP-S插件市场项目%s", COLOR_YELLOW, COLOR_RESET));
|
||||
}
|
||||
foreach(DirPath in Dirs) {
|
||||
local FilePaths = sq_GetListFiles(WorkPath + "/" + DirPath);
|
||||
|
||||
foreach(FilePath in FilePaths) {
|
||||
//找到项目文件
|
||||
if (FilePath == "Proj.ifo") {
|
||||
local Config = sq_ReadJsonFile(WorkPath + "/" + DirPath + "/" + FilePath);
|
||||
if (Config) {
|
||||
try {
|
||||
//读取配置文件建立Map
|
||||
local ProjectConfig = Config.ProjectConfig;
|
||||
if(ProjectConfig.len() > 0){
|
||||
ReloadProjectMap.rawset(ProjectConfig,Config.ProjectRunFunc);
|
||||
}
|
||||
|
||||
local ProjectFiles = Config.ProjectFiles;
|
||||
//载入所有项目文件
|
||||
foreach(ProjectFile in ProjectFiles) {
|
||||
sq_RunScript("OfficialProject/" + DirPath + "/" + ProjectFile);
|
||||
}
|
||||
//调用启动函数
|
||||
getroottable()[Config.ProjectRunFunc]();
|
||||
//播报脚本已加载
|
||||
print(format("%s[ %s ]%s" + " 脚本项目已加载 --- 当前版本: %s%.2f%s", COLOR_YELLOW, Config.ProjectName, COLOR_RESET, COLOR_YELLOW, Config.ProjectVersion, COLOR_RESET));
|
||||
} catch (exception) {
|
||||
//播报脚本未加载
|
||||
print(format("%s[ %s ]%s" + " 脚本项目未加载 --- 当前版本: %s%.2f%s", COLOR_RED, Config.ProjectName, COLOR_RESET, COLOR_RED, Config.ProjectVersion, COLOR_RESET));
|
||||
}
|
||||
//调用启动函数
|
||||
getroottable()[Config.ProjectRunFunc]();
|
||||
//播报脚本已加载
|
||||
print(format("%s[ %s ]%s" + " 脚本项目已加载 --- 当前版本: %s%.2f%s", COLOR_YELLOW, Config.ProjectName, COLOR_RESET, COLOR_YELLOW, Config.ProjectVersion, COLOR_RESET));
|
||||
} catch (exception) {
|
||||
//播报脚本未加载
|
||||
print(format("%s[ %s ]%s" + " 脚本项目未加载 --- 当前版本: %s%.2f%s", COLOR_RED, Config.ProjectName, COLOR_RESET, COLOR_RED, Config.ProjectVersion, COLOR_RESET));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ class Packet extends Base_C_Object {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function GetBinary(len) {
|
||||
local data = Memory.alloc(len);
|
||||
if (Sq_CallFunc(S_Ptr("0x858D3B2"), "int", ["pointer", "pointer"], this.C_Object, data.C_Object)) {
|
||||
@@ -99,6 +100,14 @@ class Packet extends Base_C_Object {
|
||||
return null;
|
||||
}
|
||||
|
||||
function GetString(a3,a4) {
|
||||
local data = Memory.alloc(a3);
|
||||
if (Sq_CallFunc(S_Ptr("0x858D2BC"), "int", ["pointer", "pointer","int","int","int"], this.C_Object, data.C_Object,a3,a4)) {
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function Delete() {
|
||||
Sq_CallFunc(S_Ptr("0x858DE80"), "void", ["pointer"], this.C_Object);
|
||||
Sq_Delete_Point(this.C_Object);
|
||||
|
||||
@@ -13,6 +13,8 @@ class RBTreeNode {
|
||||
parent = null;
|
||||
color = null;
|
||||
Info = null;
|
||||
|
||||
name = null;
|
||||
constructor(key, func_info) {
|
||||
this.key = key;
|
||||
this.time = key;
|
||||
@@ -43,7 +45,7 @@ class RedBlackTree {
|
||||
this.root = this.nil;
|
||||
}
|
||||
|
||||
function insert(key, func_info) {
|
||||
function insert(key, func_info, gname = null) {
|
||||
local z = RBTreeNode(key, func_info);
|
||||
local y = this.nil;
|
||||
local x = this.root;
|
||||
@@ -66,6 +68,7 @@ class RedBlackTree {
|
||||
z.left = this.nil;
|
||||
z.right = this.nil;
|
||||
z.color = "red";
|
||||
if (gname) z.name = gname;
|
||||
this.insertFixup(z);
|
||||
this.size++;
|
||||
}
|
||||
@@ -286,4 +289,26 @@ class RedBlackTree {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function findNodeByName(node,name) {
|
||||
if (node == this.nil) {
|
||||
return null;
|
||||
}
|
||||
if (node.name == name) {
|
||||
return node;
|
||||
}
|
||||
local leftResult = findNodeByName(node.left, name);
|
||||
if (leftResult) {
|
||||
return leftResult;
|
||||
}
|
||||
return findNodeByName(node.right, name);
|
||||
}
|
||||
|
||||
// 新增方法:根据 name 移除节点
|
||||
function removeNodeByName(name) {
|
||||
local targetNode = this.findNodeByName(this.root,name);
|
||||
if (targetNode) {
|
||||
this.deleteNode(targetNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,12 +88,24 @@ class Timer {
|
||||
//Cron字符串
|
||||
local NextTimestep = Info[2];
|
||||
//执行函数
|
||||
func.acall(func_args);
|
||||
local Flag = func.acall(func_args);
|
||||
//继续构建下一次任务
|
||||
Date_Exec_Tree.insert(Sq_Cron_Next(NextTimestep, time()), Info);
|
||||
if(Flag == null || Flag == true) Date_Exec_Tree.insert(Sq_Cron_Next(NextTimestep, time()), Info, Node.name);
|
||||
}
|
||||
|
||||
function SetCronTask(target_func, CronString, ...) {
|
||||
function SetCronTask(target_func, build_info, ...) {
|
||||
local CronString = "";
|
||||
local TaskName = null;
|
||||
//如果是字符串直接就是Cron字符串
|
||||
if (typeof build_info == "string") {
|
||||
CronString = build_info;
|
||||
}
|
||||
//如果是Table 则有名字
|
||||
else if (typeof build_info == "table") {
|
||||
CronString = build_info.Cron;
|
||||
TaskName = build_info.Name;
|
||||
}
|
||||
|
||||
local NowTimestep = time();
|
||||
|
||||
//下一次执行的时间
|
||||
@@ -115,7 +127,11 @@ class Timer {
|
||||
//间隔时间戳时间
|
||||
func_info.push(CronString);
|
||||
|
||||
_Timer_Object.Date_Exec_Tree.insert(NextTimestep, func_info);
|
||||
_Timer_Object.Date_Exec_Tree.insert(NextTimestep, func_info, TaskName);
|
||||
}
|
||||
|
||||
function RemoveCronTask(name) {
|
||||
_Timer_Object.Date_Exec_Tree.removeNodeByName(name);
|
||||
}
|
||||
|
||||
function Update() {
|
||||
|
||||
@@ -777,4 +777,71 @@ function User::DropItem(ItemId, Xpos, Ypos) {
|
||||
Sq_WriteByteArr(S_Ptr("0x85A773C"), [0x89, 0x44, 0x24, 0x04, 0x8B, 0x45, 0x08]);
|
||||
NativePointer("0x085A7599").writeShort(300);
|
||||
NativePointer("0x085A759F").writeShort(240);
|
||||
}
|
||||
|
||||
//角色类 发送邮件函数 (标题, 正文, 金币, 道具列表[[3037,100],[3038,100]])
|
||||
function User::ReqDBSendMultiMail(title, text, gold, item_list) {
|
||||
Timer.SetTimeOut(function(SUser,title, text, gold, item_list) {
|
||||
local Cid = SUser.GetCID();
|
||||
// 获取分割后的道具列表
|
||||
local subLists;
|
||||
local maxSlots = 10;
|
||||
local length = item_list.len();
|
||||
if (length <= maxSlots) {
|
||||
subLists = [item_list];
|
||||
} else {
|
||||
subLists = [];
|
||||
for (local i = 0; i< length; i += maxSlots) {
|
||||
local end = i + maxSlots;
|
||||
if (end > length) {
|
||||
end = length;
|
||||
}
|
||||
subLists.append(item_list.slice(i, end));
|
||||
}
|
||||
}
|
||||
if (subLists) {
|
||||
// 为每个子列表发送邮件
|
||||
for (local i = 0; i< subLists.len(); ++i) {
|
||||
local subList = subLists[i];
|
||||
|
||||
// 添加道具附件
|
||||
local vector = Memory.alloc(100);
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x81349D6"), "pointer", ["pointer"], vector.C_Object);
|
||||
Sq_CallFunc(S_Ptr("0x817A342"), "pointer", ["pointer"], vector.C_Object);
|
||||
//将所有要发送的道具写入Vector
|
||||
for (local j = 0; j< subList.len(); ++j) {
|
||||
//道具ID 分配4字节内存
|
||||
local item_id = Memory.alloc(4);
|
||||
//道具数量 分配4字节内存
|
||||
local item_cnt = Memory.alloc(4);
|
||||
//写入道具ID和数量
|
||||
item_id.writeInt(subList[j][0]);
|
||||
item_cnt.writeInt(subList[j][1]);
|
||||
|
||||
local pair = Memory.alloc(100);
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x81B8D41"), "pointer", ["pointer", "pointer", "pointer"], pair.C_Object, item_id.C_Object, item_cnt.C_Object);
|
||||
Sq_CallFunc(S_Ptr("0x80DD606"), "pointer", ["pointer", "pointer"], vector.C_Object, pair.C_Object);
|
||||
}
|
||||
|
||||
// 邮件支持10个道具附件格子
|
||||
local addition_slots = Memory.alloc(1000);
|
||||
|
||||
for (local j = 0; j< 10; ++j) {
|
||||
Sq_CallFunc(S_Ptr("0x80CB854"), "pointer", ["pointer"], addition_slots.add(j * 61).C_Object);
|
||||
}
|
||||
|
||||
Sq_CallFunc(S_Ptr("0x8556A14"), "int", ["pointer", "pointer", "int"], vector.C_Object, addition_slots.C_Object, 10);
|
||||
|
||||
local title_ptr = Memory.allocUtf8String(title); // 邮件标题
|
||||
local text_ptr = Memory.allocUtf8String(text); // 邮件正文
|
||||
|
||||
local text_len = text.len(); // 邮件正文长度
|
||||
|
||||
// 发邮件给角色
|
||||
Sq_CallFunc(S_Ptr("0x8556B68"), "int", ["pointer", "pointer", "int", "int", "int", "pointer", "int", "int", "int", "int"], title_ptr.C_Object, addition_slots.C_Object, subList.len(), gold, Cid, text_ptr.C_Object, text_len, 0, 99, 1);
|
||||
}
|
||||
}
|
||||
}, 1,this,title, text, gold, item_list);
|
||||
}
|
||||
Reference in New Issue
Block a user