Guest User

Untitled

a guest
Apr 20th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  18. #pragma dynamic 131072 // Increase heap size
  19. #pragma semicolon 1
  20. #pragma newdecls required
  21. #include <sourcemod>
  22. #include <sdktools>
  23. #include <sdkhooks>
  24. #include <insurgencydy>
  25. //#include <smlib>
  26. //#undef REQUIRE_EXTENSIONS
  27. //#include <cstrike>
  28. //#include <tf2>
  29. //#include <tf2_stocks>
  30. #define REQUIRE_EXTENSIONS
  31.  
  32. // Define grenade index value
  33. #define Gren_M67 68
  34. #define Gren_Incen 73
  35. #define Gren_Molot 74
  36. #define Gren_M18 70
  37. #define Gren_Flash 71
  38. #define Gren_F1 69
  39. #define Gren_IED 72
  40. #define Gren_C4 72
  41. #define Gren_AT4 67
  42. #define Gren_RPG7 61
  43.  
  44. //LUA Healing define values
  45. #define Healthkit_Timer_Tickrate            0.5     // Basic Sound has 0.8 loop
  46. #define Healthkit_Timer_Timeout             360.0 //6 minutes
  47. #define Healthkit_Radius                    120.0
  48. #define Revive_Indicator_Radius             100.0
  49. #define Healthkit_Remove_Type               "1"
  50. #define Healthkit_Healing_Per_Tick_Min      1
  51. #define Healthkit_Healing_Per_Tick_Max      3
  52.  
  53. // This will be used for checking which team the player is on before repsawning them
  54. #define SPECTATOR_TEAM  0
  55. #define TEAM_SPEC   1
  56. #define TEAM_1_SEC  2
  57. #define TEAM_2_INS  3
  58.  
  59. // Navmesh Init
  60. #define MAX_OBJECTIVES 13
  61. #define MAX_HIDING_SPOTS 4096
  62. #define MIN_PLAYER_DISTANCE 128.0
  63. #define MAX_ENTITIES 2048
  64.  
  65. // Counter-Attack Music
  66. #define COUNTER_ATTACK_MUSIC_DURATION 68.0
  67.  
  68. // KOLOROWE KREDKI
  69. #define YELLOW 0x01
  70. #define GREEN 0x04
  71.  
  72. // SOME DEFINES
  73. #define MAX_LINE_WIDTH 60
  74.  
  75. //Lua Healing Variables
  76. float g_iTimeCheckHeight[2048] = {0.0, ...};
  77.  
  78. // Handle for revive
  79. Handle g_hForceRespawn;
  80. Handle g_hGameConfig;
  81.  
  82. // AI Director Variables
  83. int g_AIDir_TeamStatus = 50;
  84. int g_AIDir_TeamStatus_min = 0;
  85. int g_AIDir_TeamStatus_max = 100;
  86. int g_AIDir_BotsKilledReq_mult = 4;
  87. int g_AIDir_BotsKilledCount = 0;
  88. int g_AIDir_AnnounceCounter = 0;
  89.     //g_AIDir_AnnounceTrig = 5,
  90. int g_AIDir_ChangeCond_Counter = 0;
  91. int g_AIDir_ChangeCond_Min = 60;
  92. int g_AIDir_ChangeCond_Max = 180;
  93. int g_AIDir_AmbushCond_Counter = 0;
  94. int g_AIDir_AmbushCond_Min = 120;
  95. int g_AIDir_AmbushCond_Max = 300;
  96. int g_AIDir_AmbushCond_Rand = 240;
  97. int g_AIDir_AmbushCond_Chance = 10;
  98. int g_AIDir_ChangeCond_Rand = 180;
  99. int g_AIDir_ReinforceTimer_Orig;
  100. int g_AIDir_ReinforceTimer_SubOrig;
  101.     //g_AIDir_CurrDiff = 0,
  102. int g_AIDir_DiffChanceBase = 0;
  103. bool g_AIDir_BotReinforceTriggered = false;
  104.  
  105. // Player respawn
  106. int g_iEnableRevive = 0;
  107. int g_GiveBonusLives = 0;
  108. int g_iRespawnTimeRemaining[MAXPLAYERS+1];
  109. int g_iReviveRemainingTime[MAXPLAYERS+1];
  110. int g_iReviveNonMedicRemainingTime[MAXPLAYERS+1];
  111. int g_iPlayerRespawnTimerActive[MAXPLAYERS+1];
  112. int g_iSpawnTokens[MAXPLAYERS+1];
  113. int g_iHurtFatal[MAXPLAYERS+1];
  114. int g_iClientRagdolls[MAXPLAYERS+1];
  115. int g_iNearestBody[MAXPLAYERS+1];
  116. int g_botStaticGlobal[MAXPLAYERS+1];
  117. int g_resupplyCounter[MAXPLAYERS+1];
  118. int g_ammoResupplyAmt[MAX_ENTITIES+1];
  119. int g_trackKillDeaths[MAXPLAYERS+1];
  120. float g_badSpawnPos_Track[MAXPLAYERS+1][3];
  121. int g_iRespawnCount[4];
  122.     // g_huntReinforceCacheAdd = 120,
  123.     // bool:g_huntCacheDestroyed = false,
  124. bool g_playersReady = false;
  125.     //bool:g_easterEggRound = false,
  126.     //bool:g_easterEggFlag = false,
  127. int g_removeBotGrenadeChance = 50;
  128.     // float g_fPlayerPosition[MAXPLAYERS+1][3],
  129. float g_fDeadPosition[MAXPLAYERS+1][3];
  130. float g_fRagdollPosition[MAXPLAYERS+1][3];
  131. float g_vecOrigin[MAXPLAYERS+1][3];
  132. int g_iPlayerBGroups[MAXPLAYERS+1];
  133. int g_spawnFrandom[MAXPLAYERS+1];
  134. int g_squadSpawnEnabled[MAXPLAYERS+1] = 0;
  135. int g_squadLeader[MAXPLAYERS+1];
  136.     // g_enemySpawnTimer[MAXPLAYERS+1],
  137. int g_LastButtons[MAXPLAYERS+1];
  138.     //g_extendMapVote[MAXPLAYERS+1] = 0,
  139. float g_fRespawnPosition[3];
  140.  
  141. //Ammo Amounts
  142. // Track primary and secondary ammo
  143. int playerClip[MAXPLAYERS + 1][2];
  144.     // track player ammo based on weapon slot 0 - 4
  145. int playerAmmo[MAXPLAYERS + 1][4];
  146. int playerPrimary[MAXPLAYERS + 1];
  147. int playerSecondary[MAXPLAYERS + 1];
  148. //  playerGrenadeType[MAXPLAYERS + 1][10], //track player grenade types
  149. //  playerRole[MAXPLAYERS + 1]; // tracks player role so if it changes while wounded, he dies
  150.  
  151. // Handle g_donorTagRemove_Array;
  152. ArrayList g_playerArrayList;
  153.  
  154. //Bot Spawning
  155. // ArrayList g_badSpawnPos_Array;
  156.  
  157. // Navmesh Init
  158. // Handle g_hHidingSpots = null,
  159. // g_iHidingSpotCount,
  160. // m_iNumControlPoints,
  161. // g_iCPHidingSpots[MAX_OBJECTIVES][MAX_HIDING_SPOTS],
  162. int g_iCPHidingSpotCount[MAX_OBJECTIVES];
  163. // g_iCPLastHidingSpot[MAX_OBJECTIVES],
  164. float m_vCPPositions[MAX_OBJECTIVES][3];
  165.  
  166. // Status
  167. int g_isMapInit;
  168.     //0 is over, 1 is active
  169. int g_iRoundStatus = 0;
  170. // bool:g_bIsCounterAttackTimerActive = false,
  171. int g_clientDamageDone[MAXPLAYERS+1];
  172. int playerPickSquad[MAXPLAYERS + 1];
  173. bool playerRevived[MAXPLAYERS + 1];
  174. bool playerInRevivedState[MAXPLAYERS + 1];
  175. bool g_preRoundInitial = false;
  176. char g_client_last_classstring[MAXPLAYERS+1][64];
  177. char g_client_org_nickname[MAXPLAYERS+1][64];
  178.     //float g_enemyTimerPos[MAXPLAYERS+1][3],   // Kill Stray Enemy Bots Globals
  179.     //float g_enemyTimerAwayPos[MAXPLAYERS+1][3],   // Kill Stray Enemy Bots Globals
  180. int g_playerActiveWeapon[MAXPLAYERS + 1];
  181. int g_plyrGrenScreamCoolDown[MAXPLAYERS+1];
  182. int g_plyrFireScreamCoolDown[MAXPLAYERS+1];
  183. int g_playerMedicHealsAccumulated[MAXPLAYERS+1];
  184. int g_playerMedicRevivessAccumulated[MAXPLAYERS+1];
  185. int g_playerNonMedicHealsAccumulated[MAXPLAYERS+1];
  186. int g_playerNonMedicRevive[MAXPLAYERS+1];
  187. int g_playerWoundType[MAXPLAYERS+1];
  188. int g_playerWoundTime[MAXPLAYERS+1];
  189. //g_hintCoolDown[MAXPLAYERS+1] = 30,
  190. bool g_hintsEnabled[MAXPLAYERS+1] = true;
  191. float g_fPlayerLastChat[MAXPLAYERS+1] = {0.0, ...};
  192.  
  193.     //Wave Based Arrays
  194. //g_WaveSpawnActive[MAXPLAYERS+1],
  195.  
  196. int g_playerFirstJoin[MAXPLAYERS+1];
  197.  
  198. // Player Distance Plugin //Credits to author = "Popoklopsi", url = "http://popoklopsi.de"
  199. // unit to use 1 = feet, 0 = meters
  200. int g_iUnitMetric;
  201.  
  202. // Handle for config
  203. ConVar sm_respawn_enabled;
  204. ConVar sm_revive_enabled;
  205. //AI Director Specific
  206. ConVar sm_ai_director_setdiff_chance_base;
  207. // Respawn delay time
  208. ConVar sm_respawn_delay_team_ins;
  209. ConVar sm_respawn_delay_team_ins_special;
  210. ConVar sm_respawn_delay_team_sec;
  211. ConVar sm_respawn_delay_team_sec_player_count_01;
  212. ConVar sm_respawn_delay_team_sec_player_count_02;
  213. ConVar sm_respawn_delay_team_sec_player_count_03;
  214. ConVar sm_respawn_delay_team_sec_player_count_04;
  215. ConVar sm_respawn_delay_team_sec_player_count_05;
  216. ConVar sm_respawn_delay_team_sec_player_count_06;
  217. ConVar sm_respawn_delay_team_sec_player_count_07;
  218. ConVar sm_respawn_delay_team_sec_player_count_08;
  219. ConVar sm_respawn_delay_team_sec_player_count_09;
  220. ConVar sm_respawn_delay_team_sec_player_count_10;
  221. ConVar sm_respawn_delay_team_sec_player_count_11;
  222. ConVar sm_respawn_delay_team_sec_player_count_12;
  223. ConVar sm_respawn_delay_team_sec_player_count_13;
  224. ConVar sm_respawn_delay_team_sec_player_count_14;
  225. ConVar sm_respawn_delay_team_sec_player_count_15;
  226. ConVar sm_respawn_delay_team_sec_player_count_16;
  227. ConVar sm_respawn_delay_team_sec_player_count_17;
  228. ConVar sm_respawn_delay_team_sec_player_count_18;
  229. ConVar sm_respawn_delay_team_sec_player_count_19;
  230.    
  231.     // Respawn Mode (individual or wave based)
  232. ConVar sm_respawn_mode_team_sec;
  233. ConVar sm_respawn_mode_team_ins;
  234. //Wave interval
  235. //Handle sm_respawn_wave_int_team_sec = null,
  236. ConVar sm_respawn_wave_int_team_ins;
  237.  
  238. //VIP Cvars
  239. // Handle sm_vip_obj_time = null,
  240. // Handle sm_vip_min_sp_reward = null,
  241. // Handle sm_vip_max_sp_reward = null,
  242. // Handle sm_vip_enabled = null,
  243.  
  244.  
  245. // Respawn type
  246. ConVar sm_respawn_type_team_ins;
  247. ConVar sm_respawn_type_team_sec;
  248.  
  249. // Respawn lives
  250. ConVar sm_respawn_lives_team_sec;
  251. ConVar sm_respawn_lives_team_ins;
  252. ConVar sm_respawn_lives_team_ins_player_count_01;
  253. ConVar sm_respawn_lives_team_ins_player_count_02;
  254. ConVar sm_respawn_lives_team_ins_player_count_03;
  255. ConVar sm_respawn_lives_team_ins_player_count_04;
  256. ConVar sm_respawn_lives_team_ins_player_count_05;
  257. ConVar sm_respawn_lives_team_ins_player_count_06;
  258. ConVar sm_respawn_lives_team_ins_player_count_07;
  259. ConVar sm_respawn_lives_team_ins_player_count_08;
  260. ConVar sm_respawn_lives_team_ins_player_count_09;
  261. ConVar sm_respawn_lives_team_ins_player_count_10;
  262. ConVar sm_respawn_lives_team_ins_player_count_11;
  263. ConVar sm_respawn_lives_team_ins_player_count_12;
  264. ConVar sm_respawn_lives_team_ins_player_count_13;
  265. ConVar sm_respawn_lives_team_ins_player_count_14;
  266. ConVar sm_respawn_lives_team_ins_player_count_15;
  267. ConVar sm_respawn_lives_team_ins_player_count_16;
  268. ConVar sm_respawn_lives_team_ins_player_count_17;
  269. ConVar sm_respawn_lives_team_ins_player_count_18;
  270. ConVar sm_respawn_lives_team_ins_player_count_19;
  271.  
  272. // Fatal dead
  273. ConVar sm_respawn_fatal_chance;
  274. ConVar sm_respawn_fatal_head_chance;
  275. ConVar sm_respawn_fatal_limb_dmg;
  276. ConVar sm_respawn_fatal_head_dmg;
  277. ConVar sm_respawn_fatal_burn_dmg;
  278. ConVar sm_respawn_fatal_explosive_dmg;
  279. ConVar sm_respawn_fatal_chest_stomach;
  280.  
  281. // Counter-attack
  282. ConVar sm_respawn_counterattack_type;
  283. ConVar sm_respawn_counterattack_vanilla;
  284. ConVar sm_respawn_final_counterattack_type;
  285. ConVar sm_respawn_security_on_counter;
  286. ConVar sm_respawn_counter_chance;
  287. ConVar sm_respawn_min_counter_dur_sec;
  288. ConVar sm_respawn_max_counter_dur_sec;
  289. ConVar sm_respawn_final_counter_dur_sec;
  290.  
  291. //Dynamic Respawn Mechanics
  292. ConVar sm_respawn_dynamic_distance_multiplier;
  293. ConVar sm_respawn_dynamic_spawn_counter_percent;
  294. ConVar sm_respawn_dynamic_spawn_percent;
  295.  
  296. // Misc
  297. ConVar sm_respawn_reset_type;
  298. ConVar sm_respawn_enable_track_ammo;
  299.  
  300. // Reinforcements
  301. ConVar sm_respawn_reinforce_time;
  302. ConVar sm_respawn_reinforce_time_subsequent;
  303. ConVar sm_respawn_reinforce_multiplier;
  304. ConVar sm_respawn_reinforce_multiplier_base;
  305.  
  306. // Monitor static enemy
  307. //ConVar sm_respawn_check_static_enemy = null,
  308. //ConVar sm_respawn_check_static_enemy_counter = null,
  309.  
  310. // Donor tag
  311. ConVar sm_respawn_enable_donor_tag;
  312.  
  313. // Related to 'RoundEnd_Protector' plugin
  314. //ConVar sm_remaininglife = null,
  315.  
  316. // Medic specific
  317. ConVar sm_revive_seconds;
  318. //ConVar sm_revive_bonus = null,
  319. ConVar sm_revive_distance_metric;
  320. //ConVar sm_heal_bonus = null,
  321. ConVar sm_heal_cap_for_bonus;
  322. ConVar sm_revive_cap_for_bonus;
  323. ConVar sm_reward_medics_enabled;
  324. ConVar sm_heal_amount_medpack;
  325. ConVar sm_heal_amount_paddles;
  326. ConVar sm_non_medic_heal_amt;
  327. ConVar sm_non_medic_revive_hp;
  328. ConVar sm_medic_minor_revive_hp;
  329. ConVar sm_medic_moderate_revive_hp;
  330. ConVar sm_medic_critical_revive_hp;
  331. ConVar sm_minor_wound_dmg;
  332. ConVar sm_moderate_wound_dmg;
  333. ConVar sm_medic_heal_self_max;
  334. ConVar sm_non_medic_max_heal_other;
  335. ConVar sm_minor_revive_time;
  336. ConVar sm_moderate_revive_time;
  337. ConVar sm_critical_revive_time;
  338. ConVar sm_non_medic_revive_time;
  339. ConVar sm_medpack_health_amount;
  340. ConVar sm_multi_loadout_enabled;
  341. ConVar sm_bombers_only;
  342. ConVar sm_non_medic_heal_self_max;
  343. ConVar sm_elite_counter_attacks;
  344. ConVar sm_enable_bonus_lives;
  345. ConVar sm_finale_counter_spec_enabled;
  346. ConVar sm_finale_counter_spec_percent;
  347.  
  348. // NAV MESH SPECIFIC CVARS
  349. //1 = Spawn in ins_spawnpoints, 2 = any spawnpoints that meets criteria, 0 = only at normal spawnpoints at next objective
  350. ConVar cvarSpawnMode;
  351. //ConVar cvarMinCounterattackDistance = null, //Min distance from counterattack objective to spawn
  352. //Min/max distance from players to spawn
  353. ConVar cvarMinPlayerDistance;
  354. //Adds to the minplayerdistance cvar when spawning behind player.
  355. ConVar cvarBackSpawnIncrease;
  356. //Attack delay for spawning bots
  357. ConVar cvarSpawnAttackDelay;
  358. //Min/max distance from next objective to spawn
  359. ConVar cvarMinObjectiveDistance;
  360. //Min/max distance from next objective to spawn
  361. ConVar cvarMaxObjectiveDistance;
  362. //Min/max distance from next objective to spawn using nav
  363. ConVar cvarMaxObjectiveDistanceNav;
  364. //CanSeeVector Multiplier divide this by cvarMaxPlayerDistance
  365. ConVar cvarCanSeeVectorMultiplier;
  366. //Range of ammo resupply
  367. ConVar sm_ammo_resupply_range;
  368. //Delay to resupply
  369. ConVar sm_resupply_delay;
  370. //Jammer required for intel messages?
  371. ConVar sm_jammer_required;
  372. //Min/max distance from players to spawn
  373. ConVar cvarMaxPlayerDistance;
  374.    
  375.  
  376.  
  377. // Init global variables
  378. int g_iCvar_respawn_enable;
  379. int g_jammerRequired;
  380. int g_elite_counter_attacks;
  381. int g_finale_counter_spec_enabled;
  382. int g_finale_counter_spec_percent;
  383. int g_cqc_map_enabled;
  384.     // g_elitePeriod,
  385.     // g_elitePeriod_min,
  386.     // g_elitePeriod_max,
  387. int g_iCvar_revive_enable;
  388. float g_respawn_counter_chance;
  389. int g_counterAttack_min_dur_sec;
  390. int g_counterAttack_max_dur_sec;
  391. int g_iCvar_respawn_type_team_ins;
  392. int g_iCvar_respawn_type_team_sec;
  393. int g_iCvar_respawn_reset_type;
  394. float g_fCvar_respawn_delay_team_ins;
  395. float g_fCvar_respawn_delay_team_ins_spec;
  396. int g_iCvar_enable_track_ammo;
  397. int g_iCvar_counterattack_type;
  398. int g_iCvar_counterattack_vanilla;
  399. int g_iCvar_final_counterattack_type;
  400.     //g_iCvar_SpawnMode,
  401.  
  402.     //Dynamic Respawn cvars
  403. int g_DynamicRespawn_Distance_mult;
  404. int g_dynamicSpawnCounter_Perc;
  405. int g_dynamicSpawn_Perc;
  406.  
  407.     // Fatal dead
  408. float g_fCvar_fatal_chance;
  409. float g_fCvar_fatal_head_chance;
  410. int g_iCvar_fatal_limb_dmg;
  411. int g_iCvar_fatal_head_dmg;
  412. int g_iCvar_fatal_burn_dmg;
  413. int g_iCvar_fatal_explosive_dmg;
  414. int g_iCvar_fatal_chest_stomach;
  415.     //Dynamic Loadouts
  416.     //g_iCvar_bombers_only,
  417.     //g_iCvar_multi_loadout_enabled,
  418.  
  419.     //Respawn Mode (wave based)
  420. int g_respawn_mode_team_sec;
  421.     //g_respawn_mode_team_ins,
  422.     //g_respawn_wave_int_team_ins,
  423.  
  424.     //NEW Respawn system globals (temporary)
  425.     //Grab directly from theater (3 scouts, 5 jugs, 4 bombers, All others 20)
  426.     // g_maxbots_std = 0,
  427.     // g_maxbots_light = 0,
  428.     // g_maxbots_jug = 0,
  429.     // g_maxbots_bomb = 0,
  430.     //Template of bots AI Director uses
  431.     // g_bots_std = 0,
  432.     // g_bots_light = 0,
  433.     // g_bots_jug = 0,
  434.     // g_bots_bomb = 0,
  435.  
  436.     //VIP Globals
  437.     //g_iCvar_vip_obj_time,
  438.     // g_iCvar_vip_min_sp_reward,
  439.     // g_iCvar_vip_max_sp_reward,
  440.     // g_vip_enable,
  441.     // g_vip_obj_count,
  442.     //g_vip_obj_ready,
  443.     // g_vip_min_reward,
  444.     // g_vip_max_reward,
  445.     // g_nVIP_ID = 0,
  446.  
  447. int g_cacheObjActive = 0;
  448.     //g_checkStaticAmt,
  449.     //g_checkStaticAmtCntr,
  450.     //g_checkStaticAmtAway,
  451.     //g_checkStaticAmtCntrAway,
  452. int g_iReinforceTime;
  453.     //g_iReinforceTimeSubsequent,
  454. int g_iReinforceTime_AD_Temp;
  455. int g_iReinforceTimeSubsequent_AD_Temp;
  456. int g_iReinforce_Mult;
  457. int g_iReinforce_Mult_Base;
  458. int g_iRemaining_lives_team_sec;
  459. int g_iRemaining_lives_team_ins;
  460. int g_iRespawn_lives_team_sec;
  461. int g_iRespawn_lives_team_ins;
  462.     // g_iReviveSeconds,
  463. int g_iRespawnSeconds;
  464. int g_secWave_Timer;
  465. int g_iHeal_amount_paddles;
  466. int g_iHeal_amount_medPack;
  467. int g_nonMedicHeal_amount;
  468. int g_nonMedicRevive_hp;
  469. int g_minorWoundRevive_hp;
  470. int g_modWoundRevive_hp;
  471. int g_critWoundRevive_hp;
  472. int g_minorWound_dmg;
  473. int g_moderateWound_dmg;
  474. int g_medicHealSelf_max;
  475. int g_nonMedicHealSelf_max;
  476. int g_nonMedic_maxHealOther;
  477. int g_minorRevive_time;
  478. int g_modRevive_time;
  479. int g_critRevive_time;
  480. int g_nonMedRevive_time;
  481.     //g_medpack_health_amt,
  482. int g_botsReady;
  483. int g_isConquer;
  484. int g_isOutpost;
  485. int g_isCheckpoint;
  486. int g_isHunt;
  487. float g_flMinPlayerDistance;
  488. float g_flBackSpawnIncrease;
  489. float g_flMaxPlayerDistance;
  490. float g_flCanSeeVectorMultiplier;
  491. float g_flMinObjectiveDistance;
  492.     //float g_flMaxObjectiveDistance,
  493.     //float g_flMaxObjectiveDistanceNav,
  494. float g_flSpawnAttackDelay;
  495.     //float g_flMinCounterattackDistance,
  496.  
  497.     //Elite bots Counters
  498. int g_ins_bot_count_checkpoint_max_org;
  499. int g_mp_player_resupply_coop_delay_max_org;
  500. int g_mp_player_resupply_coop_delay_penalty_org;
  501. int g_mp_player_resupply_coop_delay_base_org;
  502. int g_bot_attack_aimpenalty_amt_close_org;
  503. int g_bot_attack_aimpenalty_amt_far_org;
  504. float g_bot_attack_aimpenalty_time_close_org;
  505. float g_bot_attack_aimpenalty_time_far_org;
  506. float g_bot_aim_aimtracking_base_org;
  507. float g_bot_aim_aimtracking_frac_impossible_org;
  508. float g_bot_aim_angularvelocity_frac_impossible_org;
  509. float g_bot_aim_angularvelocity_frac_sprinting_target_org;
  510. float g_bot_aim_attack_aimtolerance_frac_impossible_org;
  511. float g_bot_attackdelay_frac_difficulty_impossible_org;
  512. float g_bot_attack_aimtolerance_newthreat_amt_org;
  513. float g_bot_attack_aimtolerance_newthreat_amt_mult;
  514. int g_bot_attack_aimpenalty_amt_close_mult;
  515. int g_bot_attack_aimpenalty_amt_far_mult;
  516. float g_bot_attackdelay_frac_difficulty_impossible_mult;
  517. float g_bot_attack_aimpenalty_time_close_mult;
  518. float g_bot_attack_aimpenalty_time_far_mult;
  519. float g_bot_aim_aimtracking_base;
  520. float g_bot_aim_aimtracking_frac_impossible;
  521. float g_bot_aim_angularvelocity_frac_impossible;
  522. float g_bot_aim_angularvelocity_frac_sprinting_target;
  523. float g_bot_aim_attack_aimtolerance_frac_impossible;
  524. int g_coop_delay_penalty_base;
  525. int g_isEliteCounter;
  526.  
  527. int m_hMyWeapons;
  528. int m_flNextPrimaryAttack;
  529.  
  530. int m_flNextSecondaryAttack;
  531.  
  532. // KOLOROWE KREDKI
  533. #define YELLOW 0x01
  534. #define GREEN 0x04
  535.  
  536. // SOME DEFINES
  537. #define MAX_LINE_WIDTH 60
  538. #define PLUGIN_VERSION "4.1"
  539.  
  540. // STATS TIME (SET DAYS AFTER STATS ARE DELETE OF NONACTIVE PLAYERS)
  541. #define PLAYER_STATSOLD 30
  542.  
  543. // STATS DEFINATION FOR PLAYERS
  544. int g_iStatKills[MAXPLAYERS+1];
  545. int g_iStatDeaths[MAXPLAYERS+1];
  546. int g_iStatHeadShots[MAXPLAYERS+1];
  547. int g_iStatSuicides[MAXPLAYERS+1];
  548. int g_iStatRevives[MAXPLAYERS+1];
  549. int g_iStatHeals[MAXPLAYERS+1];
  550. char g_sSecBot[] = "[INS] RoundEnd Protector";
  551. int g_iSecBotID = -1;
  552. float g_iCollOff;
  553.  
  554. enum FX
  555. {
  556.     FxNone = 0,
  557.     FxPulseFast,
  558.     FxPulseSlowWide,
  559.     FxPulseFastWide,
  560.     FxFadeSlow,
  561.     FxFadeFast,
  562.     FxSolidSlow,
  563.     FxSolidFast,
  564.     FxStrobeSlow,
  565.     FxStrobeFast,
  566.     FxStrobeFaster,
  567.     FxFlickerSlow,
  568.     FxFlickerFast,
  569.     FxNoDissipation,
  570.     FxDistort,               // Distort/scale/translate flicker
  571.     FxHologram,              // kRenderFxDistort + distance fade
  572.     FxExplode,               // Scale up really big!
  573.     FxGlowShell,             // Glowing Shell
  574.     FxClampMinScale,         // Keep this sprite from getting very small (SPRITES only!)
  575.     FxEnvRain,               // for environmental rendermode, make rain
  576.     FxEnvSnow,               //  "        "            "    , make snow
  577.     FxSpotlight,    
  578.     FxRagdoll,
  579.     FxPulseFastWider,
  580. };
  581.  
  582. enum Render
  583. {
  584.     Normal = 0,         // src
  585.     TransColor,         // c*a+dest*(1-a)
  586.     TransTexture,       // src*a+dest*(1-a)
  587.     Glow,               // src*a+dest -- No Z buffer checks -- Fixed size in screen space
  588.     TransAlpha,         // src*srca+dest*(1-srca)
  589.     TransAdd,           // src*a+dest
  590.     Environmental,      // not drawn, used for environmental effects
  591.     TransAddFrameBlend, // use a fractional frame value to blend between animation frames
  592.     TransAlphaAdd,      // src + dest*(1-a)
  593.     WorldGlow,          // Same as kRenderGlow but not fixed size in screen space
  594.     None,               // Don't render.
  595. };
  596.  
  597. FX:g_Effect = FX:FxGlowShell;
  598. Render:g_Render = Render:Glow;
  599.  
  600. #define PLUGIN_DESCRIPTION "Respawn dead players via admincommand or by queues"
  601. #define UPDATE_URL  "http://ins.jballou.com/sourcemod/update-respawn.txt"
  602.  
  603. // Plugin info
  604. public Plugin myinfo =
  605. {
  606.     name = "[INS] Player Respawn",
  607.     author = "Jared Ballou (Contributor: Daimyo, naong, ozzy and community members)",
  608.     version = PLUGIN_VERSION,
  609.     description = PLUGIN_DESCRIPTION,
  610.     url = "http://jballou.com"
  611. };
  612.  
  613.     ConVar sm_roundendblock_enabled = null;
  614.     ConVar sm_roundendblock_times = null;
  615.     ConVar sm_roundendblock_revive_delay = null;
  616.     ConVar sm_roundendblock_reset_each_round = null;
  617.     ConVar sm_roundendblock_debug = null;
  618.     float g_iRoundEndBlockEnabled;
  619.     //g_iRoundEndBlockCapCount = 0;
  620.     //g_iRoundEndBlockMaxCapPoints = 3;
  621.     float g_iRoundEndBlockTimes;
  622.     float g_iRoundEndBlockReviveDelay;
  623.     float g_iRoundEndBlockResetRound;
  624.     float g_iRoundEndBlockDebug;
  625.     Handle g_hPlayerRespawn;
  626.     float g_fSpawnPoint[3];
  627.     int g_iIsRoundStarted = 0;  //0 is over, 1 is active
  628.     int g_iIsRoundStartedPost = 0; //0 is over, 1 is active
  629.     int g_iIsGameEnded = 0;     //0 is not ended, 1 is ended
  630.     float g_iRoundBlockCount;
  631.     float g_iReviveCount;
  632.     //g_iAnnounceActive;
  633.     float g_max_AnnounceTime = 480;
  634.     float g_announceTick;
  635.     bool g_bIsCounterAttackTimerActive = false;
  636.     //g_isReviving = 0;
  637.  
  638.  
  639. // Start plugin
  640. void OnPluginStart()
  641. {
  642.     //Find player gear offset
  643.     //g_iPlayerEquipGear = FindSendPropInfo("CINSPlayer", "m_EquippedGear");
  644.    
  645.     //Create player array list
  646.     g_playerArrayList = new ArrayList();
  647.     //g_badSpawnPos_Array = CreateArray();
  648.    
  649.  
  650.     CreateConVar("sm_respawn_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD);
  651.     sm_respawn_enabled = CreateConVar("sm_respawn_enabled", "1", "Automatically respawn players when they die; 0 - disabled, 1 - enabled");
  652.     sm_revive_enabled = CreateConVar("sm_revive_enabled", "1", "Reviving enabled from medics?  This creates revivable ragdoll after death; 0 - disabled, 1 - enabled");
  653.     // Nav Mesh Botspawn specific START
  654.     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);
  655.     //cvarMinCounterattackDistance = CreateConVar("sm_botspawns_min_counterattack_distance", "3600.0", "Min distance from counterattack objective to spawn", FCVAR_NOTIFY);
  656.     cvarMinPlayerDistance = CreateConVar("sm_botspawns_min_player_distance", "240.0", "Min distance from players to spawn", FCVAR_NOTIFY);
  657.     cvarMaxPlayerDistance = CreateConVar("sm_botspawns_max_player_distance", "16000.0", "Max distance from players to spawn", FCVAR_NOTIFY);
  658.     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);
  659.     cvarMinObjectiveDistance = CreateConVar("sm_botspawns_min_objective_distance", "240", "Min distance from next objective to spawn", FCVAR_NOTIFY);
  660.     cvarMaxObjectiveDistance = CreateConVar("sm_botspawns_max_objective_distance", "12000", "Max distance from next objective to spawn", FCVAR_NOTIFY);
  661.     cvarMaxObjectiveDistanceNav = CreateConVar("sm_botspawns_max_objective_distance_nav", "2000", "Max distance from next objective to spawn", FCVAR_NOTIFY);
  662.     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);  
  663.     cvarSpawnAttackDelay = CreateConVar("sm_botspawns_spawn_attack_delay", "2", "Delay in seconds for spawning bots to wait before firing.", FCVAR_NOTIFY);
  664.  
  665.     // Nav Mesh Botspawn specific END
  666.  
  667.     // Respawn delay time
  668.     sm_respawn_delay_team_ins = CreateConVar("sm_respawn_delay_team_ins",
  669.         "1.0", "How many seconds to delay the respawn (bots)");
  670.     sm_respawn_delay_team_ins_special = CreateConVar("sm_respawn_delay_team_ins_special",
  671.         "20.0", "How many seconds to delay the respawn (special bots)");
  672.  
  673.  
  674.     sm_respawn_delay_team_sec = CreateConVar("sm_respawn_delay_team_sec",
  675.         "30.0", "How many seconds to delay the respawn (If not set 'sm_respawn_delay_team_sec_player_count_XX' uses this value)");
  676.     sm_respawn_delay_team_sec_player_count_01 = CreateConVar("sm_respawn_delay_team_sec_player_count_01",
  677.         "5.0", "How many seconds to delay the respawn (when player count is 1)");
  678.     sm_respawn_delay_team_sec_player_count_02 = CreateConVar("sm_respawn_delay_team_sec_player_count_02",
  679.         "10.0", "How many seconds to delay the respawn (when player count is 2)");
  680.     sm_respawn_delay_team_sec_player_count_03 = CreateConVar("sm_respawn_delay_team_sec_player_count_03",
  681.         "20.0", "How many seconds to delay the respawn (when player count is 3)");
  682.     sm_respawn_delay_team_sec_player_count_04 = CreateConVar("sm_respawn_delay_team_sec_player_count_04",
  683.         "30.0", "How many seconds to delay the respawn (when player count is 4)");
  684.     sm_respawn_delay_team_sec_player_count_05 = CreateConVar("sm_respawn_delay_team_sec_player_count_05",
  685.         "60.0", "How many seconds to delay the respawn (when player count is 5)");
  686.     sm_respawn_delay_team_sec_player_count_06 = CreateConVar("sm_respawn_delay_team_sec_player_count_06",
  687.         "60.0", "How many seconds to delay the respawn (when player count is 6)");
  688.     sm_respawn_delay_team_sec_player_count_07 = CreateConVar("sm_respawn_delay_team_sec_player_count_07",
  689.         "70.0", "How many seconds to delay the respawn (when player count is 7)");
  690.     sm_respawn_delay_team_sec_player_count_08 = CreateConVar("sm_respawn_delay_team_sec_player_count_08",
  691.         "70.0", "How many seconds to delay the respawn (when player count is 8)");
  692.     sm_respawn_delay_team_sec_player_count_09 = CreateConVar("sm_respawn_delay_team_sec_player_count_09",
  693.         "80.0", "How many seconds to delay the respawn (when player count is 9)");
  694.     sm_respawn_delay_team_sec_player_count_10 = CreateConVar("sm_respawn_delay_team_sec_player_count_10",
  695.         "80.0", "How many seconds to delay the respawn (when player count is 10)");
  696.     sm_respawn_delay_team_sec_player_count_11 = CreateConVar("sm_respawn_delay_team_sec_player_count_11",
  697.         "90.0", "How many seconds to delay the respawn (when player count is 11)");
  698.     sm_respawn_delay_team_sec_player_count_12 = CreateConVar("sm_respawn_delay_team_sec_player_count_12",
  699.         "90.0", "How many seconds to delay the respawn (when player count is 12)");
  700.     sm_respawn_delay_team_sec_player_count_13 = CreateConVar("sm_respawn_delay_team_sec_player_count_13",
  701.         "100.0", "How many seconds to delay the respawn (when player count is 13)");
  702.     sm_respawn_delay_team_sec_player_count_14 = CreateConVar("sm_respawn_delay_team_sec_player_count_14",
  703.         "100.0", "How many seconds to delay the respawn (when player count is 14)");
  704.     sm_respawn_delay_team_sec_player_count_15 = CreateConVar("sm_respawn_delay_team_sec_player_count_15",
  705.         "110.0", "How many seconds to delay the respawn (when player count is 15)");
  706.     sm_respawn_delay_team_sec_player_count_16 = CreateConVar("sm_respawn_delay_team_sec_player_count_16",
  707.         "110.0", "How many seconds to delay the respawn (when player count is 16)");
  708.     sm_respawn_delay_team_sec_player_count_17 = CreateConVar("sm_respawn_delay_team_sec_player_count_17",
  709.         "120.0", "How many seconds to delay the respawn (when player count is 17)");
  710.     sm_respawn_delay_team_sec_player_count_18 = CreateConVar("sm_respawn_delay_team_sec_player_count_18",
  711.         "120.0", "How many seconds to delay the respawn (when player count is 18)");
  712.     sm_respawn_delay_team_sec_player_count_19 = CreateConVar("sm_respawn_delay_team_sec_player_count_19",
  713.         "130.0", "How many seconds to delay the respawn (when player count is 19)");
  714.    
  715.     // Respawn type
  716.     sm_respawn_type_team_sec = CreateConVar("sm_respawn_type_team_sec",
  717.         "1", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_sec must be > 0");
  718.     sm_respawn_type_team_ins = CreateConVar("sm_respawn_type_team_ins",
  719.         "2", "1 - individual lives, 2 - each team gets a pool of lives used by everyone, sm_respawn_lives_team_ins must be > 0");
  720.    
  721.     // Respawn lives
  722.     sm_respawn_lives_team_sec = CreateConVar("sm_respawn_lives_team_sec",
  723.         "-1", "Respawn players this many times (-1: Disables player respawn)");
  724.     sm_respawn_lives_team_ins = CreateConVar("sm_respawn_lives_team_ins",
  725.         "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)");
  726.     sm_respawn_lives_team_ins_player_count_01 = CreateConVar("sm_respawn_lives_team_ins_player_count_01",
  727.         "5", "Total bot count (when player count is 1)(sm_respawn_type_team_ins must be 2)");
  728.     sm_respawn_lives_team_ins_player_count_02 = CreateConVar("sm_respawn_lives_team_ins_player_count_02",
  729.         "10", "Total bot count (when player count is 2)(sm_respawn_type_team_ins must be 2)");
  730.     sm_respawn_lives_team_ins_player_count_03 = CreateConVar("sm_respawn_lives_team_ins_player_count_03",
  731.         "15", "Total bot count (when player count is 3)(sm_respawn_type_team_ins must be 2)");
  732.     sm_respawn_lives_team_ins_player_count_04 = CreateConVar("sm_respawn_lives_team_ins_player_count_04",
  733.         "20", "Total bot count (when player count is 4)(sm_respawn_type_team_ins must be 2)");
  734.     sm_respawn_lives_team_ins_player_count_05 = CreateConVar("sm_respawn_lives_team_ins_player_count_05",
  735.         "25", "Total bot count (when player count is 5)(sm_respawn_type_team_ins must be 2)");
  736.     sm_respawn_lives_team_ins_player_count_06 = CreateConVar("sm_respawn_lives_team_ins_player_count_06",
  737.         "30", "Total bot count (when player count is 6)(sm_respawn_type_team_ins must be 2)");
  738.     sm_respawn_lives_team_ins_player_count_07 = CreateConVar("sm_respawn_lives_team_ins_player_count_07",
  739.         "35", "Total bot count (when player count is 7)(sm_respawn_type_team_ins must be 2)");
  740.     sm_respawn_lives_team_ins_player_count_08 = CreateConVar("sm_respawn_lives_team_ins_player_count_08",
  741.         "40", "Total bot count (when player count is 8)(sm_respawn_type_team_ins must be 2)");
  742.     sm_respawn_lives_team_ins_player_count_09 = CreateConVar("sm_respawn_lives_team_ins_player_count_09",
  743.         "45", "Total bot count (when player count is 9)(sm_respawn_type_team_ins must be 2)");
  744.     sm_respawn_lives_team_ins_player_count_10 = CreateConVar("sm_respawn_lives_team_ins_player_count_10",
  745.         "50", "Total bot count (when player count is 10)(sm_respawn_type_team_ins must be 2)");
  746.     sm_respawn_lives_team_ins_player_count_11 = CreateConVar("sm_respawn_lives_team_ins_player_count_11",
  747.         "55", "Total bot count (when player count is 11)(sm_respawn_type_team_ins must be 2)");
  748.     sm_respawn_lives_team_ins_player_count_12 = CreateConVar("sm_respawn_lives_team_ins_player_count_12",
  749.         "60", "Total bot count (when player count is 12)(sm_respawn_type_team_ins must be 2)");
  750.     sm_respawn_lives_team_ins_player_count_13 = CreateConVar("sm_respawn_lives_team_ins_player_count_13",
  751.         "65", "Total bot count (when player count is 13)(sm_respawn_type_team_ins must be 2)");
  752.     sm_respawn_lives_team_ins_player_count_14 = CreateConVar("sm_respawn_lives_team_ins_player_count_14",
  753.         "70", "Total bot count (when player count is 14)(sm_respawn_type_team_ins must be 2)");
  754.     sm_respawn_lives_team_ins_player_count_15 = CreateConVar("sm_respawn_lives_team_ins_player_count_15",
  755.         "75", "Total bot count (when player count is 15)(sm_respawn_type_team_ins must be 2)");
  756.     sm_respawn_lives_team_ins_player_count_16 = CreateConVar("sm_respawn_lives_team_ins_player_count_16",
  757.         "80", "Total bot count (when player count is 16)(sm_respawn_type_team_ins must be 2)");
  758.     sm_respawn_lives_team_ins_player_count_17 = CreateConVar("sm_respawn_lives_team_ins_player_count_17",
  759.         "85", "Total bot count (when player count is 17)(sm_respawn_type_team_ins must be 2)");
  760.     sm_respawn_lives_team_ins_player_count_18 = CreateConVar("sm_respawn_lives_team_ins_player_count_18",
  761.         "90", "Total bot count (when player count is 18)(sm_respawn_type_team_ins must be 2)");
  762.     sm_respawn_lives_team_ins_player_count_19 = CreateConVar("sm_respawn_lives_team_ins_player_count_19",
  763.         "90", "Total bot count (when player count is 19)(sm_respawn_type_team_ins must be 2)");
  764.    
  765.     // Fatally death
  766.     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)");
  767.     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");
  768.     sm_respawn_fatal_limb_dmg = CreateConVar("sm_respawn_fatal_limb_dmg", "80", "Amount of damage to fatally kill player in limb");
  769.     sm_respawn_fatal_head_dmg = CreateConVar("sm_respawn_fatal_head_dmg", "100", "Amount of damage to fatally kill player in head");
  770.     sm_respawn_fatal_burn_dmg = CreateConVar("sm_respawn_fatal_burn_dmg", "50", "Amount of damage to fatally kill player in burn");
  771.     sm_respawn_fatal_explosive_dmg = CreateConVar("sm_respawn_fatal_explosive_dmg", "200", "Amount of damage to fatally kill player in explosive");
  772.     sm_respawn_fatal_chest_stomach = CreateConVar("sm_respawn_fatal_chest_stomach", "100", "Amount of damage to fatally kill player in chest/stomach");
  773.    
  774.     // Counter attack
  775.     sm_respawn_counter_chance = CreateConVar("sm_respawn_counter_chance", "0.5", "Percent chance that a counter attack will happen def: 50%");
  776.     sm_respawn_counterattack_type = CreateConVar("sm_respawn_counterattack_type", "2", "Respawn during counterattack? (0: no, 1: yes, 2: infinite)");
  777.     sm_respawn_final_counterattack_type = CreateConVar("sm_respawn_final_counterattack_type", "2", "Respawn during final counterattack? (0: no, 1: yes, 2: infinite)");
  778.     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");
  779.     sm_respawn_min_counter_dur_sec = CreateConVar("sm_respawn_min_counter_dur_sec", "66", "Minimum randomized counter attack duration");
  780.     sm_respawn_max_counter_dur_sec = CreateConVar("sm_respawn_max_counter_dur_sec", "126", "Maximum randomized counter attack duration");
  781.     sm_respawn_final_counter_dur_sec = CreateConVar("sm_respawn_final_counter_dur_sec", "180", "Final counter attack duration");
  782.     sm_respawn_counterattack_vanilla = CreateConVar("sm_respawn_counterattack_vanilla", "0", "Use vanilla counter attack mechanics? (0: no, 1: yes)");
  783.    
  784.     //Dynamic respawn mechanics
  785.     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");
  786.     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)");
  787.     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)");
  788.    
  789.     // Misc
  790.     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)");
  791.     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)");
  792.    
  793.     // Reinforcements
  794.     sm_respawn_reinforce_time = CreateConVar("sm_respawn_reinforce_time", "200", "When enemy forces are low on lives, how much time til they get reinforcements?");
  795.     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?");
  796.     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");
  797.     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)");
  798.  
  799.     // Control static enemy
  800.     //sm_respawn_check_static_enemy = CreateConVar("sm_respawn_check_static_enemy", "120", "Seconds amount to check if an AI has moved probably stuck");
  801.     //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");
  802.    
  803.     // Donor tag
  804.     sm_respawn_enable_donor_tag = CreateConVar("sm_respawn_enable_donor_tag", "1", "If player has an access to reserved slot, add [DONOR] tag.");
  805.    
  806.     // Related to 'RoundEnd_Protector' plugin
  807.     //sm_remaininglife = CreateConVar("sm_remaininglife", "-1", "Returns total remaining life.");
  808.    
  809.     // Medic Revive
  810.     sm_revive_seconds = CreateConVar("sm_revive_seconds", "5", "Time in seconds medic needs to stand over body to revive");
  811.     //sm_revive_bonus = CreateConVar("sm_revive_bonus", "1", "Bonus revive score(kill count) for medic");
  812.     sm_revive_distance_metric = CreateConVar("sm_revive_distance_metric", "1", "Distance metric (0: meters / 1: feet)");
  813.     //sm_heal_bonus = CreateConVar("sm_heal_bonus", "1", "Bonus heal score(kill count) for medic");
  814.     sm_heal_cap_for_bonus = CreateConVar("sm_heal_cap_for_bonus", "5000", "Amount of health given to other players to gain a life");
  815.     sm_revive_cap_for_bonus = CreateConVar("sm_revive_cap_for_bonus", "50", "Amount of revives before medic gains a life");
  816.     sm_reward_medics_enabled = CreateConVar("sm_reward_medics_enabled", "1", "Enabled rewarding medics with lives? 0 = no, 1 = yes");
  817.     sm_heal_amount_medpack = CreateConVar("sm_heal_amount_medpack", "5", "Heal amount per 0.5 seconds when using medpack");
  818.     sm_heal_amount_paddles = CreateConVar("sm_heal_amount_paddles", "3", "Heal amount per 0.5 seconds when using paddles");
  819.     sm_non_medic_heal_amt = CreateConVar("sm_non_medic_heal_amt", "2", "Heal amount per 0.5 seconds when non-medic");
  820.     sm_non_medic_revive_hp = CreateConVar("sm_non_medic_revive_hp", "10", "Health given to target revive when non-medic reviving");
  821.     sm_medic_minor_revive_hp = CreateConVar("sm_medic_minor_revive_hp", "75", "Health given to target revive when medic reviving minor wound");
  822.     sm_medic_moderate_revive_hp = CreateConVar("sm_medic_moderate_revive_hp", "50", "Health given to target revive when medic reviving moderate wound");
  823.     sm_medic_critical_revive_hp = CreateConVar("sm_medic_critical_revive_hp", "25", "Health given to target revive when medic reviving critical wound");
  824.     sm_minor_wound_dmg = CreateConVar("sm_minor_wound_dmg", "100", "Any amount of damage <= to this is considered a minor wound when killed");
  825.     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");
  826.     sm_medic_heal_self_max = CreateConVar("sm_medic_heal_self_max", "75", "Max medic can heal self to with med pack");
  827.     sm_non_medic_heal_self_max = CreateConVar("sm_non_medic_heal_self_max", "25", "Max non-medic can heal self to with med pack");
  828.     sm_non_medic_max_heal_other = CreateConVar("sm_non_medic_max_heal_other", "25", "Heal amount per 0.5 seconds when using paddles");
  829.     sm_minor_revive_time = CreateConVar("sm_minor_revive_time", "4", "Seconds it takes medic to revive minor wounded");
  830.     sm_moderate_revive_time = CreateConVar("sm_moderate_revive_time", "7", "Seconds it takes medic to revive moderate wounded");
  831.     sm_critical_revive_time = CreateConVar("sm_critical_revive_time", "10", "Seconds it takes medic to revive critical wounded");
  832.     sm_non_medic_revive_time = CreateConVar("sm_non_medic_revive_time", "30", "Seconds it takes non-medic to revive minor wounded, requires medpack");
  833.     //sm_medpack_health_amount = CreateConVar("sm_medpack_health_amount", "500", "Amount of health a deployed healthpack has");
  834.     //sm_bombers_only = CreateConVar("sm_bombers_only", "0", "bombers ONLY?");
  835.     //sm_multi_loadout_enabled = CreateConVar("sm_multi_loadout_enabled", "0", "Use Sernix Variety Bot Loadout? - Default OFF");
  836.     //sm_ammo_resupply_range = CreateConVar("sm_ammo_resupply_range", "80", "Range to resupply near ammo cache");
  837.     sm_resupply_delay = CreateConVar("sm_resupply_delay", "5", "Delay loop for resupply ammo");
  838.     sm_jammer_required = CreateConVar("sm_jammer_required", "1", "Require deployable jammer for enemy reports? 0 = Disabled 1 = Enabled");
  839.     sm_elite_counter_attacks = CreateConVar("sm_elite_counter_attacks", "1", "Enable increased bot skills, numbers on counters?");
  840.     sm_enable_bonus_lives = CreateConVar("sm_enable_bonus_lives", "1", "Give bonus lives based on X condition? 0|1 ");
  841.    
  842.  
  843.     //Specialized Counter
  844.     sm_finale_counter_spec_enabled = CreateConVar("sm_finale_counter_spec_enabled", "0", "Enable specialized finale spawn percent? 1|0");
  845.     sm_finale_counter_spec_percent = CreateConVar("sm_finale_counter_spec_percent", "40", "What specialized finale counter percent for this map?");
  846.     //sm_cqc_map_enabled = CreateConVar("sm_cqc_map_enabled", "0", "Is this a cqc map? 0|1 no|yes");
  847.  
  848.     //sm_enable_squad_spawning = CreateConVar("sm_enable_squad_spawning", "0", "Enable squad spawning SERNIX SPECIFIC? 1|0");
  849.     //AI Director cvars
  850.     sm_ai_director_setdiff_chance_base = CreateConVar("sm_ai_director_setdiff_chance_base", "10", "Base AI Director Set Hard Difficulty Chance");
  851.  
  852.     //Respawn Modes
  853.     sm_respawn_mode_team_sec = CreateConVar("sm_respawn_mode_team_sec", "1", "Security: 0 = Individual spawning | 1 = Wave based spawning");
  854.     sm_respawn_mode_team_ins = CreateConVar("sm_respawn_mode_team_ins", "0", "Insurgents: 0 = Individual spawning | 1 = Wave based spawning");
  855.  
  856.     //Wave interval for insurgents only
  857.     sm_respawn_wave_int_team_ins = CreateConVar("sm_respawn_wave_int_team_ins", "1", "Time in seconds bots will respawn in waves");
  858.    
  859.     // cvars
  860.     sm_roundendblock_enabled = CreateConVar("sm_roundendblock_enabled", "1", "Coop bot Enabled", FCVAR_NOTIFY);
  861.     sm_roundendblock_times = CreateConVar("sm_roundendblock_times", "1", "How many times block rounds.");
  862.     sm_roundendblock_revive_delay = CreateConVar("sm_roundendblock_revive_delay", "10", "When blocks RoundEnd, wait for reviving players.");
  863.     sm_roundendblock_reset_each_round = CreateConVar("sm_roundendblock_reset_each_round", "1", "Reset block counter each round. (1 is reset / 0 is don't reset)");
  864.     sm_roundendblock_debug = CreateConVar("sm_roundendblock_debug", "0", "1: Turn on debug mode, 0: Turn off");
  865.  
  866.     CreateConVar("Lua_Ins_Healthkit", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_NOTIFY | FCVAR_DONTRECORD);
  867.    
  868.     if ((m_hMyWeapons = FindSendPropInfo("CBasePlayer", "m_hMyWeapons")) == -1)
  869.         SetFailState("Fatal Error: Unable to find property offset \"CBasePlayer::m_hMyWeapons\" !");
  870.    
  871.     if ((m_flNextPrimaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextPrimaryAttack")) == -1)
  872.         SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextPrimaryAttack\" !");
  873.    
  874.     if ((m_flNextSecondaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextSecondaryAttack")) == -1)    
  875.         SetFailState("Fatal Error: Unable to find property offset \"CBaseCombatWeapon::m_flNextSecondaryAttack\" !");
  876.  
  877.     // Add admin respawn console command
  878.     RegAdminCmd("sm_respawn", Command_Respawn, ADMFLAG_SLAY, "sm_respawn <#userid|name>");
  879.     // Add reload config console command for admin
  880.     RegAdminCmd("sm_respawn_reload", Command_Reload, ADMFLAG_SLAY, "sm_respawn_reload");
  881.     // register roundend admin commands
  882.     RegAdminCmd("sm_botcount", Command_BotCount, ADMFLAG_SLAY, "sm_botcount"); 
  883.    
  884.     g_iCollOff = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
  885.  
  886.     // Event hooking
  887.     //Lua Specific
  888.     //HookEvent("grenade_thrown", Event_GrenadeThrown);
  889.     //For ins_spawnpoint spawning
  890.     HookEvent("player_spawn", Event_Spawn);
  891.     HookEvent("player_spawn", Event_SpawnPost, EventHookMode_Post);
  892.     HookEvent("player_hurt", Event_PlayerHurt_Pre, EventHookMode_Pre);
  893.     HookEvent("player_death", Event_PlayerDeath_Pre, EventHookMode_Pre);
  894.     HookEvent("player_death", Event_PlayerDeath);
  895.     HookEvent("round_start", Event_RoundStart);
  896.     HookEvent("round_end", Event_RoundEnd);
  897.     HookEvent("round_end", Event_RoundEnd_Pre, EventHookMode_Pre);
  898.     HookEvent("game_start", Event_GameStart, EventHookMode_PostNoCopy);
  899.     HookEvent("game_end", Event_GameEnd, EventHookMode_PostNoCopy);
  900.     HookEvent("player_pick_squad", Event_PlayerPickSquad_Post, EventHookMode_Post);
  901.     HookEvent("object_destroyed", Event_ObjectDestroyed_Pre, EventHookMode_Pre);
  902.     HookEvent("object_destroyed", Event_ObjectDestroyed);
  903.     HookEvent("object_destroyed", Event_ObjectDestroyed_Post, EventHookMode_Post);
  904.     HookEvent("controlpoint_captured", Event_ControlPointCaptured_Pre, EventHookMode_Pre);
  905.     HookEvent("controlpoint_captured", Event_ControlPointCaptured);
  906.     HookEvent("controlpoint_captured", Event_ControlPointCaptured_Post, EventHookMode_Post);
  907.     HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
  908.     HookEvent("player_connect", Event_PlayerConnect);
  909.     //HookEvent("player_team", Event_PlayerTeam);
  910.     HookEvent("weapon_reload", Event_PlayerReload_Pre, EventHookMode_Pre);
  911.  
  912.     //AddCommandListener(ResupplyListener, "inventory_resupply");
  913.  
  914.     // NavMesh Botspawn Specific Start
  915.     cvarSpawnMode.AddChangeHook(CvarChange);
  916.     // NavMesh Botspawn Specific End
  917.    
  918.     // Revive/Heal specific
  919.     sm_revive_seconds.AddChangeHook(CvarChange);
  920.     sm_heal_amount_medpack.AddChangeHook(CvarChange);
  921.  
  922.     sm_non_medic_heal_amt.AddChangeHook(CvarChange);
  923.     sm_non_medic_revive_hp.AddChangeHook(CvarChange);
  924.     sm_medic_minor_revive_hp.AddChangeHook(CvarChange);
  925.     sm_medic_moderate_revive_hp.AddChangeHook(CvarChange);
  926.     sm_medic_critical_revive_hp.AddChangeHook(CvarChange);
  927.     sm_minor_wound_dmg.AddChangeHook(CvarChange);
  928.     sm_moderate_wound_dmg.AddChangeHook(CvarChange);
  929.     sm_medic_heal_self_max.AddChangeHook(CvarChange);
  930.     sm_non_medic_heal_self_max.AddChangeHook(CvarChange);
  931.     sm_non_medic_max_heal_other.AddChangeHook(CvarChange);
  932.     sm_minor_revive_time.AddChangeHook(CvarChange);
  933.     sm_moderate_revive_time.AddChangeHook(CvarChange);
  934.     sm_critical_revive_time.AddChangeHook(CvarChange);
  935.     sm_non_medic_revive_time.AddChangeHook(CvarChange);
  936.     sm_medpack_health_amount.AddChangeHook(CvarChange);
  937.     //sm_medpack_health_amount.AddChangeHook(CvarChange);
  938.    
  939.     // Respawn specific
  940.     sm_respawn_enabled.AddChangeHook(EnableChanged);
  941.     sm_revive_enabled.AddChangeHook(EnableChanged);
  942.     sm_respawn_delay_team_sec.AddChangeHook(CvarChange);
  943.     sm_respawn_delay_team_ins.AddChangeHook(CvarChange);
  944.     sm_respawn_delay_team_ins_special.AddChangeHook(CvarChange);
  945.     sm_respawn_lives_team_sec.AddChangeHook(CvarChange);
  946.     sm_respawn_lives_team_ins.AddChangeHook(CvarChange);
  947.     sm_respawn_reset_type.AddChangeHook(CvarChange);
  948.     sm_respawn_type_team_sec.AddChangeHook(CvarChange);
  949.     sm_respawn_type_team_ins.AddChangeHook(CvarChange);
  950.     cvarMinPlayerDistance.AddChangeHook(CvarChange);
  951.     cvarBackSpawnIncrease.AddChangeHook(CvarChange);
  952.     cvarMaxPlayerDistance.AddChangeHook(CvarChange);
  953.     cvarCanSeeVectorMultiplier.AddChangeHook(CvarChange);
  954.     cvarMinObjectiveDistance.AddChangeHook(CvarChange);
  955.     cvarMaxObjectiveDistance.AddChangeHook(CvarChange);
  956.     cvarMaxObjectiveDistanceNav.AddChangeHook(CvarChange);
  957.     sm_enable_bonus_lives.AddChangeHook(CvarChange);
  958.  
  959.     //Dynamic respawning
  960.     sm_respawn_dynamic_distance_multiplier.AddChangeHook(CvarChange);
  961.     sm_respawn_dynamic_spawn_counter_percent.AddChangeHook(CvarChange);
  962.     sm_respawn_dynamic_spawn_percent.AddChangeHook(CvarChange);
  963.  
  964.      //Reinforce Timer
  965.     sm_respawn_reinforce_time.AddChangeHook(CvarChange);
  966.     sm_respawn_reinforce_time_subsequent.AddChangeHook(CvarChange);
  967.     sm_respawn_reinforce_multiplier.AddChangeHook(CvarChange);
  968.     sm_respawn_reinforce_multiplier_base.AddChangeHook(CvarChange);
  969.  
  970.     // Tags
  971.     FindConVar("sv_tags").AddChangeHook(TagsChanged);
  972.  
  973.     //roundendblock
  974.     sm_roundendblock_enabled.AddChangeHook(CvarChange);
  975.     sm_roundendblock_times.AddChangeHook(CvarChange);
  976.     sm_roundendblock_reset_each_round.AddChangeHook(CvarChange);
  977.     sm_roundendblock_debug.AddChangeHook(CvarChange);
  978.     sm_roundendblock_revive_delay.AddChangeHook(CvarChange);
  979.  
  980.     //roundendblock
  981.     sm_roundendblock_enabled.AddChangeHook(CvarChange);
  982.     sm_roundendblock_times.AddChangeHook(CvarChange);
  983.     sm_roundendblock_reset_each_round.AddChangeHook(CvarChange);
  984.     sm_roundendblock_debug.AddChangeHook(CvarChange);
  985.     sm_roundendblock_revive_delay.AddChangeHook(CvarChange);
  986.  
  987.     //Other
  988.     sm_jammer_required.AddChangeHook(CvarChange);
  989.     sm_elite_counter_attacks.AddChangeHook(CvarChange);
  990.     sm_finale_counter_spec_enabled.AddChangeHook(CvarChange);
  991.     sm_ai_director_setdiff_chance_base.AddChangeHook(CvarChange);
  992.     sm_respawn_mode_team_sec.AddChangeHook(CvarChange);
  993.     sm_respawn_mode_team_ins.AddChangeHook(CvarChange);
  994.     sm_respawn_wave_int_team_ins.AddChangeHook(CvarChange);
  995.     sm_finale_counter_spec_percent.AddChangeHook(CvarChange);
  996.    
  997.     // Init respawn function
  998.     // Next 14 lines of text are taken from Andersso's DoDs respawn plugin. Thanks :)
  999.     //g_hGameConfig;
  1000.    
  1001.     //Handle g_hGameConfig;
  1002.     //Handle g_hForceRespawn;
  1003.    
  1004.     g_hGameConfig = LoadGameConfigFile("insurgency.games");
  1005.    
  1006.     if (g_hGameConfig == null)
  1007.         SetFailState("Fatal Error: Missing File \"insurgency.games\"!");
  1008.  
  1009.     StartPrepSDKCall(SDKCall_Player);
  1010.     char game[40];
  1011.     GetGameFolderName(game, sizeof(game));
  1012.     g_hPlayerRespawn = EndPrepSDKCall();
  1013.     if (StrEqual(game, "insurgency"))
  1014.     {
  1015.         PrepSDKCall_SetFromConf(g_hGameConfig, SDKConf_Signature, "ForceRespawn");
  1016.     }
  1017.    
  1018.     g_hForceRespawn = EndPrepSDKCall();
  1019.     if (g_hForceRespawn == INVALID_HANDLE)
  1020.     {
  1021.         SetFailState("Fatal Error: Unable to find signature for \"ForceRespawn\"!");
  1022.     }
  1023.  
  1024.     //Load localization file
  1025.     LoadTranslations("common.phrases");
  1026.     LoadTranslations("respawn.phrases");
  1027.     LoadTranslations("nearest_player.phrases.txt");
  1028.     AutoExecConfig(true, "respawn");
  1029.  
  1030.     // create config file
  1031.     //AutoExecConfig(true, "plugin.roundendblock");
  1032.  
  1033.     // init var - roundendblock
  1034.  
  1035.     g_iRoundEndBlockEnabled = GetConVarInt(sm_roundendblock_enabled);
  1036.     g_iRoundEndBlockTimes = GetConVarInt(sm_roundendblock_times);
  1037.     g_iRoundEndBlockReviveDelay = GetConVarInt(sm_roundendblock_revive_delay);
  1038.     g_iRoundEndBlockResetRound = GetConVarInt(sm_roundendblock_reset_each_round);
  1039.     g_iRoundEndBlockDebug = GetConVarInt(sm_roundendblock_debug);
  1040. }
  1041.  
  1042. // When cvar changed
  1043. void EnableChanged(ConVar convar, const char[] oldValue, const char[] newValue)
  1044. {
  1045.     int intNewValue = StringToInt(newValue);
  1046.     int intOldValue = StringToInt(oldValue);
  1047.  
  1048.     if(intNewValue == 1 && intOldValue == 0)
  1049.     {
  1050.         TagsCheck("respawntimes");
  1051.         //HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
  1052.     }
  1053.     else if(intNewValue == 0 && intOldValue == 1)
  1054.     {
  1055.         TagsCheck("respawntimes", true);
  1056.         //UnhookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
  1057.     }
  1058. }
  1059.  
  1060. // When cvar changed
  1061. void CvarChange(ConVar cvar, const char[] oldvalue, const char[] newvalue)
  1062. {
  1063. /*(g_iRoundEndBlockEnabled = sm_roundendblock_enabled.IntValue);
  1064. (g_iRoundEndBlockTimes = sm_roundendblock_times.IntValue);
  1065. (g_iRoundEndBlockReviveDelay = sm_roundendblock_revive_delay.IntValue);
  1066. (g_iRoundEndBlockResetRound = sm_roundendblock_reset_each_round.IntValue);
  1067. (g_iRoundEndBlockDebug = sm_roundendblock_debug.IntValue);*/
  1068. UpdateRespawnCvars();
  1069. }
  1070.  
  1071. // Update cvars
  1072. void UpdateRespawnCvars()
  1073. {
  1074.     //Counter attack chance based on number of points
  1075.     g_respawn_counter_chance = sm_respawn_counter_chance.FloatValue;
  1076.     g_counterAttack_min_dur_sec = sm_respawn_min_counter_dur_sec.IntValue;
  1077.     g_counterAttack_max_dur_sec = sm_respawn_max_counter_dur_sec.IntValue;
  1078.  
  1079.     // The number of control points
  1080.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  1081.     if (ncp < 6)
  1082.     {
  1083.         //Add to minimum dur as well.
  1084.         int fRandomInt = GetRandomInt(15, 30);
  1085.         int fRandomInt2 = GetRandomInt(6, 12);
  1086.         g_counterAttack_min_dur_sec += fRandomInt;
  1087.         g_counterAttack_max_dur_sec += fRandomInt2;
  1088.         g_respawn_counter_chance += 0.2;
  1089.     }
  1090.     else if (ncp >= 6 && ncp <= 8)
  1091.     {
  1092.         //Add to minimum dur as well.
  1093.         int fRandomInt = GetRandomInt(10, 20);
  1094.         int fRandomInt2 = GetRandomInt(4, 8);
  1095.         g_counterAttack_min_dur_sec += fRandomInt;
  1096.         g_counterAttack_max_dur_sec += fRandomInt2;
  1097.         g_respawn_counter_chance += 0.1;
  1098.     }
  1099.  
  1100. //  g_jammerRequired = GetConVarInt(sm_jammer_required);
  1101.     g_elite_counter_attacks = sm_elite_counter_attacks.IntValue;
  1102.     g_finale_counter_spec_enabled = sm_finale_counter_spec_enabled.IntValue;
  1103.     g_finale_counter_spec_percent = sm_finale_counter_spec_percent.IntValue;
  1104.  
  1105.     //Ai Director UpdateCvar
  1106.     g_AIDir_DiffChanceBase = sm_ai_director_setdiff_chance_base.IntValue;
  1107.  
  1108.     //Wave Based Spawning
  1109.     g_respawn_mode_team_sec = sm_respawn_mode_team_sec.IntValue;
  1110.    
  1111.     // Respawn type 1 //TEAM_1_SEC == Index 2 and TEAM_2_INS == Index 3
  1112.     g_iRespawnCount[2] = sm_respawn_lives_team_sec.IntValue;
  1113.     g_iRespawnCount[3] = sm_respawn_lives_team_ins.IntValue;
  1114.     g_GiveBonusLives = sm_enable_bonus_lives.IntValue;
  1115.  
  1116.     //Give bonus lives if lives are added per round
  1117.     if (g_GiveBonusLives && g_iCvar_respawn_reset_type == 0)
  1118.         SecTeamLivesBonus();
  1119.    
  1120.    
  1121.     // Type of resetting respawn token, Non-checkpoint modes get set to 0 automatically
  1122.     g_iCvar_respawn_reset_type = sm_respawn_reset_type.IntValue;
  1123.  
  1124.     if (g_isCheckpoint == 0)
  1125.         g_iCvar_respawn_reset_type = 0;
  1126.    
  1127.  
  1128.     // Update Cvars
  1129.     g_iCvar_respawn_enable = sm_respawn_enabled.IntValue;
  1130.     g_iCvar_revive_enable = sm_revive_enabled.IntValue;
  1131.     // Bot spawn mode
  1132.  
  1133.     g_iReinforce_Mult = sm_respawn_reinforce_multiplier.IntValue;
  1134.     g_iReinforce_Mult_Base = sm_respawn_reinforce_multiplier_base.IntValue;
  1135.  
  1136.     // Tracking ammo
  1137.     g_iCvar_enable_track_ammo = sm_respawn_enable_track_ammo.IntValue;
  1138.  
  1139.     // Respawn type
  1140.     g_iCvar_respawn_type_team_ins = sm_respawn_type_team_ins.IntValue;
  1141.     g_iCvar_respawn_type_team_sec = sm_respawn_type_team_sec.IntValue;
  1142.  
  1143.  
  1144.     //Dynamic Respawns
  1145.     g_DynamicRespawn_Distance_mult = sm_respawn_dynamic_distance_multiplier.IntValue;
  1146.     g_dynamicSpawnCounter_Perc = sm_respawn_dynamic_spawn_counter_percent.IntValue;
  1147.     g_dynamicSpawn_Perc = sm_respawn_dynamic_spawn_percent.IntValue;
  1148.  
  1149.     //Revive counts
  1150.  
  1151.     // Heal Amount
  1152.     g_iHeal_amount_medPack = sm_heal_amount_medpack.IntValue;
  1153.     g_iHeal_amount_paddles = sm_heal_amount_paddles.IntValue;
  1154.     g_nonMedicHeal_amount = sm_non_medic_heal_amt.IntValue;
  1155.  
  1156.     //HP when revived from wound
  1157.     g_nonMedicRevive_hp = sm_non_medic_revive_hp.IntValue;
  1158.     g_minorWoundRevive_hp = sm_medic_minor_revive_hp.IntValue;
  1159.     g_modWoundRevive_hp = sm_medic_moderate_revive_hp.IntValue;
  1160.     g_critWoundRevive_hp = sm_medic_critical_revive_hp.IntValue;
  1161.  
  1162.     //New Revive Mechanics
  1163.     g_minorWound_dmg = sm_minor_wound_dmg.IntValue;
  1164.     g_moderateWound_dmg = sm_moderate_wound_dmg.IntValue;
  1165.     g_medicHealSelf_max = sm_medic_heal_self_max.IntValue;
  1166.     g_nonMedicHealSelf_max = sm_non_medic_heal_self_max.IntValue;
  1167.     g_nonMedic_maxHealOther = sm_non_medic_max_heal_other.IntValue;
  1168.     g_minorRevive_time = sm_minor_revive_time.IntValue;
  1169.     g_modRevive_time = sm_moderate_revive_time.IntValue;
  1170.     g_critRevive_time = sm_critical_revive_time.IntValue;
  1171.     g_nonMedRevive_time = sm_non_medic_revive_time.IntValue;
  1172.     //g_medpack_health_amt = sm_medpack_health_amount.IntValue;
  1173.     // Fatal dead
  1174.     g_fCvar_fatal_chance = sm_respawn_fatal_chance.FloatValue;
  1175.     g_fCvar_fatal_head_chance = sm_respawn_fatal_head_chance.FloatValue;
  1176.     g_iCvar_fatal_limb_dmg = sm_respawn_fatal_limb_dmg.IntValue;
  1177.     g_iCvar_fatal_head_dmg = sm_respawn_fatal_head_dmg.IntValue;
  1178.     g_iCvar_fatal_burn_dmg = sm_respawn_fatal_burn_dmg.IntValue;
  1179.     g_iCvar_fatal_explosive_dmg = sm_respawn_fatal_explosive_dmg.IntValue;
  1180.     g_iCvar_fatal_chest_stomach = sm_respawn_fatal_chest_stomach.IntValue;
  1181.  
  1182.     // Nearest body distance metric
  1183.     g_iUnitMetric = sm_revive_distance_metric.IntValue;
  1184.    
  1185.     // Set respawn delay time
  1186.     g_iRespawnSeconds = -1;
  1187.     switch (GetTeamSecCount())
  1188.     {
  1189.         case 0: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_01.IntValue;
  1190.         case 1: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_01.IntValue;
  1191.         case 2: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_02.IntValue;
  1192.         case 3: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_03.IntValue;
  1193.         case 4: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_04.IntValue;
  1194.         case 5: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_05.IntValue;
  1195.         case 6: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_06.IntValue;
  1196.         case 7: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_07.IntValue;
  1197.         case 8: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_08.IntValue;
  1198.         case 9: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_09.IntValue;
  1199.         case 10: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_10.IntValue;
  1200.         case 11: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_11.IntValue;
  1201.         case 12: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_12.IntValue;
  1202.         case 13: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_13.IntValue;
  1203.         case 14: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_14.IntValue;
  1204.         case 15: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_15.IntValue;
  1205.         case 16: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_16.IntValue;
  1206.         case 17: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_17.IntValue;
  1207.         case 18: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_18.IntValue;
  1208.         case 19: g_iRespawnSeconds = sm_respawn_delay_team_sec_player_count_19.IntValue;
  1209.     }
  1210.     // If not set use default
  1211.     if (g_iRespawnSeconds == -1)
  1212.         g_iRespawnSeconds = sm_respawn_delay_team_sec.IntValue;
  1213.    
  1214.  
  1215.     // Respawn type 2 for players
  1216.     if (g_iCvar_respawn_type_team_sec == 2)
  1217.     {
  1218.         g_iRespawn_lives_team_sec = sm_respawn_lives_team_sec.IntValue;
  1219.     }
  1220.     // Respawn type 2 for bots
  1221.     else if (g_iCvar_respawn_type_team_ins == 2)
  1222.     {
  1223.         // Set base value of remaining lives for team insurgent
  1224.         g_iRespawn_lives_team_ins = -1;
  1225.         switch (GetTeamSecCount())
  1226.         {
  1227.             case 0: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_01.IntValue;
  1228.             case 1: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_01.IntValue;
  1229.             case 2: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_02.IntValue;
  1230.             case 3: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_03.IntValue;
  1231.             case 4: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_04.IntValue;
  1232.             case 5: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_05.IntValue;
  1233.             case 6: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_06.IntValue;
  1234.             case 7: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_07.IntValue;
  1235.             case 8: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_08.IntValue;
  1236.             case 9: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_09.IntValue;
  1237.             case 10: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_10.IntValue;
  1238.             case 11: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_11.IntValue;
  1239.             case 12: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_12.IntValue;
  1240.             case 13: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_13.IntValue;
  1241.             case 14: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_14.IntValue;
  1242.             case 15: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_15.IntValue;
  1243.             case 16: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_16.IntValue;
  1244.             case 17: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_17.IntValue;
  1245.             case 18: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_18.IntValue;
  1246.             case 19: g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins_player_count_19.IntValue;
  1247.         }
  1248.        
  1249.         // If not set, use default
  1250.         if (g_iRespawn_lives_team_ins == -1)
  1251.             g_iRespawn_lives_team_ins = sm_respawn_lives_team_ins.IntValue;
  1252.        
  1253.     }
  1254.    
  1255.     // Counter attack
  1256.     g_flCanSeeVectorMultiplier = cvarCanSeeVectorMultiplier.FloatValue;
  1257.     g_iCvar_counterattack_type = sm_respawn_counterattack_type.IntValue;
  1258.     g_iCvar_counterattack_vanilla = sm_respawn_counterattack_vanilla.IntValue;
  1259.     g_iCvar_final_counterattack_type = sm_respawn_final_counterattack_type.IntValue;
  1260.     g_flMinPlayerDistance = cvarMinPlayerDistance.FloatValue;
  1261.     g_flBackSpawnIncrease = cvarBackSpawnIncrease.FloatValue;
  1262.     g_flMaxPlayerDistance = cvarMaxPlayerDistance.FloatValue;
  1263.     g_flMinObjectiveDistance = cvarMinObjectiveDistance.FloatValue;
  1264.     g_flSpawnAttackDelay = cvarSpawnAttackDelay.FloatValue;
  1265. }
  1266.  
  1267. // When tags changed
  1268. void TagsChanged(ConVar convar, const char[] oldValue, const char[] newValue)
  1269. {
  1270.     if (sm_respawn_enabled.BoolValue)
  1271.         TagsCheck("respawntimes");
  1272.     else
  1273.         TagsCheck("respawntimes", true);
  1274. }
  1275.  
  1276. // On map starts, call initalizing function
  1277. void OnMapStart()
  1278. {  
  1279.     //Clear player array
  1280.     ClearArray(g_playerArrayList);
  1281.    
  1282.     //roundendblock
  1283.     g_iSecBotID = 0;
  1284.     g_announceTick = g_max_AnnounceTime;
  1285.     g_isCheckpoint = 1;
  1286.     //end roundendblock
  1287.  
  1288.     //Materials for Medic Beams
  1289.     g_iBeaconBeam = PrecacheModel("sprites/laserbeam.vmt");
  1290.     g_iBeaconHalo = PrecacheModel("sprites/halo01.vmt");
  1291.    
  1292.     //Wait until players ready to enable spawn checking
  1293.     g_playersReady = false;
  1294.     g_botsReady = 0;
  1295.  
  1296.     // Wait for navmesh
  1297.     CreateTimer(2.0, Timer_MapStart);
  1298.     g_preRoundInitial = true;
  1299.  
  1300.     CreateTimer(1.0, Timer_AnnounceSaves, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1301. }
  1302.  
  1303. // Init config
  1304. void OnConfigsExecuted()
  1305. {
  1306.     ServerCommand("exec betterbots.cfg");
  1307.     if (sm_respawn_enabled.BoolValue)
  1308.     {
  1309.         TagsCheck("respawntimes");
  1310.     }
  1311.     else
  1312.     {
  1313.         TagsCheck("respawntimes", true);
  1314.     }
  1315. }
  1316.  
  1317. void OnMapEnd()
  1318. {
  1319.     // Reset respawn token
  1320.     ResetSecurityLives();
  1321.     ResetInsurgencyLives();
  1322.     (g_isMapInit = 0) && (g_botsReady = 0) && (g_iRoundStatus = 0) && (g_iEnableRevive = 0);
  1323. }
  1324.  
  1325. //End Plugin
  1326. void OnPluginEnd()
  1327. {
  1328.     int ent = -1;
  1329.     while ((ent = FindEntityByClassname(ent, "healthkit")) > MaxClients && IsValidEntity(ent))
  1330.         AcceptEntityInput(ent, "Kill");
  1331. }
  1332.  
  1333. // When player connected server, intialize variable
  1334. public void OnClientPutInServer(int client)
  1335. {
  1336.         playerPickSquad[client] = 0;
  1337.         g_trackKillDeaths[client] = 0;
  1338.         g_iHurtFatal[client] = -1;
  1339.         g_playerFirstJoin[client] = 1;
  1340.         g_iPlayerRespawnTimerActive[client] = 0;
  1341.  
  1342.     //SDKHook(client, SDKHook_PreThinkPost, SHook_OnPreThink);
  1343.         char sNickname[64];
  1344.         Format(sNickname, sizeof(sNickname), "%N", client);
  1345.         g_client_org_nickname[client] = sNickname;
  1346. }
  1347.  
  1348. // Initializing
  1349.  
  1350. public Action Timer_MapStart(Handle Timer)
  1351. {
  1352.     // Check is map initialized
  1353.     if (g_isMapInit == 1) return;
  1354.     g_isMapInit = 1;
  1355.  
  1356.     //AI Directory Reset
  1357.     g_AIDir_ReinforceTimer_Orig = FindConVar("sm_respawn_reinforce_time").IntValue;
  1358.     g_AIDir_ReinforceTimer_SubOrig = sm_respawn_reinforce_time_subsequent.IntValue;
  1359.  
  1360.     // Bot Reinforce Times
  1361.     g_iReinforceTime = sm_respawn_reinforce_time.IntValue;
  1362.  
  1363.     // Update cvars
  1364.     UpdateRespawnCvars();
  1365.     g_isCheckpoint = 0;
  1366.    
  1367.     // Reset hiding spot
  1368.     int iEmptyArray[MAX_OBJECTIVES];
  1369.     g_iCPHidingSpotCount = iEmptyArray;
  1370.    
  1371.     // Check gamemode
  1372.     char sGameMode[32];
  1373.     FindConVar("mp_gamemode").GetString(sGameMode, sizeof(sGameMode));
  1374.  
  1375.     if (StrEqual(sGameMode,"checkpoint"))
  1376.     {
  1377.         g_isCheckpoint = 1;
  1378.     }
  1379.  
  1380.     g_iEnableRevive = 0;
  1381.    
  1382.     // Reset respawn token
  1383.     ResetSecurityLives();
  1384.     ResetInsurgencyLives();
  1385.    
  1386.     // Enemy reinforcement announce timer
  1387.     CreateTimer(1.0, Timer_EnemyReinforce, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1388.  
  1389.     // Enemy remaining announce timer
  1390.     CreateTimer(30.0, Timer_Enemies_Remaining, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1391.    
  1392.     // Player status check timer
  1393.     //CreateTimer(1.0, Timer_PlayerStatus, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1394.    
  1395.     // Revive monitor
  1396.     CreateTimer(1.0, Timer_ReviveMonitor, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1397.    
  1398.     // Heal monitor
  1399.     CreateTimer(0.5, Timer_MedicMonitor, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1400.    
  1401.     // Display nearest body for medics
  1402.     CreateTimer(0.1, Timer_NearestBody, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1403.  
  1404.     // Display nearest body for medics
  1405.     CreateTimer(60.0, Timer_AmbientRadio, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1406.  
  1407.     // Monitor ammo resupply
  1408.     //CreateTimer(1.0, Timer_AmmoResupply, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1409.  
  1410.     // AI Director Tick
  1411.     CreateTimer(1.0, Timer_AIDirector_Main, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1412.  
  1413.     // Squad Spawn Notify Leader
  1414.     //if (GetConVarInt(sm_enable_squad_spawning) == 1)
  1415.     //CreateTimer(1.0, Timer_SquadSpawn_Notify, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1416.  
  1417.     // Elite Period
  1418.     //CreateTimer(1.0, Timer_ElitePeriodTick, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1419.    
  1420.     // Static enemy check timer
  1421.     //g_checkStaticAmt = sm_respawn_check_static_enemy.IntValue;
  1422.     //g_checkStaticAmtCntr = sm_respawn_check_static_enemy_counter.IntValue;
  1423.    
  1424.     //Temp testing
  1425.     //g_checkStaticAmtAway = 30;
  1426.     //g_checkStaticAmtCntrAway = 12;
  1427.    
  1428.     //Elite Bot cvar multipliers (used to minus off top of original cvars)
  1429.     g_bot_attack_aimtolerance_newthreat_amt_mult = 0.8;
  1430.     g_bot_attack_aimpenalty_amt_close_mult = 15;
  1431.     g_bot_attack_aimpenalty_amt_far_mult = 40;
  1432.     g_bot_attackdelay_frac_difficulty_impossible_mult = 0.03;
  1433.     g_bot_attack_aimpenalty_time_close_mult = 0.15;
  1434.     g_bot_attack_aimpenalty_time_far_mult = 2.0;
  1435.     g_coop_delay_penalty_base = 800;
  1436.     g_bot_aim_aimtracking_base = 0.05;
  1437.     g_bot_aim_aimtracking_frac_impossible =  0.05;
  1438.     g_bot_aim_angularvelocity_frac_impossible =  0.05;
  1439.     g_bot_aim_angularvelocity_frac_sprinting_target =  0.05;
  1440.     g_bot_aim_attack_aimtolerance_frac_impossible =  0.05;
  1441.  
  1442.     //Get Originals
  1443.     g_ins_bot_count_checkpoint_max_org = FindConVar("ins_bot_count_checkpoint_max").IntValue;
  1444.     g_mp_player_resupply_coop_delay_max_org = FindConVar("mp_player_resupply_coop_delay_max").IntValue;
  1445.     g_mp_player_resupply_coop_delay_penalty_org = FindConVar("mp_player_resupply_coop_delay_penalty").IntValue;
  1446.     g_mp_player_resupply_coop_delay_base_org = FindConVar("mp_player_resupply_coop_delay_base").IntValue;
  1447.     g_bot_attack_aimpenalty_amt_close_org = FindConVar("bot_attack_aimpenalty_amt_close").IntValue;
  1448.     g_bot_attack_aimpenalty_amt_far_org = FindConVar("bot_attack_aimpenalty_amt_far").IntValue;
  1449.     g_bot_attack_aimpenalty_time_close_org = FindConVar("bot_attack_aimpenalty_time_close").FloatValue;
  1450.     g_bot_attack_aimpenalty_time_far_org = FindConVar("bot_attack_aimpenalty_time_far").FloatValue;
  1451.     g_bot_attack_aimtolerance_newthreat_amt_org = FindConVar("bot_attack_aimtolerance_newthreat_amt").FloatValue;
  1452.     g_bot_attackdelay_frac_difficulty_impossible_org = FindConVar("bot_attackdelay_frac_difficulty_impossible").FloatValue;
  1453.     g_bot_aim_aimtracking_base_org = FindConVar("bot_aim_aimtracking_base").FloatValue;
  1454.     g_bot_aim_aimtracking_frac_impossible_org = FindConVar("bot_aim_aimtracking_frac_impossible").FloatValue;
  1455.     g_bot_aim_angularvelocity_frac_impossible_org = FindConVar("bot_aim_angularvelocity_frac_impossible").FloatValue;
  1456.     g_bot_aim_angularvelocity_frac_sprinting_target_org = FindConVar("bot_aim_angularvelocity_frac_sprinting_target").FloatValue;
  1457.     g_bot_aim_attack_aimtolerance_frac_impossible_org = FindConVar("bot_aim_attack_aimtolerance_frac_impossible").FloatValue;
  1458.  
  1459.     //CreateTimer(1.0, Timer_CheckEnemyStatic, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1460.     //CreateTimer(1.0, Timer_CheckEnemyAway, _ , TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  1461. }
  1462.  
  1463. // When player connected server, intialize variables
  1464. public Action Event_PlayerConnect(Event event, const char[] name, bool dontBroadcast) {
  1465.     int client = GetClientOfUserId(event.GetInt("userid"));
  1466.  
  1467.     playerPickSquad[client] = 0;
  1468.     g_iHurtFatal[client] = -1;
  1469.     g_playerFirstJoin[client] = 1;
  1470.     g_iPlayerRespawnTimerActive[client] = 0;
  1471.  
  1472.     //g_fPlayerLastChat[client] = GetGameTime();
  1473.  
  1474.     //Update RespawnCvars when players join
  1475.     UpdateRespawnCvars();
  1476. }
  1477.  
  1478. // When player disconnected server, intialize variables
  1479. public Action Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast)
  1480. {
  1481.     int client = GetClientOfUserId(event.GetInt("userid"));
  1482.     if (client > 0)
  1483.     {
  1484.         g_squadSpawnEnabled[client] = 0;
  1485.         playerPickSquad[client] = 0;
  1486.    
  1487.         // Reset player status
  1488.         //reset his class model
  1489.         g_client_last_classstring[client] = "";
  1490.    
  1491.         // Remove network ragdoll associated with player
  1492.         int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  1493.         if (playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  1494.         {
  1495.             RemoveRagdoll(client);
  1496.         }
  1497.  
  1498.         // Update cvar
  1499.         UpdateRespawnCvars();
  1500.     }
  1501.     g_LastButtons[client] = 0;
  1502.     return Plugin_Continue;
  1503. }
  1504.  
  1505. Action Timer_AnnounceSaves(Handle timer, any data)
  1506. {
  1507.  
  1508.     g_announceTick--;
  1509.     if (g_announceTick <= 0)
  1510.     {
  1511.         //char textToPrint[64];
  1512.         char textToHint[64];
  1513.         //Format(textToPrint, sizeof(textToPrint), "\x03[INTEL] Remaining Security Reinforcements: %d", g_iRoundBlockCount);
  1514.         Format(textToHint, sizeof(textToHint), "\x03[INTEL] Remaining Security Reinforcements: %d", g_iRoundBlockCount);
  1515.         //PrintToChatAll(textToPrint);
  1516.         PrintHintTextToAll(textToHint);
  1517.         g_announceTick = g_max_AnnounceTime;
  1518.     }
  1519. }
  1520.  
  1521.  
  1522. // Console command for reload config
  1523. public Action Command_Reload(int client, int args)
  1524. {
  1525.     ServerCommand("exec sourcemod/respawn.cfg");
  1526.  
  1527.     //Reset respawn token
  1528.     ResetSecurityLives();
  1529.     ResetInsurgencyLives();
  1530.    
  1531.     //PrintToServer("[RESPAWN] %N reloaded respawn config.", client);
  1532.     ReplyToCommand(client, "[SM] Reloaded 'sourcemod/respawn.cfg' file.");
  1533. }
  1534.  
  1535.  
  1536.  
  1537. // Respawn function for console command
  1538. public Action Command_Respawn(int client, int args) {
  1539.     // Check argument
  1540.     if (args < 1) {
  1541.         ReplyToCommand(client, "[SM] Usage: sm_player_respawn <#userid|name>");
  1542.         return Plugin_Handled;
  1543.     }
  1544.  
  1545.     // Retrive argument
  1546.     char arg[65];
  1547.     GetCmdArg(1, arg, sizeof(arg));
  1548.     char target_name[MAX_TARGET_LENGTH];
  1549.     int[] target_list = new int[MaxClients];
  1550.     int target_count;
  1551.     bool tn_is_ml;
  1552.  
  1553.     // Get target count
  1554.     target_count = ProcessTargetString(
  1555.                     arg,
  1556.                     client,
  1557.                     target_list,
  1558.                     MaxClients,
  1559.                     COMMAND_FILTER_DEAD,
  1560.                     target_name,
  1561.                     sizeof(target_name),
  1562.                     tn_is_ml);
  1563.  
  1564.     // Check target count
  1565.     // If we don't have dead players
  1566.     if (target_count <= COMMAND_TARGET_NONE)  {
  1567.         ReplyToTargetError(client, target_count);
  1568.         return Plugin_Handled;
  1569.     }
  1570.  
  1571.     // Team filter dead players, re-order target_list array with new_target_count
  1572.     int target;
  1573.     int team;
  1574.  
  1575.     int new_target_count;
  1576.  
  1577.  
  1578.     // Check team
  1579.     for (int i = 0; i < target_count; i++) {
  1580.         target = target_list[i];
  1581.         team = GetClientTeam(target);
  1582.  
  1583.         if (team >= 2) {
  1584.             // re-order
  1585.             target_list[new_target_count] = target;
  1586.             new_target_count++;
  1587.         }
  1588.     }
  1589.  
  1590.     // Check target count
  1591.     // No dead players from  team 2 and 3
  1592.     if (new_target_count == COMMAND_TARGET_NONE)  {
  1593.         ReplyToTargetError(client, new_target_count);
  1594.         return Plugin_Handled;
  1595.     }
  1596.     // re-set new value.
  1597.     target_count = new_target_count;
  1598.  
  1599.     // If target exists
  1600.     if (tn_is_ml) {
  1601.         ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", target_name);
  1602.     }
  1603.     else {
  1604.         ShowActivity2(client, "[SM] ", "%t", "Toggled respawn on target", "_s", target_name);
  1605.     }
  1606.  
  1607.     // Process respawn
  1608.     for (int i = 0; i < target_count; i++) {
  1609.         RespawnPlayer(client, target_list[i]);
  1610.     }
  1611.  
  1612.     return Plugin_Handled;
  1613. }
  1614.  
  1615. /*Action Timer_EliteBots(Handle Timer)
  1616. {
  1617.     // Get the number of control points
  1618.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  1619.     // Get active push point
  1620.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  1621.     if (Ins_InCounterAttack())
  1622.     {      
  1623.         if ((acp+1) == ncp)
  1624.             g_isEliteCounter = 1;
  1625.         else
  1626.             g_isEliteCounter = 1;
  1627.     }
  1628. }*/
  1629.  
  1630. // Respawn player
  1631. void RespawnPlayer(int client, int target)
  1632. {
  1633.     int team = GetClientTeam(target);
  1634.     if(IsClientInGame(target) && !IsClientTimingOut(target) && g_client_last_classstring[target][0]
  1635.         && playerPickSquad[target] == 1 && !IsPlayerAlive(target) && team == TEAM_1_SEC)
  1636.    
  1637.     // Write a log
  1638.     {
  1639.         LogAction(client, target, "\"%L\" respawned \"%L\"", client, target);
  1640.  
  1641.         // Call force respawn function
  1642.         SDKCall(g_hForceRespawn, target);
  1643.     }
  1644. }
  1645.  
  1646. // ForceRespawnPlayer player
  1647. void ForceRespawnPlayer(int client, int target)
  1648. {
  1649.     int team = GetClientTeam(target);
  1650.     if(IsClientInGame(target) && !IsClientTimingOut(target) && g_client_last_classstring[target][0]
  1651.         && playerPickSquad[target] == 1 && team == TEAM_1_SEC)
  1652.     {
  1653.         // Write a log
  1654.         LogAction(client, target, "\"%L\" respawned \"%L\"", client, target);
  1655.        
  1656.         // Call force respawn fucntion
  1657.         SDKCall(g_hForceRespawn, target);
  1658.     }
  1659. }
  1660.  
  1661. // Announce enemies remaining
  1662. Action Timer_Enemies_Remaining(Handle Timer)
  1663. {
  1664.     // Check round state
  1665.     if (g_iRoundStatus == 0) return Plugin_Continue;
  1666.  
  1667.     // Check enemy count
  1668.     int alive_insurgents;
  1669.     for (int i = 1; i <= MaxClients; i++)
  1670.     {
  1671.         if (IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i))
  1672.             alive_insurgents++;
  1673.     }
  1674.     //sm_medpack_health_amount new validAntenna = -1;
  1675.     //validAntenna = FindValid_Antenna();
  1676.     //if (validAntenna != -1 || g_jammerRequired == 0)
  1677.     // Announce
  1678.     //decl String:textToPrintChat[64];
  1679.     char textToPrint[32];
  1680.     //Format(textToPrintChat, sizeof(textToPrintChat), "[INTEL]Enemies alive: %d | Enemy reinforcements left: %d", alive_insurgents, g_iRemaining_lives_team_ins);
  1681.     Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemies alive: %d", alive_insurgents);
  1682.     PrintHintTextToAll(textToPrint);
  1683.         //PrintToChatAll(textToPrintChat);
  1684.  
  1685.     int timeReduce = (GetTeamSecCount() / 3);
  1686.     if (timeReduce <= 0)
  1687.         timeReduce = 3;
  1688.     return Plugin_Continue;
  1689. }
  1690.  
  1691. //Check Min/Max AD
  1692. stock int AI_Director_SetMinMax(int t_AIDir_TeamStatus, int t_AIDir_TeamStatus_min, int t_AIDir_TeamStatus_max)
  1693. {
  1694.     if (t_AIDir_TeamStatus < t_AIDir_TeamStatus_min)
  1695.     t_AIDir_TeamStatus = t_AIDir_TeamStatus_min;
  1696.     else if (t_AIDir_TeamStatus > t_AIDir_TeamStatus_max)
  1697.     t_AIDir_TeamStatus = t_AIDir_TeamStatus_max;
  1698.     return t_AIDir_TeamStatus;
  1699. }
  1700.  
  1701. Action AI_Director_RandomEnemyReinforce()
  1702. {
  1703.     char textToPrint[64];
  1704.     //Only add more reinforcements if under certain amount so its not endless.
  1705.     if (g_iRemaining_lives_team_ins > 0)
  1706.     {
  1707.             // Get bot count
  1708.             int minBotCount = (g_iRespawn_lives_team_ins / 5);
  1709.             g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
  1710.             Format(textToPrint, sizeof(textToPrint), "[INTEL]Ambush Reinforcements Added to Existing Reinforcements!");
  1711.            
  1712.             //AI Director Reinforcement START
  1713.             g_AIDir_BotReinforceTriggered = true;
  1714.             g_AIDir_TeamStatus -= 5;
  1715.             g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  1716.             //AI Director Reinforcement END
  1717.  
  1718.             PrintHintTextToAll(textToPrint);
  1719.             g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
  1720.  
  1721.             //Lower Bot Flank spawning on reinforcements
  1722.             g_dynamicSpawn_Perc = 0;
  1723.  
  1724.             // Add bots
  1725.             for (int client = 1; client <= MaxClients; client++)
  1726.             {
  1727.                 if (client > 0 && IsClientInGame(client))
  1728.                 {
  1729.                     int m_iTeam = GetClientTeam(client);
  1730.                     if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
  1731.                     {
  1732.                         g_iRemaining_lives_team_ins++;
  1733.                         CreateBotRespawnTimer(client);
  1734.                     }
  1735.                 }
  1736.             }
  1737.            
  1738.             //Reset bot back spawning to default
  1739.             CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
  1740.     }
  1741.     else
  1742.     {
  1743.         // Get bot count
  1744.         int minBotCount = (g_iRespawn_lives_team_ins / 5);
  1745.         g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
  1746.  
  1747.         //Lower Bot Flank spawning on reinforcements
  1748.         g_dynamicSpawn_Perc = 0;
  1749.  
  1750.         // Add bots
  1751.         for (int client = 1; client <= MaxClients; client++)
  1752.         {
  1753.             if (client > 0 && IsClientInGame(client))
  1754.             {
  1755.                 int m_iTeam = GetClientTeam(client);
  1756.                 if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
  1757.                 {
  1758.                     g_iRemaining_lives_team_ins++;
  1759.                     CreateBotRespawnTimer(client);
  1760.                 }
  1761.             }
  1762.         }
  1763.         g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
  1764.  
  1765.         //Reset bot back spawning to default
  1766.         CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
  1767.  
  1768.         // Get random duration
  1769.         //new fRandomInt = GetRandomInt(1, 4);
  1770.  
  1771.         Format(textToPrint, sizeof(textToPrint), "[INTEL]Enemy Ambush Reinforcement Incoming!");
  1772.  
  1773.         //AI Director Reinforcement START
  1774.         g_AIDir_BotReinforceTriggered = true;
  1775.         g_AIDir_TeamStatus -= 5;
  1776.         g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  1777.  
  1778.         //AI Director Reinforcement END
  1779.  
  1780.         PrintHintTextToAll(textToPrint);
  1781.     }
  1782. }
  1783.  
  1784. // This timer reinforces bot team if you do not capture point
  1785. Action Timer_EnemyReinforce(Handle Timer)
  1786. {
  1787.     // Check round state
  1788.     if (g_iRoundStatus == 0) return Plugin_Continue;
  1789.    
  1790.     // Check enemy remaining
  1791.     if (g_iRemaining_lives_team_ins <= (g_iRespawn_lives_team_ins / g_iReinforce_Mult) + g_iReinforce_Mult_Base)
  1792.     {
  1793.         g_iReinforceTime--;
  1794.         char textToPrint[64];
  1795.         // Announce every 10 seconds
  1796.         if (g_iReinforceTime % 10 == 0 && g_iReinforceTime > 10)
  1797.         {
  1798.                 Format(textToPrint, sizeof(textToPrint), "Allied forces spawn on counter-attacks, capture the point!");
  1799.                 PrintHintTextToAll(textToPrint);
  1800.         }
  1801.         // Announce every 1 second
  1802.         if (g_iReinforceTime <= 10)
  1803.         {
  1804.             Format(textToPrint, sizeof(textToPrint), "ISIS reinforce in %d seconds | capture point soon!", g_iReinforceTime);
  1805.             PrintHintTextToAll(textToPrint);
  1806.         }
  1807.         // Process reinforcement
  1808.         if (g_iReinforceTime <= 0)
  1809.         {
  1810.             // If enemy reinforcement is not over, add it
  1811.             if (g_iRemaining_lives_team_ins > 0)
  1812.             {
  1813.                 //Only add more reinforcements if under certain amount so its not endless.
  1814.                 if (g_iRemaining_lives_team_ins < (g_iRespawn_lives_team_ins / g_iReinforce_Mult) + g_iReinforce_Mult_Base)
  1815.                 {
  1816.                     // Get bot count
  1817.                     int minBotCount = (g_iRespawn_lives_team_ins / 4);
  1818.                     g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
  1819.                     Format(textToPrint, sizeof(textToPrint), "ISIS terrorists have arrived!");
  1820.                    
  1821.                     //AI Director Reinforcement START
  1822.                     g_AIDir_BotReinforceTriggered = true;
  1823.                     g_AIDir_TeamStatus -= 5;
  1824.                     g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  1825.                     //AI Director Reinforcement END
  1826.  
  1827.                     PrintHintTextToAll(textToPrint);
  1828.                     g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
  1829.  
  1830.                     //Lower Bot Flank spawning on reinforcements
  1831.                     g_dynamicSpawn_Perc = 0;
  1832.  
  1833.                     // Add bots
  1834.                     for (int client = 1; client <= MaxClients; client++)
  1835.                     {
  1836.                         if (client > 0 && IsClientInGame(client))
  1837.                         {
  1838.                             int m_iTeam = GetClientTeam(client);
  1839.                             if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
  1840.                             {
  1841.                                 g_iRemaining_lives_team_ins++;
  1842.                                 CreateBotRespawnTimer(client);
  1843.                             }
  1844.                         }
  1845.                     }
  1846.                    
  1847.                     //Reset bot back spawning to default
  1848.                     CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
  1849.                 }
  1850.                 else
  1851.                 {
  1852.                
  1853.                     // Reset reinforce time
  1854.                     g_iReinforceTime = g_iReinforceTime_AD_Temp;
  1855.                 }
  1856.             }
  1857.  
  1858.             // Respawn enemies
  1859.             else
  1860.             {
  1861.                 // Get bot count
  1862.                 int minBotCount = (g_iRespawn_lives_team_ins / 4);
  1863.                 g_iRemaining_lives_team_ins = g_iRemaining_lives_team_ins + minBotCount;
  1864.                
  1865.                 //Lower Bot Flank spawning on reinforcements
  1866.                 g_dynamicSpawn_Perc = 0;
  1867.  
  1868.                 // Add bots
  1869.                 for (int client = 1; client <= MaxClients; client++)
  1870.                 {
  1871.                     if (client > 0 && IsClientInGame(client))
  1872.                     {
  1873.                         int m_iTeam = GetClientTeam(client);
  1874.                         if (IsFakeClient(client) && !IsPlayerAlive(client) && m_iTeam == TEAM_2_INS)
  1875.                         {
  1876.                             g_iRemaining_lives_team_ins++;
  1877.                             CreateBotRespawnTimer(client);
  1878.                         }
  1879.                     }
  1880.                 }
  1881.                 g_iReinforceTime = g_iReinforceTimeSubsequent_AD_Temp;
  1882.  
  1883.                 //Reset bot back spawning to default
  1884.                 CreateTimer(45.0, Timer_ResetBotFlankSpawning, _);
  1885.  
  1886.                 // Get random duration
  1887.                 //new fRandomInt = GetRandomInt(1, 4);
  1888.                
  1889.                 Format(textToPrint, sizeof(textToPrint), "ISIS terrorists have now arrived!");
  1890.  
  1891.                 //AI Director Reinforcement START
  1892.                 g_AIDir_BotReinforceTriggered = true;
  1893.                 g_AIDir_TeamStatus -= 5;
  1894.                 g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  1895.  
  1896.                 //AI Director Reinforcement END
  1897.                 PrintHintTextToAll(textToPrint);
  1898.             }
  1899.         }
  1900.     }
  1901.     return Plugin_Continue;
  1902. }
  1903.  
  1904. //Reset bot flank spawning X seconds after reinforcement
  1905. Action Timer_ResetBotFlankSpawning(Handle timer)
  1906. {
  1907.     //Reset bot back spawning to default
  1908.     g_dynamicSpawn_Perc = sm_respawn_dynamic_spawn_percent.IntValue;
  1909.     return Plugin_Continue;
  1910. }
  1911.  
  1912. /*
  1913. // Check enemy is stuck
  1914. public Action Timer_CheckEnemyStatic(Handle timer) {
  1915.     //Remove bot weapons when static killed to reduce server performance on dropped items.
  1916.     int primaryRemove = 1;
  1917.     int secondaryRemove ;
  1918.      grenadesRemove = 1;
  1919.  
  1920.     // Check round state
  1921.     if (g_iRoundStatus == 0) {
  1922.         return Plugin_Continue;
  1923.     }
  1924.  
  1925.     if (Ins_InCounterAttack()) {
  1926.         g_checkStaticAmtCntr = g_checkStaticAmtCntr - 1;
  1927.         if (g_checkStaticAmtCntr <= 0) {
  1928.             for (int enemyBot = 1; enemyBot <= MaxClients; enemyBot++) {
  1929.                 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot)) {
  1930.                     int m_iTeam = GetClientTeam(enemyBot);
  1931.                     if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS) {
  1932.                         // Get current position
  1933.                         float enemyPos[3];
  1934.                         GetClientAbsOrigin(enemyBot, float enemyPos);
  1935.  
  1936.                         // Get distance
  1937.                         float tDistance;
  1938.                         float capDistance;
  1939.                         tDistance = GetVectorDistance(enemyPos, g_enemyTimerPos[enemyBot]);
  1940.                         if (g_isCheckpoint == 1) {
  1941.                             int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  1942.                             if (0 <= m_nActivePushPointIndex < sizeof(m_vCPPositions))
  1943.                             Ins_ObjectiveResource_GetPropVector(" ", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  1944.                             capDistance = GetVectorDistance(enemyPos, m_vCPPositions[m_nActivePushPointIndex]);
  1945.                         }
  1946.                         else {
  1947.                             capDistance = 801.0;
  1948.                         }
  1949.                         // If enemy position is static, kill him
  1950.                         if (tDistance <= 150 && Check_NearbyPlayers(enemyBot) && (capDistance > 800 || g_botStaticGlobal[enemyBot] > 120)) {
  1951.                             RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
  1952.                             ForcePlayerSuicide(enemyBot);
  1953.                             AddLifeForStaticKilling(enemyBot);
  1954.                             //PrintToServer("ENEMY STATIC - KILLING");
  1955.                             g_badSpawnPos_Track[enemyBot] = enemyPos;
  1956.                             //PrintToServer("Add to g_badSpawnPos_Array | enemyPos: (%f, %f, %f) | g_badSpawnPos_Array Size: %d", enemyPos[0], enemyPos[1], enemyPos[2], g_badSpawnPos_Array.Length);
  1957.                             //g_badSpawnPos_Array.PushArray(enemyPos, sizeof(enemyPos));
  1958.                         }
  1959.                         // Update current position
  1960.                         else {
  1961.                             g_enemyTimerPos[enemyBot] = enemyPos;
  1962.                             g_botStaticGlobal[enemyBot]++;
  1963.                         }
  1964.                     }
  1965.                 }
  1966.             }
  1967.             g_checkStaticAmtCntr = sm_respawn_check_static_enemy_counter.IntValue;
  1968.         }
  1969.     }
  1970.     else {
  1971.         g_checkStaticAmt = g_checkStaticAmt - 1;
  1972.         if (g_checkStaticAmt <= 0) {
  1973.             for (int enemyBot = 1; enemyBot <= MaxClients; enemyBot++) {
  1974.                 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot)) {
  1975.                     int m_iTeam = GetClientTeam(enemyBot);
  1976.                     if (enemyBot > 0 && IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS) {
  1977.                         // Get current position
  1978.                         float enemyPos[3];
  1979.                         GetClientAbsOrigin(enemyBot, float enemyPos);
  1980.  
  1981.                         // Get distance
  1982.                         float tDistance;
  1983.                         float capDistance;
  1984.                         tDistance = GetVectorDistance(enemyPos, g_enemyTimerPos[enemyBot]);
  1985.                         //Check point distance
  1986.                         if (g_isCheckpoint == 1) {
  1987.                             int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  1988.                             if (0 <= m_nActivePushPointIndex < sizeof(m_vCPPositions))
  1989.                             Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  1990.                             capDistance = GetVectorDistance(enemyPos, m_vCPPositions[m_nActivePushPointIndex]);
  1991.                         }
  1992.                         else {
  1993.                             capDistance = 801.0;
  1994.                         }
  1995.                         // If enemy position is static, kill him
  1996.                         // || g_botStaticGlobal[enemyBot] > 120))
  1997.                         if (tDistance <= 150 && (capDistance > 800) && Check_NearbyPlayers(enemyBot))  {
  1998.                             //PrintToServer("ENEMY STATIC - KILLING");
  1999.                             RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
  2000.                             ForcePlayerSuicide(enemyBot);
  2001.                             AddLifeForStaticKilling(enemyBot);
  2002.                         }
  2003.                         // Update current position
  2004.                         else {
  2005.                             g_enemyTimerPos[enemyBot] = enemyPos;
  2006.                             //g_botStaticGlobal[enemyBot]++;
  2007.                         }
  2008.                     }
  2009.                 }
  2010.             }
  2011.             g_checkStaticAmt = sm_respawn_check_static_enemy.IntValue;
  2012.         }
  2013.     }
  2014.  
  2015.     return Plugin_Continue;
  2016. }
  2017. // Check enemy is stuck
  2018. public Action Timer_CheckEnemyAway(Handle timer) {
  2019.     //Remove bot weapons when static killed to reduce server performance on dropped items.
  2020.     int primaryRemove = 1;
  2021.     int secondaryRemove ;
  2022.      grenadesRemove = 1;
  2023.     // Check round state
  2024.     if (g_iRoundStatus == 0) {
  2025.         return Plugin_Continue;
  2026.     }
  2027.  
  2028.     if (Ins_InCounterAttack()) {
  2029.         g_checkStaticAmtCntrAway = g_checkStaticAmtCntrAway - 1;
  2030.         if (g_checkStaticAmtCntrAway <= 0) {
  2031.             for (int enemyBot = 1; enemyBot <= MaxClients; enemyBot++) {
  2032.                 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot)) {
  2033.                     int m_iTeam = GetClientTeam(enemyBot);
  2034.                     if (IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS) {
  2035.                         // Get current position
  2036.                         float enemyPos[3];
  2037.                         GetClientAbsOrigin(enemyBot, float enemyPos);
  2038.  
  2039.                         // Get distance
  2040.                         float tDistance;
  2041.                         float capDistance;
  2042.                         tDistance = GetVectorDistance(enemyPos, g_enemyTimerAwayPos[enemyBot]);
  2043.                         if (g_isCheckpoint == 1) {
  2044.                             int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2045.                             Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2046.                             capDistance = GetVectorDistance(enemyPos, m_vCPPositions[m_nActivePushPointIndex]);
  2047.                         }
  2048.                         else {
  2049.                             capDistance = 801.0;
  2050.                         }
  2051.                         // If enemy position is static, kill him
  2052.                         if (tDistance <= 150 && capDistance > 2500) {
  2053.                             //PrintToServer("ENEMY STATIC - KILLING");
  2054.                             RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
  2055.                             ForcePlayerSuicide(enemyBot);
  2056.                             AddLifeForStaticKilling(enemyBot);
  2057.                         }
  2058.                         // Update current position
  2059.                         else {
  2060.                             g_enemyTimerAwayPos[enemyBot] = enemyPos;
  2061.                         }
  2062.                     }
  2063.                 }
  2064.             }
  2065.             g_checkStaticAmtCntrAway = 12;
  2066.         }
  2067.     }
  2068.     else {
  2069.         g_checkStaticAmtAway = g_checkStaticAmtAway - 1;
  2070.         if (g_checkStaticAmtAway <= 0) {
  2071.             for (int enemyBot = 1; enemyBot <= MaxClients; enemyBot++) {
  2072.                 if (IsClientInGame(enemyBot) && IsFakeClient(enemyBot)) {
  2073.                     int m_iTeam = GetClientTeam(enemyBot);
  2074.                     if (enemyBot > 0 && IsPlayerAlive(enemyBot) && m_iTeam == TEAM_2_INS) {
  2075.                         // Get current position
  2076.                         float enemyPos[3];
  2077.                         GetClientAbsOrigin(enemyBot, float enemyPos);
  2078.  
  2079.                         // Get distance
  2080.                         float tDistance;
  2081.                         float capDistance;
  2082.                         tDistance = GetVectorDistance(enemyPos, g_enemyTimerAwayPos[enemyBot]);
  2083.                         //Check point distance
  2084.                         if (g_isCheckpoint == 1) {
  2085.                             int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2086.                             if (0 <= m_nActivePushPointIndex < sizeof(m_vCPPositions))
  2087.                             Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2088.                             capDistance = GetVectorDistance(enemyPos, m_vCPPositions[m_nActivePushPointIndex]);
  2089.                         }
  2090.                         // If enemy position is static, kill him
  2091.                         if (tDistance <= 150 && capDistance > 1200) {
  2092.                             //PrintToServer("ENEMY STATIC - KILLING");
  2093.                             RemoveWeapons(enemyBot, primaryRemove, secondaryRemove, grenadesRemove);
  2094.                             ForcePlayerSuicide(enemyBot);
  2095.                             AddLifeForStaticKilling(enemyBot);
  2096.                         }
  2097.                         // Update current position
  2098.                         else {
  2099.                             g_enemyTimerAwayPos[enemyBot] = enemyPos;
  2100.                         }
  2101.                     }
  2102.                 }
  2103.             }
  2104.             g_checkStaticAmtAway = 30;
  2105.         }
  2106.     }
  2107.  
  2108.     return Plugin_Continue;
  2109. }
  2110.  
  2111. void AddLifeForStaticKilling(int client) {
  2112.     // Respawn type 1
  2113.     int team = GetClientTeam(client);
  2114.     if (g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS && g_iRespawn_lives_team_ins > 0) {
  2115.         g_iSpawnTokens[client]++;
  2116.     }
  2117.     else if (g_iCvar_respawn_type_team_ins == 2 && team == TEAM_2_INS && g_iRespawn_lives_team_ins > 0) {
  2118.         g_iRemaining_lives_team_ins++;
  2119.     }
  2120. }
  2121. */
  2122.  
  2123. stock void SetPrimaryAmmo(int client, int weap, int ammo, int type)
  2124. {
  2125.     //new PropType:proptype = Prop_Data;
  2126.     //new myweapons = FindSendPropInfo("CCSPlayer", "m_hMyWeapons");
  2127.     //new weap = GetEntDataEnt2(client, myweapons+ (slot*4));
  2128.     if(IsValidEntity(weap))
  2129.     {
  2130.         if (type==0)
  2131.         {
  2132.             SetEntData(weap, FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"), ammo, _, true);
  2133.             return;
  2134.         }
  2135.         else if (type==1)
  2136.         {
  2137.             SetEntData(weap, FindSendPropInfo("CBaseCombatWeapon", "m_iClip2"), ammo, _, true);
  2138.             return;
  2139.         }
  2140.     }
  2141. }
  2142.  
  2143. // Update player's gear
  2144. void SetPlayerAmmo(int client)
  2145. {
  2146.     if (IsClientInGame(client) && !IsFakeClient(client))
  2147.     {
  2148.         int primaryWeapon = GetPlayerWeaponSlot(client, 0);
  2149.         int secondaryWeapon = GetPlayerWeaponSlot(client, 1);
  2150.         int playerGrenades = GetPlayerWeaponSlot(client, 3);
  2151.    
  2152.         //Check primary weapon
  2153.         if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
  2154.         {
  2155.             SetPrimaryAmmo(client, primaryWeapon, playerClip[client][0], 0); //primary clip
  2156.             Client_SetWeaponPlayerAmmoEx(client, primaryWeapon, playerAmmo[client][0]); //primary
  2157.         }
  2158.        
  2159.         // Check secondary weapon
  2160.         if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon))
  2161.         {
  2162.             SetPrimaryAmmo(client, secondaryWeapon, playerClip[client][1], 1); //secondary clip
  2163.             Client_SetWeaponPlayerAmmoEx(client, secondaryWeapon, playerAmmo[client][1]); //secondary
  2164.         }
  2165.        
  2166.         // Check grenades
  2167.         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
  2168.         {
  2169.             while (playerGrenades != -1 && IsValidEntity(playerGrenades)) // since we only have 3 slots in current theate
  2170.             {
  2171.                 playerGrenades = GetPlayerWeaponSlot(client, 3);
  2172.                 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
  2173.                 {
  2174.                    
  2175.  
  2176.                     // Remove grenades but not pistols
  2177.                     char weapon[32];
  2178.                     GetEntityClassname(playerGrenades, weapon, sizeof(weapon));
  2179.                     RemovePlayerItem(client,playerGrenades);
  2180.                     AcceptEntityInput(playerGrenades, "kill");
  2181.                    
  2182.                 }
  2183.             }
  2184.         }
  2185.         if (!IsFakeClient(client))
  2186.             playerRevived[client] = false;
  2187.     }
  2188. }
  2189.  
  2190. public Action Event_PlayerReload_Pre(Event event, const char[] name, bool dontBroadcast)
  2191. {
  2192.     int client = GetClientOfUserId(event.GetInt("userid"));
  2193.     if (IsFakeClient(client) && playerInRevivedState[client] == false) return Plugin_Continue;
  2194.     g_playerActiveWeapon[client] = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
  2195.     return Plugin_Continue;
  2196. }
  2197.  
  2198. /*
  2199. #####################################################################
  2200. #####################################################################
  2201. #####################################################################
  2202. # Jballous INS_SPAWNPOINT SPAWNING START ############################
  2203. # Jballous INS_SPAWNPOINT SPAWNING START ############################
  2204. #####################################################################
  2205. #####################################################################
  2206. #####################################################################
  2207. */
  2208.  
  2209. stock float GetInsSpawnGround(int spawnPoint, float vecSpawn[3])
  2210. {
  2211.     float fGround[3];
  2212.     vecSpawn[2] += 15.0;
  2213.     TR_TraceRayFilter(vecSpawn, view_as<float>({90.0, 0.0, 0.0}), MASK_PLAYERSOLID, RayType_Infinite, TRDontHitSelf, spawnPoint);
  2214.     if (TR_DidHit())
  2215.     {
  2216.         TR_GetEndPosition(fGround);
  2217.         return fGround;
  2218.     }
  2219.     return vecSpawn;
  2220. }
  2221.  
  2222. //  float GetClientGround(int client) {
  2223. //      float fOrigin[3];
  2224. //      float fGround[3];
  2225. //      GetClientAbsOrigin(client, fOrigin);
  2226.  
  2227. //      fOrigin[2] += 15.0;
  2228.  
  2229. //      TR_TraceRayFilter(fOrigin, float {90.0, 0.0, 0.0}, MASK_PLAYERSOLID, RayType_Infinite, TRDontHitSelf, client);
  2230. //      if (TR_DidHit()) {
  2231. //          TR_GetEndPosition(fGround);
  2232. //          fOrigin[2] -= 15.0;
  2233. //          return fGround[2];
  2234. //      }
  2235. //      return 0.0;
  2236. //  }
  2237.  
  2238. int CheckSpawnPoint(float vecSpawn[3], int client, float tObjectiveDistance, int m_nActivePushPointIndex) {
  2239. //Ins_InCounterAttack
  2240.     int m_iTeam = GetClientTeam(client);
  2241.     float distance;
  2242.     float furthest;
  2243.     float closest=-1.0;
  2244.     float vecOrigin[3];
  2245.     //float tBadPos[3];
  2246.  
  2247.     GetClientAbsOrigin(client, vecOrigin);
  2248.     float tMinPlayerDistMult = 0.0;
  2249.  
  2250.     int acp = (Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex") - 1);
  2251.     int acp2 = m_nActivePushPointIndex;
  2252.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  2253.     if (acp == acp2 && !Ins_InCounterAttack()) {
  2254.         tMinPlayerDistMult = g_flBackSpawnIncrease;
  2255.         //PrintToServer("INCREASE SPAWN DISTANCE | acp: %d acp2 %d", acp, acp2);
  2256.     }
  2257.  
  2258.     //Update player spawns before we check against them
  2259.     UpdatePlayerOrigins();
  2260.     //Lets go through checks to find a valid spawn point
  2261.     for (int iTarget = 1; iTarget < MaxClients; iTarget++) {
  2262.         if (!IsValidClient(iTarget)) continue;
  2263.        
  2264.         if (!IsClientInGame(iTarget)) continue;
  2265.         if (!IsPlayerAlive(iTarget)) {
  2266.             continue;
  2267.         }
  2268.         int tTeam = GetClientTeam(iTarget);
  2269.         if (tTeam != TEAM_1_SEC) {
  2270.             continue;
  2271.         }
  2272.         ////InsLog(DEBUG, "Distance from %N to iSpot %d is %f", iTarget, iSpot, distance);
  2273.         distance = GetVectorDistance(vecSpawn, g_vecOrigin[iTarget]);
  2274.         if (distance > furthest) {
  2275.             furthest = distance;
  2276.         }
  2277.         if ((distance < closest) || (closest < 0)) {
  2278.             closest = distance;
  2279.         }
  2280.  
  2281.         if (GetClientTeam(iTarget) != m_iTeam) {
  2282.             // If we are too close
  2283.             if (distance < (g_flMinPlayerDistance + tMinPlayerDistMult)) {
  2284.                  return 0;
  2285.             }
  2286.             // If the player can see the spawn point (divided CanSeeVector to slightly reduce strictness)
  2287.             //(IsVectorInSightRange(iTarget, vecSpawn, 120.0)) ||  / g_flCanSeeVectorMultiplier
  2288.             if (ClientCanSeeVector(iTarget, vecSpawn, (g_flMinPlayerDistance * g_flCanSeeVectorMultiplier))) {
  2289.                 return 0;
  2290.             }
  2291.             //If any player is too far
  2292.             if (closest > g_flMaxPlayerDistance) {
  2293.                 return 0;
  2294.             }
  2295.             else if (closest > 2000 && g_cacheObjActive == 1 && Ins_InCounterAttack())
  2296.                 return 0;
  2297.         }
  2298.     }
  2299.  
  2300.     Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2301.     distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2302.     if (distance > (tObjectiveDistance) && (((acp+1) != ncp) || !Ins_InCounterAttack()))
  2303.         return 0;
  2304.     else if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult) &&
  2305.     (((acp+1) != ncp) || !Ins_InCounterAttack()))
  2306.         return 0;
  2307.  
  2308.  
  2309.  
  2310. //  if ((0 >= client || client > MaxClients) || !IsClientInGame(client)) return 0;
  2311.     if ((0 < client <= MaxClients) || !IsClientInGame(client)) {
  2312.         return 0;
  2313.     }
  2314.  
  2315.     int fRandomInt = GetRandomInt(1, 100);
  2316.     //If final point respawn around last point, not final point
  2317.     if ((((acp+1) == ncp) || Ins_InCounterAttack()) && fRandomInt <= 10) {
  2318.         int m_nActivePushPointIndexFinal = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2319.         m_nActivePushPointIndexFinal -= 1;
  2320.         distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndexFinal]);
  2321.         if (distance > (tObjectiveDistance)) {
  2322.              return 0;
  2323.         }
  2324.         else if (distance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult)) {
  2325.              return 0;
  2326.         }
  2327.     }
  2328.         //PrintToServer("CHECKSPAWN | m_nActivePushPointIndex: %d", m_nActivePushPointIndex);
  2329.     return 1;
  2330. }
  2331.  
  2332.  
  2333.  
  2334. int CheckSpawnPointPlayers(float vecSpawn[3], int client, float tObjectiveDistance) {
  2335. //Ins_InCounterAttack
  2336.     int m_iTeam = GetClientTeam(client);
  2337.     float distance;
  2338.     float furthest;
  2339.     float closest=-1.0;
  2340.     float vecOrigin[3];
  2341.     GetClientAbsOrigin(client, vecOrigin);
  2342.     //Update player spawns before we check against them
  2343.     UpdatePlayerOrigins();
  2344.  
  2345.     int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2346.     float objDistance;
  2347.  
  2348.     //Lets go through checks to find a valid spawn point
  2349.     for (int iTarget = 1; iTarget < MaxClients; iTarget++) {
  2350.         if (!IsValidClient(iTarget)) {
  2351.             continue;
  2352.         }
  2353.         if (!IsClientInGame(iTarget)) {
  2354.             continue;
  2355.         }
  2356.         if (!IsPlayerAlive(iTarget)) {
  2357.             continue;
  2358.         }
  2359.         int tTeam = GetClientTeam(iTarget);
  2360.         if (tTeam != TEAM_1_SEC) {
  2361.             continue;
  2362.         }
  2363.  
  2364.         m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2365.  
  2366.         //If in counter
  2367.         if (Ins_InCounterAttack() && m_nActivePushPointIndex > 0) {
  2368.             m_nActivePushPointIndex -= 1;
  2369.         }
  2370.  
  2371.         Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2372.  
  2373.         objDistance = GetVectorDistance(g_vecOrigin[iTarget], m_vCPPositions[m_nActivePushPointIndex]);
  2374.         distance = GetVectorDistance(vecSpawn, g_vecOrigin[iTarget]);
  2375.         if (distance > furthest) {
  2376.             furthest = distance;
  2377.         }
  2378.         if ((distance < closest) || (closest < 0)) {
  2379.             closest = distance;
  2380.         }
  2381.  
  2382.         if (GetClientTeam(iTarget) != m_iTeam) {
  2383.             // If we are too close
  2384.             if (distance < g_flMinPlayerDistance) {
  2385.                  return 0;
  2386.             }
  2387.             int fRandomInt = GetRandomInt(1, 100);
  2388.  
  2389.             // If the player can see the spawn point (divided CanSeeVector to slightly reduce strictness)
  2390.             //(IsVectorInSightRange(iTarget, vecSpawn, 120.0)) ||  / g_flCanSeeVectorMultiplier
  2391.             if (ClientCanSeeVector(iTarget, vecSpawn, (g_flMinPlayerDistance * g_flCanSeeVectorMultiplier))) {
  2392.                 return 0;
  2393.             }
  2394.  
  2395.             //Check if players are getting close to point when assaulting
  2396.             if (objDistance < 2500 && fRandomInt < 30 && !Ins_InCounterAttack()) {
  2397.                 return 0;
  2398.             }
  2399.         }
  2400.     }
  2401.  
  2402.  
  2403.     // Get the number of control points
  2404.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  2405.  
  2406.     // Get active push point
  2407.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2408.  
  2409.     //If any player is too far
  2410.     if (closest > g_flMaxPlayerDistance) {
  2411.         return 0;
  2412.     }
  2413.     else if (closest > 2000 && g_cacheObjActive == 1 && Ins_InCounterAttack()) {
  2414.         return 0;
  2415.     }
  2416.  
  2417.     m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2418.  
  2419.     int fRandomInt = GetRandomInt(1, 100);
  2420.     //Check against back spawn if in counter
  2421.     if (Ins_InCounterAttack() && m_nActivePushPointIndex > 0)
  2422.     {
  2423.         m_nActivePushPointIndex -= 1;
  2424.     }
  2425.  
  2426.     Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2427.     objDistance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2428.     // && (fRandomFloat <= g_dynamicSpawn_Perc))
  2429.     if (objDistance > (tObjectiveDistance) && (((acp+1) != ncp) || !Ins_InCounterAttack()) && fRandomInt < 25)
  2430.     {
  2431.          return 0;
  2432.     }
  2433.     else if (objDistance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult) && (((acp+1) != ncp) || !Ins_InCounterAttack()) && fRandomInt < 25) {
  2434.          return 0;
  2435.     }
  2436.  
  2437.     fRandomInt = GetRandomInt(1, 100);
  2438.  
  2439.     //if ((0 >= client || client > MaxClients) || !IsClientInGame(client)) return 0;
  2440.     if ((0 < client <= MaxClients) || !IsClientInGame(client))
  2441.     {
  2442.         return 0;
  2443.     }
  2444.  
  2445.     //If final point respawn around last point, not final point
  2446.     if ((((acp+1) == ncp) || Ins_InCounterAttack()) && fRandomInt < 25) {
  2447.         int m_nActivePushPointIndexFinal = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2448.         if (m_nActivePushPointIndexFinal < 0) {
  2449.             return 0;
  2450.         }
  2451.         m_nActivePushPointIndexFinal -= 1;
  2452.         objDistance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndexFinal]);
  2453.         // && (fRandomFloat <= g_dynamicSpawn_Perc))
  2454.         if (objDistance > (tObjectiveDistance)) {
  2455.              return 0;
  2456.         }
  2457.         if (objDistance > (tObjectiveDistance * g_DynamicRespawn_Distance_mult)) {
  2458.              return 0;
  2459.         }
  2460.     }
  2461.     return 1;
  2462. }
  2463.  
  2464. int GetPushPointIndex(float fRandomFloat, int client)
  2465. {
  2466.     // Get the number of control points
  2467.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  2468.  
  2469.     // Get active push point
  2470.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2471.  
  2472.     int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2473.     //Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2474.     //float distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2475.     //Check last point
  2476.  
  2477.     if (((acp+1) == ncp && Ins_InCounterAttack()) || g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc ||
  2478.         (Ins_InCounterAttack()) || (m_nActivePushPointIndex > 1)) {
  2479.         //PrintToServer("###POINT_MOD### | fRandomFloat: %f | g_dynamicSpawnCounter_Perc %f ", fRandomFloat, g_dynamicSpawnCounter_Perc);
  2480.         if ((acp+1) == ncp && Ins_InCounterAttack())
  2481.         {
  2482.             if (g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc)
  2483.             {
  2484.                 m_nActivePushPointIndex--;
  2485.             }
  2486.         }
  2487.         else
  2488.         {
  2489.             if (Ins_InCounterAttack() && (acp+1) != ncp)
  2490.             {
  2491.                 if (fRandomFloat <= 0.5 && m_nActivePushPointIndex > 0)
  2492.                 {
  2493.                     m_nActivePushPointIndex--;
  2494.                 }
  2495.                 else
  2496.                 {
  2497.                     m_nActivePushPointIndex++;
  2498.                 }
  2499.             }
  2500.             else if (!Ins_InCounterAttack())
  2501.             {
  2502.                 if (m_nActivePushPointIndex > 0)
  2503.                 {
  2504.                     if (g_spawnFrandom[client] < g_dynamicSpawn_Perc)
  2505.                     {
  2506.                         m_nActivePushPointIndex--;
  2507.                     }
  2508.                 }
  2509.             }
  2510.         }
  2511.  
  2512.     }
  2513.     return m_nActivePushPointIndex;
  2514. }
  2515.  
  2516.  
  2517.  
  2518. float GetSpawnPoint_SpawnPoint(int client) {
  2519. //  int m_iTeam = GetClientTeam(client);
  2520. //  int m_iTeamNum;
  2521.     float vecSpawn[3];
  2522.     float vecOrigin[3];
  2523.     //float distance;
  2524.  
  2525.     GetClientAbsOrigin(client, vecOrigin);
  2526.     float fRandomFloat = GetRandomFloat(0.0, 1.0);
  2527.  
  2528.     //PrintToServer("GetSpawnPoint_SpawnPoint Call");
  2529.     // Get the number of control points
  2530.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  2531.  
  2532.     // Get active push point
  2533.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2534.  
  2535.     int m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2536.     if (((acp+1) == ncp) || (Ins_InCounterAttack() &&
  2537.         g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc) ||
  2538.         (!Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawn_Perc &&
  2539.         acp > 1))
  2540.         m_nActivePushPointIndex = GetPushPointIndex(fRandomFloat, client);
  2541.  
  2542.     int point = FindEntityByClassname(-1, "ins_spawnpoint");
  2543.     float tObjectiveDistance = g_flMinObjectiveDistance;
  2544.  
  2545.     //if ((0 >= client || client > MaxClients) || !IsClientInGame(client))
  2546.     if ((0 < client <= MaxClients) || !IsClientInGame(client))
  2547.  
  2548.     while (point != -1) {
  2549.         //m_iTeamNum = GetEntProp(point, Prop_Send, "m_iTeamNum");
  2550.         //if (m_iTeamNum == m_iTeam) {
  2551.  
  2552.  
  2553.     GetEntPropVector(point, Prop_Send, "m_vecOrigin", vecSpawn);
  2554.     Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2555.     //distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2556.     if (CheckSpawnPoint(vecSpawn, client, tObjectiveDistance, m_nActivePushPointIndex)) {
  2557.         vecSpawn = GetInsSpawnGround(point, vecSpawn);
  2558.         //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2559.         //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);
  2560.         return vecSpawn;
  2561.     }
  2562.     else {
  2563.         tObjectiveDistance += 4.0;
  2564.     }
  2565.     point = FindEntityByClassname(point, "ins_spawnpoint");
  2566.     }
  2567.     //PrintToServer("1st Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client);
  2568.     //Lets try again but wider range
  2569.     int point2 = FindEntityByClassname(-1, "ins_spawnpoint");
  2570.     tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 4);
  2571.     while (point2 != -1) {
  2572.         //m_iTeamNum = GetEntProp(point2, Prop_Send, "m_iTeamNum");
  2573.         //if (m_iTeamNum == m_iTeam) {
  2574.         GetEntPropVector(point2, Prop_Send, "m_vecOrigin", vecSpawn);
  2575.  
  2576.         Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2577.         //distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2578.         if (CheckSpawnPoint(vecSpawn, client, tObjectiveDistance, m_nActivePushPointIndex)) {
  2579.         vecSpawn = GetInsSpawnGround(point2, vecSpawn);
  2580.         //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2581.         //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);
  2582.         return vecSpawn;
  2583.         }
  2584.             else {
  2585.         tObjectiveDistance += 4.0;
  2586.     }
  2587.     //}
  2588.         point2 = FindEntityByClassname(point2, "ins_spawnpoint");
  2589.     }
  2590.     //PrintToServer("2nd Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client);
  2591.     //Lets try again but wider range
  2592.     int point3 = FindEntityByClassname(-1, "ins_spawnpoint");
  2593.     tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 10);
  2594.     while (point3 != -1) {
  2595.         //m_iTeamNum = GetEntProp(point3, Prop_Send, "m_iTeamNum");
  2596.         //if (m_iTeamNum == m_iTeam) {
  2597.         GetEntPropVector(point3, Prop_Send, "m_vecOrigin", vecSpawn);
  2598.         Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2599.         //distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2600.         if (CheckSpawnPoint(vecSpawn, client, tObjectiveDistance, m_nActivePushPointIndex)) {
  2601.             vecSpawn = GetInsSpawnGround(point3, vecSpawn);
  2602.             //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2603.             //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);
  2604.             return vecSpawn;
  2605.         }
  2606.         else {
  2607.             tObjectiveDistance += 4.0;
  2608.         }
  2609.         //}
  2610.         point3 = FindEntityByClassname(point3, "ins_spawnpoint");
  2611.     }
  2612.     //PrintToServer("3rd Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client);
  2613.     int pointFinal = FindEntityByClassname(-1, "ins_spawnpoint");
  2614.     tObjectiveDistance = ((g_flMinObjectiveDistance + 100) * 4);
  2615.     m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2616.     //m_nActivePushPointIndex = GetPushPointIndex(fRandomFloat);
  2617.     if (m_nActivePushPointIndex > 1) {
  2618.         if ((acp+1) >= ncp) {
  2619.             m_nActivePushPointIndex--;
  2620.         }
  2621.         else {
  2622.             m_nActivePushPointIndex++;
  2623.         }
  2624.     }
  2625.  
  2626.     while (pointFinal != -1) {
  2627.         //m_iTeamNum = GetEntProp(pointFinal, Prop_Send, "m_iTeamNum");
  2628.         //if (m_iTeamNum == m_iTeam) {
  2629.         GetEntPropVector(pointFinal, Prop_Send, "m_vecOrigin", vecSpawn);
  2630.         Ins_ObjectiveResource_GetPropVector("m_vCPPositions", m_vCPPositions[m_nActivePushPointIndex], m_nActivePushPointIndex);
  2631.         //distance = GetVectorDistance(vecSpawn, m_vCPPositions[m_nActivePushPointIndex]);
  2632.         if (CheckSpawnPoint(vecSpawn, client, tObjectiveDistance, m_nActivePushPointIndex)) {
  2633.             vecSpawn = GetInsSpawnGround(pointFinal, vecSpawn);
  2634.             //new m_nActivePushPointIndex = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2635.             //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);
  2636.             return vecSpawn;
  2637.             }
  2638.             else {
  2639.                 tObjectiveDistance += 4.0;
  2640.         }
  2641.         pointFinal = FindEntityByClassname(pointFinal, "ins_spawnpoint");
  2642.     }
  2643.     //PrintToServer("Final Pass: Could not find acceptable ins_spawnzone for %N (%d)", client, client);
  2644.     return vecOrigin;
  2645. }
  2646.  
  2647. float GetSpawnPoint(int client)
  2648. {
  2649.  
  2650.     float vecSpawn[3];
  2651. /*
  2652.     if ((g_iHidingSpotCount) && (g_iSpawnMode == _:SpawnMode_HidingSpots)) {
  2653.         vecSpawn = GetSpawnPoint_HidingSpot(client);
  2654.     } else {
  2655. */
  2656.     vecSpawn = GetSpawnPoint_SpawnPoint(client);
  2657. //  }
  2658.     //InsLog(DEBUG, "Could not find spawn point for %N (%d)", client, client);
  2659.     return vecSpawn;
  2660. }
  2661.  
  2662. //Lets begin to find a valid spawnpoint after spawned
  2663. void TeleportClient(int client) {
  2664.     float vecSpawn[3];
  2665.     vecSpawn = GetSpawnPoint(client);
  2666.     if ((0 < client <= MaxClients) && IsClientInGame(client)) {
  2667.         TeleportEntity(client, vecSpawn, NULL_VECTOR, NULL_VECTOR);
  2668.         SetNextAttack(client);
  2669.     }
  2670. }
  2671.  
  2672. public Action Event_Spawn(Event event, const char[] name, bool dontBroadcast) {
  2673.     //Redirect all bot spawns
  2674.     /*int client = GetClientOfUserId(event.GetInt("userid"));
  2675.     if (0 < client <= MaxClients && IsClientInGame (client)) {
  2676.         if (!IsFakeClient(client)) {
  2677.             g_iPlayerRespawnTimerActive[client] = 0;
  2678.             int iRagDoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  2679.  
  2680.             if (!IsValidEntity(iRagDoll)) {
  2681.                 return Plugin_Stop;
  2682.             }
  2683.  
  2684.             AcceptEntityInput(iRagDoll, "kill");
  2685.  
  2686.             return Plugin_Stop;
  2687.         }
  2688.         g_iHurtFatal[client] = 0;
  2689.     }*/
  2690.  
  2691.     int client = GetClientOfUserId(event.GetInt("userid"));
  2692.     // char sNewNickname[64];
  2693.     // Format(sNewNickname, sizeof(sNewNickname), "%N", client);
  2694.     // if (StrEqual(sNewNickname, "[INS] RoundEnd Protector"))
  2695.     //  return Plugin_Continue;
  2696.  
  2697.     if (client > 0 && IsClientInGame(client)) {
  2698.         if (!IsFakeClient(client)) {
  2699.             g_iPlayerRespawnTimerActive[client] = 0;
  2700.  
  2701.             //remove network ragdoll associated with player
  2702.             int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  2703.             if (playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag)) {
  2704.                 RemoveRagdoll(client);
  2705.             }
  2706.  
  2707.             g_iHurtFatal[client] = 0;
  2708.         }
  2709.     }
  2710.  
  2711.     g_resupplyCounter[client] = sm_resupply_delay.IntValue;
  2712.     //For first joining players
  2713.     if (g_playerFirstJoin[client] == 1 && !IsFakeClient(client)) {
  2714.         g_playerFirstJoin[client] = 0;
  2715.         // Get SteamID to verify is player has connected before.
  2716.         char steamId[64];
  2717.         //GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId));
  2718.         GetClientAuthId(client, AuthId_Steam3, steamId, sizeof(steamId));
  2719.         int isPlayerNew = g_playerArrayList.FindString(steamId);
  2720.  
  2721.         if (isPlayerNew == -1) {
  2722.             g_playerArrayList.PushString(steamId);
  2723.             //PrintToServer("SPAWN: Player %N is new! | SteamID: %s | PlayerArrayList Size: %d", client, steamId, g_playerArrayList.Length);
  2724.         }
  2725.     }
  2726.     if (!g_iCvar_respawn_enable) {
  2727.         return Plugin_Continue;
  2728.     }
  2729.     if (!IsClientConnected(client)) {
  2730.         return Plugin_Continue;
  2731.     }
  2732.     if (!IsClientInGame(client)) {
  2733.         return Plugin_Continue;
  2734.     }
  2735.     if (!IsValidClient(client)) {
  2736.         return Plugin_Continue;
  2737.     }
  2738.     if (!IsFakeClient(client)) {
  2739.         return Plugin_Continue;
  2740.     }
  2741.     if (g_isCheckpoint == 0) {
  2742.         return Plugin_Continue;
  2743.     }
  2744.  
  2745.     if ((StrContains(g_client_last_classstring[client], "juggernaut") > -1) && !Ins_InCounterAttack()) {
  2746.              return Plugin_Handled;
  2747.         }
  2748.  
  2749.     //PrintToServer("Eventspawn Call");
  2750.     //Reset this global timer everytime a bot spawns
  2751.     g_botStaticGlobal[client] = 0;
  2752.  
  2753.     // Get the number of control points
  2754.     //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  2755.  
  2756.     // Get active push point
  2757.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  2758.     float vecOrigin[3];
  2759.     GetClientAbsOrigin(client, vecOrigin);
  2760.  
  2761.     //if ((0 >= client || client > MaxClients) || !IsClientInGame(client))
  2762.     if ((0 < client <= MaxClients) || !IsClientInGame(client))
  2763.  
  2764.     if  (g_playersReady && g_botsReady == 1) {
  2765.         float vecSpawn[3];
  2766.         GetClientAbsOrigin(client, vecOrigin);
  2767.         int point = FindEntityByClassname(-1, "ins_spawnpoint");
  2768.         float tObjectiveDistance = g_flMinObjectiveDistance;
  2769.         int iCanSpawn = CheckSpawnPointPlayers(vecOrigin, client, tObjectiveDistance);
  2770.         while (point != -1) {
  2771.                 if (iCanSpawn < 0) {
  2772.                     return Plugin_Continue;
  2773.                 }
  2774.                 GetEntPropVector(point, Prop_Send, "m_vecOrigin", vecSpawn);
  2775.                 iCanSpawn = CheckSpawnPointPlayers(vecOrigin, client, tObjectiveDistance);
  2776.                 if (iCanSpawn == 1) {
  2777.                     break;
  2778.                 }
  2779.                 else {
  2780.                     tObjectiveDistance += 6.0;
  2781.                 }
  2782.             //}
  2783.                 point = FindEntityByClassname(point, "ins_spawnpoint");
  2784.         }
  2785.         //Global random for spawning
  2786.         g_spawnFrandom[client] = GetRandomInt(0, 100);
  2787.         //InsLog(DEBUG, "Event_Spawn iCanSpawn %d", iCanSpawn);
  2788.         if (iCanSpawn == 0 || (Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawnCounter_Perc) ||
  2789.             (!Ins_InCounterAttack() && g_spawnFrandom[client] < g_dynamicSpawn_Perc && acp > 1)) {
  2790.             //PrintToServer("TeleportClient Call");
  2791.             TeleportClient(client);
  2792.             if (client > 0 && IsClientInGame(client) && IsPlayerAlive(client) && IsClientConnected(client)) {
  2793.                 StuckCheck[client] = 0;
  2794.                 StartStuckDetection(client);
  2795.             }
  2796.         }
  2797.     }
  2798.  
  2799.     return Plugin_Continue;
  2800. }
  2801.  
  2802. public Action Event_SpawnPost(Event event, const char[] name, bool dontBroadcast) {
  2803.     int client = GetClientOfUserId(event.GetInt("userid"));
  2804.     ////InsLog(DEBUG, "Event_Spawn called");
  2805.     // char sNewNickname[64];
  2806.     // Format(sNewNickname, sizeof(sNewNickname), "%N", client);
  2807.     // if (StrEqual(sNewNickname, "[INS] RoundEnd Protector"))
  2808.     //  return Plugin_Continue;
  2809.  
  2810.  
  2811.     //Bots only below this
  2812.     if (!IsFakeClient(client)) {
  2813.         return Plugin_Continue;
  2814.     }
  2815.     SetNextAttack(client);
  2816.     //float fRandom = GetRandomFloat(0.0, 1.0);
  2817.     int fRandom = GetRandomInt(1, 100);
  2818.     //Check grenades
  2819.     if (fRandom < g_removeBotGrenadeChance && !Ins_InCounterAttack()) {
  2820.         int botGrenades = GetPlayerWeaponSlot(client, 3);
  2821.         // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
  2822.         if (botGrenades != -1 && IsValidEntity(botGrenades))  {
  2823.             // since we only have 3 slots in current theate
  2824.             while (botGrenades != -1 && IsValidEntity(botGrenades))  {
  2825.                 botGrenades = GetPlayerWeaponSlot(client, 3);
  2826.                 // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 1
  2827.                 if (botGrenades != -1 && IsValidEntity(botGrenades))  {
  2828.                     // Remove grenades but not pistols
  2829.                     char weapon[32];
  2830.                     GetEntityClassname(botGrenades, weapon, sizeof(weapon));
  2831.                     RemovePlayerItem(client, botGrenades);
  2832.                     AcceptEntityInput(botGrenades, "kill");
  2833.                 }
  2834.             }
  2835.         }
  2836.     }
  2837.     if (!g_iCvar_respawn_enable) {
  2838.         return Plugin_Continue;
  2839.     }
  2840.     return Plugin_Continue;
  2841. }
  2842.  
  2843. void UpdatePlayerOrigins()
  2844. {
  2845.     for (int i = 1; i < MaxClients; i++) {
  2846.         if (IsValidClient(i)) {
  2847.             GetClientAbsOrigin(i, g_vecOrigin[i]);
  2848.         }
  2849.     }
  2850. }
  2851.  
  2852. //This delays bot from attacking once spawned
  2853. void SetNextAttack(int client)
  2854. {
  2855.     float flTime = GetGameTime();
  2856.     float flDelay = g_flSpawnAttackDelay;
  2857.  
  2858. // Loop through entries in m_hMyWeapons.
  2859.     for (int offset = 0; offset < 128; offset += 4)
  2860.     {
  2861.         int weapon = GetEntDataEnt2(client, m_hMyWeapons + offset);
  2862.         if (weapon < 0)
  2863.         {
  2864.             continue;
  2865.         }
  2866. //      //InsLog(DEBUG, "SetNextAttack weapon %d", weapon);
  2867.         SetEntDataFloat(weapon, m_flNextPrimaryAttack, flTime + flDelay);
  2868.         SetEntDataFloat(weapon, m_flNextSecondaryAttack, flTime + flDelay);
  2869.     }
  2870. }
  2871.  
  2872.  
  2873.  
  2874. /*
  2875. #####################################################################
  2876. #####################################################################
  2877. #####################################################################
  2878. # Jballous INS_SPAWNPOINT SPAWNING END ##############################
  2879. # Jballous INS_SPAWNPOINT SPAWNING END ##############################
  2880. #####################################################################
  2881. #####################################################################
  2882. #####################################################################
  2883. */
  2884.  
  2885.  
  2886. public Action Command_BotCount(client, args)
  2887. {
  2888.     int mc = MaxClients;
  2889.     for(int i = 1; i < mc; i++ )
  2890.     {
  2891.         //if( IsClientInGame(i) && IsFakeClient(i)){
  2892.         if(IsClientInGame(i))
  2893.         {
  2894.             char target_name[50];
  2895.             GetClientName(i, target_name, sizeof(target_name));
  2896.             if (StrContains(target_name, g_sSecBot, false) >= 0)
  2897.             {
  2898.                 //KickClient(i);
  2899.             }
  2900.         }
  2901.     }
  2902.    
  2903.     return Plugin_Handled;
  2904. }
  2905.  
  2906. public Action Event_PlayerDeathPre(Handle event, const char[] name, bool dontBroadcast)
  2907. {
  2908.     if (g_iRoundEndBlockEnabled == 0) return Plugin_Continue;
  2909.  
  2910.     int teamSecCount = GetSecTeamBotCount();
  2911.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  2912.     if (client > 0 && IsClientInGame(client) && !IsFakeClient(client))
  2913.     {
  2914.         if (g_iIsRoundStarted == 1 && g_iIsRoundStartedPost == 1 && g_iIsGameEnded == 0)
  2915.         {
  2916.             //new iRemainingLife = GetRemainingLife();
  2917.             int iAlivePlayers = GetAlivePlayers();
  2918.             int iAliveAllowed = 5;
  2919.             if (teamSecCount <= 6)
  2920.                 iAliveAllowed = GetRandomInt(1, 2);
  2921.             if (teamSecCount > 6 && teamSecCount <= 10)
  2922.                 iAliveAllowed = GetRandomInt(1, 4);
  2923.             else
  2924.                 iAliveAllowed = GetRandomInt(2, 5);
  2925.  
  2926.             //Create buffer for counter attacks
  2927.             if (Ins_InCounterAttack())
  2928.             {
  2929.                 if (teamSecCount <= 6)
  2930.                     iAliveAllowed += GetRandomInt(1, 2);
  2931.                 if (teamSecCount > 6 && teamSecCount <= 10)
  2932.                     iAliveAllowed += GetRandomInt(1, 4);
  2933.                 else
  2934.                     iAliveAllowed += GetRandomInt(2, 4);
  2935.             }
  2936.  
  2937.             if (iAlivePlayers < iAliveAllowed && g_iRoundBlockCount > 0)
  2938.             {
  2939.                 g_iRoundBlockCount--;
  2940.                 char textToHint[64];
  2941.                 Format(textToHint, sizeof(textToHint), "Security Reinforcements remaining: %d", g_iRoundBlockCount);
  2942.                 PrintHintTextToAll(textToHint);
  2943.                 //ShowPanelAll(textToHint);
  2944.                
  2945.                 g_iReviveCount = g_iRoundEndBlockReviveDelay;
  2946.                 // if (g_iAnnounceActive == 0)
  2947.                 // {
  2948.                 //  g_iAnnounceActive = 1;
  2949.                 //  g_iReviveCount = g_iRoundEndBlockReviveDelay;
  2950.                 //  CreateTimer(1.0, Timer_Announce, _, TIMER_REPEAT);
  2951.                 // }
  2952.                
  2953.                 // if (Ins_InCounterAttack())
  2954.                 // {
  2955.                 //  // Get capture point speed cvar values
  2956.                 //  g_iCPSpeedUp = GetConVarInt(g_hCvarCPSpeedUp);
  2957.                 //  g_iCPSpeedUpMax = GetConVarInt(g_hCvarCPSpeedUpMax);
  2958.                 //  g_iCPSpeedUpRate = GetConVarInt(g_hCvarCPSpeedUpRate);
  2959.                    
  2960.                 //  // Prevent round end
  2961.                 //  SetConVarInt(g_hCvarCPSpeedUp, -1, true, false);
  2962.                 //  SetConVarInt(g_hCvarCPSpeedUpMax, 0, true, false);
  2963.                 //  SetConVarInt(g_hCvarCPSpeedUpRate, 0, true, false);
  2964.                 // }
  2965.                 RevivePlayers();
  2966.             }
  2967.             else if (iAlivePlayers == 1 && g_iRoundBlockCount <= 0)
  2968.             {
  2969.                 char textToHint[64];
  2970.                 Format(textToHint, sizeof(textToHint), "There's no more Security Reinforcements.");
  2971.                 PrintHintTextToAll(textToHint);
  2972.                 //ShowPanelAll(textToHint);
  2973.             }
  2974.         }
  2975.     }
  2976.    
  2977.     return Plugin_Continue;
  2978. }
  2979.  
  2980. public Action Timer_Announce(Handle Timer)
  2981. {
  2982.     if (g_iIsGameEnded == 0 && g_iIsRoundStarted == 1 && g_iIsRoundStartedPost == 1 && g_iSecBotID > 0)
  2983.     {
  2984.         if (g_iReviveCount >= 0)
  2985.         {
  2986.             for (int client = 1; client <= MaxClients; client++)
  2987.             {
  2988.                 if (IsClientConnected(client) && !IsFakeClient(client))
  2989.                 {
  2990.                     Handle hPanel = CreatePanel(null);
  2991.                     char buffer[128];
  2992.                    
  2993.                     SetPanelTitle(hPanel, "Security Reinforce");
  2994.                     DrawPanelItem(hPanel, "", ITEMDRAW_SPACER);
  2995.                    
  2996.                     DrawPanelItem(hPanel, "Waiting to revive players.", ITEMDRAW_DEFAULT);
  2997.                     //DrawPanelText(hPanel, "Waiting for reviving player.");
  2998.                     DrawPanelItem(hPanel, "", ITEMDRAW_SPACER);
  2999.                    
  3000.                     Format(buffer, sizeof(buffer), "Team Reinforcement arrives in: %d", g_iReviveCount);
  3001.                     DrawPanelItem(hPanel, buffer, ITEMDRAW_DEFAULT);
  3002.                     //DrawPanelText(hPanel, buffer);
  3003.                    
  3004.                     Format(buffer, sizeof(buffer), "Team Reinforcements remaining: %d", g_iRoundBlockCount);
  3005.                     DrawPanelItem(hPanel, buffer, ITEMDRAW_DEFAULT);
  3006.                     //DrawPanelText(hPanel, buffer);
  3007.                    
  3008.                     SetPanelCurrentKey(hPanel, 10);
  3009.                     SendPanelToClient(hPanel, client, NullMenuHandler, 1);
  3010.                     CloseHandle(hPanel);
  3011.                 }
  3012.             }
  3013.             g_iReviveCount--;
  3014.         }
  3015.         else
  3016.         {
  3017.             RevivePlayers();
  3018.             //g_iAnnounceActive = 0;
  3019.             return Plugin_Stop;
  3020.         }
  3021.     }
  3022.     else
  3023.     {
  3024.     //  g_iAnnounceActive = 0;
  3025.         return Plugin_Stop;
  3026.     }
  3027.     return Plugin_Continue;
  3028. }
  3029.  
  3030. public NullMenuHandler(Handle menu, MenuAction action, param1, param2) {}
  3031.  
  3032. void RevivePlayers()
  3033. {
  3034.     if (GetRealClientCount() <= 0) return;
  3035.     static iIsReviving = 0;
  3036.    
  3037.     if (iIsReviving == 1)
  3038.         return;
  3039.     else
  3040.         iIsReviving = 1;
  3041.    
  3042.     for (int client = 1; client <= MaxClients; client++)
  3043.     if (client > 0 && IsClientInGame(client) && !IsFakeClient(client) && !IsPlayerAlive(client))
  3044.     {
  3045.         int iTeam = GetClientTeam(client);
  3046.         if (iTeam == TEAM_1_SEC && playerPickSquad[client] == 1)
  3047.         {
  3048.             SDKCall(g_hPlayerRespawn, client);
  3049.             //if (g_fSpawnPoint[0] != 0.0 && g_fSpawnPoint[1] != 0.0 && g_fSpawnPoint[2] != 0.0)
  3050.             //  TeleportEntity(client, g_fSpawnPoint, NULL_VECTOR, NULL_VECTOR);
  3051.  
  3052.             // Get dead body
  3053.             int clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  3054.             int primaryRemove = 0;
  3055.             int secondaryRemove = 0;
  3056.             int grenadesRemove = 0;
  3057.             RemoveWeapons(client, primaryRemove, secondaryRemove, grenadesRemove);
  3058.  
  3059.             //This timer safely removes client-side ragdoll
  3060.             if(clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll))
  3061.             {
  3062.                 // Get dead body's entity
  3063.                 int ref = EntIndexToEntRef(clientRagdoll);
  3064.                 int entity = EntRefToEntIndex(ref);
  3065.                 if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
  3066.                 {
  3067.                     // Remove dead body's entity
  3068.                     AcceptEntityInput(entity, "Kill");
  3069.                     clientRagdoll = INVALID_ENT_REFERENCE;
  3070.                 }
  3071.             }
  3072.         }
  3073.     }
  3074.     iIsReviving = 0;
  3075. }
  3076.  
  3077. // When round starts, intialize variables
  3078. public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
  3079. {
  3080.     // Respawn delay for team ins
  3081.     g_fCvar_respawn_delay_team_ins = sm_respawn_delay_team_ins.FloatValue;
  3082.     g_fCvar_respawn_delay_team_ins_spec = sm_respawn_delay_team_ins_special.FloatValue;
  3083.     g_AIDir_TeamStatus = 50;
  3084.     g_AIDir_BotReinforceTriggered = false;
  3085.     g_iReinforceTime = sm_respawn_reinforce_time.IntValue;
  3086.     //g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
  3087.     //g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
  3088.     g_secWave_Timer = g_iRespawnSeconds;
  3089.     //Round_Start CVAR Sets ------------------ END -- vs using HookConVarChange
  3090.  
  3091.     //Elite Bots Reset
  3092.     if (g_elite_counter_attacks == 1)
  3093.     {
  3094.         g_isEliteCounter = 0;
  3095.         EnableDisableEliteBotCvars(0, 0);
  3096.     }
  3097.  
  3098.     // Reset respawn position
  3099.     g_fRespawnPosition[0] = 0.0;
  3100.     g_fRespawnPosition[1] = 0.0;
  3101.     g_fRespawnPosition[2] = 0.0;
  3102.  
  3103.    
  3104.     // Reset remaining life
  3105.     // ConVar hCvar = null;
  3106.     // ConVar hCvar = FindConVar("sm_remaininglife");
  3107.     // hCvar.SetInt(-1);
  3108.  
  3109.     // Reset respawn token
  3110.     ResetInsurgencyLives();
  3111.     ResetSecurityLives();
  3112.  
  3113.     // Check gamemode
  3114.     char sGameMode[32];
  3115.     FindConVar("mp_gamemode").GetString(sGameMode, sizeof(sGameMode));
  3116.     //PrintToServer("[REVIVE_DEBUG] ROUND STARTED");
  3117.    
  3118.     // Warming up revive
  3119.     g_iEnableRevive = 0;
  3120.     int iPreRoundFirst = FindConVar("mp_timer_preround_first").IntValue;
  3121.     int iPreRound = FindConVar("mp_timer_preround").IntValue;
  3122.     if (g_preRoundInitial == true)
  3123.     {
  3124.         CreateTimer(float(iPreRoundFirst), PreReviveTimer);
  3125.         iPreRoundFirst = iPreRoundFirst + 5;
  3126.         CreateTimer(float(iPreRoundFirst), BotsReady_Timer);
  3127.         g_preRoundInitial = false;
  3128.     }
  3129.     else
  3130.     {
  3131.         CreateTimer(float(iPreRound), PreReviveTimer);
  3132.         iPreRoundFirst = iPreRound + 5;
  3133.         CreateTimer(float(iPreRound), BotsReady_Timer);
  3134.     }
  3135.  
  3136.     g_iIsRoundStarted = 1;
  3137.     g_iIsRoundStartedPost = 0;
  3138.     g_iRoundStatus = 0;
  3139.    
  3140.     if (g_iRoundEndBlockResetRound == 1)
  3141.         g_iRoundBlockCount = g_iRoundEndBlockTimes;
  3142.  
  3143.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  3144.     if (ncp < 6)
  3145.     {
  3146.         g_iRoundBlockCount -= 1;
  3147.         if (g_iRoundBlockCount < 1)
  3148.             g_iRoundBlockCount = 1;
  3149.     }
  3150.  
  3151.     CreateTimer(float(iPreRound),Timer_RoundStartPost);
  3152.     return Plugin_Continue;
  3153. }
  3154.  
  3155. void SecTeamLivesBonus()
  3156. {
  3157.     int secTeamCount = GetTeamSecCount();
  3158.     if (secTeamCount <= 9)
  3159.     {
  3160.         g_iRespawnCount[2] += 1;
  3161.     }
  3162. }
  3163.  
  3164. //Adjust Lives Per Point Based On Players
  3165. void SecDynLivesPerPoint()
  3166. {
  3167.     int secTeamCount = GetTeamSecCount();
  3168.     if (secTeamCount <= 9)
  3169.     {
  3170.         g_iRespawnCount[2] += 1;
  3171.     }
  3172. }
  3173.  
  3174. // Round starts
  3175. Action PreReviveTimer(Handle timer)
  3176. {
  3177.     g_iRoundStatus = 1;
  3178.     g_iEnableRevive = 1;
  3179.  
  3180.     // Update remaining life cvar
  3181.     //Handle hCvar = null;
  3182.     //int iRemainingLife = GetRemainingLife();
  3183.     //hCvar = FindConVar("sm_remaininglife");
  3184.     //SetConVarInt(hCvar, iRemainingLife);
  3185. }
  3186.  
  3187. // Botspawn trigger
  3188. Action BotsReady_Timer(Handle timer)
  3189. {
  3190.     g_botsReady = 1;
  3191. }
  3192.  
  3193. public Action Timer_RoundStartPost(Handle Timer)
  3194. {
  3195.     g_iRoundStatus = 1;
  3196.     g_iIsRoundStartedPost = 1;
  3197. }
  3198.  
  3199. // When round ends, intialize variables
  3200. public Action Event_RoundEnd_Pre(Event event, const char[] name, bool dontBroadcast)
  3201. {
  3202.     for (int client = 1; client <= MaxClients; client++)
  3203.     {
  3204.         if (!IsValidClient(client) || !IsClientInGame(client) || IsFakeClient(client)) continue;
  3205.         int tTeam = GetClientTeam(client);
  3206.         if (tTeam != TEAM_1_SEC) continue;
  3207.         if ((g_iStatRevives[client] > 0 || g_iStatHeals[client] > 0) && StrContains(g_client_last_classstring[client], "medic") > -1)
  3208.         {
  3209.             char sBuf[255];
  3210.             // Hint to iMedic
  3211.             Format(sBuf, 255,"[MEDIC STATS] for %N: HEALS: %d | REVIVES: %d", client, g_iStatHeals[client], g_iStatRevives[client]);
  3212.             PrintHintText(client, "%s", sBuf);
  3213.             //PrintToChatAll("%s", sBuf);
  3214.         }
  3215.  
  3216.         playerInRevivedState[client] = false;
  3217.     }
  3218.  
  3219.     g_fSpawnPoint[0] = 0.0;
  3220.     g_fSpawnPoint[1] = 0.0;
  3221.     g_fSpawnPoint[2] = 0.0;
  3222.     g_iIsRoundStarted = 0;
  3223.     g_iIsRoundStartedPost = 0;
  3224.     g_iRoundStatus = 0;
  3225.  
  3226.     //Reset Variables
  3227.     g_removeBotGrenadeChance = 50;
  3228. }
  3229.  
  3230. public Action Event_RoundEnd_Post(Handle event, const char[] name, bool dontBroadcast)
  3231. {
  3232.     // Kick blocker client
  3233.     //KickBlockerClient();
  3234.     //KickBlocker(); //Just resets cvars now
  3235.     // Reset respawn position
  3236.     g_fSpawnPoint[0] = 0.0;
  3237.     g_fSpawnPoint[1] = 0.0;
  3238.     g_fSpawnPoint[2] = 0.0;
  3239.    
  3240.     g_iIsRoundStarted = 0;
  3241.     g_iIsRoundStartedPost = 0;
  3242.     g_iRoundStatus = 0;
  3243.  
  3244.     if (g_iRoundEndBlockResetRound == 1)
  3245.         g_iRoundBlockCount = g_iRoundEndBlockTimes;
  3246. }
  3247.  
  3248. // When round ends, intialize variables
  3249. public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
  3250. {
  3251.    
  3252.     //Lua Healing kill sound
  3253.     char ent = -1;
  3254.     while ((ent = FindEntityByClassname(ent, "healthkit")) > MaxClients && IsValidEntity(ent))
  3255.     {
  3256.         //StopSound(ent, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
  3257.         //PrintToServer("KILL HEALTHKITS");
  3258.         AcceptEntityInput(ent, "Kill");
  3259.     }
  3260.  
  3261.     //Elite Bots Reset
  3262.     if (g_elite_counter_attacks == 1)
  3263.     {
  3264.         g_isEliteCounter = 0;
  3265.         EnableDisableEliteBotCvars(0, 0);
  3266.     }
  3267.  
  3268.     // Reset respawn position
  3269.     g_fRespawnPosition[0] = 0.0;
  3270.     g_fRespawnPosition[1] = 0.0;
  3271.     g_fRespawnPosition[2] = 0.0;
  3272.  
  3273.     // Reset remaining life
  3274.     //Handle hCvar = FindConVar("sm_remaininglife");
  3275.     //SetConVarInt(hCvar, -1);
  3276.  
  3277.     //PrintToServer("[REVIVE_DEBUG] ROUND ENDED"); 
  3278.     // Cooldown revive
  3279.     g_iEnableRevive = 0;
  3280.     g_iRoundStatus = 0;
  3281.     g_botsReady = 0;
  3282.  
  3283.     // Reset respawn token
  3284.     ResetInsurgencyLives();
  3285.     ResetSecurityLives();
  3286. }
  3287.  
  3288. public Action Event_GameStart(Handle event, const char[] name, bool dontBroadcast)
  3289. {
  3290.     g_iIsGameEnded = 0;
  3291. }
  3292.  
  3293. public Action Event_GameEnd(Handle event, const char[] name, bool dontBroadcast)
  3294. {
  3295.     (g_iRoundStatus = 0) && (g_botsReady = 0) && (g_iEnableRevive = 0) && (g_iIsGameEnded = 1);
  3296. }
  3297.  
  3298. // Check occuring counter attack when control point captured
  3299. public Action Event_ControlPointCaptured_Pre(Event event, const char[] name, bool dontBroadcast)
  3300. {
  3301.     //roundendblock
  3302.     // Call counter-attack end timer
  3303.     int iTeam = GetEventInt(event, "team");
  3304.     if ((Ins_InCounterAttack()) && iTeam == 3)
  3305.     {
  3306.         if (!g_bIsCounterAttackTimerActive)
  3307.         {
  3308.             g_bIsCounterAttackTimerActive = true;
  3309.             CreateTimer(1.0, Timer_CounterAttackEnd, _, TIMER_REPEAT);
  3310.             //PrintToServer("[RESPAWN] Counter-attack timer started. (Normal counter-attack)");
  3311.         }
  3312.         return Plugin_Stop;
  3313.     }
  3314.    
  3315.  
  3316.     //Clear bad spawn array
  3317.     //ClearArray(g_badSpawnPos_Array);
  3318.     for (int client = 0; client < MaxClients; client++)
  3319.     {
  3320.         if (!IsValidClient(client) || client <= 0)
  3321.                 continue;
  3322.         if (!IsClientInGame(client))
  3323.             continue;
  3324.         int m_iTeam = GetClientTeam(client);
  3325.         if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
  3326.         {
  3327.             g_badSpawnPos_Track[client][0] = 0.0;
  3328.             g_badSpawnPos_Track[client][1] = 0.0;
  3329.             g_badSpawnPos_Track[client][2] = 0.0;
  3330.         }
  3331.     }
  3332.  
  3333.     //g_checkStaticAmt = GetConVarInt(sm_respawn_check_static_enemy);
  3334.     //g_checkStaticAmtCntr = GetConVarInt(sm_respawn_check_static_enemy_counter);
  3335.  
  3336.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints"); // Get the number of control points
  3337.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex"); // Get active push point
  3338.  
  3339.     //AI Director Status ###START###
  3340.     int secTeamCount = GetTeamSecCount();
  3341.     int secTeamAliveCount = Team_CountAlivePlayers(TEAM_1_SEC);
  3342.     if (g_iRespawn_lives_team_ins > 0)
  3343.         g_AIDir_TeamStatus += 10;
  3344.     if (secTeamAliveCount >= (secTeamCount * 0.8)) // If Alive Security >= 80%
  3345.         g_AIDir_TeamStatus += 10;
  3346.     else if (secTeamAliveCount >= (secTeamCount * 0.5)) // If Alive Security >= 50%
  3347.         g_AIDir_TeamStatus += 5;
  3348.     else if (secTeamAliveCount <= (secTeamCount * 0.2)) // If Dead Security <= 20%
  3349.         g_AIDir_TeamStatus -= 10;
  3350.     else if (secTeamAliveCount <= (secTeamCount * 0.5)) // If Dead Security <= 50%
  3351.         g_AIDir_TeamStatus -= 5;
  3352.  
  3353.     if (g_AIDir_BotReinforceTriggered)
  3354.         g_AIDir_TeamStatus -= 5;
  3355.     else
  3356.         g_AIDir_TeamStatus += 10;
  3357.  
  3358.     g_AIDir_BotReinforceTriggered = false;
  3359.     //AI Director Status ###END###
  3360.  
  3361.     // Get gamemode
  3362.     char sGameMode[32];
  3363.     FindConVar("mp_gamemode").GetString(sGameMode, sizeof(sGameMode));
  3364.  
  3365.     // Init variables
  3366.     ConVar cvar;
  3367.  
  3368.     // Set minimum and maximum counter attack duration time
  3369.     g_counterAttack_min_dur_sec = sm_respawn_min_counter_dur_sec.IntValue;
  3370.     g_counterAttack_max_dur_sec = sm_respawn_max_counter_dur_sec.IntValue;
  3371.     int final_ca_dur = sm_respawn_final_counter_dur_sec.IntValue;
  3372.  
  3373.     // Get random duration
  3374.     int fRandomInt = GetRandomInt(g_counterAttack_min_dur_sec, g_counterAttack_max_dur_sec);
  3375.     int fRandomIntCounterLarge = GetRandomInt(1, 100);
  3376.     int largeCounterEnabled = false;
  3377.     if (fRandomIntCounterLarge <= 15)
  3378.     {
  3379.         fRandomInt = (fRandomInt * 2);
  3380.         int fRandomInt2 = GetRandomInt(60, 90);
  3381.         final_ca_dur = (final_ca_dur + fRandomInt2);
  3382.         largeCounterEnabled = true;
  3383.     }
  3384.  
  3385.     // Set counter attack duration to server
  3386.     ConVar cvar_ca_dur;
  3387.  
  3388.     // Final counter attack
  3389.     if ((acp+1) == ncp)
  3390.     {
  3391.         g_iRemaining_lives_team_ins = 0;
  3392.         for (int i = 1; i <= MaxClients; i++)
  3393.         {
  3394.             if (i > 0 && IsClientInGame(i))
  3395.             {
  3396.                 if(IsFakeClient(i))        
  3397.                     ForcePlayerSuicide(i);
  3398.             }
  3399.         }
  3400.  
  3401.         //g_AIDir_TeamStatus -= 10;
  3402.  
  3403.         cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration_finale");
  3404.         cvar_ca_dur.SetInt(final_ca_dur, true, false);
  3405.         g_dynamicSpawnCounter_Perc += 10;
  3406.  
  3407.         if (g_finale_counter_spec_enabled == 1)
  3408.                 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
  3409.  
  3410.         //If endless spawning on final counter attack, add lives on finale counter on a delay
  3411.         if (g_iCvar_final_counterattack_type == 2)
  3412.         {
  3413.             float tCvar_CounterDelayValue = FindConVar("mp_checkpoint_counterattack_delay_finale").FloatValue;
  3414.             CreateTimer((tCvar_CounterDelayValue),Timer_FinaleCounterAssignLives);
  3415.         }
  3416.     }
  3417.  
  3418.     // Normal counter attack
  3419.     else
  3420.     {
  3421.         g_AIDir_TeamStatus -= 5;
  3422.         cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration");
  3423.         cvar_ca_dur.SetInt(fRandomInt, true, false);
  3424.     }
  3425.  
  3426.     // Get random value for occuring counter attack
  3427.     float fRandom = GetRandomFloat(0.0, 1.0);
  3428.     //PrintToServer("Counter Chance = %f", g_respawn_counter_chance);
  3429.     // Occurs counter attack
  3430.     if (fRandom < g_respawn_counter_chance && ((acp+1) != ncp))
  3431.     {
  3432.         cvar = null;
  3433.         //PrintToServer("COUNTER YES");
  3434.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3435.         cvar.SetInt(0, true, false);
  3436.         cvar = FindConVar("mp_checkpoint_counterattack_always");
  3437.         cvar.SetInt(1, true, false);
  3438.         if (largeCounterEnabled)
  3439.         {
  3440.             PrintHintTextToAll("[INTEL]: Enemy forces are sending a large counter-attack your way!  Get ready to defend!");
  3441.             //PrintToChatAll("[INTEL]: Enemy forces are sending a large counter-attack your way!  Get ready to defend!");
  3442.         }
  3443.  
  3444.         g_AIDir_TeamStatus -= 5;
  3445.         // Call music timer
  3446.         //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
  3447.  
  3448.         //Create Counter End Timer
  3449.         g_isEliteCounter = 1;
  3450.         CreateTimer(cvar_ca_dur.FloatValue + 1.0, Timer_CounterAttackEnd);
  3451.         if (g_elite_counter_attacks == 1)
  3452.         {
  3453.             EnableDisableEliteBotCvars(1, 0);
  3454.             ConVar tCvar = FindConVar("ins_bot_count_checkpoint_max");
  3455.             int tCvarIntValue = FindConVar("ins_bot_count_checkpoint_max").IntValue;
  3456.             tCvarIntValue += 3;
  3457.             tCvar.SetInt(tCvarIntValue, true, false);
  3458.         }
  3459.     }
  3460.     // If last capture point
  3461.     else if (g_isCheckpoint == 1 && ((acp+1) == ncp))
  3462.     {
  3463.         cvar = null;
  3464.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3465.         cvar.SetInt(0, true, false);
  3466.         cvar = FindConVar("mp_checkpoint_counterattack_always");
  3467.         cvar.SetInt(1, true, false);
  3468.  
  3469.         // Call music timer
  3470.         //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
  3471.  
  3472.         //Create Counter End Timer
  3473.         g_isEliteCounter = 1;
  3474.         CreateTimer((cvar_ca_dur.FloatValue + 1.0), Timer_CounterAttackEnd);
  3475.  
  3476.         if (g_elite_counter_attacks == 1)
  3477.         {
  3478.             EnableDisableEliteBotCvars(1, 1);
  3479.             ConVar tCvar = FindConVar("ins_bot_count_checkpoint_max");
  3480.             int tCvarIntValue = FindConVar("ins_bot_count_checkpoint_max").IntValue;
  3481.             tCvarIntValue += 3;
  3482.             tCvar.SetInt(tCvarIntValue, true, false);
  3483.         }
  3484.     }
  3485.     // Not occurs counter attack
  3486.     else
  3487.     {
  3488.         cvar = null;
  3489.         //PrintToServer("COUNTER NO");
  3490.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3491.         cvar.SetInt(1, true, false);
  3492.     }
  3493.     g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  3494.    
  3495.     return Plugin_Continue;
  3496. }
  3497.  
  3498. // When control point captured, reset variables
  3499. public Action Event_ControlPointCaptured(Event event, const char[] name, bool dontBroadcast)
  3500. {
  3501.     // Reset reinforcement time
  3502.     g_iReinforceTime = g_iReinforceTime_AD_Temp;
  3503.    
  3504.     // Reset respawn tokens
  3505.     ResetInsurgencyLives();
  3506.     if (g_iCvar_respawn_reset_type && g_isCheckpoint)
  3507.         ResetSecurityLives();
  3508.  
  3509.     //PrintToServer("CONTROL POINT CAPTURED");
  3510.    
  3511.     return Plugin_Continue;
  3512. }
  3513.  
  3514. // When control point captured, update respawn point and respawn all players
  3515. public Action Event_ControlPointCaptured_Post(Event event, const char[] name, bool dontBroadcast)
  3516. {
  3517.     if (sm_respawn_security_on_counter.IntValue == 1)
  3518.     {
  3519.         // Get client who captured control point.
  3520.         char cappers[512];
  3521.         event.GetString("cappers", cappers, sizeof(cappers));
  3522.         int cappersLength = strlen(cappers);
  3523.         for (int i = 0 ; i < cappersLength; i++) {
  3524.             int clientCapper = cappers[i];
  3525.             if (clientCapper > 0 && IsClientInGame(clientCapper) && IsClientConnected(clientCapper) && IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper)) {
  3526.                 // Get player's position
  3527.                 float capperPos[3];
  3528.                 GetClientAbsOrigin(clientCapper, capperPos);
  3529.  
  3530.                 // Update respawn position
  3531.                 g_fRespawnPosition = capperPos;
  3532.  
  3533.                 break;
  3534.             }
  3535.         }
  3536.  
  3537.         // Respawn all players
  3538.         for (int client = 1; client <= MaxClients; client++)
  3539.         {
  3540.             if (IsClientInGame(client))
  3541.             {
  3542.                 int team = GetClientTeam(client);
  3543.                 float clientPos[3];
  3544.                 GetClientAbsOrigin(client, clientPos);
  3545.                 if (playerPickSquad[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
  3546.                 {
  3547.                     if (!IsFakeClient(client))
  3548.                     {
  3549.                         if (!IsClientTimingOut(client))
  3550.                             CreateCounterRespawnTimer(client);
  3551.                     }
  3552.                     else
  3553.                     {
  3554.                         CreateCounterRespawnTimer(client);
  3555.                     }
  3556.                 }
  3557.             }
  3558.         }
  3559.     }
  3560.         // //Elite Bots Reset
  3561.         // if (g_elite_counter_attacks == 1)
  3562.         //  CreateTimer(5.0, Timer_EliteBots);
  3563.  
  3564.         // Update cvars
  3565.     UpdateRespawnCvars();
  3566.  
  3567.     //Reset security team wave counter
  3568.     g_secWave_Timer = g_iRespawnSeconds;
  3569.     // Get the number of control points
  3570.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  3571.    
  3572.     // Get active push point
  3573.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  3574.     // If last capture point
  3575.     if (((acp+1) == ncp))
  3576.     {
  3577.         g_secWave_Timer = g_iRespawnSeconds;
  3578.         g_secWave_Timer += (GetTeamSecCount() * 4);
  3579.     }
  3580.     else if (Ins_InCounterAttack())
  3581.             g_secWave_Timer += (GetTeamSecCount() * 3);
  3582.     return Plugin_Continue;
  3583. }
  3584.  
  3585. // When ammo cache destroyed, update respawn position and reset variables
  3586. public Action Event_ObjectDestroyed_Pre(Event event, const char[] name, bool dontBroadcast)
  3587. {
  3588.     //Clear bad spawn array
  3589.     //ClearArray(g_badSpawnPos_Array);
  3590.     for (int client = 0; client < MaxClients; client++)
  3591.     {
  3592.         if (!IsValidClient(client) || client <= 0 || !IsClientInGame(client)) continue;
  3593.         int m_iTeam = GetClientTeam(client);
  3594.         if (IsFakeClient(client) && m_iTeam == TEAM_2_INS)
  3595.         {
  3596.             g_badSpawnPos_Track[client][0] = 0.0;
  3597.             g_badSpawnPos_Track[client][1] = 0.0;
  3598.             g_badSpawnPos_Track[client][2] = 0.0;
  3599.         }
  3600.     }
  3601.  
  3602.     //g_checkStaticAmt = sm_respawn_check_static_enemy.IntValue;
  3603.     //g_checkStaticAmtCntr = sm_respawn_check_static_enemy_counter.IntValue;
  3604.  
  3605.    
  3606.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints"); // Get the number of control points
  3607.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex"); // Get active push point
  3608.  
  3609.     //AI Director Status ###START###
  3610.     int secTeamCount = GetTeamSecCount();
  3611.     int secTeamAliveCount = Team_CountAlivePlayers(TEAM_1_SEC);
  3612.  
  3613.     if (g_iRespawn_lives_team_ins > 0)
  3614.         g_AIDir_TeamStatus += 10;
  3615.     if (secTeamAliveCount >= (secTeamCount * 0.8)) // If Alive Security >= 80%
  3616.         g_AIDir_TeamStatus += 10;
  3617.     else if (secTeamAliveCount >= (secTeamCount * 0.5)) // If Alive Security >= 50%
  3618.         g_AIDir_TeamStatus += 5;
  3619.     else if (secTeamAliveCount <= (secTeamCount * 0.2)) // If Dead Security <= 20%
  3620.         g_AIDir_TeamStatus -= 10;
  3621.     else if (secTeamAliveCount <= (secTeamCount * 0.5)) // If Dead Security <= 50%
  3622.         g_AIDir_TeamStatus -= 5;
  3623.  
  3624.     if (g_AIDir_BotReinforceTriggered)
  3625.         g_AIDir_TeamStatus += 10;
  3626.     else
  3627.         g_AIDir_TeamStatus -= 5;
  3628.  
  3629.     g_AIDir_BotReinforceTriggered = false;
  3630.  
  3631.     //AI Director Status ###END###
  3632.  
  3633.     // Get gamemode
  3634.     char sGameMode[32];
  3635.     GetConVarString(FindConVar("mp_gamemode"), sGameMode, sizeof(sGameMode));
  3636.    
  3637.     // Init variables
  3638.     ConVar cvar;
  3639.    
  3640.     // Set minimum and maximum counter attack duration time
  3641.     g_counterAttack_min_dur_sec = sm_respawn_min_counter_dur_sec.IntValue;
  3642.     g_counterAttack_max_dur_sec = sm_respawn_max_counter_dur_sec.IntValue;
  3643.     int final_ca_dur = sm_respawn_final_counter_dur_sec.IntValue;
  3644.  
  3645.     // Get random duration
  3646.     int fRandomInt = GetRandomInt(g_counterAttack_min_dur_sec, g_counterAttack_max_dur_sec);
  3647.     int fRandomIntCounterLarge = GetRandomInt(1, 100);
  3648.     int largeCounterEnabled = false;
  3649.     if (fRandomIntCounterLarge <= 15)
  3650.     {
  3651.         fRandomInt = (fRandomInt * 2);
  3652.         int fRandomInt2 = GetRandomInt(90, 180);
  3653.         final_ca_dur = (final_ca_dur + fRandomInt2);
  3654.         largeCounterEnabled = true;
  3655.     }
  3656.     // Set counter attack duration to server
  3657.     ConVar cvar_ca_dur;
  3658.  
  3659.     // Final counter attack
  3660.     if ((acp+1) == ncp)
  3661.     {
  3662.         cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration_finale");
  3663.         cvar_ca_dur.SetInt(final_ca_dur, true, false);
  3664.         g_dynamicSpawnCounter_Perc += 10;
  3665.         //g_AIDir_TeamStatus -= 10;
  3666.         if (g_finale_counter_spec_enabled == 1)
  3667.         {
  3668.                 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
  3669.         }
  3670.     }
  3671.     // Normal counter attack
  3672.     else
  3673.     {
  3674.         g_AIDir_TeamStatus -= 5;
  3675.         cvar_ca_dur = FindConVar("mp_checkpoint_counterattack_duration");
  3676.         cvar_ca_dur.SetInt(fRandomInt, true, false);
  3677.     }
  3678.  
  3679.     //Are we using vanilla counter attack?
  3680.     if (g_iCvar_counterattack_vanilla == 1) return Plugin_Continue;
  3681.  
  3682.     // Get random value for occuring counter attack
  3683.     float fRandom = GetRandomFloat(0.0, 1.0);
  3684.     //PrintToServer("Counter Chance = %f", g_respawn_counter_chance);
  3685.  
  3686.     // Occurs counter attack
  3687.     if (fRandom < g_respawn_counter_chance && ((acp+1) != ncp))
  3688.     {
  3689.         cvar = null;
  3690.         //PrintToServer("COUNTER YES");
  3691.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3692.         cvar.SetInt(0, true, false);
  3693.         cvar = FindConVar("mp_checkpoint_counterattack_always");
  3694.         cvar.SetInt(1, true, false);
  3695.         if (largeCounterEnabled)
  3696.         {
  3697.             PrintHintTextToAll("[INTEL]: Enemy forces are sending a large counter-attack your way!  Get ready to defend!");
  3698.             //PrintToChatAll("[INTEL]: Enemy forces are sending a large counter-attack your way!  Get ready to defend!");
  3699.         }
  3700.         g_AIDir_TeamStatus -= 5;
  3701.         // Call music timer
  3702.         //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
  3703.  
  3704.         //Create Counter End Timer
  3705.         g_isEliteCounter = 1;
  3706.         CreateTimer(cvar_ca_dur.FloatValue + 1.0, Timer_CounterAttackEnd);
  3707.         if (g_elite_counter_attacks == 1)
  3708.         {
  3709.             EnableDisableEliteBotCvars(1, 0);
  3710.             ConVar tCvar = FindConVar("ins_bot_count_checkpoint_max");
  3711.             int tCvarIntValue = FindConVar("ins_bot_count_checkpoint_max").IntValue;
  3712.             tCvarIntValue += 3;
  3713.             tCvar.SetInt(tCvarIntValue, true, false);
  3714.         }
  3715.     }
  3716.     // If last capture point
  3717.     else if (((acp+1) == ncp))
  3718.     {
  3719.         cvar = null;
  3720.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3721.         cvar.SetInt(0, true, false);
  3722.         cvar = FindConVar("mp_checkpoint_counterattack_always");
  3723.         cvar.SetInt(1, true, false);
  3724.  
  3725.         // Call music timer
  3726.         //CreateTimer(COUNTER_ATTACK_MUSIC_DURATION, Timer_CounterAttackSound);
  3727.  
  3728.         //Create Counter End Timer
  3729.         g_isEliteCounter = 1;
  3730.         CreateTimer(cvar_ca_dur.FloatValue + 1.0, Timer_CounterAttackEnd);
  3731.  
  3732.         if (g_elite_counter_attacks == 1) {
  3733.             EnableDisableEliteBotCvars(1, 1);
  3734.             ConVar tCvar = FindConVar("ins_bot_count_checkpoint_max");
  3735.             int tCvarIntValue = FindConVar("ins_bot_count_checkpoint_max").IntValue;
  3736.             tCvarIntValue += 3;
  3737.             tCvar.SetInt(tCvarIntValue, true, false);
  3738.         }
  3739.     }
  3740.     // Not occurs counter attack
  3741.     else
  3742.     {
  3743.         cvar = null;
  3744.         //PrintToServer("COUNTER NO");
  3745.         cvar = FindConVar("mp_checkpoint_counterattack_disable");
  3746.         cvar.SetInt(1, true, false);
  3747.     }
  3748.     g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  3749.     return Plugin_Continue;
  3750. }
  3751.  
  3752. // When ammo cache destroyed, update respawn position and reset variables
  3753. public Action Event_ObjectDestroyed(Event event, const char[] name, bool dontBroadcast)
  3754. {
  3755.     // Reset reinforcement time
  3756.     g_iReinforceTime = g_iReinforceTime_AD_Temp;
  3757.  
  3758.     // Reset respawn token
  3759.     ResetInsurgencyLives();
  3760.     if (g_iCvar_respawn_reset_type)
  3761.         ResetSecurityLives();
  3762.     return Plugin_Continue;
  3763. }
  3764.  
  3765. // When control point captured, update respawn point and respawn all players
  3766. public Action Event_ObjectDestroyed_Post(Event event, const char[] name, bool dontBroadcast)
  3767. {
  3768.  
  3769.     if (sm_respawn_security_on_counter.IntValue == 1)
  3770.     {
  3771.         // Get client who captured control point.
  3772.         char cappers[512];
  3773.         event.GetString("cappers", cappers, sizeof(cappers));
  3774.         int cappersLength = strlen(cappers);
  3775.         for (int i = 0 ; i < cappersLength; i++)
  3776.         {
  3777.             int clientCapper = cappers[i];
  3778.             if (clientCapper > 0 && IsClientInGame(clientCapper) && IsPlayerAlive(clientCapper) && !IsFakeClient(clientCapper))
  3779.             {
  3780.                 // Get player's position
  3781.                 float capperPos[3];
  3782.                 GetClientAbsOrigin(clientCapper, capperPos);
  3783.  
  3784.                 // Update respawn position
  3785.                 g_fRespawnPosition = capperPos;
  3786.                 break;
  3787.             }
  3788.         }
  3789.  
  3790.         // Respawn all players
  3791.         for (int client = 1; client <= MaxClients; client++)
  3792.         {
  3793.             if (IsClientInGame(client))
  3794.             {
  3795.                 int team = GetClientTeam(client);
  3796.                 float clientPos[3];
  3797.                 GetClientAbsOrigin(client, clientPos);
  3798.                 if (playerPickSquad[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
  3799.                 {
  3800.                     if (!IsFakeClient(client))
  3801.                     {
  3802.                         if (!IsClientTimingOut(client))
  3803.                         {
  3804.                             CreateCounterRespawnTimer(client);
  3805.                         }
  3806.                     }
  3807.                     else
  3808.                     {
  3809.                         CreateCounterRespawnTimer(client);
  3810.                     }
  3811.                 }
  3812.             }
  3813.         }
  3814.     }
  3815.  
  3816.     // //Elite Bots Reset
  3817.     // if (g_elite_counter_attacks == 1)
  3818.     //  CreateTimer(5.0, Timer_EliteBots);
  3819.     //PrintToServer("CONTROL POINT CAPTURED POST");
  3820.  
  3821.     // Get the number of control points
  3822.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  3823.    
  3824.     // Get active push point
  3825.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  3826.     // If last capture point
  3827.     if (((acp+1) == ncp))
  3828.     {
  3829.         g_secWave_Timer = g_iRespawnSeconds;
  3830.         g_secWave_Timer += (GetTeamSecCount() * 4);
  3831.     }
  3832.     else if (Ins_InCounterAttack())
  3833.         g_secWave_Timer += (GetTeamSecCount() * 3);
  3834.  
  3835.     //Roundend Protection
  3836.     int attacker = GetEventInt(event, "attacker");
  3837.     if (attacker > 0 && IsValidClient(attacker))
  3838.     {
  3839.         float attackerPos[3];
  3840.         GetClientAbsOrigin(attacker, attackerPos);
  3841.         g_fSpawnPoint = attackerPos;
  3842.     }
  3843.     return Plugin_Continue;
  3844. }
  3845.  
  3846. //Enable/Disable Elite Bots
  3847. void EnableDisableEliteBotCvars(int tEnabled, int isFinale) {
  3848.     float tCvarFloatValue;
  3849.     int tCvarIntValue;
  3850.     ConVar tCvar;
  3851.     if (tEnabled == 1) {
  3852.         //PrintToServer("BOT_SETTINGS_APPLIED");
  3853.         if (isFinale == 1) {
  3854.             tCvar = FindConVar("mp_player_resupply_coop_delay_max");
  3855.             tCvar.SetInt(g_coop_delay_penalty_base, true, false);
  3856.             tCvar = FindConVar("mp_player_resupply_coop_delay_penalty");
  3857.             tCvar.SetInt(g_coop_delay_penalty_base, true, false);
  3858.             tCvar = FindConVar("mp_player_resupply_coop_delay_base");
  3859.             tCvar.SetInt(g_coop_delay_penalty_base, true, false);
  3860.         }
  3861.  
  3862.         tCvar = FindConVar("bot_attackdelay_frac_difficulty_impossible");
  3863.         tCvarFloatValue = FindConVar("bot_attackdelay_frac_difficulty_impossible").FloatValue;
  3864.         tCvarFloatValue = tCvarFloatValue - g_bot_attackdelay_frac_difficulty_impossible_mult;
  3865.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3866.  
  3867.         tCvar = FindConVar("bot_attack_aimpenalty_amt_close");
  3868.         tCvarIntValue = FindConVar("bot_attack_aimpenalty_amt_close").IntValue;
  3869.         tCvarIntValue = tCvarIntValue - g_bot_attack_aimpenalty_amt_close_mult;
  3870.         tCvar.SetInt(tCvarIntValue, true, false);
  3871.  
  3872.         tCvar = FindConVar("bot_attack_aimpenalty_amt_far");
  3873.         tCvarIntValue = FindConVar("bot_attack_aimpenalty_amt_far").IntValue;
  3874.         tCvarIntValue = tCvarIntValue - g_bot_attack_aimpenalty_amt_far_mult;
  3875.         tCvar.SetInt(tCvarIntValue, true, false);
  3876.  
  3877.         tCvar = FindConVar("bot_attack_aimpenalty_time_close");
  3878.         tCvarFloatValue = FindConVar("bot_attack_aimpenalty_time_close").FloatValue;
  3879.         tCvarFloatValue = tCvarFloatValue - g_bot_attack_aimpenalty_time_close_mult;
  3880.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3881.  
  3882.         tCvar = FindConVar("bot_attack_aimpenalty_time_far");
  3883.         tCvarFloatValue = FindConVar("bot_attack_aimpenalty_time_far").FloatValue;
  3884.         tCvarFloatValue = tCvarFloatValue - g_bot_attack_aimpenalty_time_far_mult;
  3885.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3886.  
  3887.         ConVar cv = FindConVar("bot_attack_aimtolerance_newthreat_amt");
  3888.         cv.FloatValue -= cv.FloatValue - g_bot_attack_aimtolerance_newthreat_amt_mult;
  3889.  
  3890.         /*
  3891.  
  3892.         tCvar = FindConVar("bot_attack_aimtolerance_newthreat_amt");
  3893.         tCvarIntValue = FindConVar("bot_attack_aimtolerance_newthreat_amt");
  3894.         tCvarIntValue = tCvarIntValue - g_bot_attack_aimtolerance_newthreat_amt_mult;
  3895.         tCvar.SetFloat(tCvarIntValue, true, false);
  3896.         */
  3897.  
  3898.         tCvar = FindConVar("bot_aim_aimtracking_base");
  3899.         tCvarFloatValue = FindConVar("bot_aim_aimtracking_base").FloatValue;
  3900.         tCvarFloatValue = tCvarFloatValue - g_bot_aim_aimtracking_base;
  3901.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3902.  
  3903.         tCvar = FindConVar("bot_aim_aimtracking_frac_impossible");
  3904.         tCvarFloatValue = FindConVar("bot_aim_aimtracking_frac_impossible").FloatValue;
  3905.         tCvarFloatValue = tCvarFloatValue - g_bot_aim_aimtracking_frac_impossible;
  3906.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3907.  
  3908.         tCvar = FindConVar("bot_aim_angularvelocity_frac_impossible");
  3909.         tCvarFloatValue = FindConVar("bot_aim_angularvelocity_frac_impossible").FloatValue;
  3910.         tCvarFloatValue = tCvarFloatValue + g_bot_aim_angularvelocity_frac_impossible;
  3911.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3912.  
  3913.         tCvar = FindConVar("bot_aim_angularvelocity_frac_sprinting_target");
  3914.         tCvarFloatValue = FindConVar("bot_aim_angularvelocity_frac_sprinting_target").FloatValue;
  3915.         tCvarFloatValue = tCvarFloatValue + g_bot_aim_angularvelocity_frac_sprinting_target;
  3916.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3917.  
  3918.         tCvar = FindConVar("bot_aim_attack_aimtolerance_frac_impossible");
  3919.         tCvarFloatValue = FindConVar("bot_aim_attack_aimtolerance_frac_impossible").FloatValue;
  3920.         tCvarFloatValue = tCvarFloatValue - g_bot_aim_attack_aimtolerance_frac_impossible;
  3921.         tCvar.SetFloat(tCvarFloatValue, true, false);
  3922.         //Make sure to check for FLOATS vs INTS and +/-!
  3923.     }
  3924.     else {
  3925.         //PrintToServer("BOT_SETTINGS_APPLIED_2");
  3926.         tCvar = FindConVar("ins_bot_count_checkpoint_max");
  3927.         tCvar.SetInt(g_ins_bot_count_checkpoint_max_org, true, false);
  3928.         tCvar = FindConVar("mp_player_resupply_coop_delay_max");
  3929.         tCvar.SetInt(g_mp_player_resupply_coop_delay_max_org, true, false);
  3930.         tCvar = FindConVar("mp_player_resupply_coop_delay_penalty");
  3931.         tCvar.SetInt(g_mp_player_resupply_coop_delay_penalty_org, true, false);
  3932.         tCvar = FindConVar("mp_player_resupply_coop_delay_base");
  3933.         tCvar.SetInt(g_mp_player_resupply_coop_delay_base_org, true, false);
  3934.         tCvar = FindConVar("bot_attackdelay_frac_difficulty_impossible");
  3935.         tCvar.SetFloat(g_bot_attackdelay_frac_difficulty_impossible_org, true, false);
  3936.         tCvar = FindConVar("bot_attack_aimpenalty_amt_close");
  3937.         tCvar.SetInt(g_bot_attack_aimpenalty_amt_close_org, true, false);
  3938.         tCvar = FindConVar("bot_attack_aimpenalty_amt_far");
  3939.         tCvar.SetInt(g_bot_attack_aimpenalty_amt_far_org, true, false);
  3940.         tCvar = FindConVar("bot_attack_aimpenalty_time_close");
  3941.         tCvar.SetFloat(g_bot_attack_aimpenalty_time_close_org, true, false);
  3942.         tCvar = FindConVar("bot_attack_aimpenalty_time_far");
  3943.         tCvar.SetFloat(g_bot_attack_aimpenalty_time_far_org, true, false);
  3944.         tCvar = FindConVar("bot_attack_aimtolerance_newthreat_amt");
  3945.         tCvar.SetFloat(g_bot_attack_aimtolerance_newthreat_amt_org, true, false);
  3946.         tCvar = FindConVar("bot_aim_aimtracking_base");
  3947.         tCvar.SetFloat(g_bot_aim_aimtracking_base_org, true, false);
  3948.         tCvar = FindConVar("bot_aim_aimtracking_frac_impossible");
  3949.         tCvar.SetFloat(g_bot_aim_aimtracking_frac_impossible_org, true, false);
  3950.         tCvar = FindConVar("bot_aim_angularvelocity_frac_impossible");
  3951.         tCvar.SetFloat(g_bot_aim_angularvelocity_frac_impossible_org, true, false);
  3952.         tCvar = FindConVar("bot_aim_angularvelocity_frac_sprinting_target");
  3953.         tCvar.SetFloat(g_bot_aim_angularvelocity_frac_sprinting_target_org, true, false);
  3954.         tCvar = FindConVar("bot_aim_attack_aimtolerance_frac_impossible");
  3955.         tCvar.SetFloat(g_bot_aim_attack_aimtolerance_frac_impossible_org, true, false);
  3956.     }
  3957. }
  3958.  
  3959. // On finale counter attack, add lives back to insurgents to trigger unlimited respawns (this is redundant code now and may use for something else)
  3960. Action Timer_FinaleCounterAssignLives(Handle timer)
  3961. {
  3962.     if (g_iCvar_final_counterattack_type == 2)
  3963.     {
  3964.             // Reset remaining lives for bots
  3965.             g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins;
  3966.     }
  3967. }
  3968.  
  3969. // When counter-attack end, reset reinforcement time
  3970. Action Timer_CounterAttackEnd(Handle timer) {
  3971.  
  3972.     //Disable elite bots when not in counter
  3973.     if (g_isEliteCounter == 1 && g_elite_counter_attacks == 1) {
  3974.         g_isEliteCounter = 0;
  3975.         EnableDisableEliteBotCvars(0, 0);
  3976.     }
  3977.  
  3978.     ResetInsurgencyLives();
  3979.     if (g_iCvar_respawn_reset_type && g_isCheckpoint) {
  3980.             ResetSecurityLives();
  3981.     }
  3982.  
  3983.         // Stop counter-attack music
  3984.         //StopCounterAttackMusic();
  3985.  
  3986.         // Reset variable
  3987.     //g_bIsCounterAttackTimerActive = false;
  3988.     ConVar cvar = null;
  3989.     cvar = FindConVar("mp_checkpoint_counterattack_always");
  3990.     cvar.SetInt(0, true, false);
  3991.  
  3992.     for (int client = 0; client < MaxClients; client++) {
  3993.             if (!IsValidClient(client) || client <= 0) {
  3994.                 continue;
  3995.             }
  3996.             if (!IsClientInGame(client)) {
  3997.                 continue;
  3998.             }
  3999.             int m_iTeam = GetClientTeam(client);
  4000.             if (IsFakeClient(client) && m_iTeam == TEAM_2_INS) {
  4001.                 g_badSpawnPos_Track[client][0] = 0.0;
  4002.                 g_badSpawnPos_Track[client][1] = 0.0;
  4003.                 g_badSpawnPos_Track[client][2] = 0.0;
  4004.             }
  4005.         }
  4006.  
  4007.         //PrintToServer("[RESPAWN] Counter-attack is over.");
  4008.     return Plugin_Stop;
  4009.     //}
  4010.  
  4011.     //return Plugin_Continue;
  4012. }
  4013.  
  4014. /*
  4015. // Stop counter-attack music
  4016. void StopCounterAttackMusic()
  4017. {
  4018.     for (new i = 1; i <= MaxClients; i++)
  4019.     {
  4020.         if (IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i))
  4021.         {
  4022.             //ClientCommand(i, "snd_restart");
  4023.             //FakeClientCommand(i, "snd_restart");
  4024.             StopSound(i, SNDCHAN_STATIC, "*cues/INS_GameMusic_AboutToAttack_A.ogg");
  4025.         }
  4026.     }
  4027. }
  4028. */
  4029.  
  4030. //Run this to mark a bot as ready to spawn. Add tokens if you want them to be able to spawn.
  4031. void ResetSecurityLives()
  4032. {
  4033.     // Disable if counquer
  4034.     //if (g_isConquer == 1 || g_isOutpost == 1) return;
  4035.         // The number of control points
  4036.     //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  4037.     // Active control poin
  4038.     //new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  4039.  
  4040.  
  4041.     // Return if respawn is disabled
  4042.     if (!g_iCvar_respawn_enable)
  4043.         return;
  4044.  
  4045.     // Update cvars
  4046.     UpdateRespawnCvars();
  4047.  
  4048.     //If spawned per point, give more per-point lives based on team count.
  4049.     if (g_iCvar_respawn_reset_type == 1)
  4050.     {
  4051.             SecDynLivesPerPoint();
  4052.     }
  4053.    
  4054.     // Individual lives
  4055.     if (g_iCvar_respawn_type_team_sec == 1)
  4056.     {
  4057.         for (int client = 1; client <= MaxClients; client++)
  4058.         {
  4059.             // Check valid player
  4060.             if (client > 0 && IsClientInGame(client))
  4061.             {
  4062.                 //Reset Medic Stats:
  4063.                 g_playerMedicRevivessAccumulated[client] = 0;
  4064.                 g_playerMedicHealsAccumulated[client] = 0;
  4065.                 g_playerNonMedicHealsAccumulated[client] = 0;
  4066.  
  4067.                 // Check Team
  4068.                 int iTeam = GetClientTeam(client);
  4069.                 if (iTeam != TEAM_1_SEC) continue;
  4070.  
  4071.                 /*// Individual SEC lives
  4072.                 if (g_iCvar_respawn_type_team_sec == 1)
  4073.                 {
  4074.                 // Reset remaining lives for player
  4075.                     g_iSpawnTokens[client] = g_iRespawnCount[iTeam];
  4076.                 }*/
  4077.             }
  4078.         }
  4079.     }
  4080.  
  4081.     // Team lives
  4082.     if (g_iCvar_respawn_type_team_sec == 2)
  4083.     {
  4084.         // Reset remaining lives for player
  4085.         g_iRemaining_lives_team_sec = g_iRespawn_lives_team_sec;
  4086.     }
  4087. }
  4088.  
  4089. //Run this to mark a bot as ready to spawn. Add tokens if you want them to be able to spawn.
  4090. void ResetInsurgencyLives()
  4091. {
  4092.     // Return if respawn is disabled
  4093.     if (!g_iCvar_respawn_enable) return;
  4094.  
  4095.     // Update cvars
  4096.     UpdateRespawnCvars();
  4097.  
  4098.     // Individual lives
  4099.     if (g_iCvar_respawn_type_team_ins == 1)
  4100.     {
  4101.         for (int client=1; client<=MaxClients; client++)
  4102.         {
  4103.             // Check valid player
  4104.             if (client > 0 && IsClientInGame(client))
  4105.             {
  4106.                 // Check Team
  4107.                 int iTeam = GetClientTeam(client);
  4108.                 if (iTeam != TEAM_2_INS) continue;
  4109.                 g_iSpawnTokens[client] = g_iRespawnCount[iTeam];
  4110.             }
  4111.         }
  4112.     }
  4113.  
  4114.     // Team lives
  4115.     if (g_iCvar_respawn_type_team_ins == 2)
  4116.     {
  4117.         // Reset remaining lives for bots
  4118.         g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins;
  4119.     }
  4120. }
  4121.  
  4122. // When player picked squad, initialize variables
  4123. public Action Event_PlayerPickSquad_Post(Event event, const char[] name, bool dontBroadcast)
  4124. {
  4125.     //"squad_slot" "byte"
  4126.     //"squad" "byte"
  4127.     //"userid" "short"
  4128.     //"class_template" "string"
  4129.     //PrintToServer("##########PLAYER IS PICKING SQUAD!############");
  4130.  
  4131.     // Get client ID
  4132.     int client = GetClientOfUserId( GetEventInt( event, "userid" ) );
  4133.    
  4134.     if( client == 0 || !IsClientInGame(client) || IsFakeClient(client)) return;
  4135.    
  4136.     // Init variable
  4137.     playerPickSquad[client] = 1;
  4138.  
  4139.     // Get class name
  4140.     char class_template[64];
  4141.     event.GetString("class_template", class_template, sizeof(class_template));
  4142.  
  4143.     // Set class string
  4144.     g_client_last_classstring[client] = class_template;
  4145.     g_hintsEnabled[client] = true;
  4146.  
  4147.     // If player changed squad and remain ragdoll
  4148.     int team = GetClientTeam(client);
  4149.     if (client > 0 && IsClientInGame(client) && IsClientObserver(client) && !IsPlayerAlive(client) && g_iHurtFatal[client] == 0 && team == TEAM_1_SEC)
  4150.     {
  4151.         // Remove ragdoll
  4152.         int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  4153.         if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  4154.             RemoveRagdoll(client);
  4155.  
  4156.         // Init variable
  4157.         g_iHurtFatal[client] = -1;
  4158.     }
  4159.  
  4160.     g_fPlayerLastChat[client] = GetGameTime();
  4161.  
  4162.     // Get player nickname
  4163.     char sNewNickname[64];
  4164.  
  4165.     // Medic class
  4166.     if (StrContains(g_client_last_classstring[client], "medic") > -1)
  4167.     {
  4168.         // Admin medic
  4169.         if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_ROOT))
  4170.             Format(sNewNickname, sizeof(sNewNickname), "[ADMIN][MEDIC] %s", g_client_org_nickname[client]);
  4171.         // Donor medic
  4172.         else if (GetConVarInt(sm_respawn_enable_donor_tag) == 1 && (GetUserFlagBits(client) & ADMFLAG_RESERVATION))
  4173.             Format(sNewNickname, sizeof(sNewNickname), "[DONOR][MEDIC] %s", g_client_org_nickname[client]);
  4174.         // Normal medic
  4175.         else
  4176.             Format(sNewNickname, sizeof(sNewNickname), "[MEDIC] %s", g_client_org_nickname[client]);
  4177.     }
  4178.  
  4179.     // Set player nickname
  4180.     char sCurNickname[64];
  4181.     Format(sCurNickname, sizeof(sCurNickname), "%N", client);
  4182.     if (!StrEqual(sCurNickname, sNewNickname))
  4183.         SetClientName(client, sNewNickname);
  4184.  
  4185.     g_playersReady = true;
  4186.  
  4187.     //Allow new players to use lives to respawn on join
  4188.     if (g_iRoundStatus == 1 && g_playerFirstJoin[client] == 1 && !IsPlayerAlive(client) && team == TEAM_1_SEC)
  4189.     {
  4190.         // Get SteamID to verify is player has connected before.
  4191.         char steamId[64];
  4192.         //GetClientAuthString(client, steamId, sizeof(steamId));
  4193.         GetClientAuthId(client, AuthId_Steam3, steamId, sizeof(steamId));
  4194.         int isPlayerNew = g_playerArrayList.FindString(steamId);
  4195.  
  4196.         if (isPlayerNew != -1)
  4197.         {
  4198.             //PrintToServer("Player %N has reconnected! | SteamID: %s | Index: %d", client, steamId, isPlayerNew);
  4199.         }
  4200.         else
  4201.         {
  4202.             g_playerArrayList.PushString(steamId);
  4203.             //PrintToServer("Player %N is new! | SteamID: %s | PlayerArrayList Size: %d", client, steamId, g_playerArrayList.Length);
  4204.             // Give individual lives to new player (no longer just at beginning of round)
  4205.             if (g_iCvar_respawn_type_team_sec == 1) {
  4206.                 if (g_isCheckpoint && g_iCvar_respawn_reset_type == 0) {
  4207.                     // The number of control points
  4208.                     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  4209.                     // Active control poin
  4210.                     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  4211.                     int tLiveSec = sm_respawn_lives_team_sec.IntValue;
  4212.  
  4213.                     if (acp <= (ncp / 2)) {
  4214.                         g_iSpawnTokens[client] = tLiveSec;
  4215.                     }
  4216.                     else {
  4217.                         g_iSpawnTokens[client] = (tLiveSec / 2);
  4218.                     }
  4219.  
  4220.                     if (tLiveSec < 1) {
  4221.                         tLiveSec = 1;
  4222.                         g_iSpawnTokens[client] = tLiveSec;
  4223.                     }
  4224.                 }
  4225.                 else {
  4226.                     g_iSpawnTokens[client] = sm_respawn_lives_team_sec.IntValue;
  4227.                 }
  4228.  
  4229.             }
  4230.             CreatePlayerRespawnTimer(client);
  4231.         }
  4232.     }
  4233.  
  4234.     //Update RespawnCvars when player picks squad
  4235.     UpdateRespawnCvars();
  4236. }
  4237.  
  4238. // Triggers when player hurt
  4239. ppublic Action Event_PlayerHurt_Pre(Event event, const char[] name, bool dontBroadcast) {
  4240.     int victim = GetClientOfUserId(event.GetInt("userid"));
  4241.     if (IsClientInGame(victim) && IsFakeClient(victim)) {
  4242.         return Plugin_Continue;
  4243.     }
  4244.  
  4245.     int victimHealth = event.GetInt("health");
  4246.     int dmg_taken = event.GetInt("dmg_health");
  4247.     //PrintToServer("victimHealth: %d, dmg_taken: %d", victimHealth, dmg_taken);
  4248.     if (g_fCvar_fatal_chance > 0.0 && dmg_taken > victimHealth) {
  4249.         // Get information for event structure
  4250.         int attacker = GetClientOfUserId(event.GetInt("attacker"));
  4251.         int hitgroup = event.GetInt("hitgroup");
  4252.  
  4253.         // Update last damege (related to 'hurt_fatal')
  4254.         g_clientDamageDone[victim] = dmg_taken;
  4255.  
  4256.         // Get weapon
  4257.         char weapon[32];
  4258.         event.GetString("weapon", weapon, sizeof(weapon));
  4259.  
  4260.         //PrintToServer("[DAMAGE TAKEN] Weapon used: %s, Damage done: %i", weapon, dmg_taken);
  4261.  
  4262.         // Check is team attack
  4263.         int attackerTeam;
  4264.         if (attacker > 0 && IsClientInGame(attacker) && IsClientConnected(attacker)) {
  4265.             attackerTeam = GetClientTeam(attacker);
  4266.         }
  4267.  
  4268.         // Get fatal chance
  4269.         float fRandom = GetRandomFloat(0.0, 1.0);
  4270.  
  4271.         // Is client valid
  4272.         if (IsClientInGame(victim)) {
  4273.  
  4274.             // Explosive
  4275.             if (hitgroup == 0) {
  4276.                 //explosive list
  4277.                 //incens
  4278.                 //grenade_molotov, grenade_anm14
  4279.                 //PrintToServer("[HITGROUP HURT BURN]");
  4280.                 //grenade_m67, grenade_f1, grenade_ied, grenade_c4, rocket_rpg7, rocket_at4, grenade_gp25_he, grenade_m203_he
  4281.                 // flame
  4282.                 if (StrEqual(weapon, "grenade_anm14", false) || StrEqual(weapon, "grenade_molotov", false)) {
  4283.                     //PrintToServer("[SUICIDE] incen/molotov DETECTED!");
  4284.                     if (dmg_taken >= g_iCvar_fatal_burn_dmg && (fRandom <= g_fCvar_fatal_chance)) {
  4285.                         // Hurt fatally
  4286.                         g_iHurtFatal[victim] = 1;
  4287.  
  4288.                         //PrintToServer("[PLAYER HURT BURN]");
  4289.                     }
  4290.                 }
  4291.                 // explosive
  4292.                 else if (StrEqual(weapon, "grenade_m67", false) ||
  4293.                     StrEqual(weapon, "grenade_f1", false) ||
  4294.                     StrEqual(weapon, "grenade_ied", false) ||
  4295.                     StrEqual(weapon, "grenade_c4", false) ||
  4296.                     StrEqual(weapon, "rocket_rpg7", false) ||
  4297.                     StrEqual(weapon, "rocket_at4", false) ||
  4298.                     StrEqual(weapon, "grenade_gp25_he", false) ||
  4299.                     StrEqual(weapon, "grenade_m203_he", false)) {
  4300.                     //PrintToServer("[HITGROUP HURT EXPLOSIVE]");
  4301.                     if (dmg_taken >= g_iCvar_fatal_explosive_dmg && (fRandom <= g_fCvar_fatal_chance)) {
  4302.                         // Hurt fatally
  4303.                         g_iHurtFatal[victim] = 1;
  4304.  
  4305.                         //PrintToServer("[PLAYER HURT EXPLOSIVE]");
  4306.                     }
  4307.                 }
  4308.                 //PrintToServer("[SUICIDE] HITRGOUP 0 [GENERIC]");
  4309.             }
  4310.             // Headshot
  4311.             else if (hitgroup == 1) {
  4312.                 //PrintToServer("[PLAYER HURT HEAD]");
  4313.                 if (dmg_taken >= g_iCvar_fatal_head_dmg && (fRandom <= g_fCvar_fatal_head_chance) && attackerTeam != TEAM_1_SEC) {
  4314.                     // Hurt fatally
  4315.                     g_iHurtFatal[victim] = 1;
  4316.  
  4317.                     //PrintToServer("[BOTSPAWNS] BOOM HEADSHOT");
  4318.                 }
  4319.             }
  4320.             // Chest
  4321.             else if (hitgroup == 2 || hitgroup == 3) {
  4322.                 //PrintToServer("[HITGROUP HURT CHEST]");
  4323.                 if (dmg_taken >= g_iCvar_fatal_chest_stomach && (fRandom <= g_fCvar_fatal_chance)) {
  4324.                     // Hurt fatally
  4325.                     g_iHurtFatal[victim] = 1;
  4326.  
  4327.                     //PrintToServer("[PLAYER HURT CHEST]");
  4328.                 }
  4329.             }
  4330.             // Limbs
  4331.             else if (hitgroup == 4 || hitgroup == 5  || hitgroup == 6 || hitgroup == 7) {
  4332.                 //PrintToServer("[HITGROUP HURT LIMBS]");
  4333.                 if (dmg_taken >= g_iCvar_fatal_limb_dmg && (fRandom <= g_fCvar_fatal_chance)) {
  4334.                     // Hurt fatally
  4335.                     g_iHurtFatal[victim] = 1;
  4336.  
  4337.                     //PrintToServer("[PLAYER HURT LIMBS]");
  4338.                 }
  4339.             }
  4340.         }
  4341.     }
  4342.     //Track wound type (minor, moderate, critical)
  4343.     if (g_iHurtFatal[victim] != 1) {
  4344.         if (dmg_taken <= g_minorWound_dmg) {
  4345.             g_playerWoundTime[victim] = g_minorRevive_time;
  4346.             g_playerWoundType[victim] = 0;
  4347.         }
  4348.         else if (dmg_taken > g_minorWound_dmg && dmg_taken <= g_moderateWound_dmg) {
  4349.             g_playerWoundTime[victim] = g_modRevive_time;
  4350.             g_playerWoundType[victim] = 1;
  4351.         }
  4352.         else if (dmg_taken > g_moderateWound_dmg) {
  4353.             g_playerWoundTime[victim] = g_critRevive_time;
  4354.             g_playerWoundType[victim] = 2;
  4355.         }
  4356.     }
  4357.     else {
  4358.         g_playerWoundTime[victim] = -1;
  4359.         g_playerWoundType[victim] = -1;
  4360.     }
  4361.  
  4362.     ////////////////////////
  4363.     // Rank System
  4364.     int attackerId = event.GetInt("attacker");
  4365.     int hitgroup = event.GetInt("hitgroup");
  4366.  
  4367.     int attacker = GetClientOfUserId(attackerId);
  4368.  
  4369.     if (hitgroup == 1) {
  4370.         g_iStatHeadShots[attacker]++;
  4371.     }
  4372.     ////////////////////////
  4373.  
  4374.     return Plugin_Continue;
  4375. }
  4376.  
  4377. // Triggered when player die PRE
  4378. public Action Event_PlayerDeath_Pre(Event event, const char[] name, bool dontBroadcast)
  4379. {
  4380.         int client = GetClientOfUserId(event.GetInt("userid"));
  4381.         // Tracking ammo
  4382.         if (g_iEnableRevive == 1 && g_iRoundStatus == 1 && g_iCvar_enable_track_ammo == 1)
  4383.         {
  4384.             //PrintToChatAll("### GET PLAYER WEAPONS ###");
  4385.             //CONSIDER IF PLAYER CHOOSES DIFFERENT CLASS
  4386.             // Get weapons
  4387.             int primaryWeapon = GetPlayerWeaponSlot(client, 0);
  4388.             int secondaryWeapon = GetPlayerWeaponSlot(client, 1);
  4389.  
  4390.             // Set weapons to variables
  4391.             playerPrimary[client] = primaryWeapon;
  4392.             playerSecondary[client] = secondaryWeapon;
  4393.  
  4394.             //Get ammo left in clips for primary and secondary
  4395.             playerClip[client][0] = GetPrimaryAmmo(client, primaryWeapon, 0);
  4396.             playerClip[client][1] = GetPrimaryAmmo(client, secondaryWeapon, 1); // m_iClip2 for secondary if this doesnt work? would need GetSecondaryAmmo
  4397.  
  4398.             if (!playerInRevivedState[client])
  4399.             {
  4400.                 //Get Magazines left on player
  4401.                 if (primaryWeapon != -1 && IsValidEntity(primaryWeapon))
  4402.                      Client_GetWeaponPlayerAmmoEx(client, primaryWeapon, playerAmmo[client][0]); //primary
  4403.                 if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon))
  4404.                      Client_GetWeaponPlayerAmmoEx(client, secondaryWeapon, playerAmmo[client][1]); //secondary 
  4405.             }
  4406.             playerInRevivedState[client] = false;
  4407.         }
  4408. }
  4409.  
  4410. //Thanks to Headline for fixing part of this function
  4411. // Trigged when player die
  4412. public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
  4413.     ////////////////////////
  4414.     // Rank System
  4415.     int victimId = event.GetInt("userid");
  4416.     int attackerId = event.GetInt("attacker");
  4417.     int victim = GetClientOfUserId(victimId);
  4418.     int attacker = GetClientOfUserId(attackerId);
  4419.  
  4420.     if (victim != attacker) {
  4421.         g_iStatKills[attacker]++;
  4422.         g_iStatDeaths[victim]++;
  4423.     }
  4424.     else {
  4425.         g_iStatSuicides[victim]++;
  4426.         g_iStatDeaths[victim]++;
  4427.     }
  4428.  
  4429.     // Get player ID
  4430.     int client = GetClientOfUserId(event.GetInt("userid"));
  4431.     // Check client valid
  4432.     if (!(0 < attacker <= MaxClients) || !IsClientInGame(client)) {
  4433.         return Plugin_Continue;
  4434.     } {
  4435.         g_iPlayerBGroups[client] = GetEntProp(client, Prop_Send, "m_nBody");
  4436.     }
  4437.     //PrintToServer("BodyGroups: %d", g_iPlayerBGroups[client]);
  4438.  
  4439.     // Set variable
  4440.     int dmg_taken = event.GetInt("damagebits");
  4441.     if (dmg_taken <= 0) {
  4442.         g_playerWoundTime[client] = g_minorRevive_time;
  4443.         g_playerWoundType[client] = 0;
  4444.     }
  4445.  
  4446.     //PrintToServer("[PLAYERDEATH] Client %N has %d lives remaining", client, g_iSpawnTokens[client]);
  4447.  
  4448.     // Get gamemode
  4449.     char sGameMode[32];
  4450.     FindConVar("mp_gamemode").GetString(sGameMode, sizeof(sGameMode));
  4451.     int team = GetClientTeam(client);
  4452.     int attackerTeam = GetClientTeam(attacker);
  4453.  
  4454.     //AI Director START
  4455.     //Bot Team AD Status
  4456.     if (team == TEAM_2_INS && g_iRoundStatus == 1 && attackerTeam == TEAM_1_SEC) {
  4457.         //Bonus point for specialty bots
  4458.         if (AI_Director_IsSpecialtyBot(client)) {
  4459.             g_AIDir_TeamStatus += 1;
  4460.         }
  4461.         g_AIDir_BotsKilledCount++;
  4462.         if (g_AIDir_BotsKilledCount > (GetTeamSecCount() / g_AIDir_BotsKilledReq_mult)) {
  4463.             g_AIDir_BotsKilledCount = 0;
  4464.             g_AIDir_TeamStatus += 1;
  4465.         }
  4466.     }
  4467.         //Player Team AD STATUS
  4468.     if (team == TEAM_1_SEC && g_iRoundStatus == 1) {
  4469.         if (g_iHurtFatal[client] == 1) {
  4470.             g_AIDir_TeamStatus -= 3;
  4471.         }
  4472.         else {
  4473.             g_AIDir_TeamStatus -= 2;
  4474.         }
  4475.         if ((StrContains(g_client_last_classstring[client], "medic") > -1)) {
  4476.             g_AIDir_TeamStatus -= 3;
  4477.         }
  4478.     }
  4479.     g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  4480.  
  4481.     //AI Director END
  4482.     if (g_iCvar_revive_enable) {
  4483.         // Convert ragdoll
  4484.         if (team == TEAM_1_SEC) {
  4485.             // Get current position
  4486.             float vecPos[3];
  4487.             GetClientAbsOrigin(client, vecPos);
  4488.             g_fDeadPosition[client] = vecPos;
  4489.  
  4490.                 // Call ragdoll timer
  4491.             if (g_iEnableRevive == 1 && g_iRoundStatus == 1) {
  4492.                 CreateTimer(5.0, ConvertDeleteRagdoll, client);
  4493.             }
  4494.         }
  4495.     }
  4496.     // Check enables
  4497.     if (g_iCvar_respawn_enable) {
  4498.         // Client should be TEAM_1_SEC = HUMANS or TEAM_2_INS = BOTS
  4499.         if ((team == TEAM_1_SEC) || (team == TEAM_2_INS)) {
  4500.             // The number of control points
  4501.             int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  4502.  
  4503.             // Active control point
  4504.             int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  4505.  
  4506.             // Do not decrease life in counterattack
  4507.             if (g_isCheckpoint == 1 && Ins_InCounterAttack() &&
  4508.                 (((acp+1) == ncp &&  g_iCvar_final_counterattack_type == 2) ||
  4509.                 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))) {
  4510.                 // Respawn type 1 bots
  4511.                 if ((g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS) &&
  4512.                 (((acp+1) == ncp &&  g_iCvar_final_counterattack_type == 2) ||
  4513.                 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))) {
  4514.                     if ((g_iSpawnTokens[client] < g_iRespawnCount[team])) {
  4515.                         g_iSpawnTokens[client] = (g_iRespawnCount[team] + 1);
  4516.                     }
  4517.  
  4518.                     // Call respawn timer
  4519.                     CreateBotRespawnTimer(client);
  4520.                 }
  4521.                 // Respawn type 1 player (individual lives)
  4522.                 else if (g_iCvar_respawn_type_team_sec == 1 && team == TEAM_1_SEC) {
  4523.                     if (g_iSpawnTokens[client] > 0) {
  4524.                         if (team == TEAM_1_SEC) {
  4525.                             CreatePlayerRespawnTimer(client);
  4526.                         }
  4527.                     }
  4528.                     else if (g_iSpawnTokens[client] <= 0 && g_iRespawnCount[team] > 0) {
  4529.                         // Cannot respawn anymore
  4530.                         char sChat[128];
  4531.                         Format(sChat, 128,"You cannot be respawned anymore. (out of lives)");
  4532.                         PrintToChat(client, "%s", sChat);
  4533.                     }
  4534.                 }
  4535.                 // Respawn type 2 for players
  4536.                 else if (team == TEAM_1_SEC && g_iCvar_respawn_type_team_sec == 2 && g_iRespawn_lives_team_sec > 0) {
  4537.                     g_iRemaining_lives_team_sec = g_iRespawn_lives_team_sec + 1;
  4538.  
  4539.                     // Call respawn timer
  4540.                     CreateCounterRespawnTimer(client);
  4541.                 }
  4542.                 // Respawn type 2 for bots
  4543.                 else if (team == TEAM_2_INS && g_iCvar_respawn_type_team_ins == 2 &&
  4544.                 (g_iRespawn_lives_team_ins > 0 ||
  4545.                 ((acp+1) == ncp && g_iCvar_final_counterattack_type == 2) ||
  4546.                 ((acp+1) != ncp && g_iCvar_counterattack_type == 2))) {
  4547.                     g_iRemaining_lives_team_ins = g_iRespawn_lives_team_ins + 1;
  4548.  
  4549.                     // Call respawn timer
  4550.                     CreateBotRespawnTimer(client);
  4551.                 }
  4552.             }
  4553.             // Normal respawn
  4554.             else if ((g_iCvar_respawn_type_team_sec == 1 && team == TEAM_1_SEC) ||
  4555.                 (g_iCvar_respawn_type_team_ins == 1 && team == TEAM_2_INS)) {
  4556.                 if (g_iSpawnTokens[client] > 0) {
  4557.                     if (team == TEAM_1_SEC) {
  4558.                         CreatePlayerRespawnTimer(client);
  4559.                     }
  4560.                     else if (team == TEAM_2_INS) {
  4561.                         CreateBotRespawnTimer(client);
  4562.                     }
  4563.                 }
  4564.                 else if (g_iSpawnTokens[client] <= 0 && g_iRespawnCount[team] > 0) {
  4565.                     // Cannot respawn anymore
  4566.                     char sChat[128];
  4567.                     Format(sChat, 128,"You cannot be respawned anymore. (out of lives)");
  4568.                     PrintToChat(client, "%s", sChat);
  4569.                 }
  4570.             }
  4571.             // Respawn type 2 for players
  4572.             else if (g_iCvar_respawn_type_team_sec == 2 && team == TEAM_1_SEC) {
  4573.                 if (g_iRemaining_lives_team_sec > 0) {
  4574.                     CreatePlayerRespawnTimer(client);
  4575.                 }
  4576.                 else if (g_iRemaining_lives_team_sec <= 0 && g_iRespawn_lives_team_sec > 0) {
  4577.                     // Cannot respawn anymore
  4578.                     char sChat[128];
  4579.                     Format(sChat, 128,"You cannot be respawned anymore. (out of team lives)");
  4580.                     PrintToChat(client, "%s", sChat);
  4581.                 }
  4582.             }
  4583.             // Respawn type 2 for bots
  4584.             else if (g_iCvar_respawn_type_team_ins == 2 && g_iRemaining_lives_team_ins >  0 && team == TEAM_2_INS) {
  4585.                 CreateBotRespawnTimer(client);
  4586.             }
  4587.         }
  4588.     }
  4589.  
  4590.     // Init variables
  4591.     char wound_hint[64];
  4592.     char fatal_hint[64];
  4593.     char woundType[64];
  4594.     if (g_playerWoundType[client] == 0) {
  4595.         woundType = "MINORLY WOUNDED";
  4596.     }
  4597.     else if (g_playerWoundType[client] == 1) {
  4598.         woundType = "MODERATELY WOUNDED";
  4599.     }
  4600.     else if (g_playerWoundType[client] == 2) {
  4601.         woundType = "CRITCALLY WOUNDED";
  4602.     }
  4603.  
  4604.     // Display death message
  4605.     if (g_fCvar_fatal_chance > 0.0) {
  4606.         if (g_iHurtFatal[client] == 1 && !IsFakeClient(client)) {
  4607.                 Format(fatal_hint, 255,"You were fatally killed for %i damage", g_clientDamageDone[client]);
  4608.                 PrintHintText(client, "%s", fatal_hint);
  4609.                 PrintToChat(client, "%s", fatal_hint);
  4610.         }
  4611.         else {
  4612.                 Format(wound_hint, 255,"You're %s for %i damage, call a medic for revive!", woundType, g_clientDamageDone[client]);
  4613.                 PrintHintText(client, "%s", wound_hint);
  4614.                 PrintToChat(client, "%s", wound_hint);
  4615.         }
  4616.     }
  4617.         else {
  4618.         Format(wound_hint, 255,"You're %s for %i damage, call a medic for revive!", woundType, g_clientDamageDone[client]);
  4619.         PrintHintText(client, "%s", wound_hint);
  4620.         PrintToChat(client, "%s", wound_hint);
  4621.     }
  4622.  
  4623.  
  4624.         // Update remaining life
  4625.         // ConVar hCvar = null;
  4626.         // new iRemainingLife = GetRemainingLife();
  4627.         // ConVar hCvar = FindConVar("sm_remaininglife");
  4628.         // hCvar.SetInt(iRemainingLife);
  4629.  
  4630.     return Plugin_Continue;
  4631. }
  4632.  
  4633. // Convert dead body to new ragdoll
  4634. public Action ConvertDeleteRagdoll(Handle timer, any client)
  4635. {  
  4636.     if (IsClientInGame(client) && g_iRoundStatus == 1 && !IsPlayerAlive(client))
  4637.     {
  4638.         //PrintToServer("CONVERT RAGDOLL********************");
  4639.         //new clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  4640.         //TeleportEntity(clientRagdoll, g_fDeadPosition[client], NULL_VECTOR, NULL_VECTOR);
  4641.        
  4642.         // Get dead body
  4643.         int clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  4644.        
  4645.         //This timer safely removes client-side ragdoll
  4646.         if(clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && g_iEnableRevive == 1)
  4647.         {
  4648.             // Get dead body's entity
  4649.             int ref = EntIndexToEntRef(clientRagdoll);
  4650.             int entity = EntRefToEntIndex(ref);
  4651.             if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
  4652.             {
  4653.                 // Remove dead body's entity
  4654.                 AcceptEntityInput(entity, "Kill");
  4655.                 clientRagdoll = INVALID_ENT_REFERENCE;
  4656.             }
  4657.         }
  4658.        
  4659.         // Check is fatally dead
  4660.         if (g_iHurtFatal[client] != 1)
  4661.         {
  4662.             // Create new ragdoll
  4663.             int tempRag = CreateEntityByName("prop_ragdoll");
  4664.            
  4665.             // Set client's new ragdoll
  4666.             g_iClientRagdolls[client]  = EntIndexToEntRef(tempRag);
  4667.            
  4668.             // Set position
  4669.             g_fDeadPosition[client][2] = g_fDeadPosition[client][2] + 50;
  4670.            
  4671.             // If success initialize ragdoll
  4672.             if(tempRag != -1)
  4673.             {
  4674.                 // Get model name
  4675.                 char sModelName[64];
  4676.                 GetClientModel(client, sModelName, sizeof(sModelName));
  4677.                
  4678.                 // Set model
  4679.                 SetEntityModel(tempRag, sModelName);
  4680.                 DispatchSpawn(tempRag);
  4681.                
  4682.                 // Set collisiongroup
  4683.                 SetEntProp(tempRag, Prop_Send, "m_CollisionGroup", 17);
  4684.                 //Set bodygroups for ragdoll
  4685.                     SetEntProp(tempRag, Prop_Send, "m_nBody", g_iPlayerBGroups[client]);
  4686.                
  4687.                 // Teleport to current position
  4688.                 TeleportEntity(tempRag, g_fDeadPosition[client], NULL_VECTOR, NULL_VECTOR);
  4689.                
  4690.                 // Set vector
  4691.                 GetEntPropVector(tempRag, Prop_Send, "m_vecOrigin", g_fRagdollPosition[client]);
  4692.                
  4693.                 // Set revive time remaining
  4694.                 g_iReviveRemainingTime[client] = g_playerWoundTime[client];
  4695.                 g_iReviveNonMedicRemainingTime[client] = g_nonMedRevive_time;
  4696.                 // Start revive checking timer
  4697.                 /*
  4698.                 Handle revivePack;
  4699.                 CreateDataTimer(1.0 , Timer_RevivePeriod, revivePack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  4700.                 revivePack.WriteCell(client);
  4701.                 revivePack.WriteCell(tempRag);
  4702.                 */
  4703.             }
  4704.             else
  4705.             {
  4706.                 // If failed to create ragdoll, remove entity
  4707.                 if(tempRag > 0 && IsValidEdict(tempRag) && IsValidEntity(tempRag))
  4708.                 {
  4709.                     RemoveRagdoll(client);
  4710.                 }
  4711.             }
  4712.         }
  4713.     }
  4714. }
  4715.  
  4716. // Remove ragdoll
  4717. void RemoveRagdoll(int client)
  4718. {
  4719.     //new ref = EntIndexToEntRef(g_iClientRagdolls[client]);
  4720.     int entity = EntRefToEntIndex(g_iClientRagdolls[client]);
  4721.     if(entity != INVALID_ENT_REFERENCE && IsValidEntity(entity))
  4722.     {
  4723.         AcceptEntityInput(entity, "Kill");
  4724.         g_iClientRagdolls[client] = INVALID_ENT_REFERENCE;
  4725.     }  
  4726. }
  4727.  
  4728. // This handles revives by medics
  4729. void CreateReviveTimer(int client)
  4730. {
  4731.     CreateTimer(0.0, RespawnPlayerRevive, client);
  4732. }
  4733.  
  4734. // Handles spawns when counter attack starts
  4735. void CreateCounterRespawnTimer(int client)
  4736. {
  4737.     CreateTimer(0.0, RespawnPlayerCounter, client);
  4738. }
  4739.  
  4740. // Respawn bot
  4741. void CreateBotRespawnTimer(int client)
  4742. {  
  4743.     CreateTimer(g_fCvar_respawn_delay_team_ins, RespawnBot, client);
  4744. }
  4745.  
  4746. // Respawn player
  4747. void CreatePlayerRespawnTimer(int client)
  4748. {
  4749.     // Check is respawn timer active
  4750.     if (g_iPlayerRespawnTimerActive[client] == 0)
  4751.     {
  4752.         // Set timer active
  4753.         g_iPlayerRespawnTimerActive[client] = 1;
  4754.        
  4755.         //new validAntenna = -1;
  4756.         //validAntenna = FindValid_Antenna();
  4757.  
  4758.         // Set remaining timer for respawn
  4759.         //if (validAntenna != -1)
  4760.         //{
  4761.         int timeReduce = (GetTeamSecCount() / 3);
  4762.         if (timeReduce <= 0)
  4763.         {
  4764.             timeReduce = 3;
  4765.         }
  4766.  
  4767.         int jammerSpawnReductionAmt = (g_iRespawnSeconds / timeReduce);
  4768.         g_iRespawnTimeRemaining[client] = (g_iRespawnSeconds - jammerSpawnReductionAmt);
  4769.         if (g_iRespawnTimeRemaining[client] < 5)
  4770.                 g_iRespawnTimeRemaining[client] = 5;
  4771.         else
  4772.             g_iRespawnTimeRemaining[client] = g_iRespawnSeconds;
  4773.        
  4774.         //Sync wave based timer if enabled
  4775.         if (g_respawn_mode_team_sec)
  4776.         {
  4777.             g_iRespawnTimeRemaining[client] = g_secWave_Timer;
  4778.         }
  4779.  
  4780.         // Call respawn timer
  4781.         CreateTimer(1.0, Timer_PlayerRespawn, client, TIMER_REPEAT);
  4782.     }
  4783. }
  4784.  
  4785. // Revive player
  4786. Action RespawnPlayerRevive(Handle timer, any client)
  4787. {
  4788.     // Exit if client is not in game
  4789. //  if (!IsClientInGame(client)) return;
  4790.     if (IsPlayerAlive(client) || !IsClientInGame(client) || g_iRoundStatus == 0) return;
  4791.    
  4792.     //PrintToServer("[REVIVE_RESPAWN] REVIVING client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
  4793.     // Call forcerespawn fucntion
  4794.     SDKCall(g_hForceRespawn, client);
  4795.    
  4796.     // If set 'sm_respawn_enable_track_ammo', restore player's ammo
  4797.     if (playerRevived[client] == true && g_iCvar_enable_track_ammo == 1)
  4798.     {
  4799.         playerInRevivedState[client] = true;
  4800.         SetPlayerAmmo(client); //AmmoResupply_Player(client, 0, 0, 1);
  4801.  
  4802.     }      
  4803.    
  4804.     //Set wound health
  4805.     int iHealth = GetClientHealth(client);
  4806.     if (g_playerNonMedicRevive[client] == 0)
  4807.     {
  4808.         if (g_playerWoundType[client] == 0)
  4809.             iHealth = g_minorWoundRevive_hp;
  4810.         else if (g_playerWoundType[client] == 1)
  4811.             iHealth = g_modWoundRevive_hp;
  4812.         else if (g_playerWoundType[client] == 2)
  4813.             iHealth = g_critWoundRevive_hp;
  4814.     }
  4815.     else if (g_playerNonMedicRevive[client] == 1)
  4816.     {
  4817.         //NonMedic Revived
  4818.         iHealth = g_nonMedicRevive_hp;
  4819.     }
  4820.  
  4821.     SetEntityHealth(client, iHealth);
  4822.    
  4823.     // Get player's ragdoll
  4824.     int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  4825.    
  4826.     //Remove network ragdoll
  4827.     if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  4828.         RemoveRagdoll(client);
  4829.    
  4830.     //Do the post-spawn stuff like moving to final "spawnpoint" selected
  4831.     //CreateTimer(0.0, RespawnPlayerRevivePost, client);
  4832.     RespawnPlayerRevivePost(null, client);
  4833.     if ((StrContains(g_client_last_classstring[client], "medic") > -1))
  4834.         g_AIDir_TeamStatus += 2;
  4835.     else
  4836.         g_AIDir_TeamStatus += 1;
  4837.     g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  4838. }
  4839.  
  4840. // Do post revive stuff
  4841. Action RespawnPlayerRevivePost(Handle timer, any client)
  4842. {
  4843.     // Exit if client is not in game
  4844.     if (!IsClientInGame(client)) return;
  4845.    
  4846.     //PrintToServer("[REVIVE_DEBUG] called RespawnPlayerRevivePost for client %N (%d)",client,client);
  4847.     TeleportEntity(client, g_fRagdollPosition[client], NULL_VECTOR, NULL_VECTOR);
  4848.    
  4849.     //Check if player is connected and is alive and player team is security
  4850.     int m_iTeam = GetClientTeam(client);
  4851.     if((IsClientConnected(client)) && (IsPlayerAlive(client)) && m_iTeam == TEAM_1_SEC)
  4852.     {  
  4853.         //Set health 100 percent if resupplying
  4854.         int iHealth = GetClientHealth(client);
  4855.         if (iHealth < 100)
  4856.             SetEntityHealth(client, 100);
  4857.         playerInRevivedState[client] = false;
  4858.     }
  4859.     // Reset ragdoll position
  4860.     g_fRagdollPosition[client][0] = 0.0;
  4861.     g_fRagdollPosition[client][1] = 0.0;
  4862.     g_fRagdollPosition[client][2] = 0.0;
  4863. }
  4864.  
  4865. // Respawn player in counter attack
  4866. Action RespawnPlayerCounter(Handle timer, any client)
  4867. {
  4868.     // Exit if client is not in game
  4869.     if (!IsClientInGame(client)) return;
  4870.     if (IsPlayerAlive(client) || g_iRoundStatus == 0) return;
  4871.    
  4872.     //PrintToServer("[Counter Respawn] Respawning client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
  4873.     // Call forcerespawn fucntion
  4874.     SDKCall(g_hForceRespawn, client);
  4875.  
  4876.     // Get player's ragdoll
  4877.     int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  4878.    
  4879.     //Remove network ragdoll
  4880.     if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  4881.         RemoveRagdoll(client);
  4882.    
  4883.     // If set 'sm_respawn_enable_track_ammo', restore player's ammo
  4884.     // Get the number of control points
  4885.     //new ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  4886.     // Get active push point
  4887.     //new acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  4888.    
  4889.     //Remove grenades if not final
  4890.     //if ((acp+1) != ncp)
  4891.     //RemoveWeapons(client, 0, 0, 1);
  4892.  
  4893.     // Teleport to active counter attack point
  4894.     //PrintToServer("[REVIVE_DEBUG] called RespawnPlayerPost for client %N (%d)",client,client);
  4895.     if (g_fRespawnPosition[0] != 0.0 && g_fRespawnPosition[1] != 0.0 && g_fRespawnPosition[2] != 0.0)
  4896.         TeleportEntity(client, g_fRespawnPosition, NULL_VECTOR, NULL_VECTOR);
  4897.  
  4898.     // Reset ragdoll position
  4899.     g_fRagdollPosition[client][0] = 0.0;
  4900.     g_fRagdollPosition[client][1] = 0.0;
  4901.     g_fRagdollPosition[client][2] = 0.0;
  4902. }
  4903.  
  4904.  
  4905. // Respawn bot
  4906. public Action RespawnBot(Handle timer, any client)
  4907. {
  4908.  
  4909.     // Exit if client is not in game
  4910.     //if (IsPlayerAlive(client) || !IsClientInGame(client) || g_iRoundStatus == 0) return;
  4911.     //if (client > 0 && IsPlayerAlive(client) && GetClientTeam(client) == 2 && owner > 0 && GetClientTeam(owner) == 3)
  4912.    
  4913.     //if (client > 0 && !IsClientInGame(client) || IsPlayerAlive(client) || g_iRoundStatus == 0)
  4914.  
  4915.     if (client <= 0 || client > MaxClients || !IsClientInGame(client) || IsPlayerAlive(client) || g_iRoundStatus == 0) return; 
  4916.     char sModelName[64];
  4917.     GetClientModel(client, sModelName, sizeof(sModelName));
  4918.     if (StrEqual(sModelName, "")) return;  
  4919.    
  4920.     // Check respawn type
  4921.     if (g_iCvar_respawn_type_team_ins == 1 && g_iSpawnTokens[client] > 0)
  4922.         g_iSpawnTokens[client]--;
  4923.     else if (g_iCvar_respawn_type_team_ins == 2)
  4924.     {
  4925.         if (g_iRemaining_lives_team_ins > 0)
  4926.         {
  4927.             g_iRemaining_lives_team_ins--;
  4928.             if (g_iRemaining_lives_team_ins <= 0)
  4929.                 g_iRemaining_lives_team_ins = 0;
  4930.             //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
  4931.         }
  4932.     }
  4933.     //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
  4934.     //PrintToServer("######################TEAM 2 LIVES REMAINING %i", g_iRemaining_lives_team_ins);
  4935.     //PrintToServer("[RESPAWN] Respawning client %N who has %d lives remaining", client, g_iSpawnTokens[client]);
  4936.    
  4937.     // Call forcerespawn function
  4938.    
  4939.     //if (client !=0) SDKCall(g_hForceRespawn, client);
  4940.  
  4941.     //if ((0 >= client || client > MaxClients) || !IsClientInGame(client))
  4942.     if ((0 < client <= MaxClients) || !IsClientInGame(client))
  4943.     {
  4944.        
  4945.         SDKCall(g_hForceRespawn, client);  
  4946.     }
  4947. }
  4948.  
  4949. // Monitor player reload and set ammo after each reload
  4950. Action Timer_ForceReload(Handle timer, any client)
  4951. {
  4952.     bool isReloading = Client_IsReloading(client);
  4953.     int primaryWeapon = GetPlayerWeaponSlot(client, 0);
  4954.     int secondaryWeapon = GetPlayerWeaponSlot(client, 1);
  4955.  
  4956.     if (IsPlayerAlive(client) && g_iRoundStatus == 1 && !isReloading && g_playerActiveWeapon[client] == primaryWeapon)
  4957.     {
  4958.         playerAmmo[client][0] -= 1;
  4959.         SetPlayerAmmo(client);
  4960.         return Plugin_Stop;
  4961.     }
  4962.  
  4963.     if (IsPlayerAlive(client) && g_iRoundStatus == 1 && !isReloading && g_playerActiveWeapon[client] == secondaryWeapon)
  4964.     {
  4965.         playerAmmo[client][1] -= 1;
  4966.         SetPlayerAmmo(client);
  4967.         return Plugin_Stop;
  4968.     }
  4969.     return Plugin_Continue;
  4970. }
  4971.  
  4972. // Player respawn timer
  4973. Action Timer_PlayerRespawn(Handle timer, any client)
  4974. {
  4975.     char sRemainingTime[256];
  4976.  
  4977.     // Exit if client is not in game
  4978.     if (!IsClientInGame(client)) return Plugin_Stop; // empty class name
  4979.     if (!IsPlayerAlive(client) && g_iRoundStatus == 1)
  4980.     {
  4981.         if (g_iRespawnTimeRemaining[client] > 0)
  4982.         {  
  4983.             if (g_playerFirstJoin[client] == 1)
  4984.             {
  4985.                 char woundType[128];
  4986.                 int tIsFatal = false;
  4987.                 if (g_iHurtFatal[client] == 1)
  4988.                 {
  4989.                     woundType = "fatally killed";
  4990.                     tIsFatal = true;
  4991.                 }
  4992.                 else
  4993.                 {
  4994.                     woundType = "WOUNDED";
  4995.                     if (g_playerWoundType[client] == 0)
  4996.                         woundType = "MINORLY WOUNDED";
  4997.                     else if (g_playerWoundType[client] == 1)
  4998.                         woundType = "MODERATELY WOUNDED";
  4999.                     else if (g_playerWoundType[client] == 2)
  5000.                         woundType = "CRITCALLY WOUNDED";
  5001.                 }
  5002.                 // Print remaining time to center text area
  5003.                 if (!IsFakeClient(client))
  5004.                 {
  5005.                     if (tIsFatal)
  5006.                     {
  5007.                         Format(sRemainingTime, sizeof(sRemainingTime),"Reinforcing in %d second%s (%d lives left) ", woundType, g_clientDamageDone[client], g_iRespawnTimeRemaining[client], (g_iRespawnTimeRemaining[client] > 1 ? "s" : ""), g_iSpawnTokens[client]);
  5008.                     }
  5009.                     else
  5010.                     {
  5011.                         Format(sRemainingTime, sizeof(sRemainingTime),"%s for %d damage | wait patiently for a medic\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]);
  5012.                     }
  5013.                     PrintCenterText(client, sRemainingTime);
  5014.                 }
  5015.             }
  5016.            
  5017.             // Decrease respawn remaining time
  5018.             g_iRespawnTimeRemaining[client]--;
  5019.         }
  5020.         else
  5021.         {
  5022.             // Decrease respawn token
  5023.             if (g_iCvar_respawn_type_team_sec == 1)
  5024.                 g_iSpawnTokens[client]--;
  5025.             else if (g_iCvar_respawn_type_team_sec == 2)
  5026.                 g_iRemaining_lives_team_sec--;
  5027.            
  5028.             // Call forcerespawn function
  5029.             SDKCall(g_hForceRespawn, client);
  5030.  
  5031.             //AI Director START
  5032.             if ((StrContains(g_client_last_classstring[client], "medic") > -1))
  5033.                 g_AIDir_TeamStatus += 2;
  5034.             else
  5035.                 g_AIDir_TeamStatus += 1;
  5036.  
  5037.             g_AIDir_TeamStatus = AI_Director_SetMinMax(g_AIDir_TeamStatus, g_AIDir_TeamStatus_min, g_AIDir_TeamStatus_max);
  5038.                
  5039.             //AI Director STOP
  5040.  
  5041.             // Print remaining time to center text area
  5042.             if (!IsFakeClient(client))
  5043.                 PrintCenterText(client, "You reinforced! (%d lives left)", g_iSpawnTokens[client]);
  5044.  
  5045.            
  5046.             bool tSquadSpawned = false;             //Lets confirm squad spawn
  5047.             int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]); // Get ragdoll position
  5048.            
  5049.             // Remove network ragdoll
  5050.             if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  5051.                 RemoveRagdoll(client);
  5052.            
  5053.             // Do the post-spawn stuff like moving to final "spawnpoint" selected
  5054.             //CreateTimer(0.0, RespawnPlayerPost, client);
  5055.             //RespawnPlayerPost(null, client);
  5056.                    
  5057.             // Reset ragdoll position
  5058.             g_fRagdollPosition[client][0] = 0.0;
  5059.             g_fRagdollPosition[client][1] = 0.0;
  5060.             g_fRagdollPosition[client][2] = 0.0;
  5061.  
  5062.             // Announce respawn if not wave based (to avoid spam)
  5063.             if (!g_respawn_mode_team_sec)
  5064.             {
  5065.             if (g_squadSpawnEnabled[client] == 1 && tSquadSpawned == true)
  5066.                     PrintToChatAll("\x05%N\x01 squad-reinforced on %N", client, g_squadLeader[client]);
  5067.                 else
  5068.                     PrintToChatAll("\x05%N\x01 reinforced..", client);
  5069.             }
  5070.             // Reset variable
  5071.             g_iPlayerRespawnTimerActive[client] = 0;
  5072.             return Plugin_Stop;
  5073.         }
  5074.     }
  5075.     else
  5076.     {
  5077.         // Reset variable
  5078.         g_iPlayerRespawnTimerActive[client] = 0;
  5079.         return Plugin_Stop;
  5080.     }
  5081.     return Plugin_Continue;
  5082. }
  5083.  
  5084.  
  5085. // Handles reviving for medics and non-medics
  5086. public Action Timer_ReviveMonitor(Handle timer, any data)
  5087. {
  5088.     // Check round state
  5089.     if (g_iRoundStatus == 0) return Plugin_Continue;
  5090.    
  5091.     // Init variables
  5092.     float fReviveDistance = 65.0;
  5093.     int iInjured;
  5094.     int iInjuredRagdoll;
  5095.     float fRagPos[3];
  5096.     float fMedicPos[3];
  5097.     float fDistance;
  5098.    
  5099.     // Search medics
  5100.     for (int iMedic = 1; iMedic <= MaxClients; iMedic++)
  5101.     {
  5102.         if (!IsClientInGame(iMedic) || IsFakeClient(iMedic))
  5103.             continue;
  5104.        
  5105.         // Is valid iMedic?
  5106.         if (IsPlayerAlive(iMedic) && (StrContains(g_client_last_classstring[iMedic], "medic") > -1))
  5107.         {
  5108.             // Check is there nearest body
  5109.             iInjured = g_iNearestBody[iMedic];
  5110.            
  5111.             // Valid nearest body
  5112.             if (iInjured > 0 && IsClientInGame(iInjured) && !IsPlayerAlive(iInjured) && g_iHurtFatal[iInjured] == 0
  5113.                 && iInjured != iMedic && GetClientTeam(iMedic) == GetClientTeam(iInjured))
  5114.             {
  5115.                 // Get found medic position
  5116.                 GetClientAbsOrigin(iMedic, fMedicPos);
  5117.                
  5118.                 // Get player's entity index
  5119.                 iInjuredRagdoll = EntRefToEntIndex(g_iClientRagdolls[iInjured]);
  5120.                
  5121.                 // Check ragdoll is valid
  5122.                 if(iInjuredRagdoll > 0 && iInjuredRagdoll != INVALID_ENT_REFERENCE
  5123.                     && IsValidEdict(iInjuredRagdoll) && IsValidEntity(iInjuredRagdoll))
  5124.                 {
  5125.                     // Get player's ragdoll position
  5126.                     GetEntPropVector(iInjuredRagdoll, Prop_Send, "m_vecOrigin", fRagPos);
  5127.                    
  5128.                     // Update ragdoll position
  5129.                     g_fRagdollPosition[iInjured] = fRagPos;
  5130.                    
  5131.                     // Get distance from iMedic
  5132.                     fDistance = GetVectorDistance(fRagPos,fMedicPos);
  5133.                 }
  5134.                 else
  5135.                     // Ragdoll is not valid
  5136.                     continue;
  5137.                
  5138.                 // Jareds pistols only code to verify iMedic is carrying knife
  5139.                 int ActiveWeapon = GetEntPropEnt(iMedic, Prop_Data, "m_hActiveWeapon");
  5140.                 if (ActiveWeapon < 0)
  5141.                     continue;
  5142.                
  5143.                 // Get weapon class name
  5144.                 char sWeapon[32];
  5145.                 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5146.                 //PrintToServer("[KNIFE ONLY] CheckWeapon for iMedic %d named %N ActiveWeapon %d sWeapon %s",iMedic,iMedic,ActiveWeapon,sWeapon);
  5147.                
  5148.                 // If iMedic can see ragdoll and using defib or knife
  5149.                 if (fDistance < fReviveDistance && (ClientCanSeeVector(iMedic, fRagPos, fReviveDistance))
  5150.                     && ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
  5151.                 )
  5152.                 {
  5153.                     //PrintToServer("[REVIVE_DEBUG] Distance from %N to %N is %f Seconds %d", iInjured, iMedic, fDistance, g_iReviveRemainingTime[iInjured]);      
  5154.                     char sBuf[255];
  5155.                    
  5156.                     // Need more time to revive
  5157.                     if (g_iReviveRemainingTime[iInjured] > 0)
  5158.                     {
  5159.  
  5160.                         char woundType[64];
  5161.                         if (g_playerWoundType[iInjured] == 0)
  5162.                             woundType = "Minor wound";
  5163.                         else if (g_playerWoundType[iInjured] == 1)
  5164.                             woundType = "Moderate wound";
  5165.                         else if (g_playerWoundType[iInjured] == 2)
  5166.                             woundType = "Critical wound";
  5167.  
  5168.                         // Hint to iMedic
  5169.                         Format(sBuf, 255,"Reviving %N in: %i seconds (%s)", iInjured, g_iReviveRemainingTime[iInjured], woundType);
  5170.                         PrintHintText(iMedic, "%s", sBuf);
  5171.                        
  5172.                         // Hint to victim
  5173.                         Format(sBuf, 255,"%N is reviving you in: %i seconds (%s)", iMedic, g_iReviveRemainingTime[iInjured], woundType);
  5174.                         PrintHintText(iInjured, "%s", sBuf);
  5175.                        
  5176.                         // Decrease revive remaining time
  5177.                         g_iReviveRemainingTime[iInjured]--;
  5178.                        
  5179.                         //prevent respawn while reviving
  5180.                         g_iRespawnTimeRemaining[iInjured]++;
  5181.                     }
  5182.                     // Revive player
  5183.                     else if (g_iReviveRemainingTime[iInjured] <= 0)
  5184.                     {  
  5185.                         char woundType[64];
  5186.                         if (g_playerWoundType[iInjured] == 0)
  5187.                             woundType = "minor wound";
  5188.                         else if (g_playerWoundType[iInjured] == 1)
  5189.                             woundType = "moderate wound";
  5190.                         else if (g_playerWoundType[iInjured] == 2)
  5191.                             woundType = "critical wound";
  5192.  
  5193.                         // Chat to all
  5194.                         //Format(sBuf, 255,"\x05%N\x01 revived \x03%N from a %s", iMedic, iInjured, woundType);
  5195.                         //PrintToChatAll("%s", sBuf);
  5196.                        
  5197.                         // Hint to iMedic
  5198.                         Format(sBuf, 255,"You revived %N from a %s", iInjured, woundType);
  5199.                         PrintHintText(iMedic, "%s", sBuf);
  5200.                        
  5201.                         // Hint to victim
  5202.                         Format(sBuf, 255,"%N revived you from a %s", iMedic, woundType);
  5203.                         PrintHintText(iInjured, "%s", sBuf);
  5204.                         g_iStatRevives[iMedic]++;
  5205.            
  5206.                         //Accumulate a revive
  5207.                         g_playerMedicRevivessAccumulated[iMedic]++;
  5208.                         int iReviveCap = sm_revive_cap_for_bonus.IntValue;
  5209.  
  5210.                         // Hint to iMedic
  5211.                         Format(sBuf, 255,"You revived %N from a %s | Revives remaining til bonus life: %d", iInjured, woundType, (iReviveCap - g_playerMedicRevivessAccumulated[iMedic]));
  5212.                         PrintHintText(iMedic, "%s", sBuf);
  5213.                         if (g_playerMedicRevivessAccumulated[iMedic] >= iReviveCap)
  5214.                         {
  5215.                             g_playerMedicRevivessAccumulated[iMedic] = 0;
  5216.                             g_iSpawnTokens[iMedic]++;
  5217.                         }
  5218.  
  5219.                         // Update ragdoll position
  5220.                         g_fRagdollPosition[iInjured] = fRagPos;
  5221.                        
  5222.                         // Reset revive counter
  5223.                         playerRevived[iInjured] = true;
  5224.                        
  5225.                         // Call revive function
  5226.                         g_playerNonMedicRevive[iInjured] = 0;
  5227.                         CreateReviveTimer(iInjured);
  5228.                         continue;
  5229.                     }
  5230.                 }
  5231.             }
  5232.         }
  5233.         //Non Medics with Medic Pack
  5234.         else if (IsPlayerAlive(iMedic) && !(StrContains(g_client_last_classstring[iMedic], "medic") > -1))
  5235.         {
  5236.             //PrintToServer("Non-Medic Reviving..");
  5237.             // Check is there nearest body
  5238.             iInjured = g_iNearestBody[iMedic];
  5239.            
  5240.             // Valid nearest body
  5241.             if (iInjured > 0 && IsClientInGame(iInjured) && !IsPlayerAlive(iInjured) && g_iHurtFatal[iInjured] == 0
  5242.                 && iInjured != iMedic && GetClientTeam(iMedic) == GetClientTeam(iInjured))
  5243.             {
  5244.                 // Get found medic position
  5245.                 GetClientAbsOrigin(iMedic, fMedicPos);
  5246.                
  5247.                 // Get player's entity index
  5248.                 iInjuredRagdoll = EntRefToEntIndex(g_iClientRagdolls[iInjured]);
  5249.                
  5250.                 // Check ragdoll is valid
  5251.                 if(iInjuredRagdoll > 0 && iInjuredRagdoll != INVALID_ENT_REFERENCE
  5252.                     && IsValidEdict(iInjuredRagdoll) && IsValidEntity(iInjuredRagdoll))
  5253.                 {
  5254.                     // Get player's ragdoll position
  5255.                     GetEntPropVector(iInjuredRagdoll, Prop_Send, "m_vecOrigin", fRagPos);
  5256.                    
  5257.                     // Update ragdoll position
  5258.                     g_fRagdollPosition[iInjured] = fRagPos;
  5259.                    
  5260.                     // Get distance from iMedic
  5261.                     fDistance = GetVectorDistance(fRagPos,fMedicPos);
  5262.                 }
  5263.                 else
  5264.                     // Ragdoll is not valid
  5265.                     continue;
  5266.                
  5267.                 // Jareds pistols only code to verify iMedic is carrying knife
  5268.                 int ActiveWeapon = GetEntPropEnt(iMedic, Prop_Data, "m_hActiveWeapon");
  5269.                 if (ActiveWeapon < 0)
  5270.                     continue;
  5271.                
  5272.                 // Get weapon class name
  5273.                 char sWeapon[32];
  5274.                 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5275.                 //PrintToServer("[KNIFE ONLY] CheckWeapon for iMedic %d named %N ActiveWeapon %d sWeapon %s",iMedic,iMedic,ActiveWeapon,sWeapon);
  5276.                
  5277.                 // If NON Medic can see ragdoll and using healthkit
  5278.                 if (fDistance < fReviveDistance && (ClientCanSeeVector(iMedic, fRagPos, fReviveDistance))
  5279.                     && ((StrContains(sWeapon, "weapon_healthkit") > -1)))
  5280.                 {
  5281.                     //PrintToServer("[REVIVE_DEBUG] Distance from %N to %N is %f Seconds %d", iInjured, iMedic, fDistance, g_iReviveNonMedicRemainingTime[iInjured]);      
  5282.                     char sBuf[255];
  5283.                    
  5284.                     // Need more time to reviving
  5285.                     if (g_iReviveNonMedicRemainingTime[iInjured] > 0)
  5286.                     {
  5287.  
  5288.                         //PrintToServer("NONMEDIC HAS TIME");
  5289.                         if (g_playerWoundType[iInjured] == 0 || g_playerWoundType[iInjured] == 1 || g_playerWoundType[iInjured] == 2)
  5290.                         {
  5291.                             char woundType[64];
  5292.                             if (g_playerWoundType[iInjured] == 0)
  5293.                                 woundType = "Minor wound";
  5294.                             else if (g_playerWoundType[iInjured] == 1)
  5295.                                 woundType = "Moderate wound";
  5296.                             else if (g_playerWoundType[iInjured] == 2)
  5297.                                 woundType = "Critical wound";
  5298.                             // Hint to NonMedic
  5299.                             Format(sBuf, 255,"Reviving %N in: %i seconds (%s)", iInjured, g_iReviveNonMedicRemainingTime[iInjured], woundType);
  5300.                             PrintHintText(iMedic, "%s", sBuf);
  5301.                            
  5302.                             // Hint to victim
  5303.                             Format(sBuf, 255,"%N is reviving you in: %i seconds (%s)", iMedic, g_iReviveNonMedicRemainingTime[iInjured], woundType);
  5304.                             PrintHintText(iInjured, "%s", sBuf);
  5305.                            
  5306.                             // Decrease revive remaining time
  5307.                             g_iReviveNonMedicRemainingTime[iInjured]--;
  5308.                         }
  5309.  
  5310.                         //prevent respawn while reviving
  5311.                         g_iRespawnTimeRemaining[iInjured]++;
  5312.                     }
  5313.  
  5314.                     // Revive player
  5315.                     else if (g_iReviveNonMedicRemainingTime[iInjured] <= 0)
  5316.                     {  
  5317.                         char woundType[64];
  5318.                         if (g_playerWoundType[iInjured] == 0)
  5319.                             woundType = "minor wound";
  5320.                         else if (g_playerWoundType[iInjured] == 1)
  5321.                             woundType = "moderate wound";
  5322.                         else if (g_playerWoundType[iInjured] == 2)
  5323.                             woundType = "critical wound";
  5324.  
  5325.                         // Chat to all
  5326.                         Format(sBuf, 255,"\x05%N\x01 revived \x03%N from a %s", iMedic, iInjured, woundType);
  5327.                         //PrintToChatAll("%s", sBuf);
  5328.                        
  5329.                         // Hint to iMedic
  5330.                         Format(sBuf, 255,"You revived %N from a %s", iInjured, woundType);
  5331.                         PrintHintText(iMedic, "%s", sBuf);
  5332.                        
  5333.                         // Hint to victim
  5334.                         Format(sBuf, 255,"%N revived you from a %s", iMedic, woundType);
  5335.                         PrintHintText(iInjured, "%s", sBuf);
  5336.                        
  5337.                         // Add kill bonus to iMedic
  5338.                         int iBonus = sm_revive_bonus.IntValue;
  5339.                         int iScore = GetClientFrags(iMedic) + iBonus;
  5340.                         SetEntProp(iMedic, Prop_Data, "m_iFrags", iScore);
  5341.                        
  5342.                         // Rank System
  5343.                         g_iStatRevives[iMedic]++;
  5344.                        
  5345.                         //Accumulate a revive
  5346.                         g_playerMedicRevivessAccumulated[iMedic]++;
  5347.                         int iReviveCap = sm_revive_cap_for_bonus.IntValue;
  5348.  
  5349.                         // Hint to iMedic
  5350.                         if (g_playerMedicRevivessAccumulated[iMedic] >= iReviveCap)
  5351.                         {
  5352.                             g_playerMedicRevivessAccumulated[iMedic] = 0;
  5353.                             g_iSpawnTokens[iMedic]++;
  5354.                         }
  5355.  
  5356.                        
  5357.                         // Update ragdoll position
  5358.                         g_fRagdollPosition[iInjured] = fRagPos;
  5359.                        
  5360.                         //Reward nearby medics who asssisted
  5361.                         //Check_NearbyMedicsRevive(iMedic, iInjured);
  5362.  
  5363.                         // Reset revive counter
  5364.                         playerRevived[iInjured] = true;
  5365.                        
  5366.                         g_playerNonMedicRevive[iInjured] = 1;
  5367.                         // Call revive function
  5368.                         CreateReviveTimer(iInjured);
  5369.                         RemovePlayerItem(iMedic,ActiveWeapon);
  5370.                         //Switch to knife after removing kit
  5371.                         ChangePlayerWeaponSlot(iMedic, 2);
  5372.                         //PrintToServer("##########PLAYER REVIVED %s ############", playerRevived[iInjured]);
  5373.                         continue;
  5374.                     }
  5375.                 }
  5376.             }
  5377.         }
  5378.     }
  5379.     return Plugin_Continue;
  5380. }
  5381.  
  5382. // Handles medic functions (Inspecting health, healing)
  5383. public Action Timer_MedicMonitor(Handle timer, any data)
  5384. {
  5385.     // Check round state
  5386.     if (g_iRoundStatus == 0) return Plugin_Continue;
  5387.    
  5388.     // Search medics
  5389.     for(int medic = 1; medic <= MaxClients; medic++)
  5390.     {
  5391.         if (!IsClientInGame(medic) || IsFakeClient(medic)) continue;
  5392.        
  5393.        
  5394.         // Medic only can inspect health.
  5395.         int iTeam = GetClientTeam(medic);
  5396.         if (iTeam == TEAM_1_SEC && IsPlayerAlive(medic) && StrContains(g_client_last_classstring[medic], "medic") > -1)
  5397.         {
  5398.             // Target is teammate and alive.
  5399.             int iTarget = TraceClientViewEntity(medic);
  5400.             if(iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget) && iTeam == GetClientTeam(iTarget))
  5401.             {
  5402.                 // Check distance
  5403.                 bool bCanHealPaddle = false;
  5404.                 bool bCanHealMedpack = false;
  5405.                 float fReviveDistance = 80.0;
  5406.                 float vecMedicPos[3];
  5407.                 float vecTargetPos[3];
  5408.                 float tDistance;
  5409.                 GetClientAbsOrigin(medic, vecMedicPos);
  5410.                 GetClientAbsOrigin(iTarget, vecTargetPos);
  5411.                 tDistance = GetVectorDistance(vecMedicPos,vecTargetPos);
  5412.                
  5413.                 if (tDistance < fReviveDistance && ClientCanSeeVector(medic, vecTargetPos, fReviveDistance))
  5414.                 {
  5415.                     // Check weapon
  5416.                     int ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
  5417.                     if (ActiveWeapon < 0)
  5418.                         continue;
  5419.                     char sWeapon[32];
  5420.                     GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5421.                    
  5422.                     if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
  5423.                     {
  5424.                         bCanHealPaddle = true;
  5425.                     }
  5426.                     if ((StrContains(sWeapon, "weapon_healthkit") > -1))
  5427.                     {
  5428.                         bCanHealMedpack = true;
  5429.                     }
  5430.                 }
  5431.  
  5432.                 // Check heal
  5433.                 int iHealth = GetClientHealth(iTarget);
  5434.  
  5435.                 if (tDistance < 750.0)
  5436.                 {
  5437.                     PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
  5438.                 }
  5439.  
  5440.                 if (bCanHealPaddle)
  5441.                 {
  5442.                     if (iHealth < 100)
  5443.                     {
  5444.                         iHealth += g_iHeal_amount_paddles;
  5445.                         g_playerMedicHealsAccumulated[medic] += g_iHeal_amount_paddles;
  5446.                         int iHealthCap = sm_heal_cap_for_bonus.IntValue;
  5447.                         int iRewardMedicEnabled = sm_reward_medics_enabled.IntValue;
  5448.  
  5449.                         //Reward player for healing
  5450.                         if (g_playerMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
  5451.                         {
  5452.                             g_playerMedicHealsAccumulated[medic] = 0;
  5453.                             g_iSpawnTokens[medic]++;
  5454.                         }
  5455.                        
  5456.                         if (iHealth >= 100)
  5457.                         {
  5458.                             g_iStatHeals[medic]++;
  5459.                             iHealth = 100;
  5460.                             PrintHintText(iTarget, "You were healed by %N (HP: %i)", medic, iHealth);
  5461.                             char sBuf[255];
  5462.                             Format(sBuf, 255,"You fully healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerMedicHealsAccumulated[medic]));
  5463.                             PrintHintText(medic, "%s", sBuf);
  5464.                         }
  5465.                         else
  5466.                         {
  5467.                             PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
  5468.                         }
  5469.                        
  5470.                         SetEntityHealth(iTarget, iHealth);
  5471.                         PrintHintText(medic, "%N\nHP: %i\n\nHealing with paddles for: %i", iTarget, iHealth, g_iHeal_amount_paddles);
  5472.                     }
  5473.                     else
  5474.                     {
  5475.                         PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
  5476.                     }
  5477.                 }
  5478.                 else if (bCanHealMedpack)
  5479.                 {
  5480.                     if (iHealth < 100)
  5481.                     {
  5482.                         iHealth += g_iHeal_amount_medPack;
  5483.                         g_playerMedicHealsAccumulated[medic] += g_iHeal_amount_medPack;
  5484.                         int iHealthCap = sm_heal_cap_for_bonus.IntValue;
  5485.                         int iRewardMedicEnabled = sm_reward_medics_enabled.IntValue;
  5486.                         //Reward player for healing
  5487.                         if (g_playerMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
  5488.                         {
  5489.                             g_playerMedicHealsAccumulated[medic] = 0;
  5490.                             g_iSpawnTokens[medic]++;
  5491.                         }
  5492.                         if (iHealth >= 100)
  5493.                         {
  5494.                             g_iStatHeals[medic]++;
  5495.                             iHealth = 100;
  5496.                             PrintHintText(iTarget, "You were healed by %N (HP: %i)", medic, iHealth);
  5497.                             char sBuf[255];
  5498.                             Format(sBuf, 255,"You fully healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerMedicHealsAccumulated[medic]));
  5499.                             PrintHintText(medic, "%s", sBuf);
  5500.                         }
  5501.                         else
  5502.                         {
  5503.                             PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
  5504.                         }
  5505.                         SetEntityHealth(iTarget, iHealth);
  5506.                         PrintHintText(medic, "%N\nHP: %i\n\nHealing with medpack for: %i", iTarget, iHealth, g_iHeal_amount_medPack);
  5507.                     }
  5508.                     else
  5509.                     {
  5510.                         PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
  5511.                     }
  5512.                 }
  5513.             }
  5514.             else //Heal Self
  5515.             {
  5516.                 // Check distance
  5517.                 bool bCanHealMedpack = false;
  5518.                 bool bCanHealPaddle = false;
  5519.                
  5520.                 // Check weapon
  5521.                 int ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
  5522.                 if (ActiveWeapon < 0) continue;
  5523.                 char sWeapon[32];
  5524.                 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5525.  
  5526.                 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))
  5527.                 {
  5528.                     bCanHealPaddle = true;
  5529.                 }
  5530.                 if ((StrContains(sWeapon, "weapon_healthkit") > -1))
  5531.                 {
  5532.                     bCanHealMedpack = true;
  5533.                 }
  5534.                
  5535.                 // Check heal
  5536.                 int iHealth = GetClientHealth(medic);
  5537.                 if (bCanHealMedpack || bCanHealPaddle)
  5538.                 {
  5539.                     if (iHealth < g_medicHealSelf_max)
  5540.                     {
  5541.                         if (bCanHealMedpack)
  5542.                             iHealth += g_iHeal_amount_medPack;
  5543.                         else
  5544.                             iHealth += g_iHeal_amount_paddles;
  5545.  
  5546.                         if (iHealth >= g_medicHealSelf_max)
  5547.                         {
  5548.                             iHealth = g_medicHealSelf_max;
  5549.                             PrintHintText(medic, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
  5550.                         }
  5551.                         else
  5552.                         {
  5553.                             PrintHintText(medic, "Healing Self (HP: %i) | MAX: %i", iHealth, g_medicHealSelf_max);
  5554.                         }
  5555.                         SetEntityHealth(medic, iHealth);
  5556.                     }
  5557.                 }
  5558.             }
  5559.         }
  5560.         else if (iTeam == TEAM_1_SEC && IsPlayerAlive(medic) && !(StrContains(g_client_last_classstring[medic], "medic") > -1))
  5561.         {
  5562.             // Check weapon for non medics outside
  5563.             int ActiveWeapon = GetEntPropEnt(medic, Prop_Data, "m_hActiveWeapon");
  5564.             if (ActiveWeapon < 0)
  5565.                 continue;
  5566.             char checkWeapon[32];
  5567.             GetEdictClassname(ActiveWeapon, checkWeapon, sizeof(checkWeapon));
  5568.             if ((StrContains(checkWeapon, "weapon_healthkit") > -1))
  5569.             {
  5570.                 // Target is teammate and alive.
  5571.                 int iTarget = TraceClientViewEntity(medic);
  5572.                 if(iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget) && iTeam == GetClientTeam(iTarget))
  5573.                 {
  5574.                     // Check distance
  5575.                     bool bCanHealMedpack = false;
  5576.                     float fReviveDistance = 80.0;
  5577.                     float vecMedicPos[3];
  5578.                     float vecTargetPos[3];
  5579.                     float tDistance;
  5580.                     GetClientAbsOrigin(medic, vecMedicPos);
  5581.                     GetClientAbsOrigin(iTarget, vecTargetPos);
  5582.                     tDistance = GetVectorDistance(vecMedicPos,vecTargetPos);
  5583.                    
  5584.                     if (tDistance < fReviveDistance && ClientCanSeeVector(medic, vecTargetPos, fReviveDistance))
  5585.                     {
  5586.                         // Check weapon
  5587.                         if (ActiveWeapon < 0) continue;
  5588.                         char sWeapon[32];
  5589.                         GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5590.                         if ((StrContains(sWeapon, "weapon_healthkit") > -1))
  5591.                             bCanHealMedpack = true;
  5592.                     }
  5593.                     // Check heal
  5594.                     int iHealth = GetClientHealth(iTarget);
  5595.                     if (tDistance < 750.0)
  5596.                         PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
  5597.                     if (bCanHealMedpack)
  5598.                     {
  5599.                         if (iHealth < g_nonMedic_maxHealOther)
  5600.                         {
  5601.                             iHealth += g_nonMedicHeal_amount;
  5602.                             g_playerNonMedicHealsAccumulated[medic] += g_nonMedicHeal_amount;
  5603.                             int iHealthCap = sm_heal_cap_for_bonus.IntValue;
  5604.                             int iRewardMedicEnabled = sm_reward_medics_enabled.IntValue;
  5605.                             //Reward player for healing
  5606.                             if (g_playerNonMedicHealsAccumulated[medic] >= iHealthCap && iRewardMedicEnabled == 1)
  5607.                             {
  5608.                                 g_playerNonMedicHealsAccumulated[medic] = 0;
  5609.                                 g_iSpawnTokens[medic]++;
  5610.                             }
  5611.  
  5612.                             if (iHealth >= g_nonMedic_maxHealOther)
  5613.                             {
  5614.                                 g_iStatHeals[medic]++;
  5615.                                 iHealth = g_nonMedic_maxHealOther;
  5616.                                 PrintHintText(iTarget, "Non-Medic %N can only heal you for %i HP!)", medic, iHealth);
  5617.                                 char sBuf[255];
  5618.                                 Format(sBuf, 255,"You max healed %N | Health points remaining til bonus life: %d", iTarget, (iHealthCap - g_playerNonMedicHealsAccumulated[medic]));
  5619.                                 PrintHintText(medic, "%s", sBuf);
  5620.                             }
  5621.                             else
  5622.                             {
  5623.                                 PrintHintText(iTarget, "DON'T MOVE! %N is healing you.(HP: %i)", medic, iHealth);
  5624.                             }
  5625.                             SetEntityHealth(iTarget, iHealth);
  5626.                             PrintHintText(medic, "%N\nHP: %i\n\nHealing.", iTarget, iHealth);
  5627.                         }
  5628.                         else
  5629.                         {
  5630.                             if (iHealth < g_nonMedic_maxHealOther)
  5631.                             {
  5632.                                 PrintHintText(medic, "%N\nHP: %i", iTarget, iHealth);
  5633.                             }
  5634.                             else if (iHealth >= g_nonMedic_maxHealOther)
  5635.                                 PrintHintText(medic, "%N\nHP: %i (MAX YOU CAN HEAL)", iTarget, iHealth);
  5636.                         }
  5637.                     }
  5638.                 }
  5639.                 else //Heal Self
  5640.                 {
  5641.                     // Check distance
  5642.                     bool bCanHealMedpack = false;
  5643.                    
  5644.                     // Check weapon
  5645.                     if (ActiveWeapon < 0) continue;
  5646.                     char sWeapon[32];
  5647.                     GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5648.                     if ((StrContains(sWeapon, "weapon_healthkit") > -1))
  5649.                         bCanHealMedpack = true;
  5650.  
  5651.                     // Check heal
  5652.                     int iHealth = GetClientHealth(medic);
  5653.                     if (bCanHealMedpack)
  5654.                     {
  5655.                         if (iHealth < g_nonMedicHealSelf_max)
  5656.                         {
  5657.                             iHealth += g_nonMedicHeal_amount;
  5658.                             if (iHealth >= g_nonMedicHealSelf_max)
  5659.                             {
  5660.                                 iHealth = g_nonMedicHealSelf_max;
  5661.                                 PrintHintText(medic, "You healed yourself (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
  5662.                             }
  5663.                             else
  5664.                             {
  5665.                                 PrintHintText(medic, "Healing Self (HP: %i) | MAX: %i", iHealth, g_nonMedicHealSelf_max);
  5666.                             }
  5667.                            
  5668.                             SetEntityHealth(medic, iHealth);
  5669.                         }
  5670.                     }
  5671.                 }
  5672.             }
  5673.         }
  5674.     }
  5675.     return Plugin_Continue;
  5676. }
  5677.  
  5678. //Main AI Director Tick
  5679. public Action Timer_AIDirector_Main(Handle timer, any data)
  5680. {
  5681.     g_AIDir_AnnounceCounter++;
  5682.     g_AIDir_ChangeCond_Counter++;
  5683.     g_AIDir_AmbushCond_Counter++;
  5684.    
  5685.     //Ambush Reinforcement Chance
  5686.     int tAmbushChance = GetRandomInt(0, 100);
  5687.  
  5688.     //AI Director Set Difficulty
  5689.     if (g_AIDir_ChangeCond_Counter >= g_AIDir_ChangeCond_Rand)
  5690.     {
  5691.         g_AIDir_ChangeCond_Counter = 0;
  5692.         g_AIDir_ChangeCond_Rand = GetRandomInt(g_AIDir_ChangeCond_Min, g_AIDir_ChangeCond_Max);
  5693.         //PrintToServer("[AI_DIRECTOR] STATUS: %i | SetDifficulty CALLED", g_AIDir_TeamStatus);
  5694.         AI_Director_SetDifficulty();
  5695.     }
  5696.  
  5697.     if (g_AIDir_AmbushCond_Counter >= g_AIDir_AmbushCond_Rand)
  5698.     {
  5699.         if (tAmbushChance <= g_AIDir_AmbushCond_Chance)
  5700.         {
  5701.             g_AIDir_AmbushCond_Counter = 0;
  5702.             g_AIDir_AmbushCond_Rand = GetRandomInt(g_AIDir_AmbushCond_Min, g_AIDir_AmbushCond_Max);
  5703.             AI_Director_RandomEnemyReinforce();
  5704.         }
  5705.         else
  5706.         {
  5707.             //PrintToServer("[AI_DIRECTOR]: tAmbushChance: %d | g_AIDir_AmbushCond_Chance %d", tAmbushChance, g_AIDir_AmbushCond_Chance);
  5708.             //Reset
  5709.             g_AIDir_AmbushCond_Counter = 0;
  5710.             g_AIDir_AmbushCond_Rand = GetRandomInt(g_AIDir_AmbushCond_Min, g_AIDir_AmbushCond_Max);
  5711.         }
  5712.     }
  5713.  
  5714.     // Get the number of control points
  5715.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  5716.     // Get active push point
  5717.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  5718.    
  5719.     //Confirm percent finale
  5720.     if ((acp+1) == ncp)
  5721.     {
  5722.         if (g_finale_counter_spec_enabled == 1)
  5723.                 g_dynamicSpawnCounter_Perc = g_finale_counter_spec_percent;
  5724.     }
  5725.     return Plugin_Continue;
  5726. }
  5727.  
  5728.  
  5729. public Action Timer_AmmoResupply(Handle timer, any data) {
  5730.     if (g_iRoundStatus == 0) {
  5731.         return Plugin_Continue;
  5732.     }
  5733.     for (int client = 1; client <= MaxClients; client++) {
  5734.         if (!IsClientInGame(client) || IsFakeClient(client)) {
  5735.             continue;
  5736.         }
  5737.         int team = GetClientTeam(client);
  5738.         // Valid medic?
  5739.         if (IsPlayerAlive(client) && team == TEAM_1_SEC) {
  5740.             int ActiveWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
  5741.             if (ActiveWeapon < 0) {
  5742.                 continue;
  5743.             }
  5744.  
  5745.             // Get weapon class name
  5746.             char sWeapon[32];
  5747.             GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  5748.             //if (GetClientButtons(client) & //INS_RELOAD  && ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)))
  5749.             if (((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1))) {
  5750.                 int validAmmoCache = -1;
  5751.                 validAmmoCache = FindValidProp_InDistance(client);
  5752.                 //PrintToServer("validAmmoCache: %d", validAmmoCache);
  5753.                 if (validAmmoCache != -1) {
  5754.                     g_resupplyCounter[client] -= 1;
  5755.                     if (g_ammoResupplyAmt[validAmmoCache] <= 0) {
  5756.                         int secTeamCount = GetTeamSecCount();
  5757.                         g_ammoResupplyAmt[validAmmoCache] = (secTeamCount / 6);
  5758.                         if (g_ammoResupplyAmt[validAmmoCache] <= 1) {
  5759.                             g_ammoResupplyAmt[validAmmoCache] = 1;
  5760.                         }
  5761.  
  5762.                     }
  5763.                     char sBuf[255];
  5764.                     // Hint to client
  5765.                     Format(sBuf, 255,"Resupplying ammo in %d seconds | Supply left: %d", g_resupplyCounter[client], g_ammoResupplyAmt[validAmmoCache]);
  5766.                     PrintHintText(client, "%s", sBuf);
  5767.                     if (g_resupplyCounter[client] <= 0) {
  5768.                         g_resupplyCounter[client] = sm_resupply_delay.IntValue;
  5769.                         //Spawn player again
  5770.                         AmmoResupply_Player(client, 0, 0, 0);
  5771.  
  5772.  
  5773.                         g_ammoResupplyAmt[validAmmoCache] -= 1;
  5774.                         if (g_ammoResupplyAmt[validAmmoCache] <= 0) {
  5775.                             if (validAmmoCache != -1) {
  5776.                                 AcceptEntityInput(validAmmoCache, "kill");
  5777.                             }
  5778.                         }
  5779.                         Format(sBuf, 255,"Rearmed! Ammo Supply left: %d", g_ammoResupplyAmt[validAmmoCache]);
  5780.  
  5781.                         PrintHintText(client, "%s", sBuf);
  5782.                         PrintToChat(client, "%s", sBuf);
  5783.  
  5784.                     }
  5785.                 }
  5786.             }
  5787.         }
  5788.     }
  5789.     return Plugin_Continue;
  5790. }
  5791.  
  5792. /*public void AmmoResupply_Player(int client, int primaryRemove, int secondaryRemove, int grenadesRemove) {
  5793.  
  5794.     float plyrOrigin[3];
  5795.     float tempOrigin[3];
  5796.     GetClientAbsOrigin(client, plyrOrigin);
  5797.     tempOrigin = plyrOrigin;
  5798.     tempOrigin[2] = -5000.0;
  5799.  
  5800.     //TeleportEntity(client, tempOrigin, NULL_VECTOR, NULL_VECTOR);
  5801.     //ForcePlayerSuicide(client);
  5802.     // Get dead body
  5803.     int clientRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  5804.  
  5805.     //This timer safely removes client-side ragdoll
  5806.     if (clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll)) {
  5807.         // Get dead body's entity
  5808.         int ref = EntIndexToEntRef(clientRagdoll);
  5809.         int entity = EntRefToEntIndex(ref);
  5810.         if (entity != INVALID_ENT_REFERENCE && IsValidEntity(entity)) {
  5811.             // Remove dead body's entity
  5812.             AcceptEntityInput(entity, "Kill");
  5813.             clientRagdoll = INVALID_ENT_REFERENCE;
  5814.         }
  5815.     }
  5816.  
  5817.     ForceRespawnPlayer(client, client);
  5818.     TeleportEntity(client, plyrOrigin, NULL_VECTOR, NULL_VECTOR);
  5819.     RemoveWeapons(client, primaryRemove, secondaryRemove, grenadesRemove);
  5820.     PrintHintText(client, "Ammo Resupplied");
  5821.     playerInRevivedState[client] = false;
  5822.     // //Give back life
  5823.     // new iDeaths = GetClientDeaths(client) - 1;
  5824.     // SetEntProp(client, Prop_Data, "m_iDeaths", iDeaths);
  5825. }*/
  5826.  
  5827. //Find Valid Prop
  5828. public void RemoveWeapons(int client, int primaryRemove, int secondaryRemove, int grenadesRemove)
  5829. {
  5830.  
  5831.     int primaryWeapon = GetPlayerWeaponSlot(client, 0);
  5832.     int secondaryWeapon = GetPlayerWeaponSlot(client, 1);
  5833.     int playerGrenades = GetPlayerWeaponSlot(client, 3);
  5834.  
  5835.     // Check and remove primaryWeapon
  5836.     // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
  5837.     if (primaryWeapon != -1 && IsValidEntity(primaryWeapon) && primaryRemove == 1)  
  5838.     {
  5839.         // Remove primaryWeapon
  5840.         char weapon[32];
  5841.         GetEntityClassname(primaryWeapon, weapon, sizeof(weapon));
  5842.         RemovePlayerItem(client, primaryWeapon);
  5843.         AcceptEntityInput(primaryWeapon, "kill");
  5844.     }
  5845.     // Check and remove secondaryWeapon
  5846.     // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
  5847.     if (secondaryWeapon != -1 && IsValidEntity(secondaryWeapon) && secondaryRemove == 1)  
  5848.     {
  5849.         // Remove primaryWeapon
  5850.         char weapon[32];
  5851.         GetEntityClassname(secondaryWeapon, weapon, sizeof(weapon));
  5852.         RemovePlayerItem(client, secondaryWeapon);
  5853.         AcceptEntityInput(secondaryWeapon, "kill");
  5854.     }
  5855.     // Check and remove grenades
  5856.     // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 13
  5857.     if (playerGrenades != -1 && IsValidEntity(playerGrenades) && grenadesRemove == 1)  
  5858.     {
  5859.         // since we only have 3 slots in current theate
  5860.         while (playerGrenades != -1 && IsValidEntity(playerGrenades))  
  5861.         {
  5862.             playerGrenades = GetPlayerWeaponSlot(client, 3);
  5863.             // We need to figure out what slots are defined#define Slot_HEgrenade 11, #define Slot_Flashbang 12, #define Slot_Smokegrenade 1
  5864.             if (playerGrenades != -1 && IsValidEntity(playerGrenades))  
  5865.             {
  5866.                 // Remove grenades
  5867.                 char weapon[32];
  5868.                 GetEntityClassname(playerGrenades, weapon, sizeof(weapon));
  5869.                 RemovePlayerItem(client, playerGrenades);
  5870.                 AcceptEntityInput(playerGrenades, "kill");
  5871.  
  5872.             }
  5873.         }
  5874.     }
  5875. }
  5876.  
  5877.  
  5878.  
  5879. stock AI_Director_IsSpecialtyBot(client)
  5880. {
  5881.         return false;
  5882. }
  5883.  
  5884. stock float GetEntitiesDistance(int ent1, int ent2)
  5885. {
  5886.     float orig1[3];
  5887.     GetEntPropVector(ent1, Prop_Send, "m_vecOrigin", orig1);
  5888.  
  5889.     float orig2[3];
  5890.     GetEntPropVector(ent2, Prop_Send, "m_vecOrigin", orig2);
  5891.  
  5892.     return GetVectorDistance(orig1, orig2);
  5893. }
  5894.  
  5895. public Action Timer_AmbientRadio(Handle timer, any data)
  5896. {
  5897.     if (g_iRoundStatus == 0) return Plugin_Continue;
  5898.     for (int client = 1; client <= MaxClients; client++)
  5899.     {
  5900.         if (!IsClientInGame(client) || IsFakeClient(client)) continue;
  5901.         int team = GetClientTeam(client);
  5902.        
  5903.         // Valid medic?
  5904.         if (IsPlayerAlive(client) && ((StrContains(g_client_last_classstring[client], "squadleader") > -1) || (StrContains(g_client_last_classstring[client], "teamleader") > -1)) && team == TEAM_1_SEC)
  5905.         {
  5906.             int fRandomChance = GetRandomInt(1, 100);
  5907.             if (fRandomChance < 50)
  5908.             {  
  5909.                 Handle hDatapack;
  5910.                 float fRandomFloat = GetRandomFloat(1.0, 30.0);
  5911.                 //CreateTimer(fRandomFloat, Timer_PlayAmbient);
  5912.                 CreateDataTimer(fRandomFloat, Timer_PlayAmbient, hDatapack);
  5913.                 WritePackCell(hDatapack, client);
  5914.             }
  5915.         }
  5916.     }
  5917.     return Plugin_Continue;
  5918.  
  5919. }
  5920. public Action Timer_PlayAmbient(Handle timer, DataPack hDatapack)
  5921. {
  5922.  
  5923.     hDatapack.Reset();
  5924.     int client = hDatapack.ReadCell();
  5925.  
  5926.     //PrintToServer("PlaySound");
  5927.     switch(GetRandomInt(1, 10))
  5928.     {
  5929.         case 1: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_01.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5930.         case 2: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_02.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5931.         case 3: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_03.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5932.         case 4: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_04.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5933.         case 5: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_01.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5934.         case 6: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_02.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5935.         case 7: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_03.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5936.         case 8: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_04.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5937.         case 9: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_05.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5938.         case 10: EmitSoundToAll("soundscape/emitters/oneshot/mil_radio_oneshot_06.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  5939.     }
  5940.     return Plugin_Continue;
  5941. }
  5942.  
  5943.  
  5944.  
  5945. // Check for nearest player
  5946. public Action Timer_NearestBody(Handle timer, any data)
  5947. {
  5948.     // Check round state
  5949.     if (g_iRoundStatus == 0) return Plugin_Continue;
  5950.    
  5951.     // Variables to store
  5952.     float fMedicPosition[3];
  5953.     float fMedicAngles[3];
  5954.     float fInjuredPosition[3];
  5955.     float fNearestDistance;
  5956.     float fTempDistance;
  5957.  
  5958.     // iNearest Injured client
  5959.     int iNearestInjured;
  5960.     char sDirection[64];
  5961.     char sDistance[64];
  5962.     char sHeight[6];
  5963.  
  5964.     // Client loop
  5965.     for (int medic = 1; medic <= MaxClients; medic++)
  5966.     {
  5967.         if (!IsClientInGame(medic) || IsFakeClient(medic))
  5968.             continue;
  5969.        
  5970.         // Valid medic?
  5971.         if (IsPlayerAlive(medic) && (StrContains(g_client_last_classstring[medic], "medic") > -1))
  5972.         {
  5973.             // Reset variables
  5974.             iNearestInjured = 0;
  5975.             fNearestDistance = 0.0;
  5976.            
  5977.             // Get medic position
  5978.             GetClientAbsOrigin(medic, fMedicPosition);
  5979.  
  5980.             //PrintToServer("MEDIC DETECTED ********************");
  5981.             // Search dead body
  5982.             for (int search = 1; search <= MaxClients; search++)
  5983.             {
  5984.                 if (!IsClientInGame(search) || IsFakeClient(search) || IsPlayerAlive(search)) continue;
  5985.                
  5986.                 // Check if valid
  5987.                 if (g_iHurtFatal[search] == 0 && search != medic && GetClientTeam(medic) == GetClientTeam(search))
  5988.                 {
  5989.                     // Get found client's ragdoll
  5990.                     int clientRagdoll = EntRefToEntIndex(g_iClientRagdolls[search]);
  5991.                     if (clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && clientRagdoll != INVALID_ENT_REFERENCE)
  5992.                     {
  5993.                         // Get ragdoll's position
  5994.                         fInjuredPosition = g_fRagdollPosition[search];
  5995.                        
  5996.                         // Get distance from ragdoll
  5997.                         fTempDistance = GetVectorDistance(fMedicPosition, fInjuredPosition);
  5998.  
  5999.                         // Is he more fNearestDistance to the player as the player before?
  6000.                         if (fNearestDistance == 0.0)
  6001.                         {
  6002.                             fNearestDistance = fTempDistance;
  6003.                             iNearestInjured = search;
  6004.                         }
  6005.                         // Set new distance and new iNearestInjured player
  6006.                         else if (fTempDistance < fNearestDistance)
  6007.                         {
  6008.                             fNearestDistance = fTempDistance;
  6009.                             iNearestInjured = search;
  6010.                         }
  6011.                     }
  6012.                 }
  6013.             }
  6014.            
  6015.             // Found a dead body?
  6016.             if (iNearestInjured != 0)
  6017.             {
  6018.                 // Set iNearestInjured body
  6019.                 g_iNearestBody[medic] = iNearestInjured;
  6020.                
  6021.                 // Get medic angle
  6022.                 GetClientAbsAngles(medic, fMedicAngles);
  6023.                
  6024.                 // Get direction string (if it cause server lag, remove this)
  6025.                 sDirection = GetDirectionString(fMedicAngles, fMedicPosition, fInjuredPosition);
  6026.                
  6027.                 // Get distance string
  6028.                 sDistance = GetDistanceString(fNearestDistance);
  6029.                 // Get height string
  6030.                 sHeight = GetHeightString(fMedicPosition, fInjuredPosition);
  6031.                
  6032.                 // Print iNearestInjured dead body's distance and direction text
  6033.                 //PrintCenterText(medic, "Nearest dead: %N (%s)", iNearestInjured, sDistance);
  6034.                 PrintCenterText(medic, "Nearest dead: %N ( %s | %s | %s )", iNearestInjured, sDistance, sDirection, sHeight);
  6035.                 float beamPos[3];
  6036.                 beamPos = fInjuredPosition;
  6037.                 beamPos[2] += 0.3;
  6038.                 if (fTempDistance >= 140)
  6039.                 {
  6040.                     //Attack markers option
  6041.                     //Effect_SetMarkerAtPos(medic,beamPos,1.0,{255, 0, 0, 255});
  6042.  
  6043.                     //Beam dead when farther
  6044.                     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));
  6045.                     //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)
  6046.                     TE_SendToClient(medic);
  6047.                 }
  6048.             }
  6049.             else
  6050.             {
  6051.                 // Reset iNearestInjured body
  6052.                 g_iNearestBody[medic] = -1;
  6053.             }
  6054.         }
  6055.         else if (IsPlayerAlive(medic) && !(StrContains(g_client_last_classstring[medic], "medic") > -1))
  6056.         {
  6057.             // Reset variables
  6058.             iNearestInjured = 0;
  6059.             fNearestDistance = 0.0;
  6060.            
  6061.             // Get medic position
  6062.             GetClientAbsOrigin(medic, fMedicPosition);
  6063.  
  6064.             //PrintToServer("MEDIC DETECTED ********************");
  6065.             // Search dead body
  6066.             for (int search = 1; search <= MaxClients; search++)
  6067.             {
  6068.                 if (!IsClientInGame(search) || IsFakeClient(search) || IsPlayerAlive(search))
  6069.                     continue;
  6070.                
  6071.                 // Check if valid
  6072.                 if (g_iHurtFatal[search] == 0 && search != medic && GetClientTeam(medic) == GetClientTeam(search))
  6073.                 {
  6074.                     // Get found client's ragdoll
  6075.                     int clientRagdoll = EntRefToEntIndex(g_iClientRagdolls[search]);
  6076.                     if (clientRagdoll > 0 && IsValidEdict(clientRagdoll) && IsValidEntity(clientRagdoll) && clientRagdoll != INVALID_ENT_REFERENCE)
  6077.                     {
  6078.                         // Get ragdoll's position
  6079.                         fInjuredPosition = g_fRagdollPosition[search];
  6080.                        
  6081.                         // Get distance from ragdoll
  6082.                         fTempDistance = GetVectorDistance(fMedicPosition, fInjuredPosition);
  6083.  
  6084.                         // Is he more fNearestDistance to the player as the player before?
  6085.                         if (fNearestDistance == 0.0)
  6086.                         {
  6087.                             fNearestDistance = fTempDistance;
  6088.                             iNearestInjured = search;
  6089.                         }
  6090.                         // Set new distance and new iNearestInjured player
  6091.                         else if (fTempDistance < fNearestDistance)
  6092.                         {
  6093.                             fNearestDistance = fTempDistance;
  6094.                             iNearestInjured = search;
  6095.                         }
  6096.                     }
  6097.                 }
  6098.             }
  6099.            
  6100.             // Found a dead body?
  6101.             if (iNearestInjured != 0)
  6102.             {
  6103.                 // Set iNearestInjured body
  6104.                 g_iNearestBody[medic] = iNearestInjured;
  6105.                
  6106.             }
  6107.             else
  6108.             {
  6109.                 // Reset iNearestInjured body
  6110.                 g_iNearestBody[medic] = -1;
  6111.             }
  6112.         }
  6113.     }
  6114.    
  6115.     return Plugin_Continue;
  6116. }
  6117.  
  6118. public bool Check_NearbyPlayers(int enemyBot)
  6119. {
  6120.     for (int client = 1; client <= MaxClients; client++)
  6121.     {
  6122.         if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
  6123.         {
  6124.             if (IsPlayerAlive(client))
  6125.             {
  6126.                 float botOrigin[3];
  6127.                 float clientOrigin[3];
  6128.                 float fDistance;
  6129.                
  6130.                 GetClientAbsOrigin(enemyBot,botOrigin);
  6131.                 GetClientAbsOrigin(client,clientOrigin);
  6132.                
  6133.                 //determine distance from the two
  6134.                 fDistance = GetVectorDistance(botOrigin,clientOrigin);
  6135.                
  6136.                 if (fDistance <= 600) return true;
  6137.             }
  6138.         }
  6139.     }
  6140.     return false;
  6141. }
  6142.  
  6143. /**
  6144.  * Get direction string for nearest dead body
  6145.  *
  6146.  * @param fClientAngles[3]      Client angle
  6147.  * @param fClientPosition[3]    Client position
  6148.  * @param fTargetPosition[3]    Target position
  6149.  * @Return                      direction string.
  6150.  */
  6151. char GetDirectionString(float fClientAngles[3], float fClientPosition[3], float fTargetPosition[3])
  6152. {
  6153.     float fTempAngles[3], fTempPoints[3];
  6154.     char sDirection[64];
  6155.  
  6156.     // Angles from origin
  6157.     MakeVectorFromPoints(fClientPosition, fTargetPosition, fTempPoints);
  6158.     GetVectorAngles(fTempPoints, fTempAngles);
  6159.    
  6160.     // Difference
  6161.     float fDiff = fClientAngles[1] - fTempAngles[1];
  6162.    
  6163.     // Correct it
  6164.     if (fDiff < -180)
  6165.         fDiff = 360 + fDiff;
  6166.  
  6167.     if (fDiff > 180)
  6168.         fDiff = 360 - fDiff;
  6169.    
  6170.     // Now get the direction
  6171.     // Up
  6172.     if (fDiff >= -22.5 && fDiff < 22.5)
  6173.         Format(sDirection, sizeof(sDirection), "FWD");//"\xe2\x86\x91");
  6174.     // right up
  6175.     else if (fDiff >= 22.5 && fDiff < 67.5)
  6176.         Format(sDirection, sizeof(sDirection), "FWD-RIGHT");//"\xe2\x86\x97");
  6177.     // right
  6178.     else if (fDiff >= 67.5 && fDiff < 112.5)
  6179.         Format(sDirection, sizeof(sDirection), "RIGHT");//"\xe2\x86\x92");
  6180.     // right down
  6181.     else if (fDiff >= 112.5 && fDiff < 157.5)
  6182.         Format(sDirection, sizeof(sDirection), "BACK-RIGHT");//"\xe2\x86\x98");
  6183.     // down
  6184.     else if (fDiff >= 157.5 || fDiff < -157.5)
  6185.         Format(sDirection, sizeof(sDirection), "BACK");//"\xe2\x86\x93");
  6186.     // down left
  6187.     else if (fDiff >= -157.5 && fDiff < -112.5)
  6188.         Format(sDirection, sizeof(sDirection), "BACK-LEFT");//"\xe2\x86\x99");
  6189.     // left
  6190.     else if (fDiff >= -112.5 && fDiff < -67.5)
  6191.         Format(sDirection, sizeof(sDirection), "LEFT");//"\xe2\x86\x90");
  6192.     // left up
  6193.     else if (fDiff >= -67.5 && fDiff < -22.5)
  6194.         Format(sDirection, sizeof(sDirection), "FWD-LEFT");//"\xe2\x86\x96");
  6195.    
  6196.     return sDirection;
  6197. }
  6198.  
  6199. // Return distance string
  6200. char GetDistanceString(float fDistance)
  6201. {
  6202.     // Distance to meters
  6203.     float fTempDistance = fDistance * 0.01905;
  6204.     char sResult[64];
  6205.  
  6206.     // Distance to feet?
  6207.     if (g_iUnitMetric == 1)
  6208.     {
  6209.         fTempDistance = fTempDistance * 3.2808399;
  6210.  
  6211.         // Feet
  6212.         Format(sResult, sizeof(sResult), "%.0f feet", fTempDistance);
  6213.     }
  6214.     else
  6215.     {
  6216.         // Meter
  6217.         Format(sResult, sizeof(sResult), "%.0f meter", fTempDistance);
  6218.     }
  6219.    
  6220.     return sResult;
  6221. }
  6222.  
  6223. /**
  6224.  * Get height string for nearest dead body
  6225.  *
  6226.  * @param fClientPosition[3]    Client position
  6227.  * @param fTargetPosition[3]    Target position
  6228.  * @Return                      height string.
  6229.  */
  6230. char GetHeightString(float fClientPosition[3], float fTargetPosition[3]) {
  6231.     char s[6];
  6232.  
  6233.     if (fClientPosition[2]+64 < fTargetPosition[2]) {
  6234.         s = "ABOVE";
  6235.     }
  6236.     else if (fClientPosition[2]-64 > fTargetPosition[2]) {
  6237.         s = "BELOW";
  6238.     }
  6239.     else {
  6240.         s = "LEVEL";
  6241.     }
  6242.  
  6243.     return s;
  6244. }
  6245.  
  6246. // Check tags
  6247. stock void TagsCheck(const char[] tag, bool remove = false) {
  6248.     ConVar hTags = FindConVar("sv_tags");
  6249.     char tags[255];
  6250.     hTags.GetString(tags, sizeof(tags));
  6251.  
  6252.     if (StrContains(tags, tag, false) == -1 && !remove) {
  6253.         char newTags[255];
  6254.         Format(newTags, sizeof(newTags), "%s,%s", tags, tag);
  6255.         ReplaceString(newTags, sizeof(newTags), ",,", ",", false);
  6256.         hTags.SetString(newTags);
  6257.         hTags.GetString(tags, sizeof(tags));
  6258.     }
  6259.     else if (StrContains(tags, tag, false) > -1 && remove) {
  6260.         ReplaceString(tags, sizeof(tags), tag, "", false);
  6261.         ReplaceString(tags, sizeof(tags), ",,", ",", false);
  6262.         hTags.SetString(tags);
  6263.     }
  6264. }
  6265.  
  6266. stock set_rendering(index, FX:fx=FxNone, r=255, g=255, b=255, Render:render=Normal, amount=255)
  6267. {
  6268.     SetEntProp(index, Prop_Send, "m_nRenderFX", _:fx, 1);
  6269.     SetEntProp(index, Prop_Send, "m_nRenderMode", _:render, 1);
  6270.  
  6271.     int offset = GetEntSendPropOffs(index, "m_clrRender");
  6272.    
  6273.     SetEntData(index, offset, r, 1, true);
  6274.     SetEntData(index, offset + 1, g, 1, true);
  6275.     SetEntData(index, offset + 2, b, 1, true);
  6276.     SetEntData(index, offset + 3, amount, 1, true);
  6277. }
  6278.  
  6279. // Get team2 player count
  6280. stock int GetTeamSecCount() {
  6281.     int clients = 0;
  6282.     int iTeam;
  6283.     for (int i = 1; i <= MaxClients; i++) {
  6284.         if (IsClientInGame(i) && IsClientConnected(i)) {
  6285.             iTeam = GetClientTeam(i);
  6286.             if (iTeam == TEAM_1_SEC) {
  6287.                 clients++;
  6288.             }
  6289.         }
  6290.     }
  6291.     return clients;
  6292. }
  6293.  
  6294. stock GetSecTeamBotCount()
  6295. {
  6296.     int iTeam, iSecTeamCount;
  6297.     for (int client = 1; client <= MaxClients; client++)
  6298.     {
  6299.         if (client > 0 && IsClientInGame(client) && IsFakeClient(client))
  6300.         {
  6301.             iTeam = GetClientTeam(client);
  6302.             if (iTeam == TEAM_1_SEC)
  6303.                 iSecTeamCount++;
  6304.         }
  6305.     }
  6306.    
  6307.     return iSecTeamCount;
  6308. }
  6309.  
  6310. stock int GetAlivePlayers()
  6311. {
  6312.     int iCount = 0;
  6313.     for (int client = 1; client <= MaxClients; client++)
  6314.     {
  6315.         if (client > 0 && IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
  6316.         {
  6317.             iCount++;
  6318.         }
  6319.     }
  6320.     return iCount;
  6321. }
  6322.  
  6323.  
  6324.  
  6325. public hideBot(any client)
  6326. {
  6327.     SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
  6328.     SetEntData(client, g_iCollOff, 2, 4, true);
  6329.     set_rendering(client, g_Effect, 0, 0, 0, g_Render, 0);
  6330. }
  6331.  
  6332.  
  6333.  
  6334. // Get real client count
  6335. stock int GetRealClientCount(bool inGameOnly = true)
  6336. {
  6337.     int clients = 0;
  6338.     for (int i = 1; i <= MaxClients; i++)
  6339.     {
  6340.         if (((inGameOnly)?IsClientInGame(i):IsClientConnected(i)) && !IsFakeClient(i))
  6341.             clients++;
  6342.     }
  6343.     return clients;
  6344. }
  6345.  
  6346. //Get insurgent team bot count
  6347. stock int GetTeamInsCount()
  6348. {
  6349.     int clients;
  6350.     for(int i = 1; i <= MaxClients; i++ )
  6351.     {
  6352.         if (IsClientInGame(i) && IsFakeClient(i))
  6353.         {
  6354.             clients++;
  6355.         }
  6356.     }
  6357.     return clients;
  6358. }
  6359.  
  6360. /*
  6361. LUA Version
  6362. stock GetRemainingLife()
  6363. {
  6364.     Handle hCvar = null;
  6365.     int iRemainingLife;
  6366.     hCvar = FindConVar("sm_remaininglife");
  6367.     iRemainingLife = GetConVarInt(hCvar);
  6368.     return iRemainingLife;
  6369. }*/
  6370.  
  6371. // Get remaining life
  6372. stock int GetRemainingLife()
  6373. {
  6374.     int iResult;
  6375.     for (int i = 1; i <= MaxClients; i++)
  6376.     {
  6377.         if (i > 0 && IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i))
  6378.         {
  6379.             if (g_iSpawnTokens[i] > 0)
  6380.             {
  6381.                 iResult = iResult + g_iSpawnTokens[i];
  6382.             }
  6383.         }
  6384.     }
  6385.    
  6386.     return iResult;
  6387. }
  6388.  
  6389. // Trace client's view entity
  6390. int TraceClientViewEntity(int client) {
  6391.     float m_vecOrigin[3];
  6392.     float m_angRotation[3];
  6393.  
  6394.     GetClientEyePosition(client, m_vecOrigin);
  6395.     GetClientEyeAngles(client, m_angRotation);
  6396.  
  6397.     Handle tr = TR_TraceRayFilterEx(m_vecOrigin, m_angRotation, MASK_VISIBLE, RayType_Infinite, TRDontHitSelf, client);
  6398.     int pEntity = -1;
  6399.  
  6400.     if (TR_DidHit(tr)) {
  6401.         pEntity = TR_GetEntityIndex(tr);
  6402.         delete tr;
  6403.         return pEntity;
  6404.     }
  6405.  
  6406.     delete tr;
  6407.     return -1;
  6408. }
  6409.  
  6410. // Check is hit self
  6411. public bool TRDontHitSelf(int entity, int mask, any data) // Don't ray trace ourselves -_-"
  6412. {
  6413.     return (1 <= entity <= MaxClients) && (entity != data);
  6414. }
  6415.  
  6416. /*
  6417. ########################LUA HEALING INTEGRATION######################
  6418. #   This portion of the script adds in health packs from Lua        #
  6419. ##############################START##################################
  6420. #####################################################################*/
  6421.  
  6422. /*
  6423. public Action Event_GrenadeThrown(Event event, const char[] name, bool dontBroadcast)
  6424. {
  6425.     int client = GetClientOfUserId(event.GetInt("userid"));
  6426.     int nade_id = event.GetInt("entityid");
  6427.     if (nade_id > -1 && client > -1)
  6428.     {
  6429.         if (IsPlayerAlive(client))
  6430.         {
  6431.             char grenade_name[32];
  6432.             GetEntityClassname(nade_id, grenade_name, sizeof(grenade_name));
  6433.             if (StrEqual(grenade_name, "healthkit"))
  6434.             {
  6435.                 switch(GetRandomInt(1, 18))
  6436.                 {
  6437.                     case 1: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6438.                     case 2: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6439.                     case 3: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/need_backup3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6440.                     case 4: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6441.                     case 5: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/holdposition3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6442.                     case 6: EmitSoundToAll("player/voice/radial/security/leader/unsuppressed/moving2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6443.                     case 7: EmitSoundToAll("player/voice/radial/security/leader/suppressed/backup3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6444.                     case 8: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6445.                     case 9: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6446.                     case 10: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6447.                     case 11: EmitSoundToAll("player/voice/radial/security/leader/suppressed/holdposition4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6448.                     case 12: EmitSoundToAll("player/voice/radial/security/leader/suppressed/moving3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6449.                     case 13: EmitSoundToAll("player/voice/radial/security/leader/suppressed/ontheway1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6450.                     case 14: EmitSoundToAll("player/voice/security/command/leader/located4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6451.                     case 15: EmitSoundToAll("player/voice/security/command/leader/setwaypoint1.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6452.                     case 16: EmitSoundToAll("player/voice/security/command/leader/setwaypoint2.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6453.                     case 17: EmitSoundToAll("player/voice/security/command/leader/setwaypoint3.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6454.                     case 18: EmitSoundToAll("player/voice/security/command/leader/setwaypoint4.ogg", client, SNDCHAN_VOICE, _, _, 1.0);
  6455.                 }
  6456.             }
  6457.         }
  6458.     }
  6459. }*/
  6460.  
  6461. //Healthkit Start
  6462.  
  6463. public void OnEntityDestroyed(int entity)
  6464. {
  6465.     if (entity > MaxClients)
  6466.     {
  6467.         char classname[255];
  6468.         GetEntityClassname(entity, classname, 255);
  6469.         if (StrEqual(classname, "healthkit")) {
  6470.             //StopSound(entity, SNDCHAN_STATIC, "Lua_sounds/healthkit_healing.wav");
  6471.         }
  6472.         if (!(StrContains(classname, "wcache_crate_01") > -1)) {
  6473.             g_ammoResupplyAmt[entity] = 0;
  6474.         }
  6475.     }
  6476. }
  6477.  
  6478. public OnEntityCreated(entity, const char[] classname)
  6479. {
  6480.  
  6481.     if (StrEqual(classname, "healthkit"))
  6482.     {
  6483.         Handle hDatapack;
  6484.         g_healthPack_Amount[entity] = g_medpack_health_amt;
  6485.         CreateDataTimer(Healthkit_Timer_Tickrate, Healthkit, hDatapack, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  6486.         WritePackCell(hDatapack, entity);
  6487.         WritePackFloat(hDatapack, GetGameTime()+Healthkit_Timer_Timeout);
  6488.         g_fLastHeight[entity] = -9999.0;
  6489.         g_iTimeCheckHeight[entity] = -9999;
  6490.         SDKHook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck);
  6491.         CreateTimer(0.1, HealthkitGroundCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  6492.     }
  6493.     /*else if (StrEqual(classname, "grenade_m67") || StrEqual(classname, "grenade_f1"))
  6494.     {
  6495.         CreateTimer(0.5, GrenadeScreamCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  6496.     }
  6497.     else if (StrEqual(classname, "grenade_molotov") || StrEqual(classname, "grenade_anm14"))
  6498.         CreateTimer(0.2, FireScreamCheckTimer, entity, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);*/
  6499. }
  6500.  
  6501. /*Action FireScreamCheckTimer(Handle timer, any entity)
  6502. {
  6503.     float fGrenOrigin[3];
  6504.     float fPlayerOrigin[3];
  6505.     float fPlayerEyeOrigin[3];
  6506.     int owner;
  6507.     if (IsValidEntity(entity) && entity > 0)
  6508.     {
  6509.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fGrenOrigin);
  6510.         owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
  6511.     }
  6512.     else
  6513.         CloseHandle(timer);
  6514.     for (int client = 1;client <= MaxClients;client++)
  6515.     {
  6516.         if (client <= 0 || !IsClientInGame(client) || !IsClientConnected(client)) continue;
  6517.         if (owner <= 0 || !IsClientInGame(owner) || IsFakeClient(client) || !IsClientConnected(owner)) continue;
  6518.         if (IsPlayerAlive(client) && GetClientTeam(client) == 2 && GetClientTeam(owner) == 3)
  6519.         {
  6520.             GetClientEyePosition(client, fPlayerEyeOrigin);
  6521.             GetClientAbsOrigin(client,fPlayerOrigin);
  6522.             //Handle trace = TR_TraceRayFilterEx(fPlayerEyeOrigin, fGrenOrigin, MASK_SOLID_BRUSHONLY, RayType_EndPoint, Base_TraceFilter);
  6523.             if (GetVectorDistance(fPlayerOrigin, fGrenOrigin) <= 300 &&  g_plyrFireScreamCoolDown[client] <= 0)
  6524.             {
  6525.                 //PrintToServer("SCREAM FIRE");
  6526.                 PlayerFireScreamRand(client);
  6527.                 int fRandomInt = GetRandomInt(20, 30);
  6528.                 g_plyrFireScreamCoolDown[client] = fRandomInt;
  6529.                 //CloseHandle(trace);  
  6530.             }
  6531.         }
  6532.     }
  6533.     if (!IsValidEntity(entity) || !(entity > 0)) CloseHandle(timer);
  6534. }*/
  6535.  
  6536. /*Action GrenadeScreamCheckTimer(Handle timer, any entity)
  6537. {
  6538.     float fGrenOrigin[3];
  6539.     float fPlayerOrigin[3];
  6540.     float fPlayerEyeOrigin[3];
  6541.     int owner;
  6542.     if (IsValidEntity(entity) && entity > 0)
  6543.     {
  6544.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fGrenOrigin);
  6545.         owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
  6546.     }
  6547.     else
  6548.         KillTimer(timer);
  6549.     for (int client = 1;client <= MaxClients;client++)
  6550.     {
  6551.         if (client <= 0 || IsFakeClient(client) || !IsClientInGame(client)) continue;
  6552.         if (client > 0 && IsPlayerAlive(client) && GetClientTeam(client) == 2 && owner > 0 && GetClientTeam(owner) == 3)
  6553.         {
  6554.             GetClientEyePosition(client, fPlayerEyeOrigin);
  6555.             GetClientAbsOrigin(client,fPlayerOrigin);
  6556.  
  6557.             if (GetVectorDistance(fPlayerOrigin, fGrenOrigin) <= 240 &&  g_plyrGrenScreamCoolDown[client] <= 0)
  6558.             {
  6559.                 PlayerGrenadeScreamRand(client);
  6560.                 int fRandomInt = GetRandomInt(6, 12);
  6561.                 g_plyrGrenScreamCoolDown[client] = fRandomInt;
  6562.             }
  6563.         }
  6564.     }
  6565.     if (!IsValidEntity(entity) || !(entity > 0))
  6566.         KillTimer(timer);
  6567. }*/
  6568.  
  6569. public Action HealthkitGroundCheck(int entity, int activator, int caller, UseType type, float value)
  6570. {
  6571.     float fOrigin[3];
  6572.     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
  6573.     int iRoundHeight = RoundFloat(fOrigin[2]);
  6574.     if (iRoundHeight != g_iTimeCheckHeight[entity])
  6575.     {
  6576.         g_iTimeCheckHeight[entity] = iRoundHeight;
  6577.         g_fTimeCheck[entity] = GetGameTime();
  6578.     }
  6579. }
  6580.  
  6581. Action HealthkitGroundCheckTimer(Handle timer, any entity)
  6582. {
  6583.     if (entity > MaxClients && IsValidEntity(entity))
  6584.     {
  6585.         float fGameTime = GetGameTime();
  6586.         if (fGameTime-g_fTimeCheck[entity] >= 1.0)
  6587.         {
  6588.             float fOrigin[3];
  6589.             GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
  6590.             int iRoundHeight = RoundFloat(fOrigin[2]);
  6591.             if (iRoundHeight == g_iTimeCheckHeight[entity])
  6592.             {
  6593.                 g_fTimeCheck[entity] = GetGameTime();
  6594.                 SDKUnhook(entity, SDKHook_VPhysicsUpdate, HealthkitGroundCheck);
  6595.                 SDKHook(entity, SDKHook_VPhysicsUpdate, OnEntityPhysicsUpdate);
  6596.                 KillTimer(timer);
  6597.             }
  6598.         }
  6599.     }
  6600.     else CloseHandle(timer);
  6601. }
  6602.  
  6603. public Action OnEntityPhysicsUpdate(int entity, int activator, int caller, UseType type, float value)
  6604. {
  6605.     TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, view_as<float> ({0.0, 0.0, 0.0}));
  6606. }
  6607.  
  6608. public Action Healthkit(Handle timer, Handle hDatapack)
  6609. {
  6610.     ResetPack(hDatapack);
  6611.     int entity = ReadPackCell(hDatapack);
  6612.     float fEndTime = ReadPackFloat(hDatapack);
  6613.     float fGameTime = GetGameTime();
  6614.     if (entity > 0 && IsValidEntity(entity) && fGameTime <= fEndTime)
  6615.     {
  6616.         float fOrigin[3];
  6617.         GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fOrigin);
  6618.         if (g_fLastHeight[entity] == -9999.0)
  6619.         {
  6620.             g_fLastHeight[entity] = 0.0;
  6621.             EmitSoundToAll("Lua_sounds/healthkit_healing.wav", entity, SNDCHAN_STATIC, _, _, 0.7);
  6622.         }
  6623.         //fOrigin[2] += 16.0;
  6624.         fOrigin[2] += 1.0;
  6625.         //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));
  6626.         TE_SetupBeamRingPoint(fOrigin, 15.0, Healthkit_Radius*0.55, g_iBeaconBeam, g_iBeaconHalo, 0, 5, 1.0, 1.0, 2.0, {0, 204, 100, 255},1,0);
  6627.         // // //TE_SetupBeamRingPoint(fOrigin, 5.0, Healthkit_Radius*1.95, g_iBeaconBeam, g_iBeaconHalo, 0, 30, 5.0, 3.0, 5.0, {0, 255, 0, 255}, 1, (FBEAM_FADEOUT));
  6628.         //TE_SetupBeamRingPoint(fOrigin, 10.0, Healthkit_Radius*1.95, g_iBeaconBeam, g_iBeaconHalo, 0, 30, 0.6, 3.0, 0.0, {0, 204, 102, 255}, 3, 0);
  6629.         TE_SendToAll();
  6630.         fOrigin[2] -= 16.0;
  6631.         if (fOrigin[2] != g_fLastHeight[entity])
  6632.         {
  6633.             g_fLastHeight[entity] = fOrigin[2];
  6634.         }
  6635.         else
  6636.         {
  6637.             float fAng[3];
  6638.             GetEntPropVector(entity, Prop_Send, "m_angRotation", fAng);
  6639.             if (fAng[1] > 89.0 || fAng[1] < -89.0)
  6640.                 fAng[1] = 90.0;
  6641.             if (fAng[2] > 89.0 || fAng[2] < -89.0)
  6642.             {
  6643.                 fAng[2] = 0.0;
  6644.                 fOrigin[2] -= 6.0;
  6645.                 TeleportEntity(entity, fOrigin, fAng, view_as<float>({0.0, 0.0, 0.0}));
  6646.                 fOrigin[2] += 6.0;
  6647.                 EmitSoundToAll("ui/sfx/cl_click.wav", entity, SNDCHAN_STATIC, _, _, 1.0);
  6648.             }
  6649.         }
  6650.        
  6651.         for (int iPlayer = 1;iPlayer <= MaxClients;iPlayer++)
  6652.         {
  6653.             if (IsClientInGame(iPlayer) && IsPlayerAlive(iPlayer) && GetClientTeam(iPlayer) == 2)
  6654.             {
  6655.                 float fPlayerOrigin[3];
  6656.                 GetClientEyePosition(iPlayer, fPlayerOrigin);
  6657.                 if (GetVectorDistance(fPlayerOrigin, fOrigin) <= Healthkit_Radius)
  6658.                 {
  6659.                     Handle hData = CreateDataPack();
  6660.                     WritePackCell(hData, entity);
  6661.                     WritePackCell(hData, iPlayer);
  6662.                     fOrigin[2] += 32.0;
  6663.                     Handle trace = TR_TraceRayFilterEx(fPlayerOrigin, fOrigin, MASK_SOLID, RayType_EndPoint, Filter_ClientSelf, hData);
  6664.                     CloseHandle(hData);
  6665.                     if (!TR_DidHit(trace))
  6666.                     {
  6667.                         int iMaxHealth = GetEntProp(iPlayer, Prop_Data, "m_iMaxHealth");
  6668.                         int iHealth = GetEntProp(iPlayer, Prop_Data, "m_iHealth");
  6669.                         if (iMaxHealth > iHealth)
  6670.                         {
  6671.                             iHealth += GetRandomInt(Healthkit_Healing_Per_Tick_Min, Healthkit_Healing_Per_Tick_Max);
  6672.                             if (iHealth >= iMaxHealth)
  6673.                             {
  6674.                                 EmitSoundToAll("Lua_sounds/healthkit_complete.wav", iPlayer, SNDCHAN_STATIC, _, _, 1.0);
  6675.                                 iHealth = iMaxHealth;
  6676.                                 //PrintToChat(iPlayer, "\x05竊긌ua \x01@ \x03You are completely healed!");
  6677.                                 PrintCenterText(iPlayer, "Healed !\n\n \n %d %%\n \n \n \n \n \n \n \n", iMaxHealth);
  6678.                             }
  6679.                             else PrintCenterText(iPlayer, "Healing...\n\n \n   %d %%\n \n \n \n \n \n \n \n", iHealth);
  6680.                             SetEntProp(iPlayer, Prop_Data, "m_iHealth", iHealth);
  6681.                         }
  6682.                         else PrintCenterText(iPlayer, "Healed !\n\n \n %d %%\n \n \n \n \n \n \n \n", iMaxHealth);
  6683.                     }
  6684.                     CloseHandle(trace);
  6685.                 }
  6686.             }
  6687.         }
  6688.     }
  6689.     else
  6690.     {
  6691.         RemoveHealthkit(entity);
  6692.         KillTimer(timer);
  6693.     }
  6694. }
  6695.  
  6696. public bool Filter_ClientSelf(int entity, int contentsMask, any data)
  6697. {
  6698.     DataPack dp = data;
  6699.     dp.Reset();
  6700.     int client = dp.ReadCell();
  6701.     int player = dp.ReadCell();
  6702.     delete dp;
  6703.     return (entity != client && entity != player);
  6704. }
  6705.  
  6706. public RemoveHealthkit(entity)
  6707. {
  6708.     if (entity > MaxClients && IsValidEntity(entity))
  6709.     {
  6710.         AcceptEntityInput(entity, "Kill");
  6711.     }
  6712. }
  6713.  
  6714. //  bool Check_NearbyMedics(int client) {
  6715. //      for (int friendlyMedic = 1; friendlyMedic <= MaxClients; friendlyMedic++) {
  6716. //          if (IsClientConnected(friendlyMedic) && IsClientInGame(friendlyMedic) && !IsFakeClient(friendlyMedic)) {
  6717. //              //PrintToServer("Medic 1");
  6718. //              //new team = GetClientTeam(friendlyMedic);
  6719. //              if (IsPlayerAlive(friendlyMedic) && (StrContains(g_client_last_classstring[friendlyMedic], "medic") > -1) && client != friendlyMedic) {
  6720. //              //PrintToServer("Medic 2");
  6721. //                  //Get position of bot and prop
  6722. //                  float plyrOrigin[3];
  6723. //                  float medicOrigin[3];
  6724. //                  float fDistance;
  6725.  
  6726. //                  GetClientAbsOrigin(client, plyrOrigin);
  6727. //                  GetClientAbsOrigin(friendlyMedic, medicOrigin);
  6728. //                  //GetEntPropVector(entity, Prop_Send, "m_vecOrigin", propOrigin);
  6729.  
  6730. //                  //determine distance from the two
  6731. //                  fDistance = GetVectorDistance(medicOrigin, plyrOrigin);
  6732.  
  6733. //                  int ActiveWeapon = GetEntPropEnt(friendlyMedic, Prop_Data, "m_hActiveWeapon");
  6734. //                  if (ActiveWeapon < 0) {
  6735. //                      continue;
  6736. //                  }
  6737.  
  6738. //                  // Get weapon class name
  6739. //                  char sWeapon[32];
  6740. //                  GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  6741.  
  6742. //              //PrintToServer("Medic 3");
  6743. //                  bool bCanHealPaddle = false;
  6744. //                  if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1) || (StrContains(sWeapon, "weapon_healthkit") > -1)) {
  6745. //              //PrintToServer("Medic 4");
  6746. //                      bCanHealPaddle = true;
  6747. //                  }
  6748. //                  if (fDistance <= Healthkit_Radius && bCanHealPaddle) {
  6749. //              //PrintToServer("Medic 5");
  6750. //                      return true;
  6751. //                  }
  6752. //              }
  6753. //          }
  6754. //      }
  6755. //      return false;
  6756. //  }
  6757.  
  6758. //This is to award nearby medics that participate in reviving a player
  6759. void Check_NearbyMedicsRevive(int client, int iInjured) {
  6760.     for (int friendlyMedic = 1; friendlyMedic <= MaxClients; friendlyMedic++) {
  6761.         if (IsClientConnected(friendlyMedic) && IsClientInGame(friendlyMedic) && !IsFakeClient(friendlyMedic)) {
  6762.             //PrintToServer("Medic 1");
  6763.             //new team = GetClientTeam(friendlyMedic);
  6764.             if (IsPlayerAlive(friendlyMedic) && (StrContains(g_client_last_classstring[friendlyMedic], "medic") > -1) && client != friendlyMedic) {
  6765.                 //PrintToServer("Medic 2");
  6766.                 //Get position of bot and prop
  6767.                 float medicOrigin[3];
  6768.                 float fDistance;
  6769.  
  6770.                 GetClientAbsOrigin(friendlyMedic, medicOrigin);
  6771.                 //GetEntPropVector(entity, Prop_Send, "m_vecOrigin", propOrigin);
  6772.  
  6773.                 //determine distance from the two
  6774.                 fDistance = GetVectorDistance(medicOrigin, g_fRagdollPosition[iInjured]);
  6775.  
  6776.                 int ActiveWeapon = GetEntPropEnt(friendlyMedic, Prop_Data, "m_hActiveWeapon");
  6777.                 if (ActiveWeapon < 0) {
  6778.                     continue;
  6779.                 }
  6780.  
  6781.                 // Get weapon class name
  6782.                 char sWeapon[32];
  6783.                 GetEdictClassname(ActiveWeapon, sWeapon, sizeof(sWeapon));
  6784.  
  6785.                 //PrintToServer("Medic 3");
  6786.                 bool bCanHealPaddle = false;
  6787.                 if ((StrContains(sWeapon, "weapon_defib") > -1) || (StrContains(sWeapon, "weapon_knife") > -1) || (StrContains(sWeapon, "weapon_kabar") > -1)) {
  6788.                     //PrintToServer("Medic 4");
  6789.                     bCanHealPaddle = true;
  6790.                 }
  6791.  
  6792.                 float fReviveDistance = 65.0;
  6793.                 if (fDistance <= fReviveDistance && bCanHealPaddle) {
  6794.  
  6795.                     char woundType[64];
  6796.                     if (g_playerWoundType[iInjured] == 0) {
  6797.                         woundType = "minor wound";
  6798.                     }
  6799.                     else if (g_playerWoundType[iInjured] == 1) {
  6800.                         woundType = "moderate wound";
  6801.                     }
  6802.                     else if (g_playerWoundType[iInjured] == 2) {
  6803.                         woundType = "critical wound";
  6804.                     }
  6805.                     char sBuf[255];
  6806.                     // Chat to all
  6807.                     Format(sBuf, 255,"\x05%N\x01 revived(assisted) \x03%N from a %s", friendlyMedic, iInjured, woundType);
  6808.                     PrintToChatAll("%s", sBuf);
  6809.  
  6810.                     // Add kill bonus to friendlyMedic
  6811.                     // new iBonus = sm_revive_bonus.IntValue;
  6812.                     // new iScore = GetClientFrags(friendlyMedic) + iBonus;
  6813.                     // SetEntProp(friendlyMedic, Prop_Data, "m_iFrags", iScore);
  6814.  
  6815.                     /////////////////////////
  6816.                     // Rank System
  6817.                     g_iStatRevives[friendlyMedic]++;
  6818.                     //
  6819.                     /////////////////////////
  6820.  
  6821.                     // Add score bonus to friendlyMedic (doesn't work)
  6822.                     //iScore = GetPlayerScore(friendlyMedic);
  6823.                     //PrintToServer("[SCORE] score: %d", iScore + 10);
  6824.                     //SetPlayerScore(friendlyMedic, iScore + 10);
  6825.  
  6826.                     //Accumulate a revive
  6827.                     g_playerMedicRevivessAccumulated[friendlyMedic]++;
  6828.                     int iReviveCap = sm_revive_cap_for_bonus.IntValue;
  6829.                     // Hint to friendlyMedic
  6830.                     Format(sBuf, 255,"You revived(assisted) %N from a %s | Revives remaining til bonus life: %d", iInjured, woundType, (iReviveCap - g_playerMedicRevivessAccumulated[friendlyMedic]));
  6831.                     PrintHintText(friendlyMedic, "%s", sBuf);
  6832.  
  6833.                     if (g_playerMedicRevivessAccumulated[friendlyMedic] >= iReviveCap) {
  6834.                         g_playerMedicRevivessAccumulated[friendlyMedic] = 0;
  6835.                         g_iSpawnTokens[friendlyMedic]++;
  6836.                         char sBuf2[255];
  6837.                         // if (iBonus > 1)
  6838.                         //  Format(sBuf2, 255,"Awarded %i kills and %i score for assisted revive", iBonus, 10);
  6839.                         // else
  6840.                         Format(sBuf2, 255,"Awarded %i life for reviving %d players", 1, iReviveCap);
  6841.                         PrintToChat(friendlyMedic, "%s", sBuf2);
  6842.                     }
  6843.                 }
  6844.             }
  6845.         }
  6846.     }
  6847. }
  6848.  
  6849. stock Effect_SetMarkerAtPos(int client, float pos[3], float intervall, int color[4])
  6850. {
  6851.  
  6852.    
  6853.     /*static Float:lastMarkerTime[MAXPLAYERS+1] = {0.0,...};
  6854.     new Float:gameTime = GetGameTime();
  6855.    
  6856.     if(lastMarkerTime[client] > gameTime){
  6857.        
  6858.         //no update cuz its already up2date
  6859.         return;
  6860.     }
  6861.    
  6862.     lastMarkerTime[client] = gameTime+intervall;*/
  6863.    
  6864.     float start[3];
  6865.     float end[3];
  6866.     //decl Float:worldMaxs[3];
  6867.    
  6868.     //World_GetMaxs(worldMaxs);
  6869.    
  6870.     end[0] = start[0] = pos[0];
  6871.     end[1] = start[1] = pos[1];
  6872.     end[2] = start[2] = pos[2];
  6873.     end[2] += 10000.0;
  6874.     start[2] += 5.0;
  6875.    
  6876.     //intervall -= 0.1;
  6877.    
  6878.     for(int effect=1;effect<=2;effect++){
  6879.        
  6880.        
  6881.         //blue team
  6882.         switch(effect)
  6883.         {
  6884.            
  6885.             case 1:
  6886.             {
  6887.                 TE_SetupBeamPoints(start, end, g_iBeaconBeam, 0, 0, 20, intervall, 1.0, 50.0, 0, 0.0, color, 0);
  6888.             }
  6889.             case 2:
  6890.             {
  6891.                 TE_SetupBeamRingPoint(start, 50.0, 50.1, g_iBeaconBeam, g_iBeaconHalo, 0, 10, intervall, 2.0, 0.0, color, 10, 0);
  6892.             }
  6893.         }
  6894.        
  6895.         TE_SendToClient(client);
  6896.     }
  6897. }
  6898.  
  6899. // Healthkit Finished
  6900.  
  6901. /*public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
  6902. {
  6903.         int client = GetClientOfUserId(event.GetInt("userid"));
  6904.  
  6905.         if (client > 0) // Check the client is not console/world?
  6906.             if (IsValidClient(client))
  6907.             {
  6908.                 int m_iTeam = GetClientTeam(client);
  6909.                 if (!IsFakeClient(client) && m_iTeam == TEAM_SPEC)
  6910.                 {
  6911.                     //remove network ragdoll associated with player
  6912.                     int playerRag = EntRefToEntIndex(g_iClientRagdolls[client]);
  6913.                     if(playerRag > 0 && IsValidEdict(playerRag) && IsValidEntity(playerRag))
  6914.                         RemoveRagdoll(client);
  6915.                 }
  6916.             }
  6917.         return Plugin_Continue;
  6918. }*/
  6919.  
  6920.  
  6921. //############# AI DIRECTOR In-Script Functions START #######################
  6922.  
  6923.  
  6924. void AI_Director_ResetReinforceTimers()
  6925. {
  6926.         //Set Reinforce Time
  6927.         g_iReinforceTime_AD_Temp = (g_AIDir_ReinforceTimer_Orig);
  6928.         g_iReinforceTimeSubsequent_AD_Temp = (g_AIDir_ReinforceTimer_SubOrig);
  6929. }
  6930.  
  6931. void AI_Director_SetDifficulty()
  6932. {
  6933.     AI_Director_ResetReinforceTimers();
  6934.  
  6935.         //AI Director Local Scaling Vars
  6936.     //AID_ReinfAdj_low = 10, AID_ReinfAdj_med = 20, AID_ReinfAdj_high = 30, AID_ReinfAdj_pScale = 0,
  6937.     int AID_ReinfAdj_med = 20;
  6938.     int AID_ReinfAdj_high = 30;
  6939.     int AID_ReinfAdj_pScale = 0;
  6940.     float AID_SpecDelayAdj_low = 10.0;
  6941.     float AID_SpecDelayAdj_med = 20.0;
  6942.     float AID_SpecDelayAdj_high = 30.0;
  6943.     float AID_SpecDelayAdj_pScale_Pro = 0.0;
  6944.     float AID_SpecDelayAdj_pScale_Con = 0.0;
  6945.     int AID_AmbChance_vlow = 10;
  6946.     int AID_AmbChance_low = 15;
  6947.     int AID_AmbChance_med = 20;
  6948.     int AID_AmbChance_high = 25;
  6949.     int AID_AmbChance_pScale = 0;
  6950.     int AID_SetDiffChance_pScale = 0;
  6951.  
  6952.     //Scale based on team count
  6953.     int tTeamSecCount = GetTeamSecCount();
  6954.     if (tTeamSecCount <= 6) {
  6955.         AID_ReinfAdj_pScale = 8;
  6956.         AID_SpecDelayAdj_pScale_Pro = 30.0;
  6957.         AID_SpecDelayAdj_pScale_Con = 10.0;
  6958.     }
  6959.     else if (tTeamSecCount >= 7 && tTeamSecCount <= 12) {
  6960.         AID_ReinfAdj_pScale = 4;
  6961.         AID_SpecDelayAdj_pScale_Pro = 20.0;
  6962.         AID_SpecDelayAdj_pScale_Con = 20.0;
  6963.         AID_AmbChance_pScale = 5;
  6964.         AID_SetDiffChance_pScale = 5;
  6965.     }
  6966.     else if (tTeamSecCount >= 13) {
  6967.         AID_ReinfAdj_pScale = 8;
  6968.         AID_SpecDelayAdj_pScale_Pro = 10.0;
  6969.         AID_SpecDelayAdj_pScale_Con = 30.0;
  6970.         AID_AmbChance_pScale = 10;
  6971.         AID_SetDiffChance_pScale = 10;
  6972.     }
  6973.  
  6974.     // Get the number of control points
  6975.     int ncp = Ins_ObjectiveResource_GetProp("m_iNumControlPoints");
  6976.  
  6977.     // Get active push point
  6978.     int acp = Ins_ObjectiveResource_GetProp("m_nActivePushPointIndex");
  6979.  
  6980.     int tAmbScaleMult = 2;
  6981.     if (ncp <= 5)
  6982.     {
  6983.         tAmbScaleMult = 3;
  6984.         AID_SetDiffChance_pScale += 5;
  6985.     }
  6986.     //Add More to Ambush chance based on what point we are at.
  6987.     AID_AmbChance_pScale += (acp * tAmbScaleMult);
  6988.     AID_SetDiffChance_pScale += (acp * tAmbScaleMult);
  6989.  
  6990.     float cvarSpecDelay = sm_respawn_delay_team_ins_special.FloatValue;
  6991.     int fRandomInt = GetRandomInt(0, 100);
  6992.  
  6993.  
  6994.     //Set Difficulty Based On g_AIDir_TeamStatus and adjust per player scale g_SernixMaxPlayerCount
  6995.     if (fRandomInt <= (g_AIDir_DiffChanceBase + AID_SetDiffChance_pScale))
  6996.     {
  6997.         AI_Director_ResetReinforceTimers();
  6998.         //Set Reinforce Time
  6999.         g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
  7000.         g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
  7001.  
  7002.         //Mod specialized bot spawn interval
  7003.         g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_high) - AID_SpecDelayAdj_pScale_Con);
  7004.         if (g_fCvar_respawn_delay_team_ins_spec <= 0)
  7005.             g_fCvar_respawn_delay_team_ins_spec = 1.0;
  7006.  
  7007.         //DEBUG: Track Current Difficulty setting
  7008.         //g_AIDir_CurrDiff = 5;
  7009.  
  7010.         //Set Ambush Chance
  7011.         g_AIDir_AmbushCond_Chance = AID_AmbChance_high + AID_AmbChance_pScale;
  7012.     }
  7013.     // < 25% DOING BAD >> MAKE EASIER //Scale variables should be lower with higher player counts
  7014.     else if (g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 4))
  7015.     {
  7016.         //Set Reinforce Time
  7017.         g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig + AID_ReinfAdj_high) + AID_ReinfAdj_pScale);
  7018.         g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig + AID_ReinfAdj_high) + AID_ReinfAdj_pScale);
  7019.  
  7020.         //Mod specialized bot spawn interval
  7021.         g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay + AID_SpecDelayAdj_high) + AID_SpecDelayAdj_pScale_Pro);
  7022.  
  7023.         //DEBUG: Track Current Difficulty setting
  7024.         //g_AIDir_CurrDiff = 1;
  7025.  
  7026.         //Set Ambush Chance
  7027.         g_AIDir_AmbushCond_Chance = AID_AmbChance_vlow + AID_AmbChance_pScale;
  7028.     }
  7029.     // >= 25% and < 50% NORMAL >> No Adjustments
  7030.     else if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 4) && g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 2))
  7031.     {
  7032.         AI_Director_ResetReinforceTimers();
  7033.  
  7034.         // >= 25% and < 33% Ease slightly if <= half the team alive which is 9 right now.
  7035.         if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 4) && g_AIDir_TeamStatus < (g_AIDir_TeamStatus_max / 3) && GetTeamSecCount() <= 9)
  7036.         {
  7037.             //Set Reinforce Time
  7038.             g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig + AID_ReinfAdj_med) + AID_ReinfAdj_pScale);
  7039.             g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig + AID_ReinfAdj_med) + AID_ReinfAdj_pScale);
  7040.  
  7041.             //Mod specialized bot spawn interval
  7042.             g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay + AID_SpecDelayAdj_low) + AID_SpecDelayAdj_pScale_Pro);
  7043.  
  7044.             //DEBUG: Track Current Difficulty setting
  7045.             //g_AIDir_CurrDiff = 2;
  7046.  
  7047.             //Set Ambush Chance
  7048.             g_AIDir_AmbushCond_Chance = AID_AmbChance_low + AID_AmbChance_pScale;
  7049.         }
  7050.         else
  7051.         {
  7052.             //Set Reinforce Time
  7053.             g_iReinforceTime_AD_Temp = (g_AIDir_ReinforceTimer_Orig);
  7054.             g_iReinforceTimeSubsequent_AD_Temp = (g_AIDir_ReinforceTimer_SubOrig);
  7055.  
  7056.             //Mod specialized bot spawn interval
  7057.             g_fCvar_respawn_delay_team_ins_spec = cvarSpecDelay;
  7058.  
  7059.             //DEBUG: Track Current Difficulty setting
  7060.             //g_AIDir_CurrDiff = 2;
  7061.  
  7062.             //Set Ambush Chance
  7063.             g_AIDir_AmbushCond_Chance = AID_AmbChance_low + AID_AmbChance_pScale;
  7064.  
  7065.         }
  7066.     }
  7067.     // >= 50% and < 75% DOING GOOD
  7068.     else if (g_AIDir_TeamStatus >= (g_AIDir_TeamStatus_max / 2) && g_AIDir_TeamStatus < ((g_AIDir_TeamStatus_max / 4) * 3))
  7069.     {
  7070.         AI_Director_ResetReinforceTimers();
  7071.         //Set Reinforce Time
  7072.         g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_med) - AID_ReinfAdj_pScale);
  7073.         g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_med) - AID_ReinfAdj_pScale);
  7074.  
  7075.         //Mod specialized bot spawn interval
  7076.         g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_med) - AID_SpecDelayAdj_pScale_Con);
  7077.         if (g_fCvar_respawn_delay_team_ins_spec <= 0)
  7078.             g_fCvar_respawn_delay_team_ins_spec = 1.0;
  7079.  
  7080.         //DEBUG: Track Current Difficulty setting
  7081.         //g_AIDir_CurrDiff = 3;
  7082.  
  7083.         //Set Ambush Chance
  7084.         g_AIDir_AmbushCond_Chance = AID_AmbChance_med + AID_AmbChance_pScale;
  7085.     }
  7086.     // >= 75%  CAKE WALK
  7087.     else if (g_AIDir_TeamStatus >= ((g_AIDir_TeamStatus_max / 4) * 3))
  7088.     {
  7089.         AI_Director_ResetReinforceTimers();
  7090.         //Set Reinforce Time
  7091.         g_iReinforceTime_AD_Temp = ((g_AIDir_ReinforceTimer_Orig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
  7092.         g_iReinforceTimeSubsequent_AD_Temp = ((g_AIDir_ReinforceTimer_SubOrig - AID_ReinfAdj_high) - AID_ReinfAdj_pScale);
  7093.  
  7094.         //Mod specialized bot spawn interval
  7095.         g_fCvar_respawn_delay_team_ins_spec = ((cvarSpecDelay - AID_SpecDelayAdj_high) - AID_SpecDelayAdj_pScale_Con);
  7096.         if (g_fCvar_respawn_delay_team_ins_spec <= 0)
  7097.             g_fCvar_respawn_delay_team_ins_spec = 1.0;
  7098.  
  7099.         //DEBUG: Track Current Difficulty setting
  7100.         //g_AIDir_CurrDiff = 4;
  7101.  
  7102.         //Set Ambush Chance
  7103.         g_AIDir_AmbushCond_Chance = AID_AmbChance_high + AID_AmbChance_pScale;
  7104.     }
  7105.     //return g_AIDir_TeamStatus;
  7106. }
  7107. //############# AI DIRECTOR In-Script END #######################
Add Comment
Please, Sign In to add comment