/
convars.sp
366 lines (317 loc) · 10.6 KB
/
convars.sp
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#include <autoexecconfig>
/* The convar mess starts here! */
/* Enumerated values for accessing ConVar arrays */
enum multREDs:
{
red_bunker_mult = 0,
red_assembler_mult,
red_transport_mult,
red_artillery_mult,
red_ft_turret_mult,
red_wall_mult,
red_barrier_mult,
red_supply_mult,
red_ib1_base_mult,
red_ib2_base_mult,
red_ib3_base_mult,
multREDsSize
}
enum multBullets:
{
bullet_bunker_mult = 0,
bullet_assembler_mult,
bullet_transport_mult,
bullet_artillery_mult,
bullet_ft_turret_mult,
bullet_power_plant_mult,
bullet_armoury_mult,
bullet_radar_mult,
bullet_mg_turret_mult,
bullet_rocket_turret_mult,
bullet_supply_station_mult,
multBulletsSize
}
enum multSiege:
{
// Siegers (m95 & x01)
siege_ib0_base_mult = 0,
siege_ib1_base_mult,
siege_ib2_base_mult,
siege_ib3_base_mult,
multSiegeSize
}
enum multGL:
{
gl_bunker_mult = 0,
gl_assembler_mult,
gl_transport_mult,
gl_ft_turret_mult,
gl_ib1_base_mult,
gl_ib2_base_mult,
gl_ib3_base_mult,
multGLSize
}
enum multOther:
{
nx300_ib1_base_mult = 0,
nx300_ib2_base_mult,
nx300_ib3_base_mult,
nx300_bunker_mult,
artillery_ib1_base_mult,
artillery_ib2_base_mult,
artillery_ib3_base_mult,
multOtherSize
}
/* ConVar and float arrays for the different types */
ConVar gCvar_Red[multREDsSize];
ConVar gCvar_Bullet[multBulletsSize];
ConVar gCvar_Siege[multSiegeSize];
ConVar gCvar_GL[multGLSize];
ConVar gCvar_Other[multOtherSize];
ConVar cvarNoWarmupBunkerDamage;
ConVar gCvarMinThresholdX01;
ConVar gCvarMinIncreaseX01;
ConVar gCvarMinWallDamageX01;
float gFloat_Red[multREDsSize];
float gFloat_Bullet[multBulletsSize];
float gFloat_Siege[multSiegeSize];
float gFloat_GL[multGLSize];
float gFloat_Other[multOtherSize];
int iMinThresholdX01;
float fMinWallDamageX01;
float fMinIncreaseX01;
/* Functions for creating covnars */
void CreatePluginConVars()
{
// Tell the wrapper to create the files. Required for multiples.
AutoExecConfig_SetCreateFile(true);
CreateRedConVars();
CreateBulletConVars();
CreateSiegeConVars();
CreateGLConVars();
CreateOtherConVars();
AutoExecConfig_SetFile("nd_mult");
cvarNoWarmupBunkerDamage = AutoExecConfig_CreateConVar("sm_warmup_protect_bunker", "1", "Disable bunker damage during the warmup round.");
gCvarMinThresholdX01 = AutoExecConfig_CreateConVar("sm_mult_x01_threshold", "25", "Sets amount to multiply x01 damage by a percentage.");
gCvarMinIncreaseX01 = AutoExecConfig_CreateConVar("sm_mult_x01_damage", "150", "Sets percentage to multiply x01 damage by when threshold reached.");
gCvarMinWallDamageX01 = AutoExecConfig_CreateConVar("sm_mult_x01_wall", "35", "Sets the min damage the x01 must deal to a wall.");
AutoExecConfig_EC_File();
}
void CreateRedConVars()
{
AutoExecConfig_SetFile("nd_mult_reds");
char convarName[multREDsSize][] = {
// RED Structure Damage
"sm_mult_bunker_red",
"sm_mult_assembler_red",
"sm_mult_transport_red",
"sm_mult_artillery_red",
"sm_mult_ft_turret_red",
"sm_mult_wall_red",
"sm_mult_barrier_red",
"sm_mult_supply_red",
// RED Base Damage
"sm_mult_baseIB1_red",
"sm_mult_baseIB2_red",
"sm_mult_baseIB3_red"
};
char convarDesc[multREDsSize][] = {
// RED Structure Damage
"Percentage of normal damage REDs deal to the bunker",
"Percentage of normal damage REDs deal to assemblers",
"Percentage of normal damage REDs deal to transport gates",
"Percentage of normal damage REDs deal to artillery",
"Percentage of normal damage REDs deal to ft/sonic turrets",
"Percentage of normal damage REDs deal to walls",
"Percentage of normal damage REDs deal to barriers",
"Percentage of normal damage REDs deal to supply stations",
// RED Base Damage
"Percentage of normal damage REDs deal after Infantry Boost 1",
"Percentage of normal damage REDs deal after Infantry Boost 2",
"Percentage of normal damage REDs deal after Infantry Boost 3"
};
char convarDef[multREDsSize][] = {
// RED Structure Damage
"130", "110", "130", "110", "125", "130", "115", "105",
// RED Base Damage
"103", "108", "115"
};
for (int convar = 0; convar < view_as<int>(multREDsSize); convar++) {
gCvar_Red[convar] = AutoExecConfig_CreateConVar(convarName[convar], convarDef[convar], convarDesc[convar]);
}
AutoExecConfig_EC_File();
}
void CreateBulletConVars()
{
AutoExecConfig_SetFile("nd_mult_bullet");
char convarName[multBulletsSize][] = {
"sm_mult_bunker_bullet",
"sm_mult_assembler_bullet",
"sm_mult_transport_bullet",
"sm_mult_artillery_bullet",
"sm_mult_ft_turret_bullet",
"sm_mult_power_plant_bullet",
"sm_mult_armoury_bullet",
"sm_mult_radar_bullet",
"sm_mult_mg_turret_bullet",
"sm_mult_rocket_turret_bullet",
"sm_mult_supply_station_bullet"
};
char convarDef[multBulletsSize][] = { "150", "140", "135", "95", "115", "125", "115", "100", "115", "100", "75" };
char convarDesc[multBulletsSize][] = {
"Percentage of normal damage bullets deal to the bunker",
"Percentage of normal damage bullets deal to assemblers",
"Percentage of normal damage bullets deal to transport gates",
"Percentage of normal damage bullets deal to artillery",
"Percentage of normal damage bullets deal to ft/sonic turrets",
"Percentage of normal damage bullets deal to power plants",
"Percentage of normal damage bullets deal to armouries",
"Percentage of normal damage bullets deal to radars",
"Percentage of normal damage bullets deal to mg turrets",
"Percentage of normal damage bullets deal to rocket turrets",
"Percentage of normal damage bullets deal to supply stations"
};
for (int convar = 0; convar < view_as<int>(multBulletsSize); convar++) {
gCvar_Bullet[convar] = AutoExecConfig_CreateConVar(convarName[convar], convarDef[convar], convarDesc[convar]);
}
AutoExecConfig_EC_File();
}
void CreateSiegeConVars()
{
AutoExecConfig_SetFile("nd_mult_siege");
// Siegers (m95 & x01)
char convarName[multSiegeSize][] = {
// Siege Base Damage
"sm_mult_baseIB0_siege",
"sm_mult_baseIB1_siege",
"sm_mult_baseIB2_siege",
"sm_mult_baseIB3_siege"
};
char convarDesc[multSiegeSize][] = {
// Siege Base Damage
"Percentage of normal damage Siegers deal at Infantry Boost 0",
"Percentage of normal damage Siegers deal after Infantry Boost 1",
"Percentage of normal damage Siegers deal after Infantry Boost 2",
"Percentage of normal damage Siegers deal after Infantry Boost 3"
};
char convarDef[multSiegeSize][] = {
// Siege Base Damage
"95", "100", "105", "110"
};
for (int convar = 0; convar < view_as<int>(multSiegeSize); convar++) {
gCvar_Siege[convar] = AutoExecConfig_CreateConVar(convarName[convar], convarDef[convar], convarDesc[convar]);
}
AutoExecConfig_EC_File();
}
void CreateGLConVars()
{
AutoExecConfig_SetFile("nd_mult_gl");
// GLs (Grenade Launchers)
char convarName[multGLSize][] = {
// GL Structure Damage
"sm_mult_bunker_gl",
"sm_mult_assembler_gl",
"sm_mult_transport_gl",
"sm_mult_ft_turret_gl",
// GL Base Damage
"sm_mult_baseIB1_gl",
"sm_mult_baseIB2_gl",
"sm_mult_baseIB3_gl"
};
char convarDesc[multGLSize][] = {
// GL Structure Damage
"Percentage of normal damage GLs deal to the bunker",
"Percentage of normal damage GLs deal to assemblers",
"Percentage of normal damage GLs deal to transport gates",
"Percentage of normal damage GLs deal to ft/sonic turrets",
// GL Base Damage
"Percentage of normal damage GLs deal to after Infantry Boost 1",
"Percentage of normal damage GLs deal to after Infantry Boost 2",
"Percentage of normal damage GLs deal to after Infantry Boost 3"
};
char convarDef[multGLSize][] = { "120", "110", "125", "110",
"103", "106", "109" };
for (int convar = 0; convar < view_as<int>(multGLSize); convar++) {
gCvar_GL[convar] = AutoExecConfig_CreateConVar(convarName[convar], convarDef[convar], convarDesc[convar]);
}
AutoExecConfig_EC_File();
}
void CreateOtherConVars()
{
AutoExecConfig_SetFile("nd_mult_other");
char convarName[multOtherSize][] = {
"sm_mult_baseIB1_nx300",
"sm_mult_baseIB2_nx300",
"sm_mult_baseIB3_nx300",
"sm_mult_bunker_nx300",
"sm_mult_baseSR1_artillery",
"sm_mult_baseSR2_artillery",
"sm_mult_baseSR3_artillery"
};
char convarDesc[multOtherSize][] = {
"Percentage of normal damage nx300 does after IB1",
"Percentage of normal damage nx300 does after IB2",
"Percentage of normal damage nx300 does after IB3",
"Percentage of normal damage nx300 does to bunker",
"Percentage of normal damage artillery does after SR1",
"Percentage of normal damage artillery does after SR2",
"Percentage of normal damage artillery does after SR13",
};
char convarDef[multOtherSize][] = {
// nx300 ib 1-3 base damage
"103", "105", "107",
"85", // nx300 bunker damage
// artillery sr 1-3 base damage
"95", "90", "85"
};
for (int convar = 0; convar < view_as<int>(multOtherSize); convar++) {
gCvar_Other[convar] = AutoExecConfig_CreateConVar(convarName[convar], convarDef[convar], convarDesc[convar]);
}
AutoExecConfig_EC_File();
}
/* Manage when ConVars change mid-game */
void UpdateConVarCache()
{
for (int r = 0; r < view_as<int>(multREDsSize); r++) {
gFloat_Red[r] = gCvar_Red[r].FloatValue / 100.0;
}
for (int b = 0; b < view_as<int>(multBulletsSize); b++) {
gFloat_Bullet[b] = gCvar_Bullet[b].FloatValue / 100.0;
}
for (int s = 0; s < view_as<int>(multSiegeSize); s++) {
gFloat_Siege[s] = gCvar_Siege[s].FloatValue / 100.0;
}
for (int g = 0; g < view_as<int>(multGLSize); g++) {
gFloat_GL[g] = gCvar_GL[g].FloatValue / 100.0;
}
for (int o = 0; o < view_as<int>(multOtherSize); o++) {
gFloat_Other[o] = gCvar_Other[o].FloatValue / 100.0;
}
iMinThresholdX01 = gCvarMinThresholdX01.IntValue;
fMinIncreaseX01 = gCvarMinIncreaseX01.FloatValue / 100.0;
fMinWallDamageX01 = gCvarMinWallDamageX01.FloatValue;
}
void HookConVarChanges()
{
for (int r = 0; r < view_as<int>(multREDsSize); r++) {
HookConVarChange(gCvar_Red[r], OnConfigPercentChange);
}
for (int b = 0; b < view_as<int>(multBulletsSize); b++) {
HookConVarChange(gCvar_Bullet[b], OnConfigPercentChange);
}
for (int s = 0; s < view_as<int>(multSiegeSize); s++) {
HookConVarChange(gCvar_Siege[s], OnConfigPercentChange);
}
for (int g = 0; g < view_as<int>(multGLSize); g++) {
HookConVarChange(gCvar_GL[g], OnConfigPercentChange);
}
for (int o = 0; o < view_as<int>(multOtherSize); o++) {
HookConVarChange(gCvar_Other[o], OnConfigPercentChange);
}
HookConVarChange(gCvarMinThresholdX01, OnConfigPercentChange);
HookConVarChange(gCvarMinIncreaseX01, OnConfigPercentChange);
HookConVarChange(gCvarMinWallDamageX01, OnConfigPercentChange);
}
public void OnConfigPercentChange(ConVar convar, char[] oldValue, char[] newValue) {
UpdateConVarCache();
}