· 6 years ago · Jun 14, 2019, 03:26 PM
1/*
2** ATTENTION
3** THE PRODUCED CODE, IS NOT ABLE TO COMPILE!
4** THE DECOMPILER JUST TRIES TO GIVE YOU A POSSIBILITY
5** TO LOOK HOW A PLUGIN DOES IT'S JOB AND LOOK FOR
6** POSSIBLE MALICIOUS CODE.
7**
8** ALL CONVERSIONS ARE WRONG! AT EXAMPLE:
9** SetEntityRenderFx(client, RenderFx 0); → SetEntityRenderFx(client, view_as<RenderFx>0); → SetEntityRenderFx(client, RENDERFX_NONE);
10*/
11
12 PlVers __version = 5;
13 float NULL_VECTOR[3];
14 char NULL_STRING[1];
15 Extension __ext_core = 68;
16 int MaxClients;
17 TFHoliday TFHoliday_Birthday;
18 TFHoliday TFHoliday_Halloween;
19 TFHoliday TFHoliday_Christmas;
20 TFHoliday TFHoliday_EndOfTheLine;
21 TFHoliday TFHoliday_CommunityUpdate;
22 TFHoliday TFHoliday_ValentinesDay;
23 TFHoliday TFHoliday_MeetThePyro;
24 TFHoliday TFHoliday_FullMoon;
25 TFHoliday TFHoliday_HalloweenOrFullMoon;
26 TFHoliday TFHoliday_HalloweenOrFullMoonOrValentines;
27 TFHoliday TFHoliday_AprilFools;
28 Extension __ext_tf2 = 2268;
29 Extension __ext_sdktools = 2336;
30 char TFResourceNames[18][0];
31 Extension __ext_regex = 2428;
32 bool CSkipList[66];
33 Handle CTrie;
34 int CTeamColors[1][3] =
35{
36}
37 Extension __ext_SteamTools = 5104;
38 Extension __ext_sdkhooks = 5148;
39 SharedPlugin __pl_tf2items_giveweapon = 5192;
40 float Flare_Weapon_Knockback_Scale = 1036160860;
41 float Flare_Weapon_Knockback_Scale_Multiplier = 1073741824;
42 Handle g_hCvarEnabled;
43 Handle g_hCvarEnableCfgFile;
44 Handle g_hCvarDisableCfgFile;
45 ConVar g_hCvarVotePercent;
46 ConVar g_hCvarVoteSpeedEnabled;
47 ConVar g_hCvarVoteCountEnabled;
48 ConVar g_hCvarDisableReason;
49 ConVar g_hCvarEnablePAB;
50 ConVar g_hCvarTopSpeedHolder;
51 ConVar g_hCvarTopSpeedMPH;
52 Handle g_Announce;
53 bool g_bEnabled;
54 bool g_bRoundStarted;
55 int g_iRoundCount;
56 int g_iRocketsFired;
57 Handle g_hLogicTimer;
58 float g_fNextSpawnTime;
59 int g_iLastDeadTeam;
60 int g_iLastDeadClient;
61 int g_iPlayerCount;
62 Handle g_hHud;
63 int g_iRocketSpeed;
64 Handle g_hTimerHud;
65 Handle MaxDB_Hud;
66 float g_defaultspeed;
67 float g_default_turn;
68 float g_mph_convert = 1026460677;
69 float g_turnrate_convert = 997315565;
70 bool g_newtarget_bool;
71 int g_newtarget_int;
72 int g_Voters;
73 int g_VotesNeeded;
74 bool g_VoteInProgress;
75 int g_SpeedVotes;
76 int g_SpeedVoted[66];
77 int g_CountVotes;
78 int g_CountVoted[66];
79 Database db;
80 Menu TopRocketSpeed;
81 char Fishy_DisableReason[250];
82 bool g_bMusicEnabled;
83 bool g_bMusic[4];
84 char g_strMusic[4][64];
85 bool g_bUseWebPlayer;
86 char g_strWebPlayerUrl[64];
87 bool g_bRocketIsValid[1000];
88 int g_iRocketEntity[1000];
89 int g_iRocketTarget[1000];
90 int g_iRocketSpawner[1000];
91 int g_iRocketClass[1000];
92 RocketFlags g_iRocketFlags[1000];
93 float g_fRocketSpeed[1000];
94 float g_fRocketDirection[1000][3];
95 int g_iRocketDeflections[1000];
96 float g_fRocketLastDeflectionTime[1000];
97 float g_fRocketLastBeepTime[1000];
98 int g_iLastCreatedRocket;
99 int g_iRocketCount;
100 char g_strRocketClassName[500][4];
101 char g_strRocketClassLongName[500][8];
102 BehaviourTypes g_iRocketClassBehaviour[500];
103 char g_strRocketClassModel[500][64];
104 RocketFlags g_iRocketClassFlags[500];
105 float g_fRocketClassBeepInterval[500];
106 char g_strRocketClassSpawnSound[500][64];
107 char g_strRocketClassBeepSound[500][64];
108 char g_strRocketClassAlertSound[500][64];
109 float g_fRocketClassCritChance[500];
110 float g_fRocketClassDamage[500];
111 float g_fRocketClassDamageIncrement[500];
112 float g_fRocketClassSpeed[500];
113 float g_fRocketClassSpeedIncrement[500];
114 float g_fRocketClassTurnRate[500];
115 float g_fRocketClassTurnRateIncrement[500];
116 float g_fRocketClassElevationRate[500];
117 float g_fRocketClassElevationLimit[500];
118 float g_fRocketClassRocketsModifier[500];
119 float g_fRocketClassPlayerModifier[500];
120 float g_fRocketClassControlDelay[500];
121 float g_fRocketClassTargetWeight[500];
122 Handle g_hRocketClassCmdsOnSpawn[500];
123 Handle g_hRocketClassCmdsOnDeflect[500];
124 Handle g_hRocketClassCmdsOnKill[500];
125 Handle g_hRocketClassCmdsOnExplode[500];
126 Handle g_hRocketClassTrie;
127 int g_iRocketClassCount;
128 char g_strSpawnersName[50][8];
129 int g_iSpawnersMaxRockets[50];
130 float g_fSpawnersInterval[50];
131 Handle g_hSpawnersChancesTable[50];
132 Handle g_hSpawnersTrie;
133 int g_iSpawnersCount;
134 int g_iCurrentRedSpawn;
135 int g_iSpawnPointsRedCount;
136 int g_iSpawnPointsRedClass[100];
137 int g_iSpawnPointsRedEntity[100];
138 int g_iCurrentBluSpawn;
139 int g_iSpawnPointsBluCount;
140 int g_iSpawnPointsBluClass[100];
141 int g_iSpawnPointsBluEntity[100];
142 int g_iDefaultRedSpawner;
143 int g_iDefaultBluSpawner;
144public Plugin myinfo =
145{
146 name = "[TF2] Dodgeball [Rewritten]",
147 description = "[TF2] Dodgeball [Rewritten]",
148 author = "Fishy",
149 version = "2.1.0",
150 url = "https://keybase.io/rumblefrog"
151};
152public void __ext_core_SetNTVOptional()
153{
154 MarkNativeAsOptional("GetFeatureStatus");
155 MarkNativeAsOptional("RequireFeature");
156 MarkNativeAsOptional("AddCommandListener");
157 MarkNativeAsOptional("RemoveCommandListener");
158 MarkNativeAsOptional("BfWriteBool");
159 MarkNativeAsOptional("BfWriteByte");
160 MarkNativeAsOptional("BfWriteChar");
161 MarkNativeAsOptional("BfWriteShort");
162 MarkNativeAsOptional("BfWriteWord");
163 MarkNativeAsOptional("BfWriteNum");
164 MarkNativeAsOptional("BfWriteFloat");
165 MarkNativeAsOptional("BfWriteString");
166 MarkNativeAsOptional("BfWriteEntity");
167 MarkNativeAsOptional("BfWriteAngle");
168 MarkNativeAsOptional("BfWriteCoord");
169 MarkNativeAsOptional("BfWriteVecCoord");
170 MarkNativeAsOptional("BfWriteVecNormal");
171 MarkNativeAsOptional("BfWriteAngles");
172 MarkNativeAsOptional("BfReadBool");
173 MarkNativeAsOptional("BfReadByte");
174 MarkNativeAsOptional("BfReadChar");
175 MarkNativeAsOptional("BfReadShort");
176 MarkNativeAsOptional("BfReadWord");
177 MarkNativeAsOptional("BfReadNum");
178 MarkNativeAsOptional("BfReadFloat");
179 MarkNativeAsOptional("BfReadString");
180 MarkNativeAsOptional("BfReadEntity");
181 MarkNativeAsOptional("BfReadAngle");
182 MarkNativeAsOptional("BfReadCoord");
183 MarkNativeAsOptional("BfReadVecCoord");
184 MarkNativeAsOptional("BfReadVecNormal");
185 MarkNativeAsOptional("BfReadAngles");
186 MarkNativeAsOptional("BfGetNumBytesLeft");
187 MarkNativeAsOptional("BfWrite.WriteBool");
188 MarkNativeAsOptional("BfWrite.WriteByte");
189 MarkNativeAsOptional("BfWrite.WriteChar");
190 MarkNativeAsOptional("BfWrite.WriteShort");
191 MarkNativeAsOptional("BfWrite.WriteWord");
192 MarkNativeAsOptional("BfWrite.WriteNum");
193 MarkNativeAsOptional("BfWrite.WriteFloat");
194 MarkNativeAsOptional("BfWrite.WriteString");
195 MarkNativeAsOptional("BfWrite.WriteEntity");
196 MarkNativeAsOptional("BfWrite.WriteAngle");
197 MarkNativeAsOptional("BfWrite.WriteCoord");
198 MarkNativeAsOptional("BfWrite.WriteVecCoord");
199 MarkNativeAsOptional("BfWrite.WriteVecNormal");
200 MarkNativeAsOptional("BfWrite.WriteAngles");
201 MarkNativeAsOptional("BfRead.ReadBool");
202 MarkNativeAsOptional("BfRead.ReadByte");
203 MarkNativeAsOptional("BfRead.ReadChar");
204 MarkNativeAsOptional("BfRead.ReadShort");
205 MarkNativeAsOptional("BfRead.ReadWord");
206 MarkNativeAsOptional("BfRead.ReadNum");
207 MarkNativeAsOptional("BfRead.ReadFloat");
208 MarkNativeAsOptional("BfRead.ReadString");
209 MarkNativeAsOptional("BfRead.ReadEntity");
210 MarkNativeAsOptional("BfRead.ReadAngle");
211 MarkNativeAsOptional("BfRead.ReadCoord");
212 MarkNativeAsOptional("BfRead.ReadVecCoord");
213 MarkNativeAsOptional("BfRead.ReadVecNormal");
214 MarkNativeAsOptional("BfRead.ReadAngles");
215 MarkNativeAsOptional("BfRead.GetNumBytesLeft");
216 MarkNativeAsOptional("PbReadInt");
217 MarkNativeAsOptional("PbReadFloat");
218 MarkNativeAsOptional("PbReadBool");
219 MarkNativeAsOptional("PbReadString");
220 MarkNativeAsOptional("PbReadColor");
221 MarkNativeAsOptional("PbReadAngle");
222 MarkNativeAsOptional("PbReadVector");
223 MarkNativeAsOptional("PbReadVector2D");
224 MarkNativeAsOptional("PbGetRepeatedFieldCount");
225 MarkNativeAsOptional("PbSetInt");
226 MarkNativeAsOptional("PbSetFloat");
227 MarkNativeAsOptional("PbSetBool");
228 MarkNativeAsOptional("PbSetString");
229 MarkNativeAsOptional("PbSetColor");
230 MarkNativeAsOptional("PbSetAngle");
231 MarkNativeAsOptional("PbSetVector");
232 MarkNativeAsOptional("PbSetVector2D");
233 MarkNativeAsOptional("PbAddInt");
234 MarkNativeAsOptional("PbAddFloat");
235 MarkNativeAsOptional("PbAddBool");
236 MarkNativeAsOptional("PbAddString");
237 MarkNativeAsOptional("PbAddColor");
238 MarkNativeAsOptional("PbAddAngle");
239 MarkNativeAsOptional("PbAddVector");
240 MarkNativeAsOptional("PbAddVector2D");
241 MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
242 MarkNativeAsOptional("PbReadMessage");
243 MarkNativeAsOptional("PbReadRepeatedMessage");
244 MarkNativeAsOptional("PbAddMessage");
245 MarkNativeAsOptional("Protobuf.ReadInt");
246 MarkNativeAsOptional("Protobuf.ReadFloat");
247 MarkNativeAsOptional("Protobuf.ReadBool");
248 MarkNativeAsOptional("Protobuf.ReadString");
249 MarkNativeAsOptional("Protobuf.ReadColor");
250 MarkNativeAsOptional("Protobuf.ReadAngle");
251 MarkNativeAsOptional("Protobuf.ReadVector");
252 MarkNativeAsOptional("Protobuf.ReadVector2D");
253 MarkNativeAsOptional("Protobuf.GetRepeatedFieldCount");
254 MarkNativeAsOptional("Protobuf.SetInt");
255 MarkNativeAsOptional("Protobuf.SetFloat");
256 MarkNativeAsOptional("Protobuf.SetBool");
257 MarkNativeAsOptional("Protobuf.SetString");
258 MarkNativeAsOptional("Protobuf.SetColor");
259 MarkNativeAsOptional("Protobuf.SetAngle");
260 MarkNativeAsOptional("Protobuf.SetVector");
261 MarkNativeAsOptional("Protobuf.SetVector2D");
262 MarkNativeAsOptional("Protobuf.AddInt");
263 MarkNativeAsOptional("Protobuf.AddFloat");
264 MarkNativeAsOptional("Protobuf.AddBool");
265 MarkNativeAsOptional("Protobuf.AddString");
266 MarkNativeAsOptional("Protobuf.AddColor");
267 MarkNativeAsOptional("Protobuf.AddAngle");
268 MarkNativeAsOptional("Protobuf.AddVector");
269 MarkNativeAsOptional("Protobuf.AddVector2D");
270 MarkNativeAsOptional("Protobuf.RemoveRepeatedFieldValue");
271 MarkNativeAsOptional("Protobuf.ReadMessage");
272 MarkNativeAsOptional("Protobuf.ReadRepeatedMessage");
273 MarkNativeAsOptional("Protobuf.AddMessage");
274 VerifyCoreVersion();
275 return void 0;
276}
277
278public int RoundFloat(float value)
279{
280 return RoundToNearest(value);
281}
282
283public float operator*(Float:,_:)(float oper1, int oper2)
284{
285 return FloatMul(oper1, float(oper2));
286}
287
288public float operator/(_:,Float:)(int oper1, float oper2)
289{
290 return FloatDiv(float(oper1), oper2);
291}
292
293public float operator+(Float:,_:)(float oper1, int oper2)
294{
295 return FloatAdd(oper1, float(oper2));
296}
297
298public bool operator<=(_:,Float:)(int oper1, float oper2)
299{
300 return __FLOAT_LE__(float(oper1), oper2);
301}
302
303public void ScaleVector(float vec[3], float scale)
304{
305 int var1 = vec;
306 var1[0] = FloatMul(var1[0], scale);
307 int var2 = vec[4];
308 var2 = FloatMul(var2, scale);
309 int var3 = vec[8];
310 var3 = FloatMul(var3, scale);
311 return void 0;
312}
313
314public void MakeVectorFromPoints(float pt1[3], float pt2[3], float output[3])
315{
316 output[0] = FloatSub(pt2[0], pt1[0]);
317 output[4] = FloatSub(pt2[4], pt1[4]);
318 output[8] = FloatSub(pt2[8], pt1[8]);
319 return void 0;
320}
321
322public bool StrEqual(char str1[], char str2[], bool caseSensitive)
323{
324 return strcmp(str1, str2, caseSensitive) == 0;
325}
326
327public int CharToLower(int chr)
328{
329 if (IsCharUpper(chr))
330 {
331 return chr | 32;
332 }
333 return chr;
334}
335
336public int ExplodeString(char text[], char split[], char buffers[][], int maxStrings, int maxStringLength, bool copyRemainder)
337{
338 int reloc_idx = 0;
339 int idx = 0;
340 int total = 0;
341 int var1;
342 if (maxStrings < 1)
343 {
344 return 0;
345 }
346 int var2 = SplitString(text[reloc_idx], split, buffers[total], maxStringLength);
347 idx = var2;
348 while (var2 != -1)
349 {
350 reloc_idx = idx + reloc_idx;
351 total++;
352 if (maxStrings == total)
353 {
354 if (copyRemainder)
355 {
356 strcopy(buffers[total + -1], maxStringLength, text[reloc_idx - idx]);
357 }
358 return total;
359 }
360 }
361 total++;
362 strcopy(buffers[total], maxStringLength, text[reloc_idx]);
363 return total;
364}
365
366public Handle StartMessageOne(char msgname[], int client, int flags)
367{
368 int players[1];
369 players[0] = client;
370 return StartMessage(msgname, players, 1, flags);
371}
372
373
374/* ERROR! Unrecognized opcode genarray_z */
375 function "Menu.DisplayVoteToAll" (number 12)
376public void PrintHintTextToAll(char format[])
377{
378 char buffer[256];
379 int i = 1;
380 while (i <= MaxClients)
381 {
382 if (IsClientInGame(i))
383 {
384 SetGlobalTransTarget(i);
385 VFormat(buffer, 254, format, 2);
386 PrintHintText(i, "%s", buffer);
387 i++;
388 }
389 i++;
390 }
391 return void 0;
392}
393
394public void EmitSoundToClient(int client, char sample[], int entity, int channel, int level, int flags, float volume, int pitch, int speakerentity, float origin[3], float dir[3], bool updatePos, float soundtime)
395{
396 int clients[1];
397 clients[0] = client;
398 int var1;
399 if (entity == -2)
400 {
401 var1 = client;
402 }
403 else
404 {
405 var1 = entity;
406 }
407 entity = var1;
408 EmitSound(clients, 1, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
409 return void 0;
410}
411
412
413/* ERROR! Unrecognized opcode genarray_z */
414 function "EmitSoundToAll" (number 15)
415public void AddFileToDownloadsTable(char filename[])
416{
417 static int table = -1;
418 if (table == -1)
419 {
420 table = FindStringTable("downloadables");
421 }
422 bool save = LockStringTables(false);
423 AddToStringTable(table, filename, "", -1);
424 LockStringTables(save);
425 return void 0;
426}
427
428public TFClassType TF2_GetPlayerClass(int client)
429{
430 return GetEntProp(client, PropType 0, TFResourceNames, 4, 0);
431}
432
433public void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons, bool persistent)
434{
435 SetEntProp(client, PropType 0, "m_iClass", classType, 4, 0);
436 if (persistent)
437 {
438 SetEntProp(client, PropType 0, "m_iDesiredPlayerClass", classType, 4, 0);
439 }
440 return void 0;
441}
442
443public int CPrintToChat(int client, char message[])
444{
445 CCheckTrie();
446 int var1;
447 if (client <= 0)
448 {
449 ThrowError("Invalid client index %i", client);
450 }
451 if (!IsClientInGame(client))
452 {
453 ThrowError("Client %i is not in game", client);
454 }
455 char buffer[1024];
456 char buffer2[1024];
457 SetGlobalTransTarget(client);
458 Format(buffer, 1024, "\x01%s", message);
459 VFormat(buffer2, 1024, buffer, 3);
460 CReplaceColorCodes(buffer2, 0, false, 1024);
461 CSendMessage(client, buffer2, 0);
462 return 0;
463}
464
465public int CPrintToChatAll(char message[])
466{
467 CCheckTrie();
468 char buffer[1024];
469 char buffer2[1024];
470 int i = 1;
471 while (i <= MaxClients)
472 {
473 int var1;
474 if (!IsClientInGame(i))
475 {
476 CSkipList[i] = 0;
477 }
478 else
479 {
480 SetGlobalTransTarget(i);
481 Format(buffer, 1024, "\x01%s", message);
482 VFormat(buffer2, 1024, buffer, 2);
483 CReplaceColorCodes(buffer2, 0, false, 1024);
484 CSendMessage(i, buffer2, 0);
485 }
486 i++;
487 }
488 return 0;
489}
490
491public int CSendMessage(int client, char message[], int author)
492{
493 if (!author)
494 {
495 author = client;
496 }
497 char buffer[256];
498 char game[16];
499 GetGameFolderName(game, 16);
500 strcopy(buffer, 256, message);
501 UserMsg index = GetUserMessageId("SayText2");
502 if (index == UserMsg -1)
503 {
504 if (StrEqual(game, "dod", true))
505 {
506 int team = GetClientTeam(author);
507 if (team)
508 {
509 char temp[16];
510 int var2 = CTeamColors;
511 Format(temp, 16, "\x07%06X", var2[0][0][var2][team + -1]);
512 ReplaceString(buffer, 256, "\x03", temp, false);
513 }
514 else
515 {
516 ReplaceString(buffer, 256, "\x03", "\x04", false);
517 }
518 }
519 PrintToChat(client, "%s", buffer);
520 return 0;
521 }
522 Handle buf = StartMessageOne("SayText2", client, 132);
523 int var1;
524 if (GetFeatureStatus(FeatureType 0, "GetUserMessageType"))
525 {
526 PbSetInt(buf, "ent_idx", author, -1);
527 PbSetBool(buf, "chat", true, -1);
528 PbSetString(buf, "msg_name", buffer, -1);
529 PbAddString(buf, "params", "");
530 PbAddString(buf, "params", "");
531 PbAddString(buf, "params", "");
532 PbAddString(buf, "params", "");
533 }
534 else
535 {
536 BfWriteByte(buf, author);
537 BfWriteByte(buf, 1);
538 BfWriteString(buf, buffer);
539 }
540 EndMessage();
541 return 0;
542}
543
544public int CCheckTrie()
545{
546 if (!CTrie)
547 {
548 CTrie = InitColorTrie();
549 }
550 return 0;
551}
552
553
554/* ERROR! Unrecognized opcode stradjust_pri */
555 function "CReplaceColorCodes" (number 23)
556public int CStrToLower(char buffer[])
557{
558 int len = strlen(buffer);
559 int i = 0;
560 while (i < len)
561 {
562 buffer[i] = CharToLower(buffer[i]);
563 i++;
564 }
565 return 0;
566}
567
568public Handle InitColorTrie()
569{
570 Handle hTrie = CreateTrie();
571 SetTrieValue(hTrie, "aliceblue", any 15792383, true);
572 SetTrieValue(hTrie, "allies", any 5077314, true);
573 SetTrieValue(hTrie, "ancient", any 15420235, true);
574 SetTrieValue(hTrie, "antiquewhite", any 16444375, true);
575 SetTrieValue(hTrie, "aqua", any 65535, true);
576 SetTrieValue(hTrie, "aquamarine", any 8388564, true);
577 SetTrieValue(hTrie, "arcana", any 11396444, true);
578 SetTrieValue(hTrie, "axis", any 16728128, true);
579 SetTrieValue(hTrie, "azure", any 32767, true);
580 SetTrieValue(hTrie, "beige", any 16119260, true);
581 SetTrieValue(hTrie, "bisque", any 16770244, true);
582 SetTrieValue(hTrie, "black", any 0, true);
583 SetTrieValue(hTrie, "blanchedalmond", any 16772045, true);
584 SetTrieValue(hTrie, "blue", any 10079487, true);
585 SetTrieValue(hTrie, "blueviolet", any 9055202, true);
586 SetTrieValue(hTrie, "brown", any 10824234, true);
587 SetTrieValue(hTrie, "burlywood", any 14596231, true);
588 SetTrieValue(hTrie, "cadetblue", any 6266528, true);
589 SetTrieValue(hTrie, "chartreuse", any 8388352, true);
590 SetTrieValue(hTrie, "chocolate", any 13789470, true);
591 SetTrieValue(hTrie, "collectors", any 11141120, true);
592 SetTrieValue(hTrie, "common", any 11584473, true);
593 SetTrieValue(hTrie, "community", any 7385162, true);
594 SetTrieValue(hTrie, "coral", any 16744272, true);
595 SetTrieValue(hTrie, "cornflowerblue", any 6591981, true);
596 SetTrieValue(hTrie, "cornsilk", any 16775388, true);
597 SetTrieValue(hTrie, "corrupted", any 10693678, true);
598 SetTrieValue(hTrie, "crimson", any 14423100, true);
599 SetTrieValue(hTrie, "cyan", any 65535, true);
600 SetTrieValue(hTrie, "darkblue", any 139, true);
601 SetTrieValue(hTrie, "darkcyan", any 35723, true);
602 SetTrieValue(hTrie, "darkgoldenrod", any 12092939, true);
603 SetTrieValue(hTrie, "darkgray", any 11119017, true);
604 SetTrieValue(hTrie, "darkgrey", any 11119017, true);
605 SetTrieValue(hTrie, "darkgreen", any 25600, true);
606 SetTrieValue(hTrie, "darkkhaki", any 12433259, true);
607 SetTrieValue(hTrie, "darkmagenta", any 9109643, true);
608 SetTrieValue(hTrie, "darkolivegreen", any 5597999, true);
609 SetTrieValue(hTrie, "darkorange", any 16747520, true);
610 SetTrieValue(hTrie, "darkorchid", any 10040012, true);
611 SetTrieValue(hTrie, "darkred", any 9109504, true);
612 SetTrieValue(hTrie, "darksalmon", any 15308410, true);
613 SetTrieValue(hTrie, "darkseagreen", any 9419919, true);
614 SetTrieValue(hTrie, "darkslateblue", any 4734347, true);
615 SetTrieValue(hTrie, "darkslategray", any 3100495, true);
616 SetTrieValue(hTrie, "darkslategrey", any 3100495, true);
617 SetTrieValue(hTrie, "darkturquoise", any 52945, true);
618 SetTrieValue(hTrie, "darkviolet", any 9699539, true);
619 SetTrieValue(hTrie, "deeppink", any 16716947, true);
620 SetTrieValue(hTrie, "deepskyblue", any 49151, true);
621 SetTrieValue(hTrie, "dimgray", any 6908265, true);
622 SetTrieValue(hTrie, "dimgrey", any 6908265, true);
623 SetTrieValue(hTrie, "dodgerblue", any 2003199, true);
624 SetTrieValue(hTrie, "exalted", any 13421773, true);
625 SetTrieValue(hTrie, "firebrick", any 11674146, true);
626 SetTrieValue(hTrie, "floralwhite", any 16775920, true);
627 SetTrieValue(hTrie, "forestgreen", any 2263842, true);
628 SetTrieValue(hTrie, "frozen", any 4817843, true);
629 SetTrieValue(hTrie, "fuchsia", any 16711935, true);
630 SetTrieValue(hTrie, "fullblue", any 255, true);
631 SetTrieValue(hTrie, "fullred", any 16711680, true);
632 SetTrieValue(hTrie, "gainsboro", any 14474460, true);
633 SetTrieValue(hTrie, "genuine", any 5076053, true);
634 SetTrieValue(hTrie, "ghostwhite", any 16316671, true);
635 SetTrieValue(hTrie, "gold", any 16766720, true);
636 SetTrieValue(hTrie, "goldenrod", any 14329120, true);
637 SetTrieValue(hTrie, "gray", any 13421772, true);
638 SetTrieValue(hTrie, "grey", any 13421772, true);
639 SetTrieValue(hTrie, "green", any 4128574, true);
640 SetTrieValue(hTrie, "greenyellow", any 11403055, true);
641 SetTrieValue(hTrie, "haunted", any 3732395, true);
642 SetTrieValue(hTrie, "honeydew", any 15794160, true);
643 SetTrieValue(hTrie, "hotpink", any 16738740, true);
644 SetTrieValue(hTrie, "immortal", any 14986803, true);
645 SetTrieValue(hTrie, "indianred", any 13458524, true);
646 SetTrieValue(hTrie, "indigo", any 4915330, true);
647 SetTrieValue(hTrie, "ivory", any 16777200, true);
648 SetTrieValue(hTrie, "khaki", any 15787660, true);
649 SetTrieValue(hTrie, "lavender", any 15132410, true);
650 SetTrieValue(hTrie, "lavenderblush", any 16773365, true);
651 SetTrieValue(hTrie, "lawngreen", any 8190976, true);
652 SetTrieValue(hTrie, "legendary", any 13839590, true);
653 SetTrieValue(hTrie, "lemonchiffon", any 16775885, true);
654 SetTrieValue(hTrie, "lightblue", any 11393254, true);
655 SetTrieValue(hTrie, "lightcoral", any 15761536, true);
656 SetTrieValue(hTrie, "lightcyan", any 14745599, true);
657 SetTrieValue(hTrie, "lightgoldenrodyellow", any 16448210, true);
658 SetTrieValue(hTrie, "lightgray", any 13882323, true);
659 SetTrieValue(hTrie, "lightgrey", any 13882323, true);
660 SetTrieValue(hTrie, "lightgreen", any 10092441, true);
661 SetTrieValue(hTrie, "lightpink", any 16758465, true);
662 SetTrieValue(hTrie, "lightsalmon", any 16752762, true);
663 SetTrieValue(hTrie, "lightseagreen", any 2142890, true);
664 SetTrieValue(hTrie, "lightskyblue", any 8900346, true);
665 SetTrieValue(hTrie, "lightslategray", any 7833753, true);
666 SetTrieValue(hTrie, "lightslategrey", any 7833753, true);
667 SetTrieValue(hTrie, "lightsteelblue", any 11584734, true);
668 SetTrieValue(hTrie, "lightyellow", any 16777184, true);
669 SetTrieValue(hTrie, "lime", any 65280, true);
670 SetTrieValue(hTrie, "limegreen", any 3329330, true);
671 SetTrieValue(hTrie, "linen", any 16445670, true);
672 SetTrieValue(hTrie, "magenta", any 16711935, true);
673 SetTrieValue(hTrie, "maroon", any 8388608, true);
674 SetTrieValue(hTrie, "mediumaquamarine", any 6737322, true);
675 SetTrieValue(hTrie, "mediumblue", any 205, true);
676 SetTrieValue(hTrie, "mediumorchid", any 12211667, true);
677 SetTrieValue(hTrie, "mediumpurple", any 9662680, true);
678 SetTrieValue(hTrie, "mediumseagreen", any 3978097, true);
679 SetTrieValue(hTrie, "mediumslateblue", any 8087790, true);
680 SetTrieValue(hTrie, "mediumspringgreen", any 64154, true);
681 SetTrieValue(hTrie, "mediumturquoise", any 4772300, true);
682 SetTrieValue(hTrie, "mediumvioletred", any 13047173, true);
683 SetTrieValue(hTrie, "midnightblue", any 1644912, true);
684 SetTrieValue(hTrie, "mintcream", any 16121850, true);
685 SetTrieValue(hTrie, "mistyrose", any 16770273, true);
686 SetTrieValue(hTrie, "moccasin", any 16770229, true);
687 SetTrieValue(hTrie, "mythical", any 8931327, true);
688 SetTrieValue(hTrie, "navajowhite", any 16768685, true);
689 SetTrieValue(hTrie, "navy", any 128, true);
690 SetTrieValue(hTrie, "normal", any 11711154, true);
691 SetTrieValue(hTrie, "oldlace", any 16643558, true);
692 SetTrieValue(hTrie, "olive", any 10404687, true);
693 SetTrieValue(hTrie, "olivedrab", any 7048739, true);
694 SetTrieValue(hTrie, "orange", any 16753920, true);
695 SetTrieValue(hTrie, "orangered", any 16729344, true);
696 SetTrieValue(hTrie, "orchid", any 14315734, true);
697 SetTrieValue(hTrie, "palegoldenrod", any 15657130, true);
698 SetTrieValue(hTrie, "palegreen", any 10025880, true);
699 SetTrieValue(hTrie, "paleturquoise", any 11529966, true);
700 SetTrieValue(hTrie, "palevioletred", any 14184595, true);
701 SetTrieValue(hTrie, "papayawhip", any 16773077, true);
702 SetTrieValue(hTrie, "peachpuff", any 16767673, true);
703 SetTrieValue(hTrie, "peru", any 13468991, true);
704 SetTrieValue(hTrie, "pink", any 16761035, true);
705 SetTrieValue(hTrie, "plum", any 14524637, true);
706 SetTrieValue(hTrie, "powderblue", any 11591910, true);
707 SetTrieValue(hTrie, "purple", any 8388736, true);
708 SetTrieValue(hTrie, "rare", any 4942335, true);
709 SetTrieValue(hTrie, "red", any 16728128, true);
710 SetTrieValue(hTrie, "rosybrown", any 12357519, true);
711 SetTrieValue(hTrie, "royalblue", any 4286945, true);
712 SetTrieValue(hTrie, "saddlebrown", any 9127187, true);
713 SetTrieValue(hTrie, "salmon", any 16416882, true);
714 SetTrieValue(hTrie, "sandybrown", any 16032864, true);
715 SetTrieValue(hTrie, "seagreen", any 3050327, true);
716 SetTrieValue(hTrie, "seashell", any 16774638, true);
717 SetTrieValue(hTrie, "selfmade", any 7385162, true);
718 SetTrieValue(hTrie, "sienna", any 10506797, true);
719 SetTrieValue(hTrie, "silver", any 12632256, true);
720 SetTrieValue(hTrie, "skyblue", any 8900331, true);
721 SetTrieValue(hTrie, "slateblue", any 6970061, true);
722 SetTrieValue(hTrie, "slategray", any 7372944, true);
723 SetTrieValue(hTrie, "slategrey", any 7372944, true);
724 SetTrieValue(hTrie, "snow", any 16775930, true);
725 SetTrieValue(hTrie, "springgreen", any 65407, true);
726 SetTrieValue(hTrie, "steelblue", any 4620980, true);
727 SetTrieValue(hTrie, "strange", any 13593138, true);
728 SetTrieValue(hTrie, "tan", any 13808780, true);
729 SetTrieValue(hTrie, "teal", any 32896, true);
730 SetTrieValue(hTrie, "thistle", any 14204888, true);
731 SetTrieValue(hTrie, "tomato", any 16737095, true);
732 SetTrieValue(hTrie, "turquoise", any 4251856, true);
733 SetTrieValue(hTrie, "uncommon", any 11584473, true);
734 SetTrieValue(hTrie, "unique", any 16766720, true);
735 SetTrieValue(hTrie, "unusual", any 8802476, true);
736 SetTrieValue(hTrie, "valve", any 10817401, true);
737 SetTrieValue(hTrie, "vintage", any 4678289, true);
738 SetTrieValue(hTrie, "violet", any 15631086, true);
739 SetTrieValue(hTrie, "wheat", any 16113331, true);
740 SetTrieValue(hTrie, "white", any 16777215, true);
741 SetTrieValue(hTrie, "whitesmoke", any 16119285, true);
742 SetTrieValue(hTrie, "yellow", any 16776960, true);
743 SetTrieValue(hTrie, "yellowgreen", any 10145074, true);
744 return hTrie;
745}
746
747public void OnPluginStart()
748{
749 char strModName[32];
750 GetGameFolderName(strModName, 32);
751 if (!StrEqual(strModName, "tf", true))
752 {
753 SetFailState("This plugin is only for Team Fortress 2.");
754 }
755 CreateConVar("tf_dodgeball_version", "2.1.0", "[TF2] Dodgeball [Rewritten]", 0, false, 0, false, 0);
756 g_hCvarEnabled = CreateConVar("tf_dodgeball_enabled", "1", "Enable Dodgeball on TFDB maps?", 0, true, 0, true, 1);
757 g_hCvarEnableCfgFile = CreateConVar("tf_dodgeball_enablecfg", "sourcemod/dodgeball_enable.cfg", "Config file to execute when enabling the Dodgeball game mode.", 0, false, 0, false, 0);
758 g_hCvarDisableCfgFile = CreateConVar("tf_dodgeball_disablecfg", "sourcemod/dodgeball_disable.cfg", "Config file to execute when disabling the Dodgeball game mode.", 0, false, 0, false, 0);
759 g_hCvarVotePercent = CreateConVar("tf_dodgeball_votepercent", "0.4", "Percentage Required To Start Vote", 0, true, 0, true, 1);
760 g_hCvarVoteSpeedEnabled = CreateConVar("tf_dodgeball_enablevotespeed", "1", "Enable Voting of Speed", 0, true, 0, true, 1);
761 g_hCvarVoteCountEnabled = CreateConVar("tf_dodgeball_enablevotecount", "1", "Enable Voting of Count", 0, true, 0, true, 1);
762 g_hCvarDisableReason = CreateConVar("tf_dodgeball_votedisablereason", "Disabled", "Reason for disabling", 0, false, 0, false, 0);
763 g_hCvarEnablePAB = CreateConVar("tf_dodgeball_disableplayerairblast", "1", "Enables the ability to airblast other players", 0, true, 0, true, 1);
764 g_hCvarTopSpeedHolder = CreateConVar("tf_db_topspeedholder", "Nobody", "Name for topspeed #1", 8192, false, 0, false, 0);
765 g_hCvarTopSpeedMPH = CreateConVar("tf_db_topspeedmph", "0", "MPH for topspeed #1", 8192, false, 0, false, 0);
766 g_hRocketClassTrie = CreateTrie();
767 g_hSpawnersTrie = CreateTrie();
768 g_Announce = CreateConVar("tfdb_announce", "1", "Enable kill announces in chat", 0, false, 0, false, 0);
769 g_hHud = CreateHudSynchronizer();
770 MaxDB_Hud = CreateHudSynchronizer();
771 RegisterCommands();
772 InitDB(5924);
773 TopRocketSpeed = BuildTopSpeed();
774 return void 0;
775}
776
777public void OnMapStart()
778{
779 g_Voters = 0;
780 g_SpeedVotes = 0;
781 g_CountVotes = 0;
782 g_VotesNeeded = 0;
783 Steam_SetGameDescription("MaxDB Dodgeball");
784 PrecacheModel("models/buildables/sentry_shield.mdl", true);
785 TopRocketSpeed = BuildTopSpeed();
786 int i = 1;
787 while (i <= MaxClients)
788 {
789 if (IsClientConnected(i))
790 {
791 OnClientConnected(i);
792 i++;
793 }
794 i++;
795 }
796 CreateTimer(1, Timer_MaxDB_Hud, any 0, 1);
797 return void 0;
798}
799
800public void OnClientConnected(int client)
801{
802 if (IsFakeClient(client))
803 {
804 return void 0;
805 }
806 g_SpeedVoted[client] = 0;
807 g_CountVoted[client] = 0;
808 g_Voters += 1;
809 g_VotesNeeded = RoundToFloor(FloatMul(float(g_Voters), ConVar.FloatValue.get(g_hCvarVotePercent)));
810 return void 0;
811}
812
813public void OnClientPutInServer(int client)
814{
815 SDKHook(client, SDKHookType 2, SDKHookCB 231);
816 return void 0;
817}
818
819
820/* ERROR! Unrecognized opcode dec */
821 function "OnClientDisconnect" (number 30)
822public void OnConfigsExecuted()
823{
824 int var1;
825 if (GetConVarBool(g_hCvarEnabled))
826 {
827 EnableDodgeBall();
828 ConVar.GetString(g_hCvarDisableReason, Fishy_DisableReason, 1000);
829 }
830 return void 0;
831}
832
833public void OnMapEnd()
834{
835 DisableDodgeBall();
836 return void 0;
837}
838
839public bool IsDodgeBallMap()
840{
841 char strMap[64];
842 GetCurrentMap(strMap, 64);
843 return StrContains(strMap, "tfdb_", false) == 0;
844}
845
846public void EnableDodgeBall()
847{
848 if (!g_bEnabled)
849 {
850 char strMapName[64];
851 GetCurrentMap(strMapName, 64);
852 char strMapFile[256];
853 Format(strMapFile, 256, "%s.cfg", strMapName);
854 ParseConfigurations("general.cfg");
855 ParseConfigurations(strMapFile);
856 if (!g_iRocketClassCount)
857 {
858 SetFailState("No rocket class defined.");
859 }
860 if (!g_iSpawnersCount)
861 {
862 SetFailState("No spawner class defined.");
863 }
864 if (g_iDefaultRedSpawner == -1)
865 {
866 SetFailState("No spawner class definition for the Red spawners exists in the config file.");
867 }
868 if (g_iDefaultBluSpawner == -1)
869 {
870 SetFailState("No spawner class definition for the Blu spawners exists in the config file.");
871 }
872 HookEvent("teamplay_round_start", EventHook 255, EventHookMode 2);
873 HookEvent("teamplay_setup_finished", EventHook 257, EventHookMode 2);
874 HookEvent("teamplay_round_win", EventHook 253, EventHookMode 2);
875 HookEvent("player_spawn", EventHook 249, EventHookMode 1);
876 HookEvent("player_death", EventHook 243, EventHookMode 0);
877 HookEvent("post_inventory_application", EventHook 245, EventHookMode 1);
878 HookEvent("teamplay_broadcast_audio", EventHook 221, EventHookMode 0);
879 PrecacheSound("weapons/sentry_rocket.wav", true);
880 PrecacheSound("weapons/sentry_scan.wav", true);
881 PrecacheSound("weapons/sentry_spot.wav", true);
882 PrecacheSound("misc/sniper_railgun_double_kill.wav", true);
883 if (g_bMusicEnabled == true)
884 {
885 if (g_bMusic[0][0])
886 {
887 int var1 = g_strMusic;
888 PrecacheSoundEx(var1[0][0][var1], true, true);
889 }
890 if (g_bMusic[4][0])
891 {
892 PrecacheSoundEx(g_strMusic[4][0], true, true);
893 }
894 if (g_bMusic[8][0])
895 {
896 PrecacheSoundEx(g_strMusic[8][0], true, true);
897 }
898 if (g_bMusic[12][0])
899 {
900 PrecacheSoundEx(g_strMusic[12][0], true, true);
901 }
902 }
903 PrecacheParticle("fireSmokeExplosion");
904 PrecacheParticle("fireSmokeExplosion1");
905 PrecacheParticle("fireSmokeExplosion2");
906 PrecacheParticle("fireSmokeExplosion3");
907 PrecacheParticle("fireSmokeExplosion4");
908 PrecacheParticle("fireSmoke_collumnP");
909 int i = 0;
910 while (i < g_iRocketClassCount)
911 {
912 RocketFlags iFlags = g_iRocketClassFlags[i][0][0];
913 if (!!iFlags & 1024)
914 {
915 PrecacheModelEx(g_strRocketClassModel[i][0][0], true, true);
916 }
917 if (!!iFlags & 2048)
918 {
919 PrecacheSoundEx(g_strRocketClassSpawnSound[i][0][0], true, true);
920 }
921 if (!!iFlags & 4096)
922 {
923 PrecacheSoundEx(g_strRocketClassBeepSound[i][0][0], true, true);
924 }
925 if (!!iFlags & 8192)
926 {
927 PrecacheSoundEx(g_strRocketClassAlertSound[i][0][0], true, true);
928 i++;
929 }
930 i++;
931 }
932 char strCfgFile[64];
933 GetConVarString(g_hCvarEnableCfgFile, strCfgFile, 64);
934 ServerCommand("exec \"%s\"", strCfgFile);
935 g_bEnabled = 1;
936 g_bRoundStarted = 0;
937 g_iRoundCount = 0;
938 }
939 return void 0;
940}
941
942public void DisableDodgeBall()
943{
944 if (g_bEnabled == true)
945 {
946 DestroyRockets();
947 DestroyRocketClasses();
948 DestroySpawners();
949 if (g_hLogicTimer)
950 {
951 KillTimer(g_hLogicTimer, false);
952 }
953 g_hLogicTimer = 0;
954 g_bMusic[12] = 0;
955 g_bMusic[8] = 0;
956 g_bMusic[4] = 0;
957 g_bMusic[0] = 0;
958 UnhookEvent("teamplay_round_start", EventHook 255, EventHookMode 2);
959 UnhookEvent("teamplay_setup_finished", EventHook 257, EventHookMode 2);
960 UnhookEvent("teamplay_round_win", EventHook 253, EventHookMode 2);
961 UnhookEvent("player_spawn", EventHook 249, EventHookMode 1);
962 UnhookEvent("player_death", EventHook 243, EventHookMode 0);
963 UnhookEvent("post_inventory_application", EventHook 245, EventHookMode 1);
964 UnhookEvent("teamplay_broadcast_audio", EventHook 221, EventHookMode 0);
965 char strCfgFile[64];
966 GetConVarString(g_hCvarDisableCfgFile, strCfgFile, 64);
967 ServerCommand("exec \"%s\"", strCfgFile);
968 g_bEnabled = 0;
969 g_bRoundStarted = 0;
970 g_iRoundCount = 0;
971 }
972 return void 0;
973}
974
975public Action OnRoundStart(Event hEvent, char strEventName[], bool bDontBroadcast)
976{
977 if (g_bMusic[0][0])
978 {
979 int var1 = g_strMusic;
980 EmitSoundToAll(var1[0][0][var1], -2, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
981 }
982 g_iRocketSpeed = 0;
983 if (g_hTimerHud)
984 {
985 KillTimer(g_hTimerHud, false);
986 g_hTimerHud = 0;
987 }
988 g_hTimerHud = CreateTimer(0,4, Timer_HudSpeed, any 0, 1);
989 return Action 0;
990}
991
992public Action OnSetupFinished(Event hEvent, char strEventName[], bool bDontBroadcast)
993{
994 int var1;
995 if (g_bEnabled == true)
996 {
997 PopulateSpawnPoints();
998 if (!g_iLastDeadTeam)
999 {
1000 g_iLastDeadTeam = GetURandomIntRange(2, 3);
1001 }
1002 if (!IsValidClient(g_iLastDeadClient, false))
1003 {
1004 g_iLastDeadClient = 0;
1005 }
1006 g_hLogicTimer = CreateTimer(FloatDiv(1, 60), OnDodgeBallGameFrame, any 0, 1);
1007 g_iPlayerCount = CountAlivePlayers();
1008 g_iRocketsFired = 0;
1009 g_iCurrentRedSpawn = 0;
1010 g_iCurrentBluSpawn = 0;
1011 g_fNextSpawnTime = GetGameTime();
1012 g_bRoundStarted = 1;
1013 g_iRoundCount += 1;
1014 SetAmmoAll(1, 2);
1015 }
1016 return Action 0;
1017}
1018
1019public Action OnRoundEnd(Event hEvent, char strEventName[], bool bDontBroadcast)
1020{
1021 if (g_hTimerHud)
1022 {
1023 KillTimer(g_hTimerHud, false);
1024 g_hTimerHud = 0;
1025 }
1026 if (g_hLogicTimer)
1027 {
1028 KillTimer(g_hLogicTimer, false);
1029 g_hLogicTimer = 0;
1030 }
1031 if (g_bMusicEnabled == true)
1032 {
1033 if (g_bUseWebPlayer)
1034 {
1035 int iClient = 1;
1036 while (iClient <= MaxClients)
1037 {
1038 if (IsValidClient(iClient, false))
1039 {
1040 ShowHiddenMOTDPanel(iClient, "MusicPlayerStop", "http://0.0.0.0/", "2");
1041 if (!IsFakeClient(iClient))
1042 {
1043 ClearSyncHud(iClient, g_hHud);
1044 iClient++;
1045 }
1046 iClient++;
1047 }
1048 iClient++;
1049 }
1050 }
1051 if (g_bMusic[12][0])
1052 {
1053 StopSoundToAll(32, g_strMusic[12][0]);
1054 }
1055 }
1056 DestroyRockets();
1057 g_bRoundStarted = 0;
1058 return Action 0;
1059}
1060
1061public Action OnPlayerSpawn(Event hEvent, char strEventName[], bool bDontBroadcast)
1062{
1063 int iClient = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
1064 if (!IsValidClient(iClient, false))
1065 {
1066 return Action 0;
1067 }
1068 TFClassType iClass = TF2_GetPlayerClass(iClient);
1069 int var1;
1070 if (iClass == TFClassType 7)
1071 {
1072 TF2_SetPlayerClass(iClient, TFClassType 7, false, true);
1073 TF2_RespawnPlayer(iClient);
1074 }
1075 return Action 0;
1076}
1077
1078public Action OnPlayerDeath(Event hEvent, char strEventName[], bool bDontBroadcast)
1079{
1080 if (g_bRoundStarted)
1081 {
1082 int iAttacker = GetClientOfUserId(GetEventInt(hEvent, "attacker", 0));
1083 int iVictim = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
1084 if (IsValidClient(iVictim, false))
1085 {
1086 g_iLastDeadClient = iVictim;
1087 g_iLastDeadTeam = GetClientTeam(iVictim);
1088 int iInflictor = GetEventInt(hEvent, "inflictor_entindex", 0);
1089 int iIndex = FindRocketByEntity(iInflictor);
1090 if (iIndex != -1)
1091 {
1092 int iClass = g_iRocketClass[iIndex][0][0];
1093 int iTarget = EntRefToEntIndex(g_iRocketTarget[iIndex][0][0]);
1094 float fSpeed = g_fRocketSpeed[iIndex][0][0];
1095 int iDeflections = g_iRocketDeflections[iIndex][0][0];
1096 if (GetConVarBool(g_Announce))
1097 {
1098 CPrintToChatAll("{lightseagreen}[MaxDB] {chartreuse}%N {gray}died to a rocket traveling {aqua}%i{gray} MPH!", 5328, 5340);
1099 UpdatePlayerTopSpeed(g_iLastDeadClient, g_iRocketSpeed);
1100 }
1101 int var1;
1102 if (g_iRocketFlags[iIndex][0][0] & RocketFlags 512)
1103 {
1104 ExecuteCommands(g_hRocketClassCmdsOnExplode[iClass][0][0], iClass, iInflictor, iAttacker, iTarget, g_iLastDeadClient, fSpeed, iDeflections);
1105 int var2 = g_iRocketFlags[iIndex];
1106 var2 = var2[0][0] | 32;
1107 }
1108 if (!!g_iRocketFlags[iIndex][0][0] & 256)
1109 {
1110 ExecuteCommands(g_hRocketClassCmdsOnKill[iClass][0][0], iClass, iInflictor, iAttacker, iTarget, g_iLastDeadClient, fSpeed, iDeflections);
1111 }
1112 }
1113 }
1114 SetRandomSeed(GetGameTime());
1115 return Action 0;
1116 }
1117 return Action 0;
1118}
1119
1120public Action OnPlayerInventory(Event hEvent, char strEventName[], bool bDontBroadcast)
1121{
1122 int iClient = GetClientOfUserId(GetEventInt(hEvent, "userid", 0));
1123 if (!IsValidClient(iClient, false))
1124 {
1125 return Action 0;
1126 }
1127 if (!IsClientInGame(iClient))
1128 {
1129 return Action 0;
1130 }
1131 if (IsFakeClient(iClient))
1132 {
1133 return Action 0;
1134 }
1135 char SteamID[64];
1136 int iSlot = 1;
1137 while (iSlot < 5)
1138 {
1139 int iEntity = GetPlayerWeaponSlot(iClient, iSlot);
1140 int var1;
1141 if (iSlot == 1)
1142 {
1143 GetClientAuthId(iClient, AuthIdType 3, SteamID, 64, true);
1144 int var2;
1145 if (GetEntProp(iEntity, PropType 0, "m_iItemDefinitionIndex", 4, 0) != 740)
1146 {
1147 TF2Items_GiveWeapon(iClient, 740);
1148 ChangePlayerWeaponSlot(iClient, 0);
1149 iSlot++;
1150 }
1151 iSlot++;
1152 }
1153 else
1154 {
1155 if (iEntity != -1)
1156 {
1157 RemoveEdict(iEntity);
1158 iSlot++;
1159 }
1160 iSlot++;
1161 }
1162 iSlot++;
1163 }
1164 return Action 0;
1165}
1166
1167public Action OnClientTakeDamage(int victim, &int attacker, &int inflictor, &float damage, &int damagetype, &int weapon, float damageForce[3], float damagePosition[3])
1168{
1169 char sWeapon[64];
1170 if (!IsValidEdict(inflictor))
1171 {
1172 return Action 0;
1173 }
1174 if (!GetEdictClassname(inflictor, sWeapon, 64))
1175 {
1176 return Action 0;
1177 }
1178 if (StrEqual(sWeapon, "tf_projectile_flare", true))
1179 {
1180 float vecOrigin[3];
1181 float Super_Flare_Scale = FloatMul(Flare_Weapon_Knockback_Scale, Flare_Weapon_Knockback_Scale_Multiplier);
1182 GetClientAbsOrigin(victim, vecOrigin);
1183 if (GetURandomIntRange(1, 20) == 1)
1184 {
1185 ScaleVector(damageForce, Super_Flare_Scale);
1186 EmitSoundToAll("misc/sniper_railgun_double_kill.wav", -2, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1187 }
1188 else
1189 {
1190 ScaleVector(damageForce, Flare_Weapon_Knockback_Scale);
1191 }
1192 TeleportEntity(victim, vecOrigin, NULL_VECTOR, damageForce);
1193 damage = 0;
1194 return Action 1;
1195 }
1196 if (StrEqual(sWeapon, "worldspawn", true))
1197 {
1198 damage = 0;
1199 return Action 1;
1200 }
1201 return Action 0;
1202}
1203
1204public Action TauntCmd(int iClient, char strCommand[], int iArgs)
1205{
1206 if (!IsValidClient(iClient, false))
1207 {
1208 return Action 0;
1209 }
1210 int iWeapon = GetEntPropEnt(iClient, PropType 0, "m_hActiveWeapon", 0);
1211 int var1;
1212 if (iWeapon > MaxClients)
1213 {
1214 char sWeaponClass[64];
1215 GetEdictClassname(iWeapon, sWeaponClass, 64);
1216 if (StrEqual(sWeaponClass, "tf_weapon_flaregun", true))
1217 {
1218 return Action 3;
1219 }
1220 int iEntity = GetPlayerWeaponSlot(iClient, 0);
1221 int iDefIndex = GetEntProp(iEntity, PropType 0, "m_iItemDefinitionIndex", 4, 0);
1222 int var2;
1223 if (iDefIndex == 741)
1224 {
1225 return Action 3;
1226 }
1227 }
1228 return Action 0;
1229}
1230
1231public Action OnPlayerRunCmd(int iClient, &int iButtons, &int iImpulse, float fVelocity[3], float fAngles[3], &int iWeapon)
1232{
1233 char SteamID[64];
1234 GetClientAuthId(iClient, AuthIdType 3, SteamID, 64, true);
1235 int var1;
1236 if (g_bEnabled)
1237 {
1238 int iCWeapon = GetEntPropEnt(iClient, PropType 0, "m_hActiveWeapon", 0);
1239 int var2;
1240 if (iCWeapon > MaxClients)
1241 {
1242 char sWeaponClass[64];
1243 GetEdictClassname(iCWeapon, sWeaponClass, 64);
1244 if (!StrEqual(sWeaponClass, "tf_weapon_flaregun", true))
1245 {
1246 iButtons = iButtons & -2;
1247 }
1248 }
1249 if (ConVar.BoolValue.get(g_hCvarEnablePAB))
1250 {
1251 if (IsValidClient(iClient, true))
1252 {
1253 if (!GetEntityFlags(iClient) & 32768)
1254 {
1255 SetEntityFlags(iClient, GetEntityFlags(iClient) | 32768);
1256 }
1257 }
1258 }
1259 }
1260 return Action 0;
1261}
1262
1263public Action OnBroadcastAudio(Event hEvent, char strEventName[], bool bDontBroadcast)
1264{
1265 if (g_bMusicEnabled == true)
1266 {
1267 char strSound[256];
1268 GetEventString(hEvent, "sound", strSound, 256, "");
1269 int iTeam = GetEventInt(hEvent, "team", 0);
1270 if (StrEqual(strSound, "Announcer.AM_RoundStartRandom", true) == 1)
1271 {
1272 if (g_bUseWebPlayer)
1273 {
1274 int iClient = 1;
1275 while (iClient <= MaxClients)
1276 {
1277 if (IsValidClient(iClient, false))
1278 {
1279 ShowHiddenMOTDPanel(iClient, "MusicPlayerStart", g_strWebPlayerUrl, "2");
1280 iClient++;
1281 }
1282 iClient++;
1283 }
1284 return Action 3;
1285 }
1286 if (g_bMusic[12][0])
1287 {
1288 EmitSoundToAll(g_strMusic[12][0], -2, 32, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1289 return Action 3;
1290 }
1291 }
1292 else
1293 {
1294 if (StrEqual(strSound, "Game.YourTeamWon", true) == 1)
1295 {
1296 if (g_bMusic[4][0])
1297 {
1298 int iClient = 1;
1299 while (iClient <= MaxClients)
1300 {
1301 int var1;
1302 if (IsValidClient(iClient, false))
1303 {
1304 EmitSoundToClient(iClient, g_strMusic[4][0], -2, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1305 iClient++;
1306 }
1307 iClient++;
1308 }
1309 return Action 3;
1310 }
1311 }
1312 if (StrEqual(strSound, "Game.YourTeamLost", true) == 1)
1313 {
1314 if (g_bMusic[8][0])
1315 {
1316 int iClient = 1;
1317 while (iClient <= MaxClients)
1318 {
1319 int var2;
1320 if (IsValidClient(iClient, false))
1321 {
1322 EmitSoundToClient(iClient, g_strMusic[8][0], -2, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1323 iClient++;
1324 }
1325 iClient++;
1326 }
1327 return Action 3;
1328 }
1329 return Action 3;
1330 }
1331 }
1332 }
1333 return Action 0;
1334}
1335
1336public Action OnDodgeBallGameFrame(Handle hTimer, any Data)
1337{
1338 if (BothTeamsPlaying())
1339 {
1340 if (__FLOAT_GE__(GetGameTime(), g_fNextSpawnTime))
1341 {
1342 if (g_iLastDeadTeam == 2)
1343 {
1344 int iSpawnerEntity = g_iSpawnPointsRedEntity[g_iCurrentRedSpawn][0][0];
1345 int iSpawnerClass = g_iSpawnPointsRedClass[g_iCurrentRedSpawn][0][0];
1346 if (g_iSpawnersMaxRockets[iSpawnerClass][0][0] > g_iRocketCount)
1347 {
1348 CreateRocket(iSpawnerEntity, iSpawnerClass, 2);
1349 g_iCurrentRedSpawn = g_iCurrentRedSpawn + 1;
1350 }
1351 }
1352 int iSpawnerEntity = g_iSpawnPointsBluEntity[g_iCurrentBluSpawn][0][0];
1353 int iSpawnerClass = g_iSpawnPointsBluClass[g_iCurrentBluSpawn][0][0];
1354 if (g_iSpawnersMaxRockets[iSpawnerClass][0][0] > g_iRocketCount)
1355 {
1356 CreateRocket(iSpawnerEntity, iSpawnerClass, 3);
1357 g_iCurrentBluSpawn = g_iCurrentBluSpawn + 1;
1358 }
1359 }
1360 int iIndex = -1;
1361 int var1 = FindNextValidRocket(iIndex, false);
1362 iIndex = var1;
1363 while (var1 != -1)
1364 {
1365 switch (g_iRocketClassBehaviour[g_iRocketClass[iIndex][0][0]][0][0])
1366 {
1367 case 0: {
1368 }
1369 case 1: {
1370 HomingRocketThink(iIndex);
1371 }
1372 default: {
1373 }
1374 }
1375 }
1376 return Action 0;
1377 }
1378 return Action 0;
1379}
1380
1381public Action Timer_HudSpeed(Handle hTimer)
1382{
1383 SetHudTextParams(-1, 0,9, 0,5, 127, 255, 0, 255, 0, 6, 0,1, 0,2);
1384 int iClient = 1;
1385 while (iClient <= MaxClients)
1386 {
1387 if (IsValidClient(iClient, false))
1388 {
1389 if (!IsFakeClient(iClient))
1390 {
1391 if (g_iRocketSpeed)
1392 {
1393 iClient++;
1394 }
1395 iClient++;
1396 }
1397 iClient++;
1398 }
1399 iClient++;
1400 }
1401 return Action 0;
1402}
1403
1404public Action Timer_MaxDB_Hud(Handle hTimer)
1405{
1406 SetHudTextParams(0,05, 0,05, 1,1, 0, 206, 209, 255, 0, 6, 0,1, 0,2);
1407 int iClient = 1;
1408 while (iClient <= MaxClients)
1409 {
1410 int var1;
1411 if (IsValidClient(iClient, false))
1412 {
1413 ShowSyncHudText(iClient, MaxDB_Hud, "MaxDB.NET");
1414 iClient++;
1415 }
1416 iClient++;
1417 }
1418 return Action 0;
1419}
1420
1421public void CreateRocket(int iSpawnerEntity, int iSpawnerClass, int iTeam)
1422{
1423 int iIndex = FindFreeRocketSlot();
1424 if (iIndex != -1)
1425 {
1426 int iClass = GetRandomRocketClass(iSpawnerClass);
1427 RocketFlags iFlags = g_iRocketClassFlags[iClass][0][0];
1428 int iEntity;
1429 int var1;
1430 if (!!iFlags & 32768)
1431 {
1432 var1[0] = 658720;
1433 }
1434 else
1435 {
1436 var1[0] = 658748;
1437 }
1438 iEntity = CreateEntityByName(var1, -1);
1439 int var2;
1440 if (iEntity)
1441 {
1442 float fPosition[3];
1443 float fAngles[3];
1444 float fDirection[3];
1445 GetEntPropVector(iSpawnerEntity, PropType 0, "m_vecOrigin", fPosition, 0);
1446 GetEntPropVector(iSpawnerEntity, PropType 0, "m_angRotation", fAngles, 0);
1447 GetAngleVectors(fAngles, fDirection, NULL_VECTOR, NULL_VECTOR);
1448 SetEntPropEnt(iEntity, PropType 0, "m_hOwnerEntity", 0, 0);
1449 int var3;
1450 if (__FLOAT_LE__(GetURandomFloatRange(0, 100), g_fRocketClassCritChance[iClass][0][0]))
1451 {
1452 var3 = 1;
1453 }
1454 else
1455 {
1456 var3 = 0;
1457 }
1458 SetEntProp(iEntity, PropType 0, "m_bCritical", var3, 1, 0);
1459 SetEntProp(iEntity, PropType 0, "m_iTeamNum", iTeam, 1, 0);
1460 SetEntProp(iEntity, PropType 0, "m_iDeflected", any 1, 4, 0);
1461 TeleportEntity(iEntity, fPosition, fAngles, 658856);
1462 int iTargetTeam;
1463 int var4;
1464 if (!!iFlags & 16)
1465 {
1466 var4 = 0;
1467 }
1468 else
1469 {
1470 var4 = GetAnalogueTeam(iTeam);
1471 }
1472 iTargetTeam = var4;
1473 int iTarget = SelectTarget(iTargetTeam, -1);
1474 float fModifier = CalculateModifier(iClass, 0);
1475 g_bRocketIsValid[iIndex] = 1;
1476 g_iRocketFlags[iIndex] = iFlags;
1477 g_iRocketEntity[iIndex] = EntIndexToEntRef(iEntity);
1478 g_iRocketTarget[iIndex] = EntIndexToEntRef(iTarget);
1479 g_iRocketSpawner[iIndex] = iSpawnerClass;
1480 g_iRocketClass[iIndex] = iClass;
1481 g_iRocketDeflections[iIndex] = 0;
1482 g_fRocketLastDeflectionTime[iIndex] = GetGameTime();
1483 g_fRocketLastBeepTime[iIndex] = GetGameTime();
1484 g_fRocketSpeed[iIndex] = CalculateRocketSpeed(iClass, fModifier);
1485 g_iRocketSpeed = RoundFloat(FloatMul(0,042614, g_fRocketSpeed[iIndex][0][0]));
1486 CopyVectors(fDirection, g_fRocketDirection[iIndex][0][0]);
1487 SetEntDataFloat(iEntity, FindSendPropInfo("CTFProjectile_Rocket", "m_iDeflected", 0, 0, 0) + 4, CalculateRocketDamage(iClass, fModifier), true);
1488 DispatchSpawn(iEntity);
1489 AttachLight(iIndex);
1490 if (!!iFlags & 1024)
1491 {
1492 SetEntityModel(iEntity, g_strRocketClassModel[iClass][0][0]);
1493 UpdateRocketSkin(iEntity, iTeam, !!iFlags & 16);
1494 }
1495 if (!!iFlags & 64)
1496 {
1497 ExecuteCommands(g_hRocketClassCmdsOnSpawn[iClass][0][0], iClass, iEntity, 0, iTarget, g_iLastDeadClient, g_fRocketSpeed[iIndex][0][0], 0);
1498 }
1499 EmitRocketSound(RocketSound 0, iClass, iEntity, iTarget, iFlags);
1500 EmitRocketSound(RocketSound 2, iClass, iEntity, iTarget, iFlags);
1501 g_iRocketCount += 1;
1502 g_iRocketsFired += 1;
1503 g_fNextSpawnTime = FloatAdd(GetGameTime(), g_fSpawnersInterval[iSpawnerClass][0][0]);
1504 }
1505 }
1506 return void 0;
1507}
1508
1509public void AttachLight(int rIndex)
1510{
1511 int index = EntRefToEntIndex(g_iRocketEntity[rIndex][0][0]);
1512 if (index == -1)
1513 {
1514 return void 0;
1515 }
1516 char UnderGlow[64];
1517 int iLightEntity = CreateEntityByName("light_dynamic", -1);
1518 if (IsValidEntity(iLightEntity))
1519 {
1520 DispatchKeyValue(iLightEntity, "inner_cone", "0");
1521 DispatchKeyValue(iLightEntity, "cone", "80");
1522 DispatchKeyValue(iLightEntity, "brightness", "5");
1523 DispatchKeyValueFloat(iLightEntity, "spotlight_radius", 100);
1524 DispatchKeyValueFloat(iLightEntity, "distance", 150);
1525 DispatchKeyValue(iLightEntity, "_light", UnderGlow);
1526 DispatchKeyValue(iLightEntity, "pitch", "-90");
1527 DispatchKeyValue(iLightEntity, "style", "0");
1528 DispatchSpawn(iLightEntity);
1529 float fOrigin[3];
1530 GetEntPropVector(index, PropType 1, "m_vecOrigin", fOrigin, 0);
1531 int var1 = fOrigin[8];
1532 var1 = FloatSub(var1, 80);
1533 TeleportEntity(iLightEntity, fOrigin, NULL_VECTOR, NULL_VECTOR);
1534 char strName[32];
1535 Format(strName, 32, "target%i", index);
1536 DispatchKeyValue(index, "targetname", strName);
1537 DispatchKeyValue(iLightEntity, "parentname", strName);
1538 SetVariantString("!activator");
1539 AcceptEntityInput(iLightEntity, "SetParent", index, iLightEntity, 0);
1540 AcceptEntityInput(iLightEntity, "TurnOn", -1, -1, 0);
1541 }
1542 return void 0;
1543}
1544
1545
1546/* ERROR! Unrecognized opcode dec */
1547 function "DestroyRocket" (number 51)
1548public void DestroyRockets()
1549{
1550 int iIndex = 0;
1551 while (iIndex < 1000)
1552 {
1553 DestroyRocket(iIndex);
1554 iIndex++;
1555 }
1556 g_iRocketCount = 0;
1557 return void 0;
1558}
1559
1560
1561/* ERROR! Unrecognized opcode dec */
1562 function "IsValidRocket" (number 53)
1563public int FindNextValidRocket(int iIndex, bool bWrap)
1564{
1565 int iCurrent = iIndex + 1;
1566 while (iCurrent < 1000)
1567 {
1568 if (IsValidRocket(iCurrent))
1569 {
1570 return iCurrent;
1571 }
1572 iCurrent++;
1573 }
1574 int var1;
1575 if (bWrap == true)
1576 {
1577 var1 = FindNextValidRocket(-1, false);
1578 }
1579 else
1580 {
1581 var1 = -1;
1582 }
1583 return var1;
1584}
1585
1586public int FindFreeRocketSlot()
1587{
1588 int iIndex = g_iLastCreatedRocket;
1589 int iCurrent = iIndex;
1590 while (!IsValidRocket(iCurrent))
1591 {
1592 iCurrent++;
1593 if (iCurrent == 1000)
1594 {
1595 iCurrent = 0;
1596 }
1597 if (iIndex != iCurrent)
1598 {
1599 }
1600 else
1601 {
1602 return -1;
1603 }
1604 }
1605 return iCurrent;
1606}
1607
1608public int FindRocketByEntity(int iEntity)
1609{
1610 int iIndex = -1;
1611 int var1 = FindNextValidRocket(iIndex, false);
1612 iIndex = var1;
1613 while (var1 != -1)
1614 {
1615 if (iEntity == EntRefToEntIndex(g_iRocketEntity[iIndex][0][0]))
1616 {
1617 return iIndex;
1618 }
1619 }
1620 return -1;
1621}
1622
1623public void HomingRocketThink(int iIndex)
1624{
1625 int iEntity = EntRefToEntIndex(g_iRocketEntity[iIndex][0][0]);
1626 int iClass = g_iRocketClass[iIndex][0][0];
1627 RocketFlags iFlags = g_iRocketFlags[iIndex][0][0];
1628 int iTarget = EntRefToEntIndex(g_iRocketTarget[iIndex][0][0]);
1629 int iTeam = GetEntProp(iEntity, PropType 0, "m_iTeamNum", 1, 0);
1630 int iTargetTeam;
1631 int var1;
1632 if (!!iFlags & 16)
1633 {
1634 var1 = 0;
1635 }
1636 else
1637 {
1638 var1 = GetAnalogueTeam(iTeam);
1639 }
1640 iTargetTeam = var1;
1641 int iDeflectionCount = GetEntProp(iEntity, PropType 0, "m_iDeflected", 4, 0) + -1;
1642 float fModifier = CalculateModifier(iClass, iDeflectionCount);
1643 if (!IsValidClient(iTarget, true))
1644 {
1645 iTarget = SelectTarget(iTargetTeam, -1);
1646 DestroyRocket(iIndex);
1647 if (!IsValidClient(iTarget, true))
1648 {
1649 return void 0;
1650 }
1651 g_iRocketTarget[iIndex] = EntIndexToEntRef(iTarget);
1652 }
1653 else
1654 {
1655 if (g_iRocketDeflections[iIndex][0][0] < iDeflectionCount)
1656 {
1657 int iClient = GetEntPropEnt(iEntity, PropType 0, "m_hOwnerEntity", 0);
1658 int Original_TargetTeam = GetClientTeam(iTarget);
1659 if (IsValidClient(iClient, false))
1660 {
1661 float fViewAngles[3];
1662 float fDirection[3];
1663 GetClientEyeAngles(iClient, fViewAngles);
1664 GetAngleVectors(fViewAngles, fDirection, NULL_VECTOR, NULL_VECTOR);
1665 CopyVectors(fDirection, g_fRocketDirection[iIndex][0][0]);
1666 UpdateRocketSkin(iEntity, iTeam, !!iFlags & 16);
1667 }
1668 iTarget = SelectTarget(iTargetTeam, iIndex);
1669 int var2;
1670 if (g_newtarget_bool == true)
1671 {
1672 g_newtarget_bool = 0;
1673 iTarget = g_newtarget_int;
1674 }
1675 g_iRocketTarget[iIndex] = EntIndexToEntRef(iTarget);
1676 g_iRocketDeflections[iIndex] = iDeflectionCount;
1677 g_fRocketLastDeflectionTime[iIndex] = GetGameTime();
1678 g_fRocketSpeed[iIndex] = CalculateRocketSpeed(iClass, fModifier);
1679 g_iRocketSpeed = RoundFloat(FloatMul(0,042614, g_fRocketSpeed[iIndex][0][0]));
1680 SetEntDataFloat(iEntity, FindSendPropInfo("CTFProjectile_Rocket", "m_iDeflected", 0, 0, 0) + 4, CalculateRocketDamage(iClass, fModifier), true);
1681 if (!!iFlags & 8)
1682 {
1683 int var3 = g_iRocketFlags[iIndex];
1684 var3 = var3[0][0] | 16384;
1685 }
1686 EmitRocketSound(RocketSound 2, iClass, iEntity, iTarget, iFlags);
1687 if (!!iFlags & 128)
1688 {
1689 ExecuteCommands(g_hRocketClassCmdsOnDeflect[iClass][0][0], iClass, iEntity, iClient, iTarget, g_iLastDeadClient, g_fRocketSpeed[iIndex][0][0], iDeflectionCount);
1690 }
1691 PrintHintTextToAll("%i MPH", 5340);
1692 }
1693 if (__FLOAT_GE__(FloatSub(GetGameTime(), g_fRocketLastDeflectionTime[iIndex][0][0]), g_fRocketClassControlDelay[iClass][0][0]))
1694 {
1695 float fTurnRate = CalculateRocketTurnRate(iClass, fModifier);
1696 float fDirectionToTarget[3];
1697 CalculateDirectionToClient(iEntity, iTarget, fDirectionToTarget);
1698 if (g_iRocketFlags[iIndex][0][0] & RocketFlags 16384)
1699 {
1700 if (__FLOAT_LT__(g_fRocketDirection[iIndex][0][0][8], g_fRocketClassElevationLimit[iClass][0][0]))
1701 {
1702 g_fRocketDirection[iIndex][0][0][8] = FMin(FloatAdd(g_fRocketDirection[iIndex][0][0][8], g_fRocketClassElevationRate[iClass][0][0]), g_fRocketClassElevationLimit[iClass][0][0]);
1703 fDirectionToTarget[8] = g_fRocketDirection[iIndex][0][0][8];
1704 }
1705 int var4 = g_iRocketFlags[iIndex];
1706 var4 = var4[0][0] & -16385;
1707 }
1708 LerpVectors(g_fRocketDirection[iIndex][0][0], fDirectionToTarget, g_fRocketDirection[iIndex][0][0], fTurnRate);
1709 }
1710 if (__FLOAT_GE__(FloatSub(GetGameTime(), g_fRocketLastBeepTime[iIndex][0][0]), g_fRocketClassBeepInterval[iClass][0][0]))
1711 {
1712 EmitRocketSound(RocketSound 1, iClass, iEntity, iTarget, iFlags);
1713 g_fRocketLastBeepTime[iIndex] = GetGameTime();
1714 }
1715 }
1716 ApplyRocketParameters(iIndex);
1717 return void 0;
1718}
1719
1720public float CalculateModifier(int iClass, int iDeflections)
1721{
1722 return FloatAdd(g_fRocketClassRocketsModifier[iClass][0][0] * g_iRocketsFired + iDeflections, g_fRocketClassPlayerModifier[iClass][0][0] * g_iPlayerCount);
1723}
1724
1725public float CalculateRocketDamage(int iClass, float fModifier)
1726{
1727 return FloatAdd(g_fRocketClassDamage[iClass][0][0], FloatMul(g_fRocketClassDamageIncrement[iClass][0][0], fModifier));
1728}
1729
1730public float CalculateRocketSpeed(int iClass, float fModifier)
1731{
1732 return FloatAdd(g_fRocketClassSpeed[iClass][0][0], FloatMul(g_fRocketClassSpeedIncrement[iClass][0][0], fModifier));
1733}
1734
1735public float CalculateRocketTurnRate(int iClass, float fModifier)
1736{
1737 return FloatAdd(g_fRocketClassTurnRate[iClass][0][0], FloatMul(g_fRocketClassTurnRateIncrement[iClass][0][0], fModifier));
1738}
1739
1740public void CalculateDirectionToClient(int iEntity, int iClient, float fOut[3])
1741{
1742 float fRocketPosition[3];
1743 GetEntPropVector(iEntity, PropType 0, "m_vecOrigin", fRocketPosition, 0);
1744 GetClientEyePosition(iClient, fOut);
1745 MakeVectorFromPoints(fRocketPosition, fOut, fOut);
1746 NormalizeVector(fOut, fOut);
1747 return void 0;
1748}
1749
1750public void ApplyRocketParameters(int iIndex)
1751{
1752 if (iIndex != -1)
1753 {
1754 int iEntity = EntRefToEntIndex(g_iRocketEntity[iIndex][0][0]);
1755 if (iEntity != -1)
1756 {
1757 float fAngles[3];
1758 GetVectorAngles(g_fRocketDirection[iIndex][0][0], fAngles);
1759 float fVelocity[3];
1760 CopyVectors(g_fRocketDirection[iIndex][0][0], fVelocity);
1761 ScaleVector(fVelocity, g_fRocketSpeed[iIndex][0][0]);
1762 SetEntPropVector(iEntity, PropType 1, "m_vecAbsVelocity", fVelocity, 0);
1763 SetEntPropVector(iEntity, PropType 0, "m_angRotation", fAngles, 0);
1764 }
1765 }
1766 return void 0;
1767}
1768
1769public void UpdateRocketSkin(int iEntity, int iTeam, bool bNeutral)
1770{
1771 if (bNeutral == true)
1772 {
1773 SetEntProp(iEntity, PropType 0, "m_nSkin", any 2, 4, 0);
1774 }
1775 else
1776 {
1777 int var1;
1778 if (iTeam == 3)
1779 {
1780 var1 = 0;
1781 }
1782 else
1783 {
1784 var1 = 1;
1785 }
1786 SetEntProp(iEntity, PropType 0, "m_nSkin", var1, 4, 0);
1787 }
1788 return void 0;
1789}
1790
1791public int GetRandomRocketClass(int iSpawnerClass)
1792{
1793 int iRandom = GetURandomIntRange(0, 101);
1794 Handle hTable = g_hSpawnersChancesTable[iSpawnerClass][0][0];
1795 int iTableSize = GetArraySize(hTable);
1796 int iChancesLower = 0;
1797 int iChancesUpper = 0;
1798 int iEntry = 0;
1799 while (iEntry < iTableSize)
1800 {
1801 iChancesLower = iChancesUpper + iChancesLower;
1802 iChancesUpper = GetArrayCell(hTable, iEntry, 0, false) + iChancesLower;
1803 int var1;
1804 if (iRandom >= iChancesLower)
1805 {
1806 return iEntry;
1807 }
1808 iEntry++;
1809 }
1810 return 0;
1811}
1812
1813public void EmitRocketSound(RocketSound iSound, int iClass, int iEntity, int iTarget, RocketFlags iFlags)
1814{
1815 switch (iSound)
1816 {
1817 case 0: {
1818 if (!!iFlags & 1)
1819 {
1820 if (!!iFlags & 2048)
1821 {
1822 EmitSoundToAll(g_strRocketClassSpawnSound[iClass][0][0], iEntity, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1823 }
1824 EmitSoundToAll("weapons/sentry_rocket.wav", iEntity, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1825 }
1826 }
1827 case 1: {
1828 if (!!iFlags & 2)
1829 {
1830 if (!!iFlags & 4096)
1831 {
1832 EmitSoundToAll(g_strRocketClassBeepSound[iClass][0][0], iEntity, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1833 }
1834 EmitSoundToAll("weapons/sentry_scan.wav", iEntity, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1835 }
1836 }
1837 case 2: {
1838 if (!!iFlags & 4)
1839 {
1840 if (!!iFlags & 8192)
1841 {
1842 EmitSoundToClient(iTarget, g_strRocketClassAlertSound[iClass][0][0], -2, 0, 75, 0, 1, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1843 }
1844 EmitSoundToClient(iTarget, "weapons/sentry_spot.wav", -2, 0, 75, 0, 0,5, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0);
1845 }
1846 }
1847 default: {
1848 }
1849 }
1850 return void 0;
1851}
1852
1853public void DestroyRocketClasses()
1854{
1855 int iIndex = 0;
1856 while (iIndex < g_iRocketClassCount)
1857 {
1858 Handle hCmdOnSpawn = g_hRocketClassCmdsOnSpawn[iIndex][0][0];
1859 Handle hCmdOnKill = g_hRocketClassCmdsOnKill[iIndex][0][0];
1860 Handle hCmdOnExplode = g_hRocketClassCmdsOnExplode[iIndex][0][0];
1861 Handle hCmdOnDeflect = g_hRocketClassCmdsOnDeflect[iIndex][0][0];
1862 if (hCmdOnSpawn)
1863 {
1864 CloseHandle(hCmdOnSpawn);
1865 }
1866 if (hCmdOnKill)
1867 {
1868 CloseHandle(hCmdOnKill);
1869 }
1870 if (hCmdOnExplode)
1871 {
1872 CloseHandle(hCmdOnExplode);
1873 }
1874 if (hCmdOnDeflect)
1875 {
1876 CloseHandle(hCmdOnDeflect);
1877 }
1878 g_hRocketClassCmdsOnSpawn[iIndex] = 0;
1879 g_hRocketClassCmdsOnKill[iIndex] = 0;
1880 g_hRocketClassCmdsOnExplode[iIndex] = 0;
1881 g_hRocketClassCmdsOnDeflect[iIndex] = 0;
1882 iIndex++;
1883 }
1884 g_iRocketClassCount = 0;
1885 ClearTrie(g_hRocketClassTrie);
1886 return void 0;
1887}
1888
1889public void DestroySpawners()
1890{
1891 int iIndex = 0;
1892 while (iIndex < g_iSpawnersCount)
1893 {
1894 CloseHandle(g_hSpawnersChancesTable[iIndex][0][0]);
1895 iIndex++;
1896 }
1897 g_iSpawnersCount = 0;
1898 g_iSpawnPointsRedCount = 0;
1899 g_iSpawnPointsBluCount = 0;
1900 g_iDefaultRedSpawner = -1;
1901 g_iDefaultBluSpawner = -1;
1902 ClearTrie(g_hSpawnersTrie);
1903 return void 0;
1904}
1905
1906public void PopulateSpawnPoints()
1907{
1908 g_iSpawnPointsRedCount = 0;
1909 g_iSpawnPointsBluCount = 0;
1910 int iEntity = -1;
1911 int var3 = FindEntityByClassname(iEntity, "info_target");
1912 iEntity = var3;
1913 while (var3 != -1)
1914 {
1915 char strName[32];
1916 GetEntPropString(iEntity, PropType 1, "m_iName", strName, 32, 0);
1917 int var1;
1918 if (StrContains(strName, "rocket_spawn_red", true) == -1)
1919 {
1920 int iIndex = FindSpawnerByName(strName);
1921 if (!IsValidRocket(iIndex))
1922 {
1923 iIndex = g_iDefaultRedSpawner;
1924 }
1925 g_iSpawnPointsRedClass[g_iSpawnPointsRedCount] = iIndex;
1926 g_iSpawnPointsRedEntity[g_iSpawnPointsRedCount] = iEntity;
1927 g_iSpawnPointsRedCount += 1;
1928 }
1929 int var2;
1930 if (StrContains(strName, "rocket_spawn_blue", true) == -1)
1931 {
1932 int iIndex = FindSpawnerByName(strName);
1933 if (!IsValidRocket(iIndex))
1934 {
1935 iIndex = g_iDefaultBluSpawner;
1936 }
1937 g_iSpawnPointsBluClass[g_iSpawnPointsBluCount] = iIndex;
1938 g_iSpawnPointsBluEntity[g_iSpawnPointsBluCount] = iEntity;
1939 g_iSpawnPointsBluCount += 1;
1940 }
1941 }
1942 if (!g_iSpawnPointsRedCount)
1943 {
1944 SetFailState("No RED spawn points found on this map.");
1945 }
1946 if (!g_iSpawnPointsBluCount)
1947 {
1948 SetFailState("No BLU spawn points found on this map.");
1949 }
1950 return void 0;
1951}
1952
1953public int FindSpawnerByName(char strName[32])
1954{
1955 int iIndex = -1;
1956 GetTrieValue(g_hSpawnersTrie, strName, iIndex);
1957 return iIndex;
1958}
1959
1960public void RegisterCommands()
1961{
1962 RegServerCmd("tf_dodgeball_explosion", SrvCmd 171, "", 0);
1963 RegServerCmd("tf_dodgeball_shockwave", SrvCmd 193, "", 0);
1964 RegAdminCmd("dummy_dbpermissioncheck", CmdVoid, 2, "An empty object for permission checking", "", 0);
1965 RegAdminCmd("sm_votespeed", CmdStartSpeedVote, 0, "Vote for rocket speed", "", 0);
1966 RegAdminCmd("sm_votecount", CmdStartCountVote, 0, "Vote for rocket count", "", 0);
1967 RegAdminCmd("sm_topspeed", Cmd_TopSpeed, 0, "Top 10 rocket speed", "", 0);
1968 RegAdminCmd("sm_rocketcount", CmdRocketCount, 32, "", "", 0);
1969 RegAdminCmd("sm_rocketspeed", CmdRocketSpeed, 32, "", "", 0);
1970 RegAdminCmd("sm_forcevotespeed", CmdForceVoteSpeed, 32, "", "", 0);
1971 RegAdminCmd("sm_forcevotecount", CmdForceVoteCount, 32, "", "", 0);
1972 RegAdminCmd("sm_reloadtopspeed", Cmd_RebuildTopSpeed, 32, "", "", 0);
1973 RegAdminCmd("dummy_dbpermissioncheck_root", CmdVoid, 16384, "An empty object for permission checking", "", 0);
1974 RegAdminCmd("sm_redirectrocket", CmdRedirectRocket, 16384, "", "", 0);
1975 RegAdminCmd("sm_redirectrocketid", CmdRedirectRocketID, 16384, "", "", 0);
1976 RegAdminCmd("sm_dbsetflareammo", CmdSetFlareAmmo, 16384, "", "", 0);
1977 RegAdminCmd("sm_dbrehook", CmdRehookClientDamage, 16384, "", "", 0);
1978 RegAdminCmd("sm_dbsetknockbackscale", CmdSetKnockbackScale, 16384, "", "", 0);
1979 RegAdminCmd("sm_dbreparseconfig", CmdReparseConfig, 16384, "", "", 0);
1980 AddCommandListener(CommandListener 265, "taunt");
1981 AddCommandListener(CommandListener 265, "+taunt");
1982 return void 0;
1983}
1984
1985public Action CmdReparseConfig(int client, int args)
1986{
1987 ParseConfigurations("general.cfg");
1988 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Reloaded main rocket config");
1989 return Action 3;
1990}
1991
1992public Action CmdVoid(int client, int args)
1993{
1994 return Action 3;
1995}
1996
1997public Action CmdRehookClientDamage(int client, int args)
1998{
1999 int i = 1;
2000 while (i <= MaxClients)
2001 {
2002 if (IsValidClient(i, false))
2003 {
2004 SDKHook(i, SDKHookType 2, SDKHookCB 231);
2005 i++;
2006 }
2007 i++;
2008 }
2009 return Action 3;
2010}
2011
2012public void OnEntityCreated(int entity, char classname[])
2013{
2014 if (StrEqual(classname, "tf_projectile_rocket", true))
2015 {
2016 SDKHook(entity, SDKHookType 18, SDKHookCB 261);
2017 return void 0;
2018 }
2019 if (StrEqual(classname, "tf_projectile_flare", true))
2020 {
2021 RequestFrame(RequestFrameCallback 205, entity);
2022 return void 0;
2023 }
2024 if (StrContains(classname, "tf_ammo_pack", true) != -1)
2025 {
2026 AcceptEntityInput(entity, "Kill", -1, -1, 0);
2027 return void 0;
2028 }
2029 return void 0;
2030}
2031
2032public bool Should_Collide(int entity, int collisiongroup, int contentsmask, bool originalResult)
2033{
2034 return false;
2035}
2036
2037public void Frame_SetModel(int entity)
2038{
2039 if (IsValidEntity(entity))
2040 {
2041 int iOwner = GetEntPropEnt(entity, PropType 0, "m_hOwnerEntity", 0);
2042 if (IsValidClient(iOwner, false))
2043 {
2044 SetEntityModel(entity, "models/buildables/sentry_shield.mdl");
2045 }
2046 }
2047 return void 0;
2048}
2049
2050public Action CmdSetKnockbackScale(int client, int args)
2051{
2052 if (args)
2053 {
2054 char buffer[64];
2055 GetCmdArg(1, buffer, 64);
2056 float scale = StringToFloat(buffer);
2057 Flare_Weapon_Knockback_Scale = scale;
2058 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Knockback scale set to {aqua}%f", scale);
2059 return Action 3;
2060 }
2061 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Invalid Syntax");
2062 return Action 3;
2063}
2064
2065public Action CmdSetFlareAmmo(int client, int args)
2066{
2067 if (0 < args)
2068 {
2069 char buffer[16];
2070 GetCmdArg(1, buffer, 16);
2071 int ammo = StringToInt(buffer, 10);
2072 SetAmmo(client, 1, ammo);
2073 }
2074 else
2075 {
2076 ReplyToCommand(client, "sm_dbsetflareammo <ammo>");
2077 }
2078 return Action 3;
2079}
2080
2081public Action CmdRocketCount(int client, int args)
2082{
2083 if (args < 1)
2084 {
2085 PrintToConsole(client, "Usage: sm_rocketcount <count>");
2086 return Action 3;
2087 }
2088 char rc[32];
2089 GetCmdArg(1, rc, 32);
2090 int count = StringToInt(rc, 10);
2091 int iSpawnerClass_Red = g_iSpawnPointsRedClass[g_iCurrentRedSpawn][0][0];
2092 int iSpawnerClass_Blu = g_iSpawnPointsBluClass[g_iCurrentBluSpawn][0][0];
2093 g_iSpawnersMaxRockets[iSpawnerClass_Red] = count;
2094 g_iSpawnersMaxRockets[iSpawnerClass_Blu] = count;
2095 PrintToConsole(client, "[MaxDB] Rocket count set to %d", count);
2096 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Rocket count set to {aqua}%d", count);
2097 return Action 3;
2098}
2099
2100public Action CmdRedirectRocket(int client, int args)
2101{
2102 int buffer = GetClientAimTarget(client, true);
2103 if (buffer != -1)
2104 {
2105 g_newtarget_int = buffer;
2106 g_newtarget_bool = 1;
2107 PrintToConsole(client, "[MaxDB] Rocket redirected to %N", g_newtarget_int);
2108 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Rocket redirected to {chartreuse}%N", 5372);
2109 return Action 3;
2110 }
2111 return Action 3;
2112}
2113
2114public Action CmdRedirectRocketID(int client, int args)
2115{
2116 if (args == 1)
2117 {
2118 char buffer[32];
2119 GetCmdArg(1, buffer, 32);
2120 int clientid = StringToInt(buffer, 10);
2121 if (IsValidClient(clientid, false))
2122 {
2123 g_newtarget_int = clientid;
2124 g_newtarget_bool = 1;
2125 PrintToConsole(client, "[MaxDB] Rocket redirected to %N", g_newtarget_int);
2126 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Rocket redirected to {chartreuse}%N", 5372);
2127 return Action 3;
2128 }
2129 PrintToConsole(client, "[MaxDB] Invalid Target");
2130 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Invalid Target");
2131 return Action 3;
2132 }
2133 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}sm_redirectrocketid <{aqua}id{grey}>", 5372);
2134 return Action 3;
2135}
2136
2137public Action CmdRocketSpeed(int client, int args)
2138{
2139 if (args < 1)
2140 {
2141 PrintToConsole(client, "Usage: sm_rocketspeed <increment>");
2142 return Action 3;
2143 }
2144 else
2145 {
2146 char rc[32];
2147 float speed_f = 0;
2148 float turn_rate = 0;
2149 int iIndex = -1;
2150 int iClass = 0;
2151 int speed_i = 0;
2152 GetCmdArg(1, rc, 32);
2153 int var1;
2154 if (StrEqual(rc, "reset", true))
2155 {
2156 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Speed reset to {aqua}%.0f", FloatMul(g_defaultspeed, g_mph_convert));
2157 iIndex = 0;
2158 }
2159 speed_i = StringToInt(rc, 10);
2160
2161/* ERROR! NYI */
2162 function "CmdRocketSpeed" (number 83)
2163public int Handle_VoteMenu(Menu menu, MenuAction action, int param1, int param2)
2164{
2165 if (action == MenuAction 16)
2166 {
2167 CloseHandle(menu);
2168 menu = 0;
2169 }
2170 return 0;
2171}
2172
2173public void Handle_RocketSpeedMenu(Menu menu, int num_votes, int num_clients, int client_info[][], int num_items, int item_info[][])
2174{
2175 int winner = 0;
2176 int var1;
2177 if (num_items > 1)
2178 {
2179 winner = GetRandomInt(0, 1);
2180 }
2181 char speed[64];
2182 int speedc = 0;
2183 int iIndex = -1;
2184 int iClass = 0;
2185 float turn_rate = 0;
2186 float speed_f = 0;
2187 Menu.GetItem(menu, item_info[winner][0], speed, 64, 0, "", 0);
2188 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Vote ended for rocket {aqua}speed");
2189 ResetSpeedVotes();
2190 speedc = StringToInt(speed, 10);
2191 if (speedc)
2192 {
2193
2194/* ERROR! NYI */
2195 function "Handle_RocketSpeedMenu" (number 85)
2196public void DoVoteRocketSpeed()
2197{
2198 if (IsVoteInProgress(Handle 0))
2199 {
2200 return void 0;
2201 }
2202 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Vote started for rocket {aqua}speed");
2203 Menu menu = Menu.Menu(MenuHandler 211, MenuAction 28);
2204 Menu.VoteResultCallback.set(menu, VoteHandler 209);
2205 Menu.SetTitle(menu, "Vote Rocket Speed");
2206 Menu.AddItem(menu, "0", "Normal", 0);
2207 Menu.AddItem(menu, "75", "Hard", 0);
2208 Menu.AddItem(menu, "90", "Brutal", 0);
2209 Menu.AddItem(menu, "100", "Hitler", 0);
2210 Menu.ExitButton.set(menu, false);
2211 Menu.DisplayVoteToAll(menu, 30, 0);
2212 return void 0;
2213}
2214
2215public void Handle_RocketCountMenu(Menu menu, int num_votes, int num_clients, int client_info[][], int num_items, int item_info[][])
2216{
2217 int winner = 0;
2218 int var1;
2219 if (num_items > 1)
2220 {
2221 winner = GetRandomInt(0, 1);
2222 }
2223 char count[64];
2224 int countc = 0;
2225 Menu.GetItem(menu, item_info[winner][0], count, 64, 0, "", 0);
2226 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Vote ended for rocket {aqua}count");
2227 ResetCountVotes();
2228 countc = StringToInt(count, 10);
2229 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Rocket count set to {aqua}%d", countc);
2230 int iSpawnerClass_Red = g_iSpawnPointsRedClass[g_iCurrentRedSpawn][0][0];
2231 int iSpawnerClass_Blu = g_iSpawnPointsBluClass[g_iCurrentBluSpawn][0][0];
2232 g_iSpawnersMaxRockets[iSpawnerClass_Red] = countc;
2233 g_iSpawnersMaxRockets[iSpawnerClass_Blu] = countc;
2234 return void 0;
2235}
2236
2237public void DoVoteRocketCount()
2238{
2239 if (IsVoteInProgress(Handle 0))
2240 {
2241 return void 0;
2242 }
2243 CPrintToChatAll("{lightseagreen}[MaxDB] {gray}Vote started for rocket {aqua}count");
2244 Menu menu = Menu.Menu(MenuHandler 211, MenuAction 28);
2245 Menu.VoteResultCallback.set(menu, VoteHandler 207);
2246 Menu.SetTitle(menu, "Vote Rocket Count");
2247 Menu.AddItem(menu, "1", "1", 0);
2248 Menu.AddItem(menu, "2", "2", 0);
2249 Menu.AddItem(menu, "3", "3", 0);
2250 Menu.AddItem(menu, "5", "5", 0);
2251 Menu.AddItem(menu, "10", "10", 0);
2252 Menu.ExitButton.set(menu, false);
2253 Menu.DisplayVoteToAll(menu, 30, 0);
2254 return void 0;
2255}
2256
2257public Action CmdStartSpeedVote(int client, int args)
2258{
2259 AttemptVoteSpeed(client);
2260 return Action 3;
2261}
2262
2263public Action CmdStartCountVote(int client, int args)
2264{
2265 AttemptVoteCount(client);
2266 return Action 3;
2267}
2268
2269
2270/* ERROR! L'index se trouve en dehors des limites du tableau. */
2271 function "AttemptVoteSpeed" (number 91)
2272
2273/* ERROR! L'index se trouve en dehors des limites du tableau. */
2274 function "AttemptVoteCount" (number 92)
2275public void ResetSpeedVotes()
2276{
2277 g_SpeedVotes = 0;
2278 int i = 1;
2279 while (i <= 65)
2280 {
2281 g_SpeedVoted[i] = 0;
2282 i++;
2283 }
2284 g_VoteInProgress = 0;
2285 return void 0;
2286}
2287
2288public void ResetCountVotes()
2289{
2290 g_CountVotes = 0;
2291 int i = 1;
2292 while (i <= 65)
2293 {
2294 g_CountVoted[i] = 0;
2295 i++;
2296 }
2297 g_VoteInProgress = 0;
2298 return void 0;
2299}
2300
2301public Action CmdForceVoteSpeed(int client, int args)
2302{
2303 DoVoteRocketSpeed();
2304 return Action 3;
2305}
2306
2307public Action CmdForceVoteCount(int client, int args)
2308{
2309 DoVoteRocketCount();
2310 return Action 3;
2311}
2312
2313public void InitDB(&Handle DbHNDL)
2314{
2315 char Error[256];
2316 DbHNDL = SQL_Connect("topspeed", true, Error, 255);
2317 if (!DbHNDL)
2318 {
2319 SetFailState(Error);
2320 }
2321 char Query[1000];
2322 SQL_LockDatabase(DbHNDL);
2323 SQL_FastQuery(DbHNDL, Query, -1);
2324 SQL_UnlockDatabase(DbHNDL);
2325 return void 0;
2326}
2327
2328public void UpdatePlayerTopSpeed(int client, int mph)
2329{
2330 char steamid64[20];
2331 char name[32];
2332 char query[256];
2333 char escaped_name[100];
2334 GetClientAuthId(client, AuthIdType 3, steamid64, 20, true);
2335 GetClientName(client, name, 32);
2336 SQL_EscapeString(db, name, escaped_name, 100, 0);
2337 Format(query, 255, "INSERT INTO topspeed (`steamid`, `name`, `mph`) VALUES ('%s', '%s', '%i') ON DUPLICATE KEY UPDATE `name` = '%s', `mph` = GREATEST(%i, `mph`);", steamid64, escaped_name, mph, escaped_name, mph);
2338 Database.Query(db, SQLQueryCallback 259, query, any 0, DBPriority 1);
2339 return void 0;
2340}
2341
2342public void SQL_OnUpdatePlayerTopSpeed(Database odb, DBResultSet results, char error[], any data)
2343{
2344 return void 0;
2345}
2346
2347public Menu BuildTopSpeed()
2348{
2349 char name[32];
2350 int mph = 0;
2351 int row = 0;
2352 char mphs[256];
2353 char buffer[256];
2354 Menu topspeed = Menu.Menu(MenuHandler 219, MenuAction 28);
2355 DBResultSet query = SQL_Query(db, "SELECT `name`, `mph` FROM topspeed ORDER BY mph DESC LIMIT 10;", -1);
2356 if (query)
2357 {
2358 while (SQL_FetchRow(query))
2359 {
2360 SQL_FetchString(query, 0, name, 32, 0);
2361 mph = SQL_FetchInt(query, 1, 0);
2362 Format(buffer, 255, "%s - %i MPH", name, mph);
2363 IntToString(mph, mphs, 255);
2364 Menu.AddItem(topspeed, mphs, buffer, 0);
2365 if (row)
2366 {
2367 }
2368 else
2369 {
2370 SetConVarString(g_hCvarTopSpeedHolder, name, true, false);
2371 SetConVarInt(g_hCvarTopSpeedMPH, mph, true, false);
2372 row++;
2373 }
2374 }
2375 }
2376 CloseHandle(query);
2377 query = 0;
2378 Menu.SetTitle(topspeed, "Top 10 Rocket Speed");
2379 return topspeed;
2380}
2381
2382public int Menu_Topspeed(Menu menu, MenuAction action, int param1, int param2)
2383{
2384 return 0;
2385}
2386
2387public Action Cmd_TopSpeed(int client, int args)
2388{
2389 if (!TopRocketSpeed)
2390 {
2391 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Invalid Database Handle");
2392 }
2393 Menu.Display(TopRocketSpeed, client, 0);
2394 return Action 3;
2395}
2396
2397public Action Cmd_RebuildTopSpeed(int client, int args)
2398{
2399 TopRocketSpeed = BuildTopSpeed();
2400 return Action 3;
2401}
2402
2403public Action OnClientSayCommand(int client, char command[], char sArgs[])
2404{
2405 int var1;
2406 if (strcmp(command, "say", true))
2407 {
2408 if (strcmp(sArgs, "topspeed", true))
2409 {
2410 }
2411 else
2412 {
2413 if (TopRocketSpeed)
2414 {
2415 Menu.Display(TopRocketSpeed, client, 0);
2416 }
2417 CPrintToChat(client, "{lightseagreen}[MaxDB] {gray}Invalid Database Handle");
2418 }
2419 }
2420 return Action 0;
2421}
2422
2423public void IntCmdExplosion(int iClient)
2424{
2425 if (IsValidEntity(iClient))
2426 {
2427 float fPosition[3];
2428 GetClientAbsOrigin(iClient, fPosition);
2429 switch (GetURandomIntRange(0, 4))
2430 {
2431 case 0: {
2432 PlayParticle(fPosition, 662836, "fireSmokeExplosion", 5, 9);
2433 }
2434 case 1: {
2435 PlayParticle(fPosition, 662868, "fireSmokeExplosion1", 5, 9);
2436 }
2437 case 2: {
2438 PlayParticle(fPosition, 662900, "fireSmokeExplosion2", 5, 9);
2439 }
2440 case 3: {
2441 PlayParticle(fPosition, 662932, "fireSmokeExplosion3", 5, 9);
2442 }
2443 case 4: {
2444 PlayParticle(fPosition, 662964, "fireSmokeExplosion4", 5, 9);
2445 }
2446 default: {
2447 }
2448 }
2449 PlayParticle(fPosition, 662996, "fireSmoke_collumnP", 5, 9);
2450 }
2451 return void 0;
2452}
2453
2454public Action CmdExplosion(int iArgs)
2455{
2456 if (iArgs == 1)
2457 {
2458 char strBuffer[8];
2459 char iClient = 0;
2460 GetCmdArg(1, strBuffer, 8);
2461 iClient = StringToInt(strBuffer, 10);
2462 if (IsValidEntity(iClient))
2463 {
2464 float fPosition[3];
2465 GetClientAbsOrigin(iClient, fPosition);
2466 switch (GetURandomIntRange(0, 4))
2467 {
2468 case 0: {
2469 PlayParticle(fPosition, 663028, "fireSmokeExplosion", 5, 9);
2470 }
2471 case 1: {
2472 PlayParticle(fPosition, 663060, "fireSmokeExplosion1", 5, 9);
2473 }
2474 case 2: {
2475 PlayParticle(fPosition, 663092, "fireSmokeExplosion2", 5, 9);
2476 }
2477 case 3: {
2478 PlayParticle(fPosition, 663124, "fireSmokeExplosion3", 5, 9);
2479 }
2480 case 4: {
2481 PlayParticle(fPosition, 663156, "fireSmokeExplosion4", 5, 9);
2482 }
2483 default: {
2484 }
2485 }
2486 PlayParticle(fPosition, 663188, "fireSmoke_collumnP", 5, 9);
2487 }
2488 }
2489 else
2490 {
2491 PrintToServer("Usage: tf_dodgeball_explosion <client index>");
2492 }
2493 return Action 3;
2494}
2495
2496public Action CmdShockwave(int iArgs)
2497{
2498 if (iArgs == 5)
2499 {
2500 char strBuffer[8];
2501 int iClient = 0;
2502 int iTeam = 0;
2503 int iDamage = 0;
2504 float fPosition[3];
2505 float fPushStrength = 0;
2506 float fRadius = 0;
2507 float fFalloffRadius = 0;
2508 GetCmdArg(1, strBuffer, 8);
2509 iClient = StringToInt(strBuffer, 10);
2510 GetCmdArg(2, strBuffer, 8);
2511 iDamage = StringToInt(strBuffer, 10);
2512 GetCmdArg(3, strBuffer, 8);
2513 fPushStrength = StringToFloat(strBuffer);
2514 GetCmdArg(4, strBuffer, 8);
2515 fRadius = StringToFloat(strBuffer);
2516 GetCmdArg(5, strBuffer, 8);
2517 fFalloffRadius = StringToFloat(strBuffer);
2518 if (IsValidClient(iClient, false))
2519 {
2520 iTeam = GetClientTeam(iClient);
2521 GetClientAbsOrigin(iClient, fPosition);
2522 iClient = 1;
2523 while (iClient <= MaxClients)
2524 {
2525 int var1;
2526 if (IsValidClient(iClient, true) == 1)
2527 {
2528 float fPlayerPosition[3];
2529 GetClientEyePosition(iClient, fPlayerPosition);
2530 float fDistanceToShockwave = GetVectorDistance(fPosition, fPlayerPosition, false);
2531 if (__FLOAT_LT__(fDistanceToShockwave, fRadius))
2532 {
2533 float fImpulse[3];
2534 float fFinalPush = 0;
2535 int iFinalDamage = 0;
2536 fImpulse[0] = FloatSub(fPlayerPosition[0], fPosition[0]);
2537 fImpulse[4] = FloatSub(fPlayerPosition[4], fPosition[4]);
2538 fImpulse[8] = FloatSub(fPlayerPosition[8], fPosition[8]);
2539 NormalizeVector(fImpulse, fImpulse);
2540 if (__FLOAT_LT__(fImpulse[8], 0,4))
2541 {
2542 fImpulse[8] = 1053609165;
2543 NormalizeVector(fImpulse, fImpulse);
2544 }
2545 if (__FLOAT_LT__(fDistanceToShockwave, fFalloffRadius))
2546 {
2547 fFinalPush = fPushStrength;
2548 iFinalDamage = iDamage;
2549 }
2550 else
2551 {
2552 float fImpact = FloatSub(1, FloatDiv(FloatSub(fDistanceToShockwave, fFalloffRadius), FloatSub(fRadius, fFalloffRadius)));
2553 fFinalPush = FloatMul(fImpact, fPushStrength);
2554 iFinalDamage = RoundToFloor(fImpact * iDamage);
2555 }
2556 ScaleVector(fImpulse, fFinalPush);
2557 SetEntPropVector(iClient, PropType 1, "m_vecAbsVelocity", fImpulse, 0);
2558 Handle hDamage = CreateDataPack();
2559 WritePackCell(hDamage, iClient);
2560 WritePackCell(hDamage, iFinalDamage);
2561 CreateTimer(0,1, ApplyDamage, hDamage, 2);
2562 iClient++;
2563 }
2564 iClient++;
2565 }
2566 iClient++;
2567 }
2568 }
2569 }
2570 else
2571 {
2572 PrintToServer("Usage: tf_dodgeball_shockwave <client index> <damage> <push strength> <radius> <falloff>");
2573 }
2574 return Action 3;
2575}
2576
2577public void ExecuteCommands(Handle hDataPack, int iClass, int iRocket, int iOwner, int iTarget, int iLastDead, float fSpeed, int iNumDeflections)
2578{
2579 ResetPack(hDataPack, false);
2580 int iNumCommands = ReadPackCell(hDataPack);
2581 iNumCommands--;
2582 while (0 < iNumCommands)
2583 {
2584 char strCmd[256];
2585 char strBuffer[8];
2586 ReadPackString(hDataPack, strCmd, 256);
2587 ReplaceString(strCmd, 256, "@name", g_strRocketClassLongName[iClass][0][0], true);
2588 Format(strBuffer, 8, "%i", iRocket);
2589 ReplaceString(strCmd, 256, "@rocket", strBuffer, true);
2590 Format(strBuffer, 8, "%i", iOwner);
2591 ReplaceString(strCmd, 256, "@owner", strBuffer, true);
2592 Format(strBuffer, 8, "%i", iTarget);
2593 ReplaceString(strCmd, 256, "@target", strBuffer, true);
2594 Format(strBuffer, 8, "%i", iLastDead);
2595 ReplaceString(strCmd, 256, "@dead", strBuffer, true);
2596 Format(strBuffer, 8, "%f", fSpeed);
2597 ReplaceString(strCmd, 256, "@speed", strBuffer, true);
2598 Format(strBuffer, 8, "%i", iNumDeflections);
2599 ReplaceString(strCmd, 256, "@deflections", strBuffer, true);
2600 ServerCommand(strCmd);
2601 }
2602 return void 0;
2603}
2604
2605public bool ParseConfigurations(char strConfigFile[])
2606{
2607 char strPath[256];
2608 char strFileName[256];
2609 Format(strFileName, 256, "configs/dodgeball/%s", strConfigFile);
2610 BuildPath(PathType 0, strPath, 256, strFileName);
2611 LogMessage("Executing configuration file %s", strPath);
2612 if (FileExists(strPath, true, "GAME"))
2613 {
2614 Handle kvConfig = CreateKeyValues("TF2_Dodgeball", "", "");
2615 if (!(FileToKeyValues(kvConfig, strPath)))
2616 {
2617 SetFailState("Error while parsing the configuration file.");
2618 }
2619 KvGotoFirstSubKey(kvConfig, true);
2620 do
2621{
2622 char strSection[64];
2623 KvGetSectionName(kvConfig, strSection, 64);
2624 if (StrEqual(strSection, "general", true))
2625 {
2626 ParseGeneral(kvConfig);
2627 }
2628 else
2629 {
2630 if (StrEqual(strSection, "classes", true))
2631 {
2632 ParseClasses(kvConfig);
2633 }
2634 if (StrEqual(strSection, "spawners", true))
2635 {
2636 ParseSpawners(kvConfig);
2637 }
2638 }
2639 }
2640 while (KvGotoNextKey(kvConfig, true));
2641 CloseHandle(kvConfig);
2642 }
2643 return false;
2644}
2645
2646
2647/* ERROR! Impossible d'effectuer un cast d'un objet de type 'Lysis.DJump' en type 'Lysis.DJumpCondition'. */
2648 function "ParseGeneral" (number 110)
2649public void ParseClasses(Handle kvConfig)
2650{
2651 char strName[64];
2652 char strBuffer[256];
2653 KvGotoFirstSubKey(kvConfig, true);
2654 do
2655{
2656 int iIndex = g_iRocketClassCount;
2657 RocketFlags iFlags = 0;
2658 KvGetSectionName(kvConfig, strName, 64);
2659 strcopy(g_strRocketClassName[iIndex][0][0], 16, strName);
2660 KvGetString(kvConfig, "name", strBuffer, 256, "");
2661 strcopy(g_strRocketClassLongName[iIndex][0][0], 32, strBuffer);
2662 if (KvGetString(kvConfig, "model", strBuffer, 256, ""))
2663 {
2664 strcopy(g_strRocketClassModel[iIndex][0][0], 256, strBuffer);
2665 if (strlen(g_strRocketClassModel[iIndex][0][0]))
2666 {
2667 iFlags |= 1024;
2668 if (KvGetNum(kvConfig, "is animated", 0))
2669 {
2670 iFlags |= 32768;
2671 }
2672 }
2673 }
2674 KvGetString(kvConfig, "behaviour", strBuffer, 256, "homing");
2675 if (StrEqual(strBuffer, "homing", true))
2676 {
2677 g_iRocketClassBehaviour[iIndex] = 1;
2678 }
2679 else
2680 {
2681 g_iRocketClassBehaviour[iIndex] = 0;
2682 }
2683 if (KvGetNum(kvConfig, "play spawn sound", 0) == 1)
2684 {
2685 iFlags |= 1;
2686 int var1;
2687 if (KvGetString(kvConfig, "spawn sound", g_strRocketClassSpawnSound[iIndex][0][0], 256, ""))
2688 {
2689 iFlags |= 2048;
2690 }
2691 }
2692 if (KvGetNum(kvConfig, "play beep sound", 0) == 1)
2693 {
2694 iFlags |= 2;
2695 g_fRocketClassBeepInterval[iIndex] = KvGetFloat(kvConfig, "beep interval", 0,5);
2696 int var2;
2697 if (KvGetString(kvConfig, "beep sound", g_strRocketClassBeepSound[iIndex][0][0], 256, ""))
2698 {
2699 iFlags |= 4096;
2700 }
2701 }
2702 if (KvGetNum(kvConfig, "play alert sound", 0) == 1)
2703 {
2704 iFlags |= 4;
2705 int var3;
2706 if (KvGetString(kvConfig, "alert sound", g_strRocketClassAlertSound[iIndex][0][0], 256, ""))
2707 {
2708 iFlags |= 8192;
2709 }
2710 }
2711 if (KvGetNum(kvConfig, "elevate on deflect", 1) == 1)
2712 {
2713 iFlags |= 8;
2714 }
2715 if (KvGetNum(kvConfig, "neutral rocket", 0) == 1)
2716 {
2717 iFlags |= 16;
2718 }
2719 g_fRocketClassDamage[iIndex] = KvGetFloat(kvConfig, "damage", 0);
2720 g_fRocketClassDamageIncrement[iIndex] = KvGetFloat(kvConfig, "damage increment", 0);
2721 g_fRocketClassCritChance[iIndex] = KvGetFloat(kvConfig, "critical chance", 0);
2722 g_fRocketClassSpeed[iIndex] = KvGetFloat(kvConfig, "speed", 0);
2723 g_fRocketClassSpeedIncrement[iIndex] = KvGetFloat(kvConfig, "speed increment", 0);
2724 if (__FLOAT_NOT__(g_defaultspeed))
2725 {
2726 g_defaultspeed = KvGetFloat(kvConfig, "speed", 0);
2727 }
2728 g_fRocketClassTurnRate[iIndex] = KvGetFloat(kvConfig, "turn rate", 0);
2729 if (__FLOAT_NOT__(g_default_turn))
2730 {
2731 g_default_turn = KvGetFloat(kvConfig, "turn rate", 0);
2732 }
2733 g_fRocketClassTurnRateIncrement[iIndex] = KvGetFloat(kvConfig, "turn rate increment", 0);
2734 g_fRocketClassElevationRate[iIndex] = KvGetFloat(kvConfig, "elevation rate", 0);
2735 g_fRocketClassElevationLimit[iIndex] = KvGetFloat(kvConfig, "elevation limit", 0);
2736 g_fRocketClassControlDelay[iIndex] = KvGetFloat(kvConfig, "control delay", 0);
2737 g_fRocketClassPlayerModifier[iIndex] = KvGetFloat(kvConfig, "no. players modifier", 0);
2738 g_fRocketClassRocketsModifier[iIndex] = KvGetFloat(kvConfig, "no. rockets modifier", 0);
2739 g_fRocketClassTargetWeight[iIndex] = KvGetFloat(kvConfig, "direction to target weight", 0);
2740 Handle hCmds = 0;
2741 KvGetString(kvConfig, "on spawn", strBuffer, 256, "");
2742 int var4 = ParseCommands(strBuffer);
2743 hCmds = var4;
2744 if (var4)
2745 {
2746 iFlags |= 64;
2747 g_hRocketClassCmdsOnSpawn[iIndex] = hCmds;
2748 }
2749 KvGetString(kvConfig, "on deflect", strBuffer, 256, "");
2750 int var5 = ParseCommands(strBuffer);
2751 hCmds = var5;
2752 if (var5)
2753 {
2754 iFlags |= 128;
2755 g_hRocketClassCmdsOnDeflect[iIndex] = hCmds;
2756 }
2757 KvGetString(kvConfig, "on kill", strBuffer, 256, "");
2758 int var6 = ParseCommands(strBuffer);
2759 hCmds = var6;
2760 if (var6)
2761 {
2762 iFlags |= 256;
2763 g_hRocketClassCmdsOnKill[iIndex] = hCmds;
2764 }
2765 KvGetString(kvConfig, "on explode", strBuffer, 256, "");
2766 int var7 = ParseCommands(strBuffer);
2767 hCmds = var7;
2768 if (var7)
2769 {
2770 iFlags |= 512;
2771 g_hRocketClassCmdsOnExplode[iIndex] = hCmds;
2772 }
2773 SetTrieValue(g_hRocketClassTrie, strName, iIndex, true);
2774 g_iRocketClassFlags[iIndex] = iFlags;
2775 g_iRocketClassCount += 1;
2776 }
2777 while (KvGotoNextKey(kvConfig, true));
2778 KvGoBack(kvConfig);
2779 return void 0;
2780}
2781
2782public void ParseSpawners(Handle kvConfig)
2783{
2784 char strBuffer[256];
2785 KvGotoFirstSubKey(kvConfig, true);
2786}
2787
2788public Handle ParseCommands(char strLine[])
2789{
2790 TrimString(strLine);
2791 if (strlen(strLine))
2792 {
2793 char strStrings[32][256];
2794 int iNumStrings = ExplodeString(strLine, ";", strStrings, 8, 255, false);
2795 Handle hDataPack = CreateDataPack();
2796 WritePackCell(hDataPack, iNumStrings);
2797 int i = 0;
2798 while (i < iNumStrings)
2799 {
2800 WritePackString(hDataPack, strStrings[i]);
2801 i++;
2802 }
2803 return hDataPack;
2804 }
2805 return Handle 0;
2806}
2807
2808public Action ApplyDamage(Handle hTimer, any hDataPack)
2809{
2810 ResetPack(hDataPack, false);
2811 int iClient = ReadPackCell(hDataPack);
2812 int iDamage = ReadPackCell(hDataPack);
2813 CloseHandle(hDataPack);
2814 SlapPlayer(iClient, iDamage, true);
2815 return Action 0;
2816}
2817
2818public void CopyVectors(float fFrom[3], float fTo[3])
2819{
2820 fTo[0] = fFrom[0];
2821 fTo[4] = fFrom[4];
2822 fTo[8] = fFrom[8];
2823 return void 0;
2824}
2825
2826public void LerpVectors(float fA[3], float fB[3], float fC[3], float t)
2827{
2828 if (__FLOAT_LT__(t, 0))
2829 {
2830 t = 0;
2831 }
2832 if (__FLOAT_GT__(t, 1))
2833 {
2834 t = 1065353216;
2835 }
2836 fC[0] = FloatAdd(fA[0], FloatMul(FloatSub(fB[0], fA[0]), t));
2837 fC[4] = FloatAdd(fA[4], FloatMul(FloatSub(fB[4], fA[4]), t));
2838 fC[8] = FloatAdd(fA[8], FloatMul(FloatSub(fB[8], fA[8]), t));
2839 return void 0;
2840}
2841
2842public bool IsValidClient(int iClient, bool bAlive)
2843{
2844 int var2;
2845 if (iClient >= 1)
2846 {
2847 return true;
2848 }
2849 return false;
2850}
2851
2852
2853/* ERROR! Impossible d'effectuer un cast d'un objet de type 'Lysis.DReturn' en type 'Lysis.DJumpCondition'. */
2854 function "BothTeamsPlaying" (number 118)
2855public int CountAlivePlayers()
2856{
2857 int iCount = 0;
2858 int iClient = 1;
2859 while (iClient <= MaxClients)
2860 {
2861 if (IsValidClient(iClient, true))
2862 {
2863 iCount++;
2864 iClient++;
2865 }
2866 iClient++;
2867 }
2868 return iCount;
2869}
2870
2871public int SelectTarget(int iTeam, int iRocket)
2872{
2873 int iTarget = -1;
2874 float fTargetWeight = 0;
2875 float fRocketPosition[3];
2876 float fRocketDirection[3];
2877 float fWeight = 0;
2878 bool bUseRocket = 0;
2879 if (iRocket != -1)
2880 {
2881 int iClass = g_iRocketClass[iRocket][0][0];
2882 int iEntity = EntRefToEntIndex(g_iRocketEntity[iRocket][0][0]);
2883 GetEntPropVector(iEntity, PropType 0, "m_vecOrigin", fRocketPosition, 0);
2884 CopyVectors(g_fRocketDirection[iRocket][0][0], fRocketDirection);
2885 fWeight = g_fRocketClassTargetWeight[iClass][0][0];
2886 bUseRocket = 1;
2887 }
2888 int iClient = 1;
2889 while (iClient <= MaxClients)
2890 {
2891 if (IsValidClient(iClient, true))
2892 {
2893 int var1;
2894 if (iTeam)
2895 {
2896 }
2897 }
2898 iClient++;
2899 }
2900 return iTarget;
2901}
2902
2903public void StopSoundToAll(int iChannel, char strSound[])
2904{
2905 int iClient = 1;
2906 while (iClient <= MaxClients)
2907 {
2908 if (IsValidClient(iClient, false))
2909 {
2910 StopSound(iClient, iChannel, strSound);
2911 iClient++;
2912 }
2913 iClient++;
2914 }
2915 return void 0;
2916}
2917
2918public void PlayParticle(float fPosition[3], float fAngles[3], char strParticleName[], float fEffectTime, float fLifeTime)
2919{
2920 int iEntity = CreateEntityByName("info_particle_system", -1);
2921 int var1;
2922 if (iEntity)
2923 {
2924 TeleportEntity(iEntity, fPosition, fAngles, NULL_VECTOR);
2925 DispatchKeyValue(iEntity, "effect_name", strParticleName);
2926 ActivateEntity(iEntity);
2927 AcceptEntityInput(iEntity, "Start", -1, -1, 0);
2928 CreateTimer(fEffectTime, StopParticle, EntIndexToEntRef(iEntity), 0);
2929 CreateTimer(fLifeTime, KillParticle, EntIndexToEntRef(iEntity), 0);
2930 }
2931 else
2932 {
2933 LogError("ShowParticle: could not create info_particle_system");
2934 }
2935 return void 0;
2936}
2937
2938public Action StopParticle(Handle hTimer, any iEntityRef)
2939{
2940 if (iEntityRef != any -1)
2941 {
2942 int iEntity = EntRefToEntIndex(iEntityRef);
2943 int var1;
2944 if (iEntity)
2945 {
2946 AcceptEntityInput(iEntity, "Stop", -1, -1, 0);
2947 }
2948 }
2949 return Action 0;
2950}
2951
2952public Action KillParticle(Handle hTimer, any iEntityRef)
2953{
2954 if (iEntityRef != any -1)
2955 {
2956 int iEntity = EntRefToEntIndex(iEntityRef);
2957 int var1;
2958 if (iEntity)
2959 {
2960 RemoveEdict(iEntity);
2961 }
2962 }
2963 return Action 0;
2964}
2965
2966public void PrecacheParticle(char strParticleName[])
2967{
2968 PlayParticle(664412, 664424, strParticleName, 0,1, 0,1);
2969 return void 0;
2970}
2971
2972public int GetAnalogueTeam(int iTeam)
2973{
2974 if (iTeam == 2)
2975 {
2976 return 3;
2977 }
2978 return 2;
2979}
2980
2981public void ShowHiddenMOTDPanel(int iClient, char strTitle[], char strMsg[], char strType[])
2982{
2983 Handle hPanel = CreateKeyValues("data", "", "");
2984 KvSetString(hPanel, "title", strTitle);
2985 KvSetString(hPanel, "type", strType);
2986 KvSetString(hPanel, "msg", strMsg);
2987 ShowVGUIPanel(iClient, "info", hPanel, false);
2988 CloseHandle(hPanel);
2989 return void 0;
2990}
2991
2992public void PrecacheSoundEx(char strFileName[], bool bPreload, bool bAddToDownloadTable)
2993{
2994 char strFinalPath[256];
2995 Format(strFinalPath, 256, "sound/%s", strFileName);
2996 PrecacheSound(strFileName, bPreload);
2997 if (bAddToDownloadTable == true)
2998 {
2999 AddFileToDownloadsTable(strFinalPath);
3000 }
3001 return void 0;
3002}
3003
3004public void PrecacheModelEx(char strFileName[], bool bPreload, bool bAddToDownloadTable)
3005{
3006 PrecacheModel(strFileName, bPreload);
3007 if (bAddToDownloadTable)
3008 {
3009 char strDepFileName[256];
3010 Format(strDepFileName, 256, "%s.res", strFileName);
3011 if (FileExists(strDepFileName, false, "GAME"))
3012 {
3013 Handle hStream = OpenFile(strDepFileName, "r", false, "GAME");
3014 if (hStream)
3015 {
3016 while (!IsEndOfFile(hStream))
3017 {
3018 char strBuffer[256];
3019 ReadFileLine(hStream, strBuffer, 256);
3020 CleanString(strBuffer);
3021 if (FileExists(strBuffer, true, "GAME"))
3022 {
3023 if (StrContains(strBuffer, ".vmt", false) != -1)
3024 {
3025 PrecacheDecal(strBuffer, true);
3026 }
3027 else
3028 {
3029 if (StrContains(strBuffer, ".mdl", false) != -1)
3030 {
3031 PrecacheModel(strBuffer, true);
3032 }
3033 if (StrContains(strBuffer, ".pcf", false) != -1)
3034 {
3035 PrecacheGeneric(strBuffer, true);
3036 }
3037 }
3038 AddFileToDownloadsTable(strBuffer);
3039 }
3040 }
3041 CloseHandle(hStream);
3042 }
3043 else
3044 {
3045 LogMessage("Error, can't read file containing model dependencies.");
3046 return void 0;
3047 }
3048 while (!IsEndOfFile(hStream))
3049 {
3050 char strBuffer[256];
3051 ReadFileLine(hStream, strBuffer, 256);
3052 CleanString(strBuffer);
3053 if (FileExists(strBuffer, true, "GAME"))
3054 {
3055 if (StrContains(strBuffer, ".vmt", false) != -1)
3056 {
3057 PrecacheDecal(strBuffer, true);
3058 }
3059 else
3060 {
3061 if (StrContains(strBuffer, ".mdl", false) != -1)
3062 {
3063 PrecacheModel(strBuffer, true);
3064 }
3065 if (StrContains(strBuffer, ".pcf", false) != -1)
3066 {
3067 PrecacheGeneric(strBuffer, true);
3068 }
3069 }
3070 AddFileToDownloadsTable(strBuffer);
3071 }
3072 }
3073 CloseHandle(hStream);
3074 }
3075 }
3076 return void 0;
3077}
3078
3079public void CleanString(char strBuffer[])
3080{
3081 int Length = strlen(strBuffer);
3082 int iPos = 0;
3083 while (iPos < Length)
3084 {
3085 switch (strBuffer[iPos])
3086 {
3087 case 9: {
3088 strBuffer[iPos] = 32;
3089 iPos++;
3090 }
3091 case 10: {
3092 strBuffer[iPos] = 32;
3093 iPos++;
3094 }
3095 case 13: {
3096 strBuffer[iPos] = 32;
3097 iPos++;
3098 }
3099 default: {
3100 iPos++;
3101 }
3102 }
3103 iPos++;
3104 }
3105 TrimString(strBuffer);
3106 return void 0;
3107}
3108
3109public float FMin(float a, float b)
3110{
3111 int var1;
3112 if (__FLOAT_LT__(a, b))
3113 {
3114 var1 = a;
3115 }
3116 else
3117 {
3118 var1 = b;
3119 }
3120 return var1;
3121}
3122
3123public int GetURandomIntRange(int iMin, int iMax)
3124{
3125 return GetURandomInt() + iMin;
3126}
3127
3128public float GetURandomFloatRange(float fMin, float fMax)
3129{
3130 return FloatAdd(fMin, FloatMul(GetURandomFloat(), FloatSub(fMax, fMin)));
3131}
3132
3133public void SetAmmo(int client, int wepslot, int newAmmo)
3134{
3135 int weapon = GetPlayerWeaponSlot(client, wepslot);
3136 if (IsValidEntity(weapon))
3137 {
3138 int iOffset = GetEntProp(weapon, PropType 0, "m_iPrimaryAmmoType", 1, 0) * 4;
3139 int iAmmoTable = FindSendPropInfo("CTFPlayer", "m_iAmmo", 0, 0, 0);
3140 SetEntData(client, iOffset + iAmmoTable, newAmmo, 4, true);
3141 }
3142 return void 0;
3143}
3144
3145public void SetAmmoAll(int wepslot, int newAmmo)
3146{
3147 int i = 1;
3148 while (i <= MaxClients)
3149 {
3150 if (IsValidClient(i, true))
3151 {
3152 int weapon = GetPlayerWeaponSlot(i, wepslot);
3153 if (IsValidEntity(weapon))
3154 {
3155 int iOffset = GetEntProp(weapon, PropType 0, "m_iPrimaryAmmoType", 1, 0) * 4;
3156 int iAmmoTable = FindSendPropInfo("CTFPlayer", "m_iAmmo", 0, 0, 0);
3157 SetEntData(i, iOffset + iAmmoTable, newAmmo, 4, true);
3158 i++;
3159 }
3160 i++;
3161 }
3162 i++;
3163 }
3164 return void 0;
3165}
3166
3167public bool ChangePlayerWeaponSlot(int iClient, int iSlot)
3168{
3169 int iWeapon = GetPlayerWeaponSlot(iClient, iSlot);
3170 if (iWeapon > MaxClients)
3171 {
3172 SetEntPropEnt(iClient, PropType 0, "m_hActiveWeapon", iWeapon, 0);
3173 return true;
3174 }
3175 return false;
3176}