/// <summary> /// Handles the declaration of death from a client /// </summary> static public void Handle_CS_PlayerDeath(CS_VehicleDeath pkt, Player player) { if (player == null) { Log.write(TLog.Error, "Handle_CS_PlayerDeath(): Called with null player."); return; } //Allow the player's arena to handle it if (player._arena == null) { Log.write(TLog.Error, "Handle_CS_PlayerDeath(): Player {0} sent death packet with no arena.", player); return; } player._arena.handleEvent(delegate(Arena arena) { if (arena == null) { Log.write(TLog.Error, "Handle_CS_PlayerDeath(): Player {0} sent update packet with no delegating arena.", player); return; } player._arena.handlePlayerDeath(player, pkt); } ); }
/// <summary> /// Calculates and distributes rewards for a turret kill /// </summary> static public void calculateTurretKillRewards(Player victim, Computer comp, CS_VehicleDeath update) { //Does it have a valid owner? Player owner = comp._creator; if (owner == null) { return; } //Calculate kill reward for the turret owner CfgInfo cfg = victim._server._zoneConfig; int killerCash = (int)(cfg.cash.killReward + (victim.Bounty * (((float)cfg.cash.percentOfTarget) / 1000))); int killerExp = (int)(cfg.experience.killReward + (victim.Bounty * (((float)cfg.experience.percentOfTarget) / 1000))); int killerPoints = (int)(cfg.point.killReward + (victim.Bounty * (((float)cfg.point.percentOfTarget) / 1000))); int rewardCash = (int)(killerCash * (((float)cfg.arena.turretCashSharePercent) / 1000)); int rewardExp = (int)(killerExp * (((float)cfg.arena.turretExperienceSharePercent) / 1000)); int rewardPoints = (int)(killerPoints * (((float)cfg.arena.turretPointsSharePercent) / 1000)); //Update his stats owner.Cash += rewardCash; owner.KillPoints += rewardExp; owner.Experience += rewardPoints; //Is our creator still on the same team? if (owner._team == comp._team) { //Are we sharing kills to our owner? if (cfg.arena.turretKillShareOwner) { owner.Kills++; } //Show the message owner.triggerMessage(2, 500, String.Format("Turret Kill: Kills=1 (Points={0} Exp={1} Cash={2})", rewardCash, rewardExp, rewardPoints)); } //Route to the rest of the arena Helpers.Player_RouteKill(victim._arena.Players, update, victim, rewardCash, rewardPoints, 0, rewardExp); }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { return(true); }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { if (killer == null) { return(true); } //Was it a player kill? if (killType == Helpers.KillType.Player) { //No team killing! if (victim._team != killer._team) { //Does the killer have an HQ? if (_hqs[killer._team] != null) { //Reward his HQ! (Victims bounty + half of own) _hqs[killer._team].Bounty += victim.Bounty + (killer.Bounty / 2); } } //Find out if KOTH is running if (_activeCrowns.Count == 0 || killer == null) { return(true); } //Handle crowns if (_playerCrownStatus.ContainsKey(victim) && _playerCrownStatus[victim].crown) { //Incr crownDeaths _playerCrownStatus[victim].crownDeaths++; if (_playerCrownStatus[victim].crownDeaths >= _config.king.deathCount) { //Take it away now _playerCrownStatus[victim].crown = false; _noCrowns.Remove(victim); Helpers.Player_Crowns(_arena, false, _noCrowns); } if (_playerCrownStatus.ContainsKey(killer)) { if (!_playerCrownStatus[killer].crown) { _playerCrownStatus[killer].crownKills++; } } } //Reset their timer if (_playerCrownStatus.ContainsKey(killer)) { if (_playerCrownStatus[killer].crown) { updateCrownTime(killer); } else if (_config.king.crownRecoverKills != 0) { //Should they get a crown? if (_playerCrownStatus[killer].crownKills >= _config.king.crownRecoverKills) { _playerCrownStatus[killer].crown = true; giveCrown(killer); } } } } //Was it a computer kill? if (killType == Helpers.KillType.Computer) { //Let's find the vehicle! Computer cvehicle = victim._arena.Vehicles.FirstOrDefault(v => v._id == update.killerPlayerID) as Computer; Player vehKiller = cvehicle._creator; //Do they exist? if (cvehicle != null && vehKiller != null) { //We'll take it from here... update.type = Helpers.KillType.Player; update.killerPlayerID = vehKiller._id; //Don't reward for teamkills if (vehKiller._team == victim._team) { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedTeam); } else { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedEnemy); } //Increase stats/HQ bounty and notify arena of the kill! if (_hqs[vehKiller._team] != null) { //Reward his HQ! (Victims bounty + half of own) _hqs[vehKiller._team].Bounty += victim.Bounty + (vehKiller.Bounty / 2); } vehKiller.Kills++; victim.Deaths++; Logic_Rewards.calculatePlayerKillRewards(victim, vehKiller, update); return(false); } } return(true); }
/// <summary> /// Calculates and distributes rewards for a player kill /// </summary> static public void calculatePlayerKillRewards(Player victim, Player killer, CS_VehicleDeath update) { CfgInfo cfg = victim._server._zoneConfig; int killerCash = 0; int killerExp = 0; int killerPoints = 0; if (killer._team != victim._team) { //Calculate kill reward for killer // List<Player> carriers = new List<Player>(); // carriers = killer._arena._flags.Values.Where(flag => flag.carrier == killer).Select(flag => flag.carrier).ToList(); killerCash = (int)(cfg.cash.killReward + (victim.Bounty * (((float)cfg.cash.percentOfTarget) / 1000)) + (killer.Bounty * (((float)cfg.cash.percentOfKiller) / 1000))); killerExp = (int)(cfg.experience.killReward + (victim.Bounty * (((float)cfg.experience.percentOfTarget) / 1000)) + (killer.Bounty * (((float)cfg.experience.percentOfKiller) / 1000))); killerPoints = (int)(cfg.point.killReward + (victim.Bounty * (((float)cfg.point.percentOfTarget) / 1000)) + (killer.Bounty * (((float)cfg.point.percentOfKiller) / 1000))); /* if (carriers.Contains(killer)) * { * killerCash *= cfg.flag.cashMultiplier / 1000; * killerExp *= cfg.flag.experienceMultiplier / 1000; * killerPoints *= cfg.flag.pointMultiplier / 1000; * * } */ } else { foreach (Player p in victim._arena.Players) { Helpers.Player_RouteKill(p, update, victim, 0, 0, 0, 0); } return; } //Inform the killer Helpers.Player_RouteKill(killer, update, victim, killerCash, killerPoints, killerPoints, killerExp); //Update some statistics killer.Cash += killerCash; killer.Experience += killerExp; killer.KillPoints += killerPoints; victim.DeathPoints += killerPoints; //Update his bounty killer.Bounty += (int)((cfg.bounty.fixedToKillerBounty / 1000) + (killerPoints * (((float)cfg.bounty.percentToKillerBounty) / 1000))); //Check for players in the share radius List <Player> sharedCash = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.cash.shareRadius); List <Player> sharedExp = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.experience.shareRadius); List <Player> sharedPoints = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.point.shareRadius); Dictionary <int, int> cashRewards = new Dictionary <int, int>(); Dictionary <int, int> expRewards = new Dictionary <int, int>(); Dictionary <int, int> pointRewards = new Dictionary <int, int>(); //Set up our shared math int CashShare = (int)((((float)killerCash) / 1000) * cfg.cash.sharePercent); int ExpShare = (int)((((float)killerExp) / 1000) * cfg.experience.sharePercent); int PointsShare = (int)((((float)killerPoints) / 1000) * cfg.point.sharePercent); int BtyShare = (int)((killerPoints * (((float)cfg.bounty.percentToAssistBounty) / 1000))); foreach (Player p in sharedCash) { if (p == killer || p._team != killer._team) { continue; } cashRewards[p._id] = CashShare; expRewards[p._id] = 0; pointRewards[p._id] = 0; } foreach (Player p in sharedExp) { if (p == killer || p._team != killer._team) { continue; } expRewards[p._id] = ExpShare; if (!cashRewards.ContainsKey(p._id)) { cashRewards[p._id] = 0; } if (!pointRewards.ContainsKey(p._id)) { pointRewards[p._id] = 0; } } foreach (Player p in sharedPoints) { if (p == killer || p._team != killer._team) { continue; } pointRewards[p._id] = PointsShare; if (!cashRewards.ContainsKey(p._id)) { cashRewards[p._id] = 0; } if (!expRewards.ContainsKey(p._id)) { expRewards[p._id] = 0; } //Share bounty within the experience radius, Dunno if there is a sharebounty radius? p.Bounty += BtyShare; } //Sent reward notices to our lucky witnesses List <int> sentTo = new List <int>(); foreach (Player p in sharedCash) { if (p == killer || p._team != killer._team) { continue; } Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); p.Cash += cashRewards[p._id]; p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; sentTo.Add(p._id); } foreach (Player p in sharedExp) { if (p == killer || p._team != killer._team) { continue; } if (!sentTo.Contains(p._id)) { Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); p.Cash += cashRewards[p._id]; p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; sentTo.Add(p._id); } } foreach (Player p in sharedPoints) { if (p == killer || p._team != killer._team) { continue; } if (!sentTo.Contains(p._id)) { //Update the assist bounty p.Bounty += BtyShare; Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); p.Cash += cashRewards[p._id]; p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; sentTo.Add(p._id); } } //Shared kills anyone? Vehicle sharedveh = killer._occupiedVehicle; //are we in a vehicle? if (sharedveh != null) { //Was this a child vehicle? If so, re-route us to the parent if (sharedveh._parent != null) { sharedveh = sharedveh._parent; } //Can we even share kills? if (sharedveh._type.SiblingKillsShared > 0) { //Yep! //Does this vehicle have any childs? if (sharedveh._childs.Count > 0) { //Cycle through each child and reward them foreach (Vehicle child in sharedveh._childs) { //Anyone home? if (child._inhabitant == null) { continue; } //Can we share? if (child._type.SiblingKillsShared == 0) { continue; } //Skip our killer if (child._inhabitant == killer) { continue; } //Give them a kill! child._inhabitant.Kills++; //Show the message child._inhabitant.triggerMessage(2, 500, String.Format("Sibling Assist: Kills=1 (Points={0} Exp={1} Cash={2})", CashShare, ExpShare, PointsShare)); } } } } //Route the kill to the rest of the arena foreach (Player p in victim._arena.Players.ToList()) { //As long as we haven't already declared it, send if (p == null) { continue; } if (p == killer) { continue; } if (sentTo.Contains(p._id)) { continue; } Helpers.Player_RouteKill(p, update, victim, 0, killerPoints, 0, 0); } }
static public void calculatePlayerKillRewards(Player victim, Player killer, Settings.GameTypes gameType) { CfgInfo cfg = victim._server._zoneConfig; int killerBounty = 0; int killerBountyIncrease = 0; int victimBounty = 0; int killerCash = 0; int killerExp = 0; int killerPoints = 0; //Fake it to make it CS_VehicleDeath update = new CS_VehicleDeath(0, new byte[0], 0, 0); update.killedID = victim._id; update.killerPlayerID = killer._id; update.positionX = victim._state.positionX; update.positionY = victim._state.positionY; update.type = Helpers.KillType.Player; if (killer._team != victim._team) { killerBounty = Convert.ToInt32(((double)killer.Bounty / 100) * Settings.c_percentOfOwn); killerBountyIncrease = Convert.ToInt32(((double)killer.Bounty / 100) * Settings.c_percentOfOwnIncrease); victimBounty = Convert.ToInt32(((double)victim.Bounty / 100) * Settings.c_percentOfVictim); killerPoints = Convert.ToInt32((Settings.c_baseReward + killerBounty + victimBounty) * Settings.c_pointMultiplier); killerCash = Convert.ToInt32((Settings.c_baseReward + killerBounty + victimBounty) * Settings.c_cashMultiplier); killerExp = Convert.ToInt32((Settings.c_baseReward + killerBounty + victimBounty) * Settings.c_expMultiplier); } else { foreach (Player p in victim._arena.Players) { Helpers.Player_RouteKill(p, update, victim, 0, 0, 0, 0); } return; } //Inform the killer Helpers.Player_RouteKill(killer, update, victim, killerCash, killerPoints, killerPoints, killerExp); //Update some statistics killerCash = addCash(killer, killerCash, gameType); killer.Experience += killerExp; killer.KillPoints += killerPoints; victim.DeathPoints += killerPoints; //Update his bounty killer.Bounty += (killerBountyIncrease + victimBounty); //Check for players in the share radius List <Player> sharedCash = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.cash.shareRadius).Where(p => p._baseVehicle._type.Name.Contains("Medic")).ToList(); List <Player> sharedExp = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.experience.shareRadius).Where(p => p._baseVehicle._type.Name.Contains("Medic")).ToList(); List <Player> sharedPoints = victim._arena.getPlayersInRange(update.positionX, update.positionY, cfg.point.shareRadius).Where(p => p._baseVehicle._type.Name.Contains("Medic")).ToList(); Dictionary <int, int> cashRewards = new Dictionary <int, int>(); Dictionary <int, int> expRewards = new Dictionary <int, int>(); Dictionary <int, int> pointRewards = new Dictionary <int, int>(); //Set up our shared math int CashShare = (int)((((float)killerCash) / 1000) * cfg.cash.sharePercent); int ExpShare = (int)((((float)killerExp) / 1000) * cfg.experience.sharePercent); int PointsShare = (int)((((float)killerPoints) / 1000) * cfg.point.sharePercent); int BtyShare = (int)((killerPoints * (((float)cfg.bounty.percentToAssistBounty) / 1000))); foreach (Player p in sharedCash) { if (p == killer || p._team != killer._team) { continue; } cashRewards[p._id] = CashShare; expRewards[p._id] = 0; pointRewards[p._id] = 0; } foreach (Player p in sharedExp) { if (p == killer || p._team != killer._team) { continue; } expRewards[p._id] = ExpShare; if (!cashRewards.ContainsKey(p._id)) { cashRewards[p._id] = 0; } if (!pointRewards.ContainsKey(p._id)) { pointRewards[p._id] = 0; } } foreach (Player p in sharedPoints) { if (p == killer || p._team != killer._team) { continue; } pointRewards[p._id] = PointsShare; if (!cashRewards.ContainsKey(p._id)) { cashRewards[p._id] = 0; } if (!expRewards.ContainsKey(p._id)) { expRewards[p._id] = 0; } //Share bounty within the experience radius, Dunno if there is a sharebounty radius? p.Bounty += BtyShare; } //Sent reward notices to our lucky witnesses List <int> sentTo = new List <int>(); foreach (Player p in sharedCash) { if (p == killer || p._team != killer._team) { continue; } cashRewards[p._id] = addCash(p, cashRewards[p._id], gameType); p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); sentTo.Add(p._id); } foreach (Player p in sharedExp) { if (p == killer || p._team != killer._team) { continue; } if (!sentTo.Contains(p._id)) { cashRewards[p._id] = addCash(p, cashRewards[p._id], gameType); p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); sentTo.Add(p._id); } } foreach (Player p in sharedPoints) { if (p == killer || p._team != killer._team) { continue; } if (!sentTo.Contains(p._id)) { //Update the assist bounty p.Bounty += BtyShare; cashRewards[p._id] = addCash(p, cashRewards[p._id], gameType); p.Experience += expRewards[p._id]; p.AssistPoints += pointRewards[p._id]; Helpers.Player_RouteKill(p, update, victim, cashRewards[p._id], killerPoints, pointRewards[p._id], expRewards[p._id]); sentTo.Add(p._id); } } //Shared kills anyone? Vehicle sharedveh = killer._occupiedVehicle; //are we in a vehicle? if (sharedveh != null) { //Was this a child vehicle? If so, re-route us to the parent if (sharedveh._parent != null) { sharedveh = sharedveh._parent; } //Can we even share kills? if (sharedveh._type.SiblingKillsShared > 0) { //Yep! //Does this vehicle have any childs? if (sharedveh._childs.Count > 0) { //Cycle through each child and reward them foreach (Vehicle child in sharedveh._childs) { //Anyone home? if (child._inhabitant == null) { continue; } //Can we share? if (child._type.SiblingKillsShared == 0) { continue; } //Skip our killer if (child._inhabitant == killer) { continue; } //Give them a kill! child._inhabitant.Kills++; //Show the message child._inhabitant.triggerMessage(2, 500, String.Format("Sibling Assist: Kills=1 (Points={0} Exp={1} Cash={2})", CashShare, ExpShare, PointsShare)); } } } } //Route the kill to the rest of the arena foreach (Player p in victim._arena.Players.ToList()) { //As long as we haven't already declared it, send if (p == null) { continue; } if (p == killer) { continue; } if (sentTo.Contains(p._id)) { continue; } Helpers.Player_RouteKill(p, update, victim, 0, killerPoints, 0, 0); } }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { if (gameState != GameState.ActiveGame) { return(true); } //Update our kill counter UpdateDeath(victim, killer); return(true); }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { //Respawn flag where it was initially spawn if a marine died carrying one try { _arena.flagResetPlayer(victim); } catch (Exception e) { Log.write(TLog.Exception, "exception in flagResetPlayer(victim):: '{0}'", e); } //Was it a computer kill? if (killType == Helpers.KillType.Computer) { //Let's find the vehicle! Computer cvehicle = victim._arena.Vehicles.FirstOrDefault(v => v._id == update.killerPlayerID) as Computer; Player vehKiller = cvehicle._creator; //Does it exist? if (cvehicle != null && vehKiller != null) { //We'll take it from here... update.type = Helpers.KillType.Player; update.killerPlayerID = vehKiller._id; //Don't reward for teamkills if (vehKiller._team == victim._team) { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedTeam); } else { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedEnemy); } //Increase stats and notify arena of the kill! vehKiller.Kills++; victim.Deaths++; Logic_Rewards.calculatePlayerKillRewards(victim, vehKiller, update); return(false); } } return(true); }
public void playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { }
/// <summary> /// Triggered when a player has sent a death packet /// </summary> public virtual void handlePlayerDeath(Player from, CS_VehicleDeath update) { }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { //Was it a player kill? if (killType == Helpers.KillType.Player) { //No team killing! if (victim._team != killer._team) { //Does the killer have an HQ? if (_hqs[killer._team] != null) { //Reward his HQ! (Victims bounty + half of own) _hqs[killer._team].Bounty += victim.Bounty + (killer.Bounty / 2); } } } //Was it a computer kill? if (killType == Helpers.KillType.Computer) { //Let's find the vehicle! Computer cvehicle = victim._arena.Vehicles.FirstOrDefault(v => v._id == update.killerPlayerID) as Computer; Player vehKiller = cvehicle._creator; //Do they exist? if (cvehicle != null && vehKiller != null) { //We'll take it from here... update.type = Helpers.KillType.Player; update.killerPlayerID = vehKiller._id; //Don't reward for teamkills if (vehKiller._team == victim._team) { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedTeam); } else { Logic_Assets.RunEvent(vehKiller, _arena._server._zoneConfig.EventInfo.killedEnemy); } //Increase stats/HQ bounty and notify arena of the kill! if (_hqs[vehKiller._team] != null) { //Reward his HQ! (Victims bounty + half of own) _hqs[vehKiller._team].Bounty += victim.Bounty + (vehKiller.Bounty / 2); } vehKiller.Kills++; victim.Deaths++; Logic_Rewards.calculatePlayerKillRewards(victim, vehKiller, update); return(false); } } return(true); }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { //Resets the flag to where the player picked up the flag //_arena.flagResetPlayer(victim); return(true); }
public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { //Calculate rewards AGAIN if double exp if (doubleXP == 2 && killer != null) { Logic_Rewards.calculatePlayerKillRewards(victim, killer, update); } return(true); }
/// <summary> /// Triggered when a player has died, by any means /// </summary> /// <remarks>killer may be null if it wasn't a player kill</remarks> public bool playerDeath(Player victim, Player killer, Helpers.KillType killType, CS_VehicleDeath update) { if (victim._team == _red || victim._team == _blue) { return(true); } if (_arena._bGameRunning) { if (killer == null) { _arena.sendArenaMessage(String.Format("{0} has been knocked out of the Tournament by the storm.", victim._alias)); } else if (killer._alias == victim._alias) { _arena.sendArenaMessage(String.Format("{0} has been knocked out of the Tournament by the storm.", victim._alias)); } else { _arena.sendArenaMessage(String.Format("{0} has been knocked out of the Tournament by {1}.", victim._alias, killer._alias)); } victim.sendMessage(0, "You've been knocked out of the tournament, You may continue to play Red/Blue until the next game!"); } return(true); }