3 const string STAT_DISTANCE =
"dist";
4 const string STAT_PLAYTIME =
"playtime";
5 const string STAT_PLAYERS_KILLED =
"players_killed";
6 const string STAT_INFECTED_KILLED =
"infected_killed";
7 const string STAT_LONGEST_SURVIVOR_HIT =
"longest_survivor_hit";
9 void OnPlayerConnect(Man player)
11 player.StatRegister(STAT_DISTANCE);
12 player.StatRegister(STAT_PLAYTIME);
13 player.StatRegister(STAT_PLAYERS_KILLED);
14 player.StatRegister(STAT_INFECTED_KILLED);
15 player.StatRegister(STAT_LONGEST_SURVIVOR_HIT);
18 void OnPlayerDisconnect(Man player)
20 player.StatUpdateByPosition(STAT_DISTANCE);
21 player.StatUpdateByTime(STAT_PLAYTIME);
25 void OnEntityHit(
EntityAI source, Man target)
29 Man survivor = source.GetHierarchyRootPlayer();
30 if (survivor && source.IsWeapon())
31 OnPlayerToPlayerHit(survivor, target);
35 protected void OnPlayerToPlayerHit(Man shooter, Man target)
37 float longestHitDistance = shooter.StatGet(STAT_LONGEST_SURVIVOR_HIT);
38 float currentDistance =
vector.Distance(shooter.GetPosition(), target.GetPosition());
41 if (longestHitDistance < currentDistance)
42 distanceUpdate = currentDistance - longestHitDistance;
44 shooter.StatUpdate(STAT_LONGEST_SURVIVOR_HIT, distanceUpdate);
53 Man killerSurvivor = killerEntity.GetHierarchyRootPlayer();
56 if (target.IsPlayer())
57 OnPlayerKilled(killerSurvivor, target);
58 else if (target.IsZombie())
59 OnInfectedKilled(killerSurvivor, target);
64 protected void OnPlayerKilled(Man killer,
EntityAI target)
66 killer.StatUpdate(STAT_PLAYERS_KILLED, 1);
69 protected void OnInfectedKilled(Man killer,
EntityAI target)
71 killer.StatUpdate(STAT_INFECTED_KILLED, 1);