1111
This commit is contained in:
@@ -4,6 +4,23 @@
|
||||
创建日期:2024-05-01 16:24
|
||||
文件用途:服务端核心类
|
||||
*/
|
||||
function removeBackslashes(str) {
|
||||
local result = "";
|
||||
local index = 0;
|
||||
local backslashIndex = -1;
|
||||
|
||||
while (true) {
|
||||
backslashIndex = str.find("\\", index);
|
||||
if (backslashIndex == null) {
|
||||
result += str.slice(index);
|
||||
break;
|
||||
}
|
||||
result += str.slice(index, backslashIndex);
|
||||
index = backslashIndex + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
class ServerControl {
|
||||
|
||||
function Get_User_Item_Count(SUser, ItemId) {
|
||||
@@ -26,25 +43,8 @@ class ServerControl {
|
||||
};
|
||||
}
|
||||
|
||||
function removeBackslashes(str) {
|
||||
local result = "";
|
||||
local index = 0;
|
||||
local backslashIndex = -1;
|
||||
|
||||
while (true) {
|
||||
backslashIndex = str.find("\\", index);
|
||||
if (backslashIndex == null) {
|
||||
result += str.slice(index);
|
||||
break;
|
||||
}
|
||||
result += str.slice(index, backslashIndex);
|
||||
index = backslashIndex + 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
|
||||
//分发来自网关的包
|
||||
GatewaySocketPackFuncMap.rawset(20240730, function(Jso) {
|
||||
local UserList = [];
|
||||
@@ -53,7 +53,6 @@ class ServerControl {
|
||||
if (SUser) UserList.append(SUser);
|
||||
else UserList.append(null);
|
||||
}
|
||||
|
||||
foreach(_Index, SUser in UserList) {
|
||||
if (SUser) {
|
||||
Jso.uid <- SUser.GetUID();
|
||||
@@ -707,6 +706,21 @@ class ServerControl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//任务完成
|
||||
Cb_fnStatQuestClear_Enter_Func.ServerControl <- function(args) {
|
||||
local SUser = User(args[0])
|
||||
local Jso = {
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
queId = args[1],
|
||||
op = 20069009
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
496
Dps_A/ProjectClass/EquimentUseJewel/EquimentUseJewel.nut
Normal file
496
Dps_A/ProjectClass/EquimentUseJewel/EquimentUseJewel.nut
Normal file
@@ -0,0 +1,496 @@
|
||||
/*
|
||||
文件名:EquimentUseJewel.nut
|
||||
路径:Dps_A/ProjectClass/EquimentUseJewel/EquimentUseJewel.nut
|
||||
创建日期:2024-10-28 21:18
|
||||
文件用途:装备镶嵌
|
||||
*/
|
||||
|
||||
class EquimentUseJewel {
|
||||
|
||||
ExecUser = null;
|
||||
|
||||
//建库建表
|
||||
function CreateMysqlTable() {
|
||||
local CreateSql1 = "create database if not exists l_equ_jewel default charset utf8;"
|
||||
local CreateSql2 = "CREATE TABLE l_equ_jewel.equipment ( equ_id int(11) AUTO_INCREMENT, jewel_data blob NOT NULL,andonglishanbai_flag int(11),date VARCHAR(255), PRIMARY KEY (equ_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8,AUTO_INCREMENT = 150;"
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
SqlObj.Exec_Sql(CreateSql1);
|
||||
SqlObj.Exec_Sql(CreateSql2);
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
}
|
||||
|
||||
function api_get_jewel_socket_data(id) { //获取徽章数据,存在返回徽章数据,不存在返回空字节数据
|
||||
local CheckSql = "SELECT jewel_data FROM l_equ_jewel.equipment where equ_id = " + id + ";";
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(CheckSql, ["binary"]);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
//没结婚要返回false
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return Ret[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
function api_exitjeweldata(id) { //0代表不存在,存在返回1
|
||||
local CheckSql = "SELECT andonglishanbai_flag FROM l_equ_jewel.equipment where equ_id = " + id + ";";
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(CheckSql, ["int"]);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
//没结婚要返回false
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return Ret[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
function save_equiment_socket(socket_data, id) { //0代表不存在,存在返回1
|
||||
local CheckSql = "UPDATE l_equ_jewel.equipment SET jewel_data = 0x" + socket_data + " WHERE equ_id = " + id + ";";
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(CheckSql, ["int"]);
|
||||
printT(Ret);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
//没结婚要返回false
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function CUser_SendCmdErrorPacket(SUser, id, id2) {
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, id);
|
||||
Pack.Put_Byte(0);
|
||||
Pack.Put_Byte(id2);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
|
||||
function api_PacketBuf_get_buf(packet_buf) {
|
||||
return NativePointer(NativePointer(packet_buf).add(20).readPointer()).add(13);
|
||||
}
|
||||
|
||||
function add_equiment_socket(equipment_type) { //0代表开孔失败 成功返回标识
|
||||
/*
|
||||
武器10
|
||||
称号11
|
||||
上衣12
|
||||
头肩13
|
||||
下衣14
|
||||
鞋子15
|
||||
腰带16
|
||||
项链17
|
||||
手镯18
|
||||
戒指19
|
||||
辅助装备20
|
||||
魔法石21
|
||||
*/
|
||||
|
||||
/*
|
||||
红色:'010000000000010000000000000000000000000000000000000000000000' A
|
||||
黄色:'020000000000020000000000000000000000000000000000000000000000' B
|
||||
绿色:'040000000000040000000000000000000000000000000000000000000000' C
|
||||
蓝色:'080000000000080000000000000000000000000000000000000000000000' D
|
||||
白金:'100000000000100000000000000000000000000000000000000000000000'
|
||||
*/
|
||||
local DB_JewelsocketData = "";
|
||||
switch (equipment_type) {
|
||||
case 10: //武器10 SS
|
||||
DB_JewelsocketData = "100000000000000000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 11: //称号11 SS
|
||||
DB_JewelsocketData = "100000000000000000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 12: //上衣12 C
|
||||
DB_JewelsocketData = "040000000000040000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 13: //头肩13 B
|
||||
DB_JewelsocketData = "020000000000020000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 14: //下衣14 C
|
||||
DB_JewelsocketData = "040000000000040000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 15: //鞋子15 D
|
||||
DB_JewelsocketData = "080000000000080000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 16: //腰带16 A
|
||||
DB_JewelsocketData = "010000000000010000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 17: //项链17 B
|
||||
DB_JewelsocketData = "020000000000020000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 18: //手镯18 D
|
||||
DB_JewelsocketData = "080000000000080000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 19: //戒指19 A
|
||||
DB_JewelsocketData = "010000000000010000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 20: //辅助装备20 S
|
||||
DB_JewelsocketData = "100000000000000000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
case 21: //魔法石21 S
|
||||
DB_JewelsocketData = "100000000000000000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
default:
|
||||
DB_JewelsocketData = "000000000000000000000000000000000000000000000000000000000000"
|
||||
break;
|
||||
}
|
||||
local date = time();
|
||||
local Ct = Sq_GetTimestampString();
|
||||
date = date.tostring() + Ct;
|
||||
|
||||
local CheckSql = "INSERT INTO l_equ_jewel.equipment (andonglishanbai_flag,jewel_data,date) VALUES(1,0x" + DB_JewelsocketData + ",\'" + date + "\');";
|
||||
local CheckSql1 = "SELECT equ_id FROM l_equ_jewel.equipment where date = \'" + date + "\';";
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
SqlObj.Select(CheckSql, ["int"]);
|
||||
local Ret = SqlObj.Select(CheckSql1, ["int"]);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return Ret[0][0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function CStackableItem_getJewelTargetSocket(C_Object) {
|
||||
return Sq_CallFunc(S_Ptr("0x0822CA28"), "int", ["pointer"], C_Object);
|
||||
}
|
||||
|
||||
function CUser_SendUpdateItemList_DB(SUser, Slot, DB_JewelSocketData) {
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(0, 14);
|
||||
Pack.Put_Byte(0);
|
||||
Pack.Put_Short(1);
|
||||
local InvenObj = SUser.GetInven();
|
||||
Sq_CallFunc(S_Ptr("0x084FC6BC"), "int", ["pointer", "int", "int", "pointer"], InvenObj.C_Object, 1, Slot, Pack.C_Object);
|
||||
Pack.Put_BinaryEx(DB_JewelSocketData.C_Object, 30);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
|
||||
function GetByte(value) {
|
||||
local Blob = blob();
|
||||
Blob.writen(value, 'w');
|
||||
print(Blob.len());
|
||||
return Blob;
|
||||
}
|
||||
|
||||
function intToHex(num) {
|
||||
if (num == 0) {
|
||||
return "0";
|
||||
}
|
||||
local hexDigits = "0123456789abcdef";
|
||||
local hexString = "";
|
||||
while (num > 0) {
|
||||
local remainder = num % 16;
|
||||
hexString = hexDigits[remainder] + hexString;
|
||||
num = (num / 16).tointeger();
|
||||
}
|
||||
return hexString;
|
||||
}
|
||||
|
||||
function lengthCutting(str, ystr, num, maxLength) {
|
||||
// 如果字符串长度小于最大长度,在前面补0
|
||||
local lengthDiff = maxLength - str.len();
|
||||
if (lengthDiff > 0) {
|
||||
local zeroPadding = "";
|
||||
for (local i = 0; i< lengthDiff; i++) {
|
||||
zeroPadding += "0";
|
||||
}
|
||||
str = zeroPadding + str;
|
||||
}
|
||||
local strArr = "";
|
||||
for (local i = 0; i< str.len(); i += num) {
|
||||
local endIndex = i + num;
|
||||
if (endIndex > str.len()) {
|
||||
endIndex = str.len();
|
||||
}
|
||||
strArr += str.slice(i, endIndex);
|
||||
}
|
||||
return ystr + strArr;
|
||||
}
|
||||
|
||||
|
||||
HackReturnAddSocketToAvatarFalg = null;
|
||||
|
||||
function HackReturnAddSocketToAvatar(Code) {
|
||||
//通过hook get short直接返回0达到错误返回的效果
|
||||
//标记flag
|
||||
HackReturnAddSocketToAvatarFalg = Code;
|
||||
Haker.LoadHook("0x0858D0B0", ["pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
},
|
||||
function(args) {
|
||||
Haker.UnLoadHook("0x0858D0B0");
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function FixFunction() {
|
||||
//称号回包
|
||||
Haker.LoadHook("0x08641A6A", ["pointer", "pointer", "int", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(args[3]).add(25).readU32());
|
||||
local ret = args.pop();
|
||||
if (JewelSocketData && NativePointer(JewelSocketData).add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[1]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
|
||||
//设计图继承
|
||||
Haker.LoadHook("0x08671EB2", ["pointer", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
local jewelSocketID = NativePointer(args[2]).add(25).readU32();
|
||||
NativePointer(args[1]).add(25).writeU32(jewelSocketID);
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
|
||||
//装备开孔
|
||||
Haker.LoadHook("0x0821A412", ["pointer", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local equ_slot = Pack.GetShort();
|
||||
local equitem_id = Pack.GetInt();
|
||||
local sta_slot = Pack.GetShort();
|
||||
local CurCharacInvenW = SUser.GetInven();
|
||||
local inven_item = CurCharacInvenW.GetSlot(1, equ_slot);
|
||||
|
||||
if (equ_slot > 56) { //修改后:大于56则是时装装备 原:如果不是装备文件就调用原逻辑
|
||||
equ_slot = equ_slot - 57;
|
||||
local C_PacketBuf = api_PacketBuf_get_buf(args[2]) //获取原始封包数据
|
||||
C_PacketBuf.add(0).writeShort(equ_slot) //修改掉装备位置信息 时装类镶嵌从57开始。
|
||||
//执行原逻辑
|
||||
return null;
|
||||
}
|
||||
//如果已开启镶嵌槽则不执行
|
||||
local equ_id = NativePointer(inven_item.C_Object).add(25).readU32();
|
||||
if (api_exitjeweldata(equ_id)) {
|
||||
HackReturnAddSocketToAvatar(0x13);
|
||||
return null;
|
||||
}
|
||||
|
||||
local item = PvfItem.GetPvfItemById(equitem_id);
|
||||
local ItemType = Sq_CallFunc(S_Ptr("0x08514D26"), "int", ["pointer"], item.C_Object);
|
||||
|
||||
if (ItemType == 10) {
|
||||
SUser.SendNotiBox("装备为武器类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
} else if (ItemType == 11) {
|
||||
SUser.SendNotiBox("装备为称号类型,不支持打孔!", 1)
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
local id = add_equiment_socket(ItemType);
|
||||
Sq_Inven_RemoveItemFormCount(CurCharacInvenW.C_Object, 1, sta_slot, 1, 8, 1); //删除打孔道具
|
||||
NativePointer(inven_item.C_Object).add(25).writeU32(id) //写入槽位标识
|
||||
SUser.SendUpdateItemList(1, 0, equ_slot);
|
||||
|
||||
local JewelSocketData = api_get_jewel_socket_data(id);
|
||||
CUser_SendUpdateItemList_DB(SUser, equ_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 209);
|
||||
Pack.Put_Byte(1);
|
||||
Pack.Put_Short(equ_slot + 104);
|
||||
Pack.Put_Short(sta_slot);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
HackReturnAddSocketToAvatar(0x0);
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
//跳的错误返回0 正常调用的话不处理返回值
|
||||
if (HackReturnAddSocketToAvatarFalg != null) {
|
||||
local SUser = User(args[1]);
|
||||
// SUser.SendItemSpace(0);
|
||||
CUser_SendCmdErrorPacket(SUser, 209, HackReturnAddSocketToAvatarFalg);
|
||||
HackReturnAddSocketToAvatarFalg = null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
|
||||
//装备镶嵌和时装镶嵌
|
||||
Haker.LoadHook("0x8217BD6", ["int", "pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
local SUser = User(args[1]);
|
||||
local Pack = Packet(args[2]);
|
||||
local State = SUser.GetState();
|
||||
if (State != 3) return null;
|
||||
|
||||
local avartar_inven_slot = Pack.GetShort();
|
||||
local avartar_item_id = Pack.GetInt();
|
||||
local emblem_cnt = Pack.GetByte();
|
||||
|
||||
//下面是参照原时装镶嵌的思路写的。个别点标记出来。
|
||||
if (avartar_inven_slot > 104) {
|
||||
local equipment_inven_slot = avartar_inven_slot - 104; //取出真实装备所在背包位置值
|
||||
local Inven = SUser.GetInven();
|
||||
local equipment = Inven.GetSlot(1, equipment_inven_slot);
|
||||
//校验是否合法
|
||||
if (!equipment || equipment.IsEmpty || (equipment.GetIndex() != avartar_item_id) || SUser.CheckItemLock(1, equipment_inven_slot)) return;
|
||||
|
||||
local id = NativePointer(equipment.C_Object).add(25).readU32();
|
||||
local JewelSocketData = api_get_jewel_socket_data(id);
|
||||
if (!JewelSocketData) return;
|
||||
|
||||
local emblems = {};
|
||||
if (emblem_cnt <= 3) {
|
||||
for (local i = 0; i< emblem_cnt; i++) {
|
||||
local emblem_inven_slot = Pack.GetShort();
|
||||
local emblem_item_id = Pack.GetInt();
|
||||
local equipment_socket_slot = Pack.GetByte();
|
||||
local emblem = Inven.GetSlot(1, emblem_inven_slot);
|
||||
//校验徽章及插槽数据是否合法
|
||||
if (!emblem || emblem.IsEmpty || (emblem.GetIndex() != emblem_item_id) || (equipment_socket_slot >= 3)) return;
|
||||
|
||||
//校验徽章是否满足时装插槽颜色要求
|
||||
//获取徽章pvf数据
|
||||
local citem = PvfItem.GetPvfItemById(emblem_item_id);
|
||||
if (!citem) return;
|
||||
|
||||
//校验徽章类型
|
||||
if (!citem.IsStackable() || citem.GetItemType() != 20) return;
|
||||
|
||||
//获取徽章支持的插槽
|
||||
local emblem_socket_type = CStackableItem_getJewelTargetSocket(citem.C_Object);
|
||||
//获取要镶嵌的时装插槽类型
|
||||
local avartar_socket_type = JewelSocketData.add(equipment_socket_slot * 6).readShort();
|
||||
|
||||
if (!(emblem_socket_type & avartar_socket_type)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
emblems[equipment_socket_slot] <- [emblem_inven_slot, emblem_item_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach(equipment_socket_slot, emblemObject in emblems) {
|
||||
//删除徽章
|
||||
local emblem_inven_slot = emblemObject[0];
|
||||
Sq_Inven_RemoveItemFormCount(Inven.C_Object, 1, emblem_inven_slot, 1, 8, 1); //删除打孔道具
|
||||
//设置时装插槽数据
|
||||
local emblem_item_id = emblemObject[1];
|
||||
JewelSocketData.add(2 + 6 * equipment_socket_slot).writeU32(emblem_item_id);
|
||||
}
|
||||
|
||||
local Buf = Sq_Point2Blob(JewelSocketData.C_Object, 30);
|
||||
local Str = "";
|
||||
foreach(Value in Buf) {
|
||||
Str += format("%02X", Value);
|
||||
}
|
||||
|
||||
save_equiment_socket(Str, id);
|
||||
// if (!save_equiment_socket(DB_JewelSocketData, id)) {
|
||||
// print("写入失败了");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
CUser_SendUpdateItemList_DB(SUser, equipment_inven_slot, JewelSocketData); //用于更新镶嵌后的装备显示,这里用的是带镶嵌数据的更新背包函数,并非CUser_SendUpdateItemList
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 209);
|
||||
Pack.Put_Byte(1);
|
||||
Pack.Put_Short(equipment_inven_slot + 104);
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
return 0;
|
||||
}.bindenv(this));
|
||||
|
||||
//额外数据包,发送装备镶嵌数据给本地处理
|
||||
Haker.LoadHook("0x0815098e", ["pointer", "pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local ret = args.pop();
|
||||
local Inven_Item = NativePointer(args[1]);
|
||||
if (Inven_Item.add(1).readU8() == 1) {
|
||||
local ItemObj = Item(args[1]);
|
||||
local JewelSocketData = api_get_jewel_socket_data(NativePointer(ItemObj.C_Object).add(25).readU32());
|
||||
if (JewelSocketData && JewelSocketData.add(0).readU8() != 0) {
|
||||
local Pack = Packet(args[0]);
|
||||
Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
|
||||
//装备全字节复制
|
||||
Haker.LoadHook("0x0814A62E", ["pointer", "pointer", "pointer"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local Old = NativePointer(args[1]);
|
||||
local New = NativePointer(args[0]);
|
||||
Memory.copy(New, Old, 61);
|
||||
return args[0];
|
||||
}.bindenv(this));
|
||||
|
||||
//装备全字节删除
|
||||
Haker.LoadHook("0x080CB7D8", ["pointer", "int"],
|
||||
function(args) {
|
||||
return null;
|
||||
}.bindenv(this),
|
||||
|
||||
function(args) {
|
||||
local New = NativePointer(args[0]);
|
||||
Memory.reset(New, 61);
|
||||
return null;
|
||||
}.bindenv(this));
|
||||
}
|
||||
|
||||
constructor() {
|
||||
CreateMysqlTable();
|
||||
|
||||
FixFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getroottable().RRR <- EquimentUseJewel();
|
||||
232
Dps_A/ProjectClass/Luke/LukeClass.nut
Normal file
232
Dps_A/ProjectClass/Luke/LukeClass.nut
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
文件名:LukeClass.nut
|
||||
路径:Dps_A/ProjectClass/Luke/LukeClass.nut
|
||||
创建日期:2024-07-15 20:46
|
||||
文件用途:卢克服务的文件
|
||||
*/
|
||||
class Luke {
|
||||
//频道
|
||||
Channel = 19;
|
||||
//城镇
|
||||
Town = 18;
|
||||
|
||||
//服务端区域移动添加玩家HOOK 让大家不可见
|
||||
function insert_user_hook(C_Area, C_User) {
|
||||
//如果有城镇配置
|
||||
if (Town) {
|
||||
local SUser = User(C_User);
|
||||
if (SUser.GetLocation().Town == Town) {
|
||||
if (SUser.GetLocation().Area > 1) Sq_WriteAddress(C_Area, 0x68, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//服务端区域移动HOOK 让玩家不可以直接去另一个区域
|
||||
function move_area_hook(CUser, TownIndex, AreaIndex) {
|
||||
// return true;//TODO
|
||||
if (!CUser) return true;
|
||||
local SUser = User(CUser);
|
||||
//卢克频道
|
||||
if (Sq_Game_GetConfig().find("19") != null) {
|
||||
if (AreaIndex <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20084023,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
regionId = AreaIndex
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//玩家发送消息HOOK 为了攻坚队频道和团长公告
|
||||
function base_input_hook(CUser, CmdString) {
|
||||
if (!CUser) return true;
|
||||
local SUser = User(CUser);
|
||||
//卢克频道
|
||||
if (Sq_Game_GetConfig().find("19") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20084027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = CmdString
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
function PlayerNotiMsgDistribute(Jso) {
|
||||
local SUser = World.GetUserByUidCid(Jso.uid, Jso.cid);
|
||||
if (!SUser) return;
|
||||
local CUserList = Jso.list;
|
||||
local RealList = [];
|
||||
foreach(_i, obj in CUserList) {
|
||||
local SUser = World.GetUserByUidCid(obj.uid, obj.cid);
|
||||
if (SUser && SUser.GetState() >= 3) RealList.append(SUser);
|
||||
}
|
||||
local SUserName = SUser.GetCharacName();
|
||||
local Type = Jso.type;
|
||||
|
||||
Jso.msg = Jso.msg.slice(0, Jso.msg.len() - 11);
|
||||
if (Type == -1) {
|
||||
Jso.Name <- SUserName;
|
||||
foreach(_Index, Value in RealList) {
|
||||
local SendObj = Value;
|
||||
SendObj.SendJso(Jso);
|
||||
}
|
||||
Type = "长"
|
||||
}
|
||||
local NotiStr = "(攻坚队" + Type + ") " + "" + SUserName + " : " + Jso.msg;
|
||||
foreach(_Index, Value in RealList) {
|
||||
local SendObj = Value;
|
||||
SendObj.SendNotiPacketMessage(NotiStr, 8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function LukeSendAreaUserCallBack(Jso) {
|
||||
local CUserList = Jso.list;
|
||||
local RealList = [];
|
||||
foreach(_i, obj in CUserList) {
|
||||
local SUser = World.GetUserByUidCid(obj.uid, obj.cid);
|
||||
if (SUser && SUser.GetState() >= 3) RealList.append(SUser);
|
||||
}
|
||||
|
||||
foreach(_Index, Value in RealList) {
|
||||
local SUser = Value;
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(0, 24);
|
||||
Pack.Put_Byte(SUser.GetLocation().Town); //城镇
|
||||
Pack.Put_Byte(SUser.GetArea(1)); //区域
|
||||
Pack.Put_Short((RealList.len() - 1)); //几个玩家 要减去自己
|
||||
foreach(__Index, MapObj in RealList) {
|
||||
if (SUser.GetUID() == MapObj.GetUID()) continue;
|
||||
Pack.Put_Short(MapObj.GetUniqueId());
|
||||
Pack.Put_Short(MapObj.GetAreaPos().X);
|
||||
Pack.Put_Short(MapObj.GetAreaPos().Y);
|
||||
Pack.Put_Byte(MapObj.GetDirections()); //朝向
|
||||
Pack.Put_Byte(MapObj.GetVisibleValues()); //是否可见
|
||||
}
|
||||
Pack.Put_Byte(1); //是否可见
|
||||
Pack.Finalize(true);
|
||||
SUser.Send(Pack);
|
||||
Pack.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
function LukePlayerMoveMapCallBack(Jso) {
|
||||
local MoveSUser = World.GetUserByUidCid(Jso.uid, Jso.cid);
|
||||
if (!MoveSUser) return;
|
||||
|
||||
local CUserList = Jso.list;
|
||||
local RealList = [];
|
||||
foreach(_i, obj in CUserList) {
|
||||
local SUser = World.GetUserByUidCid(obj.uid, obj.cid);
|
||||
if (SUser && SUser.GetState() >= 3) RealList.append(SUser);
|
||||
}
|
||||
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(0, 22);
|
||||
Pack.Put_Short(MoveSUser.GetUniqueId());
|
||||
Pack.Put_Short(Jso.XPos);
|
||||
Pack.Put_Short(Jso.YPos);
|
||||
Pack.Put_Byte(Jso.Direction);
|
||||
Pack.Put_Short(Jso.Code);
|
||||
Pack.Finalize(true);
|
||||
|
||||
foreach(_Index, Value in RealList) {
|
||||
local SUser = Value;
|
||||
if (SUser.GetUniqueId() == MoveSUser.GetUniqueId()) continue;
|
||||
SUser.Send(Pack);
|
||||
}
|
||||
Pack.Delete();
|
||||
}
|
||||
|
||||
function ClientGetConfigCallBack(SUser, Jso) {
|
||||
local evv = {
|
||||
op = 20084502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
}
|
||||
|
||||
function ClientCreateOrJoinParty(SUser, Jso) {
|
||||
Jso.uid <- SUser.GetUID();
|
||||
Jso.cid <- SUser.GetCID();
|
||||
Jso.PlayerName <- SUser.GetCharacName();
|
||||
Jso.PlayerLevel <- SUser.GetCharacLevel();
|
||||
Jso.PlayerJob <- SUser.GetCharacJob();
|
||||
Jso.PlayerGrowTypeJob <- SUser.GetCharacGrowType();
|
||||
Jso.IsPrepare <- false;
|
||||
Jso.PlayerSession <- World.GetSessionByUid(SUser.GetUID());
|
||||
Jso.PlayCoin <- SUser.GetCoin();
|
||||
Jso.PlayFatigue <- SUser.GetMaxFatigue() - SUser.GetFatigue();
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
|
||||
//玩家上线
|
||||
function Login_Hook(SUser) {
|
||||
//玩家上线发信息包
|
||||
local evv = {
|
||||
op = 20084502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
|
||||
local T = {
|
||||
op = 20084063,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
}
|
||||
Socket.SendGateway(T);
|
||||
}
|
||||
|
||||
//团本配置信息获取回调
|
||||
function GetPluginConfig(Jso) {
|
||||
Town = Jso.Town;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
local ConfigPath = Sq_Game_GetConfig();
|
||||
Channel = ConfigPath.slice(ConfigPath.find("cfg/") + 4, ConfigPath.len());
|
||||
|
||||
//注册HOOK
|
||||
Cb_Insert_User_Func.Luke <- insert_user_hook.bindenv(this); //区域添加角色
|
||||
Cb_Move_Area_Func.Luke <- move_area_hook.bindenv(this); //区域移动
|
||||
Base_InputHookFunc_Handle.Luke <- base_input_hook.bindenv(this); //玩家发送消息
|
||||
Cb_reach_game_world_Func.Luke <- Login_Hook.bindenv(this); //上线HOOK
|
||||
|
||||
//注册收包
|
||||
GatewaySocketPackFuncMap.rawset(20084010, LukeSendAreaUserCallBack.bindenv(this)); //玩家移动后的区域广播包
|
||||
GatewaySocketPackFuncMap.rawset(20084012, LukePlayerMoveMapCallBack.bindenv(this)); //玩家移动回调
|
||||
//玩家消息分发
|
||||
GatewaySocketPackFuncMap.rawset(20084018, PlayerNotiMsgDistribute.bindenv(this)); //玩家打字发送的信息
|
||||
GatewaySocketPackFuncMap.rawset(20084778, GetPluginConfig.bindenv(this)); //服务端配置
|
||||
|
||||
//注册来自客户端的收包
|
||||
ClientSocketPackFuncMap.rawset(20230718, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20084501, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20084001, ClientCreateOrJoinParty.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20084005, ClientCreateOrJoinParty.bindenv(this));
|
||||
}
|
||||
}
|
||||
|
||||
ProjectInitFuncMap.P_Luke <- Luke();
|
||||
@@ -243,6 +243,9 @@ class Marry {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//根据cid查询婚礼开始时间
|
||||
GetAuditoriumTimeById = function(cid) {
|
||||
local Sql = format(MARRY_SQL_LIST.GetAuditoriumTimeById, cid);
|
||||
@@ -276,6 +279,34 @@ class Marry {
|
||||
return Ret[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//根据cid查询自己的经验值
|
||||
GetExpById = function(cid) {
|
||||
local Sql = format(MARRY_SQL_LIST.GetExpById, cid);
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(Sql, ["int"]);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Ret[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
//设置自己的经验值和等级
|
||||
SetExpAndLvById = function(Cid, lv, exp) {
|
||||
local Sql = format(MARRY_SQL_LIST.SetExpAndLvById, lv, exp, Cid, Cid);
|
||||
//从池子拿连接
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
SqlObj.Exec_Sql(Sql);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -290,11 +321,13 @@ class Marry {
|
||||
local job = SUser.GetCharacJob();
|
||||
|
||||
//遍历身上的每一件装备
|
||||
for (local u = 0; u <= 11; u++) {
|
||||
for (local u = 0; u <= 2; u++) {
|
||||
local EquObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_BODY, u);
|
||||
if (EquObj && !EquObj.IsEmpty) {
|
||||
//先拿克隆id 如果这个值有 那说明带的克隆 直接用这个
|
||||
//先拿克隆id 如果这个值有 那说明带的克隆这个是被克隆的装备 直接用这个 但是如果这个人什么都没带 只带了克隆 会显示克隆的id 所以还得判断这个id是不是克隆时装
|
||||
local clearId = Sq_CallFunc(S_Ptr("0x850d374"), "int", ["pointer", "int"], InvenObj.C_Object, u)
|
||||
|
||||
|
||||
local EquObjId = EquObj.GetIndex();
|
||||
//如果这个是克隆
|
||||
if (clearId > 0) {
|
||||
@@ -521,7 +554,7 @@ class Marry {
|
||||
|
||||
SUser.SendJso(T);
|
||||
SUser.SendNotiBox(format("婚礼将在%d分钟后举行!\n点击大司祭可进入礼堂。", (Time + 1) * 10), 1);
|
||||
print(time());
|
||||
|
||||
Timer.SetTimeOut(OpenAuditorium.bindenv(this), (Time + 1) * 10 * 1000, SUser.GetCID());
|
||||
}
|
||||
}
|
||||
@@ -588,7 +621,7 @@ class Marry {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printT(info);
|
||||
|
||||
|
||||
|
||||
@@ -864,26 +897,24 @@ class Marry {
|
||||
}
|
||||
|
||||
|
||||
// Cb_Use_Item_Sp_Func[Config["结婚等级1道具ID"]] <- function(SUser, ItemId) {
|
||||
// ExpUp(SUser, Config["道具1给的心意点"]);
|
||||
// }
|
||||
// Cb_Use_Item_Sp_Func[Config["结婚等级2道具ID"]] <- function(SUser, ItemId) {
|
||||
// ExpUp(SUser, Config["道具2给的心意点"]);
|
||||
// }
|
||||
// Cb_Use_Item_Sp_Func[Config["结婚等级3道具ID"]] <- function(SUser, ItemId) {
|
||||
// ExpUp(SUser, Config["道具3给的心意点"]);
|
||||
// }
|
||||
|
||||
|
||||
Timer.SetTimeOut(function() {
|
||||
ProjectInitFuncMap.P_Marry <- Marry();
|
||||
}, 0)
|
||||
|
||||
|
||||
|
||||
Gm_InputFunc_Handle.ss <- function(SUser, CmdString) {
|
||||
|
||||
local aa = Marry.GetAva(SUser);
|
||||
printT(aa);
|
||||
|
||||
|
||||
|
||||
}.bindenv(this);
|
||||
|
||||
print("-----------------------")
|
||||
print(time());
|
||||
|
||||
Timer.SetTimeOut(function() {
|
||||
print(time());
|
||||
}, 5000);
|
||||
// function ExpUp(SUser, expUp) {
|
||||
// exp = Mysql_Operate_Func.GetExpById(SUser.GetCID())
|
||||
// exp = exp + expUp;
|
||||
// for (local i = 6; i >= 0; i--) {
|
||||
// //如果当前的经验值大于所遍历到的等级 就设定等级为这个 然后不继续向更低等级遍历
|
||||
// if (Config["戒指等级"][i.tostring()]["所需经验"]< exp) {
|
||||
// Mysql_Operate_Func.SetExpAndLvById(SUser.GetCID(), i, exp)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -38,7 +38,12 @@ MARRY_SQL_LIST.GetAuditoriumIndexById <- @"SELECT target_cid FROM zyk.marry_room
|
||||
//根据cid查询自己的礼堂编号
|
||||
MARRY_SQL_LIST.GetAuditoriumTimeById <- @"SELECT rindex FROM zyk.marry_room WHERE cid = %d";
|
||||
|
||||
MARRY_SQL_LIST.GetAuditoriumName2ById <- @"SELECT name, FROM zyk.marry_room WHERE cid = %d or target_cid = %d";
|
||||
MARRY_SQL_LIST.GetAuditoriumName2ById <- @"SELECT name FROM zyk.marry_room WHERE cid = %d or target_cid = %d";
|
||||
|
||||
MARRY_SQL_LIST.RomoveRoom <- @"DELETE FROM marry_room where rindex < UNIX_TIMESTAMP();";
|
||||
|
||||
//获取自己的经验值
|
||||
MARRY_SQL_LIST.GetExpById <- @"SELECT experience FROM zyk.marry WHERE cid = %d";
|
||||
|
||||
//设置自己的经验值和等级
|
||||
MARRY_SQL_LIST.SetExpAndLvById <- @"UPDATE zyk.marry SET level = %d , experience = %d WHERE cid = %d or target_cid = %d";
|
||||
Reference in New Issue
Block a user