Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
analyticsmanagerserver.c
Go to the documentation of this file.
2 {
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";
8 
9  void OnPlayerConnect(Man player)
10  {
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);
16  }
17 
18  void OnPlayerDisconnect(Man player)
19  {
20  player.StatUpdateByPosition(STAT_DISTANCE);
21  player.StatUpdateByTime(STAT_PLAYTIME);
22  }
23 
24  //Entity-Entity hit
25  void OnEntityHit(EntityAI source, Man target)
26  {
27  if (source)
28  {
29  Man survivor = source.GetHierarchyRootPlayer();
30  if (survivor && source.IsWeapon())
31  OnPlayerToPlayerHit(survivor, target);
32  }
33  }
34 
35  protected void OnPlayerToPlayerHit(Man shooter, Man target)
36  {
37  float longestHitDistance = shooter.StatGet(STAT_LONGEST_SURVIVOR_HIT);
38  float currentDistance = vector.Distance(shooter.GetPosition(), target.GetPosition());
39  float distanceUpdate;
40 
41  if (longestHitDistance < currentDistance)
42  distanceUpdate = currentDistance - longestHitDistance;
43 
44  shooter.StatUpdate(STAT_LONGEST_SURVIVOR_HIT, distanceUpdate);
45  }
46 
47  //Entity-Entity kill
48  void OnEntityKilled(Object killer, EntityAI target)
49  {
50  EntityAI killerEntity = EntityAI.Cast(killer);
51  if (killerEntity)
52  {
53  Man killerSurvivor = killerEntity.GetHierarchyRootPlayer();
54  if (killerSurvivor)
55  {
56  if (target.IsPlayer())
57  OnPlayerKilled(killerSurvivor, target);
58  else if (target.IsZombie())
59  OnInfectedKilled(killerSurvivor, target);
60  }
61  }
62  }
63 
64  protected void OnPlayerKilled(Man killer, EntityAI target)
65  {
66  killer.StatUpdate(STAT_PLAYERS_KILLED, 1);
67  }
68 
69  protected void OnInfectedKilled(Man killer, EntityAI target)
70  {
71  killer.StatUpdate(STAT_INFECTED_KILLED, 1);
72  }
73 }
AnalyticsManagerServer
Definition: analyticsmanagerserver.c:1
vector
Definition: enconvert.c:105
Object
Definition: objecttyped.c:1
EntityAI
Definition: building.c:5