This commit is contained in:
lenheart
2024-10-27 15:32:44 +08:00
parent e82c5ceee3
commit 6c71c79563
21 changed files with 846 additions and 253 deletions

View File

@@ -0,0 +1,209 @@
/*
文件名:AdMsg.nut
路径:Dps_A/BaseClass/AdMsg/AdMsg.nut
创建日期:2024-10-23 20:46
文件用途:高级消息类
*/
class AdMsg {
RarityColor = [
[255, 255, 255, 255], // 普通
[104, 213, 237, 255], // 高级
[179, 107, 255, 255], // 稀有
[255, 0, 255, 255], // 神器
[255, 180, 0, 255], // 史诗
[255, 102, 102, 255], // 勇者
[255, 20, 147, 255], // 深粉红色
[255, 215, 0, 255] // 金色
];
SendBinary = null;
SendInfoArr = null;
SendStrArr = null;
//写入分隔
function PutSeparate() {
SendBinary.writen(0xc2, 'c');
SendBinary.writen(0x80, 'c');
}
//写入普通字符串
function WriteStr(Str) {
local Point = Memory.allocUtf8String(Str);
local Blob = Sq_Point2Blob(Point.C_Object, Str.len());
SendBinary.writeblob(Blob);
}
//写入颜色字符串
function WriteColorStr(Str, Color) {
//写入分隔
PutSeparate();
WriteStr(Str);
PutSeparate();
local ColorBlob = blob(104);
for (local i = 0; i< 3; i++) {
ColorBlob.writen(Color[i], 'c');
}
for (local i = 0; i< 101; i++) {
ColorBlob.writen(0xff, 'c');
}
SendInfoArr.push(ColorBlob);
}
//写入表情
function WriteImotIcon(Var) {
//写入分隔
SendBinary.writen(0x1e, 'c');
SendBinary.writen(0x25, 'c');
SendBinary.writen(Var, 'c');
SendBinary.writen(0x1f, 'c');
}
//写入装备
function JumpWrite(Blob, Pos, Value, Type) {
Blob.seek(Pos, 'b');
Blob.writen(Value, Type);
}
function WriteEquipment(Str, Var, Color) {
local ItemObj = Var;
//写入分隔
PutSeparate();
WriteStr(Str);
PutSeparate();
local InfoBlob = blob(104);
for (local i = 0; i< 3; i++) {
InfoBlob.writen(Color[i], 'c');
}
//装备代码
JumpWrite(InfoBlob, 0x4, ItemObj.GetIndex(), 'i');
//品级
JumpWrite(InfoBlob, 0x8, ItemObj.GetAdd_Info(), 'i');
//强化等级
JumpWrite(InfoBlob, 0xc, ItemObj.GetUpgrade(), 'c');
//装备耐久
JumpWrite(InfoBlob, 0xe, ItemObj.GetDurable(), 's');
//是否封装 //TODO
JumpWrite(InfoBlob, 0x10, ItemObj.GetAttachType(), 'c');
//封装次数 //TODO
JumpWrite(InfoBlob, 0x12, ItemObj.GetDurable(), 'c');
//附魔卡片
JumpWrite(InfoBlob, 0x14, ItemObj.GetEnchanting(), 'i');
//红字类型
JumpWrite(InfoBlob, 0x18, ItemObj.GetAmplification(), 'c');
//红字数值
JumpWrite(InfoBlob, 0x1a, 112, 'c');
SendInfoArr.push(InfoBlob);
}
constructor() {
SendStrArr = [];
SendInfoArr = [];
SendBinary = blob(0);
//写入分隔
PutSeparate();
}
//构造信息段结构体
function MakeInfo() {
return {
Str = "",
Flag = 0,
Var = 0,
Color = 0
}
}
Type = 0;
//put 类型
function PutType(gType) {
Type = gType;
}
//put 普通信息
function PutString(Str) {
local Info = MakeInfo();
Info.Str = Str;
SendStrArr.push(Info);
}
//put 颜色信息
function PutColorString(Str, Color) {
local Info = MakeInfo();
Info.Str = Str;
Info.Flag = 1;
Info.Color = Color;
SendStrArr.push(Info);
}
//put 表情
function PutImoticon(Index) {
local Info = MakeInfo();
Info.Flag = 2;
Info.Var = Index;
SendStrArr.push(Info);
}
//put 装备
function PutEquipment(...) {
local Info = MakeInfo();
if (vargv.len() > 1) {
Info.Str = vargv[0];
Info.Var = vargv[1];
Info.Color = vargv[2];
} else {
Info.Var = vargv[0];
Info.Str = PvfItem.GetNameById(vargv[0].GetIndex());
Info.Color = RarityColor[PvfItem.GetPvfItemById(vargv[0].GetIndex()).GetRarity()];
}
Info.Flag = 3;
SendStrArr.push(Info);
}
function Finalize() {
//写入字符串
foreach(Info in SendStrArr) {
//普通字符串
if (Info.Flag == 0) WriteStr(Info.Str);
//写入颜色字符串
else if (Info.Flag == 1) WriteColorStr(Info.Str, Info.Color);
//写入表情
else if (Info.Flag == 2) WriteImotIcon(Info.Var);
//写入装备
else if (Info.Flag == 3) WriteEquipment(Info.Str, Info.Var, Info.Color);
}
}
Pack = null;
function MakePack() {
//文字信息长度
local SendBinaryLen = SendBinary.len();
//申请内存
local SendStrPoint = Memory.alloc(SendBinaryLen);
Sq_WriteBlobToAddress(SendStrPoint.C_Object, SendBinary);
Pack = Packet();
Pack.Put_Header(0, 370);
Pack.Put_Byte(Type);
Pack.Put_Short(0);
Pack.Put_Byte(3);
Pack.Put_Int(SendBinaryLen);
Pack.Put_BinaryEx(SendStrPoint.C_Object, SendBinaryLen);
Pack.Put_Byte(SendInfoArr.len());
for (local i = 0; i< SendInfoArr.len(); i++) {
local Point = Memory.alloc(104);
Sq_WriteBlobToAddress(Point.C_Object, SendInfoArr[i]);
Pack.Put_BinaryEx(Point.C_Object, 104);
}
Pack.Finalize(true);
return Pack;
}
function Delete() {
Pack.Delete();
}
}

View File

@@ -55,4 +55,5 @@ class BlobEx extends blob {
function GetString(count) {
return stream_myreadstring(count);
}
}

View File

@@ -132,6 +132,19 @@ class GameManager extends Base_C_Object {
return 0;
}
}
//修改交易金币上限
function FixGlodTradeDaily(Count) {
local Arr = [0xB8];
local BlobObj = blob(0);
BlobObj.writen(Count, 'i');
for (local i = 0; i< 4; i++) {
Arr.append(BlobObj[i]);
}
Arr.append(0x90);
Sq_WriteByteArr(S_Ptr("0x86464CE"), Arr);
}
}
//热重载
function _Reload_List_Write_(Path) {

View File

@@ -0,0 +1,65 @@
/*
文件名:HttpClass.nut
路径:Dps_A/BaseClass/HttpClass/HttpClass.nut
创建日期:2024-10-16 18:41
文件用途:Http类
*/
class Http {
Host = null;
Service = null;
constructor(host, service = "http") {
Host = host;
Service = service;
}
function Request(Type, Url, Content) {
local Request = Type + " " + Url + " HTTP/1.1\r\nHost: " + Host + "\r\n";
if (Content) {
Request += "Content-Length: " + Content.len() + "\r\n";
Request += "Content-Type: application/x-www-form-urlencoded\r\n";
Request += "\r\n";
Request += Content;
} else {
Request += "Connection: close\r\n\r\n";
}
return Sq_CreateHttp(Host, Service, Request);
}
// 发送请求
function Post(Url, Content = null) {
return Request("POST", Url, Content);
}
function Get(Url, Content = null) {
return Request("GET", Url, Content);
}
}
Timer.SetTimeOut(function() {
// local Dio = Http("192.168.200.189", "45123");
// local Jso = {
// a = 1,
// b = 4.8,
// c = "测试"
// }
// local JsonStr = Json.Encode(Jso);
// local Res = Dio.Post("/", JsonStr);
// print(Res);
// local NowTimesstamp = Sq_GetTimestampString();
// print(NowTimesstamp);
// local Trad = Sq_Conversion("這是繁體語句", 0);
// local Simple = Sq_Conversion("这是简体语句", 1);
// print(Trad);
// print(Simple);
}, 0);
// local Dio = Http("myip.ipip.net", "443");
// local Res = Dio.Get("/", "");
// print(Res);

View File

@@ -26,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 throw("文件打开错误! FileName: " + FileName);
} else throw ("文件打开错误! FileName: " + FileName);
}
//读取一行

View File

@@ -48,6 +48,10 @@ class Item extends Base_C_Object {
Attribute.seek(2);
return Attribute.readn('i');
}
//获取品级
function GetRarity() {
return Sq_CallFunc(S_Ptr("0x80F12D6"), "int", ["pointer"], this.C_Object);
}
//设置编号
function SetIndex(Index) {
Attribute.seek(2);
@@ -120,6 +124,12 @@ class Item extends Base_C_Object {
Attribute.writen(Value, 'i');
}
//获取交易类型
function GetAttachType() {
return Sq_CallFunc(S_Ptr("0x80F12E2"), "int", ["pointer"], this.C_Object);
}
//刷写装备数据
function Flush() {
Sq_WriteBlobToAddress(C_Object, Attribute);
@@ -137,4 +147,9 @@ class Item extends Base_C_Object {
}
}
//是否可打包
function Item::IsPackagble() {
return Sq_CallFunc(S_Ptr("0x828B5B4"), "int", ["pointer"], this.C_Object);
}

View File

@@ -44,6 +44,7 @@ class PvfItem extends Base_C_Object {
return Sq_GetNameByIdFromPvf(GetIndex());
}
//Public
function GetNameById(Id) {
return Sq_GetNameByIdFromPvf(Id);

View File

@@ -277,4 +277,13 @@ class RedBlackTree {
}
return null;
}
function GetPop() {
if (this.size <= 0) return null;
local z = this.minimum();
if (z != this.nil) {
return z;
}
return null;
}
}

View File

@@ -24,26 +24,6 @@ class Script {
InitStringBin(FileRo);
InitLoadString(FileRo);
// local AllFileStartPos = ScriptData.StartPos;
// foreach(FilePath, Info in ScriptData.PvfFileInfo) {
// //Ani太多了 加载的时候解密 其他文件 现在解密
// //构建AniMap
// if (endswith(FilePath, ".ani") && !endswith(FilePath, ".als")) {
// // ScriptData.Ani[FilePath] <- InitPvfAni(FileRo);
// ScriptData.AniPathTable[FilePath] <- {
// Pos = (AllFileStartPos + Info.ROffset),
// Length = Info.Length,
// Cr32 = Info.Cr32
// }
// } else {
// FileRo.seek(AllFileStartPos + Info.ROffset);
// CrcDecode(FileRo, Info.Length, Info.Cr32);
// // 解密完需要重新调整指针位置
// FileRo.seek(AllFileStartPos + Info.ROffset);
// }
// }
ScriptData.IO = FileRo;
ScriptData.Init();
@@ -1043,7 +1023,7 @@ class GlobaData {
i += 5;
}
//grade 套装Id
else if (str == "[grade]" || str == "[part set index]" || str == "[anti evil]") {
else if (str == "[grade]" || str == "[part set index]" || str == "[anti evil]" || str == "[sb dongcai]") {
local RealKey = str.slice(1, str.len() - 1);
EquipmentAtt[RealKey] <- UnpackData(FilePos, i).tointeger() - 9;
i += 5;

View File

@@ -17,9 +17,13 @@ class Timer {
Cb_timer_dispatch_Func.rawset("__System__Timer__Event", Update.bindenv(this));
}
function ClockTime() {
return Sq_GetTimestampString().slice(-10).tointeger();
}
//检测延时任务
function CheckTimeOut() {
local Node = Wait_Exec_Tree.pop();
local Node = Wait_Exec_Tree.GetPop();
if (!Node) {
return;
}
@@ -27,11 +31,13 @@ class Timer {
local Info = Node.Info;
//执行时间
local exec_time = Node.time;
//如果没到执行时间,放回去,等待下次扫描
if (clock() <= exec_time) {
Wait_Exec_Tree.insert(exec_time, Node.Info);
//如果没到执行时间,就不管
if (ClockTime() <= exec_time) {
return;
}
//该执行了从树中删除这个元素
Wait_Exec_Tree.pop();
//函数
local func = Info[0];
//参数
@@ -47,10 +53,9 @@ class Timer {
target_arg_list.push(vargv[i]);
}
//当前时间戳,单位:秒
local time_sec = clock();
local time_sec = ClockTime();
//计算下一次执行的时间
local exec_time_sec = time_sec + (delay_time / 1000.0).tofloat();
local exec_time_sec = time_sec + delay_time;
//设置下一次执行
local func_info = [];
@@ -62,7 +67,7 @@ class Timer {
//检测定时任务
function CheckCronTask() {
local Node = Date_Exec_Tree.pop();
local Node = Date_Exec_Tree.GetPop();
if (!Node) {
return;
}
@@ -72,9 +77,10 @@ class Timer {
local exec_time = Node.time;
//如果没到执行时间,放回去,等待下次扫描
if (time() <= exec_time) {
Date_Exec_Tree.insert(exec_time, Node.Info);
// Date_Exec_Tree.insert(exec_time, Node.Info);
return;
}
Date_Exec_Tree.pop();
//函数
local func = Info[0];
//参数
@@ -88,18 +94,6 @@ class Timer {
}
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 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 NowTimestep = time();
//下一次执行的时间