This commit is contained in:
lenheart
2024-09-16 17:05:26 +08:00
commit 237bcf8719
53 changed files with 21032 additions and 0 deletions

View File

@@ -0,0 +1,670 @@
/*
文件名:ServerControl.nut
路径:Dps_A/ProjectClass/ServerControl/ServerControl.nut
创建日期:2024-05-01 16:24
文件用途:服务端核心类
*/
class ServerControl {
function Get_User_Item_Count(SUser, ItemId) {
local InvenObj = SUser.GetInven();
local SlotIdx = InvenObj.GetSlotById(ItemId);
if (SlotIdx != -1) {
local SlotItem = GetSlot(1, SlotIdx);
if (SlotItem) {
if (SlotItem.GetType() != "装备") {
return {
count = SlotItem.GetAdd_Info(),
soltidx = SlotIdx
};
}
}
}
return {
count = 0,
soltidx = 0
};
}
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 = [];
foreach(_index, Value in Jso.uidlist) {
local SUser = World.GetUserByUid(Value);
if (SUser) UserList.append(SUser);
else UserList.append(null);
}
foreach(_Index, SUser in UserList) {
if (SUser) {
Jso.uid <- SUser.GetUID();
Jso.cid <- SUser.GetCID();
Jso.op <- Jso.realop;
local Str = Json.Encode(Jso);
Str = removeBackslashes(Str);
local Pack = Packet();
Pack.Put_Header(1, 130);
Pack.Put_Byte(1);
Pack.Put_Int(Str.len());
Pack.Put_Binary(Str);
Pack.Finalize(true);
SUser.Send(Pack);
Pack.Delete();
// SUser.SendJso(Jso);
} else {
}
}
}.bindenv(this));
//给查询指定uid cid列表的玩家信息
GatewaySocketPackFuncMap.rawset(2023101902, function(Jso) {
local UserList = [];
foreach(_index, Value in Jso.uidlist) {
local SUser = World.GetUserByUid(Value);
if (SUser) UserList.append(SUser);
else UserList.append(null);
}
local UserInfo = [];
foreach(_Index, SUser in UserList) {
if (SUser) {
local T = {
uid = SUser.GetUID(),
cid = SUser.GetCID(),
//名字
name = SUser.GetCharacName(),
//基础职业
job = SUser.GetCharacJob(),
//转职职业
growjob = SUser.GetCharacSecondGrowType(),
//觉醒职业
Secondjob = SUser.GetCharacSecondGrowType(),
//等级
level = SUser.GetCharacLevel(),
//使用了多少疲劳
fatigue = SUser.GetFatigue(),
//总疲劳
maxfatigue = SUser.GetMaxFatigue(),
//是否是GM
isgm = SUser.IsGmMode(),
//点券
cera = SUser.GetCera(),
//代币
cerapoint = SUser.GetCeraPoint(),
//胜点
winpoint = SUser.GetWinPoint(),
};
UserInfo.append(T);
} else {
UserInfo.append(null);
}
}
Jso.op = Jso.realop;
Jso.userinfo <- UserInfo;
Socket.SendGateway(Jso);
});
//将玩家移出副本
GatewaySocketPackFuncMap.rawset(20240420, function(Jso) {
local UserList = [];
foreach(_index, Value in Jso.uidlist) {
local SUser = World.GetUserByUid(Value);
if (SUser) UserList.append(SUser);
else UserList.append(null);
}
foreach(_Index, SUser in UserList) {
if (SUser) {
SUser.GiveupDgn();
}
}
});
//设置服务器最大等级
GatewaySocketPackFuncMap.rawset(2023110800, function(Jso) {
Cb_user_setusermaxlevel_Level <- Jso.level;
});
//将玩家移出队伍
GatewaySocketPackFuncMap.rawset(20240418, function(Jso) {
local UserList = [];
foreach(_index, Value in Jso.uidlist) {
local SUser = World.GetUserByUid(Value);
if (SUser) UserList.append(SUser);
else UserList.append(null);
}
foreach(_Index, SUser in UserList) {
if (SUser) {
SUser.LeaveParty();
}
}
});
//给注册玩家使用道具回调
GatewaySocketPackFuncMap.rawset(2023110702, function(Jso) {
local ItemId = Jso.ItemId;
local RealOp = Jso.realop;
Cb_Use_Item_Sp_Func[ItemId] <- function(SUser, ItemId) {
local T = {
op = RealOp,
uid = SUser.GetUID(),
cid = SUser.GetCID()
};
Socket.SendGateway(T);
}
});
//查询玩家背包里的某个道具
GatewaySocketPackFuncMap.rawset(2023100802, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
local ItemId = Jso.itemid;
if (SUser) {
//获取背包对象
local InvenObj = SUser.GetInven();
local SlotIdx = InvenObj.GetSlotById(ItemId);
if (SlotIdx != -1) {
local SlotItem = InvenObj.GetSlot(1, SlotIdx);
if (SlotItem) {
local Count = 1;
if (SlotItem.GetType() != "装备") {
Count = SlotItem.GetAdd_Info();
}
Jso.Count <- Count;
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
return;
}
}
}
Jso.Count <- 0;
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
});
//给指定玩家下发道具
GatewaySocketPackFuncMap.rawset(2023100804, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
if (SUser) {
local GiveTable = [];
foreach(_a, v in Jso.result) {
//点券
if (v.item == -1) {
SUser.RechargeCera(v.num);
SUser.SendItemSpace(0);
continue;
}
//代币券
else if (v.item == -2) {
SUser.RechargeCeraPoint(v.num);
SUser.SendItemSpace(0);
continue;
}
//金币
else if (v.item == 0) {
SUser.RechargeMoney(v.num);
SUser.SendItemSpace(0);
continue;
}
GiveTable.append({
id = v.item,
count = v.num
});
}
SUser.GiveItemEx(GiveTable);
}
});
//给指定队伍设置复活币数量
GatewaySocketPackFuncMap.rawset(20240804, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
if (SUser) {
local PartyObj = SUser.GetParty();
if (PartyObj) {
PartyObj.SetPartyMemberCoinLimit(Jso.count);
}
}
});
//查询指定玩家所在队伍的队长cid
GatewaySocketPackFuncMap.rawset(20240722, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
local PartyObj = SUser.GetParty();
if (PartyObj) {
Jso.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
Jso.PartyPlayer.append(SUserB.GetCID());
}
}
local Master = PartyObj.GetMaster();
if (Master) {
Jso.Master <- Master.GetCID();
}
}
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
});
//给指定玩家扣除道具
GatewaySocketPackFuncMap.rawset(2023100806, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
if (SUser) {
//获取背包对象
local InvenObj = SUser.GetInven();
InvenObj.DeleteItemCount(Jso.itemid, Jso.itemcount);
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
}
});
//给指定玩家扣除道具 并且会返回是否成功的
GatewaySocketPackFuncMap.rawset(2023100810, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
if (SUser) {
//获取背包对象
local InvenObj = SUser.GetInven();
Jso.DeleteFlag <- InvenObj.DeleteItemCount(Jso.itemid, Jso.itemcount);
} else {
Jso.DeleteFlag <- false;
}
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
});
//给指定玩家列表扣除道具
GatewaySocketPackFuncMap.rawset(2023100808, function(Jso) {
local Flag = true;
foreach(uid in Jso.uidlist) {
local SUser = World.GetUserByUid(uid);
if (SUser) {
//获取背包对象
local InvenObj = SUser.GetInven();
local FlagBuf = InvenObj.CheckArrItemCount([{
Id = Jso.itemid,
Count = Jso.itemcount
}]);
if (!FlagBuf) Flag = false;
Jso.Loser <- uid;
} else {
Flag = false;
}
}
if (Flag) {
foreach(uid in Jso.uidlist) {
local SUser = World.GetUserByUid(uid);
local InvenObj = SUser.GetInven();
InvenObj.DeleteItemCount(Jso.itemid, Jso.itemcount);
}
Jso.DeleteFlag <- true;
} else {
Jso.DeleteFlag <- false;
}
Jso.op = Jso.realop;
Socket.SendGateway(Jso);
});
//公告包
GatewaySocketPackFuncMap.rawset(2023082102, function(Jso) {
World.SendNotiPacketMessage(Jso.str, Jso.type);
});
//单人公告包
GatewaySocketPackFuncMap.rawset(2024012700, function(Jso) {
local UID = Jso.uid;
local CID = Jso.cid;
local SUser = World.GetUserByUidCid(UID, CID);
if (SUser) {
SUser.SendNotiPacketMessage(Jso.str, Jso.type);
}
});
//玩家进入副本
Cb_History_DungeonEnter_Func["RindroGoDgn"] <- function(SUser, Data) {
local PartyObj = SUser.GetParty();
if (PartyObj) {
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
if (DgnObj) {
local Dungeon_Id = DgnObj.GetId();
local Dungeon_Name = DgnObj.GetName();
local Dungeon_Level = DgnObj.GetMinLevel();
local Hell_Info = Bfobj.GetHellDifficulty();
local UserArr = [];
PartyObj.ForeachMember(function(SUser, Pos) {
UserArr.append({
PUID = SUser.GetUID(),
PCID = SUser.GetCID(),
PNAME = SUser.GetCharacName(),
PLEVEL = SUser.GetCharacLevel(),
});
})
local T = {
op = 25001039,
PDungeon_Id = Dungeon_Id,
PDungeon_Name = Dungeon_Name,
PDungeon_Level = Dungeon_Level,
PHell_Info = Hell_Info,
RESULT = UserArr
}
Socket.SendGateway(T);
}
}
}
//给注册玩家通关副本
GatewaySocketPackFuncMap.rawset(2023110704, function(Jso) {
local RealOp = Jso.realop;
Cb_BossDie_Func[RealOp] <- function(SUser) {
local PartyObj = SUser.GetParty();
if (PartyObj) {
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
if (DgnObj) {
local Dungeon_Id = DgnObj.GetId();
local Dungeon_Name = DgnObj.GetName();
local Dungeon_Level = DgnObj.GetMinLevel();
local UserArr = [];
PartyObj.ForeachMember(function(SUser, Pos) {
UserArr.append({
PUID = SUser.GetUID(),
PCID = SUser.GetCID(),
PNAME = SUser.GetCharacName(),
PLEVEL = SUser.GetCharacLevel(),
});
})
local T = {
op = RealOp,
PDungeon_Id = Dungeon_Id,
PDungeon_Name = Dungeon_Name,
PDungeon_Level = Dungeon_Level,
RESULT = UserArr
}
Socket.SendGateway(T);
}
}
}
});
//离开副本
Cb_History_DungeonLeave_Func["Rindro_DungeonLeave"] <- function(SUser, Data) {
local T = {
op = 25001003,
cid = SUser.GetCID(),
uid = SUser.GetUID()
};
local PartyObj = SUser.GetParty();
if (PartyObj) {
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
if (DgnObj) {
T.dgnid <- DgnObj.GetId();
T.dgnname <- DgnObj.GetName();
T.dgnminlevel <- DgnObj.GetMinLevel();
}
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
}
Socket.SendGateway(T);
}
//返回选择角色
Cb_return_select_character_Func["Rindro_return_select_character"] <- function(SUser) {
local T = {
op = 25001005,
cid = SUser.GetCID(),
uid = SUser.GetUID()
};
Socket.SendGateway(T);
}
//下线
Cb_player_exit_Func["Rindro_player_exit"] <- function(SUser) {
local T = {
op = 25001007,
cid = SUser.GetCID(),
uid = SUser.GetUID()
};
Socket.SendGateway(T);
}
//放弃副本
Cb_giveup_dgn_Func["Rindro_player_exit"] <- function(SUser) {
local T = {
op = 25001009,
cid = SUser.GetCID(),
uid = SUser.GetUID()
};
local PartyObj = SUser.GetParty();
if (PartyObj) {
local Bfobj = PartyObj.GetBattleField();
local DgnObj = Bfobj.GetDgn();
if (DgnObj) {
T.dgnid <- DgnObj.GetId();
T.dgnname <- DgnObj.GetName();
T.dgnminlevel <- DgnObj.GetMinLevel();
}
}
Socket.SendGateway(T);
}
//玩家上线
Cb_reach_game_world_Func["Rindro_player_reach_game_world"] <- function(SUser) {
local T = {
op = 25001011,
cid = SUser.GetCID(),
uid = SUser.GetUID(),
config = Sq_Game_GetConfig()
};
Socket.SendGateway(T);
}
//组队HOOK包 加入或者邀请
Cb_User_Party_Create_Func["Rindro_player_User_Party_Create"] <- function(SUser) {
local T = {
op = 25001023,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
local PartyObj = SUser.GetParty();
if (PartyObj) {
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
}
Socket.SendGateway(T);
return true;
}
Cb_History_PCoinDown_Func["Rindro_PCoinDown"] <- function(SUser, Data) {
if (SUser) {
local T = {
op = 25001035,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
Socket.SendGateway(T);
}
}
//组队HOOK包 同意加入或者同意申请
Cb_User_Party_Agree_Func["Rindro_player_User_Party_Agree"] <- function(SUser) {
local T = {
op = 25001025,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
local PartyObj = SUser.GetParty();
if (PartyObj) {
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
local Master = PartyObj.GetMaster();
if (Master) {
T.Master <- Master.GetCID();
}
}
Socket.SendGateway(T);
return true;
}
//组队HOOK包 退出队伍
Cb_User_Party_Exit_Func["Rindro_player_User_Party_Exit"] <- function(SUser) {
local T = {
op = 25001027,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
local PartyObj = SUser.GetParty();
if (PartyObj) {
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
local Master = PartyObj.GetMaster();
if (Master) {
T.Master <- Master.GetCID();
}
}
Socket.SendGateway(T);
return true;
}
//组队HOOK包 委任队长
Cb_User_Party_GiveMaster_Func["Rindro_player_User_Party_GiveMaster"] <- function(SUser) {
local T = {
op = 25001029,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
local PartyObj = SUser.GetParty();
if (PartyObj) {
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
local Master = PartyObj.GetMaster();
if (Master) {
T.Master <- Master.GetCID();
}
}
Socket.SendGateway(T);
return true;
}
//组队HOOK包 踢出队伍
Cb_User_Party_Kick_Func["Rindro_player_User_Party_GiveMaster"] <- function(SUser) {
local T = {
op = 25001031,
uid = SUser.GetUID(),
cid = SUser.GetCID(),
}
local PartyObj = SUser.GetParty();
if (PartyObj) {
T.PartyPlayer <- [];
for (local i = 0; i< 4; i++) {
local SUserB = PartyObj.GetUser(i);
if (SUserB) {
T.PartyPlayer.append(SUserB.GetCID());
}
}
local Master = PartyObj.GetMaster();
if (Master) {
T.Master <- Master.GetCID();
}
}
Socket.SendGateway(T);
return true;
}
//角色上线包
//上线HOOK
// Cb_History_IPUp_Func.ServerControl <- function(UID, CID, Data) {
// local T = {
// op = 25001017,
// cid = UID,
// uid = CID,
// };
// Socket.SendGateway(T);
// };
//副本清除
Cb_History_DungeonClearInfo_Func.ServerControl <- function(SUser, Data) {
local PartyObj = SUser.GetParty();
if (PartyObj) {
local T = {
op = 25001019,
cid = SUser.GetCID(),
uid = SUser.GetUID(),
state = PartyObj.Get_Dgn_Clear_State()
};
Socket.SendGateway(T);
}
};
}
}
ProjectInitFuncMap.P_ServerControl <- ServerControl();

View File

@@ -0,0 +1,233 @@
/*
文件名:AntonClass.nut
路径:Dps_A/ProjectClass/Anton/AntonClass.nut
创建日期:2024-07-15 20:46
文件用途:安图恩服务的文件
*/
class Anton {
//频道
Channel = 18;
//城镇
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("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 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 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
//注册收包
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();

View File

@@ -0,0 +1,35 @@
/*
文件名: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();

View File

@@ -0,0 +1,240 @@
/*
文件名: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) {
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 {
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 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;
if (Type == -1) {
Jso.Name <- SUserName;
foreach(_Index, Value in RealList) {
local SendObj = Value;
SendObj.SendJso(Jso);
}
} else {
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
//注册收包
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();