/// <summary> /// Credits a player if they successfully kill another player during the Capture The Flag game. /// /// NOTE: If the <see cref="MySqlDatabase"/> is not loaded then the kill is not accumulated to the attackers total kill count. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="eventArgs">The arguments for when the player (or players) was/were reset.</param> private void OnPlayerReset(CaptureTheFlagBot ctfBot, PlayerResetEventArgs eventArgs) { if (eventArgs.PlayersReset.Count == 1) { Player killedPlayer = eventArgs.PlayersReset[0]; if (killedPlayer.LastAttacker != Player.None) { ctfBot.SendPrivateMessage(killedPlayer, $"You were killed by player {killedPlayer.LastAttacker.Username}!"); ctfBot.SendPrivateMessage(killedPlayer.LastAttacker, $"You killed player {killedPlayer.Username}!"); if (MySqlDatabase.Loaded) { PlayerData playerData = MySqlDatabase.GetRow(killedPlayer.LastAttacker.Username); if (playerData != null) { playerData.Statistics.TotalKills++; } } ctfBot.CurrentGameRound.IncreaseGameFund(GameFundIncreaseReason.PlayerKilledEnemy); } killedPlayer.LastAttacker = Player.None; } }
/// <summary> /// Handles the respawn system for the Capture The Flag game. The respawn system teleports a player to their respective respawn cooldown location, which depends on /// which team they are currently on. If a player is holding the flag and this method gets called, then the flag that they're holding is returned to its base. /// </summary> /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param> /// <param name="eventArgs">The arguments for when the player (or players) was/were reset.</param> private void OnPlayerReset(CaptureTheFlagBot ctfBot, PlayerResetEventArgs eventArgs) { if (!eventArgs.PropertiesReset) { foreach (Player player in eventArgs.PlayersReset) { if (player.HasEnemyFlag(ctfBot)) { Team enemyTeam = player.Team.GetOppositeTeam(); if (ctfBot.FlagSystem.Flags[enemyTeam].Holder == player) { ctfBot.SayChatMessage($"Player {player.Username} died while holding {enemyTeam.GetStringName()} teams flag."); ctfBot.FlagSystem.Flags[enemyTeam].Return(ctfBot, null, false); } ctfBot.RemoveEffects(player); } RespawnPlayer(ctfBot, player); } } }