保存标准
This commit is contained in:
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();
|
||||
Reference in New Issue
Block a user