| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  | /* | 
					
						
							|  |  |  |  | 文件名: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); | 
					
						
							| 
									
										
										
										
											2025-03-27 20:21:11 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  |         //安图恩频道 | 
					
						
							|  |  |  |  |         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; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 20:21:11 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     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; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  |     //玩家消息分发 | 
					
						
							|  |  |  |  |     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; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-27 20:21:11 +08:00
										 |  |  |  |         Jso.msg = Jso.msg; | 
					
						
							| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  |         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); //区域移动 | 
					
						
							| 
									
										
										
										
											2025-03-27 20:21:11 +08:00
										 |  |  |  |         //Base_InputHookFunc_Handle.Anton <- base_input_hook.bindenv(this); //玩家发送消息 | 
					
						
							| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  |         Cb_reach_game_world_Func.Anton <- Login_Hook.bindenv(this); //上线HOOK | 
					
						
							| 
									
										
										
										
											2025-03-27 20:21:11 +08:00
										 |  |  |  |         Cb_Server_Chat_Log_Leave_Func.Anton <- base_input_hook2.bindenv(this); //玩家发送消息 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-16 17:05:26 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         //注册收包 | 
					
						
							|  |  |  |  |         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(); |