Guest User

Untitled

a guest
Nov 26th, 2019
2,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.32 KB | None | 0 0
  1. DEBUG <- false;
  2.  
  3. wave <- 0;
  4.  
  5. NEXTFLOOR <- 0; // the next floor to travel to
  6. FASTTRAVEL1 <- false; // has player unlocked fast travel stage 1? these vars persist on "@script_varcontainer"
  7. FASTTRAVEL2 <- false; // has player unlocked fast travel stage 2?
  8. FASTTRAVEL3 <- false; // has player unlocked fast travel stage 3?
  9.  
  10. PLAYER_AMOUNT <- 0; // how many players are playing?
  11.  
  12. PERSISTENTCONTAINER <- Entities.FindByName (null, "@script_varcontainer");
  13. ISWARMUP <- ScriptIsWarmupPeriod();
  14.  
  15. // Floor list
  16. // Floor 0 - Starting area
  17. // Floor 1 - combat arena, group 1
  18. // Floor 2 - combat arena, group 1
  19. // Floor 3 - Combat arena, group 1
  20. // Floor 4 - Combat arena, group 1
  21. //
  22. // Floor 5 - Combat arena, group 2
  23. // Floor 6 - Combat arena, group 2
  24. // Floor 7 - Combat arena, group 2
  25. // Floor 8 - Combat arena, group 2
  26. //
  27. // Floor 9 - Shortcut fight
  28. //
  29. // Floor 10 - Combat arena, group 3
  30. // Floor 11 - Combat arena, group 3
  31. // Floor 12 - Combat arena, group 3
  32. // Floor 13 - Combat arena, group 3
  33. //
  34. // Floor 14 - Combat arena, group 4
  35. // Floor 15 - Combat arena, group 4
  36.  
  37. // Floor 16 - End fight
  38.  
  39. CURRENTDIFFICULTY <- 0;
  40. ENEMYAMOUNT <- 0;
  41. LoadoutType <- [1, 9]
  42. WeaponLoadout <- {}
  43.  
  44. // NOTE: EnemyDifficulty() uses these to decide weapon loadouts, remember to keep in sync!
  45.  
  46. // early game loadouts
  47.  
  48. WeaponLoadout[1] <- "glock"
  49. WeaponLoadout[2] <- "deagle"
  50. WeaponLoadout[3] <- "tec9"
  51. WeaponLoadout[4] <- "sawedoff"
  52. WeaponLoadout[5] <- "nova"
  53. WeaponLoadout[6] <- "mp7"
  54. WeaponLoadout[7] <- "bizon"
  55. WeaponLoadout[8] <- "mac10"
  56. WeaponLoadout[9] <- "ump45"
  57.  
  58. // mid game
  59.  
  60. WeaponLoadout[10] <- "galilar"
  61. WeaponLoadout[11] <- "famas"
  62. WeaponLoadout[12] <- "p90"
  63. WeaponLoadout[13] <- "ump45, flashbang"
  64. WeaponLoadout[14] <- "mag7"
  65. WeaponLoadout[15] <- "deagle, molotov"
  66. WeaponLoadout[16] <- "xm1014"
  67. WeaponLoadout[17] <- "famas, hegrenade"
  68. WeaponLoadout[18] <- "nova, flashbang"
  69.  
  70. // late game
  71.  
  72. WeaponLoadout[19] <- "xm1014, flashbang"
  73. WeaponLoadout[20] <- "ak47"
  74. WeaponLoadout[21] <- "p90, hegrenade"
  75. WeaponLoadout[22] <- "sg556"
  76. WeaponLoadout[23] <- "m4a1, flashbang"
  77. WeaponLoadout[24] <- "ak47, molotov"
  78. WeaponLoadout[25] <- "galilar, hegrenade"
  79.  
  80. // PISTOLS: deagle, fiveseven, tec9, p250
  81. // HEAVY : sawedoff, nova, xm1014, mag7, m249
  82. // RIFLES : famas, sg556, ak47, galilar, aug, awp, m4a1
  83. // SMG : mp9, mp7, bizon, ump45, p90, mac10
  84. // NADES : hegrenade, smokegrenade, molotov, flashbang
  85.  
  86. m_CTs <- [];
  87.  
  88. function CollectCTs()
  89. {
  90. ent <- null;
  91.  
  92. while( ( ent = Entities.FindByClassname( ent, "player" ) ) != null )
  93. {
  94. if ( FindInArray( m_CTs, ent ) == null )
  95. {
  96. m_CTs.push( ent );
  97. }
  98. }
  99. }
  100.  
  101. function RoundInit() // called on OnLevelReset
  102. {
  103.  
  104. if (ISWARMUP == false)
  105. {
  106. wave = 0;
  107. EnemyDifficulty( 1 );
  108.  
  109. FASTTRAVEL1 = PERSISTENTCONTAINER.GetScriptScope().FASTTRAVEL1;
  110. FASTTRAVEL2 = PERSISTENTCONTAINER.GetScriptScope().FASTTRAVEL2;
  111. FASTTRAVEL3 = PERSISTENTCONTAINER.GetScriptScope().FASTTRAVEL3;
  112.  
  113. SendToConsoleServer( "mp_coopmission_bot_difficulty_offset 1" );
  114. ScriptCoopSetBotQuotaAndRefreshSpawns( 0 );
  115.  
  116. CollectCTs();
  117.  
  118. PLAYER_AMOUNT = m_CTs.len();
  119.  
  120. printl ("");
  121. printl ("PLAYER AMOUNT: " + PLAYER_AMOUNT );
  122. printl ("");
  123.  
  124. SetFloor(); // set up elevator, spawn points
  125.  
  126. EntFire("trigger.elevator_doors", "Enable", 0, 0);
  127. }
  128. else
  129. {
  130. printl ("");
  131. printl ("");
  132. printl ("We're in warmup so I D G A F");
  133. printl ("");
  134. printl ("");
  135. }
  136. }
  137.  
  138. SpawnCollection <- []
  139.  
  140. function CollectSpawns( name )
  141. {
  142. ent <- null;
  143.  
  144. while( ( ent = Entities.FindByName( ent, name ) ) != null )
  145. {
  146. if ( FindInArray( SpawnCollection, ent ) == null )
  147. {
  148. SpawnCollection.push( ent );
  149. }
  150. }
  151.  
  152. SetupSpawns();
  153.  
  154. }
  155.  
  156. function PlayersInElevator( var )
  157. {
  158. local amount = var;
  159. printl ("PLAYERS IN ELEVATOR : " + amount)
  160.  
  161. if (amount == PLAYER_AMOUNT)
  162. {
  163. EntFire("elevator.relay.startmove", "Trigger", 0, 0);
  164. }
  165. }
  166.  
  167. function Test()
  168. {
  169.  
  170.  
  171. RemoveDecalsAndGuns();
  172.  
  173.  
  174.  
  175. }
  176.  
  177. function EnemyDifficulty( difficulty ) // Updated via Progression();
  178. {
  179.  
  180. switch ( difficulty )
  181. {
  182. case 1:
  183. LoadoutType[0] = 1;
  184. LoadoutType[1] = 9;
  185. ENEMYAMOUNT = 6;
  186. break;
  187. case 2:
  188. LoadoutType[0] = 10;
  189. LoadoutType[1] = 18;
  190. ENEMYAMOUNT = 8;
  191. break;
  192. case 3:
  193. LoadoutType[0] = 19;
  194. LoadoutType[1] = 25;
  195. ENEMYAMOUNT = 10;
  196. break;
  197. }
  198.  
  199.  
  200.  
  201. }
  202.  
  203. function SetupSpawns()
  204. {
  205.  
  206. foreach (spawn in SpawnCollection)
  207. {
  208.  
  209. local loadout = WeaponLoadout[RandomInt( LoadoutType[0], LoadoutType[1] )];
  210.  
  211. spawn.__KeyValueFromString ("weapons_to_give", loadout );
  212.  
  213. printl ("Equipped bot with " + loadout);
  214.  
  215. }
  216.  
  217. if (wave >= 10)
  218. {
  219. local SpawnLen = SpawnCollection.len();
  220. local RandomPick = SpawnCollection[RandomInt( 0, SpawnLen - 1 )]
  221.  
  222. RandomPick.__KeyValueFromInt ("armor_to_give", 2 );
  223. RandomPick.__KeyValueFromString ("model_to_use", "models/player/custom_player/legacy/tm_phoenix_heavy.mdl" );
  224. }
  225.  
  226. }
  227.  
  228. function RespawnPlayers()
  229. {
  230. ScriptCoopMissionRespawnDeadPlayers();
  231. }
  232.  
  233. function Progression()
  234. {
  235.  
  236. printl ("WAVE IS CURRENTLY: " + wave);
  237.  
  238. if (wave <= 4)
  239. {
  240. EntFire( "floor_group1", "PickRandomShuffle", "", 0 );
  241. EnemyDifficulty( 1 );
  242. }
  243. else if (wave == 5)
  244. {
  245. SetNextFloor(9);
  246. }
  247. else if (wave >= 6 && wave <= 9)
  248. {
  249. EntFire( "floor_group2", "PickRandomShuffle", "", 0 );
  250. EnemyDifficulty( 2 );
  251. }
  252. else if (wave == 10)
  253. {
  254. SetNextFloor(9);
  255. }
  256. else if (wave >= 11 && wave <= 14)
  257. {
  258. EntFire( "floor_group3", "PickRandomShuffle", "", 0 );
  259. EnemyDifficulty( 3 );
  260. }
  261. else if (wave == 15)
  262. {
  263. SetNextFloor(9);
  264. }
  265. else if (wave >= 16 && wave <= 17)
  266. {
  267. EntFire( "floor_group4", "PickRandomShuffle", "", 0 );
  268. }
  269. else if (wave == 18)
  270. {
  271. SetNextFloor(16);
  272. }
  273.  
  274. }
  275.  
  276. function SetNextFloor( floor )
  277. {
  278. NEXTFLOOR = floor;
  279.  
  280. SetSpawnGroup();
  281. }
  282.  
  283. function SetFloor()
  284. {
  285. EntFire( "*-spawn", "SetDisabled", "", 0 ); // disable all spawns
  286.  
  287. // check if player has unlocked fast travel
  288.  
  289. printl ("FAST TRAVEL STAGE 3: " + FASTTRAVEL3);
  290. printl ("FAST TRAVEL STAGE 2: " + FASTTRAVEL2);
  291. printl ("FAST TRAVEL STAGE 1: " + FASTTRAVEL1);
  292.  
  293. if (FASTTRAVEL3 == true && wave <= 15)
  294. {
  295. wave = 16;
  296. }
  297. else if (FASTTRAVEL2 == true && wave <= 10)
  298. {
  299. wave = 11;
  300. }
  301. else if (FASTTRAVEL1 == true && wave <= 5)
  302. {
  303. wave = 6;
  304. }
  305. else
  306. {
  307. wave++;
  308. printl ("No fast travel unlocked");
  309. }
  310.  
  311. Progression();
  312. }
  313.  
  314. function SetSpawnGroup()
  315. {
  316.  
  317. local SpawnGroup = NEXTFLOOR + "-spawn";
  318. printl (SpawnGroup);
  319.  
  320. EntFire( SpawnGroup, "SetEnabled", "", 0.1 );
  321.  
  322. CollectSpawns( SpawnGroup );
  323.  
  324. }
  325.  
  326. function UnlockCheckpointSluice( players ) // check if players are spread out in different sluices
  327. {
  328.  
  329. if (players == PLAYER_AMOUNT)
  330. {
  331. EntFire( "@checkpoint_relay_start", "Trigger", "", 0 );
  332. }
  333.  
  334. }
  335.  
  336. DroppedWeapon <- null;
  337.  
  338. function RemoveDecalsAndGuns() // don't use this quite yet, it will remove the players weapons as well..
  339. {
  340. printl ("CLEANING UP, WOO!");
  341. SendToConsole("r_cleardecals");
  342.  
  343. // while((DroppedWeapon = Entities.FindByClassname(DroppedWeapon,"prop_physics")) != null)
  344. // {
  345. // DoEntFire("!self","Kill","0",0,null,DroppedWeapon); // Will fire on named and un-named entities alike.
  346. // }
  347.  
  348. }
  349.  
  350. function ElevatorSetFloor() // run when entering elevator
  351. {
  352. EntFire( "elevator.mover", "RunScriptCode", "SetTargetFloor(" + NEXTFLOOR + ")", 0 );
  353. }
  354.  
  355. function ElevatorArrived() // run when elevator stops moving
  356. {
  357.  
  358. if ( wave == 1 )
  359. {
  360. SpawnFirstEnemies( ENEMYAMOUNT );
  361. }
  362. else
  363. {
  364. SpawnNextWave( ENEMYAMOUNT );
  365. }
  366.  
  367. }
  368.  
  369. function SpawnFirstEnemies( amount )
  370. {
  371. ScriptCoopMissionSpawnFirstEnemies( amount );
  372. ScriptCoopResetRoundStartTime();
  373. }
  374.  
  375. function SpawnNextWave( amount )
  376. {
  377. ScriptCoopMissionSpawnNextWave( amount );
  378. }
  379.  
  380. function OnMissionCompleted()
  381. {
  382. // fade out screen, end round
  383. EntFire( "@screen_fade", "Fade", "", 0.0 );
  384. EntFire( "@game_end", "EndRound_CounterTerroristsWin", "3", 0.0 );
  385.  
  386. }
  387.  
  388. function OnRoundLostKilled()
  389. {
  390. //what will happen if you loose the round because you died (you could tell the players that your grandma is better than them)
  391.  
  392. }
  393.  
  394. function OnRoundLostTime()
  395. {
  396. //what will happen if you loose the round because the time runs out (you could tell the player that they are like turtles)
  397.  
  398. }
  399.  
  400. function OnRoundReset()
  401. {
  402. //called when the round resets
  403. // IMPORTANT: you need a game_coopmission_manager that has the output 'OnLevelReset' when this is called you NEED to call this function
  404. // in order for the level to work properly every round!
  405. RoundInit();
  406. }
  407.  
  408. function OnSpawnsReset()
  409. {
  410. //called right before the round resets (usually used for correcting stuff when on a new round other stuff is immediately called)
  411. //enabled/disabled the correct spawns for the start. * means every group going from Terrorist_00 to infinite enemygroup_example
  412. EntFire( "*-spawn", "SetDisabled", "", 0 );
  413. EntFire( "*-CT", "SetDisabled", "", 0 );
  414. EntFire( "1-CT", "SetEnabled", "", 0 );
  415. }
  416.  
  417. function OnWaveCompleted()
  418. {
  419. if (wave < 18)
  420. {
  421. SpawnCollection.clear();
  422. SetFloor();
  423. EntFire("elevator.relay.unlock", "Trigger", 0, 0);
  424. }
  425. else if (wave == 18)
  426. {
  427. printl ("that was the final wave");
  428. OnMissionCompleted()
  429. }
  430.  
  431. if (wave == 6) // TODO: this one and the next should both be in a checkpoint fight, fast travel unlocked via level script. ooooor just increase enemy amount for checkpoint fights?
  432. {
  433. EntFire( "@script_varcontainer", "RunScriptCode", "SetFastTravelVar(" + 1 + ")", 0 );
  434. ScriptPrintMessageCenterAll ("Fast travel to floor 6 unlocked!");
  435. }
  436. if (wave == 11)
  437. {
  438. EntFire( "@script_varcontainer", "RunScriptCode", "SetFastTravelVar(" + 2 + ")", 0 );
  439. ScriptPrintMessageCenterAll ("Fast travel to floor 11 unlocked!");
  440. }
  441. if (wave == 16)
  442. {
  443. EntFire( "@script_varcontainer", "RunScriptCode", "SetFastTravelVar(" + 3 + ")", 0 );
  444. ScriptPrintMessageCenterAll ("Fast travel to floor 16 unlocked!");
  445. }
  446.  
  447.  
  448. //Check which wave the player is and do stuff
  449. // if ( wave == 1 )
  450. // {
  451. // EntFire( "wave_*", "SetDisabled", "", 0 );
  452. // EntFire( "wave_02", "SetEnabled", "", 0 );
  453. // EntFire( "door_wave_01", "Unlock", "", 1 );
  454. // EntFire( "door_wave_01", "SetGlowEnabled", "", 1 );
  455. // }
  456. // else if ( wave == 2 )
  457. // {
  458. // EntFire( "wave_*", "SetDisabled", "", 0 );
  459. // EntFire( "wave_03", "SetEnabled", "", 0 );
  460. // EntFire( "door_wave_02", "Unlock", "", 1 );
  461. // EntFire( "door_wave_02", "SetGlowEnabled", "", 1 );
  462. // }
  463. // else if ( wave == 3 )
  464. // {
  465. // EntFire( "door_wave_03", "Unlock", "", 1 );
  466. // EntFire( "door_wave_03", "SetGlowEnabled", "", 1 );
  467. // }
  468.  
  469.  
  470. }
  471.  
  472. function ChangeGameModeToCoopIfNotCorrect()
  473. {
  474. // This will change the game mode and game type if the player has not initialized this before starting the map.
  475. local game_mode = ScriptGetGameMode();
  476. local game_type = ScriptGetGameType();
  477. local map = GetMapName();
  478.  
  479. if (game_mode != 1 || game_type != 4)
  480. {
  481. SendToConsole("game_mode 1; game_type 4; changelevel " + map);
  482. }
  483. }
  484.  
  485. // util stuff
  486.  
  487. function FindInArray( array, thing )
  488. {
  489. foreach( i, elem in array )
  490. {
  491. if ( elem == thing )
  492. return i;
  493. }
  494.  
  495. return null;
  496. }
  497.  
  498. function debugPrint( text )
  499. {
  500. if ( DEBUG == false )
  501. return;
  502.  
  503. printl( text );
  504. }
Add Comment
Please, Sign In to add comment