· 7 years ago · Oct 06, 2018, 03:04 AM
1/**
2 * [INS] Player Respawn Script - Player and BOT respawn script for sourcemod plugin.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17//#pragma dynamic 32768 // Increase heap size
18#pragma semicolon 1
19#include <sourcemod>
20#include <sdktools>
21#include <sdkhooks>
22#include <insurgencydy>
23#include <insurgency_ad>
24#include <smlib>
25#undef REQUIRE_EXTENSIONS
26#include <cstrike>
27#include <tf2>
28#include <tf2_stocks>
29#define REQUIRE_EXTENSIONS
30
31//#include <navmesh>
32//#include <insurgency>
33
34// Define grenade index value
35#define Gren_M67 68
36#define Gren_Incen 73
37#define Gren_Molot 74
38#define Gren_M18 70
39#define Gren_Flash 71
40#define Gren_F1 69
41#define Gren_IED 72
42#define Gren_C4 72
43#define Gren_AT4 67
44#define Gren_RPG7 61
45
46//LUA Healing define values
47#define Healthkit_Timer_Tickrate 0.5 // Basic Sound has 0.8 loop
48#define Healthkit_Timer_Timeout 360.0 //6 minutes
49#define Healthkit_Radius 120.0
50#define Revive_Indicator_Radius 100.0
51#define Healthkit_Remove_Type "1"
52#define Healthkit_Healing_Per_Tick_Min 1
53#define Healthkit_Healing_Per_Tick_Max 3
54
55//Lua Healing Variables
56new g_iBeaconBeam;
57new g_iBeaconHalo;
58new Float:g_fLastHeight[2048] = {0.0, ...};
59new Float:g_fTimeCheck[2048] = {0.0, ...};
60new g_iTimeCheckHeight[2048] = {0, ...};
61new g_healthPack_Amount[2048] = {0, ...};
62
63//Perks Variables
64new g_nSunglasses_ID = 12;
65
66new g_iPlayerEquipGear;
67
68// This will be used for checking which team the player is on before repsawning them
69#define SPECTATOR_TEAM 0
70#define TEAM_SPEC 1
71#define TEAM_1_SEC 2
72#define TEAM_2_INS 3
73
74// Navmesh Init
75#define MAX_OBJECTIVES 13
76#define MAX_HIDING_SPOTS 4096
77#define MIN_PLAYER_DISTANCE 128.0
78#define MAX_ENTITIES 2048
79
80// Counter-Attack Music
81#define COUNTER_ATTACK_MUSIC_DURATION 68.0
82
83// Handle for revive
84new Handle:g_hForceRespawn;
85new Handle:g_hGameConfig;
86//new g_cqcMapsArray[][] = {"chateau_tunnels_v2","congress_coop","cargo_redux9","game_day_coopv1_3", - commented by oz
87// "launch_control_coopv1_5","bunker_busting_coop_ws","gizab_b1_coop", - commented by oz
88// "inferno_checkpoint_b2","nightfall_coopv1_1","caves_coop"}; - commented by oz
89
90// AI Director Variables
91new
92 g_AIDir_TeamStatus = 50,
93 g_AIDir_TeamStatus_min = 0,
94 g_AIDir_TeamStatus_max = 100,
95 g_AIDir_BotsKilledReq_mult = 4,
96 g_AIDir_BotsKilledCount = 0,
97 g_AIDir_AnnounceCounter = 0,
98 g_AIDir_AnnounceTrig = 5,
99 g_AIDir_ChangeCond_Counter = 0,
100 g_AIDir_ChangeCond_Min = 60,
101 g_AIDir_ChangeCond_Max = 180,
102 g_AIDir_AmbushCond_Counter = 0,
103 g_AIDir_AmbushCond_Min = 120,
104 g_AIDir_AmbushCond_Max = 300,
105 g_AIDir_AmbushCond_Rand = 240,
106 g_AIDir_AmbushCond_Chance = 10,
107 g_AIDir_ChangeCond_Rand = 180,
108 g_AIDir_ReinforceTimer_Orig,
109 g_AIDir_ReinforceTimer_SubOrig,
110 g_AIDir_CurrDiff = 0,
111 g_AIDir_DiffChanceBase = 0,
112 bool:g_AIDir_BotReinforceTriggered = false;
113
114// Player respawn
115new
116 g_iEnableRevive = 0,
117 g_GiveBonusLives = 0,
118 g_iRespawnTimeRemaining[MAXPLAYERS+1],
119 g_iReviveRemainingTime[MAXPLAYERS+1],
120 g_iReviveNonMedicRemainingTime[MAXPLAYERS+1],
121 g_iPlayerRespawnTimerActive[MAXPLAYERS+1],
122 g_iSpawnTokens[MAXPLAYERS+1],
123 g_iHurtFatal[MAXPLAYERS+1],
124 g_iClientRagdolls[MAXPLAYERS+1],
125 g_iNearestBody[MAXPLAYERS+1],
126 g_botStaticGlobal[MAXPLAYERS+1],
127 g_resupplyCounter[MAXPLAYERS+1],
128 g_ammoResupplyAmt[MAX_ENTITIES+1],
129 g_trackKillDeaths[MAXPLAYERS+1],
130 Float:g_badSpawnPos_Track[MAXPLAYERS+1][3],
131 g_iRespawnCount[4],
132 g_huntReinforceCacheAdd = 120,
133 bool:g_huntCacheDestroyed = false,
134 bool:g_playersReady = false,
135 bool:g_easterEggRound = false,
136 bool:g_easterEggFlag = false,
137 g_removeBotGrenadeChance = 50,
138 Float:g_fPlayerPosition[MAXPLAYERS+1][3],
139 Float:g_fDeadPosition[MAXPLAYERS+1][3],
140 Float:g_fRagdollPosition[MAXPLAYERS+1][3],
141 Float:g_vecOrigin[MAXPLAYERS+1][3],
142 g_iPlayerBGroups[MAXPLAYERS+1],
143 g_spawnFrandom[MAXPLAYERS+1],
144 g_squadSpawnEnabled[MAXPLAYERS+1] = 0,
145 g_squadLeader[MAXPLAYERS+1],
146 g_enemySpawnTimer[MAXPLAYERS+1],
147 g_LastButtons[MAXPLAYERS+1],
148 g_extendMapVote[MAXPLAYERS+1] = 0,
149 Float:g_fRespawnPosition[3];
150
151//Ammo Amounts
152new
153 playerClip[MAXPLAYERS + 1][2], // Track primary and secondary ammo
154 playerAmmo[MAXPLAYERS + 1][4], // track player ammo based on weapon slot 0 - 4
155 playerPrimary[MAXPLAYERS + 1],
156 playerSecondary[MAXPLAYERS + 1];
157// playerGrenadeType[MAXPLAYERS + 1][10], //track player grenade types
158// playerRole[MAXPLAYERS + 1]; // tracks player role so if it changes while wounded, he dies
159
160// These steam ids remove from having a donor tag on request
161 //[1] = 1 STRING, [64] = 40 character limit per string
162
163//new Handle:g_donorTagRemove_Array; - commented by oz
164new Handle:g_playerArrayList;
165
166//Bot Spawning
167new Handle:g_badSpawnPos_Array;
168
169// Navmesh Init
170new
171 Handle:g_hHidingSpots = INVALID_HANDLE,
172 g_iHidingSpotCount,
173 m_iNumControlPoints,
174 g_iCPHidingSpots[MAX_OBJECTIVES][MAX_HIDING_SPOTS],
175 g_iCPHidingSpotCount[MAX_OBJECTIVES],
176 g_iCPLastHidingSpot[MAX_OBJECTIVES],
177 Float:m_vCPPositions[MAX_OBJECTIVES][3];
178
179// Status
180new
181 g_SernixMaxPlayerCount= 18, //This is our current theaters team count.
182 g_isMapInit,
183 g_iRoundStatus = 0, //0 is over, 1 is active
184 bool:g_bIsCounterAttackTimerActive = false,
185 g_clientDamageDone[MAXPLAYERS+1],
186 playerPickSquad[MAXPLAYERS + 1],
187 bool:playerRevived[MAXPLAYERS + 1],
188 bool:playerInRevivedState[MAXPLAYERS + 1],
189 bool:g_preRoundInitial = false,
190 String:g_client_last_classstring[MAXPLAYERS+1][64],
191 String:g_client_org_nickname[MAXPLAYERS+1][64],
192 Float:g_enemyTimerPos[MAXPLAYERS+1][3], // Kill Stray Enemy Bots Globals
193 Float:g_enemyTimerAwayPos[MAXPLAYERS+1][3], // Kill Stray Enemy Bots Globals
194 g_playerActiveWeapon[MAXPLAYERS + 1],
195 g_plyrGrenScreamCoolDown[MAXPLAYERS+1],
196 g_plyrFireScreamCoolDown[MAXPLAYERS+1],
197 g_playerMedicHealsAccumulated[MAXPLAYERS+1],
198 g_playerMedicRevivessAccumulated[MAXPLAYERS+1],
199 g_playerNonMedicHealsAccumulated[MAXPLAYERS+1],
200 g_playerNonMedicRevive[MAXPLAYERS+1],
201 g_playerWoundType[MAXPLAYERS+1],
202 g_playerWoundTime[MAXPLAYERS+1],
203 g_hintCoolDown[MAXPLAYERS+1] = 30,
204 bool:g_hintsEnabled[MAXPLAYERS+1] = true,
205 Float:g_fPlayerLastChat[MAXPLAYERS+1] = {0.0, ...},
206
207 //Wave Based Arrays
208 g_WaveSpawnActive[MAXPLAYERS+1],
209
210 g_playerFirstJoin[MAXPLAYERS+1];
211
212// Player Distance Plugin //Credits to author = "Popoklopsi", url = "http://popoklopsi.de"
213// unit to use 1 = feet, 0 = meters
214new g_iUnitMetric;
215
216// Handle for config
217new
218 Handle:sm_respawn_enabled = INVALID_HANDLE,
219 Handle:sm_revive_enabled = INVALID_HANDLE,
220
221 //AI Director Specific
222 Handle:sm_ai_director_setdiff_chance_base = INVALID_HANDLE,
223
224 // Respawn delay time
225 Handle:sm_respawn_delay_team_ins = INVALID_HANDLE,
226 Handle:sm_respawn_delay_team_ins_special = INVALID_HANDLE,
227 Handle:sm_respawn_delay_team_sec = INVALID_HANDLE,
228 Handle:sm_respawn_delay_team_sec_player_count_01 = INVALID_HANDLE,
229 Handle:sm_respawn_delay_team_sec_player_count_02 = INVALID_HANDLE,
230 Handle:sm_respawn_delay_team_sec_player_count_03 = INVALID_HANDLE,
231 Handle:sm_respawn_delay_team_sec_player_count_04 = INVALID_HANDLE,
232 Handle:sm_respawn_delay_team_sec_player_count_05 = INVALID_HANDLE,
233 Handle:sm_respawn_delay_team_sec_player_count_06 = INVALID_HANDLE,
234 Handle:sm_respawn_delay_team_sec_player_count_07 = INVALID_HANDLE,
235 Handle:sm_respawn_delay_team_sec_player_count_08 = INVALID_HANDLE,
236 Handle:sm_respawn_delay_team_sec_player_count_09 = INVALID_HANDLE,
237 Handle:sm_respawn_delay_team_sec_player_count_10 = INVALID_HANDLE,
238 Handle:sm_respawn_delay_team_sec_player_count_11 = INVALID_HANDLE,
239 Handle:sm_respawn_delay_team_sec_player_count_12 = INVALID_HANDLE,
240 Handle:sm_respawn_delay_team_sec_player_count_13 = INVALID_HANDLE,
241 Handle:sm_respawn_delay_team_sec_player_count_14 = INVALID_HANDLE,
242 Handle:sm_respawn_delay_team_sec_player_count_15 = INVALID_HANDLE,
243 Handle:sm_respawn_delay_team_sec_player_count_16 = INVALID_HANDLE,
244 Handle:sm_respawn_delay_team_sec_player_count_17 = INVALID_HANDLE,
245 Handle:sm_respawn_delay_team_sec_player_count_18 = INVALID_HANDLE,
246 Handle:sm_respawn_delay_team_sec_player_count_19 = INVALID_HANDLE,
247
248 // Respawn Mode (individual or wave based)
249 Handle:sm_respawn_mode_team_sec = INVALID_HANDLE,
250 Handle:sm_respawn_mode_team_ins = INVALID_HANDLE,
251 //Wave interval
252 Handle:sm_respawn_wave_int_team_sec = INVALID_HANDLE,
253 Handle:sm_respawn_wave_int_team_ins = INVALID_HANDLE,
254
255 //VIP Cvars
256 Handle:sm_vip_obj_time = INVALID_HANDLE,
257 Handle:sm_vip_min_sp_reward = INVALID_HANDLE,
258 Handle:sm_vip_max_sp_reward = INVALID_HANDLE,
259 Handle:sm_vip_enabled = INVALID_HANDLE,
260
261
262 // Respawn type
263 Handle:sm_respawn_type_team_ins = INVALID_HANDLE,
264 Handle:sm_respawn_type_team_sec = INVALID_HANDLE,
265
266 // Respawn lives
267 Handle:sm_respawn_lives_team_sec = INVALID_HANDLE,
268 Handle:sm_respawn_lives_team_ins = INVALID_HANDLE,
269 Handle:sm_respawn_lives_team_ins_player_count_01 = INVALID_HANDLE,
270 Handle:sm_respawn_lives_team_ins_player_count_02 = INVALID_HANDLE,
271 Handle:sm_respawn_lives_team_ins_player_count_03 = INVALID_HANDLE,
272 Handle:sm_respawn_lives_team_ins_player_count_04 = INVALID_HANDLE,
273 Handle:sm_respawn_lives_team_ins_player_count_05 = INVALID_HANDLE,
274 Handle:sm_respawn_lives_team_ins_player_count_06 = INVALID_HANDLE,
275 Handle:sm_respawn_lives_team_ins_player_count_07 = INVALID_HANDLE,
276 Handle:sm_respawn_lives_team_ins_player_count_08 = INVALID_HANDLE,
277 Handle:sm_respawn_lives_team_ins_player_count_09 = INVALID_HANDLE,
278 Handle:sm_respawn_lives_team_ins_player_count_10 = INVALID_HANDLE,
279 Handle:sm_respawn_lives_team_ins_player_count_11 = INVALID_HANDLE,
280 Handle:sm_respawn_lives_team_ins_player_count_12 = INVALID_HANDLE,
281 Handle:sm_respawn_lives_team_ins_player_count_13 = INVALID_HANDLE,
282 Handle:sm_respawn_lives_team_ins_player_count_14 = INVALID_HANDLE,
283 Handle:sm_respawn_lives_team_ins_player_count_15 = INVALID_HANDLE,
284 Handle:sm_respawn_lives_team_ins_player_count_16 = INVALID_HANDLE,
285 Handle:sm_respawn_lives_team_ins_player_count_17 = INVALID_HANDLE,
286 Handle:sm_respawn_lives_team_ins_player_count_18 = INVALID_HANDLE,
287 Handle:sm_respawn_lives_team_ins_player_count_19 = INVALID_HANDLE,
288
289 // Fatal dead
290 Handle:sm_respawn_fatal_chance = INVALID_HANDLE,
291 Handle:sm_respawn_fatal_head_chance = INVALID_HANDLE,
292 Handle:sm_respawn_fatal_limb_dmg = INVALID_HANDLE,
293 Handle:sm_respawn_fatal_head_dmg = INVALID_HANDLE,
294 Handle:sm_respawn_fatal_burn_dmg = INVALID_HANDLE,
295 Handle:sm_respawn_fatal_explosive_dmg = INVALID_HANDLE,
296 Handle:sm_respawn_fatal_chest_stomach = INVALID_HANDLE,
297
298 // Counter-attack
299 Handle:sm_respawn_counterattack_type = INVALID_HANDLE,
300 Handle:sm_respawn_counterattack_vanilla = INVALID_HANDLE,
301 Handle:sm_respawn_final_counterattack_type = INVALID_HANDLE,
302 Handle:sm_respawn_security_on_counter = INVALID_HANDLE,
303 Handle:sm_respawn_counter_chance = INVALID_HANDLE,
304 Handle:sm_respawn_min_counter_dur_sec = INVALID_HANDLE,
305 Handle:sm_respawn_max_counter_dur_sec = INVALID_HANDLE,
306 Handle:sm_respawn_final_counter_dur_sec = INVALID_HANDLE,
307
308 //Dynamic Respawn Mechanics
309 Handle:sm_respawn_dynamic_distance_multiplier = INVALID_HANDLE,
310 Handle:sm_respawn_dynamic_spawn_counter_percent = INVALID_HANDLE,
311 Handle:sm_respawn_dynamic_spawn_percent = INVALID_HANDLE,
312
313 // Misc
314 Handle:sm_respawn_reset_type = INVALID_HANDLE,
315 Handle:sm_respawn_enable_track_ammo = INVALID_HANDLE,
316
317 // Reinforcements
318 Handle:sm_respawn_reinforce_time = INVALID_HANDLE,
319 Handle:sm_respawn_reinforce_time_subsequent = INVALID_HANDLE,
320 Handle:sm_respawn_reinforce_multiplier = INVALID_HANDLE,
321 Handle:sm_respawn_reinforce_multiplier_base = INVALID_HANDLE,
322
323 // Monitor static enemy
324 Handle:sm_respawn_check_static_enemy = INVALID_HANDLE,
325 Handle:sm_respawn_check_static_enemy_counter = INVALID_HANDLE,
326
327 // Donor tag
328 Handle:sm_respawn_enable_donor_tag = INVALID_HANDLE,
329
330 // Related to 'RoundEnd_Protector' plugin
331 Handle:sm_remaininglife = INVALID_HANDLE,
332
333 // Medic specific
334 Handle:sm_revive_seconds = INVALID_HANDLE,
335 Handle:sm_revive_bonus = INVALID_HANDLE,
336 Handle:sm_revive_distance_metric = INVALID_HANDLE,
337 Handle:sm_heal_bonus = INVALID_HANDLE,
338 Handle:sm_heal_cap_for_bonus = INVALID_HANDLE,
339 Handle:sm_revive_cap_for_bonus = INVALID_HANDLE,
340 Handle:sm_reward_medics_enabled = INVALID_HANDLE,
341 Handle:sm_heal_amount_medpack = INVALID_HANDLE,
342 Handle:sm_heal_amount_paddles = INVALID_HANDLE,
343 Handle:sm_non_medic_heal_amt = INVALID_HANDLE,
344 Handle:sm_non_medic_revive_hp = INVALID_HANDLE,
345 Handle:sm_medic_minor_revive_hp = INVALID_HANDLE,
346 Handle:sm_medic_moderate_revive_hp = INVALID_HANDLE,
347 Handle:sm_medic_critical_revive_hp = INVALID_HANDLE,
348 Handle:sm_minor_wound_dmg = INVALID_HANDLE,
349 Handle:sm_moderate_wound_dmg = INVALID_HANDLE,
350 Handle:sm_medic_heal_self_max = INVALID_HANDLE,
351 Handle:sm_non_medic_max_heal_other = INVALID_HANDLE,
352 Handle:sm_minor_revive_time = INVALID_HANDLE,
353 Handle:sm_moderate_revive_time = INVALID_HANDLE,
354 Handle:sm_critical_revive_time = INVALID_HANDLE,
355 Handle:sm_non_medic_revive_time = INVALID_HANDLE,
356 Handle:sm_medpack_health_amount = INVALID_HANDLE,
357 Handle:sm_multi_loadout_enabled = INVALID_HANDLE,
358 Handle:sm_bombers_only = INVALID_HANDLE,
359 Handle:sm_non_medic_heal_self_max = INVALID_HANDLE,
360 Handle:sm_elite_counter_attacks = INVALID_HANDLE,
361 Handle:sm_enable_bonus_lives = INVALID_HANDLE,
362 Handle:sm_finale_counter_spec_enabled = INVALID_HANDLE,
363 Handle:sm_finale_counter_spec_percent = INVALID_HANDLE,
364 Handle:sm_cqc_map_enabled = INVALID_HANDLE,
365 Handle:sm_enable_squad_spawning = INVALID_HANDLE,
366
367 // NAV MESH SPECIFIC CVARS
368 Handle:cvarSpawnMode = INVALID_HANDLE, //1 = Spawn in ins_spawnpoints, 2 = any spawnpoints that meets criteria, 0 = only at normal spawnpoints at next objective
369 Handle:cvarMinCounterattackDistance = INVALID_HANDLE, //Min distance from counterattack objective to spawn
370 Handle:cvarMinPlayerDistance = INVALID_HANDLE, //Min/max distance from players to spawn
371 Handle:cvarBackSpawnIncrease = INVALID_HANDLE, //Adds to the minplayerdistance cvar when spawning behind player.
372 Handle:cvarSpawnAttackDelay = INVALID_HANDLE, //Attack delay for spawning bots
373 Handle:cvarMinObjectiveDistance = INVALID_HANDLE, //Min/max distance from next objective to spawn
374 Handle:cvarMaxObjectiveDistance = INVALID_HANDLE, //Min/max distance from next objective to spawn
375 Handle:cvarMaxObjectiveDistanceNav = INVALID_HANDLE, //Min/max distance from next objective to spawn using nav
376 Handle:cvarCanSeeVectorMultiplier = INVALID_HANDLE, //CanSeeVector Multiplier divide this by cvarMaxPlayerDistance
377 Handle:sm_ammo_resupply_range = INVALID_HANDLE, //Range of ammo resupply
378 Handle:sm_resupply_delay = INVALID_HANDLE, //Delay to resupply
379 Handle:sm_jammer_required = INVALID_HANDLE, //Jammer required for intel messages?
380 Handle:cvarMaxPlayerDistance = INVALID_HANDLE; //Min/max distance from players to spawn
381
382
383// Init global variables
384new
385 g_iCvar_respawn_enable,
386 g_jammerRequired,
387 g_elite_counter_attacks,
388 g_finale_counter_spec_enabled,
389 g_finale_counter_spec_percent,
390 g_cqc_map_enabled,
391 g_elitePeriod,
392 g_elitePeriod_min,
393 g_elitePeriod_max,
394 g_iCvar_revive_enable,
395 Float:g_respawn_counter_chance,
396 g_counterAttack_min_dur_sec,
397 g_counterAttack_max_dur_sec,
398 g_iCvar_respawn_type_team_ins,
399 g_iCvar_respawn_type_team_sec,
400 g_iCvar_respawn_reset_type,
401 Float:g_fCvar_respawn_delay_team_ins,
402 Float:g_fCvar_respawn_delay_team_ins_spec,
403 g_iCvar_enable_track_ammo,
404 g_iCvar_counterattack_type,
405 g_iCvar_counterattack_vanilla,
406 g_iCvar_final_counterattack_type,
407 g_iCvar_SpawnMode,
408
409 //Dynamic Respawn cvars
410 Float:g_DynamicRespawn_Distance_mult, //daimyo original code had no Float: at the beginning causing tag mismatch
411 g_dynamicSpawnCounter_Perc,
412 g_dynamicSpawn_Perc,
413
414 // Fatal dead
415 Float:g_fCvar_fatal_chance,
416 Float:g_fCvar_fatal_head_chance,
417 g_iCvar_fatal_limb_dmg,
418 g_iCvar_fatal_head_dmg,
419 g_iCvar_fatal_burn_dmg,
420 g_iCvar_fatal_explosive_dmg,
421 g_iCvar_fatal_chest_stomach,
422 //Dynamic Loadouts
423 g_iCvar_bombers_only,
424 g_iCvar_multi_loadout_enabled,
425
426 //Respawn Mode (wave based)
427 g_respawn_mode_team_sec,
428 g_respawn_mode_team_ins,
429 g_respawn_wave_int_team_ins,
430
431 //NEW Respawn system globals (temporary)
432 //Grab directly from theater (3 scouts, 5 jugs, 4 bombers, All others 20)
433 //g_maxbots_std = 0, - commented out by oz - symbol never used?
434 //g_maxbots_light = 0, - commented out by oz - symbol never used?
435 //g_maxbots_jug = 0, - commented out by oz - symbol never used?
436 //g_maxbots_bomb = 0, - commented out by oz - symbol never used?
437 //Template of bots AI Director uses
438 //g_bots_std = 0, - commented out by oz
439 //g_bots_light = 0, - commented out by oz
440 //g_bots_jug = 0, - commented out by oz
441 //g_bots_bomb = 0, - commented out by oz
442
443 //VIP Globals
444 g_iCvar_vip_obj_time,
445 g_iCvar_vip_min_sp_reward,
446 g_iCvar_vip_max_sp_reward,
447 g_vip_enable,
448 g_vip_obj_count,
449 g_vip_obj_ready,
450 g_vip_min_reward,
451 g_vip_max_reward,
452 g_nVIP_ID = 0,
453 g_cacheObjActive = 0,
454 g_checkStaticAmt,
455 g_checkStaticAmtCntr,
456 g_checkStaticAmtAway,
457 g_checkStaticAmtCntrAway,
458 g_iReinforceTime,
459 g_iReinforceTimeSubsequent,
460 g_iReinforceTime_AD_Temp,
461 g_iReinforceTimeSubsequent_AD_Temp,
462 g_iReinforce_Mult,
463 g_iReinforce_Mult_Base,
464 g_iRemaining_lives_team_sec,
465 g_iRemaining_lives_team_ins,
466 g_iRespawn_lives_team_sec,
467 g_iRespawn_lives_team_ins,
468 g_iReviveSeconds,
469 g_iRespawnSeconds,
470 g_secWave_Timer,
471 g_iHeal_amount_paddles,
472 g_iHeal_amount_medPack,
473 g_nonMedicHeal_amount,
474 g_nonMedicRevive_hp,
475 g_minorWoundRevive_hp,
476 g_modWoundRevive_hp,
477 g_critWoundRevive_hp,
478 g_minorWound_dmg,
479 g_moderateWound_dmg,
480 g_medicHealSelf_max,
481 g_nonMedicHealSelf_max,
482 g_nonMedic_maxHealOther,
483 g_minorRevive_time,
484 g_modRevive_time,
485 g_critRevive_time,
486 g_nonMedRevive_time,
487 g_medpack_health_amt,
488 g_botsReady,
489 g_isConquer,
490 g_isOutpost,
491 g_isCheckpoint,
492 g_isHunt,
493 Float:g_flMinPlayerDistance,
494 Float:g_flBackSpawnIncrease,
495 Float:g_flMaxPlayerDistance,
496 Float:g_flCanSeeVectorMultiplier,
497 Float:g_flMinObjectiveDistance,
498 Float:g_flMaxObjectiveDistance,
499 Float:g_flMaxObjectiveDistanceNav,
500 Float:g_flSpawnAttackDelay,
501 Float:g_flMinCounterattackDistance,
502
503 //Elite bots Counters
504 g_ins_bot_count_checkpoint_max_org,
505 g_mp_player_resupply_coop_delay_max_org,
506 g_mp_player_resupply_coop_delay_penalty_org,
507 g_mp_player_resupply_coop_delay_base_org,
508 g_bot_attack_aimpenalty_amt_close_org,
509 g_bot_attack_aimpenalty_amt_far_org,
510 g_bot_attack_aimpenalty_time_close_org,
511 g_bot_attack_aimpenalty_time_far_org,
512 g_bot_aim_aimtracking_base_org,
513 g_bot_aim_aimtracking_frac_impossible_org,
514 g_bot_aim_angularvelocity_frac_impossible_org,
515 g_bot_aim_angularvelocity_frac_sprinting_target_org,
516 g_bot_aim_attack_aimtolerance_frac_impossible_org,
517 Float:g_bot_attackdelay_frac_difficulty_impossible_org,
518 Float:g_bot_attack_aimtolerance_newthreat_amt_org,
519 Float:g_bot_attack_aimtolerance_newthreat_amt_mult,
520 g_bot_attack_aimpenalty_amt_close_mult,
521 g_bot_attack_aimpenalty_amt_far_mult,
522 Float:g_bot_attackdelay_frac_difficulty_impossible_mult,
523 Float:g_bot_attack_aimpenalty_time_close_mult,
524 Float:g_bot_attack_aimpenalty_time_far_mult,
525 Float:g_bot_aim_aimtracking_base,
526 Float:g_bot_aim_aimtracking_frac_impossible,
527 Float:g_bot_aim_angularvelocity_frac_impossible,
528 Float:g_bot_aim_angularvelocity_frac_sprinting_target,
529 Float:g_bot_aim_attack_aimtolerance_frac_impossible,
530 g_coop_delay_penalty_base,
531 g_isEliteCounter;
532
533 //Track enemy wave spawners
534 g_enemyStdMax = 4,
535 g_enemyFighterMax = 5,
536 g_enemyStrikerMax = 6,
537 g_enemyScoutMax = 3,
538 g_enemySapperMax = 4,
539 g_enemyJuggerMax = 5,
540 g_enemyBomberMax = 4,
541
542 //Count enemy currently alive
543 g_enemyStdAliveCount = 0,
544 g_enemyFighterAliveCount = 0,
545 g_enemyStrikerAliveCount = 0,
546 g_enemyScoutAliveCount = 0,
547 g_enemySapperAliveCount = 0,
548 g_enemyJuggerAliveCount = 0,
549 g_enemyBomberAliveCount = 0,
550
551 // Insurgency implements
552 g_iObjResEntity, String:g_iObjResEntityNetClass[32];
553 g_iLogicEntity, String:g_iLogicEntityNetClass[32];
554
555enum SpawnModes
556{
557 SpawnMode_Normal = 0,
558 SpawnMode_HidingSpots,
559 SpawnMode_SpawnPoints,
560};
561
562
563new m_hMyWeapons, m_flNextPrimaryAttack, m_flNextSecondaryAttack;
564/////////////////////////////////////
565// Rank System (Based on graczu's Simple CS:S Rank - https://forums.alliedmods.net/showthread.php?p=523601)
566//
567/*
568MySQL Query:
569
570CREATE TABLE `ins_rank`(
571`rank_id` int(64) NOT NULL auto_increment,
572`steamId` varchar(32) NOT NULL default '',
573`nick` varchar(128) NOT NULL default '',
574`score` int(12) NOT NULL default '0',
575`kills` int(12) NOT NULL default '0',
576`deaths` int(12) NOT NULL default '0',
577`headshots` int(12) NOT NULL default '0',
578`sucsides` int(12) NOT NULL default '0',
579`revives` int(12) NOT NULL default '0',
580`heals` int(12) NOT NULL default '0',
581`last_active` int(12) NOT NULL default '0',
582`played_time` int(12) NOT NULL default '0',
583PRIMARY KEY (`rank_id`)) ENGINE=INNODB DEFAULT CHARSET=utf8;
584
585database.cfg
586
587 "insrank"
588 {
589 "driver" "default"
590 "host" "127.0.0.1"
591 "database" "database_name"
592 "user" "database_user"
593 "pass" "PASSWORD"
594 //"timeout" "0"
595 "port" "3306"
596 }
597*/
598
599// KOLOROWE KREDKI
600#define YELLOW 0x01
601#define GREEN 0x04
602
603
604// SOME DEFINES
605#define MAX_LINE_WIDTH 60
606#define PLUGIN_VERSION "1.4"
607
608// STATS TIME (SET DAYS AFTER STATS ARE DELETE OF NONACTIVE PLAYERS)
609#define PLAYER_STATSOLD 30
610
611// STATS DEFINATION FOR PLAYERS
612new g_iStatScore[MAXPLAYERS+1];
613new g_iStatKills[MAXPLAYERS+1];
614new g_iStatDeaths[MAXPLAYERS+1];
615new g_iStatHeadShots[MAXPLAYERS+1];
616new g_iStatSuicides[MAXPLAYERS+1];
617new g_iStatRevives[MAXPLAYERS+1];
618new g_iStatHeals[MAXPLAYERS+1];
619new g_iUserInit[MAXPLAYERS+1];
620new g_iUserFlood[MAXPLAYERS+1];
621new g_iUserPtime[MAXPLAYERS+1];
622new String:g_sSteamIdSave[MAXPLAYERS+1][255];
623new g_iRank[MAXPLAYERS+1];
624
625// HANDLE OF DATABASE
626//new Handle:g_hDB; - commented by oz
627//
628/////////////////////////////////////
629
630//#define PLUGIN_VERSION "1.7.61"
631#define PLUGIN_DESCRIPTION "Respawn dead players via admincommand or by queues"
632#define UPDATE_URL "http://ins.jballou.com/sourcemod/update-respawn.txt"
633
634// Plugin info
635public Plugin:myinfo =
636{
637 name = "[INS] Player Respawn",
638 author = "Jared Ballou (Contributor: Daimyo, naong, and community members)",
639 version = PLUGIN_VERSION,
640 description = PLUGIN_DESCRIPTION,
641 url = "http://jballou.com"
642};
643
644// Start plugin
645public OnPluginStart()
646{
647 //Find player gear offset
648 g_iPlayerEquipGear = FindSendPropInfo("CINSPlayer", "m_EquippedGear");
649
650 RegConsoleCmd("sm_emap", emap);
651 RegConsoleCmd("sm_test", test);
652 RegConsoleCmd("sm_hints", Toggle_Hints);
653
654 RegConsoleCmd("sm_serverhelp", serverhelp);
655
656 //Create player array list
657 g_playerArrayList = CreateArray();
658 //g_badSpawnPos_Array = CreateArray();
659 RegConsoleCmd("kill", cmd_kill);
660
661
662 CreateConVar("sm_respawn_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD);
663 sm_respawn_enabled = CreateConVar("sm_respawn_enabled", "1", "Automatically respawn players when they die; 0 - disabled, 1 - enabled");
664 sm_revive_enabled = CreateConVar("sm_revive_enabled", "1", "Reviving enabled from medics? This creates revivable ragdoll after death; 0 - disabled, 1 - enabled");
665
666 // Nav Mesh Botspawn specific START
667 cvarSpawnMode = CreateConVar("sm_botspawns_spawn_mode", "1", "Only normal spawnpoints at the objective, the old way (0), spawn in hiding spots following rules (1)", FCVAR_NOTIFY);
668 cvarMinCounterattackDistance = CreateConVar("sm_botspawns_min_counterattack_distance", "3600.0", "Min distance from counterattack objective to spawn", FCVAR_NOTIFY);
669 cvarMinPlayerDistance = CreateConVar("sm_botspawns_min_player_distance", "240.0", "Min distance from players to spawn", FCVAR_NOTIFY);
670 cvarMaxPlayerDistance = CreateConVar("sm_botspawns_max_player_distance", "16000.0", "Max distance from players to spawn", FCVAR_NOTIFY);
671 cvarCanSeeVectorMultiplier = CreateConVar("sm_botpawns_can_see_vect_mult", "1.5", "Divide this with sm_botspawns_max_player_distance to get CanSeeVector allowed distance for bot spawning in LOS", FCVAR_NOTIFY);
672 cvarMinObjectiveDistance = CreateConVar("sm_botspawns_min_objective_distance", "240", "Min distance from next objective to spawn", FCVAR_NOTIFY);
673 cvarMaxObjectiveDistance = CreateConVar("sm_botspawns_max_objective_distance", "12000", "Max distance from next objective to spawn", FCVAR_NOTIFY);
674 cvarMaxObjectiveDistanceNav = CreateConVar("sm_botspawns_max_objective_distance_nav", "2000", "Max distance from next objective to spawn", FCVAR_NOTIFY);
675 cvarBackSpawnIncrease = CreateConVar("sm_botspawns_backspawn_increase", "1400.0", "Whenever bot spawn on last point, this is added to minimum player respawn distance to avoid spawning too close to player.", FCVAR_NOTIFY);
676 cvarSpawnAttackDelay = CreateConVar("sm_botspawns_spawn_attack_delay", "2", "Delay in seconds for spawning bots to wait before firing.", FCVAR_NOTIFY);
677 // Nav Mesh Botspawn specific END
678
679 // Respawn delay time
680 sm_respawn_delay_team_ins = CreateConVar("sm_respawn_delay_team_ins",
681 "1.0", "How many seconds to delay the respawn (bots)");
682 sm_respawn_delay_team_ins_special = CreateConVar("sm_respawn_delay_team_ins_special",
683 "20.0", "How many seconds to delay the respawn (special bots)");
684 sm_respawn_delay_team_sec = CreateConVar("sm_respawn_delay_team_sec",
685 "30.0", "How many seconds to delay the respawn (If not set 'sm_respawn_delay_team_sec_player_count_XX' uses this value)");
686 sm_respawn_delay_team_sec_player_count_01 = CreateConVar("sm_respawn_delay_team_sec_player_count_01",
687 "5.0", "How many seconds to delay the respawn (when player count is 1)");
688 sm_respawn_delay_team_sec_player_count_02 = CreateConVar("sm_respawn_delay_team_sec_player_count_02",
689 "10.0", "How many seconds to delay the respawn (when player count is 2)");
690 sm_respawn_delay_team_sec_player_count_03 = CreateConVar("sm_respawn_delay_team_sec_player_count_03",
691 "20.0", "How many seconds to delay the respawn (when player count is 3)");
692 sm_respawn_delay_team_sec_player_count_04 = CreateConVar("sm_respawn_delay_team_sec_player_count_04",
693 "30.0", "How many seconds to delay the respawn (when player count is 4)");
694 sm_respawn_delay_team_sec_player_count_05 = CreateConVar("sm_respawn_delay_team_sec_player_count_05",
695 "60.0", "How many seconds to delay the respawn (when player count is 5)");
696 sm_respawn_delay_team_sec_player_count_06 = CreateConVar("sm_respawn_delay_team_sec_player_count_06",
697 "60.0", "How many seconds to delay the respawn (when player count is 6)");
698 sm_respawn_delay_team_sec_player_count_07 = CreateConVar("sm_respawn_delay_team_sec_player_count_07",
699 "70.0", "How many seconds to delay the respawn (when player count is 7)");
700 sm_respawn_delay_team_sec_player_count_08 = CreateConVar("sm_respawn_delay_team_sec_player_count_08",
701 "70.0", "How many seconds to delay the respawn (when player count is 8)");
702 sm_respawn_delay_team_sec_player_count_09 = CreateConVar("sm_respawn_delay_team_sec_player_count_09",
703 "80.0", "How many seconds to delay the respawn (when player count is 9)");
704 sm_respawn_delay_team_sec_player_count_10 = CreateConVar("sm_respawn_delay_team_sec_player_count_10",
705 "80.0", "How many seconds to delay the respawn (when player count is 10)");
706 sm_respawn_delay_team_sec_player_count_11 = CreateConVar("sm_respawn_delay_team_sec_player_count_11",
707 "90.0", "How many seconds to delay the respawn (when player count is 11)");
708 sm_respawn_delay_team_sec_player_count_12 = CreateConVar("sm_respawn_delay_team_sec_player_count_12",
709 "90.0", "How many seconds to delay the respawn (when player count is 12)");
710 sm_respawn_delay_team_sec_player_count_13 = CreateConVar("sm_respawn_delay_team_sec_player_count_13",
711 "100.0", "How many seconds to delay the respawn (when player count is 13)");
712 sm_respawn_delay_team_sec_player_count_14 = CreateConVar("sm_respawn_delay_team_sec_player_count_14",
713 "100.0", "How many seconds to delay the respawn (when player count is 14)");
714 sm_respawn_delay_team_sec_player_count_15 = CreateConVar("sm_respawn_delay_team_sec_player_count_15",
715 "110.0", "How many seconds to delay the respawn (when player count is 15)");
716 sm_respawn_delay_team_sec_player_count_16 = CreateConVar("sm_respawn_delay_team_sec_player_count_16",
717 "110.0", "How many seconds to delay the respawn (when player count is 16)");
718 sm_respawn_delay_team_sec_player_count_17 = CreateConVar("sm_respawn_delay_team_sec_player_count_17",
719 "120.0", "How many seconds to delay the respawn (when player count is 17)");
720 sm_respawn_delay_team_sec_player_count_18 = CreateConVar("sm_respawn_delay_team_sec_player_count_18",
721 "120.0", "How many seconds to delay the respawn (when player count is 18)");
722 sm_respawn_delay_team_sec_player_count_19 = CreateConVar("sm_respawn_delay_team_sec_player_count_19",
723 "130.0", "How many seconds to delay the respawn (when player count is 19)");
724
725 // Respawn type
726 sm_respawn_type_team_sec = CreateConVar("sm_respawn_type_team_sec",
727 "1", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_sec must be > 0");
728 sm_respawn_type_team_ins = CreateConVar("sm_respawn_type_team_ins",
729 "2", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_ins must be > 0");
730
731 // Respawn lives
732 sm_respawn_lives_team_sec = CreateConVar("sm_respawn_lives_team_sec",
733 "-1", "Respawn players this many times (-1: Disables player respawn)");
734 sm_respawn_lives_team_ins = CreateConVar("sm_respawn_lives_team_ins",
735 "10", "If 'sm_respawn_type_team_ins' set 1, respawn bots this many times. If 'sm_respawn_type_team_ins' set 2, total bot count (If not set 'sm_respawn_lives_team_ins_player_count_XX' uses this value)");
736 sm_respawn_lives_team_ins_player_count_01 = CreateConVar("sm_respawn_lives_team_ins_player_count_01",
737 "5", "Total bot count (when player count is 1)(sm_respawn_type_team_ins must be 2)");
738 sm_respawn_lives_team_ins_player_count_02 = CreateConVar("sm_respawn_lives_team_ins_player_count_02",
739 "10", "Total bot count (when player count is 2)(sm_respawn_type_team_ins must be 2)");
740 sm_respawn_lives_team_ins_player_count_03 = CreateConVar("sm_respawn_lives_team_ins_player_count_03",
741 "15", "Total bot count (when player count is 3)(sm_respawn_type_team_ins must be 2)");
742 sm_respawn_lives_team_ins_player_count_04 = CreateConVar("sm_respawn_lives_team_ins_player_count_04",
743 "20", "Total bot count (when player count is 4)(sm_respawn_type_team_ins must be 2)");
744 sm_respawn_lives_team_ins_player_count_05 = CreateConVar("sm_respawn_lives_team_ins_player_count_05",
745 "25", "Total bot count (when player count is 5)(sm_respawn_type_team_ins must be 2)");
746 sm_respawn_lives_team_ins_player_count_06 = CreateConVar("sm_respawn_lives_team_ins_player_count_06",
747 "30", "Total bot count (when player count is 6)(sm_respawn_type_team_ins must be 2)");
748 sm_respawn_lives_team_ins_player_count_07 = CreateConVar("sm_respawn_lives_team_ins_player_count_07",
749 "35", "Total bot count (when player count is 7)(sm_respawn_type_team_ins must be 2)");
750 sm_respawn_lives_team_ins_player_count_08 = CreateConVar("sm_respawn_lives_team_ins_player_count_08",
751 "40", "Total bot count (when player count is 8)(sm_respawn_type_team_ins must be 2)");
752 sm_respawn_lives_team_ins_player_count_09 = CreateConVar("sm_respawn_lives_team_ins_player_count_09",
753 "45", "Total bot count (when player count is 9)(sm_respawn_type_team_ins must be 2)");
754 sm_respawn_lives_team_ins_player_count_10 = CreateConVar("sm_respawn_lives_team_ins_player_count_10",
755 "50", "Total bot count (when player count is 10)(sm_respawn_type_team_ins must be 2)");
756 sm_respawn_lives_team_ins_player_count_11 = CreateConVar("sm_respawn_lives_team_ins_player_count_11",
757 "55", "Total bot count (when player count is 11)(sm_respawn_type_team_ins must be 2)");
758 sm_respawn_lives_team_ins_player_count_12 = CreateConVar("sm_respawn_lives_team_ins_player_count_12",
759 "60", "Total bot count (when player count is 12)(sm_respawn_type_team_ins must be 2)");
760 sm_respawn_lives_team_ins_player_count_13 = CreateConVar("sm_respawn_lives_team_ins_player_count_13",
761 "65", "Total bot count (when player count is 13)(sm_respawn_type_team_ins must be 2)");
762 sm_respawn_lives_team_ins_player_count_14 = CreateConVar("sm_respawn_lives_team_ins_player_count_14",
763 "70", "Total bot count (when player count is 14)(sm_respawn_type_team_ins must be 2)");
764 sm_respawn_lives_team_ins_player_count_15 = CreateConVar("sm_respawn_lives_team_ins_player_count_15",
765 "75", "Total bot count (when player count is 15)(sm_respawn_type_team_ins must be 2)");
766 sm_respawn_lives_team_ins_player_count_16 = CreateConVar("sm_respawn_lives_team_ins_player_count_16",
767 "80", "Total bot count (when player count is 16)(sm_respawn_type_team_ins must be 2)");
768 sm_respawn_lives_team_ins_player_count_17 = CreateConVar("sm_respawn_lives_team_ins_player_count_17",
769 "85", "Total bot count (when player count is 17)(sm_respawn_type_team_ins must be 2)");
770 sm_respawn_lives_team_ins_player_count_18 = CreateConVar("sm_respawn_lives_team_ins_player_count_18",
771 "90", "Total bot count (when player count is 18)(sm_respawn_type_team_ins must be 2)");
772 sm_respawn_lives_team_ins_player_count_19 = CreateConVar("sm_respawn_lives_team_ins_player_count_19",
773 "90", "Total bot count (when player count is 19)(sm_respawn_type_team_ins must be 2)");
774
775 // Fatally death
776 sm_respawn_fatal_chance = CreateConVar("sm_respawn_fatal_chance", "0.20", "Chance for a kill to be fatal, 0.6 default = 60% chance to be fatal (To disable set 0.0)");
777 sm_respawn_fatal_head_chance = CreateConVar("sm_respawn_fatal_head_chance", "0.30", "Chance for a headshot kill to be fatal, 0.6 default = 60% chance to be fatal");
778 sm_respawn_fatal_limb_dmg = CreateConVar("sm_respawn_fatal_limb_dmg", "80", "Amount of damage to fatally kill player in limb");
779 sm_respawn_fatal_head_dmg = CreateConVar("sm_respawn_fatal_head_dmg", "100", "Amount of damage to fatally kill player in head");
780 sm_respawn_fatal_burn_dmg = CreateConVar("sm_respawn_fatal_burn_dmg", "50", "Amount of damage to fatally kill player in burn");
781 sm_respawn_fatal_explosive_dmg = CreateConVar("sm_respawn_fatal_explosive_dmg", "200", "Amount of damage to fatally kill player in explosive");
782 sm_respawn_fatal_chest_stomach = CreateConVar("sm_respawn_fatal_chest_stomach", "100", "Amount of damage to fatally kill player in chest/stomach");
783
784 // Counter attack
785 sm_respawn_counter_chance = CreateConVar("sm_respawn_counter_chance", "0.5", "Percent chance that a counter attack will happen def: 50%");
786 sm_respawn_counterattack_type = CreateConVar("sm_respawn_counterattack_type", "2", "Respawn during counterattack? (0: no, 1: yes, 2: infinite)");
787 sm_respawn_final_counterattack_type = CreateConVar("sm_respawn_final_counterattack_type", "2", "Respawn during final counterattack? (0: no, 1: yes, 2: infinite)");
788 sm_respawn_security_on_counter = CreateConVar("sm_respawn_security_on_counter", "1", "0/1 When a counter attack starts, spawn all dead players and teleport them to point to defend");
789 sm_respawn_min_counter_dur_sec = CreateConVar("sm_respawn_min_counter_dur_sec", "66", "Minimum randomized counter attack duration");
790 sm_respawn_max_counter_dur_sec = CreateConVar("sm_respawn_max_counter_dur_sec", "126", "Maximum randomized counter attack duration");
791 sm_respawn_final_counter_dur_sec = CreateConVar("sm_respawn_final_counter_dur_sec", "180", "Final counter attack duration");
792 sm_respawn_counterattack_vanilla = CreateConVar("sm_respawn_counterattack_vanilla", "0", "Use vanilla counter attack mechanics? (0: no, 1: yes)");
793
794 //Dynamic respawn mechanics
795 sm_respawn_dynamic_distance_multiplier = CreateConVar("sm_respawn_dynamic_distance_multiplier", "2", "This multiplier is used to make bot distance from points on/off counter attacks more dynamic by making distance closer/farther when bots respawn");
796 sm_respawn_dynamic_spawn_counter_percent = CreateConVar("sm_respawn_dynamic_spawn_counter_percent", "40", "Percent of bots that will spawn farther away on a counter attack (basically their more ideal normal spawns)");
797 sm_respawn_dynamic_spawn_percent = CreateConVar("sm_respawn_dynamic_spawn_percent", "5", "Percent of bots that will spawn farther away NOT on a counter (basically their more ideal normal spawns)");
798
799 // Misc
800 sm_respawn_reset_type = CreateConVar("sm_respawn_reset_type", "0", "Set type of resetting player respawn counts: each round or each objective (0: each round, 1: each objective)");
801 sm_respawn_enable_track_ammo = CreateConVar("sm_respawn_enable_track_ammo", "1", "0/1 Track ammo on death to revive (may be buggy if using a different theatre that modifies ammo)");
802
803 // Reinforcements
804 sm_respawn_reinforce_time = CreateConVar("sm_respawn_reinforce_time", "200", "When enemy forces are low on lives, how much time til they get reinforcements?");
805 sm_respawn_reinforce_time_subsequent = CreateConVar("sm_respawn_reinforce_time_subsequent", "140", "When enemy forces are low on lives and already reinforced, how much time til they get reinforcements on subsequent reinforcement?");
806 sm_respawn_reinforce_multiplier = CreateConVar("sm_respawn_reinforce_multiplier", "4", "Division multiplier to determine when to start reinforce timer for bots based on team pool lives left over");
807 sm_respawn_reinforce_multiplier_base = CreateConVar("sm_respawn_reinforce_multiplier_base", "10", "This is the base int number added to the division multiplier, so (10 * reinforce_mult + base_mult)");
808
809 // Control static enemy
810 sm_respawn_check_static_enemy = CreateConVar("sm_respawn_check_static_enemy", "120", "Seconds amount to check if an AI has moved probably stuck");
811 sm_respawn_check_static_enemy_counter = CreateConVar("sm_respawn_check_static_enemy_counter", "10", "Seconds amount to check if an AI has moved during counter");
812
813 // Donor tag
814 sm_respawn_enable_donor_tag = CreateConVar("sm_respawn_enable_donor_tag", "1", "If player has an access to reserved slot, add [DONOR] tag.");
815
816 // Related to 'RoundEnd_Protector' plugin
817 sm_remaininglife = CreateConVar("sm_remaininglife", "-1", "Returns total remaining life.");
818
819 // Medic Revive
820 sm_revive_seconds = CreateConVar("sm_revive_seconds", "5", "Time in seconds medic needs to stand over body to revive");
821 sm_revive_bonus = CreateConVar("sm_revive_bonus", "1", "Bonus revive score(kill count) for medic");
822 sm_revive_distance_metric = CreateConVar("sm_revive_distance_metric", "1", "Distance metric (0: meters / 1: feet)");
823 sm_heal_bonus = CreateConVar("sm_heal_bonus", "1", "Bonus heal score(kill count) for medic");
824 sm_heal_cap_for_bonus = CreateConVar("sm_heal_cap_for_bonus", "5000", "Amount of health given to other players to gain a life");
825 sm_revive_cap_for_bonus = CreateConVar("sm_revive_cap_for_bonus", "50", "Amount of revives before medic gains a life");
826 sm_reward_medics_enabled = CreateConVar("sm_reward_medics_enabled", "1", "Enabled rewarding medics with lives? 0 = no, 1 = yes");
827 sm_heal_amount_medpack = CreateConVar("sm_heal_amount_medpack", "5", "Heal amount per 0.5 seconds when using medpack");
828 sm_heal_amount_paddles = CreateConVar("sm_heal_amount_paddles", "3", "Heal amount per 0.5 seconds when using paddles");
829
830 sm_non_medic_heal_amt = CreateConVar("sm_non_medic_heal_amt", "2", "Heal amount per 0.5 seconds when non-medic");
831 sm_non_medic_revive_hp = CreateConVar("sm_non_medic_revive_hp", "10", "Health given to target revive when non-medic reviving");
832 sm_medic_minor_revive_hp = CreateConVar("sm_medic_minor_revive_hp", "75", "Health given to target revive when medic reviving minor wound");
833 sm_medic_moderate_revive_hp = CreateConVar("sm_medic_moderate_revive_hp", "50", "Health given to target revive when medic reviving moderate wound");
834 sm_medic_critical_revive_hp = CreateConVar("sm_medic_critical_revive_hp", "25", "Health given to target revive when medic reviving critical wound");
835 sm_minor_wound_dmg = CreateConVar("sm_minor_wound_dmg", "100", "Any amount of damage <= to this is considered a minor wound when killed");
836 sm_moderate_wound_dmg = CreateConVar("sm_moderate_wound_dmg", "200", "Any amount of damage <= to this is considered a minor wound when killed. Anything greater is CRITICAL");
837 sm_medic_heal_self_max = CreateConVar("sm_medic_heal_self_max", "75", "Max medic can heal self to with med pack");
838 sm_non_medic_heal_self_max = CreateConVar("sm_non_medic_heal_self_max", "25", "Max non-medic can heal self to with med pack");
839 sm_non_medic_max_heal_other = CreateConVar("sm_non_medic_max_heal_other", "25", "Heal amount per 0.5 seconds when using paddles");
840 sm_minor_revive_time = CreateConVar("sm_minor_revive_time", "4", "Seconds it takes medic to revive minor wounded");
841 sm_moderate_revive_time = CreateConVar("sm_moderate_revive_time", "7", "Seconds it takes medic to revive moderate wounded");
842 sm_critical_revive_time = CreateConVar("sm_critical_revive_time", "10", "Seconds it takes medic to revive critical wounded");
843 sm_non_medic_revive_time = CreateConVar("sm_non_medic_revive_time", "30", "Seconds it takes non-medic to revive minor wounded, requires medpack");
844 sm_medpack_health_amount = CreateConVar("sm_medpack_health_amount", "500", "Amount of health a deployed healthpack has");
845 sm_bombers_only = CreateConVar("sm_bombers_only", "0", "bombers ONLY?");
846 sm_multi_loadout_enabled = CreateConVar("sm_multi_loadout_enabled", "0", "Use Sernix Variety Bot Loadout? - Default OFF");
847 sm_ammo_resupply_range = CreateConVar("sm_ammo_resupply_range", "80", "Range to resupply near ammo cache");
848 sm_resupply_delay = CreateConVar("sm_resupply_delay", "5", "Delay loop for resupply ammo");
849 sm_jammer_required = CreateConVar("sm_jammer_required", "1", "Require deployable jammer for enemy reports? 0 = Disabled 1 = Enabled");
850 sm_elite_counter_attacks = CreateConVar("sm_elite_counter_attacks", "1", "Enable increased bot skills, numbers on counters?");
851 sm_enable_bonus_lives = CreateConVar("sm_enable_bonus_lives", "1", "Give bonus lives based on X condition? 0|1 ");
852
853
854 //Specialized Counter
855 sm_finale_counter_spec_enabled = CreateConVar("sm_finale_counter_spec_enabled", "0", "Enable specialized finale spawn percent? 1|0");
856 sm_finale_counter_spec_percent = CreateConVar("sm_finale_counter_spec_percent", "40", "What specialized finale counter percent for this map?");
857 sm_cqc_map_enabled = CreateConVar("sm_cqc_map_enabled", "0", "Is this a cqc map? 0|1 no|yes");
858 sm_enable_squad_spawning = CreateConVar("sm_enable_squad_spawning", "0", "Enable squad spawning SERNIX SPECIFIC? 1|0");
859
860 //AI Director cvars
861 sm_ai_director_setdiff_chance_base = CreateConVar("sm_ai_director_setdiff_chance_base", "10", "Base AI Director Set Hard Difficulty Chance");
862
863 //Respawn Modes
864 sm_respawn_mode_team_sec = CreateConVar("sm_respawn_mode_team_sec", "1", "Security: 0 = Individual spawning | 1 = Wave based spawning");
865 sm_respawn_mode_team_ins = CreateConVar("sm_respawn_mode_team_ins", "0", "Insurgents: 0 = Individual spawning | 1 = Wave based spawning");
866
867 //Wave interval for insurgents only
868 sm_respawn_wave_int_team_ins = CreateConVar("sm_respawn_wave_int_team_ins", "1", "Time in seconds bots will respawn in waves");
869
870 //VIP Specific cvar
871 sm_vip_obj_time = CreateConVar("sm_vip_obj_time", "300", "VIP must reach new CPs in this amount of seconds");
872 sm_vip_min_sp_reward = CreateConVar("sm_vip_min_sp_reward", "1", "Minimum supply points awarded to team when VIP completes objective");
873 sm_vip_max_sp_reward = CreateConVar("sm_vip_max_sp_reward", "3", "Maximum supply points awarded to team when VIP completes objective");
874 sm_vip_enabled = CreateConVar("sm_vip_enabled", "1", "Disable or Enable VIP features 0/1");
875
876
877
878 //if (GetConVarInt(sm_enable_squad_spawning) == 1)
879 RegConsoleCmd("sm_ss", SquadSpawn);
880 RegConsoleCmd("vip", Cmd_VIP, "Check for info about VIP");
881
882 //CreateConVar("Lua_Ins_Healthkit", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_PLUGIN | FCVAR_DONTRECORD);
883 CreateConVar("Lua_Ins_Healthkit", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD);
884
885
886 if ((m_hMyWeapons = FindSendPropInfo("CBasePlayer", "m_hMyWeapons")) == -1) {
887 SetFailState("Fatal Error: Unable to find property offset \"CBasePlayer::m_hMyWeapons\" !");
888 }
889
890 if ((m_flNextPrimaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextPrimaryAttack")) == -1) {
891 SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextPrimaryAttack\" !");
892 }
893
894 if ((m_flNextSecondaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextSecondaryAttack")) == -1) {
895 SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextSecondaryAttack\" !");
896 }
897
898 // Add admin respawn console command
899 RegAdminCmd("sm_respawn", Command_Respawn, ADMFLAG_SLAY, "sm_respawn <#userid|name>");
900
901 // Add reload config console command for admin
902 RegAdminCmd("sm_respawn_reload", Command_Reload, ADMFLAG_SLAY, "sm_respawn_reload");
903
904 // Event hooking
905 //Lua Specific
906 HookEvent("grenade_thrown", Event_GrenadeThrown);
907
908 // //For ins_spawnpoint spawning
909 HookEvent("player_spawn", Event_Spawn);
910 HookEvent("player_spawn", Event_SpawnPost, EventHookMode_Post);
911
912 HookEvent("player_hurt", Event_PlayerHurt_Pre, EventHookMode_Pre);
913 HookEvent("player_death", Event_PlayerDeath_Pre, EventHookMode_Pre);
914 HookEvent("player_death", Event_PlayerDeath);
915 HookEvent("round_start", Event_RoundStart);
916 HookEvent("round_end", Event_RoundEnd);
917 HookEvent("round_end", Event_RoundEnd_Pre, EventHookMode_Pre);
918 HookEvent("player_pick_squad", Event_PlayerPickSquad_Post, EventHookMode_Post);
919 HookEvent("object_destroyed", Event_ObjectDestroyed_Pre, EventHookMode_Pre);
920 HookEvent("object_destroyed", Event_ObjectDestroyed);
921 HookEvent("object_destroyed", Event_ObjectDestroyed_Post, EventHookMode_Post);
922 HookEvent("controlpoint_captured", Event_ControlPointCaptured_Pre, EventHookMode_Pre);
923 HookEvent("controlpoint_captured", Event_ControlPointCaptured);
924 HookEvent("controlpoint_captured", Event_ControlPointCaptured_Post, EventHookMode_Post);
925 HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
926 HookEvent("player_connect", Event_PlayerConnect);
927 HookEvent("game_end", Event_GameEnd, EventHookMode_PostNoCopy);
928 HookEvent("player_team", Event_PlayerTeam);
929
930 HookEvent("weapon_reload", Event_PlayerReload_Pre, EventHookMode_Pre);
931 HookEvent("player_blind", Event_OnFlashPlayerPre, EventHookMode_Pre);
932 AddCommandListener(ResupplyListener, "inventory_resupply");
933
934 // NavMesh Botspawn Specific Start
935 HookConVarChange(cvarSpawnMode,CvarChange);
936 // NavMesh Botspawn Specific End
937
938 // Revive/Heal specific
939 HookConVarChange(sm_revive_seconds, CvarChange);
940 HookConVarChange(sm_heal_amount_medpack, CvarChange);
941 HookConVarChange(sm_non_medic_heal_amt, CvarChange);
942 HookConVarChange(sm_non_medic_revive_hp, CvarChange);
943 HookConVarChange(sm_medic_minor_revive_hp, CvarChange);
944 HookConVarChange(sm_medic_moderate_revive_hp, CvarChange);
945 HookConVarChange(sm_medic_critical_revive_hp, CvarChange);
946 HookConVarChange(sm_minor_wound_dmg, CvarChange);
947 HookConVarChange(sm_moderate_wound_dmg, CvarChange);
948 HookConVarChange(sm_medic_heal_self_max, CvarChange);
949 HookConVarChange(sm_non_medic_heal_self_max, CvarChange);
950 HookConVarChange(sm_non_medic_max_heal_other, CvarChange);
951 HookConVarChange(sm_minor_revive_time, CvarChange);
952 HookConVarChange(sm_moderate_revive_time, CvarChange);
953 HookConVarChange(sm_critical_revive_time, CvarChange);
954 HookConVarChange(sm_non_medic_revive_time, CvarChange);
955 HookConVarChange(sm_medpack_health_amount, CvarChange);
956
957 // Respawn specific
958 HookConVarChange(sm_respawn_enabled, EnableChanged);
959 HookConVarChange(sm_revive_enabled, EnableChanged);
960 HookConVarChange(sm_respawn_delay_team_sec, CvarChange);
961 HookConVarChange(sm_respawn_delay_team_ins, CvarChange);
962 HookConVarChange(sm_respawn_delay_team_ins_special, CvarChange);
963 HookConVarChange(sm_respawn_lives_team_sec, CvarChange);
964 HookConVarChange(sm_respawn_lives_team_ins, CvarChange);
965 HookConVarChange(sm_respawn_reset_type, CvarChange);
966 HookConVarChange(sm_respawn_type_team_sec, CvarChange);
967 HookConVarChange(sm_respawn_type_team_ins, CvarChange);
968 HookConVarChange(cvarMinPlayerDistance,CvarChange);
969 HookConVarChange(cvarBackSpawnIncrease,CvarChange);
970 HookConVarChange(cvarMaxPlayerDistance,CvarChange);
971 HookConVarChange(cvarCanSeeVectorMultiplier,CvarChange);
972 HookConVarChange(cvarMinObjectiveDistance,CvarChange);
973 HookConVarChange(cvarMaxObjectiveDistance,CvarChange);
974 HookConVarChange(cvarMaxObjectiveDistanceNav,CvarChange);
975 HookConVarChange(sm_enable_bonus_lives, CvarChange);
976
977 //Dynamic respawning
978 HookConVarChange(sm_respawn_dynamic_distance_multiplier,CvarChange);
979 HookConVarChange(sm_respawn_dynamic_spawn_counter_percent,CvarChange);
980 HookConVarChange(sm_respawn_dynamic_spawn_percent,CvarChange);
981
982 //Reinforce Timer
983 HookConVarChange(sm_respawn_reinforce_time,CvarChange);
984 HookConVarChange(sm_respawn_reinforce_time_subsequent,CvarChange);
985 HookConVarChange(sm_respawn_reinforce_multiplier,CvarChange);
986 HookConVarChange(sm_respawn_reinforce_multiplier_base,CvarChange);
987
988 //Dynamic Loadouts
989 HookConVarChange(sm_bombers_only, CvarChange);
990 HookConVarChange(sm_multi_loadout_enabled, CvarChange);
991
992 // Tags
993 HookConVarChange(FindConVar("sv_tags"), TagsChanged);
994
995 //Other
996 HookConVarChange(sm_jammer_required, CvarChange);
997 HookConVarChange(sm_elite_counter_attacks, CvarChange);
998 HookConVarChange(sm_finale_counter_spec_enabled, CvarChange);
999 HookConVarChange(sm_ai_director_setdiff_chance_base, CvarChange);
1000 HookConVarChange(sm_respawn_mode_team_sec, CvarChange);
1001 HookConVarChange(sm_respawn_mode_team_ins, CvarChange);
1002 HookConVarChange(sm_respawn_wave_int_team_ins, CvarChange);
1003 HookConVarChange(sm_vip_obj_time, CvarChange);
1004 HookConVarChange(sm_vip_min_sp_reward, CvarChange);
1005 HookConVarChange(sm_vip_max_sp_reward, CvarChange);
1006 HookConVarChange(sm_vip_enabled, CvarChange);
1007 HookConVarChange(sm_finale_counter_spec_percent, CvarChange);
1008 // Init respawn function
1009 // Next 14 lines of text are taken from Andersso's DoDs respawn plugin. Thanks :)
1010 g_hGameConfig = LoadGameConfigFile("insurgency.games");
1011
1012 if (g_hGameConfig == INVALID_HANDLE)
1013 SetFailState("Fatal Error: Missing File \"insurgency.games\"!");
1014
1015 StartPrepSDKCall(SDKCall_Player);
1016 decl String:game[40];
1017 GetGameFolderName(game, sizeof(game));
1018 if (StrEqual(game, "insurgency")) {
1019 //PrintToServer("[RESPAWN] ForceRespawn for Insurgency");
1020 PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Signature, "ForceRespawn");
1021 }
1022 if (StrEqual(game, "doi")) {
1023 //PrintToServer("[RESPAWN] ForceRespawn for DoI");
1024 PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Virtual, "ForceRespawn");
1025 }
1026 if (StrEqual(game, "insurgency2")) {
1027 //PrintToServer("[RESPAWN] ForceRespawn for Insurgency");
1028 PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Signature, "ForceRespawn");
1029 }
1030 g_hForceRespawn = EndPrepSDKCall();
1031 if (g_hForceRespawn == INVALID_HANDLE) {
1032 SetFailState("Fatal Error: Unable to find signature for \"ForceRespawn\"!");
1033 }
1034 //Load localization file
1035 LoadTranslations("common.phrases");
1036 LoadTranslations("respawn.phrases");
1037 LoadTranslations("nearest_player.phrases.txt");
1038
1039
1040 // Init variables
1041 //g_iLogicEntity = -1; - commented by oz
1042 //g_iObjResEntity = -1; - commented by oz
1043
1044 //Uncomment this code and SQL code below to utilize rank system (youll need to setup yourself.)
1045 /////////////////////////
1046 // Rank System
1047 //RegConsoleCmd("say", Command_Say); // Monitor say
1048 //SQL_TConnect(LoadMySQLBase, "insrank"); // Connect to DB
1049 //
1050 /////////////////////////
1051
1052 AutoExecConfig(true, "respawn");
1053}
1054
1055//End Plugin
1056public OnPluginEnd()
1057{
1058 new ent = -1;
1059 while ((ent = FindEntityByClassname(ent, "healthkit")) > MaxClients && IsValidEntity(ent))
1060 {
1061 StopSound(ent, SNDCHAN_VOICE, "Lua_sounds/healthkit_healing.wav");
1062 AcceptEntityInput(ent, "Kill");
1063 }
1064}
1065
1066// Init config
1067public OnConfigsExecuted()
1068{
1069 if (GetConVarBool(sm_respawn_enabled))
1070 TagsCheck("respawntimes");
1071 else
1072 TagsCheck("respawntimes", true);
1073}
1074
1075// When cvar changed
1076public EnableChanged(Handle:convar, const String:oldValue[], const String:newValue[])
1077{
1078 new intNewValue = StringToInt(newValue);
1079 new intOldValue = StringToInt(oldValue);
1080
1081 if(intNewValue == 1 && intOldValue == 0)
1082 {
1083 TagsCheck("respawntimes");
1084 //HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
1085 }
1086 else if(intNewValue == 0 && intOldValue == 1)
1087 {
1088 TagsCheck("respawntimes", true);
1089 //UnhookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
1090 }
1091}
1092
1093// When cvar changed
1094public CvarChange(Handle:cvar, const String:oldvalue[], const String:newvalue[])
1095{
1096 UpdateRespawnCvars();
1097}
1098
1099// Update cvars
1100void UpdateRespawnCvars()
1101{
1102 //Counter attack chance based on number of points
1103 g_respawn_counter_chance = GetConVarFloat(sm_respawn_counter_chance);
1104 g_counterAttack_min_dur_sec = GetConVarInt(sm_respawn_min_counter_dur_sec);
1105 g_counterAttack_max_dur_sec = GetConVarInt(sm_respawn_max_counter_dur_sec);
1106
1107 // The number of control points
1108 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
1109 if (ncp < 6)
1110 {
1111 //Add to minimum dur as well.
1112 new fRandomInt = GetRandomInt(15, 30);
1113 new fRandomInt2 = GetRandomInt(6, 12);
1114 g_counterAttack_min_dur_sec += fRandomInt;
1115 g_counterAttack_max_dur_sec += fRandomInt2;
1116 g_respawn_counter_chance += 0.2;
1117 }
1118 else if (ncp >= 6 && ncp <= 8)
1119 {
1120 //Add to minimum dur as well.
1121 new fRandomInt = GetRandomInt(10, 20);
1122 new fRandomInt2 = GetRandomInt(4, 8);
1123 g_counterAttack_min_dur_sec += fRandomInt;
1124 g_counterAttack_max_dur_sec += fRandomInt2;
1125 g_respawn_counter_chance += 0.1;
1126 }
1127
1128 g_jammerRequired = GetConVarInt(sm_jammer_required);
1129 g_elite_counter_attacks = GetConVarInt(sm_elite_counter_attacks);
1130 g_finale_counter_spec_enabled = GetConVarInt(sm_finale_counter_spec_enabled);
1131 g_finale_counter_spec_percent = GetConVarInt(sm_finale_counter_spec_percent);
1132
1133 //Ai Director UpdateCvar
1134 g_AIDir_DiffChanceBase = GetConVarInt(sm_ai_director_setdiff_chance_base);
1135
1136 //Wave Based Spawning
1137 g_respawn_mode_team_sec = GetConVarInt(sm_respawn_mode_team_sec);
1138 g_respawn_mode_team_ins = GetConVarInt(sm_respawn_mode_team_ins);
1139 g_respawn_wave_int_team_ins = GetConVarInt(sm_respawn_wave_int_team_ins);
1140 g_iCvar_vip_obj_time = GetConVarInt(sm_vip_obj_time);
1141 g_iCvar_vip_min_sp_reward = GetConVarInt(sm_vip_min_sp_reward);
1142 g_iCvar_vip_max_sp_reward = GetConVarInt(sm_vip_max_sp_reward);
1143 g_vip_enable = GetConVarInt(sm_vip_enabled);
1144
1145 // Respawn type 1 //TEAM_1_SEC == Index 2 and TEAM_2_INS == Index 3
1146 g_iRespawnCount[2] = GetConVarInt(sm_respawn_lives_team_sec);
1147 g_iRespawnCount[3] = GetConVarInt(sm_respawn_lives_team_ins);
1148
1149 g_GiveBonusLives = GetConVarInt(sm_enable_bonus_lives);
1150
1151 //Give bonus lives if lives are added per round
1152 if (g_GiveBonusLives && g_iCvar_respawn_reset_type == 0)
1153 SecTeamLivesBonus();
1154
1155 //Below commented by oz
1156
1157 //if (g_easterEggRound == true)
1158 //{
1159 // g_iRespawnCount[2] = g_iRespawnCount[2] + 10;
1160 // g_iRespawnSeconds = (g_iRespawnSeconds / 2);
1161 // new cvar_mp_maxrounds = FindConVar("mp_maxrounds");
1162 // SetConVarInt(cvar_mp_maxrounds, 2, true, true);
1163 // new cvar_sm_botspawns_min_player_distance = FindConVar("sm_botspawns_min_player_distance");
1164 // SetConVarFloat(cvar_sm_botspawns_min_player_distance, 2000.0, true, true);
1165 // PrintToChatAll("************EASTER EGG ROUND************");
1166 // PrintToChatAll("******NO WHINING, BE NICE, HAVE FUN*****");
1167 // PrintToChatAll("******MAX ROUNDS CHANGED TO 2!**********");
1168 // PrintToChatAll("******WORK TOGETHER, ADAPT!*************");
1169 // PrintToChatAll("************EASTER EGG ROUND************");
1170 //}
1171
1172
1173 // Type of resetting respawn token, Non-checkpoint modes get set to 0 automatically
1174 g_iCvar_respawn_reset_type = GetConVarInt(sm_respawn_reset_type);
1175
1176 if(g_isCheckpoint == 0)
1177 g_iCvar_respawn_reset_type = 0;
1178
1179 // Update Cvars
1180 g_iCvar_respawn_enable = GetConVarInt(sm_respawn_enabled);
1181 g_iCvar_revive_enable = GetConVarInt(sm_revive_enabled);
1182
1183 // Bot spawn mode
1184 g_iCvar_SpawnMode = GetConVarInt(cvarSpawnMode);
1185
1186 g_iReinforce_Mult = GetConVarInt(sm_respawn_reinforce_multiplier);
1187 g_iReinforce_Mult_Base = GetConVarInt(sm_respawn_reinforce_multiplier_base);
1188
1189 // Tracking ammo
1190 g_iCvar_enable_track_ammo = GetConVarInt(sm_respawn_enable_track_ammo);
1191
1192 // Respawn type
1193 g_iCvar_respawn_type_team_ins = GetConVarInt(sm_respawn_type_team_ins);
1194 g_iCvar_respawn_type_team_sec = GetConVarInt(sm_respawn_type_team_sec);
1195
1196
1197 //Dynamic Respawns
1198 g_DynamicRespawn_Distance_mult = GetConVarFloat(sm_respawn_dynamic_distance_multiplier);
1199 g_dynamicSpawnCounter_Perc = GetConVarInt(sm_respawn_dynamic_spawn_counter_percent);
1200 g_dynamicSpawn_Perc = GetConVarInt(sm_respawn_dynamic_spawn_percent);
1201
1202 //Revive counts
1203 g_iReviveSeconds = GetConVarInt(sm_revive_seconds);
1204
1205 // Heal Amount
1206 g_iHeal_amount_medPack = GetConVarInt(sm_heal_amount_medpack);
1207 g_iHeal_amount_paddles = GetConVarInt(sm_heal_amount_paddles);
1208 g_nonMedicHeal_amount = GetConVarInt(sm_non_medic_heal_amt);
1209
1210 //HP when revived from wound
1211 g_nonMedicRevive_hp = GetConVarInt(sm_non_medic_revive_hp);
1212 g_minorWoundRevive_hp = GetConVarInt(sm_medic_minor_revive_hp);
1213 g_modWoundRevive_hp = GetConVarInt(sm_medic_moderate_revive_hp);
1214 g_critWoundRevive_hp = GetConVarInt(sm_medic_critical_revive_hp);
1215
1216 //New Revive Mechanics
1217 g_minorWound_dmg = GetConVarInt(sm_minor_wound_dmg);
1218 g_moderateWound_dmg = GetConVarInt(sm_moderate_wound_dmg);
1219 g_medicHealSelf_max = GetConVarInt(sm_medic_heal_self_max);
1220 g_nonMedicHealSelf_max = GetConVarInt(sm_non_medic_heal_self_max);
1221 g_nonMedic_maxHealOther = GetConVarInt(sm_non_medic_max_heal_other);
1222 g_minorRevive_time = GetConVarInt(sm_minor_revive_time);
1223 g_modRevive_time = GetConVarInt(sm_moderate_revive_time);
1224 g_critRevive_time = GetConVarInt(sm_critical_revive_time);
1225 g_nonMedRevive_time = GetConVarInt(sm_non_medic_revive_time);
1226 g_medpack_health_amt = GetConVarInt(sm_medpack_health_amount);
1227
1228 // Fatal dead
1229 g_fCvar_fatal_chance = GetConVarFloat(sm_respawn_fatal_chance);
1230 g_fCvar_fatal_head_chance = GetConVarFloat(sm_respawn_fatal_head_chance);
1231 g_iCvar_fatal_limb_dmg = GetConVarInt(sm_respawn_fatal_limb_dmg);
1232 g_iCvar_fatal_head_dmg = GetConVarInt(sm_respawn_fatal_head_dmg);
1233 g_iCvar_fatal_burn_dmg = GetConVarInt(sm_respawn_fatal_burn_dmg);
1234 g_iCvar_fatal_explosive_dmg = GetConVarInt(sm_respawn_fatal_explosive_dmg);
1235 g_iCvar_fatal_chest_stomach = GetConVarInt(sm_respawn_fatal_chest_stomach);
1236
1237 //Dynamic Loadouts
1238 //g_iCvar_bombers_only = GetConVarInt(sm_bombers_only);
1239 //g_iCvar_multi_loadout_enabled = GetConVarInt(sm_multi_loadout_enabled);
1240
1241
1242 // Nearest body distance metric
1243 g_iUnitMetric = GetConVarInt(sm_revive_distance_metric);
1244
1245 // Set respawn delay time
1246 g_iRespawnSeconds = -1;
1247 switch (GetTeamSecCount())
1248 {
1249 case 0: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_01);
1250 case 1: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_01);
1251 case 2: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_02);
1252 case 3: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_03);
1253 case 4: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_04);
1254 case 5: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_05);
1255 case 6: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_06);
1256 case 7: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_07);
1257 case 8: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_08);
1258 case 9: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_09);
1259 case 10: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_10);
1260 case 11: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_11);
1261 case 12: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_12);
1262 case 13: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_13);
1263 case 14: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_14);
1264 case 15: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_15);
1265 case 16: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_16);
1266 case 17: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_17);
1267 case 18: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_18);
1268 case 19: g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec_player_count_19);
1269 }
1270 // If not set use default
1271 if (g_iRespawnSeconds == -1)
1272 g_iRespawnSeconds = GetConVarInt(sm_respawn_delay_team_sec);
1273
1274
1275
1276 // Respawn type 2 for players
1277 if (g_iCvar_respawn_type_team_sec == 2)
1278 {
1279 g_iRespawn_lives_team_sec = GetConVarInt(sm_respawn_lives_team_sec);
1280 }
1281 // Respawn type 2 for bots
1282 else if (g_iCvar_respawn_type_team_ins == 2)
1283 {
1284 // Set base value of remaining lives for team insurgent
1285 g_iRespawn_lives_team_ins = -1;
1286 switch (GetTeamSecCount())
1287 {
1288 case 0: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_01);
1289 case 1: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_01);
1290 case 2: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_02);
1291 case 3: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_03);
1292 case 4: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_04);
1293 case 5: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_05);
1294 case 6: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_06);
1295 case 7: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_07);
1296 case 8: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_08);
1297 case 9: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_09);
1298 case 10: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_10);
1299 case 11: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_11);
1300 case 12: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_12);
1301 case 13: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_13);
1302 case 14: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_14);
1303 case 15: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_15);
1304 case 16: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_16);
1305 case 17: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_17);
1306 case 18: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_18);
1307 case 19: g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins_player_count_19);
1308 }
1309
1310 // If not set, use default
1311 if (g_iRespawn_lives_team_ins == -1)
1312 g_iRespawn_lives_team_ins = GetConVarInt(sm_respawn_lives_team_ins);
1313 }
1314
1315 // Counter attack
1316 g_flMinCounterattackDistance = GetConVarFloat(cvarMinCounterattackDistance);
1317 g_flCanSeeVectorMultiplier = GetConVarFloat(cvarCanSeeVectorMultiplier);
1318 g_iCvar_counterattack_type = GetConVarInt(sm_respawn_counterattack_type);
1319 g_iCvar_counterattack_vanilla = GetConVarInt(sm_respawn_counterattack_vanilla);
1320 g_iCvar_final_counterattack_type = GetConVarInt(sm_respawn_final_counterattack_type);
1321 g_flMinPlayerDistance = GetConVarFloat(cvarMinPlayerDistance);
1322 g_flBackSpawnIncrease = GetConVarFloat(cvarBackSpawnIncrease);
1323 g_flMaxPlayerDistance = GetConVarFloat(cvarMaxPlayerDistance);
1324 g_flMinObjectiveDistance = GetConVarFloat(cvarMinObjectiveDistance);
1325 g_flMaxObjectiveDistance = GetConVarFloat(cvarMaxObjectiveDistance);
1326 g_flMaxObjectiveDistanceNav = GetConVarFloat(cvarMaxObjectiveDistanceNav);
1327 g_flSpawnAttackDelay = GetConVarFloat(cvarSpawnAttackDelay);
1328
1329 //if (g_easterEggRound == true)
1330 //{
1331 // g_flMinPlayerDistance = (g_flMinPlayerDistance * 2);
1332 // g_flMaxPlayerDistance = (g_flMaxPlayerDistance * 2);
1333 //}
1334 //Below commented by oz
1335 //Disable on conquer
1336 //if (g_isConquer || g_isOutpost)
1337 // g_iCvar_SpawnMode = 0;
1338
1339 //Hunt specific
1340 //if (g_isHunt == 1)
1341 //{
1342
1343 // new secTeamCount = GetTeamSecCount();
1344 // g_iCvar_SpawnMode = 0;
1345 //Increase reinforcements
1346 // g_iRespawn_lives_team_ins = ((g_iRespawn_lives_team_ins * secTeamCount) / 4);
1347 //}
1348}
1349
1350// When tags changed
1351public TagsChanged(Handle:convar, const String:oldValue[], const String:newValue[])
1352{
1353 if (GetConVarBool(sm_respawn_enabled))
1354 TagsCheck("respawntimes");
1355 else
1356 TagsCheck("respawntimes", true);
1357}
1358
1359// On map starts, call initalizing function
1360public OnMapStart()
1361{
1362 //Supply points based on control points
1363 //int tsupply_base = 2;
1364 //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
1365 //tsupply_base += (ncp * 2);
1366 //new Handle:hSupplyBase = FindConVar("mp_supply_token_base");
1367 //SetConVarInt(hSupplyBase, tsupply_base, true, false);
1368
1369 ServerCommand("exec betterbots.cfg");
1370 //g_easterEggRound = false;
1371 //Clear player array
1372 ClearArray(g_playerArrayList);
1373 //Dynamic Loadouts
1374 g_iCvar_bombers_only = GetConVarInt(sm_bombers_only);
1375 g_iCvar_multi_loadout_enabled = GetConVarInt(sm_multi_loadout_enabled);
1376
1377
1378 //Load Dynamic Loadouts?
1379 //if (g_iCvar_multi_loadout_enabled == 1)
1380 //Dynamic_Loadouts(); - commented out by oz
1381
1382 //Wait until players ready to enable spawn checking
1383 g_playersReady = false;
1384 g_botsReady = 0;
1385 //Lua onmap start
1386 g_iBeaconBeam = PrecacheModel("sprites/laserbeam.vmt");
1387 g_iBeaconHalo = PrecacheModel("sprites/halo01.vmt");
1388
1389 // Destory, Flip sounds
1390 PrecacheSound("soundscape/emitters/oneshot/radio_explode.ogg");
1391 PrecacheSound("ui/sfx/cl_click.wav");
1392 // Deploying sounds
1393 PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup1.ogg");
1394 PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup2.ogg");
1395 PrecacheSound("player/voice/radial/security/leader/unsuppressed/need_backup3.ogg");
1396 PrecacheSound("player/voice/radial/security/leader/unsuppressed/holdposition2.ogg");
1397 PrecacheSound("player/voice/radial/security/leader/unsuppressed/holdposition3.ogg");
1398 PrecacheSound("player/voice/radial/security/leader/unsuppressed/moving2.ogg");
1399 PrecacheSound("player/voice/radial/security/leader/suppressed/backup3.ogg");
1400 PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition1.ogg");
1401 PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition2.ogg");
1402 PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition3.ogg");
1403 PrecacheSound("player/voice/radial/security/leader/suppressed/holdposition4.ogg");
1404 PrecacheSound("player/voice/radial/security/leader/suppressed/moving3.ogg");
1405 PrecacheSound("player/voice/radial/security/leader/suppressed/ontheway1.ogg");
1406 PrecacheSound("player/voice/security/command/leader/located4.ogg");
1407 PrecacheSound("player/voice/security/command/leader/setwaypoint1.ogg");
1408 PrecacheSound("player/voice/security/command/leader/setwaypoint2.ogg");
1409 PrecacheSound("player/voice/security/command/leader/setwaypoint3.ogg");
1410 PrecacheSound("player/voice/security/command/leader/setwaypoint4.ogg");
1411
1412 PrecacheSound("weapons/universal/uni_crawl_l_01.wav");
1413 PrecacheSound("weapons/universal/uni_crawl_l_04.wav");
1414 PrecacheSound("weapons/universal/uni_crawl_l_02.wav");
1415 PrecacheSound("weapons/universal/uni_crawl_r_03.wav");
1416 PrecacheSound("weapons/universal/uni_crawl_r_05.wav");
1417 PrecacheSound("weapons/universal/uni_crawl_r_06.wav");
1418
1419 //Grenade Call Out
1420 PrecacheSound("player/voice/botsurvival/leader/incominggrenade9.ogg");
1421 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade9.ogg");
1422 PrecacheSound("player/voice/botsurvival/leader/incominggrenade4.ogg");
1423 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade4.ogg");
1424 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade35.ogg");
1425 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade34.ogg");
1426 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade33.ogg");
1427 PrecacheSound("player/voice/botsurvival/subordinate/incominggrenade23.ogg");
1428 PrecacheSound("player/voice/botsurvival/leader/incominggrenade2.ogg");
1429 PrecacheSound("player/voice/botsurvival/leader/incominggrenade13.ogg");
1430 PrecacheSound("player/voice/botsurvival/leader/incominggrenade12.ogg");
1431 PrecacheSound("player/voice/botsurvival/leader/incominggrenade11.ogg");
1432 PrecacheSound("player/voice/botsurvival/leader/incominggrenade10.ogg");
1433 PrecacheSound("player/voice/botsurvival/leader/incominggrenade18.ogg");
1434
1435 //Molotov/Incen Callout
1436 PrecacheSound("player/voice/responses/security/subordinate/damage/molotov_incendiary_detonated7.ogg");
1437 PrecacheSound("player/voice/responses/security/leader/damage/molotov_incendiary_detonated6.ogg");
1438 PrecacheSound("player/voice/responses/security/subordinate/damage/molotov_incendiary_detonated6.ogg");
1439 PrecacheSound("player/voice/responses/security/leader/damage/molotov_incendiary_detonated5.ogg");
1440 PrecacheSound("player/voice/responses/security/leader/damage/molotov_incendiary_detonated4.ogg");
1441
1442 //Squad / Team Leader Ambient Radio Sounds
1443 PrecacheSound("soundscape/emitters/oneshot/mil_radio_01.ogg");
1444 PrecacheSound("soundscape/emitters/oneshot/mil_radio_02.ogg");
1445 PrecacheSound("soundscape/emitters/oneshot/mil_radio_03.ogg");
1446 PrecacheSound("soundscape/emitters/oneshot/mil_radio_04.ogg");
1447 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_01.ogg");
1448 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_02.ogg");
1449 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_03.ogg");
1450 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_04.ogg");
1451 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_05.ogg");
1452 PrecacheSound("soundscape/emitters/oneshot/mil_radio_oneshot_06.ogg");
1453
1454 PrecacheSound("sernx_lua_sounds/radio/radio1.ogg");
1455 PrecacheSound("sernx_lua_sounds/radio/radio2.ogg");
1456 PrecacheSound("sernx_lua_sounds/radio/radio3.ogg");
1457 PrecacheSound("sernx_lua_sounds/radio/radio4.ogg");
1458 PrecacheSound("sernx_lua_sounds/radio/radio5.ogg");
1459 PrecacheSound("sernx_lua_sounds/radio/radio6.ogg");
1460 PrecacheSound("sernx_lua_sounds/radio/radio7.ogg");
1461 PrecacheSound("sernx_lua_sounds/radio/radio8.ogg");
1462
1463
1464 // Wait for navmesh
1465 CreateTimer(2.0, Timer_MapStart);
1466 g_preRoundInitial = true;
1467}
1468
1469//Dynamic Loadouts
1470void Dynamic_Loadouts()
1471{
1472 new Float:fRandom = GetRandomFloat(0.0, 1.0);
1473 new Handle:hTheaterOverride = FindConVar("mp_theater_override");
1474 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc", true, false);
1475
1476 //Occurs counter attack
1477 if (fRandom >= 0.0 && fRandom < 0.5)
1478 {
1479 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_isis", true, false);
1480 g_easterEggFlag = false;
1481 }
1482 else if (fRandom >= 0.26 && fRandom < 0.50)
1483 {
1484 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_isis", true, false);
1485 g_easterEggFlag = false;
1486 }
1487 else if (fRandom >= 0.50 && fRandom < 0.74)
1488 {
1489 g_easterEggFlag = false;
1490 //Desert is just diff skins
1491 new Float:fRandom_mil = GetRandomFloat(0.0, 1.0);
1492 if (fRandom >= 0.5)
1493 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_military", true, false);
1494 else
1495 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_military_des", true, false);
1496 }
1497 else if (fRandom >= 0.74 && fRandom < 0.98)
1498 {
1499 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_rebels", true, false);
1500 g_easterEggFlag = false;
1501 }
1502 else if (fRandom >= 0.98)
1503 {
1504 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_bomber", true, false);
1505 g_easterEggFlag = true;
1506 }
1507 //Its a good day to die
1508 if (g_iCvar_bombers_only == 1)
1509 {
1510 SetConVarString(hTheaterOverride, "dy_gnalvl_coop_usmc_bomber", true, false);
1511 g_easterEggFlag = true;
1512 }
1513}
1514
1515public Action:Event_GameEnd(Handle:event, const String:name[], bool:dontBroadcast)
1516{
1517 if (g_easterEggFlag == true)
1518 {
1519 g_easterEggRound = true;
1520 }
1521 else
1522 {
1523 g_easterEggRound = false;
1524 }
1525 g_iRoundStatus = 0;
1526 g_botsReady = 0;
1527 g_iEnableRevive = 0;
1528 g_nVIP_ID = 0;
1529}
1530
1531// Initializing
1532public Action:Timer_MapStart(Handle:Timer)
1533{
1534 // Check is map initialized
1535 if (g_isMapInit == 1)
1536 {
1537 //PrintToServer("[RESPPAWN] Prevented repetitive call");
1538 return;
1539 }
1540 g_isMapInit = 1;
1541
1542
1543 //AI Directory Reset
1544 g_AIDir_ReinforceTimer_Orig = GetConVarInt(FindConVar("sm_respawn_reinforce_time"));
1545 g_AIDir_ReinforceTimer_SubOrig = GetConVarInt(FindConVar("sm_respawn_reinforce_time_subsequent"));
1546
1547
1548 // Bot Reinforce Times
1549 g_iReinforceTime = GetConVarInt(sm_respawn_reinforce_time);
1550 g_iReinforceTimeSubsequent = GetConVarInt(sm_respawn_reinforce_time_subsequent);
1551
1552
1553 g_cqc_map_enabled = GetConVarInt(sm_cqc_map_enabled);
1554
1555
1556 // Update cvars
1557 UpdateRespawnCvars();
1558
1559 g_isConquer = 0;
1560 g_isHunt = 0;
1561 g_isCheckpoint = 0;
1562 g_isOutpost = 0;
1563 // Reset hiding spot
1564 new iEmptyArray[MAX_OBJECTIVES];
1565 g_iCPHidingSpotCount = iEmptyArray;
1566
1567 // Check gamemode
1568 decl String:sGameMode[32];
1569 GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
1570 if (StrEqual(sGameMode,"hunt")) // if Hunt? - commented out by oz
1571 {
1572 g_isHunt = 1;
1573 g_iCvar_SpawnMode = 0;
1574
1575 //Lives given at beginning, change respawn type.
1576 //SetConVarFloat(sm_respawn_fatal_chance, 0.1, true, false);
1577 //SetConVarFloat(sm_respawn_fatal_head_chance, 0.2, true, false);
1578 }
1579 if (StrEqual(sGameMode,"conquer")) // if conquer?
1580 {
1581 g_isConquer = 1;
1582 g_iCvar_SpawnMode = 0;
1583
1584 //Lives given at beginning, change respawn type.
1585 //SetConVarFloat(sm_respawn_fatal_chance, 0.4, true, false);
1586 //SetConVarFloat(sm_respawn_fatal_head_chance, 0.4, true, false);
1587 }
1588 if (StrEqual(sGameMode,"outpost")) // if conquer?
1589 {
1590 g_isOutpost = 1;
1591 g_iCvar_SpawnMode = 0;
1592
1593 //Lives given at beginning, change respawn type.
1594 //SetConVarFloat(sm_respawn_fatal_chance, 0.4, true, false);
1595 //SetConVarFloat(sm_respawn_fatal_head_chance, 0.4, true, false);
1596 }
1597 if (StrEqual(sGameMode,"checkpoint")) // if Hunt?
1598 {
1599 g_isCheckpoint = 1;
1600 }
1601
1602 g_iEnableRevive = 0;
1603 // BotSpawn Nav Mesh initialize #################### END
1604
1605 // Reset respawn token
1606 ResetSecurityLives();
1607 ResetInsurgencyLives();
1608
1609 // Ammo tracking timer
1610 //if (GetConVarInt(sm_respawn_enable_track_ammo) == 1)
1611 //CreateTimer(1.0, Timer_GearMonitor,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1612
1613 // Enemy reinforcement announce timer
1614 if (g_isConquer != 1 && g_isOutpost != 1)
1615 CreateTimer(1.0, Timer_EnemyReinforce,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1616
1617 // Enemy remaining announce timer
1618 if (g_isConquer != 1 && g_isOutpost != 1)
1619 CreateTimer(30, Timer_Enemies_Remaining,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1620
1621 //Enable WAVE BASED SPAWNING
1622 if (g_respawn_mode_team_sec || g_respawn_mode_team_ins)
1623 CreateTimer(1.0, Timer_WaveSpawning,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1624
1625 // Player status check timer
1626 CreateTimer(1.0, Timer_PlayerStatus,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1627
1628 // Revive monitor
1629 CreateTimer(1.0, Timer_ReviveMonitor, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1630
1631 // Heal monitor
1632 CreateTimer(0.5, Timer_MedicMonitor, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1633
1634 // Display nearest body for medics
1635 CreateTimer(0.1, Timer_NearestBody, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1636
1637 // Display nearest body for medics
1638 CreateTimer(60.0, Timer_AmbientRadio, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1639
1640 // Monitor ammo resupply
1641 CreateTimer(1.0, Timer_AmmoResupply, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1642
1643 // AI Director Tick
1644 if (g_isCheckpoint)
1645 CreateTimer(1.0, Timer_AIDirector_Main, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1646
1647 //Vip Check for reward/complete
1648 g_vip_obj_ready = 0;
1649 if (g_vip_enable)
1650 CreateTimer(1.0, Timer_VIPCheck_Main, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1651
1652 // Squad Spawn Notify Leader
1653 //if (GetConVarInt(sm_enable_squad_spawning) == 1)
1654 CreateTimer(1.0, Timer_SquadSpawn_Notify, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1655
1656 // Elite Period
1657 //CreateTimer(1.0, Timer_ElitePeriodTick, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1658
1659 // Static enemy check timer
1660 g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
1661 g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
1662 //Temp testing
1663 g_checkStaticAmtAway = 30;
1664 g_checkStaticAmtCntrAway = 12;
1665 //Elite Bot cvar multipliers (used to minus off top of original cvars)
1666 g_bot_attack_aimtolerance_newthreat_amt_mult = 0.8;
1667 g_bot_attack_aimpenalty_amt_close_mult = 15;
1668 g_bot_attack_aimpenalty_amt_far_mult = 40;
1669 g_bot_attackdelay_frac_difficulty_impossible_mult = 0.03;
1670 g_bot_attack_aimpenalty_time_close_mult = 0.15;
1671 g_bot_attack_aimpenalty_time_far_mult = 2.0;
1672 g_coop_delay_penalty_base = 800;
1673 g_bot_aim_aimtracking_base = 0.05;
1674 g_bot_aim_aimtracking_frac_impossible = 0.05;
1675 g_bot_aim_angularvelocity_frac_impossible = 0.05;
1676 g_bot_aim_angularvelocity_frac_sprinting_target = 0.05;
1677 g_bot_aim_attack_aimtolerance_frac_impossible = 0.05;
1678
1679 //Get Originals
1680 g_ins_bot_count_checkpoint_max_org = GetConVarInt(FindConVar("ins_bot_count_checkpoint_max"));
1681 g_mp_player_resupply_coop_delay_max_org = GetConVarInt(FindConVar("mp_player_resupply_coop_delay_max"));
1682 g_mp_player_resupply_coop_delay_penalty_org = GetConVarInt(FindConVar("mp_player_resupply_coop_delay_penalty"));
1683 g_mp_player_resupply_coop_delay_base_org = GetConVarInt(FindConVar("mp_player_resupply_coop_delay_base"));
1684 g_bot_attack_aimpenalty_amt_close_org = GetConVarInt(FindConVar("bot_attack_aimpenalty_amt_close"));
1685 g_bot_attack_aimpenalty_amt_far_org = GetConVarInt(FindConVar("bot_attack_aimpenalty_amt_far"));
1686 g_bot_attack_aimpenalty_time_close_org = GetConVarFloat(FindConVar("bot_attack_aimpenalty_time_close"));
1687 g_bot_attack_aimpenalty_time_far_org = GetConVarFloat(FindConVar("bot_attack_aimpenalty_time_far"));
1688 g_bot_attack_aimtolerance_newthreat_amt_org = GetConVarFloat(FindConVar("bot_attack_aimtolerance_newthreat_amt"));
1689 g_bot_attackdelay_frac_difficulty_impossible_org = GetConVarFloat(FindConVar("bot_attackdelay_frac_difficulty_impossible"));
1690 g_bot_aim_aimtracking_base_org = GetConVarFloat(FindConVar("bot_aim_aimtracking_base"));
1691 g_bot_aim_aimtracking_frac_impossible_org = GetConVarFloat(FindConVar("bot_aim_aimtracking_frac_impossible"));
1692 g_bot_aim_angularvelocity_frac_impossible_org = GetConVarFloat(FindConVar("bot_aim_angularvelocity_frac_impossible"));
1693 g_bot_aim_angularvelocity_frac_sprinting_target_org = GetConVarFloat(FindConVar("bot_aim_angularvelocity_frac_sprinting_target"));
1694 g_bot_aim_attack_aimtolerance_frac_impossible_org = GetConVarFloat(FindConVar("bot_aim_attack_aimtolerance_frac_impossible"));
1695
1696 CreateTimer(1.0, Timer_CheckEnemyStatic,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1697 if (g_isCheckpoint)
1698 CreateTimer(1.0, Timer_CheckEnemyAway,_ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
1699
1700}
1701
1702public OnMapEnd()
1703{
1704 // Reset variable
1705 //PrintToServer("[REVIVE_DEBUG] MAP ENDED");
1706
1707 // Reset respawn token
1708 ResetSecurityLives();
1709 ResetInsurgencyLives();
1710
1711 g_nVIP_ID = 0;
1712 g_isMapInit = 0;
1713 g_botsReady = 0;
1714 g_iRoundStatus = 0;
1715 g_iEnableRevive = 0;
1716}
1717
1718// Console command for reload config
1719public Action:Command_Reload(client, args)
1720{
1721 ServerCommand("exec sourcemod/respawn.cfg");
1722
1723 //Reset respawn token
1724 ResetSecurityLives();
1725 ResetInsurgencyLives();
1726
1727 //PrintToServer("[RESPAWN] %N reloaded respawn config.", client);
1728 ReplyToCommand(client, "[SM] Reloaded 'sourcemod/respawn.cfg' file.");
1729}
1730
1731// Respawn function for console command
1732public Action:Command_Respawn(client, args)
1733{
1734 // Check argument
1735 if (args < 1)
1736 {
1737 ReplyToCommand(client, "[SM] Usage: sm_player_respawn <#userid|name>");
1738 return Plugin_Handled;
1739 }
1740
1741 // Retrive argument
1742 new String:arg[65];
1743 GetCmdArg(1, arg, sizeof(arg));
1744 new String:target_name[MAX_TARGET_LENGTH];
1745 new target_list[MaxClients], target_count, bool:tn_is_ml;
1746
1747 // Get target count
1748 target_count = ProcessTargetString(
1749 arg,
1750 client,
1751 target_list,
1752 MaxClients,
1753 COMMAND_FILTER_DEAD,
1754 target_name,
1755 sizeof(target_name),
1756 tn_is_ml);
1757
1758 // Check target count
1759 if(target_count <= COMMAND_TARGET_NONE) // If we don't have dead players
1760 {
1761 ReplyToTargetError(client, target_count);
1762 return Plugin_Handled;
1763 }
1764
1765 // Team filter dead players, re-order target_list array with new_target_count
1766 new target, team, new_target_count;
1767
1768 // Check team
1769 for (new i = 0; i < target_count; i++)
1770 {
1771 target = target_list[i];
1772 team = GetClientTeam(target);
1773
1774 if(team >= 2)
1775 {
1776 target_list[new_target_count] = target; // re-order
1777 new_target_count++;
1778 }
1779 }
1780
1781 // Check target count
1782 if(new_target_count == COMMAND_TARGET_NONE) // No dead players from team 2 and 3
1783 {
1784 ReplyToTargetError(client, new_target_count);
1785 return Plugin_Handled;
1786 }
1787 target_count = new_target_count; // re-set new value.
1788
1789 // If target exists
1790 if (tn_is_ml)
1791 ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", target_name);
1792 else
1793 ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", "_s", target_name);
1794
1795 // Process respawn
1796 for (new i = 0; i < target_count; i++)
1797 RespawnPlayer(client, target_list[i]);
1798
1799 return Plugin_Handled;
1800}
1801
1802public Action:Timer_EliteBots(Handle:Timer)
1803{
1804 // Get the number of control points
1805 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
1806
1807 // Get active push point
1808 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
1809 //new counterAlwaysCvar = GetConVarInt(FindConVar("mp_checkpoint_counterattack_always"));
1810 if (Ins_InCounterAttack())
1811 {
1812 //new validAntenna = -1;
1813 //validAntenna = FindValid_Antenna();
1814
1815 if ((acp+1) == ncp)
1816 {
1817 //PrintToServer("ENABLE ELITE FINALE"); // commented by oz
1818 g_isEliteCounter = 1;
1819 //EnableDisableEliteBotCvars(1, 1);
1820 }
1821 else
1822 {
1823 //PrintToServer("ENABLE ELITE NORMAL"); // commented by oz
1824 g_isEliteCounter = 1;
1825 //EnableDisableEliteBotCvars(1, 0);
1826 }
1827 if (g_isEliteCounter == 1)
1828 {
1829 //PrintHintTextToAll("[INTEL]ENEMY FORCES ARE SENDING ELITE UNITS TO COUNTER!");
1830 //PrintToChatAll("[INTEL]ENEMY FORCES ARE SENDING ELITE UNITS TO COUNTER!");
1831 // if (validAntenna != -1 || g_jammerRequired == 0)
1832 // {
1833 // // Announce
1834 // PrintHintTextToAll("[INTEL]ENEMY FORCES ARE SENDING ELITE UNITS TO COUNTER!");
1835 // PrintToChatAll("[INTEL]ENEMY FORCES ARE SENDING ELITE UNITS TO COUNTER!");
1836 // }
1837 // else
1838 // {
1839 // // Announce
1840 // decl String:textToPrintChat[64];
1841 // decl String:textToPrint[64];
1842 // Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
1843 // Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
1844 // PrintHintTextToAll(textToPrint);
1845 // PrintToChatAll(textToPrintChat);
1846 // }
1847 }
1848
1849 }
1850}
1851// Respawn player
1852void RespawnPlayer(client, target)
1853{
1854 new team = GetClientTeam(target);
1855 if(IsClientInGame(target) && !IsClientTimingOut(target) && g_client_last_classstring[target][0] && playerPickSquad[target] == 1 && !IsPlayerAlive(target) && team == TEAM_1_SEC)
1856 {
1857 // Write a log
1858 LogAction(client, target, "\"%L\" respawned \"%L\"", client, target);
1859
1860 // Call forcerespawn fucntion
1861 SDKCall(g_hForceRespawn, target);
1862 }
1863}
1864// ForceRespawnPlayer player
1865void ForceRespawnPlayer(client, target)
1866{
1867 new team = GetClientTeam(target);
1868 if(IsClientInGame(target) && !IsClientTimingOut(target) && g_client_last_classstring[target][0] && playerPickSquad[target] == 1 && team == TEAM_1_SEC)
1869 {
1870 // Write a log
1871 LogAction(client, target, "\"%L\" respawned \"%L\"", client, target);
1872
1873 // Call forcerespawn fucntion
1874 SDKCall(g_hForceRespawn, target);
1875 }
1876}
1877
1878// Wave Based Spawning Timer
1879public Action:Timer_WaveSpawning(Handle:Timer)
1880{
1881 if (g_iRoundStatus == 0) return Plugin_Continue;
1882
1883 if (g_respawn_mode_team_sec)
1884 {
1885 g_secWave_Timer--;
1886
1887 //Announce every X seconds
1888 if (g_secWave_Timer % 30 == 0 ||
1889 g_secWave_Timer == 10 ||
1890 g_secWave_Timer <= 3)
1891 {
1892 decl String:textToPrintChat[64];
1893 //decl String:textToPrint[64]; - commented out by oz
1894 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Team reinforce in %d seconds", g_secWave_Timer);
1895 //Format(textToPrint, sizeof(textToPrint), "[INTEL]Team wave reinforce in %d seconds", g_secWave_Timer);
1896 //PrintHintTextToAll(textToPrint); - commented by oz
1897 //PrintToChatAll(textToPrintChat); - commented by oz
1898 }
1899
1900 //Reset Wave SEC timer and announce respawn
1901 if (g_secWave_Timer <= 0)
1902 {
1903 //PrintHintTextToAll("[INTEL]Team Reinforced!"); - commented by oz
1904 //PrintToChatAll("[INTEL]Team Reinforced!"); - commented by oz
1905
1906 new validAntenna = -1;
1907 validAntenna = FindValid_Antenna();
1908
1909 // Reduce wave timer on valid antenna
1910 if (validAntenna != -1)
1911 {
1912 new timeReduce = (GetTeamSecCount() / 3);
1913 if (timeReduce <= 0)
1914 timeReduce = 3;
1915
1916 new jammerSpawnReductionAmt = (g_iRespawnSeconds / timeReduce);
1917
1918 if ((g_iRespawnSeconds - jammerSpawnReductionAmt) > 0)
1919 g_secWave_Timer = (g_iRespawnSeconds - jammerSpawnReductionAmt);
1920 else
1921 g_secWave_Timer = g_iRespawnSeconds;
1922
1923
1924 if (Ins_InCounterAttack())
1925 g_secWave_Timer += (GetTeamSecCount() * 3);
1926 }
1927 else
1928 {
1929 g_secWave_Timer = g_iRespawnSeconds;
1930 // Get the number of control points
1931 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
1932
1933 // Get active push point
1934 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
1935 // If last capture point
1936 if (g_isCheckpoint == 1 && ((acp+1) == ncp))
1937 {
1938 g_secWave_Timer += (GetTeamSecCount() * 4);
1939 }
1940 else if (Ins_InCounterAttack())
1941 g_secWave_Timer += (GetTeamSecCount() * 3);
1942 }
1943 }
1944 }
1945
1946// Announce enemies remaining
1947public Action:Timer_Enemies_Remaining(Handle:Timer)
1948{
1949 // Check round state
1950 if (g_iRoundStatus == 0) return Plugin_Continue;
1951
1952 // Check enemy count
1953 new alive_insurgents;
1954 for (new i = 1; i <= MaxClients; i++)
1955 {
1956 if (IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i))
1957 {
1958 alive_insurgents++;
1959 }
1960 }
1961 new validAntenna = -1;
1962 validAntenna = FindValid_Antenna();
1963 if (validAntenna != -1 || g_jammerRequired == 0)
1964 {
1965 // Announce
1966 decl String:textToPrintChat[64];
1967 decl String:textToPrint[64];
1968 //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemies alive: %d | Enemy reinforcements left: %d", alive_insurgents, g_iRemaining_lives_team_ins); - commented by oz
1969 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemies alive: %d", alive_insurgents, g_iRemaining_lives_team_ins);
1970 //Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies alive: %d | Enemy reinforcements left: %d", alive_insurgents ,g_iRemaining_lives_team_ins); - commented by oz
1971 //PrintHintTextToAll(textToPrint); - commented by oz
1972 PrintToChatAll(textToPrintChat);
1973
1974 new timeReduce = (GetTeamSecCount() / 3);
1975 if (timeReduce <= 0)
1976 timeReduce = 3;
1977
1978 //new jammerSpawnReductionAmt = (g_iRespawnSeconds / timeReduce); - commented out by oz
1979 //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Jammer Active! | Reinforce time reduced by: %d seconds", jammerSpawnReductionAmt); - commented out by oz
1980 PrintToChatAll(textToPrintChat);
1981
1982 }
1983 else
1984 {
1985 // Announce
1986 decl String:textToPrintChat[64];
1987 decl String:textToPrint[64];
1988 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
1989 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
1990 PrintHintTextToAll(textToPrint);
1991 PrintToChatAll(textToPrintChat);
1992 //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Jammer Inactive! | Reinforce time reduced by: %d seconds", 0); - commented out by oz
1993 PrintToChatAll(textToPrintChat);
1994 }
1995 return Plugin_Continue;
1996}
1997
1998void AI_Director_RandomEnemyReinforce();
1999{
2000 new validAntenna = -1;
2001 validAntenna = FindValid_Antenna();
2002 decl String:textToPrint[64];
2003 decl String:textToPrintChat[64];
2004 //Only add more reinforcements if under certain amount so its not endless.
2005 if (g_iRemaining_lives_team_ins > 0)
2006 {
2007 // if (g_iRemaining_lives_team_ins < (g_iRespawn_lives_team_ins / g_iReinforce_Mult) + g_iReinforce_Mult_Base)
2008 // {
2009 // Get bot count
2010 new minBotCount = (g_iRespawn_lives_team_ins / 5);
2011 g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
2012 Format(textToPrint, sizeof(textToPrint), "[INTEL]Ambush Reinforcements Added to Existing Reinforcements!");
2013 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Ambush Reinforcements Added to Existing Reinforcements!");
2014
2015 //AI Director Reinforcement START
2016 g_AIDir_BotReinforceTriggered = true;
2017 g_AIDir_TeamStatus -= 5;
2018 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
2019
2020 //AI Director Reinforcement END
2021 if (validAntenna != -1 || g_jammerRequired == 0)
2022 {
2023 //PrintHintTextToAll(textToPrint); - commented by oz
2024 PrintToChatAll(textToPrintChat);
2025 }
2026 else
2027 {
2028 new fCommsChance = GetRandomInt(1, 100);
2029 if (fCommsChance > 50)
2030 {
2031 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2032 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2033 PrintHintTextToAll(textToPrint);
2034 PrintToChatAll(textToPrintChat);
2035 }
2036 }
2037 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
2038 //PrintToServer("g_iReinforceTime %d, Ambush Reinforcements added to existing!",g_iReinforceTime); // commented by oz
2039 if (g_isHunt == 1)
2040 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp * g_iReinforce_Mult;
2041 //if (g_huntCacheDestroyed == true && g_isHunt == 1)
2042 // g_iReinforceTime = g_iReinforceTime + g_huntReinforceCacheAdd;
2043
2044 //Lower Bot Flank spawning on reinforcements
2045 g_dynamicSpawn_Perc = 0;
2046
2047 // Add bots
2048 for (new client = 1; client <= MaxClients; client++)
2049 {
2050 if (client > 0 && IsClientInGame(client))
2051 {
2052 new m_iTeam = GetClientTeam(client);
2053 if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
2054 {
2055 g_iRemaining_lives_team_ins++;
2056 CreateBotRespawnTimer(client);
2057 }
2058 }
2059 }
2060
2061 //Reset bot back spawning to default
2062 CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
2063 //}
2064 }
2065 else
2066 {
2067 // Get bot count
2068 new minBotCount = (g_iRespawn_lives_team_ins / 5);
2069 g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
2070
2071 //Lower Bot Flank spawning on reinforcements
2072 g_dynamicSpawn_Perc = 0;
2073
2074 // Add bots
2075 for (new client = 1; client <= MaxClients; client++)
2076 {
2077 if (client > 0 && IsClientInGame(client))
2078 {
2079 new m_iTeam = GetClientTeam(client);
2080 if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
2081 {
2082 g_iRemaining_lives_team_ins++;
2083 CreateBotRespawnTimer(client);
2084 }
2085 }
2086 }
2087 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
2088 //PrintToServer("g_iReinforceTime %d, AMBUSH Reinforcements Arrived Normally!",g_iReinforceTime); // commented by oz
2089
2090
2091 //Reset bot back spawning to default
2092 CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
2093
2094 // Get random duration
2095 //new fRandomInt = GetRandomInt(1, 4);
2096
2097 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemy Ambush Reinforcement Incoming!");
2098 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Enemy Ambush Reinforcement Incoming!");
2099
2100 //AI Director Reinforcement START
2101 g_AIDir_BotReinforceTriggered = true;
2102 g_AIDir_TeamStatus -= 5;
2103 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
2104
2105 //AI Director Reinforcement END
2106
2107 if (validAntenna != -1 || g_jammerRequired == 0)
2108 {
2109 //PrintHintTextToAll(textToPrint); - commented by oz
2110 PrintToChatAll(textToPrintChat);
2111 }
2112 else
2113 {
2114 new fCommsChance = GetRandomInt(1, 100);
2115 if (fCommsChance > 50)
2116 {
2117 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2118 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2119 PrintHintTextToAll(textToPrint);
2120 PrintToChatAll(textToPrintChat);
2121 }
2122 }
2123 }
2124}
2125
2126// This timer reinforces bot team if you do not capture point
2127public Action:Timer_EnemyReinforce(Handle:Timer)
2128{
2129
2130
2131 // Check round state
2132 if (g_iRoundStatus == 0) return Plugin_Continue;
2133
2134 // Check enemy remaining
2135 if (g_iRemaining_lives_team_ins <= (g_iRespawn_lives_team_ins / g_iReinforce_Mult) + g_iReinforce_Mult_Base)
2136 {
2137 g_iReinforceTime--;
2138 new validAntenna = -1;
2139 validAntenna = FindValid_Antenna();
2140 decl String:textToPrintChat[64];
2141 decl String:textToPrint[64];
2142 // Announce every 10 seconds
2143 if (g_iReinforceTime % 10 == 0 && g_iReinforceTime > 10)
2144 {
2145
2146 if (validAntenna != -1 || g_jammerRequired == 0)
2147 {
2148
2149 //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Friendlies spawn on Counter-Attacks, Capture the Point!");
2150 if (g_isHunt == 1)
2151 {
2152 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds | Kill rest/blow cache!", g_iReinforceTime);
2153 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemies reinforce in %d seconds | Kill rest/blow cache!", g_iReinforceTime);
2154 }
2155 else
2156 {
2157 //Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds | Capture point soon!", g_iReinforceTime);
2158 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds", g_iReinforceTime);
2159 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemies reinforce in %d seconds | Capture point soon!", g_iReinforceTime);
2160 }
2161
2162 //PrintHintTextToAll(textToPrint); - commented by oz
2163 if (g_iReinforceTime <= 60)
2164 {
2165 PrintToChatAll(textToPrint);
2166 }
2167 }
2168 else
2169 {
2170 new fCommsChance = GetRandomInt(1, 100);
2171 if (fCommsChance > 50)
2172 {
2173 // Announce
2174 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2175 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2176 PrintHintTextToAll(textToPrint);
2177 PrintToChatAll(textToPrintChat);
2178 }
2179 }
2180 }
2181 // Anncount every 1 second
2182 if (g_iReinforceTime <= 10 && (validAntenna != -1 || g_jammerRequired == 0))
2183 {
2184
2185 //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Friendlies spawn on Counter-Attacks, Capture the Point!");
2186 if (g_isHunt == 1)
2187 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds | Kill remaining/blow cache!", g_iReinforceTime);
2188 else
2189 // Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds | Capture point soon!", g_iReinforceTime);
2190 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies reinforce in %d seconds", g_iReinforceTime);
2191
2192 //PrintHintTextToAll(textToPrint); - commented by oz
2193 PrintToChatAll(textToPrintChat);
2194 }
2195 // Process reinforcement
2196 if (g_iReinforceTime <= 0)
2197 {
2198 // If enemy reinforcement is not over, add it
2199 if (g_iRemaining_lives_team_ins > 0)
2200 {
2201
2202 //Only add more reinforcements if under certain amount so its not endless.
2203 if (g_iRemaining_lives_team_ins < (g_iRespawn_lives_team_ins / g_iReinforce_Mult) + g_iReinforce_Mult_Base)
2204 {
2205 // Get bot count
2206 new minBotCount = (g_iRespawn_lives_team_ins / 4);
2207 g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
2208 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemy Reinforcements Added to Existing Reinforcements!");
2209 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemy Reinforcements Added to Existing Reinforcements!");
2210
2211 //AI Director Reinforcement START
2212 g_AIDir_BotReinforceTriggered = true;
2213 g_AIDir_TeamStatus -= 5;
2214 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
2215
2216 //AI Director Reinforcement END
2217 if (validAntenna != -1 || g_jammerRequired == 0)
2218 {
2219 //PrintHintTextToAll(textToPrint); - commented by oz
2220 PrintToChatAll(textToPrintChat);
2221 }
2222 else
2223 {
2224 new fCommsChance = GetRandomInt(1, 100);
2225 if (fCommsChance > 50)
2226 {
2227 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2228 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2229 PrintHintTextToAll(textToPrint);
2230 PrintToChatAll(textToPrintChat);
2231 }
2232 }
2233 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
2234 //PrintToServer("g_iReinforceTime %d, Reinforcements added to existing!",g_iReinforceTime); // commented by oz
2235 if (g_isHunt == 1)
2236 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp * g_iReinforce_Mult;
2237 //if (g_huntCacheDestroyed == true && g_isHunt == 1)
2238 // g_iReinforceTime = g_iReinforceTime + g_huntReinforceCacheAdd;
2239
2240 //Lower Bot Flank spawning on reinforcements
2241 g_dynamicSpawn_Perc = 0;
2242
2243 // Add bots
2244 for (new client = 1; client <= MaxClients; client++)
2245 {
2246 if (client > 0 && IsClientInGame(client))
2247 {
2248 new m_iTeam = GetClientTeam(client);
2249 if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
2250 {
2251 g_iRemaining_lives_team_ins++;
2252 CreateBotRespawnTimer(client);
2253 }
2254 }
2255 }
2256
2257 //Reset bot back spawning to default
2258 CreateTimer(45, Timer_ResetBotFlankSpawning, _);
2259
2260 }
2261 else
2262 {
2263 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemy Reinforcements at Maximum Capacity");
2264 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemy Reinforcements at Maximum Capacity");
2265 if (validAntenna != -1 || g_jammerRequired == 0)
2266 {
2267 //PrintHintTextToAll(textToPrint); - commented by oz
2268 //PrintToChatAll(textToPrintChat); - commented by oz
2269 }
2270 else
2271 {
2272 new fCommsChance = GetRandomInt(1, 100);
2273 if (fCommsChance > 50)
2274 {
2275 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2276 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2277 PrintHintTextToAll(textToPrint);
2278 PrintToChatAll(textToPrintChat);
2279 }
2280 }
2281 // Reset reinforce time
2282 g_iReinforceTime = g_iReinforceTime_AD_Temp;
2283 //PrintToServer("g_iReinforceTime %d, Reinforcements max capacity!",g_iReinforceTime); // commented by oz
2284 if (g_isHunt == 1)
2285 g_iReinforceTime = g_iReinforceTime_AD_Temp * g_iReinforce_Mult;
2286 //if (g_huntCacheDestroyed == true && g_isHunt == 1)
2287 // g_iReinforceTime = g_iReinforceTime + g_huntReinforceCacheAdd;
2288 }
2289
2290 }
2291 // Respawn enemies
2292 else
2293 {
2294 // Get bot count
2295 new minBotCount = (g_iRespawn_lives_team_ins / 4);
2296 g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
2297
2298 //Lower Bot Flank spawning on reinforcements
2299 g_dynamicSpawn_Perc = 0;
2300
2301 // Add bots
2302 for (new client = 1; client <= MaxClients; client++)
2303 {
2304 if (client > 0 && IsClientInGame(client))
2305 {
2306 new m_iTeam = GetClientTeam(client);
2307 if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
2308 {
2309 g_iRemaining_lives_team_ins++;
2310 CreateBotRespawnTimer(client);
2311 }
2312 }
2313 }
2314 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
2315 //PrintToServer("g_iReinforceTime %d, Reinforcements Arrived Normally!",g_iReinforceTime); // commented by oz
2316
2317
2318 //Reset bot back spawning to default
2319 CreateTimer(45, Timer_ResetBotFlankSpawning, _);
2320
2321 // Get random duration
2322 //new fRandomInt = GetRandomInt(1, 4);
2323
2324 Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemy Reinforcements Have Arrived!");
2325 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemy Reinforcements Have Arrived!");
2326
2327 //AI Director Reinforcement START
2328 g_AIDir_BotReinforceTriggered = true;
2329 g_AIDir_TeamStatus -= 5;
2330 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
2331
2332 //AI Director Reinforcement END
2333
2334 if (validAntenna != -1 || g_jammerRequired == 0)
2335 {
2336 //PrintHintTextToAll(textToPrint); - commented by oz
2337 PrintToChatAll(textToPrintChat);
2338 }
2339 else
2340 {
2341 new fCommsChance = GetRandomInt(1, 100);
2342 if (fCommsChance > 50)
2343 {
2344 Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2345 Format(textToPrint, sizeof(textToPrintChat), "[INTEL]Comms are down, build jammer to get enemy reports.");
2346 PrintHintTextToAll(textToPrint);
2347 PrintToChatAll(textToPrintChat);
2348 }
2349 }
2350 }
2351 }
2352 }
2353
2354 return Plugin_Continue;
2355}
2356
2357//Reset bot flank spawning X seconds after reinforcement
2358public Action:Timer_ResetBotFlankSpawning(Handle:Timer)
2359{
2360 //Reset bot back spawning to default
2361 g_dynamicSpawn_Perc = GetConVarInt(sm_respawn_dynamic_spawn_percent);
2362 return Plugin_Continue;
2363}
2364
2365// Check enemy is stuck
2366public Action:Timer_CheckEnemyStatic(Handle:Timer)
2367{
2368 //Remove bot weapons when static killed to reduce server performance on dropped items.
2369 new primaryRemove = 1, secondaryRemove = 1, grenadesRemove = 1;
2370
2371 // Check round state
2372 if (g_iRoundStatus == 0) return Plugin_Continue;
2373
2374 if (Ins_InCounterAttack())
2375 {
2376 g_checkStaticAmtCntr = g_checkStaticAmtCntr - 1;
2377 if (g_checkStaticAmtCntr <= 0)
2378 {
2379 for (new enemyBot = 1; enemyBot <= MaxClients; enemyBot++)
2380 {
2381 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot))
2382 {
2383 new m_iTeam = GetClientTeam(enemyBot);
2384 if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS)
2385 {
2386 // Get current position
2387 decl Float:enemyPos[3];
2388 GetClientAbsOrigin(enemyBot, Float:enemyPos);
2389
2390 // Get distance
2391 new Float:tDistance;
2392 new Float:capDistance;
2393 tDistance = GetVectorDistance(enemyPos, g_enemyTimerPos[enemyBot]);
2394 if (g_isCheckpoint == 1)
2395 {
2396 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2397 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
2398 capDistance = GetVectorDistance(enemyPos,m_vCPPositions[m_nActivePushPointIndex]);
2399 }
2400 else
2401 capDistance = 801.0;
2402 // If enemy position is static, kill him
2403 if (tDistance <= 150 && Check_NearbyPlayers(enemyBot) && (capDistance > 800 || g_botStaticGlobal[enemyBot] > 120))
2404 {
2405 RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
2406 ForcePlayerSuicide(enemyBot);
2407 AddLifeForStaticKilling(enemyBot);
2408 //PrintToServer("ENEMY STATIC - KILLING"); // commented by oz
2409 g_badSpawnPos_Track[enemyBot] = enemyPos;
2410 //PrintToServer("Add to g_badSpawnPos_Array | enemyPos: (%f, %f, %f) | g_badSpawnPos_Array Size: %d", enemyPos[0],enemyPos[1],enemyPos[2], GetArraySize(g_badSpawnPos_Array));
2411 //PushArrayArray(g_badSpawnPos_Array, enemyPos, sizeof(enemyPos));
2412 }
2413 // Update current position
2414 else
2415 {
2416 g_enemyTimerPos[enemyBot] = enemyPos;
2417 g_botStaticGlobal[enemyBot]++;
2418 }
2419 }
2420 }
2421 }
2422 g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
2423 }
2424 }
2425 else
2426 {
2427 g_checkStaticAmt = g_checkStaticAmt - 1;
2428 if (g_checkStaticAmt <= 0)
2429 {
2430 for (new enemyBot = 1; enemyBot <= MaxClients; enemyBot++)
2431 {
2432 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot))
2433 {
2434 new m_iTeam = GetClientTeam(enemyBot);
2435 if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS)
2436 {
2437 // Get current position
2438 decl Float:enemyPos[3];
2439 GetClientAbsOrigin(enemyBot, Float:enemyPos);
2440
2441 // Get distance
2442 new Float:tDistance;
2443 new Float:capDistance;
2444 tDistance = GetVectorDistance(enemyPos, g_enemyTimerPos[enemyBot]);
2445 //Check point distance
2446 if (g_isCheckpoint == 1)
2447 {
2448 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2449 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
2450 capDistance = GetVectorDistance(enemyPos,m_vCPPositions[m_nActivePushPointIndex]);
2451 }
2452 else
2453 capDistance = 801.0;
2454 // If enemy position is static, kill him
2455 if (tDistance <= 150 && (capDistance > 800) && Check_NearbyPlayers(enemyBot))// || g_botStaticGlobal[enemyBot] > 120))
2456 {
2457 //PrintToServer("ENEMY STATIC - KILLING");
2458 RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
2459 ForcePlayerSuicide(enemyBot);
2460 AddLifeForStaticKilling(enemyBot);
2461 }
2462 // Update current position
2463 else
2464 {
2465 g_enemyTimerPos[enemyBot] = enemyPos;
2466 //g_botStaticGlobal[enemyBot]++;
2467 }
2468 }
2469 }
2470 }
2471 g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
2472 }
2473 }
2474
2475 return Plugin_Continue;
2476}
2477// Check enemy is stuck
2478public Action:Timer_CheckEnemyAway(Handle:Timer)
2479{
2480 //Remove bot weapons when static killed to reduce server performance on dropped items.
2481 new primaryRemove = 1, secondaryRemove = 1, grenadesRemove = 1;
2482 // Check round state
2483 if (g_iRoundStatus == 0) return Plugin_Continue;
2484
2485 if (Ins_InCounterAttack())
2486 {
2487 g_checkStaticAmtCntrAway = g_checkStaticAmtCntrAway - 1;
2488 if (g_checkStaticAmtCntrAway <= 0)
2489 {
2490 for (new enemyBot = 1; enemyBot <= MaxClients; enemyBot++)
2491 {
2492 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot))
2493 {
2494 new m_iTeam = GetClientTeam(enemyBot);
2495 if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS)
2496 {
2497 // Get current position
2498 decl Float:enemyPos[3];
2499 GetClientAbsOrigin(enemyBot, Float:enemyPos);
2500
2501 // Get distance
2502 new Float:tDistance;
2503 new Float:capDistance;
2504 tDistance = GetVectorDistance(enemyPos, g_enemyTimerAwayPos[enemyBot]);
2505 if (g_isCheckpoint == 1)
2506 {
2507 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2508 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
2509 capDistance = GetVectorDistance(enemyPos,m_vCPPositions[m_nActivePushPointIndex]);
2510 }
2511 else
2512 capDistance = 801.0;
2513 // If enemy position is static, kill him
2514 if (tDistance <= 150 && capDistance > 2500)
2515 {
2516 //PrintToServer("ENEMY STATIC - KILLING");
2517 RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
2518 ForcePlayerSuicide(enemyBot);
2519 AddLifeForStaticKilling(enemyBot);
2520 }
2521 // Update current position
2522 else
2523 {
2524 g_enemyTimerAwayPos[enemyBot] = enemyPos;
2525 }
2526 }
2527 }
2528 }
2529 g_checkStaticAmtCntrAway = 12;
2530 }
2531 }
2532 else
2533 {
2534 g_checkStaticAmtAway = g_checkStaticAmtAway - 1;
2535 if (g_checkStaticAmtAway <= 0)
2536 {
2537 for (new enemyBot = 1; enemyBot <= MaxClients; enemyBot++)
2538 {
2539 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot))
2540 {
2541 new m_iTeam = GetClientTeam(enemyBot);
2542 if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS)
2543 {
2544 // Get current position
2545 decl Float:enemyPos[3];
2546 GetClientAbsOrigin(enemyBot, Float:enemyPos);
2547
2548 // Get distance
2549 new Float:tDistance;
2550 new Float:capDistance;
2551 tDistance = GetVectorDistance(enemyPos, g_enemyTimerAwayPos[enemyBot]);
2552 //Check point distance
2553 if (g_isCheckpoint == 1)
2554 {
2555 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2556 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
2557 capDistance = GetVectorDistance(enemyPos,m_vCPPositions[m_nActivePushPointIndex]);
2558 }
2559 // If enemy position is static, kill him
2560 if (tDistance <= 150 && capDistance > 1200)
2561 {
2562 //PrintToServer("ENEMY STATIC - KILLING");
2563 RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
2564 ForcePlayerSuicide(enemyBot);
2565 AddLifeForStaticKilling(enemyBot);
2566 }
2567 // Update current position
2568 else
2569 {
2570 g_enemyTimerAwayPos[enemyBot] = enemyPos;
2571 }
2572 }
2573 }
2574 }
2575 g_checkStaticAmtAway = 30;
2576 }
2577 }
2578
2579 return Plugin_Continue;
2580}
2581void AddLifeForStaticKilling(client)
2582{
2583 // Respawn type 1
2584 new team = GetClientTeam(client);
2585 if (g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS && g_iRespawn_lives_team_ins > 0)
2586 {
2587 g_iSpawnTokens[client]++;
2588 }
2589 else if (g_iCvar_respawn_type_team_ins == 2 && team == TEAM_2_INS && g_iRespawn_lives_team_ins > 0)
2590 {
2591 g_iRemaining_lives_team_ins++;
2592 }
2593}
2594
2595//commented out by oz - sernix specific theater?
2596//void CalculateBotCount()
2597//{
2598 // Respawn type 1
2599// for (new client = 1; client <= MaxClients; client++)
2600// {
2601// new team = GetClientTeam(client);
2602// if (team == TEAM_2_INS && IsFakeClient(client))
2603// {
2604
2605// if (StrContains(g_client_last_classstring[client], "bomber") > -1)
2606// g_maxbots_bomb += 1;
2607// else if (StrContains(g_client_last_classstring[client], "juggernaut") > -1)
2608// g_maxbots_jug += 1;
2609// else if (StrContains(g_client_last_classstring[client], "scout") > -1)
2610// g_maxbots_light += 1;
2611// else
2612// g_maxbots_std += 1;
2613//
2614// }
2615// }
2616//}
2617
2618// Monitor player's gear
2619//public Action:Timer_GearMonitor(Handle:Timer)
2620//{
2621// PrintToChatAll("GEAR MONITOR");
2622// //if (g_iRoundStatus == 0) return Plugin_Continue;
2623// for (new client = 1; client <= MaxClients; client++)
2624// {
2625// if (client > 0 && !IsFakeClient(client))
2626// {
2627// new primaryWeapon = GetPlayerWeaponSlot(client, 0);
2628// new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
2629// new playerGrenades = GetPlayerWeaponSlot(client, 3);
2630
2631// //SetWeaponAmmo(client, primaryWeapon, 3, 0);
2632
2633// //SDKHook(primaryWeapon, SDKHook_ReloadPost, OnWeaponReload);
2634// new bool:isReloading = Client_IsReloading(client);
2635// PrintToChatAll("Reloading: %i", isReloading);
2636// PrintToChatAll("Reloading: %d", isReloading);
2637
2638// if (g_iEnableRevive == 1 && g_iRoundStatus == 1 && g_iCvar_enable_track_ammo == 1)
2639// {
2640// //GetPlayerAmmo(client);
2641// }
2642// }
2643// }
2644// return Plugin_Continue;
2645//}
2646
2647// Update player's gear
2648void SetPlayerAmmo(client)
2649{
2650 if (IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client))
2651 {
2652 //PrintToServer("SETWEAPON ########");
2653 new primaryWeapon = GetPlayerWeaponSlot(client, 0);
2654 new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
2655 new playerGrenades = GetPlayerWeaponSlot(client, 3);
2656 //Lets get weapon classname, we need this to create weapon entity if primary does not fit secondary
2657 //Make sure IsValidEntity is not only for entities
2658 //decl String:weaponClassname[32];
2659 //if (secondaryWeapon != playerSecondary[client] && playerSecondary[client] != -1 && IsValidEntity(playerSecondary[client]))
2660 //{
2661 // GetEdictClassname(playerSecondary[client], weaponClassname, sizeof(weaponClassname));
2662 // RemovePlayerItem(client,secondaryWeapon);
2663 // AcceptEntityInput(secondaryWeapon, "kill");
2664 // GivePlayerItem(client, weaponClassname);
2665 // secondaryWeapon = playerSecondary[client];
2666 //}
2667 //if (primaryWeapon != playerPrimary[client] && playerPrimary[client] != -1 && IsValidEntity(playerPrimary[client]))
2668 //{
2669 // GetEdictClassname(playerPrimary[client], weaponClassname, sizeof(weaponClassname));
2670 // RemovePlayerItem(client,primaryWeapon);
2671 // AcceptEntityInput(primaryWeapon, "kill");
2672 // GivePlayerItem(client, weaponClassname);
2673 // EquipPlayerWeapon(client, playerPrimary[client]);
2674 // primaryWeapon = playerPrimary[client];
2675 //}
2676
2677 //Check primary weapon
2678 if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
2679 {
2680 //PrintToServer("PlayerClip %i, playerAmmo %i, PrimaryWeapon %d",playerClip[client][0],playerAmmo[client][0], primaryWeapon);
2681 SetPrimaryAmmo(client, primaryWeapon, playerClip[client][0], 0); //primary clip
2682 Client_SetWeaponPlayerAmmoEx(client, primaryWeapon, playerAmmo[client][0]); //primary
2683 //PrintToServer("SETWEAPON 1");
2684 }
2685
2686 // Check secondary weapon
2687 if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon))
2688 {
2689 //PrintToServer("PlayerClip %i, playerAmmo %i, PrimaryWeapon %d",playerClip[client][1],playerAmmo[client][1], primaryWeapon);
2690 SetPrimaryAmmo(client, secondaryWeapon, playerClip[client][1], 1); //secondary clip
2691 Client_SetWeaponPlayerAmmoEx(client, secondaryWeapon, playerAmmo[client][1]); //secondary
2692 //PrintToServer("SETWEAPON 2");
2693 }
2694
2695 // Check grenades
2696 if (playerGrenades != -1 && IsValidEntity(playerGrenades)) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
2697 {
2698 while (playerGrenades != -1 && IsValidEntity(playerGrenades)) // since we only have 3 slots in current theate
2699 {
2700 playerGrenades = GetPlayerWeaponSlot(client, 3);
2701 if (playerGrenades != -1 && IsValidEntity(playerGrenades)) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 1
2702 {
2703 // Remove grenades but not pistols
2704 decl String:weapon[32];
2705 GetEntityClassname(playerGrenades, weapon, sizeof(weapon));
2706 RemovePlayerItem(client,playerGrenades);
2707 AcceptEntityInput(playerGrenades, "kill");
2708
2709 }
2710 }
2711
2712 /*
2713 If we need to track grenades (since they drop them on death, its a no)
2714 SetGrenadeAmmo(client, Gren_M67, playerGrenadeType[client][0]);
2715 SetGrenadeAmmo(client, Gren_Incen, playerGrenadeType[client][1]);
2716 SetGrenadeAmmo(client, Gren_Molot, playerGrenadeType[client][2]);
2717 SetGrenadeAmmo(client, Gren_M18, playerGrenadeType[client][3]);
2718 SetGrenadeAmmo(client, Gren_Flash, playerGrenadeType[client][4]);
2719 SetGrenadeAmmo(client, Gren_F1, playerGrenadeType[client][5]);
2720 SetGrenadeAmmo(client, Gren_IED, playerGrenadeType[client][6]);
2721 SetGrenadeAmmo(client, Gren_C4, playerGrenadeType[client][7]);
2722 SetGrenadeAmmo(client, Gren_AT4, playerGrenadeType[client][8]);
2723 SetGrenadeAmmo(client, Gren_RPG7, playerGrenadeType[client][9]);
2724 */
2725 //PrintToServer("SETWEAPON 3");
2726 }
2727 if (!IsFakeClient(client))
2728 playerRevived[client] = false;
2729 }
2730}
2731// Retrive player's gear
2732// commented out by oz - Symbol GetPlayerAmmo never used
2733//void GetPlayerAmmo(client)
2734//{
2735// if (IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client))
2736// {
2737 //CONSIDER IF PLAYER CHOOSES DIFFERENT CLASS
2738// new primaryWeapon = GetPlayerWeaponSlot(client, 0);
2739// new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
2740 //new playerGrenades = GetPlayerWeaponSlot(client, 3);
2741
2742// playerPrimary[client] = primaryWeapon;
2743// playerSecondary[client] = secondaryWeapon;
2744 //Get ammo left in clips for primary and secondary
2745// playerClip[client][0] = GetPrimaryAmmo(client, primaryWeapon, 0);
2746// playerClip[client][1] = GetPrimaryAmmo(client, secondaryWeapon, 1); // m_iClip2 for secondary if this doesnt work? would need GetSecondaryAmmo
2747 //Get Magazines left on player
2748// if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
2749// Client_GetWeaponPlayerAmmoEx(client, primaryWeapon, playerAmmo[client][0], -1); //primary
2750// if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon))
2751// Client_GetWeaponPlayerAmmoEx(client, secondaryWeapon, -1, playerAmmo[client][1]); //secondary
2752
2753 /*
2754 if (playerGrenades != -1 && IsValidEntity(playerGrenades))
2755 {
2756 //PrintToServer("[GEAR] CLIENT HAS VALID GRENADES");
2757 playerGrenadeType[client][0] = GetGrenadeAmmo(client, Gren_M67);
2758 playerGrenadeType[client][1] = GetGrenadeAmmo(client, Gren_Incen);
2759 playerGrenadeType[client][2] = GetGrenadeAmmo(client, Gren_Molot);
2760 playerGrenadeType[client][3] = GetGrenadeAmmo(client, Gren_M18);
2761 playerGrenadeType[client][4] = GetGrenadeAmmo(client, Gren_Flash);
2762 playerGrenadeType[client][5] = GetGrenadeAmmo(client, Gren_F1);
2763 playerGrenadeType[client][6] = GetGrenadeAmmo(client, Gren_IED);
2764 playerGrenadeType[client][7] = GetGrenadeAmmo(client, Gren_C4);
2765 playerGrenadeType[client][8] = GetGrenadeAmmo(client, Gren_AT4);
2766 playerGrenadeType[client][9] = GetGrenadeAmmo(client, Gren_RPG7);
2767 }
2768 */
2769 //PrintToServer("G: %i, G: %i, G: %i, G: %i, G: %i, G: %i, G: %i, G: %i, G: %i, G: %i",playerGrenadeType[client][0], playerGrenadeType[client][1], playerGrenadeType[client][2],playerGrenadeType[client][3],playerGrenadeType[client][4],playerGrenadeType[client][5],playerGrenadeType[client][6],playerGrenadeType[client][7],playerGrenadeType[client][8],playerGrenadeType[client][9]);
2770// }
2771//}
2772
2773public Action:Event_PlayerReload_Pre(Handle:event, const String:name[], bool:dontBroadcast)
2774{
2775 new client = GetClientOfUserId(GetEventInt(event, "userid"));
2776 //new m_iTeam = GetClientTeam(client); - commented by oz
2777
2778 if (IsFakeClient(client) && playerInRevivedState[client] == false) {
2779 return Plugin_Continue;
2780 }
2781
2782 g_playerActiveWeapon[client] = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
2783
2784
2785 // Call respawn timer
2786 if (playerInRevivedState[client])
2787 CreateTimer(0.01, Timer_ForceReload, client, TIMER_REPEAT);
2788}
2789public Action:Event_OnFlashPlayerPre(Handle:event, const String:name[], bool:dontBroadcast)
2790{
2791 new client = GetClientOfUserId(GetEventInt(event, "userid"));
2792
2793 new m_iTeam = GetClientTeam(client);
2794 //Check if player is connected and is alive and player team is security
2795 if((IsClientConnected(client)) && (IsPlayerAlive(client)) && m_iTeam == TEAM_1_SEC)
2796 {
2797 //Get player the 4th gear item which is accessory (3rd offset with a DWORD(4 bytes))
2798 new nAccessoryItemID = GetEntData(client, g_iPlayerEquipGear + (4 * 3));
2799
2800 //If accessory is sunglasses item ID)
2801 if(nAccessoryItemID == g_nSunglasses_ID)
2802 {
2803 //Set player flash alpha (Which is the opacity)
2804 SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.5);
2805 }
2806 }
2807
2808 return Plugin_Continue;
2809}
2810public Action:ResupplyListener(client, const String:cmd[], argc)
2811{
2812 //Get current client team
2813 new m_iTeam = GetClientTeam(client);
2814
2815 //Check if player is connected and is alive and player team is security
2816 if((IsClientConnected(client)) && (IsPlayerAlive(client)) && m_iTeam == TEAM_1_SEC)
2817 {
2818
2819 //Set health 100 percent if resupplying
2820 new iHealth = GetClientHealth(client);
2821 if (iHealth < 100)
2822 {
2823
2824 SetEntityHealth(client, 100);
2825 PrintHintText(client, "Wounds healed via resupply");
2826 }
2827 playerInRevivedState[client] = false;
2828 }
2829
2830
2831 return Plugin_Continue;
2832}
2833
2834/*
2835#####################################################################
2836#####################################################################
2837#####################################################################
2838# Jballous INS_SPAWNPOINT SPAWNING START ############################
2839# Jballous INS_SPAWNPOINT SPAWNING START ############################
2840#####################################################################
2841#####################################################################
2842#####################################################################
2843*/
2844stock GetInsSpawnGround(spawnPoint, Float:vecSpawn[3])
2845{
2846 new Float:fGround[3];
2847 vecSpawn[2] += 15.0;
2848
2849 TR_TraceRayFilter(vecSpawn, Float:{90.0,0.0,0.0}, MASK_PLAYERSOLID, RayType_Infinite, TRDontHitSelf, spawnPoint);
2850 if (TR_DidHit())
2851 {
2852 TR_GetEndPosition(fGround);
2853 return fGround;
2854 }
2855 return vecSpawn;
2856}
2857stock GetClientGround(client)
2858{
2859
2860 new Float:fOrigin[3], Float:fGround[3];
2861 GetClientAbsOrigin(client,fOrigin);
2862
2863 fOrigin[2] += 15.0;
2864
2865 TR_TraceRayFilter(fOrigin, Float:{90.0,0.0,0.0}, MASK_PLAYERSOLID, RayType_Infinite, TRDontHitSelf, client);
2866 if (TR_DidHit())
2867 {
2868 TR_GetEndPosition(fGround);
2869 fOrigin[2] -= 15.0;
2870 return fGround[2];
2871 }
2872 return 0.0;
2873}
2874
2875CheckSpawnPoint(Float:vecSpawn[3],client,Float:tObjectiveDistance,Int:m_nActivePushPointIndex) {
2876//Ins_InCounterAttack
2877 new m_iTeam = GetClientTeam(client);
2878 new Float:distance,Float:furthest,Float:closest=-1.0;
2879 new Float:vecOrigin[3];
2880 //new Float:tBadPos[3]; - commented out by oz
2881
2882 GetClientAbsOrigin(client,vecOrigin);
2883 new Float:tMinPlayerDistMult = 0.0;
2884
2885 new acp = (Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex") - 1);
2886 new acp2 = m_nActivePushPointIndex;
2887 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
2888 if (acp == acp2 && !Ins_InCounterAttack())
2889 {
2890 tMinPlayerDistMult = g_flBackSpawnIncrease;
2891 //PrintToServer("INCREASE SPAWN DISTANCE | acp: %d acp2 %d", acp, acp2);
2892 }
2893
2894 //Update player spawns before we check against them
2895 UpdatePlayerOrigins();
2896 //Lets go through checks to find a valid spawn point
2897 for (new iTarget = 1; iTarget < MaxClients; iTarget++) {
2898 if (!IsValidClient(iTarget))
2899 continue;
2900 if (!IsClientInGame(iTarget))
2901 continue;
2902 if (!IsPlayerAlive(iTarget))
2903 continue;
2904 new tTeam = GetClientTeam(iTarget);
2905 if (tTeam != TEAM_1_SEC)
2906 continue;
2907 ////InsLog(DEBUG, "Distance from %N to iSpot %d is %f",iTarget,iSpot,distance);
2908 distance = GetVectorDistance(vecSpawn,g_vecOrigin[iTarget]);
2909 if (distance > furthest)
2910 furthest = distance;
2911 if ((distance < closest) || (closest < 0))
2912 closest = distance;
2913
2914 if (GetClientTeam(iTarget) != m_iTeam) {
2915 // If we are too close
2916 if (distance < (g_flMinPlayerDistance + tMinPlayerDistMult)) {
2917 return 0;
2918 }
2919 // If the player can see the spawn point (divided CanSeeVector to slightly reduce strictness)
2920 //(IsVectorInSightRange(iTarget, vecSpawn, 120.0)) || / g_flCanSeeVectorMultiplier
2921 if (ClientCanSeeVector(iTarget, vecSpawn, (g_flMinPlayerDistance * g_flCanSeeVectorMultiplier))) {
2922 return 0;
2923 }
2924 //If any player is too far
2925 if (closest > g_flMaxPlayerDistance) {
2926 return 0;
2927 }
2928 else if (closest > 2000 && g_cacheObjActive == 1 && Ins_InCounterAttack())
2929 {
2930 return 0;
2931 }
2932 }
2933 }
2934
2935
2936
2937
2938 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
2939 distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);
2940 if (distance > (tObjectiveDistance) && (((acp+1) != ncp) || !Ins_InCounterAttack())) {// && (fRandomFloat <= g_dynamicSpawn_Perc)) {
2941 return 0;
2942 }
2943 else if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult) && (((acp+1) != ncp) || !Ins_InCounterAttack())) {
2944 return 0;
2945 }
2946
2947 new fRandomInt = GetRandomInt(1, 100);
2948 //If final point respawn around last point, not final point
2949 if ((((acp+1) == ncp) || Ins_InCounterAttack()) && fRandomInt <= 10)
2950 {
2951 new m_nActivePushPointIndexFinal = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2952 m_nActivePushPointIndexFinal -= 1;
2953 distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndexFinal]);
2954 if (distance > (tObjectiveDistance)) {// && (fRandomFloat <= g_dynamicSpawn_Perc)) {
2955 return 0;
2956 }
2957 else if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult)) {
2958 return 0;
2959 }
2960 }
2961 //Check against bad spawn positions
2962 // if (Ins_InCounterAttack())
2963 // {
2964 // for (new client = 0; client < MaxClients; client++) {
2965 // if (!IsValidClient(client) || client <= 0)
2966 // continue;
2967 // if (!IsClientInGame(client))
2968 // continue;
2969 // if (g_badSpawnPos_Track[client][0] == 0 && g_badSpawnPos_Track[client][1] == 0 && g_badSpawnPos_Track[client][2] == 0)
2970 // continue;
2971
2972 // int m_iTeam = GetClientTeam(client);
2973 // if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
2974 // {
2975 // distance = GetVectorDistance(vecSpawn,g_badSpawnPos_Track[client]);
2976
2977 // //GetArrayArray(g_badSpawnPos_Array, badPos, tBadPos, sizeof(tBadPos));
2978
2979 // if (distance <= 240) {
2980 // PrintToServer("BAD POS DETECTED: (%f, %f, %f)", g_badSpawnPos_Track[client][0], g_badSpawnPos_Track[client][1], g_badSpawnPos_Track[client][2]);
2981 // return 0;
2982 // }
2983 // }
2984
2985 // }
2986 // }
2987 //Check distance to point in counterattack
2988 // if (Ins_InCounterAttack() || ((acp+1) == ncp)) {
2989 // new m_nActivePushPointIndex2 = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
2990 // Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex2],m_nActivePushPointIndex2);
2991
2992 // if ((acp+1) != ncp)
2993 // m_nActivePushPointIndex2 += 1;
2994 // else
2995 // m_nActivePushPointIndex2--;
2996
2997 // distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex2]);
2998
2999 // Get the number of control points
3000 // new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3001
3002 // // Get active push point
3003 // new acp3 = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3004 // if (Ins_InCounterAttack() || ((acp3+1) == ncp)) {
3005 // if (distance < g_flMinCounterattackDistance) {
3006 // return 0;
3007 // }
3008 // }
3009 // if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult) || (fRandomFloat <= g_dynamicSpawnCounter_Perc)) {
3010 // return 0;
3011
3012 // }
3013 // else if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult)) {
3014 // return 0;
3015 // }
3016 // }
3017 //PrintToServer("CHECKSPAWN | m_nActivePushPointIndex: %d",m_nActivePushPointIndex); // commented by oz
3018 return 1;
3019}
3020CheckSpawnPointPlayers(Float:vecSpawn[3],client, tObjectiveDistance) {
3021//Ins_InCounterAttack
3022 new m_iTeam = GetClientTeam(client);
3023 new Float:distance,Float:furthest,Float:closest=-1.0;
3024 new Float:vecOrigin[3];
3025 GetClientAbsOrigin(client,vecOrigin);
3026 //Update player spawns before we check against them
3027 UpdatePlayerOrigins();
3028
3029 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3030 new Float:objDistance;
3031
3032 //Lets go through checks to find a valid spawn point
3033 for (new iTarget = 1; iTarget < MaxClients; iTarget++) {
3034 if (!IsValidClient(iTarget))
3035 continue;
3036 if (!IsClientInGame(iTarget))
3037 continue;
3038 if (!IsPlayerAlive(iTarget))
3039 continue;
3040 new tTeam = GetClientTeam(iTarget);
3041 if (tTeam != TEAM_1_SEC)
3042 continue;
3043
3044 m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3045
3046
3047 //If in counter
3048 if (Ins_InCounterAttack() && m_nActivePushPointIndex > 0)
3049 m_nActivePushPointIndex -= 1;
3050
3051
3052 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3053
3054 objDistance = GetVectorDistance(g_vecOrigin[iTarget],m_vCPPositions[m_nActivePushPointIndex]);
3055 distance = GetVectorDistance(vecSpawn,g_vecOrigin[iTarget]);
3056 if (distance > furthest)
3057 furthest = distance;
3058 if ((distance < closest) || (closest < 0))
3059 closest = distance;
3060
3061 if (GetClientTeam(iTarget) != m_iTeam) {
3062 // If we are too close
3063 if (distance < g_flMinPlayerDistance) {
3064 return 0;
3065 }
3066 new fRandomInt = GetRandomInt(1, 100);
3067
3068 // If the player can see the spawn point (divided CanSeeVector to slightly reduce strictness)
3069 //(IsVectorInSightRange(iTarget, vecSpawn, 120.0)) || / g_flCanSeeVectorMultiplier
3070 if (ClientCanSeeVector(iTarget, vecSpawn, (g_flMinPlayerDistance * g_flCanSeeVectorMultiplier))) {
3071 return 0;
3072 }
3073
3074 //Check if players are getting close to point when assaulting
3075 if (objDistance < 2500 && fRandomInt < 30 && !Ins_InCounterAttack())
3076 return 0;
3077 }
3078 }
3079
3080
3081 // Get the number of control points
3082 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3083
3084 // Get active push point
3085 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3086
3087 //If any player is too far
3088 if (closest > g_flMaxPlayerDistance) {
3089 return 0;
3090 }
3091 else if (closest > 2000 && g_cacheObjActive == 1 && Ins_InCounterAttack())
3092 {
3093 return 0;
3094 }
3095
3096 m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3097
3098 new fRandomInt = GetRandomInt(1, 100);
3099 //Check against back spawn if in counter
3100 if (Ins_InCounterAttack() && m_nActivePushPointIndex > 0)
3101 m_nActivePushPointIndex -= 1;
3102
3103 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3104 objDistance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);
3105 if (objDistance > (tObjectiveDistance) && (((acp+1) != ncp) || !Ins_InCounterAttack()) && fRandomInt < 25) {// && (fRandomFloat <= g_dynamicSpawn_Perc)) {
3106 return 0;
3107 }
3108 else if (objDistance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult) &&
3109 (((acp+1) != ncp) || !Ins_InCounterAttack()) && fRandomInt < 25) {
3110 return 0;
3111 }
3112 fRandomInt = GetRandomInt(1, 100);
3113 //If final point respawn around last point, not final point
3114 if ((((acp+1) == ncp) || Ins_InCounterAttack()) && fRandomInt < 25)
3115 {
3116 new m_nActivePushPointIndexFinal = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3117 m_nActivePushPointIndexFinal -= 1;
3118 objDistance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndexFinal]);
3119 if (objDistance > (tObjectiveDistance)) {// && (fRandomFloat <= g_dynamicSpawn_Perc)) {
3120 return 0;
3121 }
3122 else
3123 if (objDistance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult)) {
3124 return 0;
3125 }
3126 }
3127
3128 //Check against bad spawn positions
3129 // if (Ins_InCounterAttack())
3130 // {
3131 // for (new client = 0; client < MaxClients; client++) {
3132 // if (!IsValidClient(client) || client <= 0)
3133 // continue;
3134 // if (!IsClientInGame(client))
3135 // continue;
3136 // if (g_badSpawnPos_Track[client][0] == 0 && g_badSpawnPos_Track[client][1] == 0 && g_badSpawnPos_Track[client][2] == 0)
3137 // continue;
3138
3139 // int m_iTeam = GetClientTeam(client);
3140 // if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
3141 // {
3142 // distance = GetVectorDistance(vecSpawn,g_badSpawnPos_Track[client]);
3143
3144 // //GetArrayArray(g_badSpawnPos_Array, badPos, tBadPos, sizeof(tBadPos));
3145
3146 // if (distance <= 240) {
3147 // PrintToServer("BAD POS DETECTED: (%f, %f, %f)", g_badSpawnPos_Track[client][0], g_badSpawnPos_Track[client][1], g_badSpawnPos_Track[client][2]);
3148 // return 0;
3149 // }
3150 // }
3151
3152 // }
3153 // }
3154
3155
3156 // }
3157 return 1;
3158}
3159
3160public GetPushPointIndex(Float:fRandomFloat, client)
3161{
3162 // Get the number of control points
3163 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3164
3165 // Get active push point
3166 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3167
3168 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3169 //Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3170 //new Float:distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);
3171 //Check last point
3172
3173 if (((acp+1) == ncp && Ins_InCounterAttack()) || g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc || (Ins_InCounterAttack()) || (m_nActivePushPointIndex > 1))
3174 {
3175 //PrintToServer("###POINT_MOD### | fRandomFloat: %f | g_dynamicSpawnCounter_Perc %f ",fRandomFloat, g_dynamicSpawnCounter_Perc);
3176 if ((acp+1) == ncp && Ins_InCounterAttack())
3177 {
3178 if (g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc)
3179 m_nActivePushPointIndex--;
3180 }
3181 else
3182 {
3183 if (Ins_InCounterAttack() && (acp+1) != ncp)
3184 {
3185 if (fRandomFloat <= 0.5 && m_nActivePushPointIndex > 0)
3186 m_nActivePushPointIndex--;
3187 else
3188 m_nActivePushPointIndex++;
3189 }
3190 else if (!Ins_InCounterAttack())
3191 {
3192 if (m_nActivePushPointIndex > 0)
3193 {
3194 if (g_spawnFrandom[client] < g_dynamicSpawn_Perc)
3195 m_nActivePushPointIndex--;
3196 }
3197 }
3198 }
3199
3200 }
3201 return m_nActivePushPointIndex;
3202
3203}
3204
3205float GetSpawnPoint_SpawnPoint(client) {
3206 //int m_iTeam = GetClientTeam(client); - commented out by oz
3207 //int m_iTeamNum; - commented out by oz
3208 float vecSpawn[3];
3209 float vecOrigin[3];
3210 float distance;
3211 GetClientAbsOrigin(client,vecOrigin);
3212 new Float:fRandomFloat = GetRandomFloat(0.0, 1.0);
3213
3214 //PrintToServer("GetSpawnPoint_SpawnPoint Call");
3215 // Get the number of control points
3216 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3217
3218 // Get active push point
3219 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3220
3221 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3222 if (((acp+1) == ncp) || (Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc) || (!Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawn_Perc && acp > 1))
3223 m_nActivePushPointIndex = GetPushPointIndex(fRandomFloat, client);
3224
3225
3226 new point = FindEntityByClassname(-1, "ins_spawnpoint");
3227 new Float:tObjectiveDistance = g_flMinObjectiveDistance;
3228 while (point != -1) {
3229 //m_iTeamNum = GetEntProp(point, Prop_Send, "m_iTeamNum");
3230 //if (m_iTeamNum == m_iTeam) {
3231 GetEntPropVector(point, Prop_Send, "m_vecOrigin", vecSpawn);
3232 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3233 distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);
3234 if (CheckSpawnPoint(vecSpawn,client,tObjectiveDistance,m_nActivePushPointIndex)) {
3235 vecSpawn = GetInsSpawnGround(point, vecSpawn);
3236 //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3237 //PrintToServer("FOUND! m_nActivePushPointIndex: %d %N (%d) spawnpoint %d Distance: %f tObjectiveDistance: %f g_flMinObjectiveDistance %f RAW ACP: %d",m_nActivePushPointIndex, client, client, point, distance, tObjectiveDistance, g_flMinObjectiveDistance, acp); // commented by oz
3238 return vecSpawn;
3239 }
3240 else
3241 {
3242 tObjectiveDistance += 4.0;
3243 }
3244 //}
3245 point = FindEntityByClassname(point, "ins_spawnpoint");
3246 }
3247// PrintToServer("1st Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client); // commented by oz
3248 //Lets try again but wider range
3249 new point2 = FindEntityByClassname(-1, "ins_spawnpoint");
3250 tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 4);
3251 while (point2 != -1) {
3252 //m_iTeamNum = GetEntProp(point2, Prop_Send, "m_iTeamNum");
3253 //if (m_iTeamNum == m_iTeam) {
3254 GetEntPropVector(point2, Prop_Send, "m_vecOrigin", vecSpawn);
3255
3256 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3257 //distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]); - commented out by oz - symbol distance never used
3258 if (CheckSpawnPoint(vecSpawn,client,tObjectiveDistance,m_nActivePushPointIndex)) {
3259 vecSpawn = GetInsSpawnGround(point2, vecSpawn);
3260 //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3261 //PrintToServer("FOUND! m_nActivePushPointIndex: %d %N (%d) spawnpoint %d Distance: %f tObjectiveDistance: %f g_flMinObjectiveDistance %f RAW ACP: %d",m_nActivePushPointIndex, client, client, point2, distance, tObjectiveDistance, g_flMinObjectiveDistance, acp); // commented by oz
3262 return vecSpawn;
3263 }
3264 else
3265 {
3266 tObjectiveDistance += 4.0;
3267 }
3268 //}
3269 point2 = FindEntityByClassname(point2, "ins_spawnpoint");
3270 }
3271 //PrintToServer("2nd Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client); // commented by oz
3272 //Lets try again but wider range
3273 new point3 = FindEntityByClassname(-1, "ins_spawnpoint");
3274 tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 10);
3275 while (point3 != -1) {
3276 //m_iTeamNum = GetEntProp(point3, Prop_Send, "m_iTeamNum");
3277 //if (m_iTeamNum == m_iTeam) {
3278 GetEntPropVector(point3, Prop_Send, "m_vecOrigin", vecSpawn);
3279 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3280 //distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);
3281 if (CheckSpawnPoint(vecSpawn,client,tObjectiveDistance,m_nActivePushPointIndex)) {
3282 vecSpawn = GetInsSpawnGround(point3, vecSpawn);
3283 //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3284 //PrintToServer("FOUND! m_nActivePushPointIndex: %d %N (%d) spawnpoint %d Distance: %f tObjectiveDistance: %f g_flMinObjectiveDistance %f RAW ACP: %d",m_nActivePushPointIndex, client, client, point3, distance, tObjectiveDistance, g_flMinObjectiveDistance, acp); // commented by oz
3285 return vecSpawn;
3286 }
3287 else
3288 {
3289 tObjectiveDistance += 4.0;
3290 }
3291 //}
3292 point3 = FindEntityByClassname(point3, "ins_spawnpoint");
3293 }
3294 //PrintToServer("3rd Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client); // commented by oz
3295 new pointFinal = FindEntityByClassname(-1, "ins_spawnpoint");
3296 tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 4);
3297 m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3298 //m_nActivePushPointIndex = GetPushPointIndex(fRandomFloat);
3299 if (m_nActivePushPointIndex > 1)
3300 {
3301 if ((acp+1) >= ncp)
3302 m_nActivePushPointIndex--;
3303 else
3304 m_nActivePushPointIndex++;
3305
3306 }
3307 while (pointFinal != -1) {
3308 //m_iTeamNum = GetEntProp(pointFinal, Prop_Send, "m_iTeamNum");
3309 //if (m_iTeamNum == m_iTeam) {
3310 GetEntPropVector(pointFinal, Prop_Send, "m_vecOrigin", vecSpawn);
3311
3312 Ins_ObjectiveResource_GetPropVector("m_vCPPositions",m_vCPPositions[m_nActivePushPointIndex],m_nActivePushPointIndex);
3313 //distance = GetVectorDistance(vecSpawn,m_vCPPositions[m_nActivePushPointIndex]);- commented out by oz
3314 if (CheckSpawnPoint(vecSpawn,client,tObjectiveDistance,m_nActivePushPointIndex)) {
3315 vecSpawn = GetInsSpawnGround(pointFinal, vecSpawn);
3316 //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3317 //PrintToServer("FINAL PASS FOUND! m_nActivePushPointIndex: %d %N (%d) spawnpoint %d Distance: %f tObjectiveDistance: %f g_flMinObjectiveDistance: %f RAW ACP: %d",m_nActivePushPointIndex, client, client, pointFinal, distance, tObjectiveDistance, g_flMinObjectiveDistance, acp); // commented by oz
3318 return vecSpawn;
3319 }
3320 else
3321 {
3322 tObjectiveDistance += 4.0;
3323 }
3324 //}
3325 pointFinal = FindEntityByClassname(pointFinal, "ins_spawnpoint");
3326 }
3327 //PrintToServer("Final Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client); // commented by oz
3328 return vecOrigin;
3329}
3330float GetSpawnPoint(client) {
3331 new Float:vecSpawn[3];
3332/*
3333 if ((g_iHidingSpotCount) && (g_iSpawnMode == _:SpawnMode_HidingSpots)) {
3334 vecSpawn = GetSpawnPoint_HidingSpot(client);
3335 } else {
3336*/
3337 vecSpawn = GetSpawnPoint_SpawnPoint(client);
3338// }
3339 //InsLog(DEBUG, "Could not find spawn point for %N (%d)", client, client);
3340 return vecSpawn;
3341}
3342//Lets begin to find a valid spawnpoint after spawned
3343public TeleportClient(client) {
3344 new Float:vecSpawn[3];
3345 vecSpawn = GetSpawnPoint(client);
3346
3347 //decl FLoat:ClientGroundPos;
3348 //ClientGroundPos = GetClientGround(client);
3349 //vecSpawn[2] = ClientGroundPos;
3350 TeleportEntity(client, vecSpawn, NULL_VECTOR, NULL_VECTOR);
3351 SetNextAttack(client);
3352}
3353public Action:Event_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
3354{
3355 //Redirect all bot spawns
3356 new client = GetClientOfUserId(GetEventInt(event, "userid"));
3357 // new String:sNewNickname[64];
3358 // Format(sNewNickname, sizeof(sNewNickname), "%N", client);
3359 // if (StrEqual(sNewNickname, "[INS] RoundEnd Protector"))
3360 // return Plugin_Continue;
3361
3362 if (client > 0 && IsClientInGame(client))
3363 {
3364 if (!IsFakeClient(client))
3365 {
3366 g_iPlayerRespawnTimerActive[client] = 0;
3367
3368 //remove network ragdoll associated with player
3369 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
3370 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
3371 RemoveRagdoll(client);
3372
3373 g_iHurtFatal[client] = 0;
3374
3375 }
3376 }
3377
3378 g_resupplyCounter[client] = GetConVarInt(sm_resupply_delay);
3379 //For first joining players
3380 if (g_playerFirstJoin[client] == 1 && !IsFakeClient(client))
3381 {
3382 g_playerFirstJoin[client] = 0;
3383 // Get SteamID to verify is player has connected before.
3384 decl String:steamId[64];
3385 //GetClientAuthString(client, steamId, sizeof(steamId));
3386 GetClientAuthId(client, AuthId_Steam3, steamId, sizeof(steamId));
3387 new isPlayerNew = FindStringInArray(g_playerArrayList, steamId);
3388
3389 if (isPlayerNew == -1)
3390 {
3391 PushArrayString(g_playerArrayList, steamId);
3392 //PrintToServer("SPAWN: Player %N is new! | SteamID: %s | PlayerArrayList Size: %d", client, steamId, GetArraySize(g_playerArrayList)); // commented by oz
3393 }
3394 }
3395 if (!g_iCvar_respawn_enable) {
3396 return Plugin_Continue;
3397 }
3398 if (!IsClientConnected(client)) {
3399 return Plugin_Continue;
3400 }
3401 if (!IsClientInGame(client)) {
3402 return Plugin_Continue;
3403 }
3404 if (!IsValidClient(client)) {
3405 return Plugin_Continue;
3406 }
3407 if (!IsFakeClient(client)) {
3408 return Plugin_Continue;
3409 }
3410 if (g_isCheckpoint == 0) {
3411 return Plugin_Continue;
3412 }
3413
3414 if ((StrContains(g_client_last_classstring[client], "juggernaut") > -1) && !Ins_InCounterAttack()) {
3415 return Plugin_Handled;
3416 }
3417
3418 //PrintToServer("Eventspawn Call");
3419 //Reset this global timer everytime a bot spawns
3420 g_botStaticGlobal[client] = 0;
3421
3422 // Get the number of control points
3423 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3424
3425 // Get active push point
3426 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3427
3428 new Float:vecOrigin[3];
3429 GetClientAbsOrigin(client,vecOrigin);
3430
3431 if (g_playersReady && g_botsReady == 1)
3432 {
3433 int m_iTeam = GetClientTeam(client);
3434 int m_iTeamNum;
3435 float vecSpawn[3];
3436 float vecOrigin[3];
3437 GetClientAbsOrigin(client,vecOrigin);
3438
3439 new point = FindEntityByClassname(-1, "ins_spawnpoint");
3440 new Float:tObjectiveDistance = g_flMinObjectiveDistance;
3441 int iCanSpawn = CheckSpawnPointPlayers(vecOrigin,client, tObjectiveDistance);
3442 while (point != -1) {
3443 //m_iTeamNum = GetEntProp(point, Prop_Send, "m_iTeamNum");
3444 //if (m_iTeamNum == m_iTeam) {
3445 GetEntPropVector(point, Prop_Send, "m_vecOrigin", vecSpawn);
3446 iCanSpawn = CheckSpawnPointPlayers(vecOrigin,client, tObjectiveDistance);
3447 if (iCanSpawn == 1) {
3448 break;
3449 }
3450 else
3451 {
3452 tObjectiveDistance += 6.0;
3453 }
3454 //}
3455 point = FindEntityByClassname(point, "ins_spawnpoint");
3456 }
3457 //Global random for spawning
3458 g_spawnFrandom[client] = GetRandomInt(0, 100);
3459 //InsLog(DEBUG, "Event_Spawn iCanSpawn %d", iCanSpawn);
3460 if (iCanSpawn == 0 || (Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc) ||
3461 (!Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawn_Perc && acp > 1)) {
3462 //PrintToServer("TeleportClient Call");
3463 TeleportClient(client);
3464 if (client > 0 && IsClientInGame(client) && IsPlayerAlive(client) && IsClientConnected(client))
3465 {
3466 StuckCheck[client] = 0;
3467 StartStuckDetection(client);
3468 }
3469 }
3470 }
3471
3472 return Plugin_Continue;
3473}
3474
3475public Action:Event_SpawnPost(Handle:event, const String:name[], bool:dontBroadcast) {
3476 new client = GetClientOfUserId(GetEventInt(event, "userid"));
3477 ////InsLog(DEBUG, "Event_Spawn called");
3478 // new String:sNewNickname[64];
3479 // Format(sNewNickname, sizeof(sNewNickname), "%N", client);
3480 // if (StrEqual(sNewNickname, "[INS] RoundEnd Protector"))
3481 // return Plugin_Continue;
3482
3483
3484 //Bots only below this
3485 if (!IsFakeClient(client)) {
3486 return Plugin_Continue;
3487 }
3488 SetNextAttack(client);
3489 //new Float:fRandom = GetRandomFloat(0.0, 1.0);
3490 new fRandom = GetRandomInt(1, 100);
3491 //Check grenades
3492 if (fRandom < g_removeBotGrenadeChance && !Ins_InCounterAttack())
3493 {
3494 new botGrenades = GetPlayerWeaponSlot(client, 3);
3495 if (botGrenades != -1 && IsValidEntity(botGrenades)) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
3496 {
3497 while (botGrenades != -1 && IsValidEntity(botGrenades)) // since we only have 3 slots in current theate
3498 {
3499 botGrenades = GetPlayerWeaponSlot(client, 3);
3500 if (botGrenades != -1 && IsValidEntity(botGrenades)) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 1
3501 {
3502 // Remove grenades but not pistols
3503 decl String:weapon[32];
3504 GetEntityClassname(botGrenades, weapon, sizeof(weapon));
3505 RemovePlayerItem(client,botGrenades);
3506 AcceptEntityInput(botGrenades, "kill");
3507 }
3508 }
3509 }
3510 }
3511 if (!g_iCvar_respawn_enable) {
3512 return Plugin_Continue;
3513 }
3514 return Plugin_Continue;
3515}
3516
3517public UpdatePlayerOrigins() {
3518 for (new i = 1; i < MaxClients; i++) {
3519 if (IsValidClient(i)) {
3520 GetClientAbsOrigin(i,g_vecOrigin[i]);
3521 }
3522 }
3523}
3524//This delays bot from attacking once spawned
3525SetNextAttack(client) {
3526 float flTime = GetGameTime();
3527 float flDelay = g_flSpawnAttackDelay;
3528
3529// Loop through entries in m_hMyWeapons.
3530 for(new offset = 0; offset < 128; offset += 4) {
3531 new weapon = GetEntDataEnt2(client, m_hMyWeapons + offset);
3532 if (weapon < 0) {
3533 continue;
3534 }
3535// //InsLog(DEBUG, "SetNextAttack weapon %d", weapon);
3536 SetEntDataFloat(weapon, m_flNextPrimaryAttack, flTime + flDelay);
3537 SetEntDataFloat(weapon, m_flNextSecondaryAttack, flTime + flDelay);
3538 }
3539}
3540/*
3541#####################################################################
3542#####################################################################
3543#####################################################################
3544# Jballous INS_SPAWNPOINT SPAWNING END ##############################
3545# Jballous INS_SPAWNPOINT SPAWNING END ##############################
3546#####################################################################
3547#####################################################################
3548#####################################################################
3549*/
3550
3551
3552/*
3553#####################################################################
3554# NAV MESH BOT SPAWNS FUNCTIONS START ###############################
3555# NAV MESH BOT SPAWNS FUNCTIONS START ###############################
3556#####################################################################
3557*/
3558
3559/*
3560// Check whether current bot position or given hiding point is best position to spawn
3561int CheckHidingSpotRules(m_nActivePushPointIndex, iCPHIndex, iSpot, client)
3562{
3563 // Get Team
3564 new m_iTeam = GetClientTeam(client);
3565
3566 // Init variables
3567 new Float:distance,Float:furthest,Float:closest=-1.0,Float:flHidingSpot[3];
3568 new Float:vecOrigin[3];
3569 new needSpawn = 0;
3570
3571 // Get current position
3572 GetClientAbsOrigin(client,vecOrigin);
3573
3574 // Get current hiding point
3575 flHidingSpot[0] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_X);
3576 flHidingSpot[1] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_Y);
3577 flHidingSpot[2] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_Z);
3578 // new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3579 // distance = GetVectorDistance(flHidingSpot,m_vCPPositions[m_nActivePushPointIndex]);
3580 // if (distance > g_flMaxObjectiveDistanceNav) {
3581 // return 0;
3582 // }
3583 // Check players
3584 for (new iTarget = 1; iTarget < MaxClients; iTarget++)
3585 {
3586 if (!IsClientInGame(iTarget) || !IsClientConnected(iTarget))
3587 continue;
3588
3589 // Get distance from player
3590 distance = GetVectorDistance(flHidingSpot,g_fPlayerPosition[iTarget]);
3591 //PrintToServer("[BOTSPAWNS] Distance from %N to iSpot %d is %f",iTarget,iSpot,distance);
3592
3593 // Check distance from player
3594 if (GetClientTeam(iTarget) != m_iTeam)
3595 {
3596 // If player is furthest, update furthest variable
3597 if (distance > furthest)
3598 furthest = distance;
3599
3600 // If player is closest, update closest variable
3601 if ((distance < closest) || (closest < 0))
3602 closest = distance;
3603 // If any player is close enough to telefrag
3604 // if (distance < g_flMinPlayerDistance) {
3605 // //PrintToServer("DEBUG 1"); return 0;
3606 // }
3607 // If the distance is shorter than cvarMinPlayerDistance
3608 //(IsVectorInSightRange(iTarget, flHidingSpot, 120.0, g_flMinPlayerDistance)) ||
3609 if (((ClientCanSeeVector(iTarget, flHidingSpot, (g_flMaxPlayerDistance)))))
3610 {
3611 //PrintToServer("[BOTSPAWNS] Cannot spawn %N at iSpot %d since it is in sight of %N",client,iSpot,iTarget);
3612 return 0;
3613 }
3614 }
3615 }
3616
3617 // If closest player is further than cvarMaxPlayerDistance
3618 if (closest > g_flMaxPlayerDistance)
3619 {
3620 //PrintToServer("[BOTSPAWNS] iSpot %d is too far from nearest player distance %f",iSpot,closest);
3621 return 0;
3622 }
3623
3624
3625 // During counter attack
3626 // if (Ins_InCounterAttack()) {
3627 // new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3628 // distance = GetVectorDistance(flHidingSpot,m_vCPPositions[m_nActivePushPointIndex]);
3629 // if (distance < g_flMinCounterattackDistance) {
3630 // return 0;
3631 // }
3632
3633 // }
3634
3635 // Current hiding point is the best place
3636 //distance = GetVectorDistance(flHidingSpot,vecOrigin);
3637 //PrintToServer("[BOTSPAWNS] Selected spot for %N, iCPHIndex %d iSpot %d distance %f",client,iCPHIndex,iSpot,distance);
3638 return 1;
3639}
3640
3641// Get best hiding spot
3642int GetBestHidingSpot(client, iteration=0)
3643{
3644 // Refrash players position
3645 UpdatePlayerOrigins();
3646
3647 // Get current push point
3648 new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
3649
3650 // If current push point is not available return -1
3651 if (m_nActivePushPointIndex < 0) return -1;
3652
3653 // Set minimum hiding point index
3654 new minidx = (iteration) ? 0 : g_iCPLastHidingSpot[m_nActivePushPointIndex];
3655
3656 // Set maximum hiding point index
3657 new maxidx = (iteration) ? g_iCPLastHidingSpot[m_nActivePushPointIndex] : g_iCPHidingSpotCount[m_nActivePushPointIndex];
3658
3659 // Loop hiding point index
3660 for (new iCPHIndex = minidx; iCPHIndex < maxidx; iCPHIndex++)
3661 {
3662 // Check given hiding point is best point
3663 new iSpot = g_iCPHidingSpots[m_nActivePushPointIndex][iCPHIndex];
3664 if (CheckHidingSpotRules(m_nActivePushPointIndex,iCPHIndex,iSpot,client))
3665 {
3666 // Update last hiding spot
3667 g_iCPLastHidingSpot[m_nActivePushPointIndex] = iCPHIndex;
3668 return iSpot;
3669 }
3670 }
3671
3672 // If this call is iteration and couldn't find hiding spot, return -1
3673 if (iteration)
3674 return -1;
3675
3676 // If this call is the first try, call again
3677 //return GetBestHidingSpot(client,1);
3678 return -1;
3679}
3680*/
3681
3682/*
3683#####################################################################
3684# NAV MESH BOT SPAWNS FUNCTIONS END #################################
3685# NAV MESH BOT SPAWNS FUNCTIONS END #################################
3686#####################################################################
3687*/
3688
3689// When player connected server, intialize variable
3690public OnClientPutInServer(client)
3691{
3692 g_trackKillDeaths[client] = 0;
3693 playerPickSquad[client] = 0;
3694 g_iHurtFatal[client] = -1;
3695 g_playerFirstJoin[client] = 1;
3696 g_iPlayerRespawnTimerActive[client] = 0;
3697
3698 //SDKHook(client, SDKHook_PreThinkPost, SHook_OnPreThink);
3699 new String:sNickname[64];
3700 Format(sNickname, sizeof(sNickname), "%N", client);
3701 g_client_org_nickname[client] = sNickname;
3702}
3703
3704public OnClientDisconnect(client)
3705{
3706 if(client == g_nVIP_ID)
3707 {
3708 g_nVIP_ID = 0;
3709 }
3710}
3711
3712// When player connected server, intialize variables
3713public Action:Event_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast)
3714{
3715 new client = GetClientOfUserId(GetEventInt(event, "userid"));
3716
3717 playerPickSquad[client] = 0;
3718 g_iHurtFatal[client] = -1;
3719 g_playerFirstJoin[client] = 1;
3720 g_iPlayerRespawnTimerActive[client] = 0;
3721
3722
3723 //g_fPlayerLastChat[client] = GetGameTime();
3724
3725 //Update RespawnCvars when players join
3726 UpdateRespawnCvars();
3727}
3728
3729// When player disconnected server, intialize variables
3730public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
3731{
3732 new client = GetClientOfUserId(GetEventInt(event, "userid"));
3733 if (client > 0)
3734 {
3735 g_squadSpawnEnabled[client] = 0;
3736 playerPickSquad[client] = 0;
3737 // Reset player status
3738 g_client_last_classstring[client] = ""; //reset his class model
3739 // Remove network ragdoll associated with player
3740 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
3741 if (playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
3742 RemoveRagdoll(client);
3743
3744 // Update cvar
3745 UpdateRespawnCvars();
3746 }
3747
3748
3749 g_LastButtons[client] = 0;
3750
3751 return Plugin_Continue;
3752}
3753
3754// When round starts, intialize variables
3755public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
3756{
3757
3758 //Reset VIP objective count
3759 g_vip_obj_count = g_iCvar_vip_obj_time;
3760 g_vip_obj_ready = 1;
3761
3762 int tsupply_base = 2;
3763 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
3764 tsupply_base += (ncp * 2);
3765 //new Handle:hSupplyBase = FindConVar("mp_supply_token_base"); - commented out by oz
3766 //SetConVarInt(hSupplyBase, tsupply_base, true, false); - commented out by oz
3767 //Clear bad spawn array
3768 //ClearArray(g_badSpawnPos_Array);
3769
3770 //Round_Start CVAR Sets ------------------ START -- vs using HookConVarChange
3771
3772 //Show scoreboard when dead DISABLED
3773 //new cvar_scoreboard = FindConVar("sv_hud_scoreboard_show_score_dead"); - commented out by oz
3774 //SetConVarInt(cvar_scoreboard, 0, true, false); - commented out by oz
3775
3776
3777 // Respawn delay for team ins
3778 g_fCvar_respawn_delay_team_ins = GetConVarFloat(sm_respawn_delay_team_ins);
3779 g_fCvar_respawn_delay_team_ins_spec = GetConVarFloat(sm_respawn_delay_team_ins_special);
3780
3781 g_AIDir_TeamStatus = 50;
3782 g_AIDir_BotReinforceTriggered = false;
3783
3784 g_iReinforceTime = GetConVarInt(sm_respawn_reinforce_time);
3785
3786 g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
3787 g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
3788
3789 g_secWave_Timer = g_iRespawnSeconds;
3790 //Round_Start CVAR Sets ------------------ END -- vs using HookConVarChange
3791
3792
3793
3794 //Elite Bots Reset
3795 if (g_elite_counter_attacks == 1)
3796 {
3797 g_isEliteCounter = 0;
3798 EnableDisableEliteBotCvars(0, 0);
3799 }
3800
3801 // Reset respawn position
3802 g_fRespawnPosition[0] = 0.0;
3803 g_fRespawnPosition[1] = 0.0;
3804 g_fRespawnPosition[2] = 0.0;
3805
3806 // Reset remaining life
3807 new Handle:hCvar = INVALID_HANDLE;
3808 hCvar = FindConVar("sm_remaininglife");
3809 SetConVarInt(hCvar, -1);
3810
3811 // Reset respawn token
3812 ResetInsurgencyLives();
3813 ResetSecurityLives();
3814
3815 //Hunt specific
3816 if (g_isHunt == 1)
3817 {
3818 g_iReinforceTime = (g_iReinforceTime * g_iReinforce_Mult) + g_iReinforce_Mult_Base;
3819 }
3820
3821 // Check gamemode
3822 decl String:sGameMode[32];
3823 GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
3824 //PrintToServer("[REVIVE_DEBUG] ROUND STARTED");
3825
3826 // Warming up revive
3827 g_iEnableRevive = 0;
3828 new iPreRoundFirst = GetConVarInt(FindConVar("mp_timer_preround_first"));
3829 new iPreRound = GetConVarInt(FindConVar("mp_timer_preround"));
3830 if (g_preRoundInitial == true)
3831 {
3832 CreateTimer(float(iPreRoundFirst), PreReviveTimer);
3833 iPreRoundFirst = iPreRoundFirst + 5;
3834 CreateTimer(float(iPreRoundFirst), BotsReady_Timer);
3835 g_preRoundInitial = false;
3836 }
3837 else
3838 {
3839 CreateTimer(float(iPreRound), PreReviveTimer);
3840 iPreRoundFirst = iPreRound + 5;
3841 CreateTimer(float(iPreRound), BotsReady_Timer);
3842 }
3843
3844 if (g_easterEggRound == true)
3845 {
3846 PrintToChatAll("************EASTER EGG ROUND************");
3847 PrintToChatAll("******NO WHINING, BE NICE, HAVE FUN*****");
3848 PrintToChatAll("******MAX ROUNDS CHANGED TO 2!**********");
3849 PrintToChatAll("******WORK TOGETHER, ADAPT!*************");
3850 PrintToChatAll("************EASTER EGG ROUND************");
3851 }
3852 return Plugin_Continue;
3853}
3854
3855void SecTeamLivesBonus()
3856{
3857 new secTeamCount = GetTeamSecCount();
3858 if (secTeamCount <= 9)
3859 {
3860 g_iRespawnCount[2] += 1;
3861 }
3862 //else if (secTeamCount >= 10 && secTeamCount <= 14)
3863 //{
3864 // g_iRespawnCount[2] += 1;
3865 //}
3866}
3867
3868//Adjust Lives Per Point Based On Players
3869void SecDynLivesPerPoint()
3870{
3871 new secTeamCount = GetTeamSecCount();
3872 if (secTeamCount <= 9)
3873 {
3874 g_iRespawnCount[2] += 1;
3875 }
3876}
3877
3878// Round starts
3879public Action:PreReviveTimer(Handle:Timer)
3880{
3881 //h_PreReviveTimer = INVALID_HANDLE;
3882 //PrintToServer("ROUND STATUS AND REVIVE ENABLED********************");
3883 g_iRoundStatus = 1;
3884 g_iEnableRevive = 1;
3885
3886 // Update remaining life cvar
3887 new Handle:hCvar = INVALID_HANDLE;
3888 new iRemainingLife = GetRemainingLife();
3889 hCvar = FindConVar("sm_remaininglife");
3890 SetConVarInt(hCvar, iRemainingLife);
3891}
3892// Botspawn trigger
3893public Action:BotsReady_Timer(Handle:Timer)
3894{
3895 //h_PreReviveTimer = INVALID_HANDLE;
3896 //PrintToServer("ROUND STATUS AND REVIVE ENABLED********************");
3897 g_botsReady = 1;
3898}
3899// When round ends, intialize variables
3900public Action:Event_RoundEnd_Pre(Handle:event, const String:name[], bool:dontBroadcast)
3901{
3902 //Reset VIP objective count
3903 g_vip_obj_count = g_iCvar_vip_obj_time;
3904 g_vip_obj_ready = 1;
3905
3906 //Show scoreboard when dead ENABLED
3907 new cvar_scoreboard = FindConVar("sv_hud_scoreboard_show_score_dead");
3908 SetConVarInt(cvar_scoreboard, 1, true, false);
3909
3910
3911 for (new client = 1; client <= MaxClients; client++)
3912 {
3913 if (!IsValidClient(client))
3914 continue;
3915 if (!IsClientInGame(client))
3916 continue;
3917 if (IsFakeClient(client))
3918 continue;
3919 new tTeam = GetClientTeam(client);
3920 if (tTeam != TEAM_1_SEC)
3921 continue;
3922 if ((g_iStatRevives[client] > 0 || g_iStatHeals[client] > 0) && StrContains(g_client_last_classstring[client], "medic") > -1)
3923 {
3924 decl String:sBuf[255];
3925 // Hint to iMedic
3926 Format(sBuf, 255,"[MEDIC STATS] for %N: HEALS: %d | REVIVES: %d", client, g_iStatHeals[client], g_iStatRevives[client]);
3927 PrintHintText(client, "%s", sBuf);
3928 PrintToChatAll("%s", sBuf);
3929 }
3930
3931 playerInRevivedState[client] = false;
3932 }
3933 // Stop counter-attack music
3934 //StopCounterAttackMusic();
3935
3936 //Reset Variables
3937 g_removeBotGrenadeChance = 50;
3938}
3939
3940// When round ends, intialize variables
3941public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
3942{
3943 // Set client command for round end music
3944 // int iWinner = GetEventInt(event, "winner");
3945 // decl String:sMusicCommand[128];
3946 // if (iWinner == TEAM_1_SEC)
3947 // Format(sMusicCommand, sizeof(sMusicCommand), "playgamesound Music.WonGame_Security");
3948 // else
3949 // Format(sMusicCommand, sizeof(sMusicCommand), "playgamesound Music.LostGame_Insurgents");
3950
3951 // // Play round end music
3952 // for (int i = 1; i <= MaxClients; i++)
3953 // {
3954 // if (IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i))
3955 // {
3956 // ClientCommand(i, "%s", sMusicCommand);
3957 // }
3958 // }
3959 //Elite Bots Reset
3960 if (g_elite_counter_attacks == 1)
3961 {
3962 g_isEliteCounter = 0;
3963 EnableDisableEliteBotCvars(0, 0);
3964 }
3965
3966 // Reset respawn position
3967 g_fRespawnPosition[0] = 0.0;
3968 g_fRespawnPosition[1] = 0.0;
3969 g_fRespawnPosition[2] = 0.0;
3970
3971 // Reset remaining life
3972 new Handle:hCvar = INVALID_HANDLE;
3973 hCvar = FindConVar("sm_remaininglife");
3974 SetConVarInt(hCvar, -1);
3975
3976 //PrintToServer("[REVIVE_DEBUG] ROUND ENDED");
3977 // Cooldown revive
3978 g_iEnableRevive = 0;
3979 g_iRoundStatus = 0;
3980 g_botsReady = 0;
3981
3982 // Reset respawn token
3983 ResetInsurgencyLives();
3984 ResetSecurityLives();
3985
3986 //Reset new spawn system bot count
3987 //commented out by oz - strings not used
3988 //g_maxbots_std = 0;
3989 //g_maxbots_light = 0;
3990 //g_maxbots_jug = 0;
3991 //g_maxbots_bomb = 0;
3992
3993 //g_bots_std = 0; - commented by oz
3994 //g_bots_light = 0; - commented by oz
3995 //g_bots_jug = 0; - commented by oz
3996 //g_bots_bomb = 0; - commented by oz
3997 ////////////////////////
3998 // Rank System
3999 // if (g_hDB != INVALID_HANDLE)
4000 // {
4001 // for (new client=1; client<=MaxClients; client++)
4002 // {
4003 // if (IsClientInGame(client))
4004 // {
4005 // saveUser(client);
4006 // CreateTimer(0.5, Timer_GetMyRank, client);
4007 // }
4008 // }
4009 // }
4010 ////////////////////////
4011
4012 //Lua Healing kill sound
4013 new ent = -1;
4014 while ((ent = FindEntityByClassname(ent, "healthkit")) > MaxClients && IsValidEntity(ent))
4015 {
4016 //StopSound(ent, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
4017 //PrintToServer("KILL HEALTHKITS"); // commented by oz
4018 AcceptEntityInput(ent, "Kill");
4019 }
4020
4021}
4022
4023// Check occouring counter attack when control point captured
4024public Action:Event_ControlPointCaptured_Pre(Handle:event, const String:name[], bool:dontBroadcast)
4025{
4026 //Clear bad spawn array
4027 //ClearArray(g_badSpawnPos_Array);
4028 for (new client = 0; client < MaxClients; client++) {
4029 if (!IsValidClient(client) || client <= 0)
4030 continue;
4031 if (!IsClientInGame(client))
4032 continue;
4033 int m_iTeam = GetClientTeam(client);
4034 if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
4035 {
4036 g_badSpawnPos_Track[client][0] = 0.0;
4037 g_badSpawnPos_Track[client][1] = 0.0;
4038 g_badSpawnPos_Track[client][2] = 0.0;
4039 }
4040 }
4041
4042 g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
4043 g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
4044 // Return if conquer
4045 if (g_isConquer == 1 || g_isHunt == 1 || g_isOutpost) return Plugin_Continue;
4046
4047
4048 // Get the number of control points
4049 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
4050
4051 // Get active push point
4052 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
4053
4054 //AI Director Status ###START###
4055 new secTeamCount = GetTeamSecCount();
4056 new secTeamAliveCount = Team_CountAlivePlayers(TEAM_1_SEC);
4057
4058 if (g_iRespawn_lives_team_ins > 0)
4059 g_AIDir_TeamStatus += 10;
4060
4061 if (secTeamAliveCount >= (secTeamCount * 0.8)) // If Alive Security >= 80%
4062 g_AIDir_TeamStatus += 10;
4063 else if (secTeamAliveCount >= (secTeamCount * 0.5)) // If Alive Security >= 50%
4064 g_AIDir_TeamStatus += 5;
4065 else if (secTeamAliveCount <= (secTeamCount * 0.2)) // If Dead Security <= 20%
4066 g_AIDir_TeamStatus -= 10;
4067 else if (secTeamAliveCount <= (secTeamCount * 0.5)) // If Dead Security <= 50%
4068 g_AIDir_TeamStatus -= 5;
4069
4070 if (g_AIDir_BotReinforceTriggered)
4071 g_AIDir_TeamStatus -= 5;
4072 else
4073 g_AIDir_TeamStatus += 10;
4074
4075 g_AIDir_BotReinforceTriggered = false;
4076 //AI Director Status ###END###
4077
4078
4079 // Get gamemode
4080 decl String:sGameMode[32];
4081 GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
4082
4083 // Init variables
4084 new Handle:cvar;
4085
4086 // Set minimum and maximum counter attack duration tim
4087 g_counterAttack_min_dur_sec = GetConVarInt(sm_respawn_min_counter_dur_sec);
4088 g_counterAttack_max_dur_sec = GetConVarInt(sm_respawn_max_counter_dur_sec);
4089 new final_ca_dur = GetConVarInt(sm_respawn_final_counter_dur_sec);
4090
4091 // Get random duration
4092 new fRandomInt = GetRandomInt(g_counterAttack_min_dur_sec, g_counterAttack_max_dur_sec);
4093 new fRandomIntCounterLarge = GetRandomInt(1, 100);
4094 new largeCounterEnabled = false;
4095 if (fRandomIntCounterLarge <= 15)
4096 {
4097 fRandomInt = (fRandomInt * 2);
4098 new fRandomInt2 = GetRandomInt(60, 90);
4099 final_ca_dur = (final_ca_dur + fRandomInt2);
4100 largeCounterEnabled = true;
4101
4102 }
4103 // Set counter attack duration to server
4104 new Handle:cvar_ca_dur;
4105
4106
4107
4108 // Final counter attack
4109 if ((acp+1) == ncp)
4110 {
4111 g_iRemaining_lives_team_ins = 0;
4112 for (int i = 1; i <= MaxClients; i++)
4113 {
4114 if (i > 0 && IsClientInGame(i) && IsClientConnected(i))
4115 {
4116 if(IsFakeClient(i))
4117 ForcePlayerSuicide(i);
4118 }
4119 }
4120
4121 //g_AIDir_TeamStatus -= 10;
4122
4123 cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration_finale");
4124 SetConVarInt(cvar_ca_dur, final_ca_dur, true, false);
4125 g_dynamicSpawnCounter_Perc += 10;
4126
4127 if (g_finale_counter_spec_enabled == 1)
4128 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
4129
4130 //If endless spawning on final counter attack, add lives on finale counter on a delay
4131 if (g_iCvar_final_counterattack_type == 2)
4132 {
4133 new tCvar_CounterDelayValue = GetConVarInt(FindConVar("mp_checkpoint_counterattack_delay_finale"));
4134 CreateTimer((tCvar_CounterDelayValue), Timer_FinaleCounterAssignLives, _);
4135 }
4136 }
4137 // Normal counter attack
4138 else
4139 {
4140 g_AIDir_TeamStatus -= 5;
4141
4142 cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration");
4143 SetConVarInt(cvar_ca_dur, fRandomInt, true, false);
4144 }
4145
4146
4147 // Get ramdom value for occuring counter attack
4148 new Float:fRandom = GetRandomFloat(0.0, 1.0);
4149 //PrintToServer("Counter Chance = %f", g_respawn_counter_chance); // commented by oz
4150 // Occurs counter attack
4151 if (fRandom < g_respawn_counter_chance && g_isCheckpoint == 1 && ((acp+1) != ncp))
4152 {
4153 cvar = INVALID_HANDLE;
4154 //PrintToServer("COUNTER YES");
4155 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4156 SetConVarInt(cvar, 0, true, false);
4157 cvar = FindConVar("mp_checkpoint_counterattack_always");
4158 SetConVarInt(cvar, 1, true, false);
4159 if (largeCounterEnabled)
4160 {
4161 PrintHintTextToAll("[INTEL]: Enemy forces are sending a large counter-attack your way! Get ready to defend!");
4162 //PrintToChatAll("[INTEL]: Enemy forces are sending a large counter-attack your way! Get ready to defend!"); - commented out by oz
4163 }
4164
4165
4166 g_AIDir_TeamStatus -= 5;
4167 // Call music timer
4168 //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
4169
4170 //Create Counter End Timer
4171 g_isEliteCounter = 1;
4172 CreateTimer((cvar_ca_dur + 1), Timer_CounterAttackEnd, _);
4173
4174 if (g_elite_counter_attacks == 1)
4175 {
4176 EnableDisableEliteBotCvars(1, 0);
4177 new tCvar = FindConVar("ins_bot_count_checkpoint_max");
4178 new tCvarIntValue = GetConVarInt(FindConVar("ins_bot_count_checkpoint_max"));
4179 tCvarIntValue += 3;
4180 SetConVarInt(tCvar, tCvarIntValue, true, false);
4181 }
4182 }
4183 // If last capture point
4184 else if (g_isCheckpoint == 1 && ((acp+1) == ncp))
4185 {
4186 cvar = INVALID_HANDLE;
4187 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4188 SetConVarInt(cvar, 0, true, false);
4189 cvar = FindConVar("mp_checkpoint_counterattack_always");
4190 SetConVarInt(cvar, 1, true, false);
4191
4192 // Call music timer
4193 //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
4194
4195 //Create Counter End Timer
4196 g_isEliteCounter = 1;
4197 CreateTimer((cvar_ca_dur + 1), Timer_CounterAttackEnd, _);
4198
4199 if (g_elite_counter_attacks == 1)
4200 {
4201 EnableDisableEliteBotCvars(1, 1);
4202 new tCvar = FindConVar("ins_bot_count_checkpoint_max");
4203 new tCvarIntValue = GetConVarInt(FindConVar("ins_bot_count_checkpoint_max"));
4204 tCvarIntValue += 3;
4205 SetConVarInt(tCvar, tCvarIntValue, true, false);
4206 }
4207 }
4208 // Not occurs counter attack
4209 else
4210 {
4211 cvar = INVALID_HANDLE;
4212 //PrintToServer("COUNTER NO");
4213 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4214 SetConVarInt(cvar, 1, true, false);
4215 }
4216
4217 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
4218
4219 return Plugin_Continue;
4220}
4221
4222// Play music during counter-attack
4223public Action:Timer_CounterAttackSound(Handle:event)
4224{
4225 if (g_iRoundStatus == 0 || !Ins_InCounterAttack())
4226 return;
4227
4228 // Play music
4229 for (int i = 1; i <= MaxClients; i++)
4230 {
4231 if (IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i))
4232 {
4233 //ClientCommand(i, "playgamesound Music.StartCounterAttack");
4234 //ClientCommand(i, "play *cues/INS_GameMusic_AboutToAttack_A.ogg");
4235 }
4236 }
4237
4238 // Loop
4239 //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
4240}
4241
4242// When control point captured, reset variables
4243public Action:Event_ControlPointCaptured(Handle:event, const String:name[], bool:dontBroadcast)
4244{
4245 // Return if conquer
4246 if (g_isConquer == 1 || g_isHunt == 1 || g_isOutpost == 1) return Plugin_Continue;
4247
4248 g_cacheObjActive = 0;
4249 // If VIP capped, reward team with supply points
4250 decl String:cappers[512];
4251 GetEventString(event, "cappers", cappers, sizeof(cappers));
4252 new cappersLength = strlen(cappers);
4253 if (g_vip_enable)
4254 {
4255 for (new i = 0 ; i < cappersLength; i++)
4256 {
4257 new clientCapper = cappers[i];
4258 if(clientCapper > 0 && IsClientInGame(clientCapper) && IsClientConnected(clientCapper) &&
4259 IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper) &&
4260 (StrContains(g_client_last_classstring[clientCapper], "vip") > -1) && g_vip_obj_count > 0)
4261 {
4262 //Reward team with tokens (credits to INS server)
4263 ConVar cvar_tokenmax = FindConVar("mp_supply_token_max");
4264 new nMaxSupply = GetConVarInt(cvar_tokenmax);
4265 //Determine reward
4266 new nRandSupplyReward = GetRandomInt(g_iCvar_vip_min_sp_reward, g_iCvar_vip_max_sp_reward);
4267
4268 for(new client = 1; client <= MaxClients; client++)
4269 {
4270 //new nCurrentPlayerTeam = GetClientTeam(client);
4271 if((IsValidClient(client)) && (IsClientConnected(client)) && (!IsFakeClient(client)))
4272 {
4273 int nSupplyPoint = GetEntProp(client, Prop_Send, "m_nRecievedTokens");
4274 int nAvailableSupplyPoint = GetEntProp(client, Prop_Send, "m_nAvailableTokens");
4275
4276 if(nSupplyPoint <= nMaxSupply)
4277 {
4278
4279 nSupplyPoint += nRandSupplyReward;
4280 nAvailableSupplyPoint += nRandSupplyReward;
4281 //PrintToChat(client, "VIP has captured point\nYou have received %i supply point(s) as reward", nRandSupplyReward); - commented out by oz
4282 }
4283
4284 //Set client nSupplyPoint
4285 SetEntProp(client, Prop_Send, "m_nRecievedTokens",nSupplyPoint);
4286 SetEntProp(client, Prop_Send, "m_nAvailableTokens", nAvailableSupplyPoint);
4287 }
4288 }
4289
4290 break;
4291 }
4292 }
4293 }
4294 // Reset reinforcement time
4295 g_iReinforceTime = g_iReinforceTime_AD_Temp;
4296
4297 // Reset respawn tokens
4298 ResetInsurgencyLives();
4299 if (g_iCvar_respawn_reset_type && g_isCheckpoint)
4300 ResetSecurityLives();
4301
4302 //PrintToServer("CONTROL POINT CAPTURED");
4303
4304 return Plugin_Continue;
4305}
4306
4307// When control point captured, update respawn point and respawn all players
4308public Action:Event_ControlPointCaptured_Post(Handle:event, const String:name[], bool:dontBroadcast)
4309{
4310 // Return if conquer
4311 if (g_isConquer == 1 || g_isHunt == 1 || g_isOutpost == 1) return Plugin_Continue;
4312
4313 if (GetConVarInt(sm_respawn_security_on_counter) == 1) //Test with Ins_InCounterAttack() later
4314 {
4315 // Get client who captured control point.
4316 decl String:cappers[512];
4317 GetEventString(event, "cappers", cappers, sizeof(cappers));
4318 new cappersLength = strlen(cappers);
4319 for (new i = 0 ; i < cappersLength; i++)
4320 {
4321 new clientCapper = cappers[i];
4322 if(clientCapper > 0 && IsClientInGame(clientCapper) && IsClientConnected(clientCapper) && IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper))
4323 {
4324 // Get player's position
4325 new Float:capperPos[3];
4326 GetClientAbsOrigin(clientCapper, Float:capperPos);
4327
4328 // Update respawn position
4329 g_fRespawnPosition = capperPos;
4330
4331 break;
4332 }
4333 }
4334
4335 // Respawn all players
4336 for (new client = 1; client <= MaxClients; client++)
4337 {
4338 if (IsClientInGame(client) && IsClientConnected(client))
4339 {
4340 new team = GetClientTeam(client);
4341 new Float:clientPos[3];
4342 GetClientAbsOrigin(client, Float:clientPos);
4343 if (playerPickSquad[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
4344 {
4345 if (!IsFakeClient(client))
4346 {
4347 if (!IsClientTimingOut(client))
4348 CreateCounterRespawnTimer(client);
4349 }
4350 else
4351 {
4352 CreateCounterRespawnTimer(client);
4353 }
4354 }
4355 }
4356 }
4357 }
4358 // //Elite Bots Reset
4359 // if (g_elite_counter_attacks == 1)
4360 // CreateTimer(5.0, Timer_EliteBots);
4361
4362
4363 // Update cvars
4364 UpdateRespawnCvars();
4365
4366
4367 //Reset security team wave counter
4368 g_secWave_Timer = g_iRespawnSeconds;
4369 // Get the number of control points
4370 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
4371
4372 // Get active push point
4373 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
4374 // If last capture point
4375 if (g_isCheckpoint == 1 && ((acp+1) == ncp))
4376 {
4377 g_secWave_Timer = g_iRespawnSeconds;
4378 g_secWave_Timer += (GetTeamSecCount() * 4);
4379 }
4380 else if (Ins_InCounterAttack())
4381 g_secWave_Timer += (GetTeamSecCount() * 3);
4382
4383 //Reset VIP Objective counter
4384 g_vip_obj_count = g_iCvar_vip_obj_time;
4385 g_vip_obj_ready = 1;
4386
4387 return Plugin_Continue;
4388}
4389
4390
4391// When ammo cache destroyed, update respawn position and reset variables
4392public Action:Event_ObjectDestroyed_Pre(Handle:event, const String:name[], bool:dontBroadcast)
4393{
4394
4395
4396 //Clear bad spawn array
4397 //ClearArray(g_badSpawnPos_Array);
4398 for (new client = 0; client < MaxClients; client++) {
4399 if (!IsValidClient(client) || client <= 0)
4400 continue;
4401 if (!IsClientInGame(client))
4402 continue;
4403 int m_iTeam = GetClientTeam(client);
4404 if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
4405 {
4406 g_badSpawnPos_Track[client][0] = 0.0;
4407 g_badSpawnPos_Track[client][1] = 0.0;
4408 g_badSpawnPos_Track[client][2] = 0.0;
4409 }
4410 }
4411
4412 g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
4413 g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
4414 // Return if conquer
4415 if (g_isConquer == 1 || g_isHunt == 1 || g_isOutpost == 1) return Plugin_Continue;
4416
4417
4418 // Get the number of control points
4419 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
4420
4421 // Get active push point
4422 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
4423
4424 //AI Director Status ###START###
4425 new secTeamCount = GetTeamSecCount();
4426 new secTeamAliveCount = Team_CountAlivePlayers(TEAM_1_SEC);
4427
4428 if (g_iRespawn_lives_team_ins > 0)
4429 g_AIDir_TeamStatus += 10;
4430
4431 if (secTeamAliveCount >= (secTeamCount * 0.8)) // If Alive Security >= 80%
4432 g_AIDir_TeamStatus += 10;
4433 else if (secTeamAliveCount >= (secTeamCount * 0.5)) // If Alive Security >= 50%
4434 g_AIDir_TeamStatus += 5;
4435 else if (secTeamAliveCount <= (secTeamCount * 0.2)) // If Dead Security <= 20%
4436 g_AIDir_TeamStatus -= 10;
4437 else if (secTeamAliveCount <= (secTeamCount * 0.5)) // If Dead Security <= 50%
4438 g_AIDir_TeamStatus -= 5;
4439
4440 if (g_AIDir_BotReinforceTriggered)
4441 g_AIDir_TeamStatus += 10;
4442 else
4443 g_AIDir_TeamStatus -= 5;
4444
4445 g_AIDir_BotReinforceTriggered = false;
4446
4447 //AI Director Status ###END###
4448
4449 // Get gamemode
4450 decl String:sGameMode[32];
4451 GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
4452
4453 // Init variables
4454 new Handle:cvar;
4455
4456 // Set minimum and maximum counter attack duration tim
4457 g_counterAttack_min_dur_sec = GetConVarInt(sm_respawn_min_counter_dur_sec);
4458 g_counterAttack_max_dur_sec = GetConVarInt(sm_respawn_max_counter_dur_sec);
4459 new final_ca_dur = GetConVarInt(sm_respawn_final_counter_dur_sec);
4460
4461 // Get random duration
4462 new fRandomInt = GetRandomInt(g_counterAttack_min_dur_sec, g_counterAttack_max_dur_sec);
4463 new fRandomIntCounterLarge = GetRandomInt(1, 100);
4464 new largeCounterEnabled = false;
4465 if (fRandomIntCounterLarge <= 15)
4466 {
4467 fRandomInt = (fRandomInt * 2);
4468 new fRandomInt2 = GetRandomInt(90, 180);
4469 final_ca_dur = (final_ca_dur + fRandomInt2);
4470 largeCounterEnabled = true;
4471 }
4472 // Set counter attack duration to server
4473 new Handle:cvar_ca_dur;
4474
4475 // Final counter attack
4476 if ((acp+1) == ncp)
4477 {
4478 cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration_finale");
4479 SetConVarInt(cvar_ca_dur, final_ca_dur, true, false);
4480 g_dynamicSpawnCounter_Perc += 10;
4481 //g_AIDir_TeamStatus -= 10;
4482
4483 if (g_finale_counter_spec_enabled == 1)
4484 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
4485 }
4486 // Normal counter attack
4487 else
4488 {
4489 g_AIDir_TeamStatus -= 5;
4490 cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration");
4491 SetConVarInt(cvar_ca_dur, fRandomInt, true, false);
4492 }
4493
4494 //Are we using vanilla counter attack?
4495 if (g_iCvar_counterattack_vanilla == 1) return Plugin_Continue;
4496
4497 // Get ramdom value for occuring counter attack
4498 new Float:fRandom = GetRandomFloat(0.0, 1.0);
4499 //PrintToServer("Counter Chance = %f", g_respawn_counter_chance); // commented by oz
4500 // Occurs counter attack
4501 if (fRandom < g_respawn_counter_chance && g_isCheckpoint && ((acp+1) != ncp))
4502 {
4503 cvar = INVALID_HANDLE;
4504 //PrintToServer("COUNTER YES");
4505 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4506 SetConVarInt(cvar, 0, true, false);
4507 cvar = FindConVar("mp_checkpoint_counterattack_always");
4508 SetConVarInt(cvar, 1, true, false);
4509 if (largeCounterEnabled)
4510 {
4511 //PrintHintTextToAll("[INTEL]: Enemy forces are sending a large counter-attack your way! Get ready to defend!"); - commented out by oz
4512 //PrintToChatAll("[INTEL]: Enemy forces are sending a large counter-attack your way! Get ready to defend!"); - commented out by oz
4513 }
4514 g_AIDir_TeamStatus -= 5;
4515 // Call music timer
4516 //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
4517
4518 //Create Counter End Timer
4519 g_isEliteCounter = 1;
4520 CreateTimer((cvar_ca_dur + 1), Timer_CounterAttackEnd, _);
4521
4522 if (g_elite_counter_attacks == 1)
4523 {
4524 EnableDisableEliteBotCvars(1, 0);
4525 new tCvar = FindConVar("ins_bot_count_checkpoint_max");
4526 new tCvarIntValue = GetConVarInt(FindConVar("ins_bot_count_checkpoint_max"));
4527 tCvarIntValue += 3;
4528 SetConVarInt(tCvar, tCvarIntValue, true, false);
4529 }
4530 }
4531 // If last capture point
4532 else if (g_isCheckpoint == 1 && ((acp+1) == ncp))
4533 {
4534 cvar = INVALID_HANDLE;
4535 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4536 SetConVarInt(cvar, 0, true, false);
4537 cvar = FindConVar("mp_checkpoint_counterattack_always");
4538 SetConVarInt(cvar, 1, true, false);
4539
4540 // Call music timer
4541 //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
4542
4543 //Create Counter End Timer
4544 g_isEliteCounter = 1;
4545 CreateTimer((cvar_ca_dur + 1), Timer_CounterAttackEnd, _);
4546
4547 if (g_elite_counter_attacks == 1)
4548 {
4549 EnableDisableEliteBotCvars(1, 1);
4550 new tCvar = FindConVar("ins_bot_count_checkpoint_max");
4551 new tCvarIntValue = GetConVarInt(FindConVar("ins_bot_count_checkpoint_max"));
4552 tCvarIntValue += 3;
4553 SetConVarInt(tCvar, tCvarIntValue, true, false);
4554 }
4555 }
4556 // Not occurs counter attack
4557 else
4558 {
4559 cvar = INVALID_HANDLE;
4560 //PrintToServer("COUNTER NO");
4561 cvar = FindConVar("mp_checkpoint_counterattack_disable");
4562 SetConVarInt(cvar, 1, true, false);
4563 }
4564
4565 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
4566
4567 return Plugin_Continue;
4568}
4569
4570// When ammo cache destroyed, update respawn position and reset variables
4571public Action:Event_ObjectDestroyed(Handle:event, const String:name[], bool:dontBroadcast)
4572{
4573 if (g_isHunt == 1)
4574 {
4575 //g_huntCacheDestroyed = true; - commented out by oz
4576 //g_iReinforceTime = g_iReinforceTime + g_huntReinforceCacheAdd;
4577 PrintHintTextToAll("Cache destroyed! Kill all enemies and reinforcements to win!");
4578 PrintToChatAll("Cache destroyed! Kill all enemies and reinforcements to win!");
4579
4580 }
4581 // Checkpoint
4582 if (g_isCheckpoint == 1)
4583 {
4584
4585 g_cacheObjActive = 1;
4586 // If VIP capped, reward team with supply points
4587 decl String:cappers[512];
4588 GetEventString(event, "cappers", cappers, sizeof(cappers));
4589 new cappersLength = strlen(cappers);
4590 if (g_vip_enable)
4591 {
4592 for (new i = 0 ; i < cappersLength; i++)
4593 {
4594 new clientCapper = cappers[i];
4595 if(clientCapper > 0 && IsClientInGame(clientCapper) && IsClientConnected(clientCapper) &&
4596 IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper) &&
4597 (StrContains(g_client_last_classstring[clientCapper], "vip") > -1) && g_vip_obj_count > 0)
4598 {
4599 //Reward team with tokens (credits to INS server)
4600 ConVar cvar_tokenmax = FindConVar("mp_supply_token_max");
4601 new nMaxSupply = GetConVarInt(cvar_tokenmax);
4602 //Determine reward
4603 new nRandSupplyReward = GetRandomInt(g_iCvar_vip_min_sp_reward, g_iCvar_vip_max_sp_reward);
4604
4605 for(new client = 1; client <= MaxClients; client++)
4606 {
4607 //new nCurrentPlayerTeam = GetClientTeam(client);
4608 if((IsValidClient(client)) && (IsClientConnected(client)) && (!IsFakeClient(client)))
4609 {
4610 int nSupplyPoint = GetEntProp(client, Prop_Send, "m_nRecievedTokens");
4611 int nAvailableSupplyPoint = GetEntProp(client, Prop_Send, "m_nAvailableTokens");
4612
4613 if(nSupplyPoint <= nMaxSupply)
4614 {
4615
4616 nSupplyPoint += nRandSupplyReward;
4617 nAvailableSupplyPoint += nRandSupplyReward;
4618 PrintToChat(client, "VIP has destroyed point\nYou have received %i supply point(s) as reward", nRandSupplyReward);
4619 }
4620
4621 //Set client nSupplyPoint
4622 SetEntProp(client, Prop_Send, "m_nRecievedTokens",nSupplyPoint);
4623 SetEntProp(client, Prop_Send, "m_nAvailableTokens", nAvailableSupplyPoint);
4624 }
4625 }
4626
4627 break;
4628 }
4629 }
4630 }
4631 // Update respawn position
4632 new attacker = GetEventInt(event, "attacker");
4633 new assister = GetEventInt(event, "assister");
4634
4635 if (attacker > 0 && IsClientInGame(attacker) && IsClientConnected(attacker) || assister > 0 && IsClientInGame(assister) && IsClientConnected(assister))
4636 {
4637 new Float:attackerPos[3];
4638 GetClientAbsOrigin(attacker, Float:attackerPos);
4639 g_fRespawnPosition = attackerPos;
4640 if (g_vip_enable)
4641 {
4642 if(attacker > 0 && IsClientInGame(attacker) && IsClientConnected(attacker) &&
4643 IsPlayerAlive(attacker) && !IsFakeClient(attacker) &&
4644 (StrContains(g_client_last_classstring[attacker], "vip") > -1) && g_vip_obj_count > 0 || assister > 0 && IsClientInGame(assister) && IsClientConnected(assister) &&
4645 IsPlayerAlive(assister) && !IsFakeClient(assister) &&
4646 (StrContains(g_client_last_classstring[assister], "vip") > -1) && g_vip_obj_count > 0)
4647 {
4648 //Reward team with tokens (credits to INS server)
4649 ConVar cvar_tokenmax = FindConVar("mp_supply_token_max");
4650 new nMaxSupply = GetConVarInt(cvar_tokenmax);
4651 //Determine reward
4652 new nRandSupplyReward = GetRandomInt(g_iCvar_vip_min_sp_reward, g_iCvar_vip_max_sp_reward);
4653
4654 for(new client = 1; client <= MaxClients; client++)
4655 {
4656 //new nCurrentPlayerTeam = GetClientTeam(client);
4657 if((IsValidClient(client)) && (IsClientConnected(client)) && (!IsFakeClient(client)))
4658 {
4659 int nSupplyPoint = GetEntProp(client, Prop_Send, "m_nRecievedTokens");
4660 int nAvailableSupplyPoint = GetEntProp(client, Prop_Send, "m_nAvailableTokens");
4661
4662 if(nSupplyPoint <= nMaxSupply)
4663 {
4664
4665 nSupplyPoint += nRandSupplyReward;
4666 nAvailableSupplyPoint += nRandSupplyReward;
4667 PrintToChat(client, "VIP has destroyed point\nYou have received %i supply point(s) as reward", nRandSupplyReward);
4668 }
4669
4670 //Set client nSupplyPoint
4671 SetEntProp(client, Prop_Send, "m_nRecievedTokens",nSupplyPoint);
4672 SetEntProp(client, Prop_Send, "m_nAvailableTokens", nAvailableSupplyPoint);
4673 }
4674 }
4675
4676 }
4677
4678 }
4679 }
4680
4681 // Reset reinforcement time
4682 g_iReinforceTime = g_iReinforceTime_AD_Temp;
4683
4684 // Reset respawn token
4685 ResetInsurgencyLives();
4686 if (g_iCvar_respawn_reset_type && g_isCheckpoint)
4687 ResetSecurityLives();
4688 }
4689
4690 // Conquer, Respawn all players
4691 else if (g_isConquer == 1 || g_isHunt == 1)
4692 {
4693 for (new client = 1; client <= MaxClients; client++)
4694 {
4695 if (IsClientConnected(client) && !IsFakeClient(client) && IsClientConnected(client))
4696 {
4697 new team = GetClientTeam(client);
4698 if(IsClientInGame(client) && !IsClientTimingOut(client) && playerPickSquad[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
4699 {
4700 CreateCounterRespawnTimer(client);
4701 }
4702 }
4703 }
4704 }
4705
4706 return Plugin_Continue;
4707}
4708// When control point captured, update respawn point and respawn all players
4709public Action:Event_ObjectDestroyed_Post(Handle:event, const String:name[], bool:dontBroadcast)
4710{
4711 // Return if conquer
4712 if (g_isConquer == 1 || g_isHunt == 1 || g_isOutpost == 1) return Plugin_Continue;
4713
4714 if (GetConVarInt(sm_respawn_security_on_counter) == 1)
4715 {
4716 // Get client who captured control point.
4717 decl String:cappers[512];
4718 GetEventString(event, "cappers", cappers, sizeof(cappers));
4719 new cappersLength = strlen(cappers);
4720 for (new i = 0 ; i < cappersLength; i++)
4721 {
4722 new clientCapper = cappers[i];
4723 if(clientCapper > 0 && IsClientInGame(clientCapper) && IsClientConnected(clientCapper) && IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper))
4724 {
4725 // Get player's position
4726 new Float:capperPos[3];
4727 GetClientAbsOrigin(clientCapper, Float:capperPos);
4728
4729 // Update respawn position
4730 g_fRespawnPosition = capperPos;
4731
4732 break;
4733 }
4734 }
4735
4736 // Respawn all players
4737 for (new client = 1; client <= MaxClients; client++)
4738 {
4739 if (IsClientInGame(client) && IsClientConnected(client))
4740 {
4741 new team = GetClientTeam(client);
4742 new Float:clientPos[3];
4743 GetClientAbsOrigin(client, Float:clientPos);
4744 if (playerPickSquad[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
4745 {
4746 if (!IsFakeClient(client))
4747 {
4748 if (!IsClientTimingOut(client))
4749 CreateCounterRespawnTimer(client);
4750 }
4751 else
4752 {
4753 CreateCounterRespawnTimer(client);
4754 }
4755 }
4756 }
4757 }
4758 }
4759
4760
4761 // //Elite Bots Reset
4762 // if (g_elite_counter_attacks == 1)
4763 // CreateTimer(5.0, Timer_EliteBots);
4764 //PrintToServer("CONTROL POINT CAPTURED POST");
4765
4766 // Get the number of control points
4767 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
4768
4769 // Get active push point
4770 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
4771 // If last capture point
4772 if (g_isCheckpoint == 1 && ((acp+1) == ncp))
4773 {
4774 g_secWave_Timer = g_iRespawnSeconds;
4775 g_secWave_Timer += (GetTeamSecCount() * 4);
4776 }
4777 else if (Ins_InCounterAttack())
4778 g_secWave_Timer += (GetTeamSecCount() * 3);
4779
4780 //Reset VIP timer
4781 g_vip_obj_count = g_iCvar_vip_obj_time;
4782
4783 return Plugin_Continue;
4784}
4785
4786//Command Actions START
4787public Action:serverhelp(client, args)
4788{
4789 PrintToChat(client, "[SERVER_HELP] Visit SERNIX.DYNU.COM in/out of game for more SERNIX Info/Guides.");
4790 return Plugin_Handled;
4791}
4792//VIP Info Command (Credits: INS Server)
4793public Action:Cmd_VIP(client, args)
4794{
4795 int nPlayerHealth = GetClientHealth(client);
4796 if((g_nVIP_ID != 0) && (nPlayerHealth > 0))
4797 {
4798 PrintHintText(client, "\x04VIP\x01 needs to capture point within 5 minutes to earn bonus supply.");
4799 PrintToChat(client, "\x04VIP\x01 needs to capture point within 5 minutes to earn bonus supply. Does not include destroying objectives.");
4800 }
4801 return Plugin_Handled;
4802}
4803//Squad Spawning Toggle
4804public Action:SquadSpawn(client, args)
4805{
4806 if (client < 0 || !IsValidClient(client) || !IsClientInGame(client))
4807 return Plugin_Handled;
4808
4809 new iTeam = GetClientTeam(client);
4810 if ((iTeam == TEAM_1_SEC && playerPickSquad[client] == 1) &&
4811 (StrContains(g_client_last_classstring[client], "Gnalvl_squadleader_usmc") > -1 ||
4812 StrContains(g_client_last_classstring[client], "gnalvl_teamleader_usmc") > -1 ||
4813 StrContains(g_client_last_classstring[client], "Gnalvl_teamleader_recon_usmc") > -1) )
4814 {
4815 PrintToChat(client, "[SQUAD_SPAWN] You can't squad spawn as a leader!");
4816 g_squadSpawnEnabled[client] = 0;
4817 return Plugin_Handled;
4818 }
4819
4820 if (g_squadSpawnEnabled[client] == 1)
4821 {
4822 g_squadSpawnEnabled[client] = 0;
4823 PrintToChat(client, "[SQUAD_SPAWN] Squad spawning disabled!");
4824 }
4825 else
4826 {
4827 g_squadSpawnEnabled[client] = 1;
4828 PrintToChat(client, "[SQUAD_SPAWN] Squad spawning enabled!");
4829
4830 }
4831 return Plugin_Handled;
4832 //PrintToChat(client, "[SERVER_HELP] Visit SERNIX.DYNU.COM in/out of game for more SERNIX Info/Guides.");
4833}
4834
4835public OnWeaponReload(weapon, bool:bSuccessful)
4836{
4837 if (bSuccessful)
4838 {
4839 PrintToChatAll("reload success");
4840 }
4841}
4842
4843
4844
4845public Action:Toggle_Hints(client, args)
4846{
4847 if (g_hintsEnabled[client])
4848 {
4849 g_hintsEnabled[client] = false;
4850 PrintToChat(client, "Hints disabled!");
4851 }
4852 else
4853 {
4854 g_hintsEnabled[client] = true;
4855 PrintToChat(client, "Hints enabled!");
4856 }
4857}
4858
4859//Extend Map with /emap or sm_emap
4860public Action:emap(client, args)
4861{
4862 if (g_extendMapVote[client] == 1)
4863 {
4864 g_extendMapVote[client] = 0;
4865 PrintToChat(client, "You are AGAINST extending map!");
4866 }
4867 else
4868 {
4869 g_extendMapVote[client] = 1;
4870 PrintToChat(client, "You are FOR extending map!");
4871 }
4872}
4873
4874
4875//Test stuff with /test command or sm_test
4876public Action:test(client, args)
4877{
4878
4879
4880
4881 //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
4882 //// Active control poin
4883 //new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
4884
4885 //PrintToChatAll("acp %d, ncp %d ", acp, ncp);
4886 //DisplayInstructorHint(EntRefToEntIndex(client), 5.0, 0.0, 1000.0, true, fa, "icon_interact", "icon_interact", "", true, {255, 215, 0}, "IED Jammer is broken! Fix it!");
4887 //DisplayInstructorHint(client, 5.0, 0.0, 3.0, true, true, "icon_interact", "icon_interact", "", true, {255, 255, 255}, "Crouch (hold) and press R w/ knife to resupply");
4888// new primaryWeapon = GetPlayerWeaponSlot(client, 0);
4889// new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
4890// new playerGrenades = GetPlayerWeaponSlot(client, 3);
4891
4892// //SetWeaponAmmo(client, primaryWeapon, 3, 0);
4893
4894// SDKHook(primaryWeapon, SDKHook_ReloadPost, OnWeaponReload);
4895 //Client_SetWeaponPlayerAmmoEx(client, primaryWeapon, 3, 3);
4896 // Jareds pistols only code to verify iMedic is carrying knife
4897 //new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
4898 //if (ActiveWeapon < 0)
4899 // return Plugin_Continue;
4900
4901 // // Get weapon class name
4902 // decl String:sWeapon[32];
4903 // GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
4904 // //new primaryWeapon = GetPlayerWeaponSlot(client, 0);
4905 // // if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
4906 // // {
4907 // // }
4908 // // Call revive function
4909 // //CreateReviveTimer(iInjured);
4910 // RemovePlayerItem(client,ActiveWeapon);
4911 // //Client_RemoveAllWeapons(client, "weapon_knife", true);
4912 // Client_GiveWeaponAndAmmo(client, "weapon_m4a1", _, 1, _, 10);
4913 // new Handle:forceResupply;
4914 // new Handle:hGameConfig;
4915 // // Init respawn function
4916 // // Next 14 lines of text are taken from Andersso's DoDs respawn plugin. Thanks :)
4917 // hGameConfig = LoadGameConfigFile("insurgency.games");
4918
4919 // if (hGameConfig == INVALID_HANDLE)
4920 // SetFailState("Fatal Error: Missing File \"insurgency.games\"!");
4921
4922 // StartPrepSDKCall(SDKCall_Entity);
4923 // PrepSDKCall_SetFromConf(hGameConfig, SDKConf_Signature, "CINSWeapon::DecrementAmmo");
4924
4925 // forceResupply = EndPrepSDKCall();
4926 // if (forceResupply == INVALID_HANDLE) {
4927 // SetFailState("Fatal Error: Unable to find signature for \"CINSWeapon::DecrementAmmo\"!");
4928 // }
4929 // new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
4930 // if (ActiveWeapon < 0)
4931 // return Plugin_Continue;
4932 // SDKCall(forceResupply, ActiveWeapon);
4933 //PrintToServer("clientMags: %d", clientMags);
4934 return Plugin_Handled;
4935}
4936//Command Actions END
4937
4938
4939
4940// Squad Spawn Notify Leader
4941public Action:Timer_SquadSpawn_Notify(Handle:timer, any:data)
4942{
4943 //Initialize the 3 squad leaders and squad tracking variables
4944 new tSquadLeader = -1, tTeamLeader = -1, tReconTeamLeader = -1;
4945 new tSL_lowestCount = -1, tTL_lowestCount = -1, tRTL_lowestCount = -1;
4946 new tSL_lowestClient = -1, tTL_lowestClient = -1, tRTL_lowestClient = -1;
4947 new tSL_HasSpawner = 0, tTL_HasSpawner = 0, tRTL_HasSpawner = 0;
4948 if (Ins_InCounterAttack())
4949 return Plugin_Continue;
4950 //Get Active Squad Leaders
4951 for(new tLeader = 1; tLeader <= MaxClients; tLeader++)
4952 {
4953 if (!IsClientInGame(tLeader) || IsFakeClient(tLeader))
4954 continue;
4955
4956 new iTeam = GetClientTeam(tLeader);
4957 if (iTeam == TEAM_1_SEC && StrContains(g_client_last_classstring[tLeader], "Gnalvl_squadleader_usmc") > -1 && IsPlayerAlive(tLeader))
4958 {
4959 tSquadLeader = tLeader;
4960 }
4961 else if (iTeam == TEAM_1_SEC && StrContains(g_client_last_classstring[tLeader], "gnalvl_teamleader_usmc") > -1 && IsPlayerAlive(tLeader))
4962 {
4963 tTeamLeader = tLeader;
4964 }
4965 else if (iTeam == TEAM_1_SEC && StrContains(g_client_last_classstring[tLeader], "Gnalvl_teamleader_recon_usmc") > -1 && IsPlayerAlive(tLeader))
4966 {
4967 tReconTeamLeader = tLeader;
4968 }
4969 }
4970
4971 //Find squadmate with lowest respawn time and store info to broadcast.
4972 for(new tClient = 1; tClient <= MaxClients; tClient++)
4973 {
4974 if (!IsClientInGame(tClient) || IsFakeClient(tClient))
4975 continue;
4976
4977 new iTeam = GetClientTeam(tClient);
4978 if (g_squadSpawnEnabled[tClient] == 1 && iTeam == TEAM_1_SEC && !IsPlayerAlive(tClient) && (!StrContains(g_client_last_classstring[tClient], "Gnalvl_squadleader_usmc") > -1) &&
4979 (!StrContains(g_client_last_classstring[tClient], "gnalvl_teamleader_usmc") > -1) &&
4980 (!StrContains(g_client_last_classstring[tClient], "Gnalvl_teamleader_recon_usmc") > -1))
4981 {
4982 if (g_iRespawnTimeRemaining[tClient] > 0 && g_iSpawnTokens[tClient] > 0)
4983 {
4984 //Get Valid Squad leader lowest count and lowest client
4985 if (g_squadLeader[tClient] == tSquadLeader && tSquadLeader != -1)
4986 {
4987 //Get Lowest count
4988 if (tSL_lowestCount == -1)
4989 {
4990 tSL_lowestCount = g_iRespawnTimeRemaining[tClient];
4991 tSL_lowestClient = tClient;
4992 }
4993 else if (tSL_lowestCount > g_iRespawnTimeRemaining[tClient])
4994 {
4995 tSL_lowestCount = g_iRespawnTimeRemaining[tClient];
4996 tSL_lowestClient = tClient;
4997 }
4998
4999 tSL_HasSpawner = 1;
5000 }
5001 else if (g_squadLeader[tClient] == tTeamLeader && tTeamLeader != -1)
5002 {
5003 //Get Lowest count
5004 if (tTL_lowestCount == -1)
5005 {
5006 tTL_lowestCount = g_iRespawnTimeRemaining[tClient];
5007 tTL_lowestClient = tClient;
5008 }
5009 else if (tTL_lowestCount > g_iRespawnTimeRemaining[tClient])
5010 {
5011 tTL_lowestCount = g_iRespawnTimeRemaining[tClient];
5012 tTL_lowestClient = tClient;
5013 }
5014
5015 tTL_HasSpawner = 1;
5016 }
5017 else if (g_squadLeader[tClient] == tReconTeamLeader && tReconTeamLeader != -1)
5018 {
5019 //Get Lowest count
5020 if (tRTL_lowestCount == -1)
5021 {
5022 tRTL_lowestCount = g_iRespawnTimeRemaining[tClient];
5023 tRTL_lowestClient = tClient;
5024 }
5025 else if (tRTL_lowestCount > g_iRespawnTimeRemaining[tClient])
5026 {
5027 tRTL_lowestCount = g_iRespawnTimeRemaining[tClient];
5028 tRTL_lowestClient = tClient;
5029 }
5030 tRTL_HasSpawner = 1;
5031 }
5032 }
5033 }
5034 }
5035
5036
5037 decl String:sNotifyLeader[256];
5038 //If valid squad leader and valid teammate spawning print to chat
5039 if (tSL_HasSpawner == 1)
5040 {
5041 Format(sNotifyLeader, sizeof(sNotifyLeader),"[SQUAD_SPAWN] Squadmate %N will reinforce on you in %d seconds!", tSL_lowestClient, g_iRespawnTimeRemaining[tSL_lowestClient]);
5042 PrintCenterText(tSquadLeader, sNotifyLeader);
5043 }
5044 if (tTL_HasSpawner == 1)
5045 {
5046 Format(sNotifyLeader, sizeof(sNotifyLeader),"[SQUAD_SPAWN] Squadmate %N will reinforce on you in %d seconds!", tTL_lowestClient, g_iRespawnTimeRemaining[tTL_lowestClient]);
5047 PrintCenterText(tTeamLeader, sNotifyLeader);
5048 }
5049 if (tRTL_HasSpawner == 1)
5050 {
5051 Format(sNotifyLeader, sizeof(sNotifyLeader),"[SQUAD_SPAWN] Squadmate %N will reinforce on you in %d seconds!", tRTL_lowestClient, g_iRespawnTimeRemaining[tRTL_lowestClient]);
5052 PrintCenterText(tReconTeamLeader, sNotifyLeader);
5053 }
5054
5055 return Plugin_Continue;
5056}
5057
5058//Find Squad Leader
5059public FindSquadLeader(String:leaderClassString[64])
5060{
5061 //new String:tLeaderClassString = leaderClassString;
5062 for(new tLeader = 1; tLeader <= MaxClients; tLeader++)
5063 {
5064 if (!IsClientInGame(tLeader) || IsFakeClient(tLeader))
5065 continue;
5066
5067 new iTeam = GetClientTeam(tLeader);
5068 if (iTeam == TEAM_1_SEC && StrContains(g_client_last_classstring[tLeader], leaderClassString) > -1)
5069 {
5070 return tLeader;
5071 }
5072 }
5073
5074 return -1;
5075}
5076
5077//Squad Spawning Toggle
5078public GetSquadLeader(client)
5079{
5080 //Get client class string to find squad leader
5081 decl String:tClassStrLeader[64];
5082 new tSquadLeader;
5083 if ((StrContains(g_client_last_classstring[client], "gnalvl_pointman_usmc") > -1) || (StrContains(g_client_last_classstring[client], "Gnalvl_rifleman_at_usmc_1") > -1) ||
5084 (StrContains(g_client_last_classstring[client], "Gnalvl_engineer_usmc_1") > -1) || (StrContains(g_client_last_classstring[client], "gnalvl_medic_usmc_1") > -1) ||
5085 (StrContains(g_client_last_classstring[client], "Gnalvl_support_usmc_1") > -1) )
5086 {
5087 Format(tClassStrLeader, sizeof(tClassStrLeader), "Gnalvl_squadleader_usmc");
5088 tSquadLeader = FindSquadLeader(tClassStrLeader);
5089 }
5090 else if ((StrContains(g_client_last_classstring[client], "Gnalvl_rifleman_at_usmc_2") > -1) || (StrContains(g_client_last_classstring[client], "Gnalvl_engineer_usmc_2") > -1) ||
5091 (StrContains(g_client_last_classstring[client], "gnalvl_medic_usmc_2") > -1) || (StrContains(g_client_last_classstring[client], "Gnalvl_support_usmc_2") > -1) )
5092 {
5093 Format(tClassStrLeader, sizeof(tClassStrLeader), "gnalvl_teamleader_usmc");
5094 tSquadLeader = FindSquadLeader(tClassStrLeader);
5095 }
5096 else if ((StrContains(g_client_last_classstring[client], "gnalvl_recon_medic_usmc") > -1) || (StrContains(g_client_last_classstring[client], "Gnalvl_recon_engineer_usmc") > -1) ||
5097 (StrContains(g_client_last_classstring[client], "Gnalvl_marksman_usmc_1") > -1) || (StrContains(g_client_last_classstring[client], "Gnalvl_marksman_usmc_2") > -1) ||
5098 (StrContains(g_client_last_classstring[client], "Gnalvl_spotter_usmc") > -1) )
5099 {
5100 Format(tClassStrLeader, sizeof(tClassStrLeader), "Gnalvl_teamleader_recon_usmc");
5101 tSquadLeader = FindSquadLeader(tClassStrLeader);
5102 }
5103 return tSquadLeader;
5104}
5105
5106//Enable/Disable Elite Bots
5107void EnableDisableEliteBotCvars(tEnabled, isFinale)
5108{
5109 new Float:tCvarFloatValue;
5110 new Int:tCvarIntValue;
5111 new Handle:tCvar;
5112 if (tEnabled == 1)
5113 {
5114 //PrintToServer("BOT_SETTINGS_APPLIED"); // commented by oz
5115 if (isFinale == 1)
5116 {
5117 tCvar = FindConVar("mp_player_resupply_coop_delay_max");
5118 SetConVarInt(tCvar, g_coop_delay_penalty_base, true, false);
5119 tCvar = FindConVar("mp_player_resupply_coop_delay_penalty");
5120 SetConVarInt(tCvar, g_coop_delay_penalty_base, true, false);
5121 tCvar = FindConVar("mp_player_resupply_coop_delay_base");
5122 SetConVarInt(tCvar, g_coop_delay_penalty_base, true, false);
5123 }
5124
5125 tCvar = FindConVar("bot_attackdelay_frac_difficulty_impossible");
5126 tCvarFloatValue = GetConVarFloat(FindConVar("bot_attackdelay_frac_difficulty_impossible"));
5127 tCvarFloatValue = tCvarFloatValue - g_bot_attackdelay_frac_difficulty_impossible_mult;
5128 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5129
5130 tCvar = FindConVar("bot_attack_aimpenalty_amt_close");
5131 tCvarIntValue = GetConVarInt(FindConVar("bot_attack_aimpenalty_amt_close"));
5132 tCvarIntValue = tCvarIntValue - g_bot_attack_aimpenalty_amt_close_mult;
5133 SetConVarInt(tCvar, tCvarIntValue, true, false);
5134
5135 tCvar = FindConVar("bot_attack_aimpenalty_amt_far");
5136 tCvarIntValue = GetConVarInt(FindConVar("bot_attack_aimpenalty_amt_far"));
5137 tCvarIntValue = tCvarIntValue - g_bot_attack_aimpenalty_amt_far_mult;
5138 SetConVarInt(tCvar, tCvarIntValue, true, false);
5139
5140 tCvar = FindConVar("bot_attack_aimpenalty_time_close");
5141 tCvarFloatValue = GetConVarFloat(FindConVar("bot_attack_aimpenalty_time_close"));
5142 tCvarFloatValue = tCvarFloatValue - g_bot_attack_aimpenalty_time_close_mult;
5143 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5144
5145 tCvar = FindConVar("bot_attack_aimpenalty_time_far");
5146 tCvarFloatValue = GetConVarFloat(FindConVar("bot_attack_aimpenalty_time_far"));
5147 tCvarFloatValue = tCvarFloatValue - g_bot_attack_aimpenalty_time_far_mult;
5148 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5149
5150 tCvar = FindConVar("bot_attack_aimtolerance_newthreat_amt");
5151 tCvarIntValue = GetConVarInt(FindConVar("bot_attack_aimtolerance_newthreat_amt"));
5152 tCvarIntValue = tCvarIntValue - g_bot_attack_aimtolerance_newthreat_amt_mult;
5153 SetConVarFloat(tCvar, tCvarIntValue, true, false);
5154
5155 tCvar = FindConVar("bot_aim_aimtracking_base");
5156 tCvarFloatValue = GetConVarFloat(FindConVar("bot_aim_aimtracking_base"));
5157 tCvarFloatValue = tCvarFloatValue - g_bot_aim_aimtracking_base;
5158 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5159
5160 tCvar = FindConVar("bot_aim_aimtracking_frac_impossible");
5161 tCvarFloatValue = GetConVarFloat(FindConVar("bot_aim_aimtracking_frac_impossible"));
5162 tCvarFloatValue = tCvarFloatValue - g_bot_aim_aimtracking_frac_impossible;
5163 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5164
5165 tCvar = FindConVar("bot_aim_angularvelocity_frac_impossible");
5166 tCvarFloatValue = GetConVarFloat(FindConVar("bot_aim_angularvelocity_frac_impossible"));
5167 tCvarFloatValue = tCvarFloatValue + g_bot_aim_angularvelocity_frac_impossible;
5168 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5169
5170 tCvar = FindConVar("bot_aim_angularvelocity_frac_sprinting_target");
5171 tCvarFloatValue = GetConVarFloat(FindConVar("bot_aim_angularvelocity_frac_sprinting_target"));
5172 tCvarFloatValue = tCvarFloatValue + g_bot_aim_angularvelocity_frac_sprinting_target;
5173 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5174
5175 tCvar = FindConVar("bot_aim_attack_aimtolerance_frac_impossible");
5176 tCvarFloatValue = GetConVarFloat(FindConVar("bot_aim_attack_aimtolerance_frac_impossible"));
5177 tCvarFloatValue = tCvarFloatValue - g_bot_aim_attack_aimtolerance_frac_impossible;
5178 SetConVarFloat(tCvar, tCvarFloatValue, true, false);
5179 //Make sure to check for FLOATS vs INTS and +/-!
5180 }
5181 else
5182 {
5183 //PrintToServer("BOT_SETTINGS_APPLIED_2"); // commented by oz
5184
5185 tCvar = FindConVar("ins_bot_count_checkpoint_max");
5186 SetConVarInt(tCvar, g_ins_bot_count_checkpoint_max_org, true, false);
5187 tCvar = FindConVar("mp_player_resupply_coop_delay_max");
5188 SetConVarInt(tCvar, g_mp_player_resupply_coop_delay_max_org, true, false);
5189 tCvar = FindConVar("mp_player_resupply_coop_delay_penalty");
5190 SetConVarInt(tCvar, g_mp_player_resupply_coop_delay_penalty_org, true, false);
5191 tCvar = FindConVar("mp_player_resupply_coop_delay_base");
5192 SetConVarInt(tCvar, g_mp_player_resupply_coop_delay_base_org, true, false);
5193 tCvar = FindConVar("bot_attackdelay_frac_difficulty_impossible");
5194 SetConVarFloat(tCvar, g_bot_attackdelay_frac_difficulty_impossible_org, true, false);
5195 tCvar = FindConVar("bot_attack_aimpenalty_amt_close");
5196 SetConVarInt(tCvar, g_bot_attack_aimpenalty_amt_close_org, true, false);
5197 tCvar = FindConVar("bot_attack_aimpenalty_amt_far");
5198 SetConVarInt(tCvar, g_bot_attack_aimpenalty_amt_far_org, true, false);
5199 tCvar = FindConVar("bot_attack_aimpenalty_time_close");
5200 SetConVarFloat(tCvar, g_bot_attack_aimpenalty_time_close_org, true, false);
5201 tCvar = FindConVar("bot_attack_aimpenalty_time_far");
5202 SetConVarFloat(tCvar, g_bot_attack_aimpenalty_time_far_org, true, false);
5203 tCvar = FindConVar("bot_attack_aimtolerance_newthreat_amt");
5204 SetConVarFloat(tCvar, g_bot_attack_aimtolerance_newthreat_amt_org, true, false);
5205
5206 tCvar = FindConVar("bot_aim_aimtracking_base");
5207 SetConVarFloat(tCvar, g_bot_aim_aimtracking_base_org, true, false);
5208 tCvar = FindConVar("bot_aim_aimtracking_frac_impossible");
5209 SetConVarFloat(tCvar, g_bot_aim_aimtracking_frac_impossible_org, true, false);
5210 tCvar = FindConVar("bot_aim_angularvelocity_frac_impossible");
5211 SetConVarFloat(tCvar, g_bot_aim_angularvelocity_frac_impossible_org, true, false);
5212 tCvar = FindConVar("bot_aim_angularvelocity_frac_sprinting_target");
5213 SetConVarFloat(tCvar, g_bot_aim_angularvelocity_frac_sprinting_target_org, true, false);
5214 tCvar = FindConVar("bot_aim_attack_aimtolerance_frac_impossible");
5215 SetConVarFloat(tCvar, g_bot_aim_attack_aimtolerance_frac_impossible_org, true, false);
5216
5217 }
5218}
5219
5220public Action:cmd_kill(client, args) {
5221 g_trackKillDeaths[client] += 1;
5222 PrintToChatAll("\x05%N\x01 has used the kill command! | Times Used: %d | Abusing for ammo = ban", client, g_trackKillDeaths[client]);
5223 PrintToChat(client, "\x04[SERNIX RULES] %t", "Abusing kill command is not allowed! | Times used %d | Abusing for ammo = ban", g_trackKillDeaths[client]);
5224 return Plugin_Handled;
5225}
5226// On finale counter attack, add lives back to insurgents to trigger unlimited respawns (this is redundant code now and may use for something else)
5227public Action:Timer_FinaleCounterAssignLives(Handle:Timer)
5228{
5229 if (g_iCvar_final_counterattack_type == 2)
5230 {
5231 // Reset remaining lives for bots
5232 g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins;
5233 }
5234}
5235
5236// When counter-attack end, reset reinforcement time
5237public Action:Timer_CounterAttackEnd(Handle:Timer)
5238{
5239
5240
5241 //Clear bad spawn array
5242 //ClearArray(g_badSpawnPos_Array);
5243
5244
5245 //g_bIsCounterAttackTimerActive = false;
5246 // If round end, exit
5247 // if (g_iRoundStatus == 0)
5248 // {
5249 // // Stop counter-attack music
5250 // //StopCounterAttackMusic();
5251
5252 // // Reset variable
5253 // g_bIsCounterAttackTimerActive = false;
5254 // return Plugin_Stop;
5255 // }
5256 //Disable elite bots when not in counter
5257 if (g_isEliteCounter == 1 && g_elite_counter_attacks == 1)
5258 {
5259 g_isEliteCounter = 0;
5260 EnableDisableEliteBotCvars(0, 0);
5261 }
5262 // Check counter-attack end
5263 // if (!Ins_InCounterAttack())
5264 // {
5265 //EnableDisableEliteBotCvars(0, 0);
5266 // Reset reinforcement time
5267
5268 //g_iReinforceTime = g_iReinforceTime_AD_Temp;
5269
5270 // Reset respawn token
5271 ResetInsurgencyLives();
5272 if (g_iCvar_respawn_reset_type && g_isCheckpoint)
5273 ResetSecurityLives();
5274
5275 // Stop counter-attack music
5276 //StopCounterAttackMusic();
5277
5278 // Reset variable
5279 //g_bIsCounterAttackTimerActive = false;
5280
5281 new Handle:cvar = INVALID_HANDLE;
5282 cvar = FindConVar("mp_checkpoint_counterattack_always");
5283 SetConVarInt(cvar, 0, true, false);
5284
5285 for (new client = 0; client < MaxClients; client++) {
5286 if (!IsValidClient(client) || client <= 0)
5287 continue;
5288 if (!IsClientInGame(client))
5289 continue;
5290 int m_iTeam = GetClientTeam(client);
5291 if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
5292 {
5293 g_badSpawnPos_Track[client][0] = 0.0;
5294 g_badSpawnPos_Track[client][1] = 0.0;
5295 g_badSpawnPos_Track[client][2] = 0.0;
5296 }
5297 }
5298
5299 //PrintToServer("[RESPAWN] Counter-attack is over.");
5300 return Plugin_Stop;
5301 //}
5302
5303 //return Plugin_Continue;
5304}
5305
5306
5307// Below void commented out by oz
5308// Stop counter-attack music
5309//void StopCounterAttackMusic()
5310//{
5311// for (new i = 1; i <= MaxClients; i++)
5312// {
5313// if (IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i))
5314// {
5315 //ClientCommand(i, "snd_restart");
5316 //FakeClientCommand(i, "snd_restart");
5317// StopSound(i, SNDCHAN_STATIC, "*cues/INS_GameMusic_AboutToAttack_A.ogg");
5318// }
5319// }
5320//}
5321
5322//Run this to mark a bot as ready to spawn. Add tokens if you want them to be able to spawn.
5323void ResetSecurityLives()
5324{
5325 // Disable if counquer
5326 //if (g_isConquer == 1 || g_isOutpost == 1) return;
5327 // The number of control points
5328 //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints"); - commented out by oz
5329 // Active control poin
5330 //new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex"); - commented out by oz
5331
5332
5333 // Return if respawn is disabled
5334 if (!g_iCvar_respawn_enable) return;
5335
5336 // Update cvars
5337 UpdateRespawnCvars();
5338
5339 if (g_isCheckpoint)
5340 {
5341 //If spawned per point, give more per-point lives based on team count.
5342 if (g_iCvar_respawn_reset_type == 1)
5343 SecDynLivesPerPoint();
5344 }
5345 // Individual lives
5346 if (g_iCvar_respawn_type_team_sec == 1)
5347 {
5348 for (new client=1; client<=MaxClients; client++)
5349 {
5350 // Check valid player
5351 if (client > 0 && IsClientInGame(client))
5352 {
5353 //Reset Medic Stats:
5354 g_playerMedicRevivessAccumulated[client] = 0;
5355 g_playerMedicHealsAccumulated[client] = 0;
5356 g_playerNonMedicHealsAccumulated[client] = 0;
5357
5358 // Check Team
5359 new iTeam = GetClientTeam(client);
5360 if (iTeam != TEAM_1_SEC)
5361 continue;
5362
5363 //Bonus lives for conquer/outpost
5364 if (g_isConquer == 1 || g_isOutpost == 1 || g_isHunt == 1)
5365 g_iSpawnTokens[client] = g_iRespawnCount[iTeam] + 10;
5366 else
5367 {
5368 // Individual SEC lives
5369 if (g_isCheckpoint == 1 && g_iCvar_respawn_type_team_sec == 1)
5370 {
5371 // Reset remaining lives for player
5372 g_iSpawnTokens[client] = g_iRespawnCount[iTeam];
5373 }
5374 }
5375 }
5376 }
5377 }
5378
5379 // Team lives
5380 if (g_iCvar_respawn_type_team_sec == 2)
5381 {
5382 // Reset remaining lives for player
5383 g_iRemaining_lives_team_sec = g_iRespawn_lives_team_sec;
5384 }
5385}
5386
5387//Run this to mark a bot as ready to spawn. Add tokens if you want them to be able to spawn.
5388void ResetInsurgencyLives()
5389{
5390 // Disable if counquer
5391 //if (g_isConquer == 1 || g_isOutpost == 1) return;
5392
5393 // Return if respawn is disabled
5394 if (!g_iCvar_respawn_enable) return;
5395
5396 // Update cvars
5397 UpdateRespawnCvars();
5398
5399 // Individual lives
5400 if (g_iCvar_respawn_type_team_ins == 1)
5401 {
5402 for (new client=1; client<=MaxClients; client++)
5403 {
5404 // Check valid player
5405 if (client > 0 && IsClientInGame(client))
5406 {
5407 // Check Team
5408 new iTeam = GetClientTeam(client);
5409 if (iTeam != TEAM_2_INS)
5410 continue;
5411
5412 //Bonus lives for conquer/outpost
5413 if (g_isConquer == 1 || g_isOutpost == 1 || g_isHunt == 1)
5414 g_iSpawnTokens[client] = g_iRespawnCount[iTeam] + 10;
5415 else
5416 g_iSpawnTokens[client] = g_iRespawnCount[iTeam];
5417 }
5418 }
5419 }
5420
5421 // Team lives
5422 if (g_iCvar_respawn_type_team_ins == 2)
5423 {
5424 // Reset remaining lives for bots
5425 g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins;
5426 }
5427}
5428
5429// When player picked squad, initialize variables
5430public Action:Event_PlayerPickSquad_Post( Handle:event, const String:name[], bool:dontBroadcast )
5431{
5432 //"squad_slot" "byte"
5433 //"squad" "byte"
5434 //"userid" "short"
5435 //"class_template" "string"
5436 //PrintToServer("##########PLAYER IS PICKING SQUAD!############");
5437
5438 // Get client ID
5439 new client = GetClientOfUserId( GetEventInt( event, "userid" ) );
5440
5441 // Get class name
5442 decl String:class_template[64];
5443 GetEventString(event, "class_template", class_template, sizeof(class_template));
5444
5445 // Set class string
5446 g_client_last_classstring[client] = class_template;
5447 g_hintsEnabled[client] = true;
5448
5449 if( client == 0 || !IsClientInGame(client) || IsFakeClient(client))
5450 return;
5451 // Init variable
5452 playerPickSquad[client] = 1;
5453
5454 // If player changed squad and remain ragdoll
5455 new team = GetClientTeam(client);
5456 if (client > 0 && IsClientInGame(client) && IsClientObserver(client) && !IsPlayerAlive(client) && g_iHurtFatal[client] == 0 && team == TEAM_1_SEC)
5457 {
5458 // Remove ragdoll
5459 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
5460 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
5461 RemoveRagdoll(client);
5462
5463 // Init variable
5464 g_iHurtFatal[client] = -1;
5465 }
5466
5467 g_fPlayerLastChat[client] = GetGameTime();
5468
5469 // Get player nickname
5470 decl String:sNewNickname[64];
5471
5472 // Medic class
5473 if (StrContains(g_client_last_classstring[client], "medic") > -1)
5474 {
5475 // Admin medic
5476 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5477 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][MEDIC] %s", g_client_org_nickname[client]);
5478 // Donor medic
5479 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5480 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][MEDIC] %s", g_client_org_nickname[client]);
5481 // Normal medic
5482 else
5483 Format(sNewNickname, sizeof(sNewNickname), "[MEDIC] %s", g_client_org_nickname[client]);
5484 }
5485 else if (StrContains(g_client_last_classstring[client], "engineer") > -1)
5486 {
5487 // Admin medic
5488 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5489 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][ENG] %s", g_client_org_nickname[client]);
5490 // Donor medic
5491 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5492 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][ENG] %s", g_client_org_nickname[client]);
5493 // Normal medic
5494 else
5495 Format(sNewNickname, sizeof(sNewNickname), "[ENG] %s", g_client_org_nickname[client]);
5496 }
5497 else if (StrContains(g_client_last_classstring[client], "leader") > -1)
5498 {
5499 // Admin medic
5500 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5501 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][LEADER] %s", g_client_org_nickname[client]);
5502 // Donor medic
5503 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5504 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][LEADER] %s", g_client_org_nickname[client]);
5505 // Normal medic
5506 else
5507 Format(sNewNickname, sizeof(sNewNickname), "[LEADER] %s", g_client_org_nickname[client]);
5508 }
5509 else if (StrContains(g_client_last_classstring[client], "marksman") > -1)
5510 {
5511 // Admin medic
5512 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5513 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][SNIPER] %s", g_client_org_nickname[client]);
5514 // Donor medic
5515 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5516 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][SNIPER] %s", g_client_org_nickname[client]);
5517 // Normal medic
5518 else
5519 Format(sNewNickname, sizeof(sNewNickname), "[SNIPER] %s", g_client_org_nickname[client]);
5520 }
5521 else if (StrContains(g_client_last_classstring[client], "spotter") > -1)
5522 {
5523 // Admin medic
5524 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5525 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][SPOTTER] %s", g_client_org_nickname[client]);
5526 // Donor medic
5527 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5528 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][SPOTTER] %s", g_client_org_nickname[client]);
5529 // Normal medic
5530 else
5531 Format(sNewNickname, sizeof(sNewNickname), "[SPOTTER] %s", g_client_org_nickname[client]);
5532 }
5533 else if (StrContains(g_client_last_classstring[client], "pointman") > -1)
5534 {
5535 // Admin medic
5536 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5537 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][POINT] %s", g_client_org_nickname[client]);
5538 // Donor medic
5539 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5540 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][POINT] %s", g_client_org_nickname[client]);
5541 // Normal medic
5542 else
5543 Format(sNewNickname, sizeof(sNewNickname), "[POINT] %s", g_client_org_nickname[client]);
5544 }
5545 else if (StrContains(g_client_last_classstring[client], "support") > -1)
5546 {
5547 // Admin medic
5548 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5549 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][MG] %s", g_client_org_nickname[client]);
5550 // Donor medic
5551 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5552 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][MG] %s", g_client_org_nickname[client]);
5553 // Normal medic
5554 else
5555 Format(sNewNickname, sizeof(sNewNickname), "[MG] %s", g_client_org_nickname[client]);
5556 }
5557 else if (StrContains(g_client_last_classstring[client], "rifleman_at") > -1)
5558 {
5559 // Admin medic
5560 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5561 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][AT] %s", g_client_org_nickname[client]);
5562 // Donor medic
5563 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5564 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][AT] %s", g_client_org_nickname[client]);
5565 // Normal medic
5566 else
5567 Format(sNewNickname, sizeof(sNewNickname), "[AT] %s", g_client_org_nickname[client]);
5568 }
5569 else if (StrContains(g_client_last_classstring[client], "vip") > -1)
5570 {
5571 // Admin medic
5572 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5573 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][VIP] %s", g_client_org_nickname[client]);
5574 // Donor medic
5575 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5576 Format(sNewNickname, sizeof(sNewNickname), "[DONOR][VIP] %s", g_client_org_nickname[client]);
5577 // Normal medic
5578 else
5579 Format(sNewNickname, sizeof(sNewNickname), "[VIP] %s", g_client_org_nickname[client]);
5580 }
5581 // Normal class
5582 else
5583 {
5584 // Admin
5585 if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
5586 Format(sNewNickname, sizeof(sNewNickname), "[ADMIN] %s", g_client_org_nickname[client]);
5587 // Donor
5588 else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
5589 Format(sNewNickname, sizeof(sNewNickname), "[DONOR] %s", g_client_org_nickname[client]);
5590 // Normal player
5591 else
5592 Format(sNewNickname, sizeof(sNewNickname), "%s", g_client_org_nickname[client]);
5593 }
5594
5595 // Set player nickname
5596 decl String:sCurNickname[64];
5597 Format(sCurNickname, sizeof(sCurNickname), "%N", client);
5598 if (!StrEqual(sCurNickname, sNewNickname))
5599 SetClientName(client, sNewNickname);
5600
5601 g_playersReady = true;
5602
5603 //Allow new players to use lives to respawn on join
5604 if (g_iRoundStatus == 1 && g_playerFirstJoin[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
5605 {
5606 // Get SteamID to verify is player has connected before.
5607 decl String:steamId[64];
5608 //GetClientAuthString(client, steamId, sizeof(steamId));
5609 GetClientAuthId(client, AuthId_Steam3, steamId, sizeof(steamId));
5610 new isPlayerNew = FindStringInArray(g_playerArrayList, steamId);
5611
5612 if (isPlayerNew != -1)
5613 {
5614 //PrintToServer("Player %N has reconnected! | SteamID: %s | Index: %d", client, steamId, isPlayerNew); // commented by oz
5615 }
5616 else
5617 {
5618 PushArrayString(g_playerArrayList, steamId);
5619 //PrintToServer("Player %N is new! | SteamID: %s | PlayerArrayList Size: %d", client, steamId, GetArraySize(g_playerArrayList)); // commented by oz
5620 // Give individual lives to new player (no longer just at beginning of round)
5621 if (g_iCvar_respawn_type_team_sec == 1)
5622 {
5623 if (g_isCheckpoint && g_iCvar_respawn_reset_type == 0)
5624 {
5625 // The number of control points
5626 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
5627 // Active control poin
5628 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
5629 new tLiveSec = GetConVarInt(sm_respawn_lives_team_sec);
5630
5631 if (acp <= (ncp / 2))
5632 g_iSpawnTokens[client] = tLiveSec;
5633 else
5634 g_iSpawnTokens[client] = (tLiveSec / 2);
5635
5636 if (tLiveSec < 1)
5637 {
5638 tLiveSec = 1;
5639 g_iSpawnTokens[client] = tLiveSec;
5640 }
5641 }
5642 else
5643 g_iSpawnTokens[client] = GetConVarInt(sm_respawn_lives_team_sec);
5644
5645
5646 }
5647 CreatePlayerRespawnTimer(client);
5648 }
5649 }
5650
5651 //Assign VIP (Credits INS Server)
5652 if(StrContains(class_template, "vip") > -1)
5653 {
5654 g_nVIP_ID = client;
5655 }
5656
5657 if((client == g_nVIP_ID) && (StrContains(class_template, "vip") == -1))
5658 {
5659 g_nVIP_ID = 0;
5660 }
5661
5662 //Update RespawnCvars when player picks squad
5663 UpdateRespawnCvars();
5664}
5665
5666// Triggers when player hurt
5667public Action:Event_PlayerHurt_Pre(Handle:event, const String:name[], bool:dontBroadcast)
5668{
5669 new victim = GetClientOfUserId(GetEventInt(event, "userid"));
5670 if (IsClientInGame(victim) && IsFakeClient(victim))
5671 return Plugin_Continue;
5672
5673 new victimHealth = GetEventInt(event, "health");
5674 new dmg_taken = GetEventInt(event, "dmg_health");
5675 //PrintToServer("victimHealth: %d, dmg_taken: %d", victimHealth, dmg_taken);
5676 if (g_fCvar_fatal_chance > 0.0 && dmg_taken > victimHealth)
5677 {
5678 // Get information for event structure
5679 new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
5680 new hitgroup = GetEventInt(event, "hitgroup");
5681
5682 // Update last damege (related to 'hurt_fatal')
5683 g_clientDamageDone[victim] = dmg_taken;
5684
5685 // Get weapon
5686 decl String:weapon[32];
5687 GetEventString(event, "weapon", weapon, sizeof(weapon));
5688
5689 //PrintToServer("[DAMAGE TAKEN] Weapon used: %s, Damage done: %i",weapon, dmg_taken);
5690
5691 // Check is team attack
5692 new attackerTeam;
5693 if (attacker > 0 && IsClientInGame(attacker) && IsClientConnected(attacker))
5694 attackerTeam = GetClientTeam(attacker);
5695
5696 // Get fatal chance
5697 new Float:fRandom = GetRandomFloat(0.0, 1.0);
5698
5699 // Is client valid
5700 if (IsClientInGame(victim))
5701 {
5702
5703 // Explosive
5704 if (hitgroup == 0)
5705 {
5706 //explosive list
5707 //incens
5708 //grenade_molotov, grenade_anm14
5709 //PrintToServer("[HITGROUP HURT BURN]");
5710 //grenade_m67, grenade_f1, grenade_ied, grenade_c4, rocket_rpg7, rocket_at4, grenade_gp25_he, grenade_m203_he
5711 // flame
5712 if (StrEqual(weapon, "grenade_anm14", false) || StrEqual(weapon, "grenade_molotov", false))
5713 {
5714 //PrintToServer("[SUICIDE] incen/molotov DETECTED!");
5715 if (dmg_taken >= g_iCvar_fatal_burn_dmg && (fRandom <= g_fCvar_fatal_chance))
5716 {
5717 // Hurt fatally
5718 g_iHurtFatal[victim] = 1;
5719
5720 //PrintToServer("[PLAYER HURT BURN]");
5721 }
5722 }
5723 // explosive
5724 else if (StrEqual(weapon, "grenade_m67", false) ||
5725 StrEqual(weapon, "grenade_f1", false) ||
5726 StrEqual(weapon, "grenade_ied", false) ||
5727 StrEqual(weapon, "grenade_c4", false) ||
5728 StrEqual(weapon, "rocket_rpg7", false) ||
5729 StrEqual(weapon, "rocket_at4", false) ||
5730 StrEqual(weapon, "grenade_gp25_he", false) ||
5731 StrEqual(weapon, "grenade_m203_he", false))
5732 {
5733 //PrintToServer("[HITGROUP HURT EXPLOSIVE]");
5734 if (dmg_taken >= g_iCvar_fatal_explosive_dmg && (fRandom <= g_fCvar_fatal_chance))
5735 {
5736 // Hurt fatally
5737 g_iHurtFatal[victim] = 1;
5738
5739 //PrintToServer("[PLAYER HURT EXPLOSIVE]");
5740 }
5741 }
5742 //PrintToServer("[SUICIDE] HITRGOUP 0 [GENERIC]");
5743 }
5744 // Headshot
5745 else if (hitgroup == 1)
5746 {
5747 //PrintToServer("[PLAYER HURT HEAD]");
5748 if (dmg_taken >= g_iCvar_fatal_head_dmg && (fRandom <= g_fCvar_fatal_head_chance) && attackerTeam != TEAM_1_SEC)
5749 {
5750 // Hurt fatally
5751 g_iHurtFatal[victim] = 1;
5752
5753 //PrintToServer("[BOTSPAWNS] BOOM HEADSHOT");
5754 }
5755 }
5756 // Chest
5757 else if (hitgroup == 2 || hitgroup == 3)
5758 {
5759 //PrintToServer("[HITGROUP HURT CHEST]");
5760 if (dmg_taken >= g_iCvar_fatal_chest_stomach && (fRandom <= g_fCvar_fatal_chance))
5761 {
5762 // Hurt fatally
5763 g_iHurtFatal[victim] = 1;
5764
5765 //PrintToServer("[PLAYER HURT CHEST]");
5766 }
5767 }
5768 // Limbs
5769 else if (hitgroup == 4 || hitgroup == 5 || hitgroup == 6 || hitgroup == 7)
5770 {
5771 //PrintToServer("[HITGROUP HURT LIMBS]");
5772 if (dmg_taken >= g_iCvar_fatal_limb_dmg && (fRandom <= g_fCvar_fatal_chance))
5773 {
5774 // Hurt fatally
5775 g_iHurtFatal[victim] = 1;
5776
5777 //PrintToServer("[PLAYER HURT LIMBS]");
5778 }
5779 }
5780 }
5781 }
5782 //Track wound type (minor, moderate, critical)
5783 if (g_iHurtFatal[victim] != 1)
5784 {
5785 if (dmg_taken <= g_minorWound_dmg)
5786 {
5787 g_playerWoundTime[victim] = g_minorRevive_time;
5788 g_playerWoundType[victim] = 0;
5789 }
5790 else if (dmg_taken > g_minorWound_dmg && dmg_taken <= g_moderateWound_dmg)
5791 {
5792 g_playerWoundTime[victim] = g_modRevive_time;
5793 g_playerWoundType[victim] = 1;
5794 }
5795 else if (dmg_taken > g_moderateWound_dmg)
5796 {
5797 g_playerWoundTime[victim] = g_critRevive_time;
5798 g_playerWoundType[victim] = 2;
5799 }
5800 }
5801 else
5802 {
5803 g_playerWoundTime[victim] = -1;
5804 g_playerWoundType[victim] = -1;
5805 }
5806
5807
5808
5809 ////////////////////////
5810 // Rank System
5811 new attackerId = GetEventInt(event, "attacker");
5812 new hitgroup = GetEventInt(event,"hitgroup");
5813
5814 new attacker = GetClientOfUserId(attackerId);
5815
5816 if ( hitgroup == 1 )
5817 {
5818 g_iStatHeadShots[attacker]++;
5819 }
5820 ////////////////////////
5821
5822 return Plugin_Continue;
5823}
5824
5825// Trigged when player die PRE
5826public Action:Event_PlayerDeath_Pre(Handle:event, const String:name[], bool:dontBroadcast)
5827{
5828 new client = GetClientOfUserId(GetEventInt(event, "userid"));
5829 // Tracking ammo
5830 if (g_iEnableRevive == 1 && g_iRoundStatus == 1 && g_iCvar_enable_track_ammo == 1)
5831 {
5832 //PrintToChatAll("### GET PLAYER WEAPONS ###");
5833 //CONSIDER IF PLAYER CHOOSES DIFFERENT CLASS
5834 // Get weapons
5835 new primaryWeapon = GetPlayerWeaponSlot(client, 0);
5836 new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
5837 //new playerGrenades = GetPlayerWeaponSlot(client, 3);
5838
5839 // Set weapons to variables
5840 playerPrimary[client] = primaryWeapon;
5841 playerSecondary[client] = secondaryWeapon;
5842
5843 //Get ammo left in clips for primary and secondary
5844 playerClip[client][0] = GetPrimaryAmmo(client, primaryWeapon, 0);
5845 playerClip[client][1] = GetPrimaryAmmo(client, secondaryWeapon, 1); // m_iClip2 for secondary if this doesnt work? would need GetSecondaryAmmo
5846
5847 if (!playerInRevivedState[client])
5848 {
5849 //Get Magazines left on player
5850 if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
5851 Client_GetWeaponPlayerAmmoEx(client, primaryWeapon, playerAmmo[client][0]); //primary
5852 if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon))
5853 Client_GetWeaponPlayerAmmoEx(client, secondaryWeapon, playerAmmo[client][1]); //secondary
5854 }
5855 playerInRevivedState[client] = false;
5856 //PrintToServer("PlayerClip_1 %i, PlayerClip_2 %i, playerAmmo_1 %i, playerAmmo_2 %i, playerGrenades %i",playerClip[client][0], playerClip[client][1], playerAmmo[client][0], playerAmmo[client][1], playerAmmo[client][2]);
5857 // if (playerGrenades != -1 && IsValidEntity(playerGrenades))
5858 // {
5859 // playerGrenadeType[victim][0] = GetGrenadeAmmo(victim, Gren_M67);
5860 // playerGrenadeType[victim][1] = GetGrenadeAmmo(victim, Gren_Incen);
5861 // playerGrenadeType[victim][2] = GetGrenadeAmmo(victim, Gren_Molot);
5862 // playerGrenadeType[victim][3] = GetGrenadeAmmo(victim, Gren_M18);
5863 // playerGrenadeType[victim][4] = GetGrenadeAmmo(victim, Gren_Flash);
5864 // playerGrenadeType[victim][5] = GetGrenadeAmmo(victim, Gren_F1);
5865 // playerGrenadeType[victim][6] = GetGrenadeAmmo(victim, Gren_IED);
5866 // playerGrenadeType[victim][7] = GetGrenadeAmmo(victim, Gren_C4);
5867 // playerGrenadeType[victim][8] = GetGrenadeAmmo(victim, Gren_AT4);
5868 // playerGrenadeType[victim][9] = GetGrenadeAmmo(victim, Gren_RPG7);
5869 // }
5870 }
5871
5872}
5873// Trigged when player die
5874public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
5875{
5876 ////////////////////////
5877 // Rank System
5878 new victimId = GetEventInt(event, "userid");
5879 new attackerId = GetEventInt(event, "attacker");
5880
5881 new victim = GetClientOfUserId(victimId);
5882 new attacker = GetClientOfUserId(attackerId);
5883
5884 if(victim != attacker){
5885 g_iStatKills[attacker]++;
5886 g_iStatDeaths[victim]++;
5887
5888 } else {
5889 g_iStatSuicides[victim]++;
5890 g_iStatDeaths[victim]++;
5891 }
5892
5893 ////////////////////////
5894
5895 // Get player ID
5896 new client = GetClientOfUserId(GetEventInt(event, "userid"));
5897
5898 g_iPlayerBGroups[client] = GetEntProp(client, Prop_Send, "m_nBody");
5899
5900 //PrintToServer("BodyGroups: %d", g_iPlayerBGroups[client]);
5901
5902 // Check client valid
5903 if (!IsClientInGame(client)) return Plugin_Continue;
5904
5905 // Set variable
5906 new dmg_taken = GetEventInt(event, "damagebits");
5907 if (dmg_taken <= 0)
5908 {
5909 g_playerWoundTime[client] = g_minorRevive_time;
5910 g_playerWoundType[client] = 0;
5911 }
5912 //PrintToServer("[PLAYERDEATH] Client %N has %d lives remaining", client, g_iSpawnTokens[client]);
5913
5914 // Get gamemode
5915 decl String:sGameMode[32];
5916 GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
5917 new team = GetClientTeam(client);
5918 new attackerTeam = GetClientTeam(attacker);
5919
5920 //AI Director START
5921 //Bot Team AD Status
5922 if (team == TEAM_2_INS && g_iRoundStatus == 1 && attackerTeam == TEAM_1_SEC)
5923 {
5924 //Bonus point for specialty bots
5925 if (AI_Director_IsSpecialtyBot(client))
5926 g_AIDir_TeamStatus += 1;
5927
5928 g_AIDir_BotsKilledCount++;
5929 if (g_AIDir_BotsKilledCount > (GetTeamSecCount() / g_AIDir_BotsKilledReq_mult))
5930 {
5931 g_AIDir_BotsKilledCount = 0;
5932 g_AIDir_TeamStatus += 1;
5933 }
5934 }
5935 //Player Team AD STATUS
5936 if (team == TEAM_1_SEC && g_iRoundStatus == 1)
5937 {
5938 if (g_iHurtFatal[client] == 1)
5939 g_AIDir_TeamStatus -= 3;
5940 else
5941 g_AIDir_TeamStatus -= 2;
5942
5943 if ((StrContains(g_client_last_classstring[client], "medic") > -1))
5944 g_AIDir_TeamStatus -= 3;
5945
5946 }
5947
5948 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
5949
5950 //AI Director END
5951
5952 if (g_iCvar_revive_enable)
5953 {
5954 // Convert ragdoll
5955 if (team == TEAM_1_SEC)
5956 {
5957 // Get current position
5958 decl Float:vecPos[3];
5959 GetClientAbsOrigin(client, Float:vecPos);
5960 g_fDeadPosition[client] = vecPos;
5961
5962 // Call ragdoll timer
5963 if (g_iEnableRevive == 1 && g_iRoundStatus == 1)
5964 CreateTimer(5.0, ConvertDeleteRagdoll, client);
5965 }
5966 }
5967 // Check enables
5968 if (g_iCvar_respawn_enable)
5969 {
5970
5971 // Client should be TEAM_1_SEC = HUMANS or TEAM_2_INS = BOTS
5972 if ((team == TEAM_1_SEC) || (team == TEAM_2_INS))
5973 {
5974 // The number of control points
5975 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
5976
5977 // Active control poin
5978 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
5979
5980 // Do not decrease life in counterattack
5981 if (g_isCheckpoint == 1 && Ins_InCounterAttack() &&
5982 (((acp+1) == ncp && g_iCvar_final_counterattack_type == 2) ||
5983 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))
5984 )
5985 {
5986 // Respawn type 1 bots
5987 if ((g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS) &&
5988 (((acp+1) == ncp && g_iCvar_final_counterattack_type == 2) ||
5989 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))
5990 )
5991 {
5992 if ((g_iSpawnTokens[client] < g_iRespawnCount[team]))
5993 g_iSpawnTokens[client] = (g_iRespawnCount[team] + 1);
5994
5995 // Call respawn timer
5996 CreateBotRespawnTimer(client);
5997 }
5998 // Respawn type 1 player (individual lives)
5999 else if (g_iCvar_respawn_type_team_sec == 1 && team == TEAM_1_SEC)
6000 {
6001 if (g_iSpawnTokens[client] > 0)
6002 {
6003 if (team == TEAM_1_SEC)
6004 {
6005 CreatePlayerRespawnTimer(client);
6006 }
6007 }
6008 else if (g_iSpawnTokens[client] <= 0 && g_iRespawnCount[team] > 0)
6009 {
6010 // Cannot respawn anymore
6011 decl String:sChat[128];
6012 Format(sChat, 128,"You cannot be respawned anymore. (out of lives)");
6013 PrintToChat(client, "%s", sChat);
6014 }
6015 }
6016 // Respawn type 2 for players
6017 else if (team == TEAM_1_SEC && g_iCvar_respawn_type_team_sec == 2 && g_iRespawn_lives_team_sec > 0)
6018 {
6019 g_iRemaining_lives_team_sec = g_iRespawn_lives_team_sec + 1;
6020
6021 // Call respawn timer
6022 CreateCounterRespawnTimer(client);
6023 }
6024 // Respawn type 2 for bots
6025 else if (team == TEAM_2_INS && g_iCvar_respawn_type_team_ins == 2 &&
6026 (g_iRespawn_lives_team_ins > 0 ||
6027 ((acp+1) == ncp && g_iCvar_final_counterattack_type == 2) ||
6028 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))
6029 )
6030 {
6031 g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins + 1;
6032
6033 // Call respawn timer
6034 CreateBotRespawnTimer(client);
6035 }
6036 }
6037 // Normal respawn
6038 else if ((g_iCvar_respawn_type_team_sec == 1 && team == TEAM_1_SEC) || (g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS))
6039 {
6040 if (g_iSpawnTokens[client] > 0)
6041 {
6042 if (team == TEAM_1_SEC)
6043 {
6044 CreatePlayerRespawnTimer(client);
6045 }
6046 else if (team == TEAM_2_INS)
6047 {
6048 CreateBotRespawnTimer(client);
6049 }
6050 }
6051 else if (g_iSpawnTokens[client] <= 0 && g_iRespawnCount[team] > 0)
6052 {
6053 // Cannot respawn anymore
6054 decl String:sChat[128];
6055 Format(sChat, 128,"You cannot be respawned anymore. (out of lives)");
6056 //PrintToChat(client, "%s", sChat); - commented out by oz
6057 }
6058 }
6059 // Respawn type 2 for players
6060 else if (g_iCvar_respawn_type_team_sec == 2 && team == TEAM_1_SEC)
6061 {
6062 if (g_iRemaining_lives_team_sec > 0)
6063 {
6064 CreatePlayerRespawnTimer(client);
6065 }
6066 else if (g_iRemaining_lives_team_sec <= 0 && g_iRespawn_lives_team_sec > 0)
6067 {
6068 // Cannot respawn anymore
6069 decl String:sChat[128];
6070 Format(sChat, 128,"You cannot be respawned anymore. (out of team lives)");
6071 //PrintToChat(client, "%s", sChat); - commented out by oz
6072 }
6073 }
6074 // Respawn type 2 for bots
6075 else if (g_iCvar_respawn_type_team_ins == 2 && g_iRemaining_lives_team_ins > 0 && team == TEAM_2_INS)
6076 {
6077 CreateBotRespawnTimer(client);
6078 }
6079 }
6080 }
6081
6082 // Init variables
6083 decl String:wound_hint[64];
6084 decl String:fatal_hint[64];
6085 decl String:woundType[64];
6086 if (g_playerWoundType[client] == 0)
6087 woundType = "MINORLY WOUNDED";
6088 else if (g_playerWoundType[client] == 1)
6089 woundType = "MODERATELY WOUNDED";
6090 else if (g_playerWoundType[client] == 2)
6091 woundType = "CRITCALLY WOUNDED";
6092
6093 // Display death message
6094 if (g_fCvar_fatal_chance > 0.0)
6095 {
6096 if (g_iHurtFatal[client] == 1 && !IsFakeClient(client))
6097 {
6098 Format(fatal_hint, 255,"You were fatally killed for %i damage", g_clientDamageDone[client]);
6099 //PrintHintText(client, "%s", fatal_hint); - commented out by oz
6100 //PrintToChat(client, "%s", fatal_hint); - commented out by oz
6101 }
6102 else
6103 {
6104 Format(wound_hint, 255,"You're %s for %i damage, call a medic for revive!", woundType, g_clientDamageDone[client]);
6105 //PrintHintText(client, "%s", wound_hint); - commented out by oz
6106 //PrintToChat(client, "%s", wound_hint); - commented out by oz
6107 }
6108 }
6109 else
6110 {
6111 Format(wound_hint, 255,"You're %s for %i damage, call a medic for revive!", woundType, g_clientDamageDone[client]);
6112 //PrintHintText(client, "%s", wound_hint); - commented out by oz
6113 //PrintToChat(client, "%s", wound_hint); - commented out by oz
6114 }
6115
6116
6117 // Update remaining life
6118 new Handle:hCvar = INVALID_HANDLE;
6119 new iRemainingLife = GetRemainingLife();
6120 hCvar = FindConVar("sm_remaininglife");
6121 SetConVarInt(hCvar, iRemainingLife);
6122 return Plugin_Continue;
6123}
6124
6125// Convert dead body to new ragdoll
6126public Action:ConvertDeleteRagdoll(Handle:Timer, any:client)
6127{
6128 if (IsClientInGame(client) && g_iRoundStatus == 1 && !IsPlayerAlive(client))
6129 {
6130 //PrintToServer("CONVERT RAGDOLL********************");
6131 //new clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
6132 //TeleportEntity(clientRagdoll, g_fDeadPosition[client], NULL_VECTOR, NULL_VECTOR);
6133
6134 // Get dead body
6135 new clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
6136
6137 //This timer safely removes client-side ragdoll
6138 if(clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && g_iEnableRevive == 1)
6139 {
6140 // Get dead body's entity
6141 new ref = EntIndexToEntRef(clientRagdoll);
6142 new entity = EntRefToEntIndex(ref);
6143 if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
6144 {
6145 // Remove dead body's entity
6146 AcceptEntityInput(entity, "Kill");
6147 clientRagdoll = INVALID_ENT_REFERENCE;
6148 }
6149 }
6150
6151 // Check is fatally dead
6152 if (g_iHurtFatal[client] != 1)
6153 {
6154 // Create new ragdoll
6155 new tempRag = CreateEntityByName("prop_ragdoll");
6156
6157 // Set client's new ragdoll
6158 g_iClientRagdolls[client] = EntIndexToEntRef(tempRag);
6159
6160 // Set position
6161 g_fDeadPosition[client][2] = g_fDeadPosition[client][2] + 50;
6162
6163 // If success initialize ragdoll
6164 if(tempRag != -1)
6165 {
6166 // Get model name
6167 decl String:sModelName[64];
6168 GetClientModel(client, sModelName, sizeof(sModelName));
6169
6170 // Set model
6171 SetEntityModel(tempRag, sModelName);
6172 DispatchSpawn(tempRag);
6173
6174 // Set collisiongroup
6175 SetEntProp(tempRag, Prop_Send, "m_CollisionGroup", 17);
6176 //Set bodygroups for ragdoll
6177 SetEntProp(tempRag, Prop_Send, "m_nBody", g_iPlayerBGroups[client]);
6178
6179 // Teleport to current position
6180 TeleportEntity(tempRag, g_fDeadPosition[client], NULL_VECTOR, NULL_VECTOR);
6181
6182 // Set vector
6183 GetEntPropVector(tempRag, Prop_Send, "m_vecOrigin", g_fRagdollPosition[client]);
6184
6185 // Set revive time remaining
6186 g_iReviveRemainingTime[client] = g_playerWoundTime[client];
6187 g_iReviveNonMedicRemainingTime[client] = g_nonMedRevive_time;
6188 // Start revive checking timer
6189 /*
6190 new Handle:revivePack;
6191 CreateDataTimer(1.0 , Timer_RevivePeriod, revivePack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
6192 WritePackCell(revivePack, client);
6193 WritePackCell(revivePack, tempRag);
6194 */
6195 }
6196 else
6197 {
6198 // If failed to create ragdoll, remove entity
6199 if(tempRag > 0 && IsValidEdict(tempRag) && IsValidEntity(tempRag))
6200 RemoveRagdoll(client);
6201 }
6202 }
6203 }
6204}
6205
6206// Remove ragdoll
6207void RemoveRagdoll(client)
6208{
6209 //new ref = EntIndexToEntRef(g_iClientRagdolls[client]);
6210 new entity = EntRefToEntIndex(g_iClientRagdolls[client]);
6211 if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
6212 {
6213 AcceptEntityInput(entity, "Kill");
6214 g_iClientRagdolls[client] = INVALID_ENT_REFERENCE;
6215 }
6216}
6217
6218// This handles revives by medics
6219public CreateReviveTimer(client)
6220{
6221 CreateTimer(0.0, RespawnPlayerRevive, client);
6222}
6223
6224// Handles spawns when counter attack starts
6225public CreateCounterRespawnTimer(client)
6226{
6227 CreateTimer(0.0, RespawnPlayerCounter, client);
6228}
6229
6230// Respawn bot
6231public CreateBotRespawnTimer(client)
6232{
6233 if ((g_cqc_map_enabled == 1 && Ins_InCounterAttack() && ((StrContains(g_client_last_classstring[client], "bomber") > -1) ||
6234 (StrContains(g_client_last_classstring[client], "juggernaut") > -1))) ||
6235 (!Ins_InCounterAttack() && ((StrContains(g_client_last_classstring[client], "bomber") > -1) ||
6236 (StrContains(g_client_last_classstring[client], "juggernaut") > -1)))) //make sure its a bot bomber
6237 {
6238 //new fRandomFloat = GetRandomFloat(0.0, 1.0); - commented by oz, symbol never used?
6239 //new tSpecRespawnDelay = 0; - commented by oz, symbol never used?
6240
6241 if (g_cqc_map_enabled == 1 && Ins_InCounterAttack())
6242 {
6243 if (StrContains(g_client_last_classstring[client], "bomber") > -1)
6244 {
6245 //PrintToServer("BOMBER SPAWN: Delay %f", (g_fCvar_respawn_delay_team_ins_spec / 3)); // commented by oz
6246 CreateTimer((g_fCvar_respawn_delay_team_ins_spec / 3), RespawnBot, client);
6247 }
6248 else if (StrContains(g_client_last_classstring[client], "juggernaut") > -1)
6249 {
6250 //PrintToServer("JUGGER SPAWN: Delay %f", (g_fCvar_respawn_delay_team_ins_spec / 4)); // commented by oz
6251 CreateTimer((g_fCvar_respawn_delay_team_ins_spec / 4), RespawnBot, client);
6252 }
6253 }
6254 else
6255 {
6256 if (StrContains(g_client_last_classstring[client], "bomber") > -1)
6257 {
6258 CreateTimer((g_fCvar_respawn_delay_team_ins_spec * 2), RespawnBot, client);
6259 }
6260 else if (StrContains(g_client_last_classstring[client], "juggernaut") > -1)
6261 {
6262 CreateTimer((g_fCvar_respawn_delay_team_ins_spec), RespawnBot, client);
6263 }
6264 }
6265 }
6266 else
6267 CreateTimer(g_fCvar_respawn_delay_team_ins, RespawnBot, client);
6268
6269}
6270
6271// Respawn player
6272public CreatePlayerRespawnTimer(client)
6273{
6274 // Check is respawn timer active
6275 if (g_iPlayerRespawnTimerActive[client] == 0)
6276 {
6277 // Set timer active
6278 g_iPlayerRespawnTimerActive[client] = 1;
6279
6280 new validAntenna = -1;
6281 validAntenna = FindValid_Antenna();
6282
6283 // Set remaining timer for respawn
6284 if (validAntenna != -1)
6285 {
6286 new timeReduce = (GetTeamSecCount() / 3);
6287 if (timeReduce <= 0)
6288 timeReduce = 3;
6289
6290 new jammerSpawnReductionAmt = (g_iRespawnSeconds / timeReduce);
6291
6292 g_iRespawnTimeRemaining[client] = (g_iRespawnSeconds - jammerSpawnReductionAmt);
6293 if (g_iRespawnTimeRemaining[client] < 5)
6294 g_iRespawnTimeRemaining[client] = 5;
6295 }
6296 else
6297 g_iRespawnTimeRemaining[client] = g_iRespawnSeconds;
6298
6299 //Sync wave based timer if enabled
6300 if (g_respawn_mode_team_sec)
6301 g_iRespawnTimeRemaining[client] = g_secWave_Timer;
6302
6303 // Call respawn timer
6304 CreateTimer(1.0, Timer_PlayerRespawn, client, TIMER_REPEAT);
6305 }
6306}
6307
6308// Revive player
6309public Action:RespawnPlayerRevive(Handle:Timer, any:client)
6310{
6311 // Exit if client is not in game
6312 if (!IsClientInGame(client)) return;
6313 if (IsPlayerAlive(client) || g_iRoundStatus == 0) return;
6314
6315 //PrintToServer("[REVIVE_RESPAWN] REVIVING client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
6316 // Call forcerespawn fucntion
6317 SDKCall(g_hForceRespawn, client);
6318
6319 // If set 'sm_respawn_enable_track_ammo', restore player's ammo
6320 if (playerRevived[client] == true && g_iCvar_enable_track_ammo == 1)
6321 {
6322 playerInRevivedState[client] = true;
6323 //SetPlayerAmmo(client); //AmmoResupply_Player(client, 0, 0, 1);
6324
6325 }
6326
6327 //Set wound health
6328 new iHealth = GetClientHealth(client);
6329 if (g_playerNonMedicRevive[client] == 0)
6330 {
6331 if (g_playerWoundType[client] == 0)
6332 iHealth = g_minorWoundRevive_hp;
6333 else if (g_playerWoundType[client] == 1)
6334 iHealth = g_modWoundRevive_hp;
6335 else if (g_playerWoundType[client] == 2)
6336 iHealth = g_critWoundRevive_hp;
6337 }
6338 else if (g_playerNonMedicRevive[client] == 1)
6339 {
6340 //NonMedic Revived
6341 iHealth = g_nonMedicRevive_hp;
6342 }
6343
6344 SetEntityHealth(client, iHealth);
6345
6346 // Get player's ragdoll
6347 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
6348
6349 //Remove network ragdoll
6350 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
6351 RemoveRagdoll(client);
6352
6353 //Do the post-spawn stuff like moving to final "spawnpoint" selected
6354 //CreateTimer(0.0, RespawnPlayerRevivePost, client);
6355 RespawnPlayerRevivePost(INVALID_HANDLE, client);
6356 if ((StrContains(g_client_last_classstring[client], "medic") > -1))
6357 g_AIDir_TeamStatus += 2;
6358 else
6359 g_AIDir_TeamStatus += 1;
6360
6361 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
6362
6363
6364}
6365
6366// Do post revive stuff
6367public Action:RespawnPlayerRevivePost(Handle:timer, any:client)
6368{
6369 // Exit if client is not in game
6370 if (!IsClientInGame(client)) return;
6371
6372 //PrintToServer("[REVIVE_DEBUG] called RespawnPlayerRevivePost for client %N (%d)",client,client);
6373 TeleportEntity(client, g_fRagdollPosition[client], NULL_VECTOR, NULL_VECTOR);
6374
6375 // Reset ragdoll position
6376 g_fRagdollPosition[client][0] = 0.0;
6377 g_fRagdollPosition[client][1] = 0.0;
6378 g_fRagdollPosition[client][2] = 0.0;
6379}
6380
6381// Respawn player in counter attack
6382public Action:RespawnPlayerCounter(Handle:Timer, any:client)
6383{
6384 // Exit if client is not in game
6385 if (!IsClientInGame(client)) return;
6386 if (IsPlayerAlive(client) || g_iRoundStatus == 0) return;
6387
6388 //PrintToServer("[Counter Respawn] Respawning client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
6389 // Call forcerespawn fucntion
6390 SDKCall(g_hForceRespawn, client);
6391
6392 // Get player's ragdoll
6393 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
6394
6395 //Remove network ragdoll
6396 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
6397 RemoveRagdoll(client);
6398
6399 // If set 'sm_respawn_enable_track_ammo', restore player's ammo
6400 // Get the number of control points
6401 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
6402 // Get active push point
6403 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
6404
6405 //Remove grenades if not finale
6406 if ((acp+1) != ncp)
6407 RemoveWeapons(client, 0, 0, 1);
6408
6409 // Teleport to avtive counter attack point
6410 //PrintToServer("[REVIVE_DEBUG] called RespawnPlayerPost for client %N (%d)",client,client);
6411 if (g_fRespawnPosition[0] != 0.0 && g_fRespawnPosition[1] != 0.0 && g_fRespawnPosition[2] != 0.0)
6412 TeleportEntity(client, g_fRespawnPosition, NULL_VECTOR, NULL_VECTOR);
6413
6414 // Reset ragdoll position
6415 g_fRagdollPosition[client][0] = 0.0;
6416 g_fRagdollPosition[client][1] = 0.0;
6417 g_fRagdollPosition[client][2] = 0.0;
6418}
6419
6420
6421// Respawn bot
6422public Action:RespawnBot(Handle:Timer, any:client)
6423{
6424
6425 // Exit if client is not in game
6426 if (IsPlayerAlive(client) || !IsClientInGame(client) || g_iRoundStatus == 0) return;
6427
6428 decl String:sModelName[64];
6429 GetClientModel(client, sModelName, sizeof(sModelName));
6430 if (StrEqual(sModelName, ""))
6431 {
6432 //PrintToServer("Invalid model: %s", sModelName);
6433 return; //check if model is blank
6434 }
6435 else
6436 {
6437 //PrintToServer("Valid model: %s", sModelName);
6438 }
6439
6440 // Check respawn type
6441 if (g_iCvar_respawn_type_team_ins == 1 && g_iSpawnTokens[client] > 0)
6442 g_iSpawnTokens[client]--;
6443 else if (g_iCvar_respawn_type_team_ins == 2)
6444 {
6445 if (g_iRemaining_lives_team_ins > 0)
6446 {
6447 g_iRemaining_lives_team_ins--;
6448
6449 if (g_iRemaining_lives_team_ins <= 0)
6450 g_iRemaining_lives_team_ins = 0;
6451 //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
6452 }
6453 }
6454 //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
6455 //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
6456 //PrintToServer("[RESPAWN] Respawning client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
6457
6458 // Call forcerespawn fucntion
6459 SDKCall(g_hForceRespawn, client);
6460
6461 //ins_spawnpoint forcerespawn
6462 //TeleportClient(client);
6463
6464 //Do the post-spawn stuff like moving to final "spawnpoint" selected
6465 // if (g_iCvar_SpawnMode == 1)
6466 // {
6467 // //CreateTimer(0.0, RespawnBotPost, client);
6468 // RespawnBotPost(INVALID_HANDLE, client);
6469 // }
6470
6471}
6472
6473//Handle any work that needs to happen after the client is in the game
6474//Funcion commented out by oz but body already commented out
6475//public Action:RespawnBotPost(Handle:timer, any:client)
6476//{
6477 /*
6478 // Exit if client is not in game
6479 if (!IsClientInGame(client)) return;
6480
6481 //PrintToServer("[BOTSPAWNS] called RespawnBotPost for client %N (%d)",client,client);
6482 //g_iSpawning[client] = 0;
6483
6484 if ((g_iHidingSpotCount) && !Ins_InCounterAttack())
6485 {
6486 //PrintToServer("[BOTSPAWNS] HAS g_iHidingSpotCount COUNT");
6487
6488 //Older Nav Spawning
6489 // Get hiding point - Nav Spawning - Commented for Rehaul
6490 new Float:flHidingSpot[3];
6491 new iSpot = GetBestHidingSpot(client);
6492
6493 //PrintToServer("[BOTSPAWNS] FOUND Hiding spot %d",iSpot);
6494
6495 //If found hiding spot
6496 if (iSpot > -1)
6497 {
6498 // Set hiding spot
6499 flHidingSpot[0] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_X);
6500 flHidingSpot[1] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_Y);
6501 flHidingSpot[2] = GetArrayCell(g_hHidingSpots, iSpot, NavMeshHidingSpot_Z);
6502
6503 // Debug message
6504 //new Float:vecOrigin[3];
6505 //GetClientAbsOrigin(client,vecOrigin);
6506 //new Float:distance = GetVectorDistance(flHidingSpot,vecOrigin);
6507 //PrintToServer("[BOTSPAWNS] Teleporting %N to hiding spot %d at %f,%f,%f distance %f", client, iSpot, flHidingSpot[0], flHidingSpot[1], flHidingSpot[2], distance);
6508
6509 // Teleport to hiding spot
6510 TeleportEntity(client, flHidingSpot, NULL_VECTOR, NULL_VECTOR);
6511 }
6512 }
6513 */
6514
6515//}
6516// Monitor player reload and set ammo after each reload
6517public Action:Timer_ForceReload(Handle:Timer, any:client)
6518{
6519 new bool:isReloading = Client_IsReloading(client);
6520 new primaryWeapon = GetPlayerWeaponSlot(client, 0);
6521 new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
6522
6523 if (IsPlayerAlive(client) && g_iRoundStatus == 1 && !isReloading && g_playerActiveWeapon[client] == primaryWeapon)
6524 {
6525 playerAmmo[client][0] -= 1;
6526 SetPlayerAmmo(client);
6527 return Plugin_Stop;
6528 }
6529
6530 if (IsPlayerAlive(client) && g_iRoundStatus == 1 && !isReloading && g_playerActiveWeapon[client] == secondaryWeapon)
6531 {
6532 playerAmmo[client][1] -= 1;
6533 SetPlayerAmmo(client);
6534 return Plugin_Stop;
6535 }
6536 return Plugin_Continue;
6537}
6538
6539// Player respawn timer
6540public Action:Timer_PlayerRespawn(Handle:Timer, any:client)
6541{
6542 decl String:sRemainingTime[256];
6543
6544 // Exit if client is not in game
6545 if (!IsClientInGame(client)) return Plugin_Stop; // empty class name
6546
6547 if (!IsPlayerAlive(client) && g_iRoundStatus == 1)
6548 {
6549 g_squadLeader[client] = GetSquadLeader(client);
6550 if (g_iRespawnTimeRemaining[client] > 0)
6551 {
6552 if (g_playerFirstJoin[client] == 1)
6553 {
6554 //GetSquadSpawnStatus(client)
6555 //Get Leader Status >> 0 = Dead/Disconnected, 1 = Alive and well
6556 // Print remaining time to center text area
6557 if (!IsFakeClient(client))
6558 {
6559 if (g_squadSpawnEnabled[client] == 1)
6560 {
6561 if (g_squadLeader[client] == -1)
6562 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] This is your first time joining. Squad has no leader! Reinforcing normally in %d second%s (%d lives left) ", g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6563 else if (IsValidClient(g_squadLeader[client]) && IsClientInGame(g_squadLeader[client]) && playerPickSquad[g_squadLeader[client]] == 1)
6564 {
6565 if (Ins_InCounterAttack())
6566 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] This is your first time joining. Counter-attack in Progress! Reinforcing normally in %d second%s (%d lives left) ", g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6567 else if (IsPlayerAlive(g_squadLeader[client]))
6568 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] This is your first time joining. You will squad reinforce on %N in %d second%s (%d lives left) ", g_squadLeader[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6569 else
6570 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] This is your first time joining. Squad leader %N is dead! Reinforcing normally in %d second%s (%d lives left) ", g_squadLeader[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6571 }
6572
6573 }
6574 else
6575 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_DISABLED|Type /ss to toggle] This is your first time joining. You will reinforce in %d second%s (%d lives left) ", g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6576
6577 //PrintCenterText(client, sRemainingTime); - commented out by oz
6578 }
6579 }
6580 else
6581 {
6582 new String:woundType[128];
6583 new tIsFatal = false;
6584 if (g_iHurtFatal[client] == 1)
6585 {
6586 woundType = "fatally killed";
6587 tIsFatal = true;
6588 }
6589 else
6590 {
6591 woundType = "WOUNDED";
6592 if (g_playerWoundType[client] == 0)
6593 woundType = "MINORLY WOUNDED";
6594 else if (g_playerWoundType[client] == 1)
6595 woundType = "MODERATELY WOUNDED";
6596 else if (g_playerWoundType[client] == 2)
6597 woundType = "CRITCALLY WOUNDED";
6598 }
6599 // Print remaining time to center text area
6600 if (!IsFakeClient(client))
6601 {
6602 if (g_squadSpawnEnabled[client] == 1)
6603 {
6604 if (g_squadLeader[client] == -1)
6605 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] %s for %d damage | If wounded, wait patiently for a medic..do NOT mic/chat spam!\n\n Squad has no leader! Reinforcing normally in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6606 else if (IsValidClient(g_squadLeader[client]) && IsClientInGame(g_squadLeader[client]) && playerPickSquad[g_squadLeader[client]] == 1)
6607 {
6608
6609 if (Ins_InCounterAttack())
6610 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] %s for %d damage | If wounded, wait patiently for a medic..do NOT mic/chat spam!\n\n Counter-attack in progress! Reinforcing normally in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6611 else if (IsPlayerAlive(g_squadLeader[client]))
6612 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] %s for %d damage | If wounded, wait patiently for a medic..do NOT mic/chat spam!\n\n Squad reinforcing on %N in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_squadLeader[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6613 else
6614 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_ENABLED|Type /ss to toggle] %s for %d damage | If wounded, wait patiently for a medic..do NOT mic/chat spam!\n\n Squad leader %N is dead! Reinforcing normally in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_squadLeader[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6615 }
6616
6617 }
6618 //Normal spawn
6619 else
6620 {
6621 if (tIsFatal)
6622 {
6623 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_DISABLED|Type /ss to toggle] %s for %d damage\n\n Reinforcing in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6624 }
6625 else
6626 {
6627 Format(sRemainingTime, sizeof(sRemainingTime),"[SQUAD_SPAWN_DISABLED|Type /ss to toggle] %s for %d damage | wait patiently for a medic..do NOT mic/chat spam!\n\n Reinforcing in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
6628 }
6629 }
6630 //PrintCenterText(client, sRemainingTime); - commented out by oz
6631 }
6632 }
6633
6634 // Decrease respawn remaining time
6635 g_iRespawnTimeRemaining[client]--;
6636 }
6637 else
6638 {
6639 // Decrease respawn token
6640 if (g_iCvar_respawn_type_team_sec == 1)
6641 g_iSpawnTokens[client]--;
6642 else if (g_iCvar_respawn_type_team_sec == 2)
6643 g_iRemaining_lives_team_sec--;
6644
6645 // Call forcerespawn function
6646 SDKCall(g_hForceRespawn, client);
6647
6648 //AI Director START
6649
6650 if ((StrContains(g_client_last_classstring[client], "medic") > -1))
6651 g_AIDir_TeamStatus += 2;
6652 else
6653 g_AIDir_TeamStatus += 1;
6654
6655 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
6656
6657 //AI Director STOP
6658
6659 // Print remaining time to center text area
6660 //if (!IsFakeClient(client)) - commented out by oz
6661 // PrintCenterText(client, "You reinforced! (%d lives left)", g_iSpawnTokens[client]); - commented out by OnClientAuthorized
6662
6663
6664 //Lets confirm squad spawn
6665 new tSquadSpawned = false;
6666
6667 //Spawn on Squad Leader Action
6668 if (!Ins_InCounterAttack() && g_squadSpawnEnabled[client] == 1 && g_squadLeader[client] != -1 && IsPlayerAlive(g_squadLeader[client]) && playerPickSquad[g_squadLeader[client]] == 1)
6669 {
6670 if (IsValidClient(g_squadLeader[client]) && IsClientInGame(g_squadLeader[client]))
6671 {
6672 new Float:tSquadLeadPos[3];
6673 GetClientAbsOrigin(g_squadLeader[client], tSquadLeadPos);
6674 TeleportEntity(client, tSquadLeadPos, NULL_VECTOR, NULL_VECTOR);
6675 PrintHintText(g_squadLeader[client], "%N squad-reinforced on you!", client);
6676 tSquadSpawned = true;
6677 g_AIDir_TeamStatus += 2;
6678 }
6679 }
6680
6681 // Get ragdoll position
6682 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
6683
6684 // Remove network ragdoll
6685 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
6686 RemoveRagdoll(client);
6687
6688 // Do the post-spawn stuff like moving to final "spawnpoint" selected
6689 //CreateTimer(0.0, RespawnPlayerPost, client);
6690 //RespawnPlayerPost(INVALID_HANDLE, client);
6691
6692 // Reset ragdoll position
6693 g_fRagdollPosition[client][0] = 0.0;
6694 g_fRagdollPosition[client][1] = 0.0;
6695 g_fRagdollPosition[client][2] = 0.0;
6696
6697 // Announce respawn if not wave based (to avoid spam)
6698 if (!g_respawn_mode_team_sec)
6699 {
6700 if (g_squadSpawnEnabled[client] == 1 && tSquadSpawned == true)
6701 PrintToChatAll("\x05%N\x01 squad-reinforced on %N", client, g_squadLeader[client]);
6702 else
6703 PrintToChatAll("\x05%N\x01 reinforced..", client);
6704 }
6705 // Reset variable
6706 g_iPlayerRespawnTimerActive[client] = 0;
6707
6708 return Plugin_Stop;
6709 }
6710 }
6711 else
6712 {
6713 // Reset variable
6714 g_iPlayerRespawnTimerActive[client] = 0;
6715
6716 return Plugin_Stop;
6717 }
6718
6719 return Plugin_Continue;
6720}
6721
6722
6723// Handles reviving for medics and non-medics
6724public Action:Timer_ReviveMonitor(Handle:timer, any:data)
6725{
6726 // Check round state
6727 if (g_iRoundStatus == 0) return Plugin_Continue;
6728
6729
6730 // Init variables
6731 new Float:fReviveDistance = 65.0;
6732 new iInjured;
6733 new iInjuredRagdoll;
6734 new Float:fRagPos[3];
6735 new Float:fMedicPos[3];
6736 new Float:fDistance;
6737
6738 // Search medics
6739 for (new iMedic = 1; iMedic <= MaxClients; iMedic++)
6740 {
6741 if (!IsClientInGame(iMedic) || IsFakeClient(iMedic))
6742 continue;
6743
6744 // Is valid iMedic?
6745 if (IsPlayerAlive(iMedic) && (StrContains(g_client_last_classstring[iMedic], "medic") > -1))
6746 {
6747 // Check is there nearest body
6748 iInjured = g_iNearestBody[iMedic];
6749
6750 // Valid nearest body
6751 if (iInjured > 0 && IsClientInGame(iInjured) && !IsPlayerAlive(iInjured) && g_iHurtFatal[iInjured] == 0
6752 && iInjured != iMedic && GetClientTeam(iMedic) == GetClientTeam(iInjured)
6753 )
6754 {
6755 // Get found medic position
6756 GetClientAbsOrigin(iMedic, fMedicPos);
6757
6758 // Get player's entity index
6759 iInjuredRagdoll = EntRefToEntIndex(g_iClientRagdolls[iInjured]);
6760
6761 // Check ragdoll is valid
6762 if(iInjuredRagdoll > 0 && iInjuredRagdoll != INVALID_ENT_REFERENCE
6763 && IsValidEdict(iInjuredRagdoll) && IsValidEntity(iInjuredRagdoll)
6764 )
6765 {
6766 // Get player's ragdoll position
6767 GetEntPropVector(iInjuredRagdoll, Prop_Send, "m_vecOrigin", fRagPos);
6768
6769 // Update ragdoll position
6770 g_fRagdollPosition[iInjured] = fRagPos;
6771
6772 // Get distance from iMedic
6773 fDistance = GetVectorDistance(fRagPos,fMedicPos);
6774 }
6775 else
6776 // Ragdoll is not valid
6777 continue;
6778
6779 // Jareds pistols only code to verify iMedic is carrying knife
6780 new ActiveWeapon = GetEntPropEnt(iMedic, Prop_Data, "m_hActiveWeapon");
6781 if (ActiveWeapon < 0)
6782 continue;
6783
6784 // Get weapon class name
6785 decl String:sWeapon[32];
6786 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
6787 //PrintToServer("[KNIFE ONLY] CheckWeapon for iMedic %d named %N ActiveWeapon %d sWeapon %s",iMedic,iMedic,ActiveWeapon,sWeapon);
6788
6789 // If iMedic can see ragdoll and using defib or knife
6790 if (fDistance < fReviveDistance && (ClientCanSeeVector(iMedic, fRagPos, fReviveDistance))
6791 && ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
6792 )
6793 {
6794 //PrintToServer("[REVIVE_DEBUG] Distance from %N to %N is %f Seconds %d", iInjured, iMedic, fDistance, g_iReviveRemainingTime[iInjured]);
6795 decl String:sBuf[255];
6796
6797 // Need more time to reviving
6798 if (g_iReviveRemainingTime[iInjured] > 0)
6799 {
6800
6801 decl String:woundType[64];
6802 if (g_playerWoundType[iInjured] == 0)
6803 woundType = "Minor wound";
6804 else if (g_playerWoundType[iInjured] == 1)
6805 woundType = "Moderate wound";
6806 else if (g_playerWoundType[iInjured] == 2)
6807 woundType = "Critical wound";
6808
6809 // Hint to iMedic
6810 Format(sBuf, 255,"Reviving %N in: %i seconds (%s)", iInjured, g_iReviveRemainingTime[iInjured], woundType);
6811 PrintHintText(iMedic, "%s", sBuf);
6812
6813 // Hint to victim
6814 Format(sBuf, 255,"%N is reviving you in: %i seconds (%s)", iMedic, g_iReviveRemainingTime[iInjured], woundType);
6815 PrintHintText(iInjured, "%s", sBuf);
6816
6817 // Decrease revive remaining time
6818 g_iReviveRemainingTime[iInjured]--;
6819
6820 //prevent respawn while reviving
6821 g_iRespawnTimeRemaining[iInjured]++;
6822 }
6823 // Revive player
6824 else if (g_iReviveRemainingTime[iInjured] <= 0)
6825 {
6826 decl String:woundType[64];
6827 if (g_playerWoundType[iInjured] == 0)
6828 woundType = "minor wound";
6829 else if (g_playerWoundType[iInjured] == 1)
6830 woundType = "moderate wound";
6831 else if (g_playerWoundType[iInjured] == 2)
6832 woundType = "critical wound";
6833
6834 // Chat to all
6835 Format(sBuf, 255,"\x05%N\x01 revived \x03%N from a %s", iMedic, iInjured, woundType);
6836 PrintToChatAll("%s", sBuf);
6837
6838 // Hint to iMedic
6839 Format(sBuf, 255,"You revived %N from a %s", iInjured, woundType);
6840 PrintHintText(iMedic, "%s", sBuf);
6841
6842 // Hint to victim
6843 Format(sBuf, 255,"%N revived you from a %s", iMedic, woundType);
6844 PrintHintText(iInjured, "%s", sBuf);
6845
6846 // Add kill bonus to iMedic
6847 //new iBonus = GetConVarInt(sm_revive_bonus);
6848 //PrintToServer("iBonus: %d", iBonus);
6849 //new iScore = GetClientFrags(iMedic) + iBonus;
6850 //PrintToServer("GetClientFrags: %d | iScore: %d", GetClientFrags(iMedic), iScore);
6851 //SetEntProp(iMedic, Prop_Data, "m_iFrags", iScore);
6852
6853 /////////////////////////
6854 // Rank System
6855 g_iStatRevives[iMedic]++;
6856 //
6857 /////////////////////////
6858
6859 //Accumulate a revive
6860 g_playerMedicRevivessAccumulated[iMedic]++;
6861 new iReviveCap = GetConVarInt(sm_revive_cap_for_bonus);
6862
6863 // Hint to iMedic
6864 Format(sBuf, 255,"You revived %N from a %s | Revives remaining til bonus life: %d", iInjured, woundType, (iReviveCap - g_playerMedicRevivessAccumulated[iMedic]));
6865 PrintHintText(iMedic, "%s", sBuf);
6866 // Add score bonus to iMedic (doesn't work)
6867 //iScore = GetPlayerScore(iMedic);
6868 //PrintToServer("[SCORE] score: %d", iScore + 10);
6869 //SetPlayerScore(iMedic, iScore + 10);
6870 if (g_playerMedicRevivessAccumulated[iMedic] >= iReviveCap)
6871 {
6872 g_playerMedicRevivessAccumulated[iMedic] = 0;
6873 g_iSpawnTokens[iMedic]++;
6874 decl String:sBuf2[255];
6875 //if (iBonus > 1)
6876 // Format(sBuf2, 255,"Awarded %i kills and %i score for revive", iBonus, 10);
6877 //else
6878 Format(sBuf2, 255,"Awarded %i life for reviving %d players", 1, iReviveCap);
6879 PrintToChat(iMedic, "%s", sBuf2);
6880 }
6881
6882 // Update ragdoll position
6883 g_fRagdollPosition[iInjured] = fRagPos;
6884
6885 //Reward nearby medics who asssisted
6886 Check_NearbyMedicsRevive(iMedic, iInjured);
6887
6888 // Reset revive counter
6889 playerRevived[iInjured] = true;
6890
6891 // Call revive function
6892 g_playerNonMedicRevive[iInjured] = 0;
6893 CreateReviveTimer(iInjured);
6894
6895 //PrintToServer("##########PLAYER REVIVED %s ############", playerRevived[iInjured]);
6896 continue;
6897 }
6898 }
6899 }
6900 }
6901 //Non Medics with Medic Pack
6902 else if (IsPlayerAlive(iMedic) && !(StrContains(g_client_last_classstring[iMedic], "medic") > -1))
6903 {
6904 //PrintToServer("Non-Medic Reviving..");
6905 // Check is there nearest body
6906 iInjured = g_iNearestBody[iMedic];
6907
6908 // Valid nearest body
6909 if (iInjured > 0 && IsClientInGame(iInjured) && !IsPlayerAlive(iInjured) && g_iHurtFatal[iInjured] == 0
6910 && iInjured != iMedic && GetClientTeam(iMedic) == GetClientTeam(iInjured)
6911 )
6912 {
6913 // Get found medic position
6914 GetClientAbsOrigin(iMedic, fMedicPos);
6915
6916 // Get player's entity index
6917 iInjuredRagdoll = EntRefToEntIndex(g_iClientRagdolls[iInjured]);
6918
6919 // Check ragdoll is valid
6920 if(iInjuredRagdoll > 0 && iInjuredRagdoll != INVALID_ENT_REFERENCE
6921 && IsValidEdict(iInjuredRagdoll) && IsValidEntity(iInjuredRagdoll)
6922 )
6923 {
6924 // Get player's ragdoll position
6925 GetEntPropVector(iInjuredRagdoll, Prop_Send, "m_vecOrigin", fRagPos);
6926
6927 // Update ragdoll position
6928 g_fRagdollPosition[iInjured] = fRagPos;
6929
6930 // Get distance from iMedic
6931 fDistance = GetVectorDistance(fRagPos,fMedicPos);
6932 }
6933 else
6934 // Ragdoll is not valid
6935 continue;
6936
6937 // Jareds pistols only code to verify iMedic is carrying knife
6938 new ActiveWeapon = GetEntPropEnt(iMedic, Prop_Data, "m_hActiveWeapon");
6939 if (ActiveWeapon < 0)
6940 continue;
6941
6942 // Get weapon class name
6943 decl String:sWeapon[32];
6944 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
6945 //PrintToServer("[KNIFE ONLY] CheckWeapon for iMedic %d named %N ActiveWeapon %d sWeapon %s",iMedic,iMedic,ActiveWeapon,sWeapon);
6946
6947 // If NON Medic can see ragdoll and using healthkit
6948 if (fDistance < fReviveDistance && (ClientCanSeeVector(iMedic, fRagPos, fReviveDistance))
6949 && ((StrContains(sWeapon, "weapon_healthkit") > -1))
6950 )
6951 {
6952 //PrintToServer("[REVIVE_DEBUG] Distance from %N to %N is %f Seconds %d", iInjured, iMedic, fDistance, g_iReviveNonMedicRemainingTime[iInjured]);
6953 decl String:sBuf[255];
6954
6955 // Need more time to reviving
6956 if (g_iReviveNonMedicRemainingTime[iInjured] > 0)
6957 {
6958
6959 //PrintToServer("NONMEDIC HAS TIME");
6960 if (g_playerWoundType[iInjured] == 0 || g_playerWoundType[iInjured] == 1 || g_playerWoundType[iInjured] == 2)
6961 {
6962 decl String:woundType[64];
6963 if (g_playerWoundType[iInjured] == 0)
6964 woundType = "Minor wound";
6965 else if (g_playerWoundType[iInjured] == 1)
6966 woundType = "Moderate wound";
6967 else if (g_playerWoundType[iInjured] == 2)
6968 woundType = "Critical wound";
6969 // Hint to NonMedic
6970 Format(sBuf, 255,"Reviving %N in: %i seconds (%s)", iInjured, g_iReviveNonMedicRemainingTime[iInjured], woundType);
6971 PrintHintText(iMedic, "%s", sBuf);
6972
6973 // Hint to victim
6974 Format(sBuf, 255,"%N is reviving you in: %i seconds (%s)", iMedic, g_iReviveNonMedicRemainingTime[iInjured], woundType);
6975 PrintHintText(iInjured, "%s", sBuf);
6976
6977 // Decrease revive remaining time
6978 g_iReviveNonMedicRemainingTime[iInjured]--;
6979 }
6980 // else if (g_playerWoundType[iInjured] == 1 || g_playerWoundType[iInjured] == 2)
6981 // {
6982 // decl String:woundType[64];
6983 // if (g_playerWoundType[iInjured] == 1)
6984 // woundType = "moderately wounded";
6985 // else if (g_playerWoundType[iInjured] == 2)
6986 // woundType = "critically wounded";
6987 // // Hint to NonMedic
6988 // Format(sBuf, 255,"%N is %s and can only be revived by a medic!", iInjured, woundType);
6989 // PrintHintText(iMedic, "%s", sBuf);
6990 // }
6991 //prevent respawn while reviving
6992 g_iRespawnTimeRemaining[iInjured]++;
6993 }
6994 // Revive player
6995 else if (g_iReviveNonMedicRemainingTime[iInjured] <= 0)
6996 {
6997 decl String:woundType[64];
6998 if (g_playerWoundType[iInjured] == 0)
6999 woundType = "minor wound";
7000 else if (g_playerWoundType[iInjured] == 1)
7001 woundType = "moderate wound";
7002 else if (g_playerWoundType[iInjured] == 2)
7003 woundType = "critical wound";
7004
7005 // Chat to all
7006 Format(sBuf, 255,"\x05%N\x01 revived \x03%N from a %s", iMedic, iInjured, woundType);
7007 PrintToChatAll("%s", sBuf);
7008
7009 // Hint to iMedic
7010 Format(sBuf, 255,"You revived %N from a %s", iInjured, woundType);
7011 PrintHintText(iMedic, "%s", sBuf);
7012
7013 // Hint to victim
7014 Format(sBuf, 255,"%N revived you from a %s", iMedic, woundType);
7015 PrintHintText(iInjured, "%s", sBuf);
7016
7017 // Add kill bonus to iMedic
7018 // new iBonus = GetConVarInt(sm_revive_bonus);
7019 // new iScore = GetClientFrags(iMedic) + iBonus;
7020 // SetEntProp(iMedic, Prop_Data, "m_iFrags", iScore);
7021
7022
7023 /////////////////////////
7024 // Rank System
7025 g_iStatRevives[iMedic]++;
7026 //
7027 /////////////////////////
7028
7029 //Accumulate a revive
7030 g_playerMedicRevivessAccumulated[iMedic]++;
7031 new iReviveCap = GetConVarInt(sm_revive_cap_for_bonus);
7032
7033 // Hint to iMedic
7034 Format(sBuf, 255,"You revived %N from a %s | Revives remaining til bonus life: %d", iInjured, woundType, (iReviveCap - g_playerMedicRevivessAccumulated[iMedic]));
7035 PrintHintText(iMedic, "%s", sBuf);
7036 // Add score bonus to iMedic (doesn't work)
7037 //iScore = GetPlayerScore(iMedic);
7038 //PrintToServer("[SCORE] score: %d", iScore + 10);
7039 //SetPlayerScore(iMedic, iScore + 10);
7040 if (g_playerMedicRevivessAccumulated[iMedic] >= iReviveCap)
7041 {
7042 g_playerMedicRevivessAccumulated[iMedic] = 0;
7043 g_iSpawnTokens[iMedic]++;
7044 decl String:sBuf2[255];
7045 //if (iBonus > 1)
7046 // Format(sBuf2, 255,"Awarded %i kills and %i score for revive", iBonus, 10);
7047 //else
7048 Format(sBuf2, 255,"Awarded %i life for reviving %d players", 1, iReviveCap);
7049 PrintToChat(iMedic, "%s", sBuf2);
7050 }
7051
7052
7053 // Update ragdoll position
7054 g_fRagdollPosition[iInjured] = fRagPos;
7055
7056 //Reward nearby medics who asssisted
7057 Check_NearbyMedicsRevive(iMedic, iInjured);
7058
7059 // Reset revive counter
7060 playerRevived[iInjured] = true;
7061
7062 g_playerNonMedicRevive[iInjured] = 1;
7063 // Call revive function
7064 CreateReviveTimer(iInjured);
7065 RemovePlayerItem(iMedic,ActiveWeapon);
7066 //Switch to knife after removing kit
7067 ChangePlayerWeaponSlot(iMedic, 2);
7068 //PrintToServer("##########PLAYER REVIVED %s ############", playerRevived[iInjured]);
7069 continue;
7070 }
7071 }
7072 }
7073 }
7074 }
7075
7076 return Plugin_Continue;
7077}
7078
7079// Handles medic functions (Inspecting health, healing)
7080public Action:Timer_MedicMonitor(Handle:timer)
7081{
7082 // Check round state
7083 if (g_iRoundStatus == 0) return Plugin_Continue;
7084
7085 // Search medics
7086 for(new medic = 1; medic <= MaxClients; medic++)
7087 {
7088 if (!IsClientInGame(medic) || IsFakeClient(medic))
7089 continue;
7090
7091 // Medic only can inspect health.
7092 new iTeam = GetClientTeam(medic);
7093 if (iTeam == TEAM_1_SEC && IsPlayerAlive(medic) && StrContains(g_client_last_classstring[medic], "medic") > -1)
7094 {
7095 // Target is teammate and alive.
7096 new iTarget = TraceClientViewEntity(medic);
7097 if(iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget) && iTeam == GetClientTeam(iTarget))
7098 {
7099 // Check distance
7100 new bool:bCanHealPaddle = false;
7101 new bool:bCanHealMedpack = false;
7102 new Float:fReviveDistance = 80.0;
7103 new Float:vecMedicPos[3];
7104 new Float:vecTargetPos[3];
7105 new Float:tDistance;
7106 GetClientAbsOrigin(medic, Float:vecMedicPos);
7107 GetClientAbsOrigin(iTarget, Float:vecTargetPos);
7108 tDistance = GetVectorDistance(vecMedicPos,vecTargetPos);
7109
7110 if (tDistance < fReviveDistance && ClientCanSeeVector(medic, vecTargetPos, fReviveDistance))
7111 {
7112 // Check weapon
7113 new ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
7114 if (ActiveWeapon < 0)
7115 continue;
7116 decl String:sWeapon[32];
7117 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
7118
7119 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
7120 {
7121 bCanHealPaddle = true;
7122 }
7123 if ((StrContains(sWeapon, "weapon_healthkit") > -1))
7124 {
7125 bCanHealMedpack = true;
7126 }
7127 }
7128
7129 // Check heal
7130 new iHealth = GetClientHealth(iTarget);
7131
7132 if (tDistance < 750.0)
7133 {
7134 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
7135 }
7136
7137 if (bCanHealPaddle)
7138 {
7139 if (iHealth < 100)
7140 {
7141 iHealth += g_iHeal_amount_paddles;
7142 g_playerMedicHealsAccumulated[medic] += g_iHeal_amount_paddles;
7143 new iHealthCap = GetConVarInt(sm_heal_cap_for_bonus);
7144 new iRewardMedicEnabled = GetConVarInt(sm_reward_medics_enabled);
7145 //Reward player for healing
7146 if (g_playerMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
7147 {
7148 g_playerMedicHealsAccumulated[medic] = 0;
7149 // new iBonus = GetConVarInt(sm_heal_bonus);
7150 // new iScore = GetClientFrags(medic) + iBonus;
7151 // SetEntProp(medic, Prop_Data, "m_iFrags", iScore);
7152 g_iSpawnTokens[medic]++;
7153 decl String:sBuf2[255];
7154 // if (iBonus > 1)
7155 // Format(sBuf2, 255,"Awarded %i kills for healing %i in HP of other players.", iBonus, iHealthCap);
7156 // else
7157 Format(sBuf2, 255,"Awarded %i life for healing %i in HP of other players.", 1, iHealthCap);
7158
7159 PrintToChat(medic, "%s", sBuf2);
7160 }
7161
7162 if (iHealth >= 100)
7163 {
7164 ////////////////////////
7165 // Rank System
7166 g_iStatHeals[medic]++;
7167 //
7168 ////////////////////////
7169
7170 iHealth = 100;
7171 //Client_PrintToChatAll(false, "{OG}%N{N} healed {OG}%N", medic, iTarget);
7172 PrintToChatAll("\x05%N\x01 healed \x05%N", medic, iTarget);
7173 PrintHintText(iTarget, "You were healed by %N (HP: %i)", medic, iHealth);
7174 decl String:sBuf[255];
7175 Format(sBuf, 255,"You fully healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerMedicHealsAccumulated[medic]));
7176 PrintHintText(medic, "%s", sBuf);
7177 PrintToChat(medic, "%s", sBuf);
7178 }
7179 else
7180 {
7181 PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
7182 }
7183
7184 SetEntityHealth(iTarget, iHealth);
7185 PrintHintText(medic, "%N\nHP: %i\n\nHealing with paddles for: %i", iTarget, iHealth, g_iHeal_amount_paddles);
7186 }
7187 else
7188 {
7189 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
7190 }
7191 }
7192 else if (bCanHealMedpack)
7193 {
7194 if (iHealth < 100)
7195 {
7196 iHealth += g_iHeal_amount_medPack;
7197 g_playerMedicHealsAccumulated[medic] += g_iHeal_amount_medPack;
7198 new iHealthCap = GetConVarInt(sm_heal_cap_for_bonus);
7199 new iRewardMedicEnabled = GetConVarInt(sm_reward_medics_enabled);
7200 //Reward player for healing
7201 if (g_playerMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
7202 {
7203 g_playerMedicHealsAccumulated[medic] = 0;
7204 // new iBonus = GetConVarInt(sm_heal_bonus);
7205 // new iScore = GetClientFrags(medic) + iBonus;
7206 // SetEntProp(medic, Prop_Data, "m_iFrags", iScore);
7207 g_iSpawnTokens[medic]++;
7208 decl String:sBuf2[255];
7209 // if (iBonus > 1)
7210 // Format(sBuf2, 255,"Awarded %i kills for healing %i in HP of other players.", iBonus, iHealthCap);
7211 // else
7212 Format(sBuf2, 255,"Awarded %i life for healing %i in HP of other players.", 1, iHealthCap);
7213
7214 PrintToChat(medic, "%s", sBuf2);
7215 }
7216
7217 if (iHealth >= 100)
7218 {
7219 ////////////////////////
7220 // Rank System
7221 g_iStatHeals[medic]++;
7222 //
7223 ////////////////////////
7224 iHealth = 100;
7225
7226 //Client_PrintToChatAll(false, "{OG}%N{N} healed {OG}%N", medic, iTarget);
7227 PrintToChatAll("\x05%N\x01 healed \x05%N", medic, iTarget);
7228 PrintHintText(iTarget, "You were healed by %N (HP: %i)", medic, iHealth);
7229 decl String:sBuf[255];
7230 Format(sBuf, 255,"You fully healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerMedicHealsAccumulated[medic]));
7231 PrintHintText(medic, "%s", sBuf);
7232 PrintToChat(medic, "%s", sBuf);
7233 }
7234 else
7235 {
7236 PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
7237 }
7238
7239 SetEntityHealth(iTarget, iHealth);
7240 PrintHintText(medic, "%N\nHP: %i\n\nHealing with medpack for: %i", iTarget, iHealth, g_iHeal_amount_medPack);
7241 }
7242 else
7243 {
7244 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
7245 }
7246 }
7247 }
7248 else //Heal Self
7249 {
7250 // Check distance
7251 new bool:bCanHealMedpack = false;
7252 new bool:bCanHealPaddle = false;
7253
7254 // Check weapon
7255 new ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
7256 if (ActiveWeapon < 0)
7257 continue;
7258 decl String:sWeapon[32];
7259 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
7260
7261 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
7262 {
7263 bCanHealPaddle = true;
7264 }
7265 if ((StrContains(sWeapon, "weapon_healthkit") > -1))
7266 {
7267 bCanHealMedpack = true;
7268 }
7269
7270 // Check heal
7271 new iHealth = GetClientHealth(medic);
7272 if (bCanHealMedpack || bCanHealPaddle)
7273 {
7274 if (iHealth < g_medicHealSelf_max)
7275 {
7276 if (bCanHealMedpack)
7277 iHealth += g_iHeal_amount_medPack;
7278 else
7279 iHealth += g_iHeal_amount_paddles;
7280
7281 if (iHealth >= g_medicHealSelf_max)
7282 {
7283 iHealth = g_medicHealSelf_max;
7284 PrintHintText(medic, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
7285 }
7286 else
7287 {
7288 PrintHintText(medic, "Healing Self (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
7289 }
7290 SetEntityHealth(medic, iHealth);
7291 }
7292 }
7293 }
7294 }
7295 else if (iTeam == TEAM_1_SEC && IsPlayerAlive(medic) && !(StrContains(g_client_last_classstring[medic], "medic") > -1))
7296 {
7297 // Check weapon for non medics outside
7298 new ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
7299 if (ActiveWeapon < 0)
7300 continue;
7301 decl String:checkWeapon[32];
7302 GetEdictClassname(ActiveWeapon, checkWeapon, sizeof(checkWeapon));
7303 if ((StrContains(checkWeapon, "weapon_healthkit") > -1))
7304 {
7305 // Target is teammate and alive.
7306 new iTarget = TraceClientViewEntity(medic);
7307 if(iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget) && iTeam == GetClientTeam(iTarget))
7308 {
7309 // Check distance
7310 new bool:bCanHealMedpack = false;
7311 new Float:fReviveDistance = 80.0;
7312 new Float:vecMedicPos[3];
7313 new Float:vecTargetPos[3];
7314 new Float:tDistance;
7315 GetClientAbsOrigin(medic, Float:vecMedicPos);
7316 GetClientAbsOrigin(iTarget, Float:vecTargetPos);
7317 tDistance = GetVectorDistance(vecMedicPos,vecTargetPos);
7318
7319 if (tDistance < fReviveDistance && ClientCanSeeVector(medic, vecTargetPos, fReviveDistance))
7320 {
7321 // Check weapon
7322 //new ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
7323 if (ActiveWeapon < 0)
7324 continue;
7325
7326 decl String:sWeapon[32];
7327 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
7328 if ((StrContains(sWeapon, "weapon_healthkit") > -1))
7329 {
7330 bCanHealMedpack = true;
7331 }
7332 }
7333 // Check heal
7334 new iHealth = GetClientHealth(iTarget);
7335
7336 if (tDistance < 750.0)
7337 {
7338 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
7339 }
7340 if (bCanHealMedpack)
7341 {
7342 if (iHealth < g_nonMedic_maxHealOther)
7343 {
7344 iHealth += g_nonMedicHeal_amount;
7345 g_playerNonMedicHealsAccumulated[medic] += g_nonMedicHeal_amount;
7346 new iHealthCap = GetConVarInt(sm_heal_cap_for_bonus);
7347 new iRewardMedicEnabled = GetConVarInt(sm_reward_medics_enabled);
7348 //Reward player for healing
7349 if (g_playerNonMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
7350 {
7351 g_playerNonMedicHealsAccumulated[medic] = 0;
7352 // new iBonus = GetConVarInt(sm_heal_bonus);
7353 // new iScore = GetClientFrags(medic) + iBonus;
7354 // SetEntProp(medic, Prop_Data, "m_iFrags", iScore);
7355 g_iSpawnTokens[medic]++;
7356 decl String:sBuf2[255];
7357 // if (iBonus > 1)
7358 // Format(sBuf2, 255,"Awarded %i kills for healing %i in HP of other players.", iBonus, iHealthCap);
7359 // else
7360 Format(sBuf2, 255,"Awarded %i life for healing %i in HP of other players.", 1, iHealthCap);
7361
7362 PrintToChat(medic, "%s", sBuf2);
7363 }
7364
7365 if (iHealth >= g_nonMedic_maxHealOther)
7366 {
7367 ////////////////////////
7368 // Rank System
7369 g_iStatHeals[medic]++;
7370 //
7371 ////////////////////////
7372 iHealth = g_nonMedic_maxHealOther;
7373
7374 //Client_PrintToChatAll(false, "{OG}%N{N} healed {OG}%N", medic, iTarget);
7375 //PrintToChatAll("\x05%N\x01 healed \x05%N", medic, iTarget);
7376 PrintHintText(iTarget, "Non-Medic %N can only heal you for %i HP!)", medic, iHealth);
7377
7378 decl String:sBuf[255];
7379 Format(sBuf, 255,"You max healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerNonMedicHealsAccumulated[medic]));
7380 PrintHintText(medic, "%s", sBuf);
7381 PrintToChat(medic, "%s", sBuf);
7382 }
7383 else
7384 {
7385 PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
7386 }
7387
7388 SetEntityHealth(iTarget, iHealth);
7389 PrintHintText(medic, "%N\nHP: %i\n\nHealing.", iTarget, iHealth);
7390 }
7391 else
7392 {
7393 if (iHealth < g_nonMedic_maxHealOther)
7394 {
7395 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
7396 }
7397 else if (iHealth >= g_nonMedic_maxHealOther)
7398 PrintHintText(medic, "%N\nHP: %i (MAX YOU CAN HEAL)", iTarget, iHealth);
7399
7400 }
7401 }
7402 }
7403 else //Heal Self
7404 {
7405 // Check distance
7406 new bool:bCanHealMedpack = false;
7407
7408 // Check weapon
7409 //new ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon"); - variable already defined above
7410 if (ActiveWeapon < 0)
7411 continue;
7412 decl String:sWeapon[32];
7413 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
7414
7415 if ((StrContains(sWeapon, "weapon_healthkit") > -1))
7416 {
7417 bCanHealMedpack = true;
7418 }
7419
7420 // Check heal
7421 new iHealth = GetClientHealth(medic);
7422 if (bCanHealMedpack)
7423 {
7424 if (iHealth < g_nonMedicHealSelf_max)
7425 {
7426 iHealth += g_nonMedicHeal_amount;
7427 if (iHealth >= g_nonMedicHealSelf_max)
7428 {
7429 iHealth = g_nonMedicHealSelf_max;
7430 PrintHintText(medic, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
7431 }
7432 else
7433 {
7434 PrintHintText(medic, "Healing Self (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
7435 }
7436
7437 SetEntityHealth(medic, iHealth);
7438 }
7439 }
7440 }
7441 }
7442 }
7443 }
7444
7445 return Plugin_Continue;
7446}
7447
7448// public Action:Timer_ElitePeriodTick(Handle:timer, any:data)
7449// {
7450// new fTempTime =
7451// if (g_elitePeriod == 0)
7452// {
7453
7454
7455// }
7456
7457// }
7458
7459public Action:Timer_VIPCheck_Main(Handle:timer, any:data)
7460{
7461 //Only count down if not in counter
7462 if (!Ins_InCounterAttack() && g_vip_obj_count >= 0)
7463 g_vip_obj_count--;
7464
7465 //PrintToServer("[VIP] g_vip_obj_count: %i ", g_vip_obj_count);
7466
7467 decl String:textToPrintChat[128];
7468 //decl String:textToPrint[64];
7469 // Announce every 10 seconds
7470 if (g_vip_obj_count > 0 && (g_vip_obj_count % 45 == 0 || g_vip_obj_count < 4 || g_vip_obj_count == 10 || g_vip_obj_count == 20))
7471 {
7472
7473 //Format(textToPrint, sizeof(textToPrint), "Capture point with VIP in %d second to receive bonus supply!", g_vip_obj_count);
7474 Format(textToPrintChat, sizeof(textToPrintChat), "\x04VIP\x01 must be capture next point within %d second(s) for team to receive bonus supply!", g_vip_obj_count);
7475 //PrintToChatAll("Destroyable objectives should work as well.");- commented out by oz
7476 //PrintHintTextToAll(textToPrint);
7477 //PrintToChatAll(textToPrintChat); - commented out by oz
7478 if (g_nVIP_ID == 0)
7479 {
7480 Format(textToPrintChat, sizeof(textToPrintChat), "No \x04VIP\x01 on team | Supply points will not be granted for capturing objectives.");
7481 //PrintHintTextToAll(textToPrint);
7482 //PrintToChatAll(textToPrintChat); - commented out by oz
7483 }
7484 }
7485 if (g_vip_obj_count == 0 && g_vip_obj_ready != 0)
7486 {
7487 g_vip_obj_ready = 0;
7488 //PrintToChatAll("\x04VIP\x01 failed to capture point within allotted time of %d seconds.", g_iCvar_vip_obj_time); - commented out by oz
7489
7490 if (g_nVIP_ID == 0)
7491 {
7492 Format(textToPrintChat, sizeof(textToPrintChat), "No \x04VIP\x01 on team | Supply points will not be granted.");
7493 //PrintHintTextToAll(textToPrint);
7494 //PrintToChatAll(textToPrintChat); - commented out by oz
7495 }
7496 }
7497}
7498
7499//Main AI Director Tick
7500public Action:Timer_AIDirector_Main(Handle:timer, any:data)
7501{
7502 g_AIDir_AnnounceCounter++;
7503 g_AIDir_ChangeCond_Counter++;
7504 g_AIDir_AmbushCond_Counter++;
7505
7506 //Ambush Reinforcement Chance
7507 new tAmbushChance = GetRandomInt(0, 100);
7508
7509 //AI Director DEBUG
7510 if (g_AIDir_AnnounceCounter >= g_AIDir_AnnounceTrig)
7511 {
7512 g_AIDir_AnnounceCounter = 0;
7513 new tIsInCounter = 0;
7514 if (Ins_InCounterAttack())
7515 tIsInCounter = 1;
7516
7517 //PrintToServer("[AI_DIRECTOR] STATUS: %i | g_AIDir_CurrDiff %d | InCounter: %d | DiffChanceBase: %d", g_AIDir_TeamStatus, g_AIDir_CurrDiff, tIsInCounter, g_AIDir_DiffChanceBase); // commented by oz
7518 //PrintToServer("[AI_DIRECTOR]: Ambush_Counter: %d | tAmbushChance: %d | AmbushCond_Chance %d",g_AIDir_AmbushCond_Counter, tAmbushChance, g_AIDir_AmbushCond_Chance); // commented by oz
7519 //PrintToServer("[AI_DIRECTOR]: AmbushCond_Chance: %d | ChangeCond_Counter: %d | ChangeCond_Rand %d",g_AIDir_AmbushCond_Rand, g_AIDir_ChangeCond_Counter, g_AIDir_ChangeCond_Rand); // commented by oz
7520
7521 }
7522
7523 //AI Director Set Difficulty
7524 if (g_AIDir_ChangeCond_Counter >= g_AIDir_ChangeCond_Rand)
7525 {
7526 g_AIDir_ChangeCond_Counter = 0;
7527 g_AIDir_ChangeCond_Rand = GetRandomInt(g_AIDir_ChangeCond_Min, g_AIDir_ChangeCond_Max);
7528 //PrintToServer("[AI_DIRECTOR] STATUS: %i | SetDifficulty CALLED", g_AIDir_TeamStatus); // commented by oz
7529 AI_Director_SetDifficulty(g_AIDir_TeamStatus, g_AIDir_TeamStatus_max);
7530 }
7531
7532 if (g_AIDir_AmbushCond_Counter >= g_AIDir_AmbushCond_Rand)
7533 {
7534 if (tAmbushChance <= g_AIDir_AmbushCond_Chance)
7535 {
7536 g_AIDir_AmbushCond_Counter = 0;
7537 g_AIDir_AmbushCond_Rand = GetRandomInt(g_AIDir_AmbushCond_Min, g_AIDir_AmbushCond_Max);
7538 AI_Director_RandomEnemyReinforce();
7539 }
7540 else
7541 {
7542 //PrintToServer("[AI_DIRECTOR]: tAmbushChance: %d | g_AIDir_AmbushCond_Chance %d", tAmbushChance, g_AIDir_AmbushCond_Chance); // commented by oz
7543 //Reset
7544 g_AIDir_AmbushCond_Counter = 0;
7545 g_AIDir_AmbushCond_Rand = GetRandomInt(g_AIDir_AmbushCond_Min, g_AIDir_AmbushCond_Max);
7546 }
7547 }
7548
7549 // Get the number of control points
7550 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
7551 // Get active push point
7552 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
7553
7554 //Confirm percent finale
7555 if ((acp+1) == ncp)
7556 {
7557 if (g_finale_counter_spec_enabled == 1)
7558 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
7559 }
7560
7561 return Plugin_Continue;
7562
7563}
7564
7565public Action:Timer_AmmoResupply(Handle:timer, any:data)
7566{
7567 if (g_iRoundStatus == 0) return Plugin_Continue;
7568 for (new client = 1; client <= MaxClients; client++)
7569 {
7570 if (!IsClientInGame(client) || IsFakeClient(client))
7571 continue;
7572 new team = GetClientTeam(client);
7573 // Valid medic?
7574 if (IsPlayerAlive(client) && team == TEAM_1_SEC)
7575 {
7576 new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
7577 if (ActiveWeapon < 0)
7578 continue;
7579
7580 // Get weapon class name
7581 decl String:sWeapon[32];
7582 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
7583 //if (GetClientButtons(client) & //INS_RELOAD && ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)))
7584 if (((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)))
7585 {
7586 new validAmmoCache = -1;
7587 validAmmoCache = FindValidProp_InDistance(client);
7588 //PrintToServer("validAmmoCache: %d", validAmmoCache);
7589 if (validAmmoCache != -1)
7590 {
7591 g_resupplyCounter[client] -= 1;
7592 if (g_ammoResupplyAmt[validAmmoCache] <= 0)
7593 {
7594 new secTeamCount = GetTeamSecCount();
7595 g_ammoResupplyAmt[validAmmoCache] = (secTeamCount / 6);
7596 if (g_ammoResupplyAmt[validAmmoCache] <= 1)
7597 {
7598 g_ammoResupplyAmt[validAmmoCache] = 1;
7599 }
7600
7601 }
7602 decl String:sBuf[255];
7603 // Hint to client
7604 Format(sBuf, 255,"Resupplying ammo in %d seconds | Supply left: %d", g_resupplyCounter[client], g_ammoResupplyAmt[validAmmoCache]);
7605 //PrintHintText(client, "%s", sBuf);
7606 if (g_resupplyCounter[client] <= 0)
7607 {
7608 g_resupplyCounter[client] = GetConVarInt(sm_resupply_delay);
7609 //Spawn player again
7610 AmmoResupply_Player(client, 0, 0, 0);
7611
7612
7613 g_ammoResupplyAmt[validAmmoCache] -= 1;
7614 if (g_ammoResupplyAmt[validAmmoCache] <= 0)
7615 {
7616 if(validAmmoCache != -1)
7617 AcceptEntityInput(validAmmoCache, "kill");
7618 }
7619 Format(sBuf, 255,"Rearmed! Ammo Supply left: %d", g_ammoResupplyAmt[validAmmoCache]);
7620
7621 PrintHintText(client, "%s", sBuf);
7622 PrintToChat(client, "%s", sBuf);
7623
7624 }
7625 }
7626 }
7627 }
7628 }
7629 return Plugin_Continue;
7630}
7631
7632public AmmoResupply_Player(client, primaryRemove, secondaryRemove, grenadesRemove)
7633{
7634
7635 new Float:plyrOrigin[3];
7636 new Float:tempOrigin[3];
7637 GetClientAbsOrigin(client,plyrOrigin);
7638 tempOrigin = plyrOrigin;
7639 tempOrigin[2] = -5000.0;
7640
7641 //TeleportEntity(client, tempOrigin, NULL_VECTOR, NULL_VECTOR);
7642 //ForcePlayerSuicide(client);
7643 // Get dead body
7644 new clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
7645
7646 //This timer safely removes client-side ragdoll
7647 if(clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll))
7648 {
7649 // Get dead body's entity
7650 new ref = EntIndexToEntRef(clientRagdoll);
7651 new entity = EntRefToEntIndex(ref);
7652 if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
7653 {
7654 // Remove dead body's entity
7655 AcceptEntityInput(entity, "Kill");
7656 clientRagdoll = INVALID_ENT_REFERENCE;
7657 }
7658 }
7659
7660 ForceRespawnPlayer(client, client);
7661 TeleportEntity(client, plyrOrigin, NULL_VECTOR, NULL_VECTOR);
7662 RemoveWeapons(client, primaryRemove, secondaryRemove, grenadesRemove);
7663 PrintHintText(client, "Ammo Resupplied");
7664 playerInRevivedState[client] = false;
7665 // //Give back life
7666 // new iDeaths = GetClientDeaths(client) - 1;
7667 // SetEntProp(client, Prop_Data, "m_iDeaths", iDeaths);
7668}
7669//Find Valid Prop
7670public RemoveWeapons(client, primaryRemove, secondaryRemove, grenadesRemove)
7671{
7672
7673 new primaryWeapon = GetPlayerWeaponSlot(client, 0);
7674 new secondaryWeapon = GetPlayerWeaponSlot(client, 1);
7675 new playerGrenades = GetPlayerWeaponSlot(client, 3);
7676
7677 // Check and remove primaryWeapon
7678 if (primaryWeapon != -1 && IsValidEntity(primaryWeapon) && primaryRemove == 1) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
7679 {
7680 // Remove primaryWeapon
7681 decl String:weapon[32];
7682 GetEntityClassname(primaryWeapon, weapon, sizeof(weapon));
7683 RemovePlayerItem(client,primaryWeapon);
7684 AcceptEntityInput(primaryWeapon, "kill");
7685 }
7686 // Check and remove secondaryWeapon
7687 if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon) && secondaryRemove == 1) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
7688 {
7689 // Remove primaryWeapon
7690 decl String:weapon[32];
7691 GetEntityClassname(secondaryWeapon, weapon, sizeof(weapon));
7692 RemovePlayerItem(client,secondaryWeapon);
7693 AcceptEntityInput(secondaryWeapon, "kill");
7694 }
7695 // Check and remove grenades
7696 if (playerGrenades != -1 && IsValidEntity(playerGrenades) && grenadesRemove == 1) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
7697 {
7698 while (playerGrenades != -1 && IsValidEntity(playerGrenades)) // since we only have 3 slots in current theate
7699 {
7700 playerGrenades = GetPlayerWeaponSlot(client, 3);
7701 if (playerGrenades != -1 && IsValidEntity(playerGrenades)) // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 1
7702 {
7703 // Remove grenades
7704 decl String:weapon[32];
7705 GetEntityClassname(playerGrenades, weapon, sizeof(weapon));
7706 RemovePlayerItem(client,playerGrenades);
7707 AcceptEntityInput(playerGrenades, "kill");
7708
7709 }
7710 }
7711 }
7712}
7713//Find Valid Prop
7714public FindValidProp_InDistance(client)
7715{
7716
7717 new prop;
7718 while ((prop = FindEntityByClassname(prop, "prop_dynamic_override")) != -1)
7719 {
7720 new String:propModelName[128];
7721 GetEntPropString(prop, Prop_Data, "m_ModelName", propModelName, 128);
7722 //PrintToChatAll("propModelName %s", propModelName);
7723 if (StrEqual(propModelName, "models/sernix/ammo_cache/ammo_cache_small.mdl") || StrContains(propModelName, "models/sernix/ammo_cache/ammo_cache_small.mdl") > -1)
7724 {
7725 new Float:tDistance = (GetEntitiesDistance(client, prop));
7726 if (tDistance <= (GetConVarInt(sm_ammo_resupply_range)))
7727 {
7728 return prop;
7729 }
7730 }
7731
7732 }
7733 return -1;
7734}
7735stock AI_Director_IsSpecialtyBot(client)
7736{
7737 if (IsFakeClient(client) && ((StrContains(g_client_last_classstring[client], "bomber") > -1) || (StrContains(g_client_last_classstring[client], "juggernaut") > -1)))
7738 return true;
7739 else
7740 return false;
7741}
7742stock Float:GetEntitiesDistance(ent1, ent2)
7743{
7744 new Float:orig1[3];
7745 GetEntPropVector(ent1, Prop_Send, "m_vecOrigin", orig1);
7746
7747 new Float:orig2[3];
7748 GetEntPropVector(ent2, Prop_Send, "m_vecOrigin", orig2);
7749
7750 return GetVectorDistance(orig1, orig2);
7751}
7752public Action:Timer_AmbientRadio(Handle:timer, any:data)
7753{
7754 if (g_iRoundStatus == 0) return Plugin_Continue;
7755 for (new client = 1; client <= MaxClients; client++)
7756 {
7757
7758 if (!IsClientInGame(client) || IsFakeClient(client))
7759 continue;
7760
7761 new team = GetClientTeam(client);
7762 // Valid medic?
7763 if (IsPlayerAlive(client) && ((StrContains(g_client_last_classstring[client], "squadleader") > -1) || (StrContains(g_client_last_classstring[client], "teamleader") > -1)) && team == TEAM_1_SEC)
7764 {
7765
7766
7767 new fRandomChance = GetRandomInt(1, 100);
7768 if (fRandomChance < 50)
7769 {
7770 new Handle:hDatapack;
7771 new fRandomFloat = GetRandomFloat(1.0, 30.0);
7772 //CreateTimer(fRandomFloat, Timer_PlayAmbient);
7773 CreateDataTimer(fRandomFloat, Timer_PlayAmbient, hDatapack);
7774 WritePackCell(hDatapack, client);
7775 }
7776 }
7777 }
7778 return Plugin_Continue;
7779
7780
7781}
7782public Action:Timer_PlayAmbient(Handle:timer, Handle:hDatapack)
7783{
7784
7785 ResetPack(hDatapack);
7786 new client = ReadPackCell(hDatapack);
7787 //PrintToServer("PlaySound");
7788 switch(GetRandomInt(1, 18))
7789 {
7790 case 1: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_01.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7791 case 2: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_02.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7792 case 3: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_03.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7793 case 4: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_04.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7794 case 5: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_01.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7795 case 6: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_02.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7796 case 7: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_03.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7797 case 8: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_04.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7798 case 9: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_05.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7799 case 10: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_06.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7800 case 11: EmitSoundToAll("sernx_lua_sounds/radio/radio1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7801 case 12: EmitSoundToAll("sernx_lua_sounds/radio/radio2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7802 case 13: EmitSoundToAll("sernx_lua_sounds/radio/radio3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7803 case 14: EmitSoundToAll("sernx_lua_sounds/radio/radio4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7804 case 15: EmitSoundToAll("sernx_lua_sounds/radio/radio5.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7805 case 16: EmitSoundToAll("sernx_lua_sounds/radio/radio6.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7806 case 17: EmitSoundToAll("sernx_lua_sounds/radio/radio7.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7807 case 18: EmitSoundToAll("sernx_lua_sounds/radio/radio8.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
7808 }
7809 return Plugin_Continue;
7810
7811}
7812// Check for nearest player
7813public Action:Timer_NearestBody(Handle:timer, any:data)
7814{
7815 // Check round state
7816 if (g_iRoundStatus == 0) return Plugin_Continue;
7817
7818 // Variables to store
7819 new Float:fMedicPosition[3];
7820 new Float:fMedicAngles[3];
7821 new Float:fInjuredPosition[3];
7822 new Float:fNearestDistance;
7823 new Float:fTempDistance;
7824
7825 // iNearestInjured client
7826 new iNearestInjured;
7827
7828 decl String:sDirection[64];
7829 decl String:sDistance[64];
7830 decl String:sHeight[6];
7831
7832 // Client loop
7833 for (new medic = 1; medic <= MaxClients; medic++)
7834 {
7835 if (!IsClientInGame(medic) || IsFakeClient(medic))
7836 continue;
7837
7838 // Valid medic?
7839 if (IsPlayerAlive(medic) && (StrContains(g_client_last_classstring[medic], "medic") > -1))
7840 {
7841 // Reset variables
7842 iNearestInjured = 0;
7843 fNearestDistance = 0.0;
7844
7845 // Get medic position
7846 GetClientAbsOrigin(medic, fMedicPosition);
7847
7848 //PrintToServer("MEDIC DETECTED ********************");
7849 // Search dead body
7850 for (new search = 1; search <= MaxClients; search++)
7851 {
7852 if (!IsClientInGame(search) || IsFakeClient(search) || IsPlayerAlive(search))
7853 continue;
7854
7855 // Check if valid
7856 if (g_iHurtFatal[search] == 0 && search != medic && GetClientTeam(medic) == GetClientTeam(search))
7857 {
7858 // Get found client's ragdoll
7859 new clientRagdoll = EntRefToEntIndex(g_iClientRagdolls[search]);
7860 if (clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && clientRagdoll != INVALID_ENT_REFERENCE)
7861 {
7862 // Get ragdoll's position
7863 fInjuredPosition = g_fRagdollPosition[search];
7864
7865 // Get distance from ragdoll
7866 fTempDistance = GetVectorDistance(fMedicPosition, fInjuredPosition);
7867
7868 // Is he more fNearestDistance to the player as the player before?
7869 if (fNearestDistance == 0.0)
7870 {
7871 fNearestDistance = fTempDistance;
7872 iNearestInjured = search;
7873 }
7874 // Set new distance and new iNearestInjured player
7875 else if (fTempDistance < fNearestDistance)
7876 {
7877 fNearestDistance = fTempDistance;
7878 iNearestInjured = search;
7879 }
7880 }
7881 }
7882 }
7883
7884 // Found a dead body?
7885 if (iNearestInjured != 0)
7886 {
7887 // Set iNearestInjured body
7888 g_iNearestBody[medic] = iNearestInjured;
7889
7890 // Get medic angle
7891 GetClientAbsAngles(medic, fMedicAngles);
7892
7893 // Get direction string (if it cause server lag, remove this)
7894 sDirection = GetDirectionString(fMedicAngles, fMedicPosition, fInjuredPosition);
7895
7896 // Get distance string
7897 sDistance = GetDistanceString(fNearestDistance);
7898 // Get height string
7899 sHeight = GetHeightString(fMedicPosition, fInjuredPosition);
7900
7901 // Print iNearestInjured dead body's distance and direction text
7902 //PrintCenterText(medic, "Nearest dead: %N (%s)", iNearestInjured, sDistance);
7903 PrintCenterText(medic, "Nearest dead: %N ( %s | %s | %s )", iNearestInjured, sDistance, sDirection, sHeight);
7904 new Float:beamPos[3];
7905 beamPos = fInjuredPosition;
7906 beamPos[2] += 0.3;
7907 if (fTempDistance >= 140)
7908 {
7909 //Attack markers option
7910 //Effect_SetMarkerAtPos(medic,beamPos,1.0,{255, 0, 0, 255});
7911
7912 //Beam dead when farther
7913 TE_SetupBeamRingPoint(beamPos, 1.0, Revive_Indicator_Radius, g_iBeaconBeam, g_iBeaconHalo, 0, 15, 5.0, 3.0, 5.0, {255, 0, 0, 255}, 1, (FBEAM_FADEIN, FBEAM_FADEOUT));
7914 //void TE_SetupBeamRingPoint(const float center[3], float Start_Radius, float End_Radius, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags)
7915 TE_SendToClient(medic);
7916 }
7917 }
7918 else
7919 {
7920 // Reset iNearestInjured body
7921 g_iNearestBody[medic] = -1;
7922 }
7923 }
7924 else if (IsPlayerAlive(medic) && !(StrContains(g_client_last_classstring[medic], "medic") > -1))
7925 {
7926 // Reset variables
7927 iNearestInjured = 0;
7928 fNearestDistance = 0.0;
7929
7930 // Get medic position
7931 GetClientAbsOrigin(medic, fMedicPosition);
7932
7933 //PrintToServer("MEDIC DETECTED ********************");
7934 // Search dead body
7935 for (new search = 1; search <= MaxClients; search++)
7936 {
7937 if (!IsClientInGame(search) || IsFakeClient(search) || IsPlayerAlive(search))
7938 continue;
7939
7940 // Check if valid
7941 if (g_iHurtFatal[search] == 0 && search != medic && GetClientTeam(medic) == GetClientTeam(search))
7942 {
7943 // Get found client's ragdoll
7944 new clientRagdoll = EntRefToEntIndex(g_iClientRagdolls[search]);
7945 if (clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && clientRagdoll != INVALID_ENT_REFERENCE)
7946 {
7947 // Get ragdoll's position
7948 fInjuredPosition = g_fRagdollPosition[search];
7949
7950 // Get distance from ragdoll
7951 fTempDistance = GetVectorDistance(fMedicPosition, fInjuredPosition);
7952
7953 // Is he more fNearestDistance to the player as the player before?
7954 if (fNearestDistance == 0.0)
7955 {
7956 fNearestDistance = fTempDistance;
7957 iNearestInjured = search;
7958 }
7959 // Set new distance and new iNearestInjured player
7960 else if (fTempDistance < fNearestDistance)
7961 {
7962 fNearestDistance = fTempDistance;
7963 iNearestInjured = search;
7964 }
7965 }
7966 }
7967 }
7968
7969 // Found a dead body?
7970 if (iNearestInjured != 0)
7971 {
7972 // Set iNearestInjured body
7973 g_iNearestBody[medic] = iNearestInjured;
7974
7975 }
7976 else
7977 {
7978 // Reset iNearestInjured body
7979 g_iNearestBody[medic] = -1;
7980 }
7981 }
7982 }
7983
7984 return Plugin_Continue;
7985}
7986
7987
7988public Check_NearbyPlayers(enemyBot)
7989{
7990 for (new client = 1; client <= MaxClients; client++)
7991 {
7992 if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
7993 {
7994 if (IsPlayerAlive(client))
7995 {
7996 new Float:botOrigin[3];
7997 new Float:clientOrigin[3];
7998 new Float:fDistance;
7999
8000 GetClientAbsOrigin(enemyBot,botOrigin);
8001 GetClientAbsOrigin(client,clientOrigin);
8002
8003 //determine distance from the two
8004 fDistance = GetVectorDistance(botOrigin,clientOrigin);
8005
8006 if (fDistance <= 600)
8007 {
8008 return true;
8009 }
8010 }
8011 }
8012 }
8013 return false;
8014}
8015
8016/**
8017 * Get direction string for nearest dead body
8018 *
8019 * @param fClientAngles[3] Client angle
8020 * @param fClientPosition[3] Client position
8021 * @param fTargetPosition[3] Target position
8022 * @Return direction string.
8023 */
8024String:GetDirectionString(Float:fClientAngles[3], Float:fClientPosition[3], Float:fTargetPosition[3])
8025{
8026 new
8027 Float:fTempAngles[3],
8028 Float:fTempPoints[3];
8029
8030 decl String:sDirection[64];
8031
8032 // Angles from origin
8033 MakeVectorFromPoints(fClientPosition, fTargetPosition, fTempPoints);
8034 GetVectorAngles(fTempPoints, fTempAngles);
8035
8036 // Differenz
8037 new Float:fDiff = fClientAngles[1] - fTempAngles[1];
8038
8039 // Correct it
8040 if (fDiff < -180)
8041 fDiff = 360 + fDiff;
8042
8043 if (fDiff > 180)
8044 fDiff = 360 - fDiff;
8045
8046 // Now geht the direction
8047 // Up
8048 if (fDiff >= -22.5 && fDiff < 22.5)
8049 Format(sDirection, sizeof(sDirection), "FWD");//"\xe2\x86\x91");
8050 // right up
8051 else if (fDiff >= 22.5 && fDiff < 67.5)
8052 Format(sDirection, sizeof(sDirection), "FWD-RIGHT");//"\xe2\x86\x97");
8053 // right
8054 else if (fDiff >= 67.5 && fDiff < 112.5)
8055 Format(sDirection, sizeof(sDirection), "RIGHT");//"\xe2\x86\x92");
8056 // right down
8057 else if (fDiff >= 112.5 && fDiff < 157.5)
8058 Format(sDirection, sizeof(sDirection), "BACK-RIGHT");//"\xe2\x86\x98");
8059 // down
8060 else if (fDiff >= 157.5 || fDiff < -157.5)
8061 Format(sDirection, sizeof(sDirection), "BACK");//"\xe2\x86\x93");
8062 // down left
8063 else if (fDiff >= -157.5 && fDiff < -112.5)
8064 Format(sDirection, sizeof(sDirection), "BACK-LEFT");//"\xe2\x86\x99");
8065 // left
8066 else if (fDiff >= -112.5 && fDiff < -67.5)
8067 Format(sDirection, sizeof(sDirection), "LEFT");//"\xe2\x86\x90");
8068 // left up
8069 else if (fDiff >= -67.5 && fDiff < -22.5)
8070 Format(sDirection, sizeof(sDirection), "FWD-LEFT");//"\xe2\x86\x96");
8071
8072 return sDirection;
8073}
8074
8075// Return distance string
8076String:GetDistanceString(Float:fDistance)
8077{
8078 // Distance to meters
8079 new Float:fTempDistance = fDistance * 0.01905;
8080 decl String:sResult[64];
8081
8082 // Distance to feet?
8083 if (g_iUnitMetric == 1)
8084 {
8085 fTempDistance = fTempDistance * 3.2808399;
8086
8087 // Feet
8088 Format(sResult, sizeof(sResult), "%.0f feet", fTempDistance);
8089 }
8090 else
8091 {
8092 // Meter
8093 Format(sResult, sizeof(sResult), "%.0f meter", fTempDistance);
8094 }
8095
8096 return sResult;
8097}
8098
8099/**
8100 * Get height string for nearest dead body
8101 *
8102 * @param fClientPosition[3] Client position
8103 * @param fTargetPosition[3] Target position
8104 * @Return height string.
8105 */
8106String:GetHeightString(Float:fClientPosition[3], Float:fTargetPosition[3])
8107{
8108 decl String:s[6];
8109
8110 if (fClientPosition[2]+64 < fTargetPosition[2])
8111 {
8112 s = "ABOVE";
8113 }
8114 else if (fClientPosition[2]-64 > fTargetPosition[2])
8115 {
8116 s = "BELOW";
8117 }
8118 else
8119 {
8120 s = "LEVEL";
8121 }
8122
8123 return s;
8124}
8125// Check tags
8126stock TagsCheck(const String:tag[], bool:remove = false)
8127{
8128 new Handle:hTags = FindConVar("sv_tags");
8129 decl String:tags[255];
8130 GetConVarString(hTags, tags, sizeof(tags));
8131
8132 if (StrContains(tags, tag, false) == -1 && !remove)
8133 {
8134 decl String:newTags[255];
8135 Format(newTags, sizeof(newTags), "%s,%s", tags, tag);
8136 ReplaceString(newTags, sizeof(newTags), ",,", ",", false);
8137 SetConVarString(hTags, newTags);
8138 GetConVarString(hTags, tags, sizeof(tags));
8139 }
8140 else if (StrContains(tags, tag, false) > -1 && remove)
8141 {
8142 ReplaceString(tags, sizeof(tags), tag, "", false);
8143 ReplaceString(tags, sizeof(tags), ",,", ",", false);
8144 SetConVarString(hTags, tags);
8145 }
8146}
8147
8148// Get tesm2 player count
8149stock GetTeamSecCount() {
8150 new clients = 0;
8151 new iTeam;
8152 for( new i = 1; i <= GetMaxClients(); i++ ) {
8153 if (IsClientInGame(i) && IsClientConnected(i))
8154 {
8155 iTeam = GetClientTeam(i);
8156 if(iTeam == TEAM_1_SEC)
8157 clients++;
8158 }
8159 }
8160 return clients;
8161}
8162
8163// Get real client count
8164stock GetRealClientCount( bool:inGameOnly = true ) {
8165 new clients = 0;
8166 for( new i = 1; i <= GetMaxClients(); i++ ) {
8167 if(((inGameOnly)?IsClientInGame(i):IsClientConnected(i)) && !IsFakeClient(i)) {
8168 clients++;
8169 }
8170 }
8171 return clients;
8172}
8173
8174// Get insurgent team bot count
8175stock GetTeamInsCount() {
8176 new clients;
8177 for(new i = 1; i <= GetMaxClients(); i++ ) {
8178 if (IsClientInGame(i) && IsClientConnected(i) && IsFakeClient(i)) {
8179 clients++;
8180 }
8181 }
8182 return clients;
8183}
8184
8185// Get remaining life
8186stock GetRemainingLife()
8187{
8188 new iResult;
8189 for (new i = 1; i <= MaxClients; i++)
8190 {
8191 if (i > 0 && IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i))
8192 {
8193 if (g_iSpawnTokens[i] > 0)
8194 iResult = iResult + g_iSpawnTokens[i];
8195 }
8196 }
8197
8198 return iResult;
8199}
8200
8201// Trace client's view entity
8202stock TraceClientViewEntity(client)
8203{
8204 new Float:m_vecOrigin[3];
8205 new Float:m_angRotation[3];
8206
8207 GetClientEyePosition(client, m_vecOrigin);
8208 GetClientEyeAngles(client, m_angRotation);
8209
8210 new Handle:tr = TR_TraceRayFilterEx(m_vecOrigin, m_angRotation, MASK_VISIBLE, RayType_Infinite, TRDontHitSelf, client);
8211 new pEntity = -1;
8212
8213 if (TR_DidHit(tr))
8214 {
8215 pEntity = TR_GetEntityIndex(tr);
8216 CloseHandle(tr);
8217 return pEntity;
8218 }
8219
8220 if(tr != INVALID_HANDLE)
8221 {
8222 CloseHandle(tr);
8223 }
8224
8225 return -1;
8226}
8227
8228// Check is hit self
8229public bool:TRDontHitSelf(entity, mask, any:data) // Don't ray trace ourselves -_-"
8230{
8231 return (1 <= entity <= MaxClients) && (entity != data);
8232}
8233
8234// Get player score (works fine)
8235int GetPlayerScore(client)
8236{
8237 // Get player manager class
8238 new iPlayerManager, String:iPlayerManagerNetClass[32];
8239 iPlayerManager = FindEntityByClassname(0,"ins_player_manager");
8240 GetEntityNetClass(iPlayerManager, iPlayerManagerNetClass, sizeof(iPlayerManagerNetClass));
8241
8242 // Check result
8243 if (iPlayerManager < 1)
8244 {
8245 //PrintToServer("[SCORE] Unable to find ins_player_manager");
8246 return -1;
8247 }
8248
8249 // Debug result
8250 //PrintToServer("[SCORE] iPlayerManagerNetClass %s", iPlayerManagerNetClass);
8251
8252 // Get player score structure
8253 new m_iPlayerScore = FindSendPropInfo(iPlayerManagerNetClass, "m_iPlayerScore");
8254
8255 // Check result
8256 if (m_iPlayerScore < 1) {
8257 //PrintToServer("[SCORE] Unable to find ins_player_manager property m_iPlayerScore");
8258 return -1;
8259 }
8260
8261 // Get score
8262 new iScore = GetEntData(iPlayerManager, m_iPlayerScore + (4 * client));
8263
8264 return iScore;
8265}
8266
8267
8268//Below void Commented out by oz
8269// Set player score (doesn't work)
8270//void SetPlayerScore(client, iScore)
8271//{
8272 // Get player manager class
8273// new iPlayerManager, String:iPlayerManagerNetClass[32];
8274// iPlayerManager = FindEntityByClassname(0,"ins_player_manager");
8275// GetEntityNetClass(iPlayerManager, iPlayerManagerNetClass, sizeof(iPlayerManagerNetClass));
8276
8277 // Check result
8278// if (iPlayerManager < 1)
8279// {
8280 //PrintToServer("[SCORE] Unable to find ins_player_manager");
8281// return;
8282// }
8283
8284 // Debug result
8285 //PrintToServer("[SCORE] iPlayerManagerNetClass %s", iPlayerManagerNetClass);
8286
8287 // Get player score
8288// new m_iPlayerScore = FindSendPropInfo(iPlayerManagerNetClass, "m_iPlayerScore");
8289
8290 // Check result
8291// if (m_iPlayerScore < 1) {
8292 //PrintToServer("[SCORE] Unable to find ins_player_manager property m_iPlayerScore");
8293// return;
8294// }
8295
8296 // Set score
8297// SetEntData(iPlayerManager, m_iPlayerScore + (4 * client), iScore, _, true);
8298//}
8299
8300//Find Valid Antenna
8301public FindValid_Antenna()
8302{
8303 new prop;
8304 while ((prop = FindEntityByClassname(prop, "prop_dynamic_override")) != INVALID_ENT_REFERENCE)
8305 {
8306 new String:propModelName[128];
8307 GetEntPropString(prop, Prop_Data, "m_ModelName", propModelName, 128);
8308 if (StrEqual(propModelName, "models/sernix/ied_jammer/ied_jammer.mdl"))
8309 {
8310 return prop;
8311 }
8312
8313 }
8314 return -1;
8315}
8316
8317
8318//### - UNCOMMENT BELOW TO USE CODE BELOW - ###
8319
8320// ================================================================================
8321// Start Rank System
8322// ================================================================================
8323//Load data from database
8324// public LoadMySQLBase(Handle:owner, Handle:hndl, const String:error[], any:data)
8325// {
8326// // Check DB
8327// if (hndl == INVALID_HANDLE)
8328// {
8329// //PrintToServer("Failed to connect: %s", error);
8330// g_hDB = INVALID_HANDLE;
8331// return;
8332// } else {
8333// //PrintToServer("DEBUG: DatabaseInit (CONNECTED)");
8334// }
8335
8336
8337// g_hDB = hndl;
8338// decl String:sQuery[1024];
8339
8340// // Set UTF8
8341// FormatEx(sQuery, sizeof(sQuery), "SET NAMES \"UTF8\"");
8342// SQL_TQuery(g_hDB, SQLErrorCheckCallback, sQuery);
8343
8344// // Get 'last_active'
8345// FormatEx(sQuery, sizeof(sQuery), "DELETE FROM ins_rank WHERE last_active <= %i", GetTime() - PLAYER_STATSOLD * 12 * 60 * 60);
8346// SQL_TQuery(g_hDB, SQLErrorCheckCallback, sQuery);
8347// }
8348
8349// // Init Client
8350// public OnClientAuthorized(client, const String:auth[])
8351// {
8352// InitializeClient(client);
8353// }
8354
8355// // Init Client
8356// public InitializeClient( client )
8357// {
8358// if ( !IsFakeClient(client) )
8359// {
8360// // Init stats
8361// g_iStatScore[client]=0;
8362// g_iStatKills[client]=0;
8363// g_iStatDeaths[client]=0;
8364// g_iStatHeadShots[client]=0;
8365// g_iStatSuicides[client]=0;
8366// g_iStatRevives[client]=0;
8367// g_iStatHeals[client]=0;
8368// g_iUserFlood[client]=0;
8369// g_iUserPtime[client]=GetTime();
8370
8371// // Get SteamID
8372// decl String:steamId[64];
8373// //GetClientAuthString(client, steamId, sizeof(steamId));
8374// GetClientAuthId(client, AuthId_Steam3, steamId, sizeof(steamId));
8375// g_sSteamIdSave[client] = steamId;
8376
8377// // Process Init
8378// CreateTimer(1.0, initPlayerBase, client);
8379// }
8380// }
8381
8382// // Init player
8383// public Action:initPlayerBase(Handle:timer, any:client){
8384// if (g_hDB != INVALID_HANDLE)
8385// {
8386// // Check player's data existance
8387// decl String:buffer[200];
8388// Format(buffer, sizeof(buffer), "SELECT * FROM ins_rank WHERE steamId = '%s'", g_sSteamIdSave[client]);
8389// if(DEBUG == 1){
8390// //PrintToServer("DEBUG: Action:initPlayerBase (%s)", buffer);
8391// }
8392// SQL_TQuery(g_hDB, SQLUserLoad, buffer, client);
8393// }
8394// else
8395// {
8396// // Join message
8397// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8398// }
8399// }
8400
8401// /*
8402// // Add kills and deaths
8403// public EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
8404// {
8405
8406// new victimId = GetEventInt(event, "userid");
8407// new attackerId = GetEventInt(event, "attacker");
8408
8409// new victim = GetClientOfUserId(victimId);
8410// new attacker = GetClientOfUserId(attackerId);
8411
8412// if(victim != attacker){
8413// g_iStatKills[attacker]++;
8414// g_iStatDeaths[victim]++;
8415
8416// } else {
8417// g_iStatSuicides[victim]++;
8418// g_iStatDeaths[victim]++;
8419// }
8420// }
8421
8422// // Add headshots
8423// public EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
8424// {
8425// new attackerId = GetEventInt(event, "attacker");
8426// new hitgroup = GetEventInt(event,"hitgroup");
8427
8428// new attacker = GetClientOfUserId(attackerId);
8429
8430// if ( hitgroup == 1 )
8431// {
8432// g_iStatHeadShots[attacker]++;
8433// }
8434// }
8435// */
8436
8437// // Save stats when player disconnect
8438// public OnClientDisconnect (client)
8439// {
8440// if ( !IsFakeClient(client) && g_iUserInit[client] == 1)
8441// {
8442// if (g_hDB != INVALID_HANDLE)
8443// {
8444// saveUser(client);
8445// g_iUserInit[client] = 0;
8446// }
8447// }
8448// }
8449
8450// // Save stats
8451// public saveUser(client){
8452// if ( !IsFakeClient(client) && g_iUserInit[client] == 1)
8453// {
8454// if (g_hDB != INVALID_HANDLE)
8455// {
8456// new String:buffer[200];
8457// Format(buffer, sizeof(buffer), "SELECT * FROM ins_rank WHERE steamId = '%s'", g_sSteamIdSave[client]);
8458// if(DEBUG == 1){
8459// //PrintToServer("DEBUG: saveUser (%s)", buffer);
8460// }
8461// SQL_TQuery(g_hDB, SQLUserSave, buffer, client);
8462// }
8463// }
8464// }
8465
8466// // Monitor say command
8467// public Action:Command_Say(client, args)
8468// {
8469// // Init variables
8470// decl String:text[192], String:command[64];
8471// new startidx = 0;
8472
8473// // Get cmd string
8474// GetCmdArgString(text, sizeof(text));
8475
8476// // Check string
8477// if (text[strlen(text)-1] == '"')
8478// {
8479// text[strlen(text)-1] = '\0';
8480// startidx = 1;
8481// }
8482// if (strcmp(command, "say2", false) == 0)
8483
8484// // Set start point
8485// startidx += 4;
8486
8487// // Check commands for stats
8488// // Rank
8489// if (strcmp(text[startidx], "/rank", false) == 0 || strcmp(text[startidx], "!rank", false) == 0 || strcmp(text[startidx], "rank", false) == 0) {
8490// if(g_iUserFlood[client] != 1){
8491// saveUser(client);
8492// //GetMyRank(client);
8493// CreateTimer(0.5, Timer_GetMyRank, client);
8494// g_iUserFlood[client]=1;
8495// CreateTimer(10.0, removeFlood, client);
8496// } else {
8497// PrintToChat(client,"%cDo not flood the server!", GREEN);
8498// }
8499// }
8500// // Top10
8501// else if (strcmp(text[startidx], "/top10", false) == 0 || strcmp(text[startidx], "!top10", false) == 0 || strcmp(text[startidx], "top10", false) == 0)
8502// {
8503// if(g_iUserFlood[client] != 1){
8504// saveUser(client);
8505// showTOP(client);
8506// g_iUserFlood[client]=1;
8507// CreateTimer(10.0, removeFlood, client);
8508// } else {
8509// PrintToChat(client,"%cDo not flood the server!", GREEN);
8510// }
8511// }
8512// // Top10
8513// else if (strcmp(text[startidx], "/topmedics", false) == 0 || strcmp(text[startidx], "!topmedics", false) == 0 || strcmp(text[startidx], "topmedics", false) == 0)
8514// {
8515// if(g_iUserFlood[client] != 1){
8516// saveUser(client);
8517// showTOPMedics(client);
8518// g_iUserFlood[client]=1;
8519// CreateTimer(10.0, removeFlood, client);
8520// } else {
8521// PrintToChat(client,"%cDo not flood the server!", GREEN);
8522// }
8523// }
8524// // Headhunters
8525// else if (strcmp(text[startidx], "/headhunters", false) == 0 || strcmp(text[startidx], "!headhunters", false) == 0 || strcmp(text[startidx], "headhunters", false) == 0)
8526// {
8527// if(g_iUserFlood[client] != 1){
8528// saveUser(client);
8529// showTOPHeadHunter(client);
8530// g_iUserFlood[client]=1;
8531// CreateTimer(10.0, removeFlood, client);
8532// } else {
8533// PrintToChat(client,"%cDo not flood the server!", GREEN);
8534// }
8535// }
8536// return Plugin_Continue;
8537// }
8538
8539// // Get My Rank
8540// public Action:Timer_GetMyRank(Handle:timer, any:client){
8541// if (IsClientInGame(client))
8542// GetMyRank(client);
8543// }
8544
8545// // Remove flood flag
8546// public Action:removeFlood(Handle:timer, any:client){
8547// g_iUserFlood[client]=0;
8548// }
8549
8550// // Get my rank
8551// public GetMyRank(client){
8552// // Check DB
8553// if (g_hDB != INVALID_HANDLE)
8554// {
8555// // Check player init
8556// if(g_iUserInit[client] == 1){
8557// // Get stat data from DB
8558// decl String:buffer[200];
8559// Format(buffer, sizeof(buffer), "SELECT `score`, `kills`, `deaths`, `headshots`, `sucsides`, `revives`, `heals` FROM `ins_rank` WHERE `steamId` = '%s' LIMIT 1", g_sSteamIdSave[client]);
8560// if(DEBUG == 1){
8561// //PrintToServer("DEBUG: GetMyRank (%s)", buffer);
8562// }
8563// SQL_TQuery(g_hDB, SQLGetMyRank, buffer, client);
8564// }
8565// else
8566// {
8567// PrintToChat(client,"%cWait for system load you from database", GREEN);
8568// }
8569// }
8570// else
8571// {
8572// PrintToChat(client, "%cRank System is now not available", GREEN);
8573// }
8574// }
8575
8576// // Get Top10
8577// public showTOP(client){
8578// // Check DB
8579// if (g_hDB != INVALID_HANDLE)
8580// {
8581// // Get Top10
8582// decl String:buffer[200];
8583// //Format(buffer, sizeof(buffer), "SELECT *, (`deaths`/`kills`) / `played_time` AS rankn FROM `ins_rank` WHERE `kills` > 0 AND `deaths` > 0 ORDER BY rankn ASC LIMIT 10");
8584// Format(buffer, sizeof(buffer), "SELECT *, `score` AS rankn FROM `ins_rank` WHERE `score` > 0 ORDER BY rankn DESC LIMIT 10");
8585// if(DEBUG == 1){
8586// //PrintToServer("DEBUG: showTOP (%s)", buffer);
8587// }
8588// SQL_TQuery(g_hDB, SQLTopShow, buffer, client);
8589// } else {
8590// PrintToChat(client, "%cRank System is now not avilable", GREEN);
8591// }
8592// }
8593
8594// // Get Top Medics
8595// public showTOPMedics(client){
8596// // Check DB
8597// if (g_hDB != INVALID_HANDLE)
8598// {
8599// // Get HadHunters
8600// decl String:buffer[200];
8601// Format(buffer, sizeof(buffer), "SELECT * FROM ins_rank ORDER BY revives, heals DESC LIMIT 10");
8602// if(DEBUG == 1){
8603// //PrintToServer("DEBUG: showTOPMedics (%s)", buffer);
8604// }
8605// SQL_TQuery(g_hDB, SQLTopShowMedic, buffer, client);
8606// } else {
8607// PrintToChat(client, "%cRank System is now not avilable", GREEN);
8608// }
8609// }
8610
8611// // Get HeadHunters
8612// public showTOPHeadHunter(client){
8613// // Check DB
8614// if (g_hDB != INVALID_HANDLE)
8615// {
8616// // Get HadHunters
8617// decl String:buffer[200];
8618// Format(buffer, sizeof(buffer), "SELECT * FROM ins_rank ORDER BY headshots DESC LIMIT 10");
8619// if(DEBUG == 1){
8620// //PrintToServer("DEBUG: showTOPHeadHunter (%s)", buffer);
8621// }
8622// SQL_TQuery(g_hDB, SQLTopShowHS, buffer, client);
8623// } else {
8624// PrintToChat(client, "%cRank System is now not avilable", GREEN);
8625// }
8626// }
8627// // Dummy menu
8628// public TopMenu(Handle:menu, MenuAction:action, param1, param2)
8629// {
8630// }
8631
8632// // SQL Callback (Check errors)
8633// public SQLErrorCheckCallback(Handle:owner, Handle:hndl, const String:error[], any:data)
8634// {
8635// if(!StrEqual("", error))
8636// {
8637// //PrintToServer("Last Connect SQL Error: %s", error);
8638// }
8639// }
8640
8641// // Check existance of player's data. If not add new.
8642// public SQLUserLoad(Handle:owner, Handle:hndl, const String:error[], any:client){
8643// if(SQL_FetchRow(hndl))
8644// {
8645// // Found player's data
8646// decl String:name[MAX_LINE_WIDTH];
8647// GetClientName( client, name, sizeof(name) );
8648
8649// // Remove special cheracters
8650// ReplaceString(name, sizeof(name), "'", "");
8651// ReplaceString(name, sizeof(name), "<", "");
8652// ReplaceString(name, sizeof(name), "\"", "");
8653
8654// // Update last active
8655// decl String:buffer[512];
8656// Format(buffer, sizeof(buffer), "UPDATE ins_rank SET nick = '%s', last_active = '%i' WHERE steamId = '%s'", name, GetTime(), g_sSteamIdSave[client]);
8657// if(DEBUG == 1){
8658// //PrintToServer("DEBUG: SQLUserLoad (%s)", buffer);
8659// }
8660// SQL_TQuery(g_hDB, SQLErrorCheckCallback, buffer);
8661
8662// // Init completed
8663// g_iUserInit[client] = 1;
8664// }
8665// else
8666// {
8667// // Add new record
8668// decl String:name[MAX_LINE_WIDTH];
8669// decl String:buffer[200];
8670
8671// // Get nickname
8672// GetClientName( client, name, sizeof(name) );
8673
8674// // Remove special cheracters
8675// ReplaceString(name, sizeof(name), "'", "");
8676// ReplaceString(name, sizeof(name), "<", "");
8677// ReplaceString(name, sizeof(name), "\"", "");
8678
8679// // Add new record
8680// Format(buffer, sizeof(buffer), "INSERT INTO ins_rank (steamId, nick, last_active) VALUES('%s', '%s', '%i')", g_sSteamIdSave[client], name, GetTime());
8681// if(DEBUG == 1){
8682// //PrintToServer("DEBUG: SQLUserLoad (%s)", buffer);
8683// }
8684// SQL_TQuery(g_hDB, SQLErrorCheckCallback, buffer);
8685
8686// // Init completed
8687// g_iUserInit[client] = 1;
8688// }
8689
8690// // Join message
8691// SQLDisplayJoinMessage(client);
8692// }
8693
8694// // Display join message - Get score
8695// void SQLDisplayJoinMessage(client)
8696// {
8697// // Get current score
8698// decl String:buffer[512];
8699// Format(buffer, sizeof(buffer), "SELECT score FROM ins_rank WHERE steamId = '%s'", g_sSteamIdSave[client]);
8700// SQL_TQuery(g_hDB, SQLJoinMsgGetScore, buffer, client);
8701// }
8702
8703// // Display join message - Get rank
8704// public SQLJoinMsgGetScore(Handle:owner, Handle:hndl, const String:error[], any:client)
8705// {
8706// // Check DB
8707// if(hndl == INVALID_HANDLE)
8708// {
8709// LogError(error);
8710// //PrintToServer("Last Connect SQL Error: %s", error);
8711// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8712// return;
8713// }
8714
8715// // Get data
8716// if(SQL_FetchRow(hndl))
8717// {
8718// // Get score
8719// new iScore = SQL_FetchInt(hndl, 0);
8720
8721// // Get player count
8722// decl String:buffer[512];
8723// Format(buffer, sizeof(buffer),"SELECT COUNT(*) FROM ins_rank WHERE score >= %i", iScore);
8724// SQL_TQuery(g_hDB, SQLJoinMsgGetRank, buffer, client);
8725// }
8726// else
8727// {
8728// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8729// }
8730// }
8731
8732// // Display join message - Get player count
8733// public SQLJoinMsgGetRank(Handle:owner, Handle:hndl, const String:error[], any:client)
8734// {
8735// // Check DB
8736// if(hndl == INVALID_HANDLE)
8737// {
8738// LogError(error);
8739// //PrintToServer("Last Connect SQL Error: %s", error);
8740// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8741// return;
8742// }
8743
8744// // Get data
8745// if(SQL_FetchRow(hndl))
8746// {
8747// // Get score
8748// new iRank = SQL_FetchInt(hndl, 0);
8749// g_iRank[client] = iRank;
8750
8751// // Get player count
8752// SQL_TQuery(g_hDB, SQLJoinMsgGetPlayerCount, "SELECT COUNT(*) FROM ins_rank", client);
8753// }
8754// else
8755// {
8756// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8757// }
8758// }
8759// // Display join message - Print to chat all
8760// public SQLJoinMsgGetPlayerCount(Handle:owner, Handle:hndl, const String:error[], any:client)
8761// {
8762// // Check DB
8763// if(hndl == INVALID_HANDLE)
8764// {
8765// LogError(error);
8766// //PrintToServer("Last Connect SQL Error: %s", error);
8767// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8768// return;
8769// }
8770
8771// // Get data
8772// if(SQL_FetchRow(hndl))
8773// {
8774// // Get player count
8775// new iPlayerCount = SQL_FetchInt(hndl, 0);
8776
8777// // Display join message
8778// PrintToChatAll("\x04%N\x01 joined the fight. \x05(Rank: %i of %i)", client, g_iRank[client], iPlayerCount);
8779// //PrintToServer("%N joined the fight. (Rank: %i of %i)", client, g_iRank[client], iPlayerCount);
8780// }
8781// else
8782// {
8783// PrintToChatAll("\x04%N\x01 joined the fight.", client);
8784// }
8785// }
8786
8787// // Save stats
8788// public SQLUserSave(Handle:owner, Handle:hndl, const String:error[], any:client){
8789// // Check DB
8790// if(hndl == INVALID_HANDLE)
8791// {
8792// LogError(error);
8793// //PrintToServer("Last Connect SQL Error: %s", error);
8794// return;
8795// }
8796
8797// // Declare variables
8798// decl QueryReadRow_SCORE;
8799// decl QueryReadRow_KILL;
8800// decl QueryReadRow_DEATHS;
8801// decl QueryReadRow_HEADSHOTS;
8802// decl QueryReadRow_SUCSIDES;
8803// decl QueryReadRow_REVIVES;
8804// decl QueryReadRow_HEALS;
8805// decl QueryReadRow_PTIME;
8806
8807// // Get record
8808// if(SQL_FetchRow(hndl))
8809// {
8810
8811// // Calculate score
8812// QueryReadRow_SCORE=GetPlayerScore(client) - g_iStatScore[client];
8813// if (QueryReadRow_SCORE < 0) QueryReadRow_SCORE=0;
8814// QueryReadRow_SCORE=SQL_FetchInt(hndl,3) + QueryReadRow_SCORE + (g_iStatRevives[client] * 20) + (g_iStatHeals[client] * 10);
8815
8816// QueryReadRow_KILL=SQL_FetchInt(hndl,4) + g_iStatKills[client];
8817// QueryReadRow_DEATHS=SQL_FetchInt(hndl,5) + g_iStatDeaths[client];
8818// QueryReadRow_HEADSHOTS=SQL_FetchInt(hndl,6) + g_iStatHeadShots[client];
8819// QueryReadRow_SUCSIDES=SQL_FetchInt(hndl,7) + g_iStatSuicides[client];
8820// QueryReadRow_REVIVES=SQL_FetchInt(hndl,8) + g_iStatRevives[client];
8821// QueryReadRow_HEALS=SQL_FetchInt(hndl,9) + g_iStatHeals[client];
8822// QueryReadRow_PTIME=SQL_FetchInt(hndl,11) + GetTime() - g_iUserPtime[client];
8823
8824// // Reset stats
8825// g_iStatScore[client] = GetPlayerScore(client);
8826// g_iStatKills[client] = 0;
8827// g_iStatDeaths[client] = 0;
8828// g_iStatHeadShots[client] = 0;
8829// g_iStatSuicides[client] = 0;
8830// g_iStatRevives[client] = 0;
8831// g_iStatHeals[client] = 0;
8832// g_iUserPtime[client] = GetTime();
8833
8834// // Update database
8835// decl String:buffer[512];
8836// Format(buffer, sizeof(buffer), "UPDATE ins_rank SET score = '%i', kills = '%i', deaths = '%i', headshots = '%i', sucsides = '%i', revives = '%i', heals = '%i', played_time = '%i' WHERE steamId = '%s'", QueryReadRow_SCORE, QueryReadRow_KILL, QueryReadRow_DEATHS, QueryReadRow_HEADSHOTS, QueryReadRow_SUCSIDES, QueryReadRow_REVIVES, QueryReadRow_HEALS, QueryReadRow_PTIME, g_sSteamIdSave[client]);
8837
8838// if(DEBUG == 1){
8839// //PrintToServer("DEBUG: SQLUserSave (%s)", buffer);
8840// }
8841
8842// SQL_TQuery(g_hDB, SQLErrorCheckCallback, buffer);
8843// }
8844// }
8845
8846// // Get my rank
8847// public SQLGetMyRank(Handle:owner, Handle:hndl, const String:error[], any:client){
8848// // Check DB
8849// if(hndl == INVALID_HANDLE)
8850// {
8851// LogError(error);
8852// //PrintToServer("Last Connect SQL Error: %s", error);
8853// return;
8854// }
8855
8856// // Declare variables
8857// decl RAscore;
8858// decl RAkills;
8859// decl RAdeaths;
8860// decl RAheadshots;
8861// decl RAsucsides;
8862// decl RArevives;
8863// decl RAheals;
8864
8865// // Get record
8866// if(SQL_FetchRow(hndl))
8867// {
8868// // Get stats
8869// RAscore=SQL_FetchInt(hndl, 0);
8870// RAkills=SQL_FetchInt(hndl, 1);
8871// RAdeaths=SQL_FetchInt(hndl, 2);
8872// RAheadshots=SQL_FetchInt(hndl, 3);
8873// RAsucsides=SQL_FetchInt(hndl, 4);
8874// RArevives=SQL_FetchInt(hndl, 5);
8875// RAheals=SQL_FetchInt(hndl, 6);
8876
8877// decl String:buffer[512];
8878// //test
8879// // 0.00027144
8880// //STEAM_0:1:13462423
8881// //Format(buffer, sizeof(buffer), "SELECT ((`deaths`/`kills`)/`played_time`) AS rankn FROM `ins_rank` WHERE (`kills` > 0 AND `deaths` > 0) AND ((`deaths`/`kills`)/`played_time`) < (SELECT ((`deaths`/`kills`)/`played_time`) FROM `ins_rank` WHERE steamId = '%s' LIMIT 1) AND `steamId` != '%s' ORDER BY rankn ASC", g_sSteamIdSave[client], g_sSteamIdSave[client]);
8882
8883// // Get rank
8884// Format(buffer, sizeof(buffer), "SELECT COUNT(*) FROM ins_rank WHERE score >= %i", RAscore);
8885// SQL_TQuery(g_hDB, SQLGetRank, buffer, client);
8886
8887// PrintToChat(client,"%cScore: %i | Kills: %i | Revives: %i | Heals: %i | Deaths: %i | Headshots: %i | Suicides: %i", GREEN, RAscore, RAkills, RArevives, RAheals, RAdeaths, RAheadshots, RAsucsides);
8888// } else {
8889// PrintToChat(client, "%cYour rank is not available!", GREEN);
8890// }
8891// }
8892
8893// // Get my rank - Get rank
8894// public SQLGetRank(Handle:owner, Handle:hndl, const String:error[], any:client){
8895// // Check DB
8896// if(hndl == INVALID_HANDLE)
8897// {
8898// LogError(error);
8899// //PrintToServer("Last Connect SQL Error: %s", error);
8900// return;
8901// }
8902
8903// // Get record
8904// if(SQL_FetchRow(hndl))
8905// {
8906// // Get rank
8907// new iRank = SQL_FetchInt(hndl, 0);
8908// g_iRank[client] = iRank;
8909
8910// // Get player count
8911// SQL_TQuery(g_hDB, SQLShowRankToChat, "SELECT COUNT(*) FROM ins_rank", client);
8912// } else {
8913// PrintToChat(client, "%cYour rank is not avlilable!", GREEN);
8914// }
8915// }
8916
8917// // Get my rank - Get player count
8918// public SQLShowRankToChat(Handle:owner, Handle:hndl, const String:error[], any:client){
8919// // Check DB
8920// if(hndl == INVALID_HANDLE)
8921// {
8922// LogError(error);
8923// //PrintToServer("Last Connect SQL Error: %s", error);
8924// return;
8925// }
8926
8927// // Get record
8928// if(SQL_FetchRow(hndl))
8929// {
8930// // Get player count
8931// new iPlayerCount = SQL_FetchInt(hndl, 0);
8932
8933// // Display rank
8934// PrintToChat(client,"%cYour rank is: %i (of %i).", GREEN, g_iRank[client], iPlayerCount);
8935// } else {
8936// PrintToChat(client, "%cYour rank is not avlilable!", GREEN);
8937// }
8938// }
8939
8940// // Show top 10
8941// public SQLTopShow(Handle:owner, Handle:hndl, const String:error[], any:client){
8942// // Check DB
8943// if(hndl == INVALID_HANDLE)
8944// {
8945// LogError(error);
8946// //PrintToServer("Last Connect SQL Error: %s", error);
8947// return;
8948// }
8949
8950// // Init panel
8951// new Handle:hPanel = CreatePanel(GetMenuStyleHandle(MenuStyle_Radio));
8952// new String:text[128];
8953// Format(text,127,"Top 10 Players");
8954// SetPanelTitle(hPanel,text);
8955
8956// // Init variables
8957// decl row;
8958// decl String:name[64];
8959// decl score;
8960// decl kills;
8961// decl deaths;
8962
8963// // Check result
8964// if (SQL_HasResultSet(hndl))
8965// {
8966// // Loop players
8967// while (SQL_FetchRow(hndl))
8968// {
8969// row++;
8970// // Nickname
8971// SQL_FetchString(hndl, 2, name, sizeof(name));
8972
8973// // Stats
8974// score=SQL_FetchInt(hndl,3);
8975// kills=SQL_FetchInt(hndl,4);
8976// deaths=SQL_FetchInt(hndl,5);
8977
8978// // Set text
8979// Format(text,127,"[%d] %s", row, name);
8980// DrawPanelText(hPanel, text);
8981// Format(text,127," - Score: %i | Kills: %i | Deaths: %i", score, kills, deaths);
8982// DrawPanelText(hPanel, text);
8983// }
8984// } else {
8985// Format(text,127,"TOP 10 is empty!");
8986// DrawPanelText(hPanel, text);
8987// }
8988
8989// // Draw panel
8990// DrawPanelItem(hPanel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
8991
8992// Format(text,59,"Exit");
8993// DrawPanelItem(hPanel, text);
8994
8995// SendPanelToClient(hPanel, client, TopMenu, 20);
8996
8997// CloseHandle(hPanel);
8998// }
8999
9000// // Show Top medics
9001// public SQLTopShowMedic(Handle:owner, Handle:hndl, const String:error[], any:client){
9002// // Check DB
9003// if(hndl == INVALID_HANDLE)
9004// {
9005// LogError(error);
9006// //PrintToServer("Last Connect SQL Error: %s", error);
9007// return;
9008// }
9009
9010// // Init panel
9011// new Handle:hPanel = CreatePanel(GetMenuStyleHandle(MenuStyle_Radio));
9012// new String:text[128];
9013// Format(text,127,"Top Medics");
9014// SetPanelTitle(hPanel,text);
9015
9016// // Init variables
9017// decl row;
9018// decl String:name[64];
9019// decl revives;
9020// decl heals;
9021
9022// // Check result
9023// if (SQL_HasResultSet(hndl))
9024// {
9025// // Loop players
9026// while (SQL_FetchRow(hndl))
9027// {
9028// row++;
9029// // Nickname
9030// SQL_FetchString(hndl, 2, name, sizeof(name));
9031
9032// // Stats
9033// revives=SQL_FetchInt(hndl,8);
9034// heals=SQL_FetchInt(hndl,9);
9035
9036// // Set text
9037// Format(text,127,"[%d] %s", row, name);
9038// DrawPanelText(hPanel, text);
9039// Format(text,127," - Revives: %i | Heals: %i", revives, heals);
9040// DrawPanelText(hPanel, text);
9041// }
9042// } else {
9043// Format(text,127,"TOP Medics is empty!");
9044// DrawPanelText(hPanel, text);
9045// }
9046
9047// // Draw panel
9048// DrawPanelItem(hPanel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
9049
9050// Format(text,59,"Exit");
9051// DrawPanelItem(hPanel, text);
9052
9053// SendPanelToClient(hPanel, client, TopMenu, 20);
9054
9055// CloseHandle(hPanel);
9056// }
9057// // Show Headhunters
9058// public SQLTopShowHS(Handle:owner, Handle:hndl, const String:error[], any:client){
9059// // Check DB
9060// if(hndl == INVALID_HANDLE)
9061// {
9062// LogError(error);
9063// //PrintToServer("Last Connect SQL Error: %s", error);
9064// return;
9065// }
9066
9067// // Init panel
9068// new Handle:hPanel = CreatePanel(GetMenuStyleHandle(MenuStyle_Radio));
9069// new String:text[128];
9070// Format(text,127,"Top 10 Headhunters");
9071// SetPanelTitle(hPanel,text);
9072
9073// // Init variables
9074// decl row;
9075// decl String:name[64];
9076// decl shoths;
9077// decl ptimed;
9078// decl String:textime[64];
9079
9080// // Check result
9081// if (SQL_HasResultSet(hndl))
9082// {
9083// // Loop players
9084// while (SQL_FetchRow(hndl))
9085// {
9086// row++;
9087// // Nickname
9088// SQL_FetchString(hndl, 2, name, sizeof(name));
9089
9090// // Stats
9091// shoths=SQL_FetchInt(hndl,6);
9092// ptimed=SQL_FetchInt(hndl,11);
9093
9094// // Calc
9095// if(ptimed <= 3600){
9096// Format(textime,63,"%i m.", ptimed / 60);
9097// } else if(ptimed <= 43200){
9098// Format(textime,63,"%i h.", ptimed / 60 / 60);
9099// } else if(ptimed <= 1339200){
9100// Format(textime,63,"%i d.", ptimed / 60 / 60 / 12);
9101// } else {
9102// Format(textime,63,"%i mo.", ptimed / 60 / 60 / 12 / 31);
9103// }
9104
9105// // Set text
9106// Format(text,127,"[%d] %s", row, name);
9107// DrawPanelText(hPanel, text);
9108// Format(text,127," - HS: %i - In Time: %s", shoths, textime);
9109// DrawPanelText(hPanel, text);
9110// }
9111// } else {
9112// Format(text,127,"TOP Headhunters is empty!");
9113// DrawPanelText(hPanel, text);
9114// }
9115
9116// // Display panel
9117// DrawPanelItem(hPanel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
9118
9119// Format(text,59,"Exit");
9120// DrawPanelItem(hPanel, text);
9121
9122// SendPanelToClient(hPanel, client, TopMenu, 20);
9123
9124// CloseHandle(hPanel);
9125// }
9126
9127/*
9128PrintQueryData(Handle:query)
9129{
9130 if (!SQL_HasResultSet(query))
9131 {
9132 //PrintToServer("Query Handle %x has no results", query)
9133 return
9134 }
9135
9136 new rows = SQL_GetRowCount(query)
9137 new fields = SQL_GetFieldCount(query)
9138
9139 decl String:fieldNames[fields][32]
9140 //PrintToServer("Fields: %d", fields)
9141 for (new i=0; i<fields; i++)
9142 {
9143 SQL_FieldNumToName(query, i, fieldNames[i], 32)
9144 //PrintToServer("-> Field %d: \"%s\"", i, fieldNames[i])
9145 }
9146
9147 //PrintToServer("Rows: %d", rows)
9148 decl String:result[255]
9149 new row
9150 while (SQL_FetchRow(query))
9151 {
9152 row++
9153 //PrintToServer("Row %d:", row)
9154 for (new i=0; i<fields; i++)
9155 {
9156 SQL_FetchString(query, i, result, sizeof(result))
9157 //PrintToServer(" [%s] %s", fieldNames[i], result)
9158 }
9159 }
9160}
9161*/
9162
9163
9164/*
9165########################LUA HEALING INTEGRATION######################
9166# This portion of the script adds in health packs from Lua #
9167##############################START##################################
9168#####################################################################
9169*/
9170public Action:Event_GrenadeThrown(Handle:event, const String:name[], bool:dontBroadcast)
9171{
9172 new client = GetClientOfUserId(GetEventInt(event, "userid"));
9173 new nade_id = GetEventInt(event, "entityid");
9174 if (nade_id > -1 && client > -1)
9175 {
9176 if (IsPlayerAlive(client))
9177 {
9178 decl String:grenade_name[32];
9179 GetEntityClassname(nade_id, grenade_name, sizeof(grenade_name));
9180 if (StrEqual(grenade_name, "healthkit"))
9181 {
9182 switch(GetRandomInt(1, 18))
9183 {
9184 case 1: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9185 case 2: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9186 case 3: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9187 case 4: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9188 case 5: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9189 case 6: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/moving2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9190 case 7: EmitSoundToAll("player/voice/radial/security/leader/suppressed/backup3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9191 case 8: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9192 case 9: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9193 case 10: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9194 case 11: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9195 case 12: EmitSoundToAll("player/voice/radial/security/leader/suppressed/moving3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9196 case 13: EmitSoundToAll("player/voice/radial/security/leader/suppressed/ontheway1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9197 case 14: EmitSoundToAll("player/voice/security/command/leader/located4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9198 case 15: EmitSoundToAll("player/voice/security/command/leader/setwaypoint1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9199 case 16: EmitSoundToAll("player/voice/security/command/leader/setwaypoint2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9200 case 17: EmitSoundToAll("player/voice/security/command/leader/setwaypoint3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9201 case 18: EmitSoundToAll("player/voice/security/command/leader/setwaypoint4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
9202 }
9203 }
9204 }
9205 }
9206}
9207
9208//Healthkit Start
9209
9210public OnEntityDestroyed(entity)
9211{
9212 if (entity > MaxClients)
9213 {
9214 decl String:classname[255];
9215 GetEntityClassname(entity, classname, 255);
9216 if (StrEqual(classname, "healthkit"))
9217 {
9218 //StopSound(entity, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
9219 }
9220 if (!(StrContains(classname, "wcache_crate_01") > -1))
9221 {
9222 g_ammoResupplyAmt[entity] = 0;
9223 }
9224 }
9225}
9226
9227public OnEntityCreated(entity, const String:classname[])
9228{
9229
9230 if (StrEqual(classname, "healthkit"))
9231 {
9232 new Handle:hDatapack;
9233
9234 g_healthPack_Amount[entity] = g_medpack_health_amt;
9235 CreateDataTimer(Healthkit_Timer_Tickrate, Healthkit, hDatapack, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
9236 WritePackCell(hDatapack, entity);
9237 WritePackFloat(hDatapack, GetGameTime()+Healthkit_Timer_Timeout);
9238 g_fLastHeight[entity] = -9999.0;
9239 g_iTimeCheckHeight[entity] = -9999;
9240 SDKHook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck);
9241 CreateTimer(0.1, HealthkitGroundCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
9242 }
9243 else if (StrEqual(classname, "grenade_m67") || StrEqual(classname, "grenade_f1"))
9244 {
9245 CreateTimer(0.5, GrenadeScreamCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
9246 }
9247 else if (StrEqual(classname, "grenade_molotov") || StrEqual(classname, "grenade_anm14"))
9248 CreateTimer(0.2, FireScreamCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
9249
9250
9251
9252}
9253public Action:FireScreamCheckTimer(Handle:timer, any:entity)
9254{
9255 new Float:fGrenOrigin[3];
9256 new Float:fPlayerOrigin[3];
9257 new Float:fPlayerEyeOrigin[3];
9258 new owner;
9259 if (IsValidEntity(entity) && entity > 0)
9260 {
9261 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fGrenOrigin);
9262 owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
9263 }
9264 else
9265 KillTimer(timer);
9266
9267
9268
9269
9270 for (new client = 1;client <= MaxClients;client++)
9271 {
9272 if (client <= 0 || !IsClientInGame(client) || !IsClientConnected(client))
9273 continue;
9274 if (owner <= 0 || !IsClientInGame(owner) || !IsClientConnected(owner))
9275 continue;
9276 if (IsFakeClient(client))
9277 continue;
9278
9279 if (IsPlayerAlive(client) && GetClientTeam(client) == 2 && GetClientTeam(owner) == 3)
9280 {
9281
9282 GetClientEyePosition(client, fPlayerEyeOrigin);
9283 GetClientAbsOrigin(client,fPlayerOrigin);
9284 //new Handle:trace = TR_TraceRayFilterEx(fPlayerEyeOrigin, fGrenOrigin, MASK_SOLID_BRUSHONLY, RayType_EndPoint, Base_TraceFilter);
9285
9286 if (GetVectorDistance(fPlayerOrigin, fGrenOrigin) <= 300 && g_plyrFireScreamCoolDown[client] <= 0)// && TR_DidHit(trace) && fGrenOrigin[2] > 0)
9287 {
9288 //PrintToServer("SCREAM FIRE");
9289 PlayerFireScreamRand(client);
9290 new fRandomInt = GetRandomInt(20, 30);
9291 g_plyrFireScreamCoolDown[client] = fRandomInt;
9292 //CloseHandle(trace);
9293 }
9294 }
9295 }
9296
9297 if (!IsValidEntity(entity) || !(entity > 0))
9298 KillTimer(timer);
9299}
9300public Action:GrenadeScreamCheckTimer(Handle:timer, any:entity)
9301{
9302 new Float:fGrenOrigin[3];
9303 new Float:fPlayerOrigin[3];
9304 new Float:fPlayerEyeOrigin[3];
9305 new owner;
9306 if (IsValidEntity(entity) && entity > 0)
9307 {
9308 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fGrenOrigin);
9309 owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
9310 }
9311 else
9312 KillTimer(timer);
9313
9314 for (new client = 1;client <= MaxClients;client++)
9315 {
9316 if (client <= 0 || !IsClientInGame(client) || !IsClientConnected(client))
9317 continue;
9318
9319 if (IsFakeClient(client))
9320 continue;
9321
9322 if (client > 0 && IsPlayerAlive(client) && GetClientTeam(client) == 2 && GetClientTeam(owner) == 3)
9323 {
9324
9325 GetClientEyePosition(client, fPlayerEyeOrigin);
9326 GetClientAbsOrigin(client,fPlayerOrigin);
9327 //new Handle:trace = TR_TraceRayFilterEx(fPlayerEyeOrigin, fGrenOrigin, MASK_VISIBLE, RayType_EndPoint, Base_TraceFilter);
9328
9329 if (GetVectorDistance(fPlayerOrigin, fGrenOrigin) <= 240 && g_plyrGrenScreamCoolDown[client] <= 0)// && TR_DidHit(trace) && fGrenOrigin[2] > 0)
9330 {
9331 PlayerGrenadeScreamRand(client);
9332 new fRandomInt = GetRandomInt(6, 12);
9333 g_plyrGrenScreamCoolDown[client] = fRandomInt;
9334 //CloseHandle(trace);
9335 }
9336 }
9337 }
9338
9339 if (!IsValidEntity(entity) || !(entity > 0))
9340 KillTimer(timer);
9341}
9342public Action:HealthkitGroundCheck(entity, activator, caller, UseType:type, Float:value)
9343{
9344 new Float:fOrigin[3];
9345 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
9346 new iRoundHeight = RoundFloat(fOrigin[2]);
9347 if (iRoundHeight != g_iTimeCheckHeight[entity])
9348 {
9349 g_iTimeCheckHeight[entity] = iRoundHeight;
9350 g_fTimeCheck[entity] = GetGameTime();
9351 }
9352}
9353
9354public Action:HealthkitGroundCheckTimer(Handle:timer, any:entity)
9355{
9356 if (entity > MaxClients && IsValidEntity(entity))
9357 {
9358 new Float:fGameTime = GetGameTime();
9359 if (fGameTime-g_fTimeCheck[entity] >= 1.0)
9360 {
9361 new Float:fOrigin[3];
9362 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
9363 new iRoundHeight = RoundFloat(fOrigin[2]);
9364 if (iRoundHeight == g_iTimeCheckHeight[entity])
9365 {
9366 g_fTimeCheck[entity] = GetGameTime();
9367 SDKUnhook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck);
9368 SDKHook(entity, SDKHook_VPhysicsUpdate, OnEntityPhysicsUpdate);
9369 KillTimer(timer);
9370 }
9371 }
9372 }
9373 else KillTimer(timer);
9374}
9375
9376public Action:OnEntityPhysicsUpdate(entity, activator, caller, UseType:type, Float:value)
9377{
9378 TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, Float:{0.0, 0.0, 0.0});
9379}
9380
9381public Action:Healthkit(Handle:timer, Handle:hDatapack)
9382{
9383 ResetPack(hDatapack);
9384 new entity = ReadPackCell(hDatapack);
9385 new Float:fEndTime = ReadPackFloat(hDatapack);
9386 new Float:fGameTime = GetGameTime();
9387 //PrintToServer("fGameTime %i",fGameTime);
9388 //PrintToServer("g_healthPack_Amount %i",g_healthPack_Amount[entity]);
9389 if (entity > 0 && IsValidEntity(entity) && fGameTime > fEndTime)
9390 {
9391 RemoveHealthkit(entity);
9392 KillTimer(timer);
9393 return Plugin_Stop;
9394 }
9395 if (g_healthPack_Amount[entity] > 0)
9396 {
9397 //PrintToServer("DEBUG 1");
9398 if (entity > 0 && IsValidEntity(entity))
9399 {
9400 //PrintToServer("DEBUG 2");
9401 new Float:fOrigin[3];
9402 GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
9403 if (g_fLastHeight[entity] == -9999.0)
9404 {
9405 g_fLastHeight[entity] = 0.0;
9406 //Play sound
9407
9408 //PrintToServer("DEBUG 3");
9409 }
9410 fOrigin[2] += 1.0;
9411 TE_SetupBeamRingPoint(fOrigin, 1.0, Healthkit_Radius*1.95, g_iBeaconBeam, g_iBeaconHalo, 0, 30, 5.0, 3.0, 0.0, {0, 200, 0, 255}, 1, (FBEAM_FADEOUT));
9412 //void TE_SetupBeamRingPoint(const float center[3], float Start_Radius, float End_Radius, int ModelIndex, int HaloIndex, int StartFrame, int FrameRate, float Life, float Width, float Amplitude, const int Color[4], int Speed, int Flags)
9413 TE_SendToAll();
9414 fOrigin[2] -= 16.0;
9415 if (fOrigin[2] != g_fLastHeight[entity])
9416 {
9417 g_fLastHeight[entity] = fOrigin[2];
9418 }
9419 else
9420 {
9421 new Float:fAng[3];
9422 GetEntPropVector(entity, Prop_Send, "m_angRotation", fAng);
9423 if (fAng[1] > 89.0 || fAng[1] < -89.0)
9424 fAng[1] = 90.0;
9425 if (fAng[2] > 89.0 || fAng[2] < -89.0)
9426 {
9427 fAng[2] = 0.0;
9428 fOrigin[2] -= 6.0;
9429 TeleportEntity(entity, fOrigin, fAng, Float:{0.0, 0.0, 0.0});
9430 fOrigin[2] += 6.0;
9431 EmitSoundToAll("ui/sfx/cl_click.wav", entity, SNDCHAN_VOICE, _, _, 1.0);
9432 }
9433 }
9434 for (new client = 1;client <= MaxClients;client++)
9435 {
9436 if (IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 2)
9437 {
9438 //non medic area heal self
9439 if (!(StrContains(g_client_last_classstring[client], "medic") > -1))
9440 {
9441 decl Float:fPlayerOrigin[3];
9442 GetClientEyePosition(client, fPlayerOrigin);
9443 if (GetVectorDistance(fPlayerOrigin, fOrigin) <= Healthkit_Radius)
9444 {
9445 //PrintToServer("DEBUG 5");
9446 //g_medpack_health_amt
9447 new Handle:hData = CreateDataPack();
9448 WritePackCell(hData, entity);
9449 WritePackCell(hData, client);
9450 //fOrigin[2] += 6.0;
9451 //new Handle:trace = TR_TraceRayFilterEx(fPlayerOrigin, fOrigin, MASK_SOLID, RayType_EndPoint, Filter_ClientSelf, hData);
9452 CloseHandle(hData);
9453 new isMedicNearby = Check_NearbyMedics(client);
9454 //if (!TR_DidHit(trace))
9455 if (isMedicNearby)
9456 {
9457 //PrintToServer("DEBUG 4");
9458 new iHealth = GetClientHealth(client);
9459 //new iMaxHealth = GetEntProp(client, Prop_Data, "m_iMaxHealth");
9460 //new iHealth = GetEntProp(client, Prop_Data, "m_iHealth");
9461 if (iHealth < 100)
9462 {
9463 //PrintToServer("DEBUG 6");
9464 iHealth += g_iHeal_amount_paddles;
9465 g_healthPack_Amount[entity] -= g_iHeal_amount_paddles;
9466 if (iHealth >= 100)
9467 {
9468 //EmitSoundToAll("Lua_sounds/healthkit_complete.wav", client, SNDCHAN_STATIC, _, _, 1.0);
9469 iHealth = 100;
9470 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9471 PrintHintText(client, "A medic assisted in healing you (HP: %i)", iHealth);
9472 }
9473 else
9474 {
9475 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9476 PrintHintText(client, "Medic area healing you (HP: %i)", iHealth);
9477 switch(GetRandomInt(1, 6))
9478 {
9479 case 1: EmitSoundToAll("weapons/universal/uni_crawl_l_01.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9480 case 2: EmitSoundToAll("weapons/universal/uni_crawl_l_04.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9481 case 3: EmitSoundToAll("weapons/universal/uni_crawl_l_02.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9482 case 4: EmitSoundToAll("weapons/universal/uni_crawl_r_03.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9483 case 5: EmitSoundToAll("weapons/universal/uni_crawl_r_05.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9484 case 6: EmitSoundToAll("weapons/universal/uni_crawl_r_06.wav", client, SNDCHAN_VOICE, _, _, 1.0);
9485 }
9486 }
9487
9488 SetEntityHealth(client, iHealth);
9489 }
9490 }
9491 else
9492 {
9493 //PrintToServer("DEBUG 7");
9494 //Get weapon
9495 decl String:sWeapon[32];
9496 new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
9497 if (ActiveWeapon < 0)
9498 continue;
9499
9500 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
9501 new iHealth = GetClientHealth(client);
9502 if ((StrContains(sWeapon, "weapon_knife") > -1))
9503 {
9504 //PrintToServer("DEBUG 8");
9505 if (iHealth < g_nonMedicHealSelf_max)
9506 {
9507 //PrintToServer("DEBUG 9");
9508 iHealth += g_nonMedicHeal_amount;
9509 g_healthPack_Amount[entity] -= g_nonMedicHeal_amount;
9510 if (iHealth >= g_nonMedicHealSelf_max)
9511 {
9512 //PrintToServer("DEBUG 10");
9513 //EmitSoundToAll("Lua_sounds/healthkit_complete.wav", client, SNDCHAN_STATIC, _, _, 1.0);
9514 iHealth = g_nonMedicHealSelf_max;
9515 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9516 PrintHintText(client, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
9517 }
9518 else
9519 {
9520 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9521 PrintHintText(client, "Healing Self (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
9522 }
9523
9524 SetEntityHealth(client, iHealth);
9525 }
9526 else
9527 {
9528 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9529 PrintHintText(client, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
9530 }
9531
9532 }
9533 else if (iHealth < g_nonMedicHealSelf_max && !(StrContains(sWeapon, "weapon_knife") > -1))
9534 {
9535 PrintHintText(client, "No medics nearby! Pull knife out to heal! (HP: %i)", iHealth);
9536 }
9537 }
9538
9539 }
9540 } //Medic assist area heal and self heal
9541 else if ((StrContains(g_client_last_classstring[client], "medic") > -1))
9542 {
9543 decl Float:fPlayerOrigin[3];
9544 GetClientEyePosition(client, fPlayerOrigin);
9545 if (GetVectorDistance(fPlayerOrigin, fOrigin) <= Healthkit_Radius)
9546 {
9547 //g_medpack_health_amt
9548 new Handle:hData = CreateDataPack();
9549 WritePackCell(hData, entity);
9550 WritePackCell(hData, client);
9551 fOrigin[2] += 32.0;
9552 //new Handle:trace = TR_TraceRayFilterEx(fPlayerOrigin, fOrigin, MASK_SOLID, RayType_EndPoint, Filter_ClientSelf, hData);
9553 CloseHandle(hData);
9554
9555 new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
9556 if (ActiveWeapon < 0)
9557 continue;
9558
9559 // Get weapon class name
9560 decl String:sWeapon[32];
9561 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
9562 //new bool:bCanHealPaddle = false; - commented by oz
9563 if (((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)))
9564 {
9565 //PrintToServer("DEBUG 3");
9566 new iHealth = GetClientHealth(client);
9567 //new iMaxHealth = GetEntProp(client, Prop_Data, "m_iMaxHealth");
9568 //new iHealth = GetEntProp(client, Prop_Data, "m_iHealth");
9569 if (Check_NearbyMedics(client))
9570 {
9571 if (iHealth < 100)
9572 {
9573 iHealth += g_iHeal_amount_paddles;
9574 g_healthPack_Amount[entity] -= g_iHeal_amount_paddles;
9575 if (iHealth >= 100)
9576 {
9577 //EmitSoundToAll("Lua_sounds/healthkit_complete.wav", client, SNDCHAN_STATIC, _, _, 1.0);
9578 iHealth = 100;
9579 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9580 PrintHintText(client, "A medic assisted in healing you (HP: %i)", iHealth);
9581 }
9582 else
9583 {
9584 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9585 PrintHintText(client, "Self area healing (HP: %i)", iHealth);
9586 }
9587
9588 SetEntityHealth(client, iHealth);
9589 }
9590 }
9591 else
9592 {
9593 if (iHealth < g_medicHealSelf_max)
9594 {
9595 iHealth += g_iHeal_amount_paddles;
9596 g_healthPack_Amount[entity] -= g_iHeal_amount_paddles;
9597 if (iHealth >= g_medicHealSelf_max)
9598 {
9599 //EmitSoundToAll("Lua_sounds/healthkit_complete.wav", client, SNDCHAN_STATIC, _, _, 1.0);
9600 iHealth = g_medicHealSelf_max;
9601 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9602 PrintHintText(client, "You area healed yourself (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
9603 }
9604 else
9605 {
9606 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9607 PrintHintText(client, "Self area healing (HP: %i) | MAX %i", iHealth, g_medicHealSelf_max);
9608 }
9609 }
9610 else
9611 {
9612 PrintCenterText(client, "Medical Pack HP Left: %i", g_healthPack_Amount[entity]);
9613 PrintHintText(client, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
9614 }
9615 }
9616 }
9617 }
9618 }
9619 }
9620 }
9621 }
9622 else
9623 {
9624 //PrintToServer("DEBUG 4");
9625 RemoveHealthkit(entity);
9626 KillTimer(timer);
9627 }
9628 }
9629 else if (g_healthPack_Amount[entity] <= 0)
9630 {
9631 //PrintToServer("DEBUG 5");
9632 RemoveHealthkit(entity);
9633 KillTimer(timer);
9634 }
9635 return Plugin_Continue;
9636}
9637
9638
9639
9640
9641public bool:Filter_ClientSelf(entity, contentsMask, any:data)
9642{
9643 ResetPack(data);
9644 new client = ReadPackCell(data);
9645 new player = ReadPackCell(data);
9646 if (entity != client && entity != player)
9647 return true;
9648 return false;
9649}
9650
9651public RemoveHealthkit(entity)
9652{
9653 if (entity > MaxClients && IsValidEntity(entity))
9654 {
9655 //StopSound(entity, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
9656 //EmitSoundToAll("soundscape/emitters/oneshot/radio_explode.ogg", entity, SNDCHAN_STATIC, _, _, 1.0);
9657
9658 //new dissolver = CreateEntityByName("env_entity_dissolver");
9659 //if (dissolver != -1)
9660 //{
9661 // DispatchKeyValue(dissolver, "dissolvetype", Healthkit_Remove_Type);
9662 // DispatchKeyValue(dissolver, "magnitude", "1");
9663 // DispatchKeyValue(dissolver, "target", "!activator");
9664 // AcceptEntityInput(dissolver, "Dissolve", entity);
9665 // AcceptEntityInput(dissolver, "Kill");
9666
9667 AcceptEntityInput(entity, "Kill");
9668 //}
9669 }
9670}
9671
9672public Check_NearbyMedics(client)
9673{
9674 for (new friendlyMedic = 1; friendlyMedic <= MaxClients; friendlyMedic++)
9675 {
9676 if (IsClientConnected(friendlyMedic) && IsClientInGame(friendlyMedic) && !IsFakeClient(friendlyMedic))
9677 {
9678 //PrintToServer("Medic 1");
9679 //new team = GetClientTeam(friendlyMedic);
9680 if (IsPlayerAlive(friendlyMedic) && (StrContains(g_client_last_classstring[friendlyMedic], "medic") > -1) && client != friendlyMedic)
9681 {
9682 //PrintToServer("Medic 2");
9683 //Get position of bot and prop
9684 new Float:plyrOrigin[3];
9685 new Float:medicOrigin[3];
9686 new Float:fDistance;
9687
9688 GetClientAbsOrigin(client,plyrOrigin);
9689 GetClientAbsOrigin(friendlyMedic,medicOrigin);
9690 //GetEntPropVector(entity, Prop_Send, "m_vecOrigin", propOrigin);
9691
9692 //determine distance from the two
9693 fDistance = GetVectorDistance(medicOrigin,plyrOrigin);
9694
9695 new ActiveWeapon = GetEntPropEnt(friendlyMedic, Prop_Data, "m_hActiveWeapon");
9696 if (ActiveWeapon < 0)
9697 continue;
9698
9699 // Get weapon class name
9700 decl String:sWeapon[32];
9701 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
9702
9703 //PrintToServer("Medic 3");
9704 new bool:bCanHealPaddle = false;
9705 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1) || (StrContains(sWeapon, "weapon_healthkit") > -1))
9706 {
9707 //PrintToServer("Medic 4");
9708 bCanHealPaddle = true;
9709 }
9710 if (fDistance <= Healthkit_Radius && bCanHealPaddle)
9711 {
9712 //PrintToServer("Medic 5");
9713 return true;
9714 }
9715 }
9716 }
9717 }
9718 return false;
9719}
9720
9721//This is to award nearby medics that participate in reviving a player
9722public Check_NearbyMedicsRevive(client, iInjured)
9723{
9724 for (new friendlyMedic = 1; friendlyMedic <= MaxClients; friendlyMedic++)
9725 {
9726 if (IsClientConnected(friendlyMedic) && IsClientInGame(friendlyMedic) && !IsFakeClient(friendlyMedic))
9727 {
9728 //PrintToServer("Medic 1");
9729 //new team = GetClientTeam(friendlyMedic);
9730 if (IsPlayerAlive(friendlyMedic) && (StrContains(g_client_last_classstring[friendlyMedic], "medic") > -1) && client != friendlyMedic)
9731 {
9732 //PrintToServer("Medic 2");
9733 //Get position of bot and prop
9734 new Float:medicOrigin[3];
9735 new Float:fDistance;
9736
9737 GetClientAbsOrigin(friendlyMedic,medicOrigin);
9738 //GetEntPropVector(entity, Prop_Send, "m_vecOrigin", propOrigin);
9739
9740 //determine distance from the two
9741 fDistance = GetVectorDistance(medicOrigin,g_fRagdollPosition[iInjured]);
9742
9743 new ActiveWeapon = GetEntPropEnt(friendlyMedic, Prop_Data, "m_hActiveWeapon");
9744 if (ActiveWeapon < 0)
9745 continue;
9746
9747 // Get weapon class name
9748 decl String:sWeapon[32];
9749 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
9750
9751 //PrintToServer("Medic 3");
9752 new bool:bCanHealPaddle = false;
9753 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
9754 {
9755 //PrintToServer("Medic 4");
9756 bCanHealPaddle = true;
9757 }
9758
9759 new Float:fReviveDistance = 65.0;
9760 if (fDistance <= fReviveDistance && bCanHealPaddle)
9761 {
9762
9763 decl String:woundType[64];
9764 if (g_playerWoundType[iInjured] == 0)
9765 woundType = "minor wound";
9766 else if (g_playerWoundType[iInjured] == 1)
9767 woundType = "moderate wound";
9768 else if (g_playerWoundType[iInjured] == 2)
9769 woundType = "critical wound";
9770 decl String:sBuf[255];
9771 // Chat to all
9772 Format(sBuf, 255,"\x05%N\x01 revived(assisted) \x03%N from a %s", friendlyMedic, iInjured, woundType);
9773 PrintToChatAll("%s", sBuf);
9774
9775 // Add kill bonus to friendlyMedic
9776 // new iBonus = GetConVarInt(sm_revive_bonus);
9777 // new iScore = GetClientFrags(friendlyMedic) + iBonus;
9778 // SetEntProp(friendlyMedic, Prop_Data, "m_iFrags", iScore);
9779
9780 /////////////////////////
9781 // Rank System
9782 g_iStatRevives[friendlyMedic]++;
9783 //
9784 /////////////////////////
9785
9786 // Add score bonus to friendlyMedic (doesn't work)
9787 //iScore = GetPlayerScore(friendlyMedic);
9788 //PrintToServer("[SCORE] score: %d", iScore + 10);
9789 //SetPlayerScore(friendlyMedic, iScore + 10);
9790
9791 //Accumulate a revive
9792 g_playerMedicRevivessAccumulated[friendlyMedic]++;
9793 new iReviveCap = GetConVarInt(sm_revive_cap_for_bonus);
9794 // Hint to friendlyMedic
9795 Format(sBuf, 255,"You revived(assisted) %N from a %s | Revives remaining til bonus life: %d", iInjured, woundType, (iReviveCap - g_playerMedicRevivessAccumulated[friendlyMedic]));
9796 PrintHintText(friendlyMedic, "%s", sBuf);
9797
9798 if (g_playerMedicRevivessAccumulated[friendlyMedic] >= iReviveCap)
9799 {
9800 g_playerMedicRevivessAccumulated[friendlyMedic] = 0;
9801 g_iSpawnTokens[friendlyMedic]++;
9802 decl String:sBuf2[255];
9803 // if (iBonus > 1)
9804 // Format(sBuf2, 255,"Awarded %i kills and %i score for assisted revive", iBonus, 10);
9805 // else
9806 Format(sBuf2, 255,"Awarded %i life for reviving %d players", 1, iReviveCap);
9807 PrintToChat(friendlyMedic, "%s", sBuf2);
9808 }
9809 }
9810 }
9811 }
9812 }
9813}
9814/*
9815########################LUA HEALING INTEGRATION######################
9816# This portion of the script adds in health packs from Lua #
9817##############################END####################################
9818#####################################################################
9819*/
9820
9821
9822
9823
9824stock Effect_SetMarkerAtPos(client,Float:pos[3],Float:intervall,color[4]){
9825
9826
9827 /*static Float:lastMarkerTime[MAXPLAYERS+1] = {0.0,...};
9828 new Float:gameTime = GetGameTime();
9829
9830 if(lastMarkerTime[client] > gameTime){
9831
9832 //no update cuz its already up2date
9833 return;
9834 }
9835
9836 lastMarkerTime[client] = gameTime+intervall;*/
9837
9838 new Float:start[3];
9839 new Float:end[3];
9840 //decl Float:worldMaxs[3];
9841
9842 //World_GetMaxs(worldMaxs);
9843
9844 end[0] = start[0] = pos[0];
9845 end[1] = start[1] = pos[1];
9846 end[2] = start[2] = pos[2];
9847 end[2] += 10000.0;
9848 start[2] += 5.0;
9849
9850 //intervall -= 0.1;
9851
9852 for(new effect=1;effect<=2;effect++){
9853
9854
9855 //blue team
9856 switch(effect){
9857
9858 case 1:{
9859 TE_SetupBeamPoints(start, end, g_iBeaconBeam, 0, 0, 20, intervall, 1.0, 50.0, 0, 0.0, color, 0);
9860 }
9861 case 2:{
9862 TE_SetupBeamRingPoint(start, 50.0, 50.1, g_iBeaconBeam, g_iBeaconHalo, 0, 10, intervall, 2.0, 0.0, color, 10, 0);
9863 }
9864 }
9865
9866 TE_SendToClient(client);
9867 }
9868}
9869
9870public Action Event_PlayerTeam(Handle event, const char[] name, bool dontBroadcast)
9871{
9872
9873 int client = GetClientOfUserId(GetEventInt(event, "userid"));
9874
9875 if (client > 0) // Check the client is not console/world?
9876 if (IsValidClient(client))
9877 {
9878 new m_iTeam = GetClientTeam(client);
9879 if (!IsFakeClient(client) && m_iTeam == TEAM_SPEC)
9880 {
9881 //remove network ragdoll associated with player
9882 new playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
9883 if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
9884 RemoveRagdoll(client);
9885 }
9886 if((m_iTeam == TEAM_SPEC) && (client == g_nVIP_ID))
9887 {
9888 g_nVIP_ID = 0;
9889 }
9890 }
9891
9892 return Plugin_Continue;
9893}
9894
9895
9896//############# AI DIRECTOR In-Script Functions START #######################
9897
9898
9899public AI_Director_ResetReinforceTimers()
9900{
9901 //Set Reinforce Time
9902 g_iReinforceTime_AD_Temp = (g_AIDir_ReinforceTimer_Orig);
9903 g_iReinforceTimeSubsequent_AD_Temp = (g_AIDir_ReinforceTimer_SubOrig);
9904}
9905public AI_Director_SetDifficulty(g_AIDir_TeamStatus, g_AIDir_TeamStatus_max)
9906{
9907 AI_Director_ResetReinforceTimers();
9908
9909 //AI Director Local Scaling Vars
9910 new
9911 //AID_ReinfAdj_low = 10, AID_ReinfAdj_med = 20, AID_ReinfAdj_high = 30, AID_ReinfAdj_pScale = 0, - commented out by oz
9912 AID_ReinfAdj_med = 20, AID_ReinfAdj_high = 30, AID_ReinfAdj_pScale = 0,
9913 Float:AID_SpecDelayAdj_low = 10.0, Float:AID_SpecDelayAdj_med = 20.0, Float:AID_SpecDelayAdj_high = 30.0, Float:AID_SpecDelayAdj_pScale_Pro = 0.0, Float:AID_SpecDelayAdj_pScale_Con = 0.0,
9914 AID_AmbChance_vlow = 10, AID_AmbChance_low = 15, AID_AmbChance_med = 20, AID_AmbChance_high = 25, AID_AmbChance_pScale = 0;
9915 new AID_SetDiffChance_pScale = 0;
9916
9917 //Scale based on team count
9918 new tTeamSecCount = GetTeamSecCount();
9919 if (tTeamSecCount <= 6)
9920 {
9921 AID_ReinfAdj_pScale = 8;
9922 AID_SpecDelayAdj_pScale_Pro = 30.0;
9923 AID_SpecDelayAdj_pScale_Con = 10.0;
9924 }
9925 else if (tTeamSecCount >= 7 && tTeamSecCount <= 12)
9926 {
9927 AID_ReinfAdj_pScale = 4;
9928 AID_SpecDelayAdj_pScale_Pro = 20.0;
9929 AID_SpecDelayAdj_pScale_Con = 20.0;
9930 AID_AmbChance_pScale = 5;
9931 AID_SetDiffChance_pScale = 5;
9932 }
9933 else if (tTeamSecCount >= 13)
9934 {
9935 AID_ReinfAdj_pScale = 8;
9936 AID_SpecDelayAdj_pScale_Pro = 10.0;
9937 AID_SpecDelayAdj_pScale_Con = 30.0;
9938 AID_AmbChance_pScale = 10;
9939 AID_SetDiffChance_pScale = 10;
9940 }
9941
9942 // Get the number of control points
9943 new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
9944 // Get active push point
9945 new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
9946
9947 new tAmbScaleMult = 2;
9948 if (ncp <= 5)
9949 {
9950 tAmbScaleMult = 3;
9951 AID_SetDiffChance_pScale += 5;
9952 }
9953 //Add More to Ambush chance based on what point we are at.
9954 AID_AmbChance_pScale += (acp * tAmbScaleMult);
9955 AID_SetDiffChance_pScale += (acp * tAmbScaleMult);
9956
9957 new Float:cvarSpecDelay = GetConVarFloat(sm_respawn_delay_team_ins_special);
9958 new fRandomInt = GetRandomInt(0, 100);
9959
9960
9961 //Set Difficulty Based On g_AIDir_TeamStatus and adjust per player scale g_SernixMaxPlayerCount
9962 if (fRandomInt <= (g_AIDir_DiffChanceBase + AID_SetDiffChance_pScale))
9963 {
9964 AI_Director_ResetReinforceTimers();
9965 //Set Reinforce Time
9966 g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
9967 g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
9968
9969 //Mod specialized bot spawn interval
9970 g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_high) - AID_SpecDelayAdj_pScale_Con);
9971 if (g_fCvar_respawn_delay_team_ins_spec <= 0)
9972 g_fCvar_respawn_delay_team_ins_spec = 1.0;
9973
9974 //DEBUG: Track Current Difficulty setting
9975 //g_AIDir_CurrDiff = 5; - commented out by oz
9976
9977 //Set Ambush Chance
9978 g_AIDir_AmbushCond_Chance = AID_AmbChance_high + AID_AmbChance_pScale;
9979 }
9980 // < 25% DOING BAD >> MAKE EASIER //Scale variables should be lower with higher player counts
9981 else if (g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 4))
9982 {
9983 //Set Reinforce Time
9984 g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig + AID_ReinfAdj_high) + AID_ReinfAdj_pScale);
9985 g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig + AID_ReinfAdj_high) + AID_ReinfAdj_pScale);
9986
9987 //Mod specialized bot spawn interval
9988 g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay + AID_SpecDelayAdj_high) + AID_SpecDelayAdj_pScale_Pro);
9989
9990 //DEBUG: Track Current Difficulty setting
9991 //g_AIDir_CurrDiff = 1; - commented out by oz
9992
9993 //Set Ambush Chance
9994 g_AIDir_AmbushCond_Chance = AID_AmbChance_vlow + AID_AmbChance_pScale;
9995 }
9996 // >= 25% and < 50% NORMAL >> No Adjustments
9997 else if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 4) && g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 2))
9998 {
9999 AI_Director_ResetReinforceTimers();
10000
10001 // >= 25% and < 33% Ease slightly if <= half the team alive which is 9 right now.
10002 if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 4) && g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 3) && GetTeamSecCount() <= 9)
10003 {
10004 //Set Reinforce Time
10005 g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig + AID_ReinfAdj_med) + AID_ReinfAdj_pScale);
10006 g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig + AID_ReinfAdj_med) + AID_ReinfAdj_pScale);
10007
10008 //Mod specialized bot spawn interval
10009 g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay + AID_SpecDelayAdj_low) + AID_SpecDelayAdj_pScale_Pro);
10010
10011 //DEBUG: Track Current Difficulty setting
10012 //g_AIDir_CurrDiff = 2; - commented out by oz
10013
10014 //Set Ambush Chance
10015 g_AIDir_AmbushCond_Chance = AID_AmbChance_low + AID_AmbChance_pScale;
10016 }
10017 else
10018 {
10019 //Set Reinforce Time
10020 g_iReinforceTime_AD_Temp = (g_AIDir_ReinforceTimer_Orig);
10021 g_iReinforceTimeSubsequent_AD_Temp = (g_AIDir_ReinforceTimer_SubOrig);
10022
10023 //Mod specialized bot spawn interval
10024 g_fCvar_respawn_delay_team_ins_spec = cvarSpecDelay;
10025
10026 //DEBUG: Track Current Difficulty setting
10027 //g_AIDir_CurrDiff = 2; - commented out by oz
10028
10029 //Set Ambush Chance
10030 g_AIDir_AmbushCond_Chance = AID_AmbChance_low + AID_AmbChance_pScale;
10031
10032 }
10033
10034 }
10035 // >= 50% and < 75% DOING GOOD
10036 else if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 2) && g_AIDir_TeamStatus < ((g_AIDir_TeamStatus_max / 4) * 3))
10037 {
10038 AI_Director_ResetReinforceTimers();
10039 //Set Reinforce Time
10040 g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_med) - AID_ReinfAdj_pScale);
10041 g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_med) - AID_ReinfAdj_pScale);
10042
10043 //Mod specialized bot spawn interval
10044 g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_med) - AID_SpecDelayAdj_pScale_Con);
10045 if (g_fCvar_respawn_delay_team_ins_spec <= 0)
10046 g_fCvar_respawn_delay_team_ins_spec = 1.0;
10047
10048 //DEBUG: Track Current Difficulty setting
10049 //g_AIDir_CurrDiff = 3; - commented out by oz
10050
10051 //Set Ambush Chance
10052 g_AIDir_AmbushCond_Chance = AID_AmbChance_med + AID_AmbChance_pScale;
10053
10054 }
10055 // >= 75% CAKE WALK
10056 else if (g_AIDir_TeamStatus >= ((g_AIDir_TeamStatus_max / 4) * 3))
10057 {
10058 AI_Director_ResetReinforceTimers();
10059 //Set Reinforce Time
10060 g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
10061 g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
10062
10063 //Mod specialized bot spawn interval
10064 g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_high) - AID_SpecDelayAdj_pScale_Con);
10065 if (g_fCvar_respawn_delay_team_ins_spec <= 0)
10066 g_fCvar_respawn_delay_team_ins_spec = 1.0;
10067
10068 //DEBUG: Track Current Difficulty setting
10069 //g_AIDir_CurrDiff = 4; - commented by oz
10070
10071 //Set Ambush Chance
10072 g_AIDir_AmbushCond_Chance = AID_AmbChance_high + AID_AmbChance_pScale;
10073 }
10074 //return g_AIDir_TeamStatus;
10075}
10076
10077
10078
10079
10080
10081
10082//############# AI DIRECTOR In-Script END #######################
10083
10084
10085//############ ON BUTTON PRESS START ###########################
10086
10087//public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
10088//{
10089
10090// if (!IsFakeClient(client))
10091// {
10092// //PrintToServer("BUTTON PRESS DEBUG RUNCMD");
10093// for (new i = 0; i < MAX_BUTTONS; i++)
10094// {
10095// new button = (1 << i);
10096// if ((buttons & button)) {
10097// // if (!(g_LastButtons[client] & button)) {
10098// // OnButtonPress(client, button);
10099// // }
10100// // } else if ((g_LastButtons[client] & button)) {
10101// // OnButtonRelease(client, button);
10102// // }
10103// OnButtonPress(client, button, buttons);
10104// }
10105// }
10106
10107// g_LastButtons[client] = buttons;
10108// }
10109// return Plugin_Continue;
10110//}
10111
10112//OnButtonPress(client, button, buttons)
10113//{
10114// new ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
10115
10116// if (ActiveWeapon < 0 || g_iRoundStatus == 0)
10117// return Plugin_Handled;
10118
10119
10120// // Get weapon class name
10121// decl String:sWeapon[32];
10122// GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
10123// ////PrintToServer("[KNIFE ONLY] CheckWeapon for iMedic %d named %N ActiveWeapon %d sWeapon %s",iMedic,iMedic,ActiveWeapon,sWeapon);
10124
10125// if (GetGameTime()-g_fPlayerLastChat[client] >= 1.0 && (buttons & INS_DUCK || buttons & INS_PRONE) && (buttons & INS_RELOAD) && ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)))// && !(buttons & IN_FORWARD) && !(buttons & IN_ATTACK2) && !(buttons & IN_ATTACK))// & !IN_ATTACK2)
10126// {
10127// g_fPlayerLastChat[client] = GetGameTime();
10128
10129// new team = GetClientTeam(client);
10130// // Valid medic?
10131// if (IsPlayerAlive(client) && team == TEAM_1_SEC)
10132// {
10133// new iAimTarget = -1;
10134// iAimTarget = FindValidProp_InDistance(client);
10135
10136// if (iAimTarget < 0)
10137// return Plugin_Stop;
10138
10139
10140// new Float:vOrigin[3], Float:vTargetOrigin[3];
10141// GetEntPropVector(iAimTarget, Prop_Data, "m_vecAbsOrigin", vOrigin);
10142// GetClientAbsOrigin(client, vTargetOrigin);
10143
10144// new String:targetname[64];
10145// GetEntPropString(iAimTarget, Prop_Data, "m_iName", targetname, sizeof(targetname));
10146// new String:propModelName[64];
10147// GetEntPropString(iAimTarget, Prop_Data, "m_ModelName", propModelName, sizeof(propModelName));
10148
10149// PrintToChat(client, "iAimTarget: %d | propModelName %s | targetname %s true %b", iAimTarget, propModelName, targetname, (StrEqual(propModelName, "models/sernix/ammo_cache/ammo_cache_small.mdl", true) > -1));
10150// if (ClientCanSeeVector(client, vOrigin, 100) && (GetVectorDistance(vOrigin, vTargetOrigin) <= 80.0) && StrEqual(propModelName, "models/sernix/ammo_cache/ammo_cache_small.mdl", false))
10151// {
10152// g_resupplyCounter[client] -= 1;
10153// new ammoStock = RoundToNearest(GetEntPropFloat(iAimTarget, Prop_Data, "m_flLocalTime"));
10154// //if (g_ammoResupplyAmt[validAmmoCache] <= 0)
10155// //{
10156// // new secTeamCount = GetTeamSecCount();
10157// // g_ammoResupplyAmt[validAmmoCache] = (secTeamCount / 6);
10158// // if (g_ammoResupplyAmt[validAmmoCache] <= 1)
10159// // {
10160// // g_ammoResupplyAmt[validAmmoCache] = 1;
10161// // }
10162
10163// //}
10164
10165// decl String:sBuf[255];
10166// // Hint to client
10167// Format(sBuf, 255,"Resupplying ammo in %d seconds | Supply left: %d", g_resupplyCounter[client], ammoStock);
10168// PrintHintText(client, "%s", sBuf);
10169
10170// //Controls loop interval
10171
10172// if (g_resupplyCounter[client] <= 0)
10173// {
10174
10175// ammoStock -= 1.0;
10176// if (ammoStock <= 0)
10177// {
10178// if(iAimTarget != -1)
10179// AcceptEntityInput(iAimTarget, "kill");
10180// }
10181
10182// SetEntPropFloat(iAimTarget, Prop_Data, "m_flLocalTime", ammoStock);
10183// ammoStock = RoundToNearest(GetEntPropFloat(iAimTarget, Prop_Data, "m_flLocalTime"));
10184// Format(sBuf, 255,"Rearmed! Ammo Supply left: %d", ammoStock);
10185
10186// PrintHintText(client, "%s", sBuf);
10187// PrintToChat(client, "%s", sBuf);
10188
10189// g_resupplyCounter[client] = GetConVarInt(sm_resupply_delay);
10190// //Spawn player again
10191// //FakeClientCommand(client, "inventory_resupply");
10192// AmmoResupply_Player(client, 0, 0, 0);
10193
10194// }
10195// }
10196
10197// }
10198
10199// }
10200// return Plugin_Stop;
10201
10202
10203//}
10204
10205//OnButtonRelease(client, button) - commented out by oz
10206//{ - commented out by oz
10207 ////PrintToServer("BUTTON RELEASE");
10208
10209 // do stuff
10210//} - commented out by oz
10211
10212//##################### ON BUTTON PRESS END ######################
10213
10214
10215//##################### ON PRE THINK START #######################
10216
10217//public SHook_OnPreThink(client)
10218//{
10219// if (IsFakeClient(client))
10220// return;
10221
10222// new team = GetClientTeam(client);
10223// if(IsClientInGame(client) && !IsClientTimingOut(client) && playerPickSquad[client] == 1 && IsPlayerAlive(client) && team == TEAM_1_SEC && g_iRoundStatus == 1)
10224// {
10225// if ((GetGameTime()-g_fPlayerLastChat[client] >= 1.0))
10226// {
10227// g_hintCoolDown[client] -= 1;
10228// new iAimTarget = GetClientAimTarget(client, false);
10229// if (iAimTarget < 0 || iAimTarget < MaxClients || FindDataMapInfo(iAimTarget, "m_ModelName") == -1)
10230// return;
10231
10232
10233
10234// new String:propModelName[128];
10235// GetEntPropString(iAimTarget, Prop_Data, "m_ModelName", propModelName, 128);
10236// new Float:vOrigin[3], Float:vTargetOrigin[3];
10237
10238// GetEntPropVector(iAimTarget, Prop_Data, "m_vecAbsOrigin", vOrigin);
10239// GetClientAbsOrigin(client, vTargetOrigin);
10240// //PrintToChatAll("g_hintCoolDown[client] %d | propModelName %s | Distance %d", g_hintCoolDown[client], propModelName, (GetVectorDistance(vOrigin, vTargetOrigin) <= 100.0));
10241
10242// if (g_hintsEnabled[client] && g_hintCoolDown[client] <= 0 && (GetGameTime()-g_fPlayerLastChat[client] >= 1.0) && (GetVectorDistance(vOrigin, vTargetOrigin) <= 100.0) && StrEqual(propModelName, "models/sernix/ammo_cache/ammo_cache_small.mdl"))
10243// {
10244
10245// g_hintCoolDown[client] = 30;
10246// g_fPlayerLastChat[client] = GetGameTime();
10247// DisplayInstructorHint(iAimTarget, 6.0, 0.0, 120.0, true, true, "icon_interact", "icon_interact", "", true, {255, 255, 255}, "Crouch (hold) and press RELOAD w/ knife to resupply");
10248// PrintHintText(client, "Crouch (hold) and press RELOAD w/ knife to resupply | toggle hints /hints");
10249// PrintToChat(client, "Crouch (hold) and press RELOAD w/ knife to resupply | toggle hints /hints");
10250// }
10251
10252
10253// decl String:targetname[128];
10254// GetEntPropString(iAimTarget, Prop_Data, "m_iName", targetname, sizeof(targetname));
10255
10256// if ((StrContains(g_client_last_classstring[client], "engineer") > -1) && StrContains(targetname, "OMPropSpawnProp", true) != -1 && g_hintsEnabled[client] && g_hintCoolDown[client] <= 0 &&
10257// (GetGameTime()-g_fPlayerLastChat[client] >= 1.0) && (GetVectorDistance(vOrigin, vTargetOrigin) <= 100.0) &&
10258// (StrEqual(propModelName, "models/fortifications/barbed_wire_02b.mdl") || StrEqual(propModelName, "models/static_fortifications/sandbagwall01.mdl") ||
10259// StrEqual(propModelName, "models/static_fortifications/sandbagwall02.mdl")))
10260// {
10261
10262// g_hintCoolDown[client] = 30;
10263// g_fPlayerLastChat[client] = GetGameTime();
10264// DisplayInstructorHint(iAimTarget, 6.0, 0.0, 3.0, true, true, "icon_interact", "icon_interact", "", true, {255, 255, 255}, "Press USE w/ knife out to repair (engineer only)");
10265// PrintHintText(client, "Press USE w/ knife out to repair (engineer only) | toggle hints /hints");
10266// PrintToChat(client, "Press USE w/ knife out to repair (engineer only) | toggle hints /hints");
10267// }
10268
10269// g_fPlayerLastChat[client] = GetGameTime();
10270// }
10271
10272
10273// }
10274// else
10275// return;
10276//}
10277
10278
10279//################## ON PRETHINK END #########################