Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
analyticsmanagerclient.c
Go to the documentation of this file.
2 {
3  static const int GEAR_COUNT = 3;
4  static string m_FullGear[GEAR_COUNT] = {"Shoulder","Melee","Back"};
5 
6  void RegisterEvents()
7  {
8  ClientData.SyncEvent_OnEntityKilled.Insert(Event_OnEntityKilled);
9  ClientData.SyncEvent_OnPlayerIgnitedFireplace.Insert(Event_OnPlayerIgnitedFireplace);
10  }
11 
12  void UnregisterEvents()
13  {
14  ClientData.SyncEvent_OnEntityKilled.Remove(Event_OnEntityKilled);
15  ClientData.SyncEvent_OnPlayerIgnitedFireplace.Remove(Event_OnPlayerIgnitedFireplace);
16  }
17 
18  //===================================
19  // OnActionEat
20  //===================================
21  void OnActionEat()
22  {
23  Achievements.OnActionEat();
24  }
25 
26  //===================================
27  // OnActionDrink
28  //===================================
29  void OnActionDrink()
30  {
31  Achievements.OnActionDrink();
32  }
33 
34  //===================================
35  // OnActionCookedSteak - not implemented
36  //===================================
37  void OnActionCookedSteak()
38  {
39  Achievements.OnCookedSteak();
40  }
41 
42  //===================================
43  // OnActionFinishedShaveSelf
44  //===================================
45  void OnActionFinishedShaveSelf()
46  {
47  Achievements.OnActionShave();
48  }
49 
50  //===================================
51  // OnActionFinishedGutDeer
52  //===================================
53  void OnActionFinishedGutDeer()
54  {
55  Achievements.OnActionGutDeer();
56  }
57 
58  //===================================
59  // OnActionRestrain
60  //===================================
61  void OnActionRestrain()
62  {
63  Achievements.OnActionHandcuff();
64  }
65 
66  //===================================
67  // OnActionBandageTarget
68  //===================================
69  void OnActionBandageTarget()
70  {
71  Achievements.OnActionMedsSurvivor();
72  }
73 
74  //===================================
75  // OnItemAttachedAtPlayer
76  //===================================
77  void OnItemAttachedAtPlayer(EntityAI item, string slot_name)
78  {
79  bool weapon_present;
80  bool melee_present;
81  bool backpack_present;
82  HumanInventory inventory;
83 
84  if ( GetDayZGame().GetGameState() != DayZGameState.IN_GAME )
85  {
86  return;
87  }
88 
89  Man player = GetGame().GetPlayer();
90  if (!player)
91  {
92  return;
93  }
94 
95  inventory = player.GetHumanInventory();
96 
97  if ( player && inventory )
98  {
99  for ( int i = 0; i < GEAR_COUNT; ++i )
100  {
101  int slot_id = InventorySlots.GetSlotIdFromString(m_FullGear[i]);
102  EntityAI att_item = inventory.FindAttachment( slot_id ); // Boris V [27.2.2019]: Consider using player.GetItemOnSlot(m_FullGear[i]) instead.
103 
104  if ( !att_item )
105  {
106  //Print("index: "+ i +" slot_id: "+ slot_id +" = "+ att_item + " EMPTY");
107  continue;
108  }
109 
110  //checks for firearm
111  if (att_item.IsWeapon())
112  weapon_present = true;
113  //checks for melee weapon
114  else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee")))
115  melee_present = true;
116  //checks for backpack
117  else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back")))
118  backpack_present = true;
119  //Print("index: "+ i +" slot_id: "+ slot_id +" = "+ att_item + " ATTACHED");
120  }
121 
122  //separate check for hand slot; TODO remove duplicates
123  att_item = inventory.GetEntityInHands();
124  if ( att_item )
125  {
126  //checks for firearm
127  if (att_item.IsWeapon())
128  weapon_present = true;
129  //checks for melee weapon
130  else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Melee")) )
131  melee_present = true;
132  //checks for backpack
133  else if (!att_item.IsWeapon() && att_item.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString("Back")))
134  backpack_present = true;
135  }
136 
137  if (weapon_present && melee_present && backpack_present)
138  {
139  //Print("---EAchievementActionId.ACTION_EQUIP_GEAR");
140  Achievements.OnEquippedFullGear();
141  }
142  }
143  }
144 
145  //===================================
146  // Event_OnPlayerIgnitedFireplace
147  //===================================
148  void Event_OnPlayerIgnitedFireplace( EFireIgniteType ignite_type )
149  {
150  switch ( ignite_type )
151  {
152  case EFireIgniteType.Matchbox:
153  {
154  Achievements.OnActionIgniteMatchbox();
155  break;
156  }
157  case EFireIgniteType.Roadflare:
158  {
159  Achievements.OnActionIgniteRoadflare();
160  break;
161  }
162  case EFireIgniteType.HandDrill:
163  {
164  Achievements.OnActionIgniteDrill();
165  break;
166  }
167  }
168  }
169 
170  //===================================
171  // Event_OnEntityKilled
172  //===================================
173  void Event_OnEntityKilled(EntityAI victim, EntityAI killer, EntityAI source, bool is_headshot)
174  {
175  if ( killer != null && killer.IsPlayer() && killer.GetID() == GetGame().GetPlayer().GetID() )
176  {
177  Achievements.OnPlayerKilled(victim, killer, source, is_headshot);
178  }
179  }
180 }
GetGame
proto native CGame GetGame()
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
AnalyticsManagerClient
Definition: analyticsmanagerclient.c:1
ClientData
Definition: clientdata.c:1
GetID
int GetID()
Get the ID registered in SEffectManager.
Definition: effect.c:534
EFireIgniteType
EFireIgniteType
Definition: efireignitetype.c:1
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
HumanInventory
inventory for plain man/human
Definition: humaninventory.c:9
EntityAI
Definition: building.c:5
Achievements
Definition: achievementsxbox.c:51