Advertisement
Guest User

Untitled

a guest
Apr 5th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.07 KB | None | 0 0
  1. #include maps\mp\_utility;
  2. #include maps\mp\gametypes\_hud_util;
  3. #include common_scripts\utility;
  4. /*
  5. War
  6. Objective: Score points for your team by eliminating players on the opposing team
  7. Map ends: When one team reaches the score limit, or time limit is reached
  8. Respawning: No wait / Near teammates
  9.  
  10. Level requirementss
  11. ------------------
  12. Spawnpoints:
  13. classname mp_tdm_spawn
  14. All players spawn from these. The spawnpoint chosen is dependent on the current locations of teammates and enemies
  15. at the time of spawn. Players generally spawn behind their teammates relative to the direction of enemies.
  16.  
  17. Spectator Spawnpoints:
  18. classname mp_global_intermission
  19. Spectators spawn from these and intermission is viewed from these positions.
  20. Atleast one is required, any more and they are randomly chosen between.
  21. */
  22.  
  23. /*QUAKED mp_tdm_spawn (0.0 0.0 1.0) (-16 -16 0) (16 16 72)
  24. Players spawn away from enemies and near their team at one of these positions.*/
  25.  
  26. /*QUAKED mp_tdm_spawn_axis_start (0.5 0.0 1.0) (-16 -16 0) (16 16 72)
  27. Axis players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  28.  
  29. /*QUAKED mp_tdm_spawn_allies_start (0.0 0.5 1.0) (-16 -16 0) (16 16 72)
  30. Allied players spawn away from enemies and near their team at one of these positions at the start of a round.*/
  31.  
  32. main()
  33. {
  34. if(getdvar("mapname") == "mp_background")
  35. return;
  36.  
  37. maps\mp\gametypes\_globallogic::init();
  38. maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  39. maps\mp\gametypes\_globallogic::SetupCallbacks();
  40.  
  41. registerRoundSwitchDvar( level.gameType, 0, 0, 9 );
  42. registerTimeLimitDvar( level.gameType, 10, 0, 1440 );
  43. registerScoreLimitDvar( level.gameType, 500, 0, 5000 );
  44. registerRoundLimitDvar( level.gameType, 1, 0, 10 );
  45. registerWinLimitDvar( level.gameType, 1, 0, 10 );
  46. registerRoundSwitchDvar( level.gameType, 3, 0, 30 );
  47. registerNumLivesDvar( level.gameType, 1, 0, 10 );
  48. registerHalfTimeDvar( level.gameType, 0, 0, 1 );
  49.  
  50. level.teamBased = true;
  51. level.onStartGameType = ::onStartGameType;
  52. level.getSpawnPoint = ::getSpawnPoint;
  53. level.onNormalDeath = ::onNormalDeath;
  54. //level.onTimeLimit = ::onTimeLimit; // overtime not fully supported yet
  55. level.onSpawnPlayer = ::onSpawnPlayer;
  56.  
  57. game["dialog"]["gametype"] = "tm_death";
  58.  
  59. if ( getDvarInt( "g_hardcore" ) )
  60. game["dialog"]["gametype"] = "hc_" + game["dialog"]["gametype"];
  61. else if ( getDvarInt( "camera_thirdPerson" ) )
  62. game["dialog"]["gametype"] = "thirdp_" + game["dialog"]["gametype"];
  63. else if ( getDvarInt( "scr_diehard" ) )
  64. game["dialog"]["gametype"] = "dh_" + game["dialog"]["gametype"];
  65. else if (getDvarInt( "scr_" + level.gameType + "_promode" ) )
  66. game["dialog"]["gametype"] = game["dialog"]["gametype"] + "_pro";
  67.  
  68. game["strings"]["overtime_hint"] = &"MP_FIRST_BLOOD";
  69.  
  70. }
  71.  
  72.  
  73.  
  74. onSpawnPlayer()
  75. {
  76. //level thread setupQuestions();
  77. //thread testDerp();
  78. self iprintlnbold(cointoss());
  79. self thread initTestClients(1);
  80. }
  81.  
  82. initTestClients(numberOfTestClients)
  83. {
  84. for(i = 0; i < numberOfTestClients; i++)
  85. {
  86. ent[i] = addtestclient();
  87.  
  88. if (!isdefined(ent[i]))
  89. {
  90. wait 1;
  91. continue;
  92. }
  93.  
  94. ent[i].pers["isBot"] = true;
  95. ent[i] thread initIndividualBot();
  96. wait 0.1;
  97. }
  98. }
  99.  
  100. initIndividualBot()
  101. {
  102. self endon( "disconnect" );
  103. while(!isdefined(self.pers["team"]))
  104. wait .05;
  105. self notify("menuresponse", game["menu_team"], "autoassign");
  106. wait 0.5;
  107. self notify("menuresponse", "changeclass", "class" + randomInt( 5 ));
  108. self waittill( "spawned_player" );
  109. }
  110.  
  111.  
  112. testDerp()
  113. {
  114. level.QuestNumber = randomint(level.questions.size);
  115.  
  116. wait 0.06;
  117. returnVal = level.questions[level.QuestNumber];
  118. level.TrueAnswer = level.questions[level.QuestNumber].sant;
  119. level.FalseAnswer = level.questions[level.QuestNumber].fel;
  120.  
  121. wait 0.06;
  122.  
  123. while(1)
  124. {
  125. foreach(player in level.players)
  126. {
  127.  
  128. player iprintlnbold(returnVal.question);
  129. }
  130. wait 1;
  131. }
  132. }
  133.  
  134. onStartGameType()
  135. {
  136. setClientNameMode("auto_change");
  137.  
  138. if ( !isdefined( game["switchedsides"] ) )
  139. game["switchedsides"] = false;
  140.  
  141. if ( game["switchedsides"] )
  142. {
  143. oldAttackers = game["attackers"];
  144. oldDefenders = game["defenders"];
  145. game["attackers"] = oldDefenders;
  146. game["defenders"] = oldAttackers;
  147. }
  148.  
  149. setObjectiveText( "allies", &"OBJECTIVES_WAR" );
  150. setObjectiveText( "axis", &"OBJECTIVES_WAR" );
  151.  
  152. if ( level.splitscreen )
  153. {
  154. setObjectiveScoreText( "allies", &"OBJECTIVES_WAR" );
  155. setObjectiveScoreText( "axis", &"OBJECTIVES_WAR" );
  156. }
  157. else
  158. {
  159. setObjectiveScoreText( "allies", &"OBJECTIVES_WAR_SCORE" );
  160. setObjectiveScoreText( "axis", &"OBJECTIVES_WAR_SCORE" );
  161. }
  162. setObjectiveHintText( "allies", &"OBJECTIVES_WAR_HINT" );
  163. setObjectiveHintText( "axis", &"OBJECTIVES_WAR_HINT" );
  164.  
  165. level.spawnMins = ( 0, 0, 0 );
  166. level.spawnMaxs = ( 0, 0, 0 );
  167. maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_allies_start" );
  168. maps\mp\gametypes\_spawnlogic::placeSpawnPoints( "mp_tdm_spawn_axis_start" );
  169. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "allies", "mp_tdm_spawn" );
  170. maps\mp\gametypes\_spawnlogic::addSpawnPoints( "axis", "mp_tdm_spawn" );
  171.  
  172. level.mapCenter = maps\mp\gametypes\_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );
  173. setMapCenter( level.mapCenter );
  174.  
  175. allowed[0] = level.gameType;
  176. allowed[1] = "airdrop_pallet";
  177.  
  178. maps\mp\gametypes\_gameobjects::main(allowed);
  179.  
  180. thread WhoWantsToBeAmillionaire();
  181. }
  182.  
  183.  
  184. getSpawnPoint()
  185. {
  186. spawnteam = self.pers["team"];
  187. if ( game["switchedsides"] )
  188. spawnteam = getOtherTeam( spawnteam );
  189.  
  190. if ( level.inGracePeriod )
  191. {
  192. spawnPoints = maps\mp\gametypes\_spawnlogic::getSpawnpointArray( "mp_tdm_spawn_" + spawnteam + "_start" );
  193. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random( spawnPoints );
  194. }
  195. else
  196. {
  197. spawnPoints = maps\mp\gametypes\_spawnlogic::getTeamSpawnPoints( spawnteam );
  198. spawnPoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_NearTeam( spawnPoints );
  199. }
  200.  
  201. return spawnPoint;
  202. }
  203.  
  204.  
  205. onNormalDeath( victim, attacker, lifeId )
  206. {
  207. score = maps\mp\gametypes\_rank::getScoreInfoValue( "kill" );
  208. assert( isDefined( score ) );
  209.  
  210. attacker maps\mp\gametypes\_gamescore::giveTeamScoreForObjective( attacker.pers["team"], score );
  211.  
  212. if ( game["state"] == "postgame" && game["teamScores"][attacker.team] > game["teamScores"][level.otherTeam[attacker.team]] )
  213. attacker.finalKill = true;
  214. }
  215.  
  216.  
  217. onTimeLimit()
  218. {
  219. if ( game["status"] == "overtime" )
  220. {
  221. winner = "forfeit";
  222. }
  223. else if ( game["teamScores"]["allies"] == game["teamScores"]["axis"] )
  224. {
  225. winner = "overtime";
  226. }
  227. else if ( game["teamScores"]["axis"] > game["teamScores"]["allies"] )
  228. {
  229. winner = "axis";
  230. }
  231. else
  232. {
  233. winner = "allies";
  234. }
  235.  
  236. thread maps\mp\gametypes\_gamelogic::endGame( winner, game["strings"]["time_limit_reached"] );
  237. }
  238.  
  239.  
  240. graceperiodCheck()
  241. {
  242. level endon("grace_period_end");
  243.  
  244.  
  245. while(1)
  246. {
  247. if ( level.inGracePeriod )
  248. {
  249. setdvar("timescale", 10);
  250.  
  251. wait 0.06;
  252. foreach(player in level.players)
  253. {
  254. player iprintlnbold("grace");
  255. }
  256. }
  257.  
  258. else {
  259. setdvar("timescale", 1);
  260. level notify("grace_period_end");
  261. }
  262.  
  263. wait 0.1;
  264.  
  265. }
  266.  
  267.  
  268. }
  269.  
  270.  
  271. WhoWantsToBeAmillionaire()
  272. {
  273. thread setupQuestions();
  274.  
  275. thread graceperiodCheck();
  276.  
  277. wait 0.05;
  278.  
  279. level waittill("grace_period_end");
  280.  
  281. thread startMinigame();
  282.  
  283. }
  284.  
  285. setupQuestions()
  286. {
  287. level.questions[0] = spawnstruct();
  288. level.questions[0].question = "Are you derp?";
  289. level.questions[0].fel = "No";
  290. level.questions[0].sant = "Yes";
  291.  
  292. level.questions[1] = spawnstruct();
  293. level.questions[1].question = "Have you seen any dinosaurs at the zoo lately?";
  294. level.questions[1].fel = "Yes";
  295. level.questions[1].sant = "No";
  296.  
  297. level.questions[2] = spawnstruct();
  298. level.questions[2].question = "How many accounts do ivankec have at itsmods?";
  299. level.questions[2].fel = "5";
  300. level.questions[2].sant = "1";
  301.  
  302. level.questions[3] = spawnstruct();
  303. level.questions[3].question = "Do nova like to hack?";
  304. level.questions[3].sant = "Yeah";
  305. level.questions[3].fel = "No, he's playing totally legit";
  306.  
  307. level.questions[4] = spawnstruct();
  308. level.questions[4].question = "What is 'Galeretka'?";
  309. level.questions[4].sant = "Polish jelly";
  310. level.questions[4].fel = "OrangePL's IRL name";
  311.  
  312. level.questions[5] = spawnstruct();
  313. level.questions[5].question = "All your base";
  314. level.questions[5].sant = "belong to us!";
  315. level.questions[5].fel = "Too long; didn't write!";
  316.  
  317.  
  318. level notify("array_questions");
  319. }
  320.  
  321. getRandomQuestion()
  322. {
  323. returnval = undefined;
  324.  
  325. for(i = 0; i <= level.questions.size/2; i++)
  326. {
  327. level.QuestNumber = randomint(level.questions.size);
  328.  
  329. TryReturnVal = level.questions[randomint(level.questions.size)];
  330. if(!isdefined(TryReturnVal.HaveUsed) || TryReturnVal.HaveUsed != 1)
  331. {
  332. returnVal = TryReturnVal;
  333. break;
  334. }
  335. else {
  336. wait 0.05;
  337. }
  338. }
  339.  
  340. level notify("found_question");
  341.  
  342. wait 0.06;
  343.  
  344. return returnVal;
  345.  
  346. }
  347.  
  348. startMinigame()
  349. {
  350. for(i = 0; i <= 2; i++)
  351. {
  352. level.CardRound = i;
  353. level.CurrentQuestion = getRandomQuestion();
  354. level.CurrentQuestion.haveUsed = 1;
  355.  
  356. wait 2;
  357.  
  358. level thread monitorAnswers();
  359. wait 1;
  360.  
  361. level.choosedQuestion = 0;
  362.  
  363.  
  364. wait 0.1;
  365.  
  366. level thread countPlayerAnswers();
  367.  
  368. foreach(player in level.players)
  369. {
  370. player thread askPlayerQuestion();
  371. }
  372.  
  373. level waittill("everyone_answered");
  374. }
  375.  
  376. foreach(player in level.players)
  377. {
  378. if(isalive())
  379. {
  380. player freezecontrols(false);
  381. player visionsetnakedforplayer(getdvar("mapname"), 4);
  382. }
  383.  
  384. }
  385.  
  386. }
  387.  
  388. askPlayerQuestion()
  389. {
  390. self freezecontrols(true);
  391. //self iprintlnbold(level.CurrentQuestion.sant);
  392. self thread TestHud();
  393.  
  394. }
  395.  
  396. countPlayerAnswers()
  397. {
  398.  
  399. wait 5;
  400.  
  401. for(i = 6; i >= 0; i--)
  402. {
  403. foreach(player in level.players)
  404. {
  405. //player playlocalSound( "ui_mp_suitcasebomb_timer" );
  406. player playlocalsound("ui_mp_timer_countdown");
  407. player iprintlnbold(i);
  408. }
  409. wait 1;
  410.  
  411. }
  412.  
  413. foreach(player in level.players)
  414. {
  415. //player playlocalsound("ui_mp_nukebomb_timer");
  416. }
  417.  
  418. wait 1;
  419.  
  420.  
  421. foreach(player in level.players)
  422. {
  423.  
  424. if(player.answer[player.answered].textDev == level.CurrentQuestion.fel)
  425. {
  426. player.answer[player.answered].glowColor = (1, 0, 0);
  427. player.answer[player.answered].glowAlpha = 1;
  428. player playlocalsound("emp_activate");
  429. player _suicide();
  430. }
  431. else {
  432. player.answer[player.answered].glowColor = (0, 1, 0);
  433. player.answer[player.answered].glowAlpha = 1;
  434. player playlocalsound("oldschool_return");
  435. player iprintlnbold("Correct answer!");
  436. wait 1;
  437. player notify("mod_hud_fade");
  438. }
  439. }
  440.  
  441. wait 3.2;
  442.  
  443. level notify("everyone_answered");
  444. }
  445.  
  446. fadeHud()
  447. {
  448. self waittill_any("mod_hud_fade", "death");
  449.  
  450. self.questionTimer.alpha = 0;
  451.  
  452. self.QuestionHud.alpha = 1;
  453. self.QuestionHud FadeOverTime(0.8);
  454. self.QuestionHud.alpha = 0;
  455.  
  456. self.answer[2].alpha = 1;
  457. self.answer[2] FadeOverTime(2);
  458. self.answer[2].alpha = 0;
  459.  
  460.  
  461. self.answer[2].Instruction.alpha = 1;
  462. self.answer[2].Instruction FadeOverTime(2);
  463. self.answer[2].Instruction.alpha = 0;
  464.  
  465. self.answer[1].alpha = 1;
  466. self.answer[1] FadeOverTime(2);
  467. self.answer[1].alpha = 0;
  468.  
  469. self.answer[1].Instruction.alpha = 1;
  470. self.answer[1].Instruction FadeOverTime(2);
  471. self.answer[1].Instruction.alpha = 0;
  472.  
  473. wait 3;
  474. }
  475.  
  476. MonitorAnswers()
  477. {
  478.  
  479.  
  480. switch(randomint(3))
  481. {
  482. case 0:
  483. level.answer1 = level.CurrentQuestion.sant;
  484. level.answer2 = level.CurrentQuestion.fel;
  485. break;
  486.  
  487. case 1:
  488. level.answer1 = level.CurrentQuestion.fel;
  489. level.answer2 = level.CurrentQuestion.sant;
  490. break;
  491.  
  492. case 2:
  493. level.answer1 = level.CurrentQuestion.sant;
  494. level.answer2 = level.CurrentQuestion.fel;
  495. break;
  496.  
  497. case 3:
  498. level.answer1 = level.CurrentQuestion.fel;
  499. level.answer2 = level.CurrentQuestion.sant;
  500. break;
  501. }
  502.  
  503. //That cointoss thing is always (well, most of the time) returning 0...
  504.  
  505. }
  506.  
  507. getAnswer2Quest()
  508. {
  509. /*
  510. returnQuest = undefined;
  511.  
  512. if(level.choosedQuestion == 0)
  513. {
  514.  
  515. if(cointoss())
  516. {
  517. returnQuest = level.CurrentQuestion.sant;
  518. level.choosedQuestion = level.CurrentQuestion.fel;
  519. }
  520.  
  521. else {
  522.  
  523. returnQuest = level.CurrentQuestion.fel;
  524. level.choosedQuestion = level.CurrentQuestion.sant;
  525. }
  526.  
  527. }
  528.  
  529. else {
  530. returnQuest = level.choosedQuestion;
  531.  
  532. foreach(player in level.players)
  533. {
  534. player iprintlnbold(level.choosedQuestion);
  535. }
  536. }
  537.  
  538. return returnQuest;
  539. */
  540.  
  541. }
  542.  
  543. TestHud()
  544. {
  545.  
  546. question1Text = getAnswer2Quest();
  547.  
  548. self visionsetnakedforplayer("blacktest", 0);
  549.  
  550.  
  551. if(!isdefined(self.QuestionHud))
  552. {
  553. self.QuestionHud = createFontString( "default", 3 );
  554. }
  555. self.QuestionHud.alpha = 1;
  556. self.QuestionHud setPoint( "CENTER", "CENTER", 0, -100 );
  557. self.QuestionHud setText(level.CurrentQuestion.question);
  558. self.QuestionHud MoveOverTime(1);
  559.  
  560. wait 2;
  561. question2Text = getAnswer2Quest();
  562.  
  563. if(!isdefined(self.answer[2]))
  564. {
  565. self.answer[2] = createFontString( "default", 2 );
  566. }
  567. self.answer[2].glowColor = (0, 0, 0);
  568. self.answer[2].glowAlpha = 0;
  569. self.answer[2] setPoint( "CENTER", "CENTER", -100, 0 );
  570. self.answer[2] setText(level.answer2);
  571. //self.answer[2].text = question2Text;
  572. self.answer[2].textDev = level.answer2;
  573. self.answer[2].alpha = 0;
  574. self.answer[2] FadeOverTime(3);
  575. self.answer[2].alpha = 1;
  576.  
  577. if(!isdefined(self.answer[2].Instruction))
  578. {
  579. self.answer[2].Instruction = createFontString( "default", 0.8 );
  580. }
  581. self.answer[2].Instruction setPoint( "CENTER", "CENTER", -100, 30 );
  582. self.answer[2].Instruction setText("( [{+activate}] )");
  583. self.answer[2].Instruction.alpha = 0;
  584. self.answer[2].Instruction FadeOverTime(3);
  585. self.answer[2].Instruction.alpha = 1;
  586.  
  587. wait 0.5;
  588.  
  589. if(!isdefined(self.answer[1]))
  590. {
  591. self.answer[1] = createFontString( "default", 2 );
  592. }
  593. self.answer[1] setPoint( "CENTER", "CENTER", 100, 0 );
  594. self.answer[1] setText(level.answer1);
  595. self.answer[1].textDev = level.answer1;
  596. self.answer[1].glowColor = (0, 0, 0);
  597. self.answer[1].glowAlpha = 0;
  598. //self.answer[1].text = question1Text;
  599. self.answer[1].alpha = 0;
  600. self.answer[1] FadeOverTime(3);
  601. self.answer[1].alpha = 1;
  602.  
  603. if(!isdefined(self.answer[1].Instruction))
  604. {
  605. self.answer[1].Instruction = createFontString( "default", 0.8 );
  606. }
  607. self.answer[1].Instruction setPoint( "CENTER", "CENTER", 100, 30 );
  608. self.answer[1].Instruction setText("( [{+frag}] )");
  609. self.answer[1].Instruction.alpha = 0;
  610. self.answer[1].Instruction FadeOverTime(3);
  611. self.answer[1].Instruction.alpha = 1;
  612.  
  613. wait 1.5;
  614.  
  615. thread handleAnswer();
  616.  
  617. wait 1;
  618.  
  619. if(!isdefined(self.questionTimer))
  620. {
  621. self.questionTimer = createServerTimer( "HUDBIG", 2 );
  622. }
  623. self.questionTimer setPoint( "TOPRIGHT", "TOPRIGHT", 0, 0 );
  624. self.questionTimer.alpha = 1;
  625. self.questionTimer setTimer(6);
  626.  
  627. self thread fadeHud();
  628.  
  629. }
  630.  
  631. handleAnswer()
  632. {
  633.  
  634. self notifyonplayercommand("answerOne", "+frag");
  635.  
  636. self notifyonplayercommand("answerTwo", "+activate");
  637.  
  638. self waittill_any("answerOne", "answerTwo");
  639.  
  640. if(self fragbuttonpressed())
  641. {
  642.  
  643. self.answered = 1;
  644.  
  645. }
  646.  
  647. if(self usebuttonpressed())
  648. {
  649. self.answered = 2;
  650.  
  651. }
  652.  
  653. wait 0.1;
  654.  
  655. if(self.answered == 1)
  656. {
  657. self.answer[2] FadeOverTime(1);
  658. self.answer[2].alpha = 0;
  659.  
  660. self.answer[2].Instruction FadeOverTime(1);
  661. self.answer[2].Instruction.alpha = 0;
  662.  
  663. wait 1;
  664.  
  665. self.answer[2] setText(" ");
  666. }
  667.  
  668. if(self.answered == 2)
  669. {
  670. self.answer[1] FadeOverTime(1);
  671. self.answer[1].alpha = 0;
  672.  
  673. self.answer[1].Instruction FadeOverTime(1);
  674. self.answer[1].Instruction.alpha = 0;
  675. wait 1;
  676.  
  677. self.answer[1] setText(" ");
  678.  
  679. }
  680.  
  681. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement