保存标准
This commit is contained in:
258
_DPS_/_BuiltProject/Anton/AntonClass.nut
Normal file
258
_DPS_/_BuiltProject/Anton/AntonClass.nut
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
文件名:AntonClass.nut
|
||||
路径:Dps_A/ProjectClass/Anton/AntonClass.nut
|
||||
创建日期:2024-07-15 20:46
|
||||
文件用途:安图恩服务的文件
|
||||
*/
|
||||
class Anton {
|
||||
//频道
|
||||
Channel = 18;
|
||||
//城镇
|
||||
Town = 188;
|
||||
|
||||
//服务端区域移动添加玩家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("18") != null) {
|
||||
if (AreaIndex <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064023,
|
||||
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("18") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = CmdString
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function base_input_hook2(args) {
|
||||
local type = args[2];
|
||||
local SUser = User(args[1]);
|
||||
local msg = args[3];
|
||||
if ((type == 8 || type == 3) && Sq_Game_GetConfig().find("18") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = msg
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
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;
|
||||
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 AntonSendAreaUserCallBack(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 AntonPlayerMoveMapCallBack(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 = 20064502,
|
||||
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 = 20064502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
|
||||
local T = {
|
||||
op = 20064063,
|
||||
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.Anton <- insert_user_hook.bindenv(this); //区域添加角色
|
||||
Cb_Move_Area_Func.Anton <- move_area_hook.bindenv(this); //区域移动
|
||||
//Base_InputHookFunc_Handle.Anton <- base_input_hook.bindenv(this); //玩家发送消息
|
||||
Cb_reach_game_world_Func.Anton <- Login_Hook.bindenv(this); //上线HOOK
|
||||
Cb_Server_Chat_Log_Leave_Func.Anton <- base_input_hook2.bindenv(this); //玩家发送消息
|
||||
|
||||
|
||||
//注册收包
|
||||
GatewaySocketPackFuncMap.rawset(20064010, AntonSendAreaUserCallBack.bindenv(this)); //玩家移动后的区域广播包
|
||||
GatewaySocketPackFuncMap.rawset(20064012, AntonPlayerMoveMapCallBack.bindenv(this)); //玩家移动回调
|
||||
//玩家消息分发
|
||||
GatewaySocketPackFuncMap.rawset(20064018, PlayerNotiMsgDistribute.bindenv(this)); //玩家打字发送的信息
|
||||
GatewaySocketPackFuncMap.rawset(20064778, GetPluginConfig.bindenv(this)); //服务端配置
|
||||
|
||||
//注册来自客户端的收包
|
||||
ClientSocketPackFuncMap.rawset(20230718, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064501, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064001, ClientCreateOrJoinParty.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064005, ClientCreateOrJoinParty.bindenv(this));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ProjectInitFuncMap.P_Anton <- Anton();
|
||||
1
_DPS_/_BuiltProject/Anton/config
Normal file
1
_DPS_/_BuiltProject/Anton/config
Normal file
@@ -0,0 +1 @@
|
||||
AntonClass.nut
|
||||
267
_DPS_/_BuiltProject/Fiendwar/FiendwarClass.nut
Normal file
267
_DPS_/_BuiltProject/Fiendwar/FiendwarClass.nut
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
文件名:FiendwarClass.nut
|
||||
路径:ProjectClass/Fiendwar/FiendwarClass.nut
|
||||
创建日期:2024-04-08 03:00
|
||||
文件用途:超时空服务器文件
|
||||
*/
|
||||
class Fiendwar {
|
||||
//频道
|
||||
Channel = null;
|
||||
//城镇
|
||||
Town = null;
|
||||
|
||||
//服务端区域移动添加玩家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("20") != null) {
|
||||
if (AreaIndex <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20063023,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
regionId = AreaIndex
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//玩家发送消息HOOK 为了攻坚队频道和团长公告
|
||||
function base_input_hook(CUser, CmdString) {
|
||||
print(111);
|
||||
if (!CUser) return true;
|
||||
local SUser = User(CUser);
|
||||
//超时空频道
|
||||
if (Sq_Game_GetConfig().find("20") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
print(111);
|
||||
if (CmdString.find("RindroType") == 8) {
|
||||
local Jso = {
|
||||
op = 20063027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = CmdString.slice(0, CmdString.find("RindroType"))
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function base_input_hook2(args) {
|
||||
print(1111);
|
||||
local type = args[2];
|
||||
local SUser = User(args[1]);
|
||||
local msg = args[3];
|
||||
if ((type == 8 || type == 3) && Sq_Game_GetConfig().find("20") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20063027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = msg
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
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;
|
||||
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 FiendwarSendAreaUserCallBack(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 FiendwarPlayerMoveMapCallBack(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 = 20063502,
|
||||
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 = 20063502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
|
||||
local T = {
|
||||
op = 20063063,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
}
|
||||
Socket.SendGateway(T);
|
||||
}
|
||||
|
||||
//团本配置信息获取回调
|
||||
function GetPluginConfig(Jso) {
|
||||
Town = Jso.Town;
|
||||
|
||||
if ("hookparty" in Jso) {
|
||||
Cb_User_Party_Create_Func["Fiendwar"] <- function(SUser) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
local ConfigPath = Sq_Game_GetConfig();
|
||||
Channel = ConfigPath.slice(ConfigPath.find("cfg/") + 4, ConfigPath.len());
|
||||
|
||||
//注册HOOK
|
||||
Cb_Insert_User_Func.Fiendwar <- insert_user_hook.bindenv(this); //区域添加角色
|
||||
Cb_Move_Area_Func.Fiendwar <- move_area_hook.bindenv(this); //区域移动
|
||||
Base_InputHookFunc_Handle.Fiendwar <- base_input_hook.bindenv(this); //玩家发送消息
|
||||
Cb_reach_game_world_Func.Fiendwar <- Login_Hook.bindenv(this); //上线HOOK
|
||||
Cb_Server_Chat_Log_Leave_Func.Luke <- base_input_hook2.bindenv(this); //玩家发送消息
|
||||
|
||||
//注册收包
|
||||
GatewaySocketPackFuncMap.rawset(20063010, FiendwarSendAreaUserCallBack.bindenv(this)); //玩家移动后的区域广播包
|
||||
GatewaySocketPackFuncMap.rawset(20063012, FiendwarPlayerMoveMapCallBack.bindenv(this)); //玩家移动回调
|
||||
//玩家消息分发
|
||||
GatewaySocketPackFuncMap.rawset(20063018, PlayerNotiMsgDistribute.bindenv(this)); //玩家打字发送的信息
|
||||
GatewaySocketPackFuncMap.rawset(20063778, GetPluginConfig.bindenv(this)); //服务端配置
|
||||
|
||||
//注册来自客户端的收包
|
||||
ClientSocketPackFuncMap.rawset(20230718, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20063501, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20063001, ClientCreateOrJoinParty.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20063005, ClientCreateOrJoinParty.bindenv(this));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ProjectInitFuncMap.P_Fiendwar <- Fiendwar();
|
||||
1
_DPS_/_BuiltProject/Fiendwar/config
Normal file
1
_DPS_/_BuiltProject/Fiendwar/config
Normal file
@@ -0,0 +1 @@
|
||||
FiendwarClass.nut
|
||||
259
_DPS_/_BuiltProject/Luke/LukeClass.nut
Normal file
259
_DPS_/_BuiltProject/Luke/LukeClass.nut
Normal file
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
文件名: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);
|
||||
print(111);
|
||||
//卢克频道
|
||||
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 base_input_hook2(args) {
|
||||
local type = args[2];
|
||||
local SUser = User(args[1]);
|
||||
local msg = args[3];
|
||||
|
||||
if ((type == 8 || type == 3) && 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 = msg
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
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;
|
||||
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) {
|
||||
Timer.SetTimeOut(function(SUser) {
|
||||
//玩家上线发信息包
|
||||
local evv = {
|
||||
op = 20084502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
}.bindenv(this), 5, SUser);
|
||||
|
||||
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
|
||||
Cb_Server_Chat_Log_Leave_Func.Luke <- base_input_hook2.bindenv(this); //玩家发送消息
|
||||
|
||||
//注册收包
|
||||
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();
|
||||
1
_DPS_/_BuiltProject/Luke/config
Normal file
1
_DPS_/_BuiltProject/Luke/config
Normal file
@@ -0,0 +1 @@
|
||||
LukeClass.nut
|
||||
250
_DPS_/_BuiltProject/NPC交易/NpcTransaction.nut
Normal file
250
_DPS_/_BuiltProject/NPC交易/NpcTransaction.nut
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
文件名:NpcTransaction.nut
|
||||
路径:Dps_A/ProjectClass/NpcTransaction/NpcTransaction.nut
|
||||
创建日期:2025-10-23 14:37
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class NpcTransaction {
|
||||
|
||||
//装备价值
|
||||
EquValue = null;
|
||||
//品级装备组
|
||||
EquGroup = null;
|
||||
//金币易物浮动比例
|
||||
GoldFloat = 0.5;
|
||||
//最低交换品级
|
||||
MinRarity = 0;
|
||||
//交易消耗物品
|
||||
TradeItem = null;
|
||||
//交易冷却时间
|
||||
TradingCooldownTime = 3600000;
|
||||
|
||||
//装备易物浮动等级
|
||||
EquFloatMin = 5;
|
||||
EquFloatMax = 5;
|
||||
|
||||
//事件概率
|
||||
EventRate = null;
|
||||
|
||||
//用户状态表
|
||||
UserState = null;
|
||||
|
||||
|
||||
|
||||
constructor() {
|
||||
//注册客户端收包
|
||||
RegisterClient();
|
||||
EquValue = {};
|
||||
UserState = {};
|
||||
EquGroup = [{}, {}, {}, {}, {}, {}, {}, {}];
|
||||
|
||||
//读取PVF
|
||||
InitPvf();
|
||||
}
|
||||
|
||||
|
||||
function RegisterClient() {
|
||||
ClientSocketPackFuncMap.rawset(21005001, function(SUser, Jso) {
|
||||
local lastTime = GetTransactionInfo(SUser, Jso);
|
||||
if (lastTime && Sq_GetTimestampString().slice(-9).tointeger() - lastTime.time< TradingCooldownTime) {
|
||||
local T = {
|
||||
op = 21005002,
|
||||
flag = 3
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
return;
|
||||
}
|
||||
local InvenObj = SUser.GetInven();
|
||||
local DFlag = InvenObj.DeleteItemCount(TradeItem.item, TradeItem.count);
|
||||
if(!DFlag){
|
||||
local T = {
|
||||
op = 21005002,
|
||||
flag = 3
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
SUser.SendNotiPacketMessage("没有足够的道具用于交易!", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
local InvenObj = SUser.GetInven();
|
||||
local Equ = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + Jso.pos);
|
||||
if (Equ) {
|
||||
local EquId = Equ.GetIndex();
|
||||
if (EquId) {
|
||||
local equ = PvfItem.GetPvfItemById(EquId);
|
||||
local Rarity = equ.GetRarity();
|
||||
local Level = equ.GetUsableLevel();
|
||||
//判断是否解封装
|
||||
local CanTrade = GetTrade(InvenObj, 9 + Jso.pos);
|
||||
|
||||
if ((Rarity == 2 || Rarity == 3) && CanTrade == 0) {
|
||||
local T = {
|
||||
op = 21005006,
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
SUser.SendNotiPacketMessage("该装备属于封装装备,并已解封,无法进行交易!", 0);
|
||||
} else {
|
||||
//判断是进行什么交易逻辑
|
||||
local Random = MathClass.Rand(0, 1000);
|
||||
//嘲讽
|
||||
if (Random <= EventRate[0]) {
|
||||
local T = {
|
||||
op = 21005002,
|
||||
flag = 0
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
local Cid = SUser.GetCID();
|
||||
if (!UserState.rawin(Cid)) UserState[Cid] <- {};
|
||||
UserState[Cid].rawset(Jso.npc, {
|
||||
time = Sq_GetTimestampString().slice(-9).tointeger()
|
||||
});
|
||||
}
|
||||
//金币易物
|
||||
else if (Random <= EventRate[1]) {
|
||||
local FloatValue = (EquValue[EquId] * GoldFloat).tointeger();
|
||||
local RandValue = MathClass.Rand(0, FloatValue);
|
||||
local RandType = MathClass.Rand(0, 2);
|
||||
if (RandType == 0) RandValue = -RandValue;
|
||||
local Glod = EquValue[EquId] + RandValue;
|
||||
local T = {
|
||||
op = 21005002,
|
||||
flag = 1,
|
||||
glod = Glod
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
|
||||
local Cid = SUser.GetCID();
|
||||
if (!UserState.rawin(Cid)) UserState[Cid] <- {};
|
||||
UserState[Cid].rawset(Jso.npc, {
|
||||
glod = Glod,
|
||||
pos = Jso.pos,
|
||||
oldid = EquId
|
||||
time = Sq_GetTimestampString().slice(-9).tointeger()
|
||||
});
|
||||
}
|
||||
//装备易物
|
||||
else if (Random <= EventRate[2]) {
|
||||
local setarr = [];
|
||||
local findtable = EquGroup[Rarity];
|
||||
foreach(index, level in findtable) {
|
||||
if (level >= Level - EquFloatMin && level <= Level + EquFloatMax) {
|
||||
setarr.append(index);
|
||||
}
|
||||
}
|
||||
|
||||
local SendId = setarr[MathClass.Rand(0, setarr.len() - 1)];
|
||||
local T = {
|
||||
op = 21005002,
|
||||
flag = 2,
|
||||
equ = SendId
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
|
||||
local Cid = SUser.GetCID();
|
||||
if (!UserState.rawin(Cid)) UserState[Cid] <- {};
|
||||
UserState[Cid].rawset(Jso.npc, {
|
||||
equ = SendId,
|
||||
pos = Jso.pos,
|
||||
oldid = EquId
|
||||
time = Sq_GetTimestampString().slice(-9).tointeger()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
|
||||
|
||||
ClientSocketPackFuncMap.rawset(21005003, function(SUser, Jso) {
|
||||
//获取交易结构体
|
||||
local Info = GetTransactionInfo(SUser, Jso);
|
||||
if (!Info) return;
|
||||
//获取旧装备ID
|
||||
local oldid = Info.oldid;
|
||||
//获取旧装备格子
|
||||
local pos = Info.pos;
|
||||
//检测扣除
|
||||
local InvenObj = SUser.GetInven();
|
||||
local Equ = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + Info.pos);
|
||||
if (Equ.GetIndex() != oldid) {
|
||||
SUser.SendNotiBox("交易时请不要移动背包中装备的位置!", 1);
|
||||
return;
|
||||
}
|
||||
Equ.Delete();
|
||||
|
||||
if (Info.rawin("equ")) {
|
||||
SUser.GiveItem(Info.equ, 1);
|
||||
SUser.SendNotiBox("与NPC交易获得装备 [" + PvfItem.GetNameById(Info.equ) + "]", 1);
|
||||
} else if (Info.rawin("glod")) {
|
||||
SUser.RechargeMoney(Info.glod);
|
||||
SUser.SendNotiBox("与NPC交易获得金币: " + Info.glod, 1);
|
||||
}
|
||||
SUser.SendItemSpace(0);
|
||||
}.bindenv(this));
|
||||
}
|
||||
|
||||
function GetTransactionInfo(SUser, Jso) {
|
||||
try {
|
||||
local Info = UserState[SUser.GetCID()][Jso.npc];
|
||||
return Info;
|
||||
} catch (exception) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
function InitPvf() {
|
||||
Script();
|
||||
ScriptData.GetFileData("etc/rindro/npctransaction/npctransaction.etc", function(DataTable, Data) {
|
||||
while (!Data.Eof()) {
|
||||
local Fragment = Data.Get();
|
||||
if (Fragment == "[value]") {
|
||||
while (true) {
|
||||
local Fbuf = Data.Get();
|
||||
if (Fbuf == "[/value]") {
|
||||
break;
|
||||
}
|
||||
local Value = Data.Get();
|
||||
EquValue.rawset(Fbuf, Value);
|
||||
//读取装备品级
|
||||
local equ = PvfItem.GetPvfItemById(Fbuf);
|
||||
local Rarity = equ.GetRarity();
|
||||
local Level = equ.GetUsableLevel();
|
||||
EquGroup[Rarity].rawset(Fbuf, Level);
|
||||
}
|
||||
} else if (Fragment == "[random]") {
|
||||
GoldFloat = Data.Get().tofloat() / 1000.0;
|
||||
} else if (Fragment == "[allow rarity]") {
|
||||
MinRarity = Data.Get();
|
||||
} else if (Fragment == "[exchange cost item]") {
|
||||
TradeItem = {
|
||||
item = Data.Get(),
|
||||
count = Data.Get()
|
||||
}
|
||||
} else if (Fragment == "[equipment random level lower]") {
|
||||
EquFloatMin = Data.Get();
|
||||
} else if (Fragment == "[equipment random level upper]") {
|
||||
EquFloatMax = Data.Get();
|
||||
} else if (Fragment == "[event rate]") {
|
||||
local o1 = Data.Get();
|
||||
local o2 = Data.Get();
|
||||
local o3 = Data.Get();
|
||||
|
||||
EventRate = [o1, o1 + o2, o1 + o2 + o3];
|
||||
}else if (Fragment == "[exchange term]") {
|
||||
TradingCooldownTime = Data.Get();
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
}
|
||||
|
||||
function GetTrade(InvenObj, pos) {
|
||||
local ptr = Memory.alloc(10240);
|
||||
Sq_CallFunc(S_Ptr("0x084FB918"), "int", ["pointer", "pointer", "int", "int"], ptr.C_Object, InvenObj.C_Object, 1, pos);
|
||||
return ptr.readS8();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timer.SetTimeOut(function() {
|
||||
ProjectInitFuncMap.P_NpcTransaction <- NpcTransaction();
|
||||
}, 10000);
|
||||
1
_DPS_/_BuiltProject/NPC交易/config
Normal file
1
_DPS_/_BuiltProject/NPC交易/config
Normal file
@@ -0,0 +1 @@
|
||||
NpcTransaction.nut
|
||||
36
_DPS_/_BuiltProject/combatrank/CombatRank.nut
Normal file
36
_DPS_/_BuiltProject/combatrank/CombatRank.nut
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
文件名:CombatRank.nut
|
||||
路径:Dps_A/ProjectClass/CombatRank/CombatRank.nut
|
||||
创建日期:2024-06-26 23:10
|
||||
文件用途:战斗力系统
|
||||
*/
|
||||
class CombatRank {
|
||||
|
||||
//角色更换了装备事件包
|
||||
PacketId_0 = 20072102;
|
||||
|
||||
constructor() {
|
||||
|
||||
//注册服务端收包
|
||||
RegisterServer();
|
||||
//注册客户端收包
|
||||
RegisterClient();
|
||||
|
||||
}
|
||||
|
||||
function RegisterServer() {
|
||||
Cb_player_chanage_equ_Func.CombatRankFunc <- function(SUser) {
|
||||
local T = {
|
||||
op = PacketId_0
|
||||
}
|
||||
SUser.SendJso(T);
|
||||
}.bindenv(this);
|
||||
}
|
||||
|
||||
|
||||
function RegisterClient() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ProjectInitFuncMap.P_CombatRank <- CombatRank();
|
||||
1
_DPS_/_BuiltProject/combatrank/config
Normal file
1
_DPS_/_BuiltProject/combatrank/config
Normal file
@@ -0,0 +1 @@
|
||||
CombatRank.nut
|
||||
259
_DPS_/_BuiltProject/卢克/LukeClass.nut
Normal file
259
_DPS_/_BuiltProject/卢克/LukeClass.nut
Normal file
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
文件名: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);
|
||||
print(111);
|
||||
//卢克频道
|
||||
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 base_input_hook2(args) {
|
||||
local type = args[2];
|
||||
local SUser = User(args[1]);
|
||||
local msg = args[3];
|
||||
|
||||
if ((type == 8 || type == 3) && 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 = msg
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
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;
|
||||
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) {
|
||||
Timer.SetTimeOut(function(SUser) {
|
||||
//玩家上线发信息包
|
||||
local evv = {
|
||||
op = 20084502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
}.bindenv(this), 5, SUser);
|
||||
|
||||
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
|
||||
Cb_Server_Chat_Log_Leave_Func.Luke <- base_input_hook2.bindenv(this); //玩家发送消息
|
||||
|
||||
//注册收包
|
||||
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();
|
||||
1
_DPS_/_BuiltProject/卢克/config
Normal file
1
_DPS_/_BuiltProject/卢克/config
Normal file
@@ -0,0 +1 @@
|
||||
LukeClass.nut
|
||||
258
_DPS_/_BuiltProject/安图恩/AntonClass.nut
Normal file
258
_DPS_/_BuiltProject/安图恩/AntonClass.nut
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
文件名:AntonClass.nut
|
||||
路径:Dps_A/ProjectClass/Anton/AntonClass.nut
|
||||
创建日期:2024-07-15 20:46
|
||||
文件用途:安图恩服务的文件
|
||||
*/
|
||||
class Anton {
|
||||
//频道
|
||||
Channel = 18;
|
||||
//城镇
|
||||
Town = 188;
|
||||
|
||||
//服务端区域移动添加玩家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("18") != null) {
|
||||
if (AreaIndex <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064023,
|
||||
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("18") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = CmdString
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function base_input_hook2(args) {
|
||||
local type = args[2];
|
||||
local SUser = User(args[1]);
|
||||
local msg = args[3];
|
||||
if ((type == 8 || type == 3) && Sq_Game_GetConfig().find("18") != null) {
|
||||
local Localtion = SUser.GetLocation();
|
||||
if (Localtion.Area <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
local Jso = {
|
||||
op = 20064027,
|
||||
uid = SUser.GetUID(),
|
||||
cid = SUser.GetCID(),
|
||||
msg = msg
|
||||
}
|
||||
Socket.SendGateway(Jso);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//玩家消息分发
|
||||
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;
|
||||
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 AntonSendAreaUserCallBack(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 AntonPlayerMoveMapCallBack(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 = 20064502,
|
||||
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 = 20064502,
|
||||
town_index = Town,
|
||||
channel_index = Channel
|
||||
}
|
||||
SUser.SendJso(evv);
|
||||
|
||||
local T = {
|
||||
op = 20064063,
|
||||
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.Anton <- insert_user_hook.bindenv(this); //区域添加角色
|
||||
Cb_Move_Area_Func.Anton <- move_area_hook.bindenv(this); //区域移动
|
||||
//Base_InputHookFunc_Handle.Anton <- base_input_hook.bindenv(this); //玩家发送消息
|
||||
Cb_reach_game_world_Func.Anton <- Login_Hook.bindenv(this); //上线HOOK
|
||||
Cb_Server_Chat_Log_Leave_Func.Anton <- base_input_hook2.bindenv(this); //玩家发送消息
|
||||
|
||||
|
||||
//注册收包
|
||||
GatewaySocketPackFuncMap.rawset(20064010, AntonSendAreaUserCallBack.bindenv(this)); //玩家移动后的区域广播包
|
||||
GatewaySocketPackFuncMap.rawset(20064012, AntonPlayerMoveMapCallBack.bindenv(this)); //玩家移动回调
|
||||
//玩家消息分发
|
||||
GatewaySocketPackFuncMap.rawset(20064018, PlayerNotiMsgDistribute.bindenv(this)); //玩家打字发送的信息
|
||||
GatewaySocketPackFuncMap.rawset(20064778, GetPluginConfig.bindenv(this)); //服务端配置
|
||||
|
||||
//注册来自客户端的收包
|
||||
ClientSocketPackFuncMap.rawset(20230718, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064501, ClientGetConfigCallBack.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064001, ClientCreateOrJoinParty.bindenv(this));
|
||||
ClientSocketPackFuncMap.rawset(20064005, ClientCreateOrJoinParty.bindenv(this));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ProjectInitFuncMap.P_Anton <- Anton();
|
||||
1
_DPS_/_BuiltProject/安图恩/config
Normal file
1
_DPS_/_BuiltProject/安图恩/config
Normal file
@@ -0,0 +1 @@
|
||||
AntonClass.nut
|
||||
327
_DPS_/_BuiltProject/定制-交易行/Exchange.nut
Normal file
327
_DPS_/_BuiltProject/定制-交易行/Exchange.nut
Normal file
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
文件名:Exchange.nut
|
||||
路径:Dps_A/ProjectClass/Exchange/Exchange.nut
|
||||
创建日期:2025-07-21 19:05
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Exchange {
|
||||
|
||||
MysqlObject = null;
|
||||
Commission = 0;
|
||||
|
||||
constructor() {
|
||||
Script();
|
||||
MysqlObject = Mysql(Str_Ptr("127.0.0.1"), 3306, Str_Ptr("taiwan_cain"), Str_Ptr("game"), Str_Ptr("uu5!^%jg"));
|
||||
MysqlObject.Exec_Sql(format("SET NAMES %s", "latin1"));
|
||||
|
||||
SelectSql("CREATE TABLE `zyk`.`exchange` ( `uuid` int NOT NULL AUTO_INCREMENT, `type` int NULL, `itemid` int NULL, `itemcount` int NULL, `itemdata` varchar(512) NULL, `price` int NULL, `uid` int NULL , `cid` int NULL , `name` varchar(128) NULL, PRIMARY KEY (`uuid`));", []);
|
||||
|
||||
|
||||
|
||||
local Ct = ScriptData.GetFileData("etc/rindro/exchange/exchange.etc", function(DataTable, Data) {
|
||||
DataTable.Attribute <- {};
|
||||
while (!Data.Eof()) {
|
||||
local Str = Data.Get();
|
||||
if (Str == "[commission]") {
|
||||
Commission = Data.Get().tofloat() * 0.01;
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
|
||||
//上架商品
|
||||
ClientSocketPackFuncMap.rawset(21001001, function(SUser, Jso) {
|
||||
//获取玩家背包
|
||||
local InvenObj = SUser.GetInven();
|
||||
if (!InvenObj) {
|
||||
return;
|
||||
}
|
||||
|
||||
//获取道具
|
||||
local ItemObj = InvenObj.GetSlot(1, Jso.pos + 9 + (Jso.type * 48));
|
||||
if (!ItemObj) return;
|
||||
|
||||
//获取道具类型
|
||||
ItemObj.Attribute.seek(1);
|
||||
local ItemType = ItemObj.Attribute.readn('c');
|
||||
//副职业材料是10 这里给转成5
|
||||
if (ItemType == 10) ItemType = 5;
|
||||
|
||||
//获取道具Id
|
||||
local ItemId = ItemObj.GetIndex();
|
||||
//获取数量
|
||||
local ItemCount = ItemObj.GetAdd_Info();
|
||||
//如果是装备 数量恒定为1
|
||||
if (ItemType == 1) ItemCount = 1;
|
||||
|
||||
//获取道具数据
|
||||
local ItemData = "0x00";
|
||||
|
||||
//获取价格
|
||||
local Price = Jso.value;
|
||||
//获取上架者cid
|
||||
local Uid = SUser.GetUID();
|
||||
local Cid = SUser.GetCID();
|
||||
local Name = SUser.GetCharacName();
|
||||
|
||||
local InfoTable = {
|
||||
ItemType = ItemType,
|
||||
ItemId = ItemId,
|
||||
ItemCount = ItemCount,
|
||||
ItemData = ItemData,
|
||||
Price = Price,
|
||||
Uid = Uid,
|
||||
Cid = Cid,
|
||||
Name = Name
|
||||
}
|
||||
|
||||
if (ItemType == 1) {
|
||||
EquipLogic(SUser, Jso.pos + 9, InfoTable, ItemObj);
|
||||
return;
|
||||
}
|
||||
|
||||
//插入数据库
|
||||
local Sql = format("INSERT INTO `zyk`.`exchange` (`type`, `itemid`, `itemcount`, `itemdata`, `price`, `uid` ,`cid`,`name`) VALUES (%d, %d, %d, \'%s\', %d, %d, %d, \'%s\');", InfoTable.ItemType, InfoTable.ItemId, InfoTable.ItemCount, InfoTable.ItemData, InfoTable.Price, InfoTable.Uid, InfoTable.Cid, InfoTable.Name);
|
||||
local Ret = SelectSql(Sql, []);
|
||||
|
||||
//删除道具
|
||||
ItemObj.Delete();
|
||||
//发送刷新背包消息
|
||||
SUser.SendUpdateItemList(1, 1, Jso.pos + 9 + (Jso.type * 48));
|
||||
SUser.SendItemSpace(0);
|
||||
}.bindenv(this));
|
||||
|
||||
|
||||
//查询上架商品
|
||||
ClientSocketPackFuncMap.rawset(21001003, function(SUser, Jso) {
|
||||
local Offset = Jso.offset;
|
||||
local Sql = format("SELECT * FROM `zyk`.`exchange` WHERE `type` = %d LIMIT 7 OFFSET %d;", Jso.type, Offset);
|
||||
local Ret = SelectSql(Sql, ["int", "int", "int", "int", "binary", "int", "int", "int", "string"]);
|
||||
|
||||
local CountSql = format("SELECT COUNT(*) AS total FROM `zyk`.`exchange` WHERE `type` = %d;", Jso.type);
|
||||
local CountRet = SelectSql(CountSql, ["int"]);
|
||||
|
||||
local TotalCount = 0;
|
||||
if (CountRet.len() > 0) TotalCount = CountRet[0][0];
|
||||
|
||||
local Pack = {};
|
||||
Pack.op <- 21001004;
|
||||
Pack.info <- [];
|
||||
Pack.total <- TotalCount;
|
||||
foreach(info in Ret) {
|
||||
local T = {
|
||||
uid = info[0],
|
||||
itemId = info[2],
|
||||
count = info[3],
|
||||
price = info[5],
|
||||
name = info[8]
|
||||
}
|
||||
Pack.info.push(T);
|
||||
}
|
||||
SUser.SendJso(Pack);
|
||||
|
||||
}.bindenv(this));
|
||||
|
||||
//购买商品
|
||||
ClientSocketPackFuncMap.rawset(21001005, function(SUser, Jso) {
|
||||
local uuid = Jso.uuid;
|
||||
|
||||
local Sql = format("SELECT * FROM `zyk`.`exchange` WHERE `uuid` = %d;", uuid);
|
||||
local Ret = SelectSql(Sql, ["int", "int", "int", "int", "string", "int", "int", "int", "string"]);
|
||||
if (Ret.len() == 0) return;
|
||||
|
||||
local ItemObj = null;
|
||||
local ItemType = Ret[0][1];
|
||||
local ItemId = Ret[0][2];
|
||||
local ItemCount = Ret[0][3];
|
||||
local ItemPrice = Ret[0][5];
|
||||
local ItemData = Ret[0][4];
|
||||
local uid = Ret[0][6];
|
||||
local cid = Ret[0][7];
|
||||
|
||||
local SelfCid = SUser.GetCID();
|
||||
if (SelfCid == cid) return;
|
||||
|
||||
local UserPoint = SUser.GetCera();
|
||||
if (UserPoint< ItemPrice) return;
|
||||
|
||||
//扣除点券
|
||||
SUser.RechargeCera(-ItemPrice);
|
||||
|
||||
//如果是装备
|
||||
if (ItemType == 1) {
|
||||
local ItemDataJso = Json.Decode(ItemData);
|
||||
SendItemExMail(SUser.GetUID(), SUser.GetCID(), [ItemDataJso], "交易所小助手", "您在交易所购买的商品已发货,请查收!");
|
||||
} else {
|
||||
//发送道具
|
||||
local SendInfo = SUser.GiveItem(ItemId, 1);
|
||||
SUser.SendItemSpace(0);
|
||||
}
|
||||
|
||||
//给上架者加钱
|
||||
local RealItemPrice = (ItemPrice * (1.0 - Commission.tofloat()).tofloat()).tointeger();
|
||||
User.SendItemMail(uid, cid, [{
|
||||
item = 2022110573,
|
||||
num = RealItemPrice
|
||||
}], "交易所小助手", "恭喜您在交易所成功出售商品,获得点券奖励");
|
||||
|
||||
//删除数据库中的记录
|
||||
Sql = format("DELETE FROM `zyk`.`exchange` WHERE `uuid` = %d;", uuid);
|
||||
SelectSql(Sql, []);
|
||||
|
||||
}.bindenv(this));
|
||||
|
||||
|
||||
Cb_Use_Item_Sp_Func[2022110573] <- function(SUser, ItemId) {
|
||||
local Cid = SUser.GetCID();
|
||||
local InvenObj = SUser.GetInven();
|
||||
if (InvenObj) {
|
||||
local SlotIdx = InvenObj.GetSlotById(ItemId);
|
||||
local ItemObj = InvenObj.GetSlot(1, SlotIdx);
|
||||
|
||||
local ItemCount = ItemObj.GetAdd_Info();
|
||||
ItemObj.Delete();
|
||||
SUser.SendItemSpace(0);
|
||||
SUser.RechargeCera(ItemCount);
|
||||
SUser.SendNotiPacketMessage("获得交易所点卷收益: " + ItemCount + "点卷", 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function EquipLogic(SUser, slot, InfoTable, ItemObj) {
|
||||
Sq_CallFunc(S_Ptr("0x0864FE52"), "int", ["pointer"], SUser.C_Object);
|
||||
Timer.SetTimeOut(function() {
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select("SELECT inventory FROM taiwan_cain_2nd.inventory WHERE charac_no = " + SUser.GetCID() + ";", ["binary"]);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
if (Ret.len()< 1 || Ret[0][0] == null) {
|
||||
return false;
|
||||
} else {
|
||||
local LengthPointer = Memory.alloc(4);
|
||||
LengthPointer.writeInt(18238);
|
||||
|
||||
local ReadPointer = Memory.alloc(18238);
|
||||
|
||||
local Flag = Sq_CallFunc(S_Ptr("0x086B2102"), "bool", ["pointer", "pointer", "pointer", "int"], ReadPointer.C_Object, LengthPointer.C_Object, Ret[0][0].C_Object, Ret[0][0].Size);
|
||||
|
||||
local RealP = ReadPointer.add(2 + slot * 61);
|
||||
|
||||
//装备编号
|
||||
local ItemId = RealP.readInt();
|
||||
// print("装备编号: " + ItemId);
|
||||
|
||||
//强化等级
|
||||
local EnhancementLevel = RealP.add(4).readS8();
|
||||
// print("强化等级: " + EnhancementLevel);
|
||||
|
||||
//红字类型
|
||||
local AmplifyType = RealP.add(15).readS8();
|
||||
// print("红字类型: " + AmplifyType);
|
||||
|
||||
//红字属性值
|
||||
local AmplifyValue = RealP.add(16).readS8();
|
||||
// print("红字属性值: " + AmplifyValue);
|
||||
|
||||
//锻造等级
|
||||
local ForgingGrade = RealP.add(49).readS8();
|
||||
// print("锻造等级: " + ForgingGrade);
|
||||
|
||||
//附魔卡片
|
||||
local CardId = RealP.add(11).readShort();
|
||||
// print("附魔卡片: " + CardId);
|
||||
|
||||
//品级
|
||||
local Grade = RealP.add(5).readInt();
|
||||
// print("品级: " + Grade);
|
||||
|
||||
//耐久度
|
||||
local Durability = RealP.add(9).readS8();
|
||||
// print("耐久度: " + Durability)
|
||||
|
||||
//魔法封印
|
||||
local MagicSealP = "0x";
|
||||
for (local i = 0; i< 14; i++) {
|
||||
MagicSealP += format("%02x", RealP.add(35 + i).readU8());
|
||||
}
|
||||
// print(MagicSealP);
|
||||
|
||||
local SendT = {
|
||||
ItemId = ItemId,
|
||||
Grade = Grade,
|
||||
Durability = Durability,
|
||||
EnhancementLevel = EnhancementLevel,
|
||||
AmplifyType = AmplifyType,
|
||||
AmplifyValue = AmplifyValue,
|
||||
MagicSealP = MagicSealP,
|
||||
CardId = CardId,
|
||||
}
|
||||
|
||||
local Json = Json.Encode(SendT);
|
||||
InfoTable.ItemData = Json;
|
||||
|
||||
//插入数据库
|
||||
local Sql = format("INSERT INTO `zyk`.`exchange` (`type`, `itemid`, `itemcount`, `itemdata`, `price`, `uid` ,`cid`,`name`) VALUES (%d, %d, %d, \'%s\', %d, %d, %d, \'%s\');", InfoTable.ItemType, InfoTable.ItemId, InfoTable.ItemCount, InfoTable.ItemData, InfoTable.Price, InfoTable.Uid, InfoTable.Cid, InfoTable.Name);
|
||||
local Ret = SelectSql(Sql, []);
|
||||
|
||||
//删除道具
|
||||
ItemObj.Delete();
|
||||
//发送刷新背包消息
|
||||
SUser.SendUpdateItemList(1, 1, slot);
|
||||
SUser.SendItemSpace(0);
|
||||
}
|
||||
}.bindenv(this), 100)
|
||||
}
|
||||
|
||||
|
||||
function SendItemExMail(UID, CID, ItemList, title, content) {
|
||||
local SUser = World.GetUserByUid(UID);
|
||||
local sql = "select letter_id from taiwan_cain_2nd.postal order by letter_id DESC";
|
||||
local column_type_list = ["int"];
|
||||
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local result = SqlObj.Select(sql, column_type_list);
|
||||
local sl = 1;
|
||||
if (result.len() > 0) {
|
||||
sl = result[0][0] + 1;
|
||||
}
|
||||
|
||||
local time = date();
|
||||
local timeStr = time["year"] + "-" + (time["month"] + 1) + "-" + time["day"] + " " + time["hour"] + ":" + time["min"] + ":" + time["sec"];
|
||||
|
||||
foreach(value in ItemList) {
|
||||
//时间 发送者名字 接收者id 装备ID 品级 耐久度 强化等级 红字类型 红字属性值 魔法封印属性 letterid
|
||||
local sql1 = format("insert into taiwan_cain_2nd.postal (occ_time,send_charac_name,receive_charac_no,item_id,add_info,endurance,upgrade,amplify_option,amplify_value,random_option,letter_id,extend_info) values ('%s','%s',%d,%d,%d,%d,%d,%d,%d,%s,%d,%d)", timeStr, title, CID, value.ItemId, value.Grade, value.Durability, value.EnhancementLevel, value.AmplifyType, value.AmplifyValue, value.MagicSealP, sl, value.CardId)
|
||||
SqlObj.Select(sql1, []);
|
||||
}
|
||||
|
||||
local sql2 = "insert into taiwan_cain_2nd.letter (letter_id,charac_no,send_charac_name,letter_text,reg_date,stat) values ('" + sl + "'," + CID + ",'" + title + "','" + content + "','" + timeStr + "','1')";
|
||||
SqlObj.Select(sql2, []);
|
||||
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
|
||||
// if (SUser) {
|
||||
// local Pack = Packet();
|
||||
// Pack.Put_Header(0, 9);
|
||||
// local MailBox = Sq_CallFunc(S_Ptr("0x0823020C"), "int", ["pointer"], SUser.C_Object);
|
||||
// Sq_CallFunc(S_Ptr("0x0823455A"), "int", ["int"], MailBox);
|
||||
// local Not_Count = Sq_CallFunc(S_Ptr("0x084ED330"), "int", ["int"], MailBox);
|
||||
// Pack.Put_Short(Not_Count);
|
||||
// Pack.Finalize(true);
|
||||
// SUser.Send(Pack);
|
||||
// Pack.Delete();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
//执行数据库命令
|
||||
function SelectSql(Sql, Type) {
|
||||
local Ret = MysqlObject.Select(Sql, Type);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ProjectInitFuncMap.P_Exchange <- Exchange();
|
||||
1
_DPS_/_BuiltProject/定制-交易行/config
Normal file
1
_DPS_/_BuiltProject/定制-交易行/config
Normal file
@@ -0,0 +1 @@
|
||||
Exchange.nut
|
||||
447
_DPS_/_BuiltProject/宿命魂石/FatalismStone.nut
Normal file
447
_DPS_/_BuiltProject/宿命魂石/FatalismStone.nut
Normal file
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
文件名:FatalismStone.nut
|
||||
路径:Dps_A/ProjectClass/FatalismStone/FatalismStone.nut
|
||||
创建日期:2025-06-22 12:54
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
|
||||
class FatalismStone_Stone {
|
||||
//编号
|
||||
Id = 0;
|
||||
//类型
|
||||
StoneType = 0;
|
||||
//洗练度
|
||||
CultivationDegree = 0;
|
||||
|
||||
|
||||
|
||||
//特殊 ! 石头的储存数据大小
|
||||
Size = 8;
|
||||
|
||||
constructor(FatalismStoneID = 0) {
|
||||
Id = FatalismStoneID;
|
||||
CultivationDegree = MathClass.Rand(1, 100);
|
||||
}
|
||||
|
||||
function Blob2Hex(buf) {
|
||||
local str = "";
|
||||
for (local i = 0; i< buf.len(); i++) {
|
||||
str += format("%02X", buf[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function Serialize() {
|
||||
local B = blob(0);
|
||||
|
||||
B.writen(Id, 'i'); //写入ID
|
||||
B.writen(CultivationDegree, 'i'); //写入洗练值
|
||||
|
||||
return Blob2Hex(B);
|
||||
}
|
||||
|
||||
function Deserialize(Data) {
|
||||
local Buf = FatalismStone_Stone();
|
||||
Buf.Id = Data.readn('i');
|
||||
Buf.CultivationDegree = Data.readn('i');
|
||||
if (Buf.Id == 0) return Buf;
|
||||
Buf.StoneType = ProjectInitFuncMap.P_FatalismStone.GetStoneData(Buf.Id)["stone type"];
|
||||
return Buf;
|
||||
}
|
||||
|
||||
function SerializeTable(Obj) {
|
||||
local T = {
|
||||
id = Obj.Id,
|
||||
cultivationDegree = Obj.CultivationDegree
|
||||
};
|
||||
return T;
|
||||
}
|
||||
}
|
||||
|
||||
class FatalismStone {
|
||||
|
||||
//总格子数
|
||||
GridCount = 77;
|
||||
//总穿戴数
|
||||
WearCount = 6;
|
||||
|
||||
//属性数据位数
|
||||
AttrCount = 2;
|
||||
|
||||
//魂石Lst
|
||||
FatalismStoneLst = null;
|
||||
|
||||
constructor() {
|
||||
local PoolObj = MysqlPool.GetInstance();
|
||||
PoolObj.SetBaseConfiguration("127.0.0.1", 3306, "game", "uu5!^%jg");
|
||||
//连接池大小
|
||||
PoolObj.PoolSize = 10;
|
||||
//初始化
|
||||
PoolObj.Init();
|
||||
|
||||
//读取pvf的魂石相关数据
|
||||
InitFatalismStoneData();
|
||||
|
||||
//注册客户端收包
|
||||
RegisterClient();
|
||||
//注册调试命令
|
||||
RegisterDebugCmd();
|
||||
|
||||
|
||||
|
||||
SelectSql("CREATE TABLE `zyk`.`fatalismstone` ( `cid` int(250) NOT NULL, `data` varbinary(10240) NULL, `wearpack` varbinary(1024) NULL, PRIMARY KEY (`cid`));", []);
|
||||
}
|
||||
|
||||
|
||||
//通过数组生成魂石序列化数据
|
||||
function GenerateSerializeData(StoneList) {
|
||||
local Str = "0x";
|
||||
foreach(Stone in StoneList) {
|
||||
Str += Stone.Serialize();
|
||||
}
|
||||
return Str;
|
||||
}
|
||||
|
||||
//通过数据反序列化魂石列表 数据 序列化个数
|
||||
function GenerateDeserializeData(Data, Count) {
|
||||
local BData = Sq_Point2Blob(Data.C_Object, FatalismStone_Stone.Size * Count);
|
||||
local DataArr = [];
|
||||
|
||||
//一直读到最后
|
||||
while (!BData.eos()) {
|
||||
DataArr.push(FatalismStone_Stone.Deserialize(BData));
|
||||
}
|
||||
return DataArr;
|
||||
}
|
||||
|
||||
//给指定玩家新增魂石
|
||||
function AddFatalismStone(SUser, FatalismStoneID) {
|
||||
local CID = SUser.GetCID();
|
||||
local Ret = SelectSql("select data from zyk.fatalismstone where cid = " + CID, ["binary"]);
|
||||
//获得玩家魂石数据
|
||||
local DataArr = GenerateDeserializeData(Ret[0][0], GridCount * 3);
|
||||
//获取魂石属性
|
||||
local info = GetStoneData(FatalismStoneID);
|
||||
//根据页数分割
|
||||
local Offset = (info["stone type"] * GridCount);
|
||||
|
||||
local DataBuffer = DataArr.slice(Offset);
|
||||
//找到第一个空格子
|
||||
local Index = null;
|
||||
foreach(Pos, Obj in DataBuffer) {
|
||||
if (Obj.Id == 0) {
|
||||
Index = Pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Index == null) {
|
||||
SUser.SendNotiPacketMessage("您的魂石背包已满!", 8);
|
||||
return false;
|
||||
}
|
||||
//添加魂石
|
||||
DataArr[Offset + Index] = FatalismStone_Stone(FatalismStoneID);
|
||||
local backpackBinary = GenerateSerializeData(DataArr);
|
||||
SelectSql("update zyk.fatalismstone set data = (" + backpackBinary + ") where cid = " + CID, ["int"]);
|
||||
FlushPlayerFatalismStoneBackpack(SUser);
|
||||
return true;
|
||||
}
|
||||
|
||||
//给指定玩家刷新魂石背包
|
||||
function FlushPlayerFatalismStoneBackpack(SUser) {
|
||||
local Ret = SelectSql("select data,wearpack from zyk.fatalismstone where cid = " + SUser.GetCID(), ["binary", "binary"]);
|
||||
//背包数量*背包类型数量全部使用默认的构造石头填充会是0
|
||||
local BackPackArr = array(GridCount * 3, FatalismStone_Stone());
|
||||
local WearArr = array(WearCount, FatalismStone_Stone());
|
||||
//没有初始化背包的时候先初始化背包
|
||||
if (Ret.len() == 0) {
|
||||
local backpackBinary = GenerateSerializeData(BackPackArr);
|
||||
local wearBinary = GenerateSerializeData(WearArr);
|
||||
SelectSql("insert into zyk.fatalismstone(cid,data,wearpack) values(" + SUser.GetCID() + ",(" + backpackBinary + "),(" + wearBinary + "))", ["int"]);
|
||||
} else {
|
||||
BackPackArr = GenerateDeserializeData(Ret[0][0], GridCount * 3);
|
||||
WearArr = GenerateDeserializeData(Ret[0][1], WearCount);
|
||||
}
|
||||
SUser.SendJso({
|
||||
op = 21000002,
|
||||
BackPackData = BackPackArr.map(FatalismStone_Stone.SerializeTable),
|
||||
WearData = WearArr.map(FatalismStone_Stone.SerializeTable)
|
||||
});
|
||||
}
|
||||
|
||||
function RegisterClient() {
|
||||
//查询魂石背包数据
|
||||
ClientSocketPackFuncMap.rawset(21000001, function(SUser, Jso) {
|
||||
FlushPlayerFatalismStoneBackpack(SUser);
|
||||
}.bindenv(this));
|
||||
|
||||
//交换魂石位置
|
||||
ClientSocketPackFuncMap.rawset(21000003, function(SUser, Jso) {
|
||||
local OldType = Jso.oldtype;
|
||||
local OldIndex = Jso.oldpos;
|
||||
|
||||
local NewType = Jso.newtype;
|
||||
local NewIndex = Jso.newpos;
|
||||
|
||||
|
||||
local Ret = SelectSql("select data,wearpack from zyk.fatalismstone where cid = " + SUser.GetCID(), ["binary", "binary"]);
|
||||
local BackPackArr = GenerateDeserializeData(Ret[0][0], GridCount * 3);
|
||||
local WearArr = GenerateDeserializeData(Ret[0][1], WearCount);
|
||||
|
||||
//如果有魂石要移动到穿戴栏 需要检测魂石的类型是否与穿戴栏符合
|
||||
// if (OldType == -1 || NewType == -1) {
|
||||
// if(OldType == -1){
|
||||
// local OldStone = WearArr[OldIndex];
|
||||
// if(OldStone.Id != 0){
|
||||
// local Info = GetStoneData(OldStone.Id);
|
||||
// if(Info["stone type"] != NewType){
|
||||
// SUser.SendNotiPacketMessage("该魂石无法穿戴在当前位置", 8);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(NewType == -1){
|
||||
// local NewStone = BackPackArr[NewIndex];
|
||||
// if(NewStone.Id != 0){
|
||||
// local Info = GetStoneData(NewStone.Id);
|
||||
// if(Info["stone type"] != OldType){
|
||||
// SUser.SendNotiPacketMessage("该魂石无法穿戴在当前位置", 8);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//如果Type等于-1 说明是穿戴的魂石的槽位
|
||||
local OldTemp, NewTemp;
|
||||
if (OldType == -1) {
|
||||
OldTemp = WearArr[OldIndex];
|
||||
} else {
|
||||
OldTemp = BackPackArr[OldType * GridCount + OldIndex];
|
||||
}
|
||||
if (NewType == -1) {
|
||||
NewTemp = WearArr[NewIndex];
|
||||
} else {
|
||||
NewTemp = BackPackArr[NewType * GridCount + NewIndex];
|
||||
}
|
||||
|
||||
|
||||
// //比对两个魂石的槽位类型
|
||||
// local ComparisonType;
|
||||
// if (NewType == -1) {
|
||||
// ComparisonType = NewIndex + 1;
|
||||
// } else {
|
||||
// ComparisonType = (NewType + 1);
|
||||
// }
|
||||
// print("旧类型: " + OldTemp.StoneType + "\n 新类型: " + ComparisonType);
|
||||
// print("旧ID: " + OldTemp.Id + "\n 新ID: " + NewTemp.Id);
|
||||
// if (OldTemp.StoneType != ComparisonType) {
|
||||
// SUser.SendNotiPacketMessage("该魂石无法穿戴在当前位置", 8);
|
||||
// return;
|
||||
// }
|
||||
|
||||
//交换数据
|
||||
if (OldType == -1) {
|
||||
WearArr[OldIndex] = NewTemp;
|
||||
} else {
|
||||
BackPackArr[OldType * GridCount + OldIndex] = NewTemp;
|
||||
}
|
||||
if (NewType == -1) {
|
||||
WearArr[NewIndex] = OldTemp;
|
||||
} else {
|
||||
BackPackArr[NewType * GridCount + NewIndex] = OldTemp;
|
||||
}
|
||||
|
||||
|
||||
//序列化数据
|
||||
local backpackBinary = GenerateSerializeData(BackPackArr);
|
||||
local wearBinary = GenerateSerializeData(WearArr);
|
||||
|
||||
|
||||
//更新数据库
|
||||
SelectSql("update zyk.fatalismstone set data = (" + backpackBinary + "),wearpack = (" + wearBinary + ") where cid = " + SUser.GetCID(), ["int"]);
|
||||
|
||||
//发送数据
|
||||
SUser.SendJso({
|
||||
op = 21000002,
|
||||
BackPackData = BackPackArr.map(FatalismStone_Stone.SerializeTable),
|
||||
WearData = WearArr.map(FatalismStone_Stone.SerializeTable)
|
||||
});
|
||||
}.bindenv(this));
|
||||
|
||||
|
||||
Cb_User_Insert_Item_Leave_Func["宿命魂石"] <- function(args) {
|
||||
local SUser = User(NativePointer(args[0]).readPointer());
|
||||
local InvenObj = SUser.GetInven();
|
||||
local idx = args.pop();
|
||||
if (idx > 0) {
|
||||
local inven_item = InvenObj.GetSlot(1, idx);
|
||||
local item_id = inven_item.GetIndex();
|
||||
if (item_id >= 200625000 && item_id< 200626000) {
|
||||
local Ret = AddFatalismStone(SUser, item_id - 200625000);
|
||||
//删除原道具
|
||||
Timer.SetTimeOut(function() {
|
||||
inven_item.Delete();
|
||||
SUser.SendUpdateItemList(1, 0, idx);
|
||||
}, 100);
|
||||
//如果满了就发邮件
|
||||
if (!Ret) {
|
||||
local T = {};
|
||||
T.rawset(item_id, 1);
|
||||
SUser.SendMail(T, {
|
||||
Title = "系统",
|
||||
Text = "由于你的魂石包裹已满, 请留出足够的空间来接收道具."
|
||||
});
|
||||
}
|
||||
SUser.SendItemSpace(0);
|
||||
}
|
||||
}
|
||||
}.bindenv(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function RegisterDebugCmd() {
|
||||
Gm_InputFunc_Handle["给魂石"] <- function(SUser, CmdString) {
|
||||
local count = -1;
|
||||
local pos = 0;
|
||||
local handler = [];
|
||||
do {
|
||||
local start = pos;
|
||||
pos = CmdString.find(" ", pos + 1);
|
||||
if (pos != null) {
|
||||
handler.append(CmdString.slice(start + 1, pos));
|
||||
} else
|
||||
handler.append(CmdString.slice(start + 1));
|
||||
count = count + 1
|
||||
} while (pos != null)
|
||||
|
||||
//得到空格数量
|
||||
if (count == 1) {
|
||||
AddFatalismStone(SUser, handler[1].tointeger());
|
||||
}
|
||||
}.bindenv(this);
|
||||
}
|
||||
|
||||
function InitFatalismStoneData() {
|
||||
Script();
|
||||
FatalismStoneLst = {};
|
||||
ScriptData.GetFileData("fatalismstone/fatalismstone.lst", function(DataTable, Data) {
|
||||
while (!Data.Eof()) {
|
||||
local Id = Data.Get();
|
||||
local Path = Data.Get();
|
||||
FatalismStoneLst.rawset(Id, Path);
|
||||
}
|
||||
}.bindenv(this));
|
||||
}
|
||||
|
||||
function GetStoneData(Index) {
|
||||
if (FatalismStoneLst.rawin(Index)) {
|
||||
//还是路径就读取数据
|
||||
if (typeof FatalismStoneLst[Index] == "string") {
|
||||
FatalismStoneLst[Index] = ScriptData.GetFileData("fatalismstone/" + FatalismStoneLst[Index], function(DataTable, Data) {
|
||||
DataTable.Attribute <- {};
|
||||
while (!Data.Eof()) {
|
||||
local Key = Data.Get();
|
||||
if (Key == "[rarity]" || Key == "[stone type]" || Key == "[move wav]" || Key == "[front effect]" || Key == "[back effect]") {
|
||||
DataTable[Key.slice(1, -1)] <- Data.Get();
|
||||
} else if (Key == "[icon]") {
|
||||
DataTable.icon <- {
|
||||
img = Data.Get(),
|
||||
index = Data.Get()
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return FatalismStoneLst[Index];
|
||||
} else error("没有ID为: " + Index + " 的魂石数据!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//执行数据库命令
|
||||
function SelectSql(Sql, Type) {
|
||||
local SqlObj = MysqlPool.GetInstance().GetConnect();
|
||||
local Ret = SqlObj.Select(Sql, Type);
|
||||
//把连接还池子
|
||||
MysqlPool.GetInstance().PutConnect(SqlObj);
|
||||
return Ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ProjectInitFuncMap.P_FatalismStone <- FatalismStone();
|
||||
|
||||
print("文件加载!");
|
||||
1
_DPS_/_BuiltProject/宿命魂石/config
Normal file
1
_DPS_/_BuiltProject/宿命魂石/config
Normal file
@@ -0,0 +1 @@
|
||||
FatalismStone.nut
|
||||
Reference in New Issue
Block a user