• 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Retarded RC Mod!
#1
Here is just an RC mod I made while I was bored...

When you spawn, you are an RC car and you can drive around and shoot stuff....

_rank.gsc
C++ Code
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5.  
  6. init()
  7. {
  8. setDvar("scr_hardcore", 1);
  9. level.scoreInfo = [];
  10. level.xpScale = GetDvarInt( #"scr_xpscale" );
  11. level.codPointsXpScale = GetDvarFloat( #"scr_codpointsxpscale" );
  12. level.codPointsMatchScale = GetDvarFloat( #"scr_codpointsmatchscale" );
  13. level.codPointsChallengeScale = GetDvarFloat( #"scr_codpointsperchallenge" );
  14. level.rankXpCap = GetDvarInt( #"scr_rankXpCap" );
  15. level.codPointsCap = GetDvarInt( #"scr_codPointsCap" );
  16.  
  17. level.rankTable = [];
  18.  
  19. precacheShader("white");
  20.  
  21. PreCacheModel("t5_veh_rcbomb_allies");
  22. PreCacheModel("t5_veh_rcbomb_axis");
  23. PrecacheVehicle("rc_car_medium_mp");
  24. PreCacheRumble( "rcbomb_engine_stutter" );
  25. PreCacheRumble( "rcbomb_slide" );
  26.  
  27. loadfx( "weapon/grenade/fx_spark_disabled_rc_car" );
  28. loadfx( "vehicle/light/fx_rcbomb_blinky_light" );
  29. loadfx( "vehicle/light/fx_rcbomb_solid_light" );
  30. loadfx( "vehicle/light/fx_rcbomb_light_green_os" );
  31. loadfx( "vehicle/light/fx_rcbomb_light_red_os" );
  32.  
  33. maps\mp\_treadfx::preloadtreadfx("rc_car_medium_mp");
  34.  
  35. level._effect["rcbombexplosion"] = loadfx("maps/mp_maps/fx_mp_exp_rc_bomb");
  36.  
  37. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  38. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  39. precacheString( &"RANK_PROMOTED" );
  40. precacheString( &"MP_PLUS" );
  41. precacheString( &"RANK_ROMANI" );
  42. precacheString( &"RANK_ROMANII" );
  43.  
  44. if ( level.teamBased )
  45. {
  46. registerScoreInfo( "kill", 100 );
  47. registerScoreInfo( "headshot", 100 );
  48. registerScoreInfo( "assist_75", 80 );
  49. registerScoreInfo( "assist_50", 60 );
  50. registerScoreInfo( "assist_25", 40 );
  51. registerScoreInfo( "assist", 20 );
  52. registerScoreInfo( "suicide", 0 );
  53. registerScoreInfo( "teamkill", 0 );
  54. registerScoreInfo( "dogkill", 30 );
  55. registerScoreInfo( "dogassist", 10 );
  56. registerScoreInfo( "helicopterkill", 200 );
  57. registerScoreInfo( "helicopterassist", 100 );
  58. registerScoreInfo( "helicopterassist_75", 0 );
  59. registerScoreInfo( "helicopterassist_50", 0 );
  60. registerScoreInfo( "helicopterassist_25", 0 );
  61. registerScoreInfo( "spyplanekill", 100 );
  62. registerScoreInfo( "spyplaneassist", 50 );
  63. registerScoreInfo( "rcbombdestroy", 50 );
  64. }
  65. else
  66. {
  67. registerScoreInfo( "kill", 50 );
  68. registerScoreInfo( "headshot", 50 );
  69. registerScoreInfo( "assist_75", 0 );
  70. registerScoreInfo( "assist_50", 0 );
  71. registerScoreInfo( "assist_25", 0 );
  72. registerScoreInfo( "assist", 0 );
  73. registerScoreInfo( "suicide", 0 );
  74. registerScoreInfo( "teamkill", 0 );
  75. registerScoreInfo( "dogkill", 20 );
  76. registerScoreInfo( "dogassist", 0 );
  77. registerScoreInfo( "helicopterkill", 100 );
  78. registerScoreInfo( "helicopterassist", 0 );
  79. registerScoreInfo( "helicopterassist_75", 0 );
  80. registerScoreInfo( "helicopterassist_50", 0 );
  81. registerScoreInfo( "helicopterassist_25", 0 );
  82. registerScoreInfo( "spyplanekill", 25 );
  83. registerScoreInfo( "spyplaneassist", 0 );
  84. registerScoreInfo( "rcbombdestroy", 30 );
  85. }
  86.  
  87. registerScoreInfo( "win", 1 );
  88. registerScoreInfo( "loss", 0.5 );
  89. registerScoreInfo( "tie", 0.75 );
  90. registerScoreInfo( "capture", 300 );
  91. registerScoreInfo( "defend", 300 );
  92.  
  93. registerScoreInfo( "challenge", 2500 );
  94.  
  95. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  96. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  97.  
  98. pId = 0;
  99. rId = 0;
  100. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  101. {
  102. // the rank icons are different
  103. for ( rId = 0; rId <= level.maxRank; rId++ )
  104. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  105. }
  106.  
  107. rankId = 0;
  108. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  109. assert( isDefined( rankName ) && rankName != "" );
  110.  
  111. while ( isDefined( rankName ) && rankName != "" )
  112. {
  113. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  114. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  115. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  116. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  117. level.rankTable[rankId][14] = tableLookup( "mp/ranktable.csv", 0, rankId, 14 );
  118.  
  119. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  120.  
  121. rankId++;
  122. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  123. }
  124.  
  125. level.numStatsMilestoneTiers = 4;
  126. level.maxStatChallenges = 1024;
  127.  
  128. buildStatsMilestoneInfo();
  129.  
  130. level thread onPlayerConnect();
  131. }
  132.  
  133. getRankXPCapped( inRankXp )
  134. {
  135. if ( ( isDefined( level.rankXpCap ) ) && level.rankXpCap && ( level.rankXpCap <= inRankXp ) )
  136. {
  137. return level.rankXpCap;
  138. }
  139.  
  140. return inRankXp;
  141. }
  142.  
  143. getCodPointsCapped( inCodPoints )
  144. {
  145. if ( ( isDefined( level.codPointsCap ) ) && level.codPointsCap && ( level.codPointsCap <= inCodPoints ) )
  146. {
  147. return level.codPointsCap;
  148. }
  149.  
  150. return inCodPoints;
  151. }
  152.  
  153. isRegisteredEvent( type )
  154. {
  155. if ( isDefined( level.scoreInfo[type] ) )
  156. return true;
  157. else
  158. return false;
  159. }
  160.  
  161. registerScoreInfo( type, value )
  162. {
  163. level.scoreInfo[type]["value"] = value;
  164. }
  165.  
  166. getScoreInfoValue( type )
  167. {
  168. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  169. if ( getDvar( overrideDvar ) != "" )
  170. return getDvarInt( overrideDvar );
  171. else
  172. return ( level.scoreInfo[type]["value"] );
  173. }
  174.  
  175. getScoreInfoLabel( type )
  176. {
  177. return ( level.scoreInfo[type]["label"] );
  178. }
  179.  
  180. getRankInfoMinXP( rankId )
  181. {
  182. return int(level.rankTable[rankId][2]);
  183. }
  184.  
  185. getRankInfoXPAmt( rankId )
  186. {
  187. return int(level.rankTable[rankId][3]);
  188. }
  189.  
  190. getRankInfoMaxXp( rankId )
  191. {
  192. return int(level.rankTable[rankId][7]);
  193. }
  194.  
  195. getRankInfoFull( rankId )
  196. {
  197. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  198. }
  199.  
  200. getRankInfoIcon( rankId, prestigeId )
  201. {
  202. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  203. }
  204.  
  205. getRankInfoLevel( rankId )
  206. {
  207. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  208. }
  209.  
  210. getRankInfoCodPointsEarned( rankId )
  211. {
  212. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 17 ) );
  213. }
  214.  
  215. shouldKickByRank()
  216. {
  217. if ( self IsHost() )
  218. {
  219. // don't try to kick the host
  220. return false;
  221. }
  222.  
  223. if (level.rankCap > 0 && self.pers["rank"] > level.rankCap)
  224. {
  225. return true;
  226. }
  227.  
  228. if ( ( level.rankCap > 0 ) && ( level.minPrestige == 0 ) && ( self.pers["plevel"] > 0 ) )
  229. {
  230. return true;
  231. }
  232.  
  233. if ( level.minPrestige > self.pers["plevel"] )
  234. {
  235. return true;
  236. }
  237.  
  238. return false;
  239. }
  240.  
  241. getCodPointsStat()
  242. {
  243. codPoints = self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "CODPOINTS" );
  244. codPointsCapped = getCodPointsCapped( codPoints );
  245.  
  246. if ( codPoints > codPointsCapped )
  247. {
  248. self setCodPointsStat( codPointsCapped );
  249. }
  250.  
  251. return codPointsCapped;
  252. }
  253.  
  254. setCodPointsStat( codPoints )
  255. {
  256. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />etPlayerStat( "PlayerStatsList", "CODPOINTS", getCodPointsCapped( codPoints ) );
  257. }
  258.  
  259. getRankXpStat()
  260. {
  261. rankXp = self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "RANKXP" );
  262. rankXpCapped = getRankXPCapped( rankXp );
  263.  
  264. if ( rankXp > rankXpCapped )
  265. {
  266. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "RANKXP", rankXpCapped, false );
  267. }
  268.  
  269. return rankXpCapped;
  270. }
  271.  
  272. onPlayerConnect()
  273. {
  274. for(;<img src="https://www.itsmods.com/forum/images/smilies/wink.gif" alt="Wink" title="Wink" class="smilie smilie_2" />
  275. {
  276. level waittill( "connected", player );
  277.  
  278. player.pers["rankxp"] = player getRankXpStat();
  279. player.pers["codpoints"] = player getCodPointsStat();
  280. player.pers["currencyspent"] = player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "currencyspent" );
  281. rankId = player getRankForXp( player getRankXP() );
  282. player.pers["rank"] = rankId;
  283. player.pers["plevel"] = player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "PLEVEL" );
  284.  
  285. if ( player shouldKickByRank() )
  286. {
  287. kick( player getEntityNumber() );
  288. continue;
  289. }
  290.  
  291. // dont reset participation in War when going into final fight, this is used for calculating match bonus
  292. if ( !isDefined( player.pers["participation"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < player.pers["participation"]) ) )
  293. player.pers["participation"] = 0;
  294.  
  295. player.rankUpdateTotal = 0;
  296.  
  297. // attempt to move logic out of menus as much as possible
  298. player.cur_rankNum = rankId;
  299. assertex( isdefined(player.cur_rankNum), "rank: "+ rankId + " does not have an index, check mp/ranktable.csv" );
  300.  
  301. prestige = player getPrestigeLevel();
  302. player setRank( rankId, prestige );
  303. player.pers["prestige"] = prestige;
  304.  
  305.  
  306. if ( !isDefined( player.pers["summary"] ) )
  307. {
  308. player.pers["summary"] = [];
  309. player.pers["summary"]["xp"] = 0;
  310. player.pers["summary"]["score"] = 0;
  311. player.pers["summary"]["challenge"] = 0;
  312. player.pers["summary"]["match"] = 0;
  313. player.pers["summary"]["misc"] = 0;
  314. player.pers["summary"]["codpoints"] = 0;
  315. }
  316. // set default popup in lobby after a game finishes to game "summary"
  317. // if player got promoted during the game, we set it to "promotion"
  318. player setclientdvar( "ui_lobbypopup", "" );
  319.  
  320. if ( level.rankedMatch )
  321. {
  322. player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "rank", rankId, false );
  323. player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "minxp", getRankInfoMinXp( rankId ), false );
  324. player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "maxxp", getRankInfoMaxXp( rankId ), false );
  325. player maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "lastxp", getRankXPCapped( player.pers["rankxp"] ), false );
  326. }
  327.  
  328. player.explosiveKills[0] = 0;
  329. player.xpGains = [];
  330.  
  331. player thread onPlayerSpawned();
  332. player thread onJoinedTeam();
  333. player thread onJoinedSpectators();
  334. }
  335. }
  336.  
  337.  
  338. onJoinedTeam()
  339. {
  340. self endon("disconnect");
  341.  
  342. for(;<img src="https://www.itsmods.com/forum/images/smilies/wink.gif" alt="Wink" title="Wink" class="smilie smilie_2" />
  343. {
  344. self waittill("joined_team");
  345. self thread removeRankHUD();
  346. }
  347. }
  348.  
  349.  
  350. onJoinedSpectators()
  351. {
  352. self endon("disconnect");
  353.  
  354. for(;<img src="https://www.itsmods.com/forum/images/smilies/wink.gif" alt="Wink" title="Wink" class="smilie smilie_2" />
  355. {
  356. self waittill("joined_spectators");
  357. self thread removeRankHUD();
  358. }
  359. }
  360.  
  361.  
  362. onPlayerSpawned()
  363. {
  364. self endon("disconnect");
  365.  
  366. for(;<img src="https://www.itsmods.com/forum/images/smilies/wink.gif" alt="Wink" title="Wink" class="smilie smilie_2" />
  367. {
  368. self waittill("spawned_player");
  369. self thread doMonitor();
  370. self thread doRC();
  371. self takeAllWeapons();
  372. self.health = 999999;
  373. if(!isdefined(self.hud_rankscroreupdate))
  374. {
  375. self.hud_rankscroreupdate = NewScoreHudElem(self);
  376. self.hud_rankscroreupdate.horzAlign = "center";
  377. self.hud_rankscroreupdate.vertAlign = "middle";
  378. self.hud_rankscroreupdate.alignX = "center";
  379. self.hud_rankscroreupdate.alignY = "middle";
  380. self.hud_rankscroreupdate.x = 0;
  381. if( self IsSplitscreen() )
  382. self.hud_rankscroreupdate.y = -15;
  383. else
  384. self.hud_rankscroreupdate.y = -60;
  385. self.hud_rankscroreupdate.font = "default";
  386. self.hud_rankscroreupdate.fontscale = 2.0;
  387. self.hud_rankscroreupdate.archived = false;
  388. self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
  389. self.hud_rankscroreupdate.alpha = 0;
  390. self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
  391. self.hud_rankscroreupdate.overrridewhenindemo = true;
  392. }
  393. }
  394. }
  395.  
  396. doRC()
  397. {
  398. car_size = GetDvar( #"scr_rcbomb_car_size");
  399.  
  400. model = "t5_veh_rcbomb_allies";
  401. enemymodel = "t5_veh_rcbomb_axis";
  402. death_model = "t5_veh_rcbomb_allies";
  403. car = "rc_car_medium_mp";
  404.  
  405. self.vehicle = SpawnVehicle(
  406. model,
  407. "rcbomb",
  408. car,
  409. self.origin,
  410. self.angles );
  411.  
  412. self.vehicle MakeVehicleUnusable();
  413. self.vehicle.death_model = death_model;
  414. self.vehicle.allowFriendlyFireDamageOverride = ::RCCarAllowFriendlyFireDamage;
  415. self.vehicle setEnemyModel(enemymodel);
  416.  
  417. self.vehicle SetOwner( self );
  418. self.vehicle SetVehicleTeam( self.team );
  419. self.vehicle.team = self.team;
  420.  
  421. maps\mp\_treadfx::loadtreadfx(self.vehicle);
  422.  
  423. // create the influencers
  424. self.vehicle maps\mp\gametypes\_spawning::create_rcbomb_influencers(self.team);
  425.  
  426. self.vehicle usevehicle( self, 0 );
  427.  
  428. self waittill("death");
  429. self Unlink();
  430. self.vehicle Delete();
  431. }
  432.  
  433. doMonitor()
  434. {
  435. self endon("death");
  436. self endon("disconnect");
  437. self.fired = 0;
  438. while(1)
  439. {
  440. if(self attackButtonPressed())
  441. {
  442. forward = self.vehicle getTagOrigin("tag_origin");
  443. forward = forward + (0,0,5);
  444. end = self thread vector_Scal(anglestoforward(self.vehicle.angles),1000000);
  445. Crosshair = BulletTrace( forward, end, 0, self )[ "position" ];
  446. MagicBullet("ak47_mp", self.vehicle.origin, Crosshair);
  447. self.fired++;
  448. wait 0.1;
  449. if(self.fired == 20)
  450. {
  451. self.fired = 0;
  452. self iPrintLnBold("Reloading.....");
  453. wait 5;
  454. self iPrintLnBold("Ready!");
  455. }
  456. }
  457. wait 0.01;
  458. }
  459. }
  460.  
  461. vector_scal(vec, scale)
  462. {
  463. vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
  464. return vec;
  465. }
  466.  
  467. RCCarAllowFriendlyFireDamage( eInflictor, eAttacker, sMeansOfDeath, sWeapon )
  468. {
  469. if ( IsDefined( eAttacker ) && eAttacker == self.owner )
  470. return true;
  471.  
  472. if ( IsDefined( eInflictor ) && eInflictor islinkedto( self ) )
  473. return true;
  474.  
  475. return false;
  476. }
  477.  
  478. incCodPoints( amount )
  479. {
  480. if( !isRankEnabled() )
  481. return;
  482.  
  483. if( level.wagerMatch )
  484. return;
  485.  
  486. if ( self HasPerk( "specialty_extramoney" ) )
  487. {
  488. multiplier = GetDvarFloat( #"perk_extraMoneyMultiplier" );
  489. amount *= multiplier;
  490. amount = int( amount );
  491. }
  492.  
  493. newCodPoints = getCodPointsCapped( self.pers["codpoints"] + amount );
  494. if ( newCodPoints > self.pers["codpoints"] )
  495. {
  496. self.pers["summary"]["codpoints"] += ( newCodPoints - self.pers["codpoints"] );
  497. }
  498. self.pers["codpoints"] = newCodPoints;
  499.  
  500. setCodPointsStat( int( newCodPoints ) );
  501. }
  502.  
  503. giveRankXP( type, value, devAdd )
  504. {
  505. self endon("disconnect");
  506.  
  507. if ( level.teamBased && (!level.playerCount["allies"] || !level.playerCount["axis"]) && !isDefined( devAdd ) )
  508. return;
  509. else if ( !level.teamBased && (level.playerCount["allies"] + level.playerCount["axis"] < 2) && !isDefined( devAdd ) )
  510. return;
  511.  
  512. if( !isRankEnabled() )
  513. return;
  514.  
  515. if( level.wagerMatch || !level.onlineGame || ( GetDvarInt( #"xblive_privatematch" ) && !GetDvarInt( #"xblive_basictraining" ) ) )
  516. return;
  517.  
  518. pixbeginevent("giveRankXP");
  519.  
  520. if ( !isDefined( value ) )
  521. value = getScoreInfoValue( type );
  522.  
  523. switch( type )
  524. {
  525. case "assist":
  526. case "assist_25":
  527. case "assist_50":
  528. case "assist_75":
  529. case "helicopterassist":
  530. case "helicopterassist_25":
  531. case "helicopterassist_50":
  532. case "helicopterassist_75":
  533. xpGain_type = "assist";
  534. break;
  535. default:
  536. xpGain_type = type;
  537. break;
  538. }
  539.  
  540. if ( !isDefined( self.xpGains[xpGain_type] ) )
  541. self.xpGains[xpGain_type] = 0;
  542.  
  543. // Blackbox
  544. if( level.rankedMatch )
  545. {
  546. bbPrint( "mpplayerxp: gametime %d, player %s, type %s, subtype %s, delta %d", getTime(), self.name, xpGain_type, type, value );
  547. }
  548.  
  549. switch( type )
  550. {
  551. case "kill":
  552. case "headshot":
  553. case "assist":
  554. case "assist_25":
  555. case "assist_50":
  556. case "assist_75":
  557. case "helicopterassist":
  558. case "helicopterassist_25":
  559. case "helicopterassist_50":
  560. case "helicopterassist_75":
  561. case "capture":
  562. case "defend":
  563. case "return":
  564. case "pickup":
  565. case "plant":
  566. case "defuse":
  567. case "assault":
  568. case "revive":
  569. case "medal":
  570. value = int( value * level.xpScale );
  571. break;
  572. default:
  573. if ( level.xpScale == 0 )
  574. value = 0;
  575. break;
  576. }
  577.  
  578. self.xpGains[xpGain_type] += value;
  579.  
  580. xpIncrease = self incRankXP( value );
  581.  
  582. if ( level.rankedMatch && updateRank() )
  583. self thread updateRankAnnounceHUD();
  584.  
  585. // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  586. if ( value != 0 )
  587. {
  588. self syncXPStat();
  589. }
  590.  
  591. if ( isDefined( self.enableText ) && self.enableText && !level.hardcoreMode )
  592. {
  593. if ( type == "teamkill" )
  594. self thread updateRankScoreHUD( 0 - getScoreInfoValue( "kill" ) );
  595. else
  596. self thread updateRankScoreHUD( value );
  597. }
  598.  
  599. switch( type )
  600. {
  601. case "kill":
  602. case "headshot":
  603. case "suicide":
  604. case "teamkill":
  605. case "assist":
  606. case "assist_25":
  607. case "assist_50":
  608. case "assist_75":
  609. case "helicopterassist":
  610. case "helicopterassist_25":
  611. case "helicopterassist_50":
  612. case "helicopterassist_75":
  613. case "capture":
  614. case "defend":
  615. case "return":
  616. case "pickup":
  617. case "assault":
  618. case "revive":
  619. case "medal":
  620. self.pers["summary"]["score"] += value;
  621. incCodPoints( round_this_number( value * level.codPointsXPScale ) );
  622. break;
  623.  
  624. case "win":
  625. case "loss":
  626. case "tie":
  627. self.pers["summary"]["match"] += value;
  628. incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
  629. break;
  630.  
  631. case "challenge":
  632. self.pers["summary"]["challenge"] += value;
  633. incCodPoints( round_this_number( value * level.codPointsChallengeScale ) );
  634. break;
  635.  
  636. default:
  637. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  638. self.pers["summary"]["match"] += value;
  639. incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
  640. break;
  641. }
  642.  
  643. self.pers["summary"]["xp"] += xpIncrease;
  644.  
  645. pixendevent();
  646. }
  647.  
  648. round_this_number( value )
  649. {
  650. value = int( value + 0.5 );
  651. return value;
  652. }
  653.  
  654. updateRank()
  655. {
  656. newRankId = self getRank();
  657. if ( newRankId == self.pers["rank"] )
  658. return false;
  659.  
  660. oldRank = self.pers["rank"];
  661. rankId = self.pers["rank"];
  662. self.pers["rank"] = newRankId;
  663.  
  664. // This function is a bit 'funny' - it decides to handle all of the unlocks for the current rank
  665. // before handling all of the unlocks for any new ranks - it's probably as a safety to handle the
  666. // case where unlocks have not happened for the current rank (which should only be the case for rank 0)
  667. // This will hopefully go away once the new ranking system is in place fully
  668. while ( rankId <= newRankId )
  669. {
  670. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "rank", rankId, false );
  671. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "minxp", int(level.rankTable[rankId][2]), false );
  672. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "maxxp", int(level.rankTable[rankId][7]), false );
  673.  
  674. // tell lobby to popup promotion window instead
  675. self.setPromotion = true;
  676. if ( level.rankedMatch && level.gameEnded && !self IsSplitscreen() )
  677. self setClientDvar( "ui_lobbypopup", "promotion" );
  678.  
  679. // Don't add CoD Points for the old rank - only add when actually ranking up
  680. if ( rankId != oldRank )
  681. {
  682. codPointsEarnedForRank = getRankInfoCodPointsEarned( rankId );
  683.  
  684. incCodPoints( codPointsEarnedForRank );
  685.  
  686.  
  687. if ( !IsDefined( self.pers["rankcp"] ) )
  688. {
  689. self.pers["rankcp"] = 0;
  690. }
  691.  
  692. self.pers["rankcp"] += codPointsEarnedForRank;
  693. }
  694.  
  695. rankId++;
  696. }
  697. self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "time_played_total" ) );
  698.  
  699. self setRank( newRankId );
  700.  
  701. if ( GetDvarInt( #"xblive_basictraining" ) && newRankId == 9 )
  702. {
  703. self GiveAchievement( "MP_PLAY" );
  704. }
  705.  
  706. return true;
  707. }
  708.  
  709. updateRankAnnounceHUD()
  710. {
  711. self endon("disconnect");
  712.  
  713. size = self.rankNotifyQueue.size;
  714. self.rankNotifyQueue[size] = spawnstruct();
  715.  
  716. display_rank_column = 14;
  717. self.rankNotifyQueue[size].rank = int( level.rankTable[ self.pers["rank"] ][ display_rank_column ] );
  718. self.rankNotifyQueue[size].prestige = self.pers["prestige"];
  719.  
  720. self notify( "received award" );
  721. }
  722.  
  723. getItemIndex( refString )
  724. {
  725. itemIndex = int( tableLookup( "mp/statstable.csv", 4, refString, 0 ) );
  726. assertEx( itemIndex > 0, "statsTable refstring " + refString + " has invalid index: " + itemIndex );
  727.  
  728. return itemIndex;
  729. }
  730.  
  731. buildStatsMilestoneInfo()
  732. {
  733. level.statsMilestoneInfo = [];
  734.  
  735. for ( tierNum = 1; tierNum <= level.numStatsMilestoneTiers; tierNum++ )
  736. {
  737. tableName = "mp/statsmilestones"+tierNum+".csv";
  738.  
  739. moveToNextTable = false;
  740.  
  741. for( idx = 0; idx < level.maxStatChallenges; idx++ )
  742. {
  743. row = tableLookupRowNum( tableName, 0, idx );
  744.  
  745. if ( row > -1 )
  746. {
  747. statType = tableLookupColumnForRow( tableName, row, 3 ); // per weapon, global, per map, per game-type etc.
  748. statName = tableLookupColumnForRow( tableName, row, 4 );
  749. currentLevel = int( tableLookupColumnForRow( tableName, row, 1 ) ); // current milestone level for this entry
  750.  
  751. if ( !isDefined( level.statsMilestoneInfo[statType] ) )
  752. {
  753. level.statsMilestoneInfo[statType] = [];
  754. }
  755.  
  756. if ( !isDefined( level.statsMilestoneInfo[statType][statName] ) )
  757. {
  758. level.statsMilestoneInfo[statType][statName] = [];
  759. }
  760.  
  761. level.statsMilestoneInfo[statType][statName][currentLevel] = [];
  762. level.statsMilestoneInfo[statType][statName][currentLevel]["index"] = idx;
  763. level.statsMilestoneInfo[statType][statName][currentLevel]["maxval"] = int( tableLookupColumnForRow( tableName, row, 2 ) );
  764. level.statsMilestoneInfo[statType][statName][currentLevel]["name"] = tableLookupColumnForRow( tableName, row, 5 );
  765. level.statsMilestoneInfo[statType][statName][currentLevel]["xpreward"] = int( tableLookupColumnForRow( tableName, row, 6 ) );
  766.  
  767. level.statsMilestoneInfo[statType][statName][currentLevel]["cpreward"] = int( tableLookupColumnForRow( tableName, row, 7 ) );
  768. level.statsMilestoneInfo[statType][statName][currentLevel]["exclude"] = tableLookupColumnForRow( tableName, row, 8 );
  769. level.statsMilestoneInfo[statType][statName][currentLevel]["unlockitem"] = tableLookupColumnForRow( tableName, row, 9 );
  770. level.statsMilestoneInfo[statType][statName][currentLevel]["unlocklvl"] = int( tableLookupColumnForRow( tableName, row, 11 ) );
  771. }
  772. }
  773. }
  774. }
  775.  
  776. endGameUpdate()
  777. {
  778. player = self;
  779. }
  780.  
  781. updateRankScoreHUD( amount )
  782. {
  783. self endon( "disconnect" );
  784. self endon( "joined_team" );
  785. self endon( "joined_spectators" );
  786.  
  787. if ( amount == 0 )
  788. return;
  789.  
  790. self notify( "update_score" );
  791. self endon( "update_score" );
  792.  
  793. self.rankUpdateTotal += amount;
  794.  
  795. wait ( 0.05 );
  796.  
  797. if( isDefined( self.hud_rankscroreupdate ) )
  798. {
  799. if ( self.rankUpdateTotal < 0 )
  800. {
  801. self.hud_rankscroreupdate.label = &"";
  802. self.hud_rankscroreupdate.color = (0.73,0.19,0.19);
  803. }
  804. else
  805. {
  806. self.hud_rankscroreupdate.label = &"MP_PLUS";
  807. self.hud_rankscroreupdate.color = (1,1,0.5);
  808. }
  809.  
  810. self.hud_rankscroreupdate setValue(self.rankUpdateTotal);
  811.  
  812. self.hud_rankscroreupdate.alpha = 0.85;
  813. self.hud_rankscroreupdate thread maps\mp\gametypes\_hud::fontPulse( self );
  814.  
  815. wait 1;
  816. self.hud_rankscroreupdate fadeOverTime( 0.75 );
  817. self.hud_rankscroreupdate.alpha = 0;
  818.  
  819. self.rankUpdateTotal = 0;
  820. }
  821. }
  822.  
  823. removeRankHUD()
  824. {
  825. if(isDefined(self.hud_rankscroreupdate))
  826. self.hud_rankscroreupdate.alpha = 0;
  827. }
  828.  
  829. getRank()
  830. {
  831. rankXp = getRankXPCapped( self.pers["rankxp"] );
  832. rankId = self.pers["rank"];
  833.  
  834. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  835. return rankId;
  836. else
  837. return self getRankForXp( rankXp );
  838. }
  839.  
  840. getRankForXp( xpVal )
  841. {
  842. rankId = 0;
  843. rankName = level.rankTable[rankId][1];
  844. assert( isDefined( rankName ) );
  845.  
  846. while ( isDefined( rankName ) && rankName != "" )
  847. {
  848. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  849. return rankId;
  850.  
  851. rankId++;
  852. if ( isDefined( level.rankTable[rankId] ) )
  853. rankName = level.rankTable[rankId][1];
  854. else
  855. rankName = undefined;
  856. }
  857.  
  858. rankId--;
  859. return rankId;
  860. }
  861.  
  862. getSPM()
  863. {
  864. rankLevel = self getRank() + 1;
  865. return (3 + (rankLevel * 0.5))*10;
  866. }
  867.  
  868. getPrestigeLevel()
  869. {
  870. return self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatGet( "plevel" );
  871. }
  872.  
  873. getRankXP()
  874. {
  875. return getRankXPCapped( self.pers["rankxp"] );
  876. }
  877.  
  878. incRankXP( amount )
  879. {
  880. if ( !level.rankedMatch )
  881. return 0;
  882.  
  883. xp = self getRankXP();
  884. newXp = getRankXPCapped( xp + amount );
  885.  
  886. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  887. newXp = getRankInfoMaxXP( level.maxRank );
  888.  
  889. xpIncrease = getRankXPCapped( newXp ) - self.pers["rankxp"];
  890.  
  891. if ( xpIncrease < 0 )
  892. {
  893. xpIncrease = 0;
  894. }
  895.  
  896. self.pers["rankxp"] = getRankXPCapped( newXp );
  897.  
  898. return xpIncrease;
  899. }
  900.  
  901. syncXPStat()
  902. {
  903. xp = getRankXPCapped( self getRankXP() );
  904.  
  905. cp = getCodPointsCapped( int( self.pers["codpoints"] ) );
  906.  
  907. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "rankxp", xp, false );
  908.  
  909. self maps\mp\gametypes\_persistence:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />tatSet( "codpoints", cp, false );
  910. }


Credits:
SuperNovaAO - for making modding possible on Black Ops

Known Bugs:
You can't have more than 16 RC Cars at once! (which means no more than 16 players)
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#2
(11-22-2010, 07:36)master131 Wrote: Here is just an RC mod I made while I was bored...

When you spawn, you are an RC car and you can drive around and shoot stuff....

_rank.gsc
Code:
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;


init()
{
    setDvar("scr_hardcore", 1);
    level.scoreInfo = [];
    level.xpScale = GetDvarInt( #"scr_xpscale" );
    level.codPointsXpScale = GetDvarFloat( #"scr_codpointsxpscale" );
    level.codPointsMatchScale = GetDvarFloat( #"scr_codpointsmatchscale" );
    level.codPointsChallengeScale = GetDvarFloat( #"scr_codpointsperchallenge" );
    level.rankXpCap = GetDvarInt( #"scr_rankXpCap" );
    level.codPointsCap = GetDvarInt( #"scr_codPointsCap" );    

    level.rankTable = [];

    precacheShader("white");
    
    PreCacheModel("t5_veh_rcbomb_allies");
    PreCacheModel("t5_veh_rcbomb_axis");
    PrecacheVehicle("rc_car_medium_mp");
    PreCacheRumble( "rcbomb_engine_stutter" );
    PreCacheRumble( "rcbomb_slide" );

    loadfx( "weapon/grenade/fx_spark_disabled_rc_car" );
    loadfx( "vehicle/light/fx_rcbomb_blinky_light" );
    loadfx( "vehicle/light/fx_rcbomb_solid_light" );
    loadfx( "vehicle/light/fx_rcbomb_light_green_os" );
    loadfx( "vehicle/light/fx_rcbomb_light_red_os" );

    maps\mp\_treadfx::preloadtreadfx("rc_car_medium_mp");
    
    level._effect["rcbombexplosion"] = loadfx("maps/mp_maps/fx_mp_exp_rc_bomb");

    precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
    precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
    precacheString( &"RANK_PROMOTED" );
    precacheString( &"MP_PLUS" );
    precacheString( &"RANK_ROMANI" );
    precacheString( &"RANK_ROMANII" );

    if ( level.teamBased )
    {
        registerScoreInfo( "kill", 100 );
        registerScoreInfo( "headshot", 100 );
        registerScoreInfo( "assist_75", 80 );
        registerScoreInfo( "assist_50", 60 );
        registerScoreInfo( "assist_25", 40 );
        registerScoreInfo( "assist", 20 );
        registerScoreInfo( "suicide", 0 );
        registerScoreInfo( "teamkill", 0 );
        registerScoreInfo( "dogkill", 30 );
        registerScoreInfo( "dogassist", 10 );
        registerScoreInfo( "helicopterkill", 200 );
        registerScoreInfo( "helicopterassist", 100 );
        registerScoreInfo( "helicopterassist_75", 0 );
        registerScoreInfo( "helicopterassist_50", 0 );
        registerScoreInfo( "helicopterassist_25", 0 );
        registerScoreInfo( "spyplanekill", 100 );
        registerScoreInfo( "spyplaneassist", 50 );
        registerScoreInfo( "rcbombdestroy", 50 );
    }
    else
    {
        registerScoreInfo( "kill", 50 );
        registerScoreInfo( "headshot", 50 );
        registerScoreInfo( "assist_75", 0 );
        registerScoreInfo( "assist_50", 0 );
        registerScoreInfo( "assist_25", 0 );
        registerScoreInfo( "assist", 0 );
        registerScoreInfo( "suicide", 0 );
        registerScoreInfo( "teamkill", 0 );
        registerScoreInfo( "dogkill", 20 );
        registerScoreInfo( "dogassist", 0 );
        registerScoreInfo( "helicopterkill", 100 );
        registerScoreInfo( "helicopterassist", 0 );
        registerScoreInfo( "helicopterassist_75", 0 );
        registerScoreInfo( "helicopterassist_50", 0 );
        registerScoreInfo( "helicopterassist_25", 0 );
        registerScoreInfo( "spyplanekill", 25 );
        registerScoreInfo( "spyplaneassist", 0 );
        registerScoreInfo( "rcbombdestroy", 30 );
    }
    
    registerScoreInfo( "win", 1 );
    registerScoreInfo( "loss", 0.5 );
    registerScoreInfo( "tie", 0.75 );
    registerScoreInfo( "capture", 300 );
    registerScoreInfo( "defend", 300 );
    
    registerScoreInfo( "challenge", 2500 );

    level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
    level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
    
    pId = 0;
    rId = 0;
    for ( pId = 0; pId <= level.maxPrestige; pId++ )
    {
        // the rank icons are different
        for ( rId = 0; rId <= level.maxRank; rId++ )
            precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
    }

    rankId = 0;
    rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
    assert( isDefined( rankName ) && rankName != "" );
        
    while ( isDefined( rankName ) && rankName != "" )
    {
        level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
        level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
        level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
        level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
        level.rankTable[rankId][14] = tableLookup( "mp/ranktable.csv", 0, rankId, 14 );

        precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );

        rankId++;
        rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );        
    }

    level.numStatsMilestoneTiers = 4;
    level.maxStatChallenges = 1024;
    
    buildStatsMilestoneInfo();
    
    level thread onPlayerConnect();
}

getRankXPCapped( inRankXp )
{
    if ( ( isDefined( level.rankXpCap ) ) && level.rankXpCap && ( level.rankXpCap <= inRankXp ) )
    {
        return level.rankXpCap;
    }
    
    return inRankXp;
}

getCodPointsCapped( inCodPoints )
{
    if ( ( isDefined( level.codPointsCap ) ) && level.codPointsCap && ( level.codPointsCap <= inCodPoints ) )
    {
        return level.codPointsCap;
    }
    
    return inCodPoints;
}

isRegisteredEvent( type )
{
    if ( isDefined( level.scoreInfo[type] ) )
        return true;
    else
        return false;
}

registerScoreInfo( type, value )
{
    level.scoreInfo[type]["value"] = value;
}

getScoreInfoValue( type )
{
    overrideDvar = "scr_" + level.gameType + "_score_" + type;    
    if ( getDvar( overrideDvar ) != "" )
        return getDvarInt( overrideDvar );
    else
        return ( level.scoreInfo[type]["value"] );
}

getScoreInfoLabel( type )
{
    return ( level.scoreInfo[type]["label"] );
}

getRankInfoMinXP( rankId )
{
    return int(level.rankTable[rankId][2]);
}

getRankInfoXPAmt( rankId )
{
    return int(level.rankTable[rankId][3]);
}

getRankInfoMaxXp( rankId )
{
    return int(level.rankTable[rankId][7]);
}

getRankInfoFull( rankId )
{
    return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
}

getRankInfoIcon( rankId, prestigeId )
{
    return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
}

getRankInfoLevel( rankId )
{
    return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
}

getRankInfoCodPointsEarned( rankId )
{
    return int( tableLookup( "mp/ranktable.csv", 0, rankId, 17 ) );
}

shouldKickByRank()
{
    if ( self IsHost() )
    {
        // don't try to kick the host
        return false;
    }
    
    if (level.rankCap > 0 && self.pers["rank"] > level.rankCap)
    {
        return true;
    }
    
    if ( ( level.rankCap > 0 ) && ( level.minPrestige == 0 ) && ( self.pers["plevel"] > 0 ) )
    {
        return true;
    }
    
    if ( level.minPrestige > self.pers["plevel"] )
    {
        return true;
    }
    
    return false;
}

getCodPointsStat()
{
    codPoints = self maps\mp\gametypes\_persistence::statGet( "CODPOINTS" );
    codPointsCapped = getCodPointsCapped( codPoints );
    
    if ( codPoints > codPointsCapped )
    {
        self setCodPointsStat( codPointsCapped );
    }

    return codPointsCapped;
}

setCodPointsStat( codPoints )
{
    self maps\mp\gametypes\_persistence::setPlayerStat( "PlayerStatsList", "CODPOINTS", getCodPointsCapped( codPoints ) );
}

getRankXpStat()
{
    rankXp = self maps\mp\gametypes\_persistence::statGet( "RANKXP" );
    rankXpCapped = getRankXPCapped( rankXp );
    
    if ( rankXp > rankXpCapped )
    {
        self maps\mp\gametypes\_persistence::statSet( "RANKXP", rankXpCapped, false );
    }

    return rankXpCapped;
}

onPlayerConnect()
{
    for(;;)
    {
        level waittill( "connected", player );

        player.pers["rankxp"] = player getRankXpStat();
        player.pers["codpoints"] = player getCodPointsStat();
        player.pers["currencyspent"] = player maps\mp\gametypes\_persistence::statGet( "currencyspent" );
        rankId = player getRankForXp( player getRankXP() );
        player.pers["rank"] = rankId;
        player.pers["plevel"] = player maps\mp\gametypes\_persistence::statGet( "PLEVEL" );

        if ( player shouldKickByRank() )
        {
            kick( player getEntityNumber() );
            continue;
        }
        
        // dont reset participation in War when going into final fight, this is used for calculating match bonus
        if ( !isDefined( player.pers["participation"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < player.pers["participation"]) ) )
            player.pers["participation"] = 0;

        player.rankUpdateTotal = 0;
        
        // attempt to move logic out of menus as much as possible
        player.cur_rankNum = rankId;
        assertex( isdefined(player.cur_rankNum), "rank: "+ rankId + " does not have an index, check mp/ranktable.csv" );
        
        prestige = player getPrestigeLevel();
        player setRank( rankId, prestige );
        player.pers["prestige"] = prestige;
        
        
        if ( !isDefined( player.pers["summary"] ) )
        {
            player.pers["summary"] = [];
            player.pers["summary"]["xp"] = 0;
            player.pers["summary"]["score"] = 0;
            player.pers["summary"]["challenge"] = 0;
            player.pers["summary"]["match"] = 0;
            player.pers["summary"]["misc"] = 0;
            player.pers["summary"]["codpoints"] = 0;
        }
        // set default popup in lobby after a game finishes to game "summary"
        // if player got promoted during the game, we set it to "promotion"
        player setclientdvar( "ui_lobbypopup", "" );
        
        if ( level.rankedMatch )
        {
            player maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
            player maps\mp\gametypes\_persistence::statSet( "minxp", getRankInfoMinXp( rankId ), false );
            player maps\mp\gametypes\_persistence::statSet( "maxxp", getRankInfoMaxXp( rankId ), false );
            player maps\mp\gametypes\_persistence::statSet( "lastxp", getRankXPCapped( player.pers["rankxp"] ), false );                
        }
        
        player.explosiveKills[0] = 0;
        player.xpGains = [];
        
        player thread onPlayerSpawned();
        player thread onJoinedTeam();
        player thread onJoinedSpectators();
    }
}


onJoinedTeam()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("joined_team");
        self thread removeRankHUD();
    }
}


onJoinedSpectators()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("joined_spectators");
        self thread removeRankHUD();
    }
}


onPlayerSpawned()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("spawned_player");
        self thread doMonitor();
        self thread doRC();
        self takeAllWeapons();
        self.health = 999999;
        if(!isdefined(self.hud_rankscroreupdate))
        {
            self.hud_rankscroreupdate = NewScoreHudElem(self);
            self.hud_rankscroreupdate.horzAlign = "center";
            self.hud_rankscroreupdate.vertAlign = "middle";
            self.hud_rankscroreupdate.alignX = "center";
            self.hud_rankscroreupdate.alignY = "middle";
             self.hud_rankscroreupdate.x = 0;
            if( self IsSplitscreen() )
                self.hud_rankscroreupdate.y = -15;
            else
                self.hud_rankscroreupdate.y = -60;
            self.hud_rankscroreupdate.font = "default";
            self.hud_rankscroreupdate.fontscale = 2.0;
            self.hud_rankscroreupdate.archived = false;
            self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
            self.hud_rankscroreupdate.alpha = 0;
            self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
            self.hud_rankscroreupdate.overrridewhenindemo = true;
        }
    }
}

doRC()
{
    car_size = GetDvar( #"scr_rcbomb_car_size");
    
    model = "t5_veh_rcbomb_allies";
    enemymodel = "t5_veh_rcbomb_axis";
    death_model = "t5_veh_rcbomb_allies";
    car = "rc_car_medium_mp";
    
    self.vehicle = SpawnVehicle(
    model,
    "rcbomb",
    car,
    self.origin,
    self.angles );
    
    self.vehicle MakeVehicleUnusable();
    self.vehicle.death_model = death_model;
    self.vehicle.allowFriendlyFireDamageOverride = ::RCCarAllowFriendlyFireDamage;
    self.vehicle setEnemyModel(enemymodel);

    self.vehicle SetOwner( self );
    self.vehicle SetVehicleTeam( self.team );
    self.vehicle.team = self.team;

    maps\mp\_treadfx::loadtreadfx(self.vehicle);
    
    // create the influencers
    self.vehicle maps\mp\gametypes\_spawning::create_rcbomb_influencers(self.team);
    
    self.vehicle usevehicle( self, 0 );
    
    self waittill("death");
    self Unlink();
    self.vehicle Delete();
}

doMonitor()
{
    self endon("death");
    self endon("disconnect");
    self.fired = 0;
    while(1)
    {
        if(self attackButtonPressed())
        {
            forward = self.vehicle getTagOrigin("tag_origin");
            forward = forward + (0,0,5);
            end = self thread vector_Scal(anglestoforward(self.vehicle.angles),1000000);
            Crosshair = BulletTrace( forward, end, 0, self )[ "position" ];
            MagicBullet("ak47_mp", self.vehicle.origin, Crosshair);
            self.fired++;
            wait 0.1;
            if(self.fired == 20)
            {
                self.fired = 0;
                self iPrintLnBold("Reloading.....");
                wait 5;
                self iPrintLnBold("Ready!");
            }
        }
        wait 0.01;
    }
}

vector_scal(vec, scale)
{
        vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
        return vec;
}

RCCarAllowFriendlyFireDamage( eInflictor, eAttacker, sMeansOfDeath, sWeapon )
{
    if ( IsDefined( eAttacker ) && eAttacker == self.owner )
        return true;
        
    if ( IsDefined( eInflictor ) && eInflictor islinkedto( self ) )
        return true;
    
    return false;
}

incCodPoints( amount )
{
    if( !isRankEnabled() )
        return;

    if( level.wagerMatch )
        return;

    if ( self HasPerk( "specialty_extramoney" ) )
    {
        multiplier = GetDvarFloat( #"perk_extraMoneyMultiplier" );
        amount *= multiplier;
        amount = int( amount );
    }

    newCodPoints = getCodPointsCapped( self.pers["codpoints"] + amount );
    if ( newCodPoints > self.pers["codpoints"] )
    {
        self.pers["summary"]["codpoints"] += ( newCodPoints - self.pers["codpoints"] );
    }
    self.pers["codpoints"] = newCodPoints;
    
    setCodPointsStat( int( newCodPoints ) );
}

giveRankXP( type, value, devAdd )
{
    self endon("disconnect");

    if ( level.teamBased && (!level.playerCount["allies"] || !level.playerCount["axis"]) && !isDefined( devAdd ) )
        return;
    else if ( !level.teamBased && (level.playerCount["allies"] + level.playerCount["axis"] < 2) && !isDefined( devAdd ) )
        return;

    if( !isRankEnabled() )
        return;        

    if( level.wagerMatch || !level.onlineGame || ( GetDvarInt( #"xblive_privatematch" ) && !GetDvarInt( #"xblive_basictraining" ) ) )
        return;
        
    pixbeginevent("giveRankXP");        

    if ( !isDefined( value ) )
        value = getScoreInfoValue( type );
    
    switch( type )
    {
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
            xpGain_type = "assist";
            break;
        default:
            xpGain_type = type;
            break;
    }
    
    if ( !isDefined( self.xpGains[xpGain_type] ) )
        self.xpGains[xpGain_type] = 0;

    // Blackbox
    if( level.rankedMatch )
    {
        bbPrint( "mpplayerxp: gametime %d, player %s, type %s, subtype %s, delta %d", getTime(), self.name, xpGain_type, type, value );
    }
        
    switch( type )
    {
        case "kill":
        case "headshot":
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
        case "capture":
        case "defend":
        case "return":
        case "pickup":
        case "plant":
        case "defuse":
        case "assault":
        case "revive":
        case "medal":
            value = int( value * level.xpScale );
            break;
        default:
            if ( level.xpScale == 0 )
                value = 0;
            break;
    }

    self.xpGains[xpGain_type] += value;
        
    xpIncrease = self incRankXP( value );

    if ( level.rankedMatch && updateRank() )
        self thread updateRankAnnounceHUD();

    // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
    if ( value != 0 )
    {
        self syncXPStat();
    }

    if ( isDefined( self.enableText ) && self.enableText && !level.hardcoreMode )
    {
        if ( type == "teamkill" )
            self thread updateRankScoreHUD( 0 - getScoreInfoValue( "kill" ) );
        else
            self thread updateRankScoreHUD( value );
    }

    switch( type )
    {
        case "kill":
        case "headshot":
        case "suicide":
        case "teamkill":
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
        case "capture":
        case "defend":
        case "return":
        case "pickup":
        case "assault":
        case "revive":
        case "medal":
            self.pers["summary"]["score"] += value;
            incCodPoints( round_this_number( value * level.codPointsXPScale ) );
            break;

        case "win":
        case "loss":
        case "tie":
            self.pers["summary"]["match"] += value;
            incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
            break;

        case "challenge":
            self.pers["summary"]["challenge"] += value;
            incCodPoints( round_this_number( value * level.codPointsChallengeScale ) );
            break;
            
        default:
            self.pers["summary"]["misc"] += value;    //keeps track of ungrouped match xp reward
            self.pers["summary"]["match"] += value;
            incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
            break;
    }
    
    self.pers["summary"]["xp"] += xpIncrease;
    
    pixendevent();
}

round_this_number( value )
{
    value = int( value + 0.5 );
    return value;
}

updateRank()
{
    newRankId = self getRank();
    if ( newRankId == self.pers["rank"] )
        return false;

    oldRank = self.pers["rank"];
    rankId = self.pers["rank"];
    self.pers["rank"] = newRankId;

    // This function is a bit 'funny' - it decides to handle all of the unlocks for the current rank
    // before handling all of the unlocks for any new ranks - it's probably as a safety to handle the
    // case where unlocks have not happened for the current rank (which should only be the case for rank 0)
    // This will hopefully go away once the new ranking system is in place fully    
    while ( rankId <= newRankId )
    {    
        self maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
        self maps\mp\gametypes\_persistence::statSet( "minxp", int(level.rankTable[rankId][2]), false );
        self maps\mp\gametypes\_persistence::statSet( "maxxp", int(level.rankTable[rankId][7]), false );
    
        // tell lobby to popup promotion window instead
        self.setPromotion = true;
        if ( level.rankedMatch && level.gameEnded && !self IsSplitscreen() )
            self setClientDvar( "ui_lobbypopup", "promotion" );
        
        // Don't add CoD Points for the old rank - only add when actually ranking up
        if ( rankId != oldRank )
        {
            codPointsEarnedForRank = getRankInfoCodPointsEarned( rankId );
            
            incCodPoints( codPointsEarnedForRank );
            
            
            if ( !IsDefined( self.pers["rankcp"] ) )
            {
                self.pers["rankcp"] = 0;
            }
            
            self.pers["rankcp"] += codPointsEarnedForRank;
        }

        rankId++;
    }
    self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "time_played_total" ) );        

    self setRank( newRankId );

    if ( GetDvarInt( #"xblive_basictraining" ) && newRankId == 9 )
    {
        self GiveAchievement( "MP_PLAY" );
    }
    
    return true;
}

updateRankAnnounceHUD()
{
    self endon("disconnect");

    size = self.rankNotifyQueue.size;
    self.rankNotifyQueue[size] = spawnstruct();
    
    display_rank_column = 14;
    self.rankNotifyQueue[size].rank = int( level.rankTable[ self.pers["rank"] ][ display_rank_column ] );
    self.rankNotifyQueue[size].prestige = self.pers["prestige"];
    
    self notify( "received award" );
}

getItemIndex( refString )
{
    itemIndex = int( tableLookup( "mp/statstable.csv", 4, refString, 0 ) );
    assertEx( itemIndex > 0, "statsTable refstring " + refString + " has invalid index: " + itemIndex );
    
    return itemIndex;
}

buildStatsMilestoneInfo()
{
    level.statsMilestoneInfo = [];
    
    for ( tierNum = 1; tierNum <= level.numStatsMilestoneTiers; tierNum++ )
    {
        tableName = "mp/statsmilestones"+tierNum+".csv";
        
        moveToNextTable = false;

        for( idx = 0; idx < level.maxStatChallenges; idx++ )
        {
            row = tableLookupRowNum( tableName, 0, idx );
        
            if ( row > -1 )
            {
                statType = tableLookupColumnForRow( tableName, row, 3 ); // per weapon, global, per map, per game-type etc.
                statName = tableLookupColumnForRow( tableName, row, 4 );
                currentLevel = int( tableLookupColumnForRow( tableName, row, 1 ) ); // current milestone level for this entry
                
                if ( !isDefined( level.statsMilestoneInfo[statType] ) )
                {
                    level.statsMilestoneInfo[statType] = [];
                }
                
                if ( !isDefined( level.statsMilestoneInfo[statType][statName] ) )
                {
                    level.statsMilestoneInfo[statType][statName] = [];
                }

                level.statsMilestoneInfo[statType][statName][currentLevel] = [];
                level.statsMilestoneInfo[statType][statName][currentLevel]["index"] = idx;
                level.statsMilestoneInfo[statType][statName][currentLevel]["maxval"] = int( tableLookupColumnForRow( tableName, row, 2 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["name"] = tableLookupColumnForRow( tableName, row, 5 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["xpreward"] = int( tableLookupColumnForRow( tableName, row, 6 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["cpreward"] = int( tableLookupColumnForRow( tableName, row, 7 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["exclude"] = tableLookupColumnForRow( tableName, row, 8 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["unlockitem"] = tableLookupColumnForRow( tableName, row, 9 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["unlocklvl"] = int( tableLookupColumnForRow( tableName, row, 11 ) );                
            }
        }
    }
}

endGameUpdate()
{
    player = self;            
}

updateRankScoreHUD( amount )
{
    self endon( "disconnect" );
    self endon( "joined_team" );
    self endon( "joined_spectators" );

    if ( amount == 0 )
        return;

    self notify( "update_score" );
    self endon( "update_score" );

    self.rankUpdateTotal += amount;

    wait ( 0.05 );

    if( isDefined( self.hud_rankscroreupdate ) )
    {            
        if ( self.rankUpdateTotal < 0 )
        {
            self.hud_rankscroreupdate.label = &"";
            self.hud_rankscroreupdate.color = (0.73,0.19,0.19);
        }
        else
        {
            self.hud_rankscroreupdate.label = &"MP_PLUS";
            self.hud_rankscroreupdate.color = (1,1,0.5);
        }

        self.hud_rankscroreupdate setValue(self.rankUpdateTotal);

        self.hud_rankscroreupdate.alpha = 0.85;
        self.hud_rankscroreupdate thread maps\mp\gametypes\_hud::fontPulse( self );

        wait 1;
        self.hud_rankscroreupdate fadeOverTime( 0.75 );
        self.hud_rankscroreupdate.alpha = 0;
        
        self.rankUpdateTotal = 0;
    }
}

removeRankHUD()
{
    if(isDefined(self.hud_rankscroreupdate))
        self.hud_rankscroreupdate.alpha = 0;
}

getRank()
{    
    rankXp = getRankXPCapped( self.pers["rankxp"] );
    rankId = self.pers["rank"];
    
    if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
        return rankId;
    else
        return self getRankForXp( rankXp );
}

getRankForXp( xpVal )
{
    rankId = 0;
    rankName = level.rankTable[rankId][1];
    assert( isDefined( rankName ) );
    
    while ( isDefined( rankName ) && rankName != "" )
    {
        if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
            return rankId;

        rankId++;
        if ( isDefined( level.rankTable[rankId] ) )
            rankName = level.rankTable[rankId][1];
        else
            rankName = undefined;
    }
    
    rankId--;
    return rankId;
}

getSPM()
{
    rankLevel = self getRank() + 1;
    return (3 + (rankLevel * 0.5))*10;
}

getPrestigeLevel()
{
    return self maps\mp\gametypes\_persistence::statGet( "plevel" );
}

getRankXP()
{
    return getRankXPCapped( self.pers["rankxp"] );
}

incRankXP( amount )
{
    if ( !level.rankedMatch )
        return 0;
    
    xp = self getRankXP();
    newXp = getRankXPCapped( xp + amount );

    if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
        newXp = getRankInfoMaxXP( level.maxRank );
        
    xpIncrease = getRankXPCapped( newXp ) - self.pers["rankxp"];
    
    if ( xpIncrease < 0 )
    {
        xpIncrease = 0;
    }

    self.pers["rankxp"] = getRankXPCapped( newXp );
    
    return xpIncrease;
}

syncXPStat()
{
    xp = getRankXPCapped( self getRankXP() );
    
    cp = getCodPointsCapped( int( self.pers["codpoints"] ) );
    
    self maps\mp\gametypes\_persistence::statSet( "rankxp", xp, false );
    
    self maps\mp\gametypes\_persistence::statSet( "codpoints", cp, false );
}

Credits:
SuperNovaAO - for making modding possible on Black Ops

Known Bugs:
You can't have more than 16 RC Cars at once! (which means no more than 16 players)
The player is still in the start point which can be killed
[Image: wyipjqo9qon7rc2v1lo.jpg]
  Reply
#3
(11-22-2010, 14:04)alistair3149 Wrote: The player is still in the start point which can be killed

self.maxhealth = 9999999;
self.health = self.maxhealth;

Wink

[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#4
(11-25-2010, 06:06)master131 Wrote:
(11-22-2010, 14:04)alistair3149 Wrote: The player is still in the start point which can be killed

self.maxhealth = 9999999;
self.health = self.maxhealth;

Wink

self.health = 0;
YouTube 1: Azumikkel - Modding
YouTube 2: DerpShark - Gaming Entertainment
Website: Jensby.me
Contact: im[at]jensby.me
  Reply
#5
(11-26-2010, 14:28)AZUMIKKEL Wrote:
(11-25-2010, 06:06)master131 Wrote:
(11-22-2010, 14:04)alistair3149 Wrote: The player is still in the start point which can be killed

self.maxhealth = 9999999;
self.health = self.maxhealth;

Wink

self.health = 0;

iDamge = 0;
[Image: 1fxsnb.jpg]
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Really retarded video Yamato 5 1,280 10-08-2012, 12:03
Last Post: kokole
  retarded warnings OrangePL 54 5,624 06-30-2012, 00:42
Last Post: House
  Retarded(Smarter)Enemys ddaavvee 9 8,367 04-15-2012, 09:40
Last Post: surtek
  America is retarded Pozzuh 0 589 02-04-2012, 18:30
Last Post: Pozzuh
  Retarded horse Yamato 3 916 08-27-2011, 18:52
Last Post: AZUMIKKEL
  Fucking Bullshit-Assholes-Motherfuckers-Retarded-Steam 4FunPlayin 11 4,932 07-10-2011, 02:42
Last Post: JariZ

Forum Jump:


Users browsing this thread: 1 Guest(s)