-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcounterstats.inc
More file actions
213 lines (180 loc) · 6.36 KB
/
counterstats.inc
File metadata and controls
213 lines (180 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
enum StatStatus
{
/// If the weaponstat returned from WeaponStatsEnumerator is invalid,
/// it will equal this.
StatStatus_Invalid = 0xFFFFFFFF
};
/// See https://github.com/saul/demofile/issues/38 for a list of values.
/// Thanks, saul!
/// The reason why the round ended, provided to the fun fact manager to decide valid fun facts.
enum RoundEnd
{
RoundEnd_TargetBombed = 1, // Target Successfully Bombed!
// 2/3 not in use in CSGO
RoundEnd_TerroristsEscaped = 4, // The terrorists have escaped!
RoundEnd_CTStoppedEscape = 5, // The CTs have prevented most of the terrorists from escaping!
RoundEnd_TerroristsStopped = 6, // Escaping terrorists have all been neutralized!
RoundEnd_BombDefused = 7, // The bomb has been defused!
RoundEnd_CTWin = 8, // Counter-Terrorists Win!
RoundEnd_TerroristWin = 9, // Terrorists Win!
RoundEnd_Draw = 10, // Round Draw!
RoundEnd_HostagesRescued = 11, // All Hostages have been rescued!
RoundEnd_TargetSaved = 12, // Target has been saved!
RoundEnd_HostagesNotRescued = 13, // Hostages have not been rescued!
RoundEnd_TerroristsNotEscaped = 14, // Terrorists have not escaped!
RoundEnd_GameStart = 16, // Game Commencing!
// 15 not in use in CSGO
RoundEnd_TerroristsSurrender = 17, // Terrorists Surrender
RoundEnd_CTSurrender = 18, // CTs Surrender
RoundEnd_TerroristsPlanted = 19, // Terrorists Planted the bomb
RoundEnd_CTsReachedHostage = 20, // CTs Reached the hostage
};
methodmap WeaponStatsEnumerator __nullable__
{
/// Create a new weaponstatsenumerator.
public native WeaponStatsEnumerator();
/// Move the enumerator to the next value.
/// Returns false if we have reached the end of the list, or if another error occured.
public static native bool Next(WeaponStatsEnumerator &self);
/// Search for the desired weapon index and return true if found.
public static bool Seek(WeaponStatsEnumerator &self, const char[] weapon)
{
do
{
char name[32];
self.GetName(name, sizeof(name));
if (StrEqual(name, weapon))
return true;
} while (WeaponStatsEnumerator.Next(self));
// index not found.
return false;
}
/// Writes the weapon name of the current stats block to the buffer.
/// The name length will never exceed parameter "maxlen".
/// Returns non-0 on failure.
public native int GetName(char[] buffer, int maxlen);
/// Gets a weaponstat for kills using this weapon
property StatType Kills
{
public native get();
}
/// Gets a weaponstat for the amount of times this weapon was fired
/// Note: Currently invalid on non-decoy grenades and knives.
property StatType Shots
{
public native get();
}
/// Gets a weaponstat for the amount of shots that hit
/// Note: Currently invalid on non-decoy grenades and knives.
property StatType Hits
{
public native get();
}
/// Gets a weaponstat for the amount of damage done by this weapon
/// Note: Currently invalid on non-decoy grenades and knives.
property StatType Damage
{
public native get();
}
};
methodmap PlayerStats __nullable__
{
/// Create a playerstats object for this player index
public native PlayerStats(int player_idx);
/// Appears to show the stats for the past 2-3 seconds.
/// Cleared with a timer on an unknown basis.
/// Returns -1 on failure.
public native int GetDelta(StatType idx);
/// Get the value of this stat for the current round
/// Returns -1 on failure.
public native int GetRound(StatType idx);
/// Get the value of this stat for the current match
/// Returns -1 on failure.
public native int GetMatch(StatType idx);
};
methodmap StatType
{
/// Returns true if this is a valid weaponstat.
/// Some weapons do not have specific stats (eg, "hits" for grenades)
/// And will use a specific placeholder value instead.
/// This will return false if that is the case.
public native bool IsValid();
};
methodmap FunFactEnumerator __nullable__
{
/// Create a new fun fact enumerator and set it to the current entry
public native FunFactEnumerator();
/// Move the enumerator to the next value.
/// Returns false if we have reached the end of the list, or if another error occured.
public static native bool Next(FunFactEnumerator &self);
/// Search for the desired fun fact and return true if found.
/// ONLY USE FOR DEBUGGING--LEAKS MEMORY
public static bool UnsafeSeek(FunFactEnumerator &self, const char[] funfact)
{
do
{
FunFact current = self.Current();
char name[128];
current.GetName(name, sizeof(name));
if (StrEqual(name, funfact))
return true;
} while (FunFactEnumerator.Next(self));
// index not found.
return false;
}
/// Gets the current fun fact
/// This uses an sdkcall--avoid calling this function unnecessarily.
/// !! Unstable--this is very likely to change in March/April 2023.
public native FunFact Current();
}
/// A FunFact is a struct that contains information about a fun fact
/// and a method to generate a fun fact of the specified type.
methodmap FunFact
{
/// Get the localization string of this fun fact
/// Can be used to reliably get the same funfact.
public native int GetName(char[] buffer, int maxlen);
/// Evaluate this fun fact assuming the round ended with "reason".
/// Returns true if a fun fact was generated, false if none or error.
public native bool Evaluate(RoundEnd reason, FunFactResult &result);
/// Exact purpose unknown. Assumed to be a unique ID.
property int Id
{
public native get();
}
/// Get how rare/cool/whatever this fun fact is.
/// Expressed as a float from 0 to 1.
property float Prestige
{
public native get();
}
}
methodmap FunFactResult
{
/// Gets the data values for this fun fact.
/// Note that there are THREE data values.
/// So you had better be passing an INT array with THREE slots in it.
/// ONE TWO THREE. THREE. Do not make maxlen save your dumb butt.
/// Return 0 on success, otherwise error code on failure.
public native int GetData(int[] data, int maxlen);
/// Get the localization string of this fun fact
/// Can be used to reliably get the same funfact.
public native int GetName(char[] buffer, int maxlen);
/// Get the subject of this fun fact.
/// EG, for the bomb planter, returns the player that planted the bomb.
property int Player
{
public native get();
}
/// Exact purpose unknown. Assumed to be a unique ID.
property int Id
{
public native get();
}
/// Exact purpose unknown.
/// Assumed to be how cool this fun fact is.
property float Magnitude
{
public native get();
}
}