Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
achievementsxbox.c
Go to the documentation of this file.
2 {
8 };
9 
11 {
14 };
15 
17 {
21 };
22 
24 {
28 };
29 
31 {
34 };
35 
37 {
49 };
50 
52 {
53  private void Achievements();
54  private void ~Achievements();
55 
56  static proto EAchievementError SendEventAction(EAchievementActionId action_id);
57  static proto EAchievementError SendEventKill(EAchievementTargetId target_id, EAchievementRankId rank_id, EAchievementRangeId range_id, EAchievementHitId hit_id, float distance);
58 
59  //===================================
60  // OnActionEat
61  //===================================
62  static void OnActionEat()
63  {
64  CheckError( SendEventAction( EAchievementActionId.ACTION_EAT ) );
65  }
66 
67  //===================================
68  // OnActionDrink
69  //===================================
70  static void OnActionDrink()
71  {
72  CheckError( SendEventAction( EAchievementActionId.ACTION_DRINK ) );
73  }
74 
75  //===================================
76  // OnEquipdFullGear
77  //===================================
78  static void OnEquippedFullGear()
79  {
80  CheckError( SendEventAction( EAchievementActionId.ACTION_EQUIP_GEAR ) );
81  }
82 
83  //===================================
84  // OnCookedSteak
85  //===================================
86  static void OnCookedSteak()
87  {
88  CheckError( SendEventAction( EAchievementActionId.ACTION_COOK_STEAK ) );
89  }
90 
91  //===================================
92  // OnActionIgniteMatchbox
93  //===================================
94  static void OnActionIgniteMatchbox()
95  {
96  CheckError( SendEventAction( EAchievementActionId.ACTION_IGNITE_FIRE_MATCHBOX ) );
97  }
98 
99  //===================================
100  // OnActionIgniteRoadflare
101  //===================================
102  static void OnActionIgniteRoadflare()
103  {
104  CheckError( SendEventAction( EAchievementActionId.ACTION_IGNITE_FIRE_ROAD_FLARE ) );
105  }
106 
107  //===================================
108  // OnActionIgniteDrill
109  //===================================
110  static void OnActionIgniteDrill()
111  {
112  CheckError( SendEventAction( EAchievementActionId.ACTION_IGNITE_FIRE_HAND_DRILL ) );
113  }
114 
115  //===================================
116  // OnActionShave
117  //===================================
118  static void OnActionShave()
119  {
120  CheckError( SendEventAction( EAchievementActionId.ACTION_SHAVE ) );
121  }
122 
123  //===================================
124  // OnActionGutDeer
125  //===================================
126  static void OnActionGutDeer()
127  {
128  CheckError( SendEventAction( EAchievementActionId.ACTION_GUT_DEER ) );
129  }
130 
131  //===================================
132  // OnActionMedsSurvivor
133  //===================================
134  static void OnActionMedsSurvivor()
135  {
136  CheckError( SendEventAction( EAchievementActionId.ACTION_APPLY_MEDS_ON_SURVIVOR ) );
137  }
138 
139  //===================================
140  // OnActionHandcuff
141  //===================================
142  static void OnActionHandcuff()
143  {
144  CheckError( SendEventAction( EAchievementActionId.ACTION_HANDCUFF_SURVIVOR ) );
145  }
146 
147  //===================================
148  // OnPlayerKilled
149  //===================================
150  static void OnPlayerKilled(EntityAI victim, EntityAI killer, EntityAI source, bool is_headshot)
151  {
152  EAchievementTargetId target_id = EAchievementTargetId.TARGET_SURVIVOR;
153  EAchievementRankId target_rank_id = EAchievementRankId.RANK_SURVIVOR;
154  EAchievementRangeId range_id = EAchievementRangeId.RANGE_OTHER;
155  EAchievementHitId hit_id = EAchievementHitId.HIT_OTHER;
156  float distance = 0;
157 
158  if ( victim.IsZombie() )
159  {
160  target_id = EAchievementTargetId.TARGET_INFECTED;
161  target_rank_id = EAchievementRankId.RANK_INFECTED;
162 
163  if ( victim.IsZombieMilitary() )
164  {
165  target_rank_id = EAchievementRankId.RANK_INFECTED_SOLDIER;
166  }
167  }
168 
169  if ( source )
170  {
171  if ( source.IsMeleeWeapon() )
172  {
173  range_id = EAchievementRangeId.RANGE_MELEE;
174  }
175  else if ( source.IsWeapon() && killer )
176  {
177  range_id = EAchievementRangeId.RANGE_RANGED;
178  distance = vector.Distance( killer.GetPosition(), victim.GetPosition() );
179 
180  if ( is_headshot )
181  {
182  hit_id = EAchievementHitId.HIT_HEADSHOT;
183  }
184  }
185  }
186 
187  CheckError( SendEventKill(target_id, target_rank_id, range_id, hit_id, distance) );
188  }
189 
190  //-----------------------------------
191  // CheckError
192  //-----------------------------------
193  private static void CheckError(EAchievementError error)
194  {
195  if ( error != EAchievementError.ERR_OK )
196  {
197  Print("Achievements: Cannot send achievement event. Error ID: " + error);
198  }
199  }
200 };
201 
ACTION_IGNITE_FIRE_MATCHBOX
@ ACTION_IGNITE_FIRE_MATCHBOX
Definition: achievementsxbox.c:42
HIT_OTHER
@ HIT_OTHER
Definition: achievementsxbox.c:32
ERR_BAD_DATA
@ ERR_BAD_DATA
Definition: achievementsxbox.c:5
TARGET_SURVIVOR
@ TARGET_SURVIVOR
Definition: achievementsxbox.c:12
ACTION_IGNITE_FIRE_HAND_DRILL
@ ACTION_IGNITE_FIRE_HAND_DRILL
Definition: achievementsxbox.c:44
EAchievementError
EAchievementError
Definition: achievementsxbox.c:1
HIT_HEADSHOT
@ HIT_HEADSHOT
Definition: achievementsxbox.c:33
RANK_INFECTED_SOLDIER
@ RANK_INFECTED_SOLDIER
must be TARGET_INFECTED
Definition: achievementsxbox.c:20
EAchievementRankId
EAchievementRankId
Definition: achievementsxbox.c:16
Print
proto void Print(void var)
Prints content of variable to console/log.
ACTION_GUT_DEER
@ ACTION_GUT_DEER
Definition: achievementsxbox.c:46
RANK_INFECTED
@ RANK_INFECTED
must be TARGET_INFECTED
Definition: achievementsxbox.c:19
AchievementsXbox
Achievements AchievementsXbox
Definition: achievementsxbox.c:202
ACTION_HANDCUFF_SURVIVOR
@ ACTION_HANDCUFF_SURVIVOR
Definition: achievementsxbox.c:48
ACTION_EAT
@ ACTION_EAT
Definition: achievementsxbox.c:38
vector
Definition: enconvert.c:105
RANGE_RANGED
@ RANGE_RANGED
Definition: achievementsxbox.c:27
ACTION_SHAVE
@ ACTION_SHAVE
Definition: achievementsxbox.c:45
ACTION_EQUIP_GEAR
@ ACTION_EQUIP_GEAR
Definition: achievementsxbox.c:40
EAchievementTargetId
EAchievementTargetId
Definition: achievementsxbox.c:10
RANK_SURVIVOR
@ RANK_SURVIVOR
must be TARGET_SURVIVOR
Definition: achievementsxbox.c:18
EAchievementHitId
EAchievementHitId
Definition: achievementsxbox.c:30
RANGE_OTHER
@ RANGE_OTHER
Definition: achievementsxbox.c:25
ERR_OK
@ ERR_OK
Definition: achievementsxbox.c:3
ACTION_DRINK
@ ACTION_DRINK
Definition: achievementsxbox.c:39
ERR_NOT_FOUND
@ ERR_NOT_FOUND
Definition: achievementsxbox.c:4
ACTION_IGNITE_FIRE_ROAD_FLARE
@ ACTION_IGNITE_FIRE_ROAD_FLARE
Definition: achievementsxbox.c:43
ACTION_COOK_STEAK
@ ACTION_COOK_STEAK
Definition: achievementsxbox.c:41
RANGE_MELEE
@ RANGE_MELEE
Definition: achievementsxbox.c:26
ERR_NOT_IMPLEMENTED
@ ERR_NOT_IMPLEMENTED
Definition: achievementsxbox.c:6
TARGET_INFECTED
@ TARGET_INFECTED
Definition: achievementsxbox.c:13
ERR_UNKNOWN
@ ERR_UNKNOWN
Definition: achievementsxbox.c:7
ACTION_APPLY_MEDS_ON_SURVIVOR
@ ACTION_APPLY_MEDS_ON_SURVIVOR
Definition: achievementsxbox.c:47
EntityAI
Definition: building.c:5
EAchievementRangeId
EAchievementRangeId
Definition: achievementsxbox.c:23
Achievements
Definition: achievementsxbox.c:51
EAchievementActionId
EAchievementActionId
Definition: achievementsxbox.c:36