/// <summary> /// Handle a bot kill command to kill the bots /// </summary> /// <param name="sender">Sending object</param> /// <param name="listEvent"></param> internal void HandleBotKillEvent(object sender, BotKillEvent listEvent) { // Send the response message to the bot BotInstance sourceBot = (sender as BotInstance); // Make sure the bot is not a public arena bot if ((sourceBot.Settings.SessionSettings.InitialArena.Length > 0) || (listEvent.Message.Equals("!forcekill"))) { // close the bot sourceBot.Close(); // Create a fresh new bot instance BotInstance newBot = new BotInstance(sourceBot.Settings); newBot.CoreEventManager += (new BotEvent(HandleCoreEvents)); // Add the bot to the available list m_availableBots.Add(newBot.Settings.SessionSettings.UserName.ToUpper(), newBot); // Remove the bot from the active list m_activeBots.Remove(sourceBot.Settings.SessionSettings.UserName.ToUpper()); } else { // Create the chat response packet ChatEvent response = new ChatEvent(); // Set the player Identifier to reply to response.PlayerId = listEvent.PlayerId; response.ChatType = ChatTypes.Private; response.Message = "ERROR: unable to !kill bots in public arena!"; sourceBot.SendGameEvent(response); } }
/// <summary> /// Handle the kill bot command. /// </summary> /// <param name="chatEvent"></param> private void HandleKillCommand(ChatEvent chatEvent) { // The kill command can only be sent privately if (chatEvent.ChatType == ChatTypes.Private) { // Create the bot spawn event BotKillEvent killEvent = new BotKillEvent(); try { // parse the spawn parameters from the message killEvent.PlayerId = chatEvent.PlayerId; killEvent.Message = chatEvent.Message; // Send the spawn event to the core handler m_core.OnCoreEvent(this, killEvent); } catch (Exception e) { // Create the chat response message ChatPacket response = new ChatPacket(); // Set the response message information response.Event.PlayerId = chatEvent.PlayerId; response.Event.ChatType = ChatTypes.Private; // Set the response message response.Event.Message = e.Message; // Send the exception message to the player m_session.TransmitPacket(response); } } }