111
This commit is contained in:
58
Dps_A/BaseClass/BlobExClass/BlobExClass.nut
Normal file
58
Dps_A/BaseClass/BlobExClass/BlobExClass.nut
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
文件名:BlobExClass.nut
|
||||
路径:BaseClass/BaseTool/BlobExClass.nut
|
||||
创建日期:2024-05-07 17:34
|
||||
文件用途:拓展的Blob类
|
||||
*/
|
||||
class BlobEx extends blob {
|
||||
|
||||
constructor(BaseBlob) {
|
||||
base.constructor(BaseBlob.len());
|
||||
writeblob(BaseBlob);
|
||||
}
|
||||
|
||||
function writeblob(B) {
|
||||
base.writeblob(B);
|
||||
seek(0);
|
||||
}
|
||||
|
||||
function GetUShort() {
|
||||
return readn('s');
|
||||
}
|
||||
|
||||
function GetShort() {
|
||||
return readn('w');
|
||||
}
|
||||
|
||||
function charPtrToInt(arr) {
|
||||
local value = ((arr[0]) << 0) |
|
||||
((arr[1]) << 8) |
|
||||
((arr[2]) << 16) |
|
||||
((arr[3]) << 24);
|
||||
return value;
|
||||
}
|
||||
|
||||
// function GetInt() {
|
||||
// local CurTPos = tell();
|
||||
// local Ret = charPtrToInt([this[CurTPos], this[CurTPos + 1], this[CurTPos + 2], this[CurTPos + 3]]);
|
||||
// seek(4, 'c');
|
||||
// return Ret;
|
||||
// }
|
||||
|
||||
function GetInt() {
|
||||
return readn('i');
|
||||
}
|
||||
|
||||
function Get256() {
|
||||
local Buf = readn('c');
|
||||
return (256.0 + Buf.tofloat()) % 256.0;
|
||||
}
|
||||
|
||||
function GetFloat() {
|
||||
return readn('f');
|
||||
}
|
||||
|
||||
function GetString(count) {
|
||||
return stream_myreadstring(count);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,51 @@ class GameManager extends Base_C_Object {
|
||||
print("请注意如果你不处于DP-S开发环境,请关闭此功能,以免对性能造成影响");
|
||||
Sq_AutoReload(Path);
|
||||
}
|
||||
|
||||
//开启时装镶嵌
|
||||
function FixAvatarUseJewel() {
|
||||
//时装镶嵌修复
|
||||
_AvatarUseJewel_Object <- AvatarUseJewel();
|
||||
}
|
||||
|
||||
//修复下线卡城镇
|
||||
function FixSaveTown() {
|
||||
Cb_Set_Charac_Info_Detail_Enter_Func._FixSaveTown_ <- function(arg) {
|
||||
local curArea = NativePointer(arg[3]).add(34).readS8();
|
||||
if (curArea == 12 || curArea == 13) {
|
||||
NativePointer(arg[3]).add(34).writeS8(11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修复绝望金币异常
|
||||
function FixDespairGold() {
|
||||
getroottable()._FixDespairGold_Data_ <- {};
|
||||
Cb_UseAncientDungeonItems_Enter_Func._FixDespairGold_ <- function(arg) {
|
||||
local DgnObj = Dungeon(arg[1]);
|
||||
local DgnIndex = DgnObj.GetId();
|
||||
if ((DgnIndex >= 11008) && (DgnIndex <= 11107)) {
|
||||
getroottable()._FixDespairGold_Data_[arg[1]] <- NativePointer(arg[1]).add(2044).readS8();
|
||||
NativePointer(arg[1]).add(2044).writeS8(0);
|
||||
}
|
||||
}
|
||||
Cb_UseAncientDungeonItems_Leave_Func._FixDespairGold_ <- function(arg) {
|
||||
local DgnObj = Dungeon(arg[1]);
|
||||
local DgnIndex = DgnObj.GetId();
|
||||
if ((DgnIndex >= 11008) && (DgnIndex <= 11107)) {
|
||||
//绝望之塔 不再扣除金币
|
||||
NativePointer(arg[1]).add(2044).writeS8(getroottable()._FixDespairGold_Data_[arg[1]]);
|
||||
getroottable()._FixDespairGold_Data_.rawdelete(arg[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修复绝望之塔通关后可以用门票继续进入
|
||||
function FixDespairDungeon() {
|
||||
Cb_User_GetLastClearTime_Leave_Func._FixDespairDungeon_ <- function(arg) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//热重载
|
||||
function _Reload_List_Write_(Path) {
|
||||
|
||||
@@ -16,6 +16,7 @@ class IO extends Base_C_Object {
|
||||
_Fseek_Address = Module.getExportByName(null, "fseek");
|
||||
_Ftell_Address = Module.getExportByName(null, "ftell");
|
||||
_Rewind_Address = Module.getExportByName(null, "rewind");
|
||||
_Flush_Address = Module.getExportByName(null, "fflush");
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +26,7 @@ class IO extends Base_C_Object {
|
||||
local FileObj = Sq_CallFunc(_Fopen_Address, "pointer", ["pointer", "pointer"], Str_Ptr(FileName), Str_Ptr(Modes));
|
||||
if (FileObj) {
|
||||
base.constructor(FileObj);
|
||||
} else error("文件打开错误! FileName: " + FileName);
|
||||
} else throw("文件打开错误! FileName: " + FileName);
|
||||
}
|
||||
|
||||
//读取一行
|
||||
@@ -68,6 +69,9 @@ class IO extends Base_C_Object {
|
||||
Sq_CallFunc(_Fputs_Address, "int", ["pointer", "pointer"], Buffer.C_Object, this.C_Object);
|
||||
}
|
||||
|
||||
function Flush() {
|
||||
Sq_CallFunc(_Flush_Address, "pointer", ["pointer"], this.C_Object);
|
||||
}
|
||||
|
||||
//关闭文件
|
||||
function Close() {
|
||||
|
||||
@@ -72,4 +72,9 @@ class Inven extends Base_C_Object {
|
||||
SUser.SendUpdateItemList(1, 0, Slot);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
//获取时装管理器
|
||||
function GetAvatarItemMgr() {
|
||||
return Sq_CallFunc(S_Ptr("0x80DD576"), "pointer", ["pointer"], this.C_Object);
|
||||
}
|
||||
}
|
||||
@@ -125,6 +125,11 @@ class Item extends Base_C_Object {
|
||||
Sq_WriteBlobToAddress(C_Object, Attribute);
|
||||
}
|
||||
|
||||
//检查是否为空
|
||||
// function IsEmpty() {
|
||||
// return Sq_CallFunc(S_Ptr("0x811ED66"), "int", ["pointer"], this.C_Object);
|
||||
// }
|
||||
|
||||
//删除道具
|
||||
function Delete() {
|
||||
Sq_Inven_RemoveItem(C_Object);
|
||||
|
||||
90
Dps_A/BaseClass/LogClass/LogClass.nut
Normal file
90
Dps_A/BaseClass/LogClass/LogClass.nut
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
文件名:LogClass.nut
|
||||
路径:Dps_A/BaseClass/LogClass/LogClass.nut
|
||||
创建日期:2024-10-10 11:35
|
||||
文件用途:日志类
|
||||
*/
|
||||
class Log {
|
||||
|
||||
//linux创建文件夹
|
||||
// function api_mkdir(path) {
|
||||
// var path_ptr = Memory.allocUtf8String(path);
|
||||
// if (opendir(path_ptr))
|
||||
// return true;
|
||||
// return mkdir(path_ptr, 0x1FF);
|
||||
// }
|
||||
_opendir_Address = Module.getExportByName(null, "opendir");
|
||||
_mkdir_Address = Module.getExportByName(null, "mkdir");
|
||||
|
||||
|
||||
Logger = null;
|
||||
LoggerBuffer = null;
|
||||
|
||||
Coro = null;
|
||||
|
||||
constructor(Info) {
|
||||
Logger = {};
|
||||
LoggerBuffer = {};
|
||||
|
||||
local DirPath = Str_Ptr("/dp_s/log");
|
||||
if (!(Sq_CallFunc(_opendir_Address, "int", ["pointer"], DirPath))) {
|
||||
Sq_CallFunc(_mkdir_Address, "int", ["pointer", "int"], DirPath, 0x1FF);
|
||||
}
|
||||
|
||||
//打开文件输出句柄
|
||||
foreach(Level, Path in Info) {
|
||||
|
||||
try {
|
||||
local Io = IO(Path, "a");
|
||||
Logger[Level] <- Io;
|
||||
LoggerBuffer[Level] <- [];
|
||||
} catch (exception) {
|
||||
error("日志器初始化失败");
|
||||
}
|
||||
}
|
||||
|
||||
getroottable()._Logger_Object_ <- this;
|
||||
Cb_timer_dispatch_Func.rawset("__System__Logger__Event", Update.bindenv(this));
|
||||
|
||||
Coro = newthread(__Write__.bindenv(this));
|
||||
}
|
||||
|
||||
|
||||
function Put(Type, Message) {
|
||||
if (getroottable().rawin("_Logger_Object_")) {
|
||||
if (getroottable()._Logger_Object_.Logger.rawin(Type)) {
|
||||
getroottable()._Logger_Object_.LoggerBuffer[Type].push(Message);
|
||||
// getroottable()._Logger_Object_.Logger[Type].Write(Message);
|
||||
// getroottable()._Logger_Object_.Logger[Type].Flush();
|
||||
} else {
|
||||
error("未知的日志类型");
|
||||
}
|
||||
} else {
|
||||
error("未初始化日志器");
|
||||
}
|
||||
}
|
||||
|
||||
function __Write__() {
|
||||
local ret = suspend("no");
|
||||
foreach(Type, MessageArr in LoggerBuffer) {
|
||||
for (local i = 0; i< MessageArr.len(); i++) {
|
||||
Logger[Type].Write(MessageArr[i]);
|
||||
Logger[Type].Flush();
|
||||
MessageArr.remove(i);
|
||||
i--;
|
||||
suspend("no");
|
||||
}
|
||||
}
|
||||
return "yes";
|
||||
}
|
||||
|
||||
function Update() {
|
||||
local susparam = "noq";
|
||||
if (Coro.getstatus() == "idle") susparam = Coro.call();
|
||||
else if (Coro.getstatus() == "suspended") susparam = Coro.wakeup();
|
||||
|
||||
if (susparam == "yes") {
|
||||
Coro = newthread(__Write__.bindenv(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,17 @@ class NativePointer extends Base_C_Object {
|
||||
}
|
||||
}
|
||||
|
||||
function Output(Size) {
|
||||
local Buf = Sq_Point2Blob(this.C_Object, Size);
|
||||
local Str = "[";
|
||||
foreach(Value in Buf) {
|
||||
Str = format("%s%02X", Str, Value);
|
||||
Str += ",";
|
||||
}
|
||||
Str += "]";
|
||||
print(Str);
|
||||
}
|
||||
|
||||
function add(intoffset) {
|
||||
this.C_Object = Sq_PointerOperation(this.C_Object, intoffset, "+");
|
||||
return this;
|
||||
|
||||
@@ -65,6 +65,40 @@ class Packet extends Base_C_Object {
|
||||
Sq_Packet_Send(SUser.C_Object, this.C_Object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function GetByte() {
|
||||
local data = Memory.alloc(1);
|
||||
if (Sq_CallFunc(S_Ptr("0x858CF22"), "int", ["pointer", "pointer"], this.C_Object, data.C_Object)) {
|
||||
return data.readS8();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function GetShort() {
|
||||
local data = Memory.alloc(2);
|
||||
if (Sq_CallFunc(S_Ptr("0x858CFC0"), "int", ["pointer", "pointer"], this.C_Object, data.C_Object)) {
|
||||
return data.readS16();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function GetInt() {
|
||||
local data = Memory.alloc(4);
|
||||
if (Sq_CallFunc(S_Ptr("0x858D27E"), "int", ["pointer", "pointer"], this.C_Object, data.C_Object)) {
|
||||
return data.readS32();
|
||||
}
|
||||
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)) {
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function Delete() {
|
||||
Sq_CallFunc(S_Ptr("0x858DE80"), "void", ["pointer"], this.C_Object);
|
||||
Sq_Delete_Point(this.C_Object);
|
||||
|
||||
@@ -70,4 +70,9 @@ function PvfItem::GetUsableLevel() {
|
||||
//是否为消耗品
|
||||
function PvfItem::IsStackable() {
|
||||
return Sq_CallFunc(S_Ptr("0x80f12fa"), "int", ["pointer"], this.C_Object);
|
||||
}
|
||||
|
||||
//获取消耗品类型
|
||||
function PvfItem::GetItemType() {
|
||||
return Sq_CallFunc(S_Ptr("0x8514A84"), "int", ["pointer"], this.C_Object);
|
||||
}
|
||||
1228
Dps_A/BaseClass/ScriptManager/ScriptManager.nut
Normal file
1228
Dps_A/BaseClass/ScriptManager/ScriptManager.nut
Normal file
File diff suppressed because it is too large
Load Diff
@@ -79,31 +79,31 @@ class Timer {
|
||||
local func = Info[0];
|
||||
//参数
|
||||
local func_args = Info[1];
|
||||
//下次任务叠加时间
|
||||
//Cron字符串
|
||||
local NextTimestep = Info[2];
|
||||
//执行函数
|
||||
func.acall(func_args);
|
||||
//继续构建下一次任务
|
||||
Date_Exec_Tree.insert(time() + NextTimestep, Info);
|
||||
Date_Exec_Tree.insert(Sq_Cron_Next(NextTimestep, time()), Info);
|
||||
}
|
||||
|
||||
function SetCronTask(target_func, CronString, ...) {
|
||||
local parts = split(CronString, "/");
|
||||
local minute = parts[0].tointeger();
|
||||
local hour = parts[1].tointeger();
|
||||
local day = parts[2].tointeger();
|
||||
local weekday = parts[3].tointeger();
|
||||
// local parts = split(CronString, "/");
|
||||
// local minute = parts[0].tointeger();
|
||||
// local hour = parts[1].tointeger();
|
||||
// local day = parts[2].tointeger();
|
||||
// local weekday = parts[3].tointeger();
|
||||
|
||||
local S_minute = minute * 60;
|
||||
local S_hour = hour * 60 * 60;
|
||||
local S_day = day * 24 * 60 * 60;
|
||||
local S_weekday = weekday * 7 * 24 * 60 * 60;
|
||||
// local S_minute = minute * 60;
|
||||
// local S_hour = hour * 60 * 60;
|
||||
// local S_day = day * 24 * 60 * 60;
|
||||
// local S_weekday = weekday * 7 * 24 * 60 * 60;
|
||||
|
||||
local AddTimestep = S_minute + S_hour + S_day + S_weekday;
|
||||
// local AddTimestep = S_minute + S_hour + S_day + S_weekday;
|
||||
local NowTimestep = time();
|
||||
|
||||
//下一次执行的时间
|
||||
local NextTimestep = AddTimestep + NowTimestep;
|
||||
local NextTimestep = Sq_Cron_Next(CronString, NowTimestep);
|
||||
|
||||
local target_arg_list = [];
|
||||
target_arg_list.push(getroottable());
|
||||
@@ -119,7 +119,7 @@ class Timer {
|
||||
//参数列表
|
||||
func_info.push(target_arg_list);
|
||||
//间隔时间戳时间
|
||||
func_info.push(AddTimestep);
|
||||
func_info.push(CronString);
|
||||
|
||||
_Timer_Object.Date_Exec_Tree.insert(NextTimestep, func_info);
|
||||
}
|
||||
|
||||
@@ -599,4 +599,9 @@ function User::SendItemMail(UID, CID, ItemList, title, content) {
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
//道具是否被锁
|
||||
function User::CheckItemLock(Type, Slot) {
|
||||
return Sq_CallFunc(S_Ptr("0x8646942"), "int", ["pointer", "int", "int"], this.C_Object, Type, Slot);
|
||||
}
|
||||
Reference in New Issue
Block a user