Advertisement
Guest User

Untitled

a guest
May 29th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.83 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. //***************
  6. //***************
  7. //** Gun Game **
  8. //** By Rockey **
  9. //***************
  10. //***************
  11.  
  12. initGuns()
  13. {
  14. self.inverse = false;
  15. self.upgscore = 100;
  16. self.finalkills = 3;
  17. self.gunList = [];
  18. self.gunList[0] = createGun("deserteaglegold_mp", 9, false, false);
  19. self.gunList[1] = createGun("beretta_fmj_mp", 9, false, false);
  20. self.gunList[2] = createGun("usp_fmj_mp", 9, false, false);
  21. self.gunList[3] = createGun("coltanaconda_fmj_mp", 9, false, false);
  22. self.gunList[4] = createGun("m4_mp", 9, false, false);
  23. self.gunList[5] = createGun("famas_mp", 9, false, false);
  24. self.gunList[6] = createGun("scar_mp", 9, false, false);
  25. self.gunList[7] = createGun("fal_mp", 9, false, false);
  26. self.gunList[8] = createGun("tavor_mp", 9, false, false);
  27. self.gunList[9] = createGun("m16_mp", 9, true, false);
  28. self.gunList[10] = createGun("masada_mp", 9, false, false);
  29. self.gunList[11] = createGun("fn2000_mp", 9, false, false);
  30. self.gunList[12] = createGun("ak47_mp", 9, false, false);
  31. self.gunList[13] = createGun("at4_mp", 9, true, false);
  32. self.gunList[14] = createGun("m79_mp", 9, false, false);
  33. self.gunList[15] = createGun("rpg_mp", 9, false, false);
  34. self.gunList[16] = createGun("mp5k_mp", 9, false, false);
  35. self.gunList[17] = createGun("ump45_reflex_rof_mp", 9, true, false);
  36. self.gunList[18] = createGun("kriss_mp", 9, false, false);
  37. self.gunList[19] = createGun("p90_mp", 9, false, false);
  38. self.gunList[20] = createGun("uzi_mp", 9, false, false);
  39. self.gunList[21] = createGun("spas12_mp", 9, false, false);
  40. self.gunList[22] = createGun("aa12_mp", 9, false, false);
  41. self.gunList[23] = createGun("striker_mp", 9, false, false);
  42. self.gunList[24] = createGun("m1014_mp", 9, false, false);
  43. self.gunList[25] = createGun("ranger_akimbo_mp", 9, true, true);
  44. self.gunList[26] = createGun("model1887_akimbo_mp", 9, true, true);
  45. self.gunList[27] = createGun("pp2000_mp", 9, false, false);
  46. self.gunList[28] = createGun("beretta393_akimbo_mp", 9, false, false);
  47. self.gunList[29] = createGun("glock_mp", 9,false, false);
  48. self.gunList[30] = createGun("tmp_mp", 9, false, false);
  49. self.gunList[31] = createGun("cheytac_fmj_mp", 9, false, false);
  50. self.gunList[32] = createGun("barrett_fmj_mp", 9, false, false);
  51. self.gunList[33] = createGun("wa2000_fmj_mp", 9, false, false);
  52. self.gunList[34] = createGun("m21_fmj_mp", 9, false, false);
  53. self.gunList[35] = createGun("mg4_grip_mp", 9, true, false);
  54. self.gunList[36] = createGun("sa80_mp", 9, false, false);
  55. self.gunList[37] = createGun("aug_mp", 9, false, false);
  56. self.gunList[38] = createGun("rpd_grip_mp", 9, true, false);
  57. self.gunList[39] = createGun("throwingknife_mp", 9, false, false);
  58. self.gunList[40] = createGun("javelin_mp", 9, true, false);
  59. }
  60.  
  61. createGun(gunName, camo, laserSight, akimbo)
  62. {
  63. gun = spawnstruct();
  64. gun.name = gunName;
  65. gun.camo = camo;
  66. gun.laser = laserSight;
  67. gun.akimbo = akimbo;
  68. return gun;
  69. }
  70.  
  71. doBinds() //Put persistent threads that are started once here
  72. {
  73. self.firstRun = true;
  74. self thread initGuns();
  75. self.nv = false;
  76. self thread killCrosshairs();
  77. self thread doScore();
  78. self thread doGun();
  79. setDvar("scr_dm_scorelimit", ((self.gunList.size - 1) * self.upgscore) + (self.finalkills * 50));
  80. setDvar("scr_dm_timelimit", 0);
  81. setDvar("ui_gametype", "ffa");
  82. setDvar("scr_game_killstreakdelay", 99999999);
  83. }
  84.  
  85. doDvars() //Put threads that are called with every respawn
  86. {
  87. setDvar("g_speed", 220);
  88. setDvar("bg_fallDamageMaxHeight", 1);
  89. setDvar("bg_fallDamageMinHeight", 99999);
  90. setDvar("perk_weapReloadMultiplier", 0.001);
  91. setDvar("player_burstFireCooldown", 0);
  92. setDvar("bg_fallDamageMaxHeight", 1);
  93. self setClientDvar("player_meleerange", 0);
  94. self _clearPerks();
  95. self maps\mp\perks\_perks::givePerk("specialty_fastmantle");
  96. self maps\mp\perks\_perks::givePerk("specialty_bulletdamage");
  97. self maps\mp\perks\_perks::givePerk("specialty_bulletaccuracy");
  98. self maps\mp\perks\_perks::givePerk("specialty_bulletpenetration");
  99. self maps\mp\perks\_perks::givePerk("specialty_coldblooded");
  100. self maps\mp\perks\_perks::givePerk("specialty_extendedmelee");
  101. self maps\mp\perks\_perks::givePerk("specialty_extraammo");
  102. self maps\mp\perks\_perks::givePerk("specialty_falldamage");
  103. self maps\mp\perks\_perks::givePerk("specialty_fastreload");
  104. self maps\mp\perks\_perks::givePerk("specialty_fastsnipe");
  105. self maps\mp\perks\_perks::givePerk("specialty_fastsprintrecovery");
  106. self maps\mp\perks\_perks::givePerk("specialty_lightweight");
  107. self maps\mp\perks\_perks::givePerk("specialty_marathon");
  108. self maps\mp\perks\_perks::givePerk("specialty_quieter");
  109. self maps\mp\perks\_perks::givePerk("specialty_scavenger");
  110. if(self.nv) self VisionSetNakedForPlayer("default_night_mp", 1);
  111. else self VisionSetNakedForPlayer(getDvar("mapname"), 2);
  112. self thread doNV();
  113. if(self.firstRun){
  114. if(self.inverted){
  115. self thread maps\mp\gametypes\_hud_message::hintMessage("^9Gun Game ^1By Rockey");
  116. self thread maps\mp\gametypes\_hud_message::hintMessage("^9Credits to ^1A^0L^1U^0C^1A^0R^1D ^9& ^1Aean");
  117. self thread maps\mp\gametypes\_hud_message::hintMessage("^1Two kills to Upgrade Gun^9, Have Fun!");
  118. }else{
  119. self thread maps\mp\gametypes\_hud_message::hintMessage("^9Gun Game ^1By Rockey");
  120. self thread maps\mp\gametypes\_hud_message::hintMessage("^1Two kills to Upgrade Gun");
  121. self thread maps\mp\gametypes\_hud_message::hintMessage("^9Modded by ^1Rockey");
  122. }
  123. self thread maps\mp\gametypes\_hud_message::hintMessage("^9Press [{+actionslot 1}] to Toggle ^2Night Vision");
  124. self.firstRun = false;
  125. }
  126. }
  127.  
  128. doGun()
  129. {
  130. self endon("disconnect");
  131. if(self.inverse) self.curgun = self.gunList.size - 1;
  132. else self.curgun = 0;
  133. curscore = 0;
  134. done = false;
  135. while(true){
  136. if(self.inverse && self.curgun <= 0) done = true;
  137. if(!self.inverse && self.curgun >= (self.gunList.size - 1)) done = true;
  138. if(!done){
  139. if(self.inverse && (self.score - curscore >= self.upgscore)){
  140. self.curgun--;
  141. self thread maps\mp\gametypes\_hud_message::hintMessage("^1Weapon Upgraded!");
  142. curscore = self.score;
  143. }else if((self.score - curscore >= self.upgscore)){
  144. self.curgun++;
  145. self thread maps\mp\gametypes\_hud_message::hintMessage("^1Weapon Upgraded!");
  146. curscore = self.score;
  147. }
  148. }
  149. while(self getCurrentWeapon() != self.gunList[self.curgun].name){
  150. if(self.gunList[self.curgun].laser) self setclientDvar("laserForceOn", 1);
  151. else self setclientDvar("laserForceOn", 0);
  152. self takeAllWeapons();
  153. self giveWeapon(self.gunList[self.curgun].name, self.gunList[self.curgun].camo, self.gunList[self.curgun].akimbo);
  154. self switchToWeapon(self.gunList[self.curgun].name);
  155. wait .2;
  156. }
  157. self giveMaxAmmo(self.gunList[self.curgun].name);
  158. wait .2;
  159. }
  160. }
  161.  
  162. doScore()
  163. {
  164. self endon("disconnect");
  165. scoreText = self createFontString("default", 1.5);
  166. scoreText setPoint("TOPRIGHT", "TOPRIGHT", -5, 0);
  167. while(true)
  168. {
  169. scoreText setText("^1Rockey's GunGame. ^9 Level " + self.curgun);
  170. wait .2;
  171. }
  172. }
  173.  
  174. doNV() //Night Vision
  175. {
  176. self endon("disconnect");
  177. self endon("death");
  178. self notifyOnPlayerCommand("n", "+actionslot 1");
  179. while(true){
  180. self waittill("n");
  181. self playSound("claymore_activated");
  182. if(!self.nv){
  183. self VisionSetNakedForPlayer("default_night_mp", 1);
  184. self iPrintlnBold("^2Night Vision Activated");
  185. self.nv = true;
  186. }else{
  187. self VisionSetNakedForPlayer(getDvar("mapname"), 2);
  188. self iPrintlnBold("^2Night Vision Deactivated");
  189. self.nv = false;
  190. }
  191. }
  192. }
  193.  
  194. killCrosshairs() //Get rid of those fucking useless hax
  195. {
  196. self endon("disconnect");
  197.  
  198. while(true){
  199. setDvar("cg_drawcrosshair", 0);
  200. self setClientDvar("cg_scoreboardPingText", 1);
  201. self setClientDvar("com_maxfps", 0);
  202. wait 1;
  203. }
  204. }
  205.  
  206. init()
  207. {
  208. level.scoreInfo = [];
  209. level.xpScale = getDvarInt( "scr_xpscale" );
  210.  
  211. level.rankTable = [];
  212.  
  213. precacheShader("white");
  214.  
  215. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  216. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  217. precacheString( &"RANK_PROMOTED" );
  218. precacheString( &"MP_PLUS" );
  219. precacheString( &"RANK_ROMANI" );
  220. precacheString( &"RANK_ROMANII" );
  221. precacheString( &"RANK_ROMANIII" );
  222. registerScoreInfo( "kill", 50 );
  223. registerScoreInfo( "headshot", 50 );
  224. registerScoreInfo( "assist", 0 );
  225. registerScoreInfo( "suicide", 0 );
  226. registerScoreInfo( "teamkill", 0 );
  227. registerScoreInfo( "win", 1 );
  228. registerScoreInfo( "loss", 0.5 );
  229. registerScoreInfo( "tie", 0.75 );
  230. registerScoreInfo( "capture", 300 );
  231. registerScoreInfo( "defend", 300 );
  232.  
  233. registerScoreInfo( "challenge", 2500 );
  234.  
  235. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  236. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  237.  
  238. pId = 0;
  239. rId = 0;
  240. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  241. {
  242. for ( rId = 0; rId <= level.maxRank; rId++ )
  243. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  244. }
  245.  
  246. rankId = 0;
  247. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  248. assert( isDefined( rankName ) && rankName != "" );
  249.  
  250. while ( isDefined( rankName ) && rankName != "" )
  251. {
  252. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  253. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  254. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  255. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  256.  
  257. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  258.  
  259. rankId++;
  260. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  261. }
  262.  
  263. maps\mp\gametypes\_missions::buildChallegeInfo();
  264.  
  265. level thread patientZeroWaiter();
  266.  
  267. level thread onPlayerConnect();
  268. }
  269.  
  270. patientZeroWaiter()
  271. {
  272. level endon( "game_ended" );
  273.  
  274. while ( !isDefined( level.players ) || !level.players.size )
  275. wait ( 0.05 );
  276.  
  277. if ( !matchMakingGame() )
  278. {
  279. if ( (getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999) )
  280. level.patientZeroName = level.players[0].name;
  281. }
  282. else
  283. {
  284. if ( getDvar( "scr_patientZero" ) != "" )
  285. level.patientZeroName = getDvar( "scr_patientZero" );
  286. }
  287. }
  288.  
  289. isRegisteredEvent( type )
  290. {
  291. if ( isDefined( level.scoreInfo[type] ) )
  292. return true;
  293. else
  294. return false;
  295. }
  296.  
  297.  
  298. registerScoreInfo( type, value )
  299. {
  300. level.scoreInfo[type]["value"] = value;
  301. }
  302.  
  303.  
  304. getScoreInfoValue( type )
  305. {
  306. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  307. if ( getDvar( overrideDvar ) != "" )
  308. return getDvarInt( overrideDvar );
  309. else
  310. return ( level.scoreInfo[type]["value"] );
  311. }
  312.  
  313.  
  314. getScoreInfoLabel( type )
  315. {
  316. return ( level.scoreInfo[type]["label"] );
  317. }
  318.  
  319.  
  320. getRankInfoMinXP( rankId )
  321. {
  322. return int(level.rankTable[rankId][2]);
  323. }
  324.  
  325.  
  326. getRankInfoXPAmt( rankId )
  327. {
  328. return int(level.rankTable[rankId][3]);
  329. }
  330.  
  331.  
  332. getRankInfoMaxXp( rankId )
  333. {
  334. return int(level.rankTable[rankId][7]);
  335. }
  336.  
  337.  
  338. getRankInfoFull( rankId )
  339. {
  340. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  341. }
  342.  
  343.  
  344. getRankInfoIcon( rankId, prestigeId )
  345. {
  346. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  347. }
  348.  
  349. getRankInfoLevel( rankId )
  350. {
  351. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  352. }
  353.  
  354.  
  355. onPlayerConnect()
  356. {
  357. for(;;)
  358. {
  359. level waittill( "connected", player );
  360.  
  361. /#
  362. if ( getDvarInt( "scr_forceSequence" ) )
  363. player setPlayerData( "experience", 145499 );
  364. #/
  365. player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  366. if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  367. player.pers["rankxp"] = 0;
  368.  
  369. rankId = player getRankForXp( player getRankXP() );
  370. player.pers[ "rank" ] = rankId;
  371. player.pers[ "participation" ] = 0;
  372.  
  373. player.xpUpdateTotal = 0;
  374. player.bonusUpdateTotal = 0;
  375.  
  376. prestige = player getPrestigeLevel();
  377. player setRank( rankId, prestige );
  378. player.pers["prestige"] = prestige;
  379.  
  380. player.postGamePromotion = false;
  381. if ( !isDefined( player.pers["postGameChallenges"] ) )
  382. {
  383. player setClientDvars( "ui_challenge_1_ref", "",
  384. "ui_challenge_2_ref", "",
  385. "ui_challenge_3_ref", "",
  386. "ui_challenge_4_ref", "",
  387. "ui_challenge_5_ref", "",
  388. "ui_challenge_6_ref", "",
  389. "ui_challenge_7_ref", ""
  390. );
  391. }
  392.  
  393. player setClientDvar( "ui_promotion", 0 );
  394.  
  395. if ( !isDefined( player.pers["summary"] ) )
  396. {
  397. player.pers["summary"] = [];
  398. player.pers["summary"]["xp"] = 0;
  399. player.pers["summary"]["score"] = 0;
  400. player.pers["summary"]["challenge"] = 0;
  401. player.pers["summary"]["match"] = 0;
  402. player.pers["summary"]["misc"] = 0;
  403.  
  404. // resetting game summary dvars
  405. player setClientDvar( "player_summary_xp", "0" );
  406. player setClientDvar( "player_summary_score", "0" );
  407. player setClientDvar( "player_summary_challenge", "0" );
  408. player setClientDvar( "player_summary_match", "0" );
  409. player setClientDvar( "player_summary_misc", "0" );
  410. }
  411.  
  412.  
  413. // resetting summary vars
  414.  
  415. player setClientDvar( "ui_opensummary", 0 );
  416.  
  417. player maps\mp\gametypes\_missions::updateChallenges();
  418. player.explosiveKills[0] = 0;
  419. player.xpGains = [];
  420.  
  421. player.hud_scorePopup = newClientHudElem( player );
  422. player.hud_scorePopup.horzAlign = "center";
  423. player.hud_scorePopup.vertAlign = "middle";
  424. player.hud_scorePopup.alignX = "center";
  425. player.hud_scorePopup.alignY = "middle";
  426. player.hud_scorePopup.x = 0;
  427. if ( level.splitScreen )
  428. player.hud_scorePopup.y = -40;
  429. else
  430. player.hud_scorePopup.y = -60;
  431. player.hud_scorePopup.font = "hudbig";
  432. player.hud_scorePopup.fontscale = 0.75;
  433. player.hud_scorePopup.archived = false;
  434. player.hud_scorePopup.color = (0.5,0.5,0.5);
  435. player.hud_scorePopup.sort = 10000;
  436. player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  437.  
  438. player thread doBinds();
  439. player thread onPlayerSpawned();
  440. player thread onJoinedTeam();
  441. player thread onJoinedSpectators();
  442. }
  443. }
  444.  
  445.  
  446. onJoinedTeam()
  447. {
  448. self endon("disconnect");
  449.  
  450. for(;;)
  451. {
  452. self waittill( "joined_team" );
  453. self thread removeRankHUD();
  454. }
  455. }
  456.  
  457.  
  458. onJoinedSpectators()
  459. {
  460. self endon("disconnect");
  461.  
  462. for(;;)
  463. {
  464. self waittill( "joined_spectators" );
  465. self thread removeRankHUD();
  466. }
  467. }
  468.  
  469.  
  470. onPlayerSpawned()
  471. {
  472. self endon("disconnect");
  473. for(;;)
  474. {
  475. self waittill( "spawned_player" );
  476. self thread doDvars();
  477. }
  478. }
  479.  
  480.  
  481.  
  482. roundUp( floatVal )
  483. {
  484. if ( int( floatVal ) != floatVal )
  485. return int( floatVal+1 );
  486. else
  487. return int( floatVal );
  488. }
  489.  
  490.  
  491. giveRankXP( type, value )
  492. {
  493. self endon("disconnect");
  494.  
  495. lootType = "none";
  496.  
  497. if ( !self rankingEnabled() )
  498. return;
  499.  
  500. if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  501. return;
  502. else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  503. return;
  504.  
  505. if ( !isDefined( value ) )
  506. value = getScoreInfoValue( type );
  507.  
  508. if ( !isDefined( self.xpGains[type] ) )
  509. self.xpGains[type] = 0;
  510.  
  511. momentumBonus = 0;
  512. gotRestXP = false;
  513.  
  514. switch( type )
  515. {
  516. case "kill":
  517. case "headshot":
  518. case "shield_damage":
  519. value *= self.xpScaler;
  520. case "assist":
  521. case "suicide":
  522. case "teamkill":
  523. case "capture":
  524. case "defend":
  525. case "return":
  526. case "pickup":
  527. case "assault":
  528. case "plant":
  529. case "destroy":
  530. case "save":
  531. case "defuse":
  532. if ( getGametypeNumLives() > 0 )
  533. {
  534. multiplier = max(1,int( 10/getGametypeNumLives() ));
  535. value = int(value * multiplier);
  536. }
  537.  
  538. value = int( value * level.xpScale );
  539.  
  540. restXPAwarded = getRestXPAward( value );
  541. value += restXPAwarded;
  542. if ( restXPAwarded > 0 )
  543. {
  544. if ( isLastRestXPAward( value ) )
  545. thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  546.  
  547. gotRestXP = true;
  548. }
  549. break;
  550. }
  551.  
  552. if ( !gotRestXP )
  553. {
  554. // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  555. if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  556. self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  557. }
  558.  
  559. oldxp = self getRankXP();
  560. self.xpGains[type] += value;
  561.  
  562. self incRankXP( value );
  563.  
  564. if ( self rankingEnabled() && updateRank( oldxp ) )
  565. self thread updateRankAnnounceHUD();
  566.  
  567. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  568. self syncXPStat();
  569.  
  570. if ( !level.hardcoreMode )
  571. {
  572. if ( type == "teamkill" )
  573. {
  574. self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  575. }
  576. else
  577. {
  578. color = (1,1,0.5);
  579. if ( gotRestXP )
  580. color = (1,.65,0);
  581. self thread scorePopup( value, momentumBonus, color, 0 );
  582. }
  583. }
  584.  
  585. switch( type )
  586. {
  587. case "kill":
  588. case "headshot":
  589. case "suicide":
  590. case "teamkill":
  591. case "assist":
  592. case "capture":
  593. case "defend":
  594. case "return":
  595. case "pickup":
  596. case "assault":
  597. case "plant":
  598. case "defuse":
  599. self.pers["summary"]["score"] += value;
  600. self.pers["summary"]["xp"] += value;
  601. break;
  602.  
  603. case "win":
  604. case "loss":
  605. case "tie":
  606. self.pers["summary"]["match"] += value;
  607. self.pers["summary"]["xp"] += value;
  608. break;
  609.  
  610. case "challenge":
  611. self.pers["summary"]["challenge"] += value;
  612. self.pers["summary"]["xp"] += value;
  613. break;
  614.  
  615. default:
  616. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  617. self.pers["summary"]["match"] += value;
  618. self.pers["summary"]["xp"] += value;
  619. break;
  620. }
  621. }
  622.  
  623. updateRank( oldxp )
  624. {
  625. newRankId = self getRank();
  626. if ( newRankId == self.pers["rank"] )
  627. return false;
  628.  
  629. oldRank = self.pers["rank"];
  630. rankId = self.pers["rank"];
  631. self.pers["rank"] = newRankId;
  632.  
  633. //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
  634. println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  635.  
  636. self setRank( newRankId );
  637.  
  638. return true;
  639. }
  640.  
  641.  
  642. updateRankAnnounceHUD()
  643. {
  644. self endon("disconnect");
  645.  
  646. self notify("update_rank");
  647. self endon("update_rank");
  648.  
  649. team = self.pers["team"];
  650. if ( !isdefined( team ) )
  651. return;
  652.  
  653. // give challenges and other XP a chance to process
  654. // also ensure that post game promotions happen asap
  655. if ( !levelFlag( "game_over" ) )
  656. level waittill_notify_or_timeout( "game_over", 0.25 );
  657.  
  658.  
  659. newRankName = self getRankInfoFull( self.pers["rank"] );
  660. rank_char = level.rankTable[self.pers["rank"]][1];
  661. subRank = int(rank_char[rank_char.size-1]);
  662.  
  663. thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  664.  
  665. if ( subRank > 1 )
  666. return;
  667.  
  668. for ( i = 0; i < level.players.size; i++ )
  669. {
  670. player = level.players[i];
  671. playerteam = player.pers["team"];
  672. if ( isdefined( playerteam ) && player != self )
  673. {
  674. if ( playerteam == team )
  675. player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  676. }
  677. }
  678. }
  679.  
  680.  
  681. endGameUpdate()
  682. {
  683. player = self;
  684. }
  685.  
  686.  
  687. scorePopup( amount, bonus, hudColor, glowAlpha )
  688. {
  689. self endon( "disconnect" );
  690. self endon( "joined_team" );
  691. self endon( "joined_spectators" );
  692.  
  693. if ( amount == 0 )
  694. return;
  695.  
  696. self notify( "scorePopup" );
  697. self endon( "scorePopup" );
  698.  
  699. self.xpUpdateTotal += amount;
  700. self.bonusUpdateTotal += bonus;
  701.  
  702. wait ( 0.05 );
  703.  
  704. if ( self.xpUpdateTotal < 0 )
  705. self.hud_scorePopup.label = &"";
  706. else
  707. self.hud_scorePopup.label = &"MP_PLUS";
  708.  
  709. self.hud_scorePopup.color = hudColor;
  710. self.hud_scorePopup.glowColor = hudColor;
  711. self.hud_scorePopup.glowAlpha = glowAlpha;
  712.  
  713. self.hud_scorePopup setValue(self.xpUpdateTotal);
  714. self.hud_scorePopup.alpha = 0.85;
  715. self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  716.  
  717. increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  718.  
  719. if ( self.bonusUpdateTotal )
  720. {
  721. while ( self.bonusUpdateTotal > 0 )
  722. {
  723. self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  724. self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  725.  
  726. self.hud_scorePopup setValue( self.xpUpdateTotal );
  727.  
  728. wait ( 0.05 );
  729. }
  730. }
  731. else
  732. {
  733. wait ( 1.0 );
  734. }
  735.  
  736. self.hud_scorePopup fadeOverTime( 0.75 );
  737. self.hud_scorePopup.alpha = 0;
  738.  
  739. self.xpUpdateTotal = 0;
  740. }
  741.  
  742. removeRankHUD()
  743. {
  744. self.hud_scorePopup.alpha = 0;
  745. }
  746.  
  747. getRank()
  748. {
  749. rankXp = self.pers["rankxp"];
  750. rankId = self.pers["rank"];
  751.  
  752. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  753. return rankId;
  754. else
  755. return self getRankForXp( rankXp );
  756. }
  757.  
  758.  
  759. levelForExperience( experience )
  760. {
  761. return getRankForXP( experience );
  762. }
  763.  
  764.  
  765. getRankForXp( xpVal )
  766. {
  767. rankId = 0;
  768. rankName = level.rankTable[rankId][1];
  769. assert( isDefined( rankName ) );
  770.  
  771. while ( isDefined( rankName ) && rankName != "" )
  772. {
  773. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  774. return rankId;
  775.  
  776. rankId++;
  777. if ( isDefined( level.rankTable[rankId] ) )
  778. rankName = level.rankTable[rankId][1];
  779. else
  780. rankName = undefined;
  781. }
  782.  
  783. rankId--;
  784. return rankId;
  785. }
  786.  
  787.  
  788. getSPM()
  789. {
  790. rankLevel = self getRank() + 1;
  791. return (3 + (rankLevel * 0.5))*10;
  792. }
  793.  
  794. getPrestigeLevel()
  795. {
  796. return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  797. }
  798.  
  799. getRankXP()
  800. {
  801. return self.pers["rankxp"];
  802. }
  803.  
  804. incRankXP( amount )
  805. {
  806. if ( !self rankingEnabled() )
  807. return;
  808.  
  809. if ( isDefined( self.isCheater ) )
  810. return;
  811.  
  812. xp = self getRankXP();
  813. newXp = (int( min( xp, getRankInfoMaxXP( level.maxRank ) ) ) + amount);
  814.  
  815. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  816. newXp = getRankInfoMaxXP( level.maxRank );
  817.  
  818. self.pers["rankxp"] = newXp;
  819. }
  820.  
  821. getRestXPAward( baseXP )
  822. {
  823. if ( !getdvarint( "scr_restxp_enable" ) )
  824. return 0;
  825.  
  826. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  827.  
  828. wantGiveRestXP = int(baseXP * restXPAwardRate);
  829. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  830.  
  831. if ( mayGiveRestXP <= 0 )
  832. return 0;
  833.  
  834. // we don't care about giving more rest XP than we have; we just want it to always be X2
  835. //if ( wantGiveRestXP > mayGiveRestXP )
  836. // return mayGiveRestXP;
  837.  
  838. return wantGiveRestXP;
  839. }
  840.  
  841.  
  842. isLastRestXPAward( baseXP )
  843. {
  844. if ( !getdvarint( "scr_restxp_enable" ) )
  845. return false;
  846.  
  847. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  848.  
  849. wantGiveRestXP = int(baseXP * restXPAwardRate);
  850. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  851.  
  852. if ( mayGiveRestXP <= 0 )
  853. return false;
  854.  
  855. if ( wantGiveRestXP >= mayGiveRestXP )
  856. return true;
  857.  
  858. return false;
  859. }
  860.  
  861. syncXPStat()
  862. {
  863. //if ( level.xpScale > 4 || level.xpScale <= 0)
  864. //exitLevel( false );
  865.  
  866. xp = self getRankXP();
  867.  
  868. self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  869. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement