Advertisement
SMF

aiw mods comp

SMF
Mar 31st, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.11 KB | None | 0 0
  1. [TUTORIAL] Creating a Gametype
  2.  
  3. [spoiler=]Moderator: Tech Support
  4.  
  5. 39 posts • Page 1 of 2 • 1, 2
  6. [TUTORIAL] Creating a Gametype
  7.  
  8. Postby Vekiorus » Fri Oct 22, 2010 2:51 am
  9.  
  10. Hey
  11. WHATS UP
  12. //fluffee off
  13. As i did some research into making a mod-gametype, i found a quite interesting way to make your own.
  14. This is addressed to server admins, whole for example wants to rotate one in the chamber, gungame from zxz and, lets say, my mod.
  15. Using the maprotation command of course.
  16. As you know, we can change gametypes AND maps witht the map rotation command.
  17. So here is how to make your own gametype.
  18. Note: This tutorial will show how to create gametypes with 1 file mods (exemple: _rank.gsc). It is perfectly possible to make multifile mods gametypes, but would be to long to explain, but I guess people with IQ over 70 can find the way ;)
  19.  
  20. Creating the base
  21. First step, navigate to your mw2 "main" directory.
  22. Backup the file "iw_25.iwd"
  23. Now open the original copy. If you have the alterIwnet one, your iwd should look like this:
  24. maps/mp/gametypes. In the gametype folder:
  25. Spoiler: Toggle
  26. Image
  27.  
  28. Now, open the _gametypes.txt file. It should look like:
  29. Spoiler: Toggle
  30. Code: Select all
  31. dm
  32. dom
  33. sd
  34. sab
  35. war
  36. koth
  37. oneflag
  38. arena
  39. dd
  40. vip
  41. ctf
  42. gtnw
  43. oitc
  44.  
  45. For the purpose of this tutorial, my gametype is going to be called "vek1"
  46. So add "vek1" under "oitc":
  47. Spoiler: Toggle
  48. Code: Select all
  49. dm
  50. dom
  51. sd
  52. sab
  53. war
  54. koth
  55. oneflag
  56. arena
  57. dd
  58. vip
  59. ctf
  60. gtnw
  61. oitc
  62. vek1
  63.  
  64. My gametype is going to be based on Free For All.
  65. So, i am going to find the "dm.gsc" file. You can get it from a gsc rip, google it.
  66. Im going to rename it to "vek1.gsc" and put it into my IWD (in the gametypes folder obviously). Dont touch it anymore for now.
  67. Last step of this part :
  68. You need to create a "vek1.txt" file. In it, i'm going to put this content:
  69. Code: Select all
  70. "Veki's Arena"
  71.  
  72. YES, with the quotes. It's important.
  73. Your IWD now looks like:
  74. Spoiler: Toggle
  75. Image
  76.  
  77. Dont mind the whited out part.
  78.  
  79. Converting the mod
  80. Okay.
  81. This might be the easiest part.
  82. Find your "rank.gsc" mod file, or whichever one you choosen, and copy it. Now, name it "_vek1.gsc". NOT "vek1.gsc". You need to rename it with an underscore or you will overwrite your gametype.
  83. Put it into your "gametypes" folder in your iwd25.
  84. Thats all for this part!
  85.  
  86. Calling the mod into the gametype
  87. Okay, last part.
  88. You are now going to open your "vek1.gsc" file. (the GAMETYPE one, without the underscore.)
  89. Find this:
  90. Spoiler: Toggle
  91. Code: Select all
  92. main()
  93. {
  94.  
  95. maps\mp\gametypes\_globallogic::init();
  96. maps\mp\gametypes\_callbacksetup::SetupCallbacks();
  97. maps\mp\gametypes\_globallogic::SetupCallbacks();
  98.  
  99. registerTimeLimitDvar( level.gameType, 10, 0, 1440 );
  100. registerScoreLimitDvar( level.gameType, 1000, 0, 5000 );
  101. registerWinLimitDvar( level.gameType, 1, 0, 5000 );
  102. registerRoundLimitDvar( level.gameType, 1, 0, 10 );
  103. registerNumLivesDvar( level.gameType, 0, 0, 10 );
  104. registerHalfTimeDvar( level.gameType, 0, 0, 1 );
  105.  
  106. level.onStartGameType = ::onStartGameType;
  107. level.getSpawnPoint = ::getSpawnPoint;
  108.  
  109. game["dialog"]["gametype"] = "freeforall";
  110.  
  111. if ( getDvarInt( "g_hardcore" ) )
  112. game["dialog"]["gametype"] = "hc_" + game["dialog"]["gametype"];
  113. else if ( getDvarInt( "camera_thirdPerson" ) )
  114. game["dialog"]["gametype"] = "thirdp_" + game["dialog"]["gametype"];
  115. else if ( getDvarInt( "scr_diehard" ) )
  116. game["dialog"]["gametype"] = "dh_" + game["dialog"]["gametype"];
  117. else if (getDvarInt( "scr_" + level.gameType + "_promode" ) )
  118. game["dialog"]["gametype"] = game["dialog"]["gametype"] + "_pro";
  119. }
  120.  
  121. Under the maps\mp\gametypes\_globallogic::init();, you want to add:
  122. Code: Select all
  123. maps\mp\gametypes\_vek1::init();
  124.  
  125. This calls the INIT function of your mod. If your mod doesent have one, then i wonder what the fuck game are you modding.
  126. Now save the file.
  127. You are done.
  128. Good job Delta Squad.
  129.  
  130. By the way, your rar should look like :
  131. Spoiler: Toggle
  132. Image
  133.  
  134. Ah, and to call your gametype, type in console
  135. Code: Select all
  136. g_gametype vek1
  137.  
  138. It will then say:
  139. Code: Select all
  140. g_gametype will be changed upon restarting.
  141.  
  142. Just start the map or do map_restart if you are in game.
  143.  
  144.  
  145. Proof the method works
  146. Screenshots:
  147. Spoiler: Toggle
  148. Image
  149.  
  150. Spoiler: Toggle
  151. Image
  152.  
  153.  
  154. Good luck, and have fun!
  155.  
  156. Note: However, because changing to dm gametype is bugged, you will need a couple extra commands to make it look like a real ffa.
  157. I let you find out,
  158.  
  159. And please dont steal this tutorial/claim it as yours.
  160. Thanks
  161.  
  162. Edit: If anyone wants my iw_25 PM me.
  163. Downloads
  164. Roll the Dice 4 Gametype
  165. -> g_gametype rtdwar Team Deathmatch RTD
  166. -> g_gametype rtdffa FFA RTD
  167. Last edited by Vekiorus on Sat Nov 06, 2010 11:49 pm, edited 1 time in total.
  168. Image
  169. Image
  170. User avatar
  171. Vekiorus
  172.  
  173. Joined: Mon May 17, 2010 2:29 am
  174.  
  175. Top[/spoiler]
  176.  
  177.  
  178. [Tutorial] Making an intermediate mod.
  179.  
  180. [spoiler=]Moderator: Tech Support
  181.  
  182. 26 posts • Page 1 of 2 • 1, 2
  183. [Tutorial] Making an intermediate mod.
  184.  
  185. Postby SolareStill » Sat Jun 25, 2011 9:41 am
  186.  
  187. Making an Intermediate Mod.
  188.  
  189. __________________________________________________________________________________________________
  190.  
  191. Image
  192. 1. Introduction
  193. 2. Getting your _rank.gsc
  194. 3. Creating / Loading a custom gsc
  195. 4. Coding
  196. 5. Conclusion
  197.  
  198.  
  199. Image
  200. Hey guys, in this tutorial I'll be showing you how to create a simple mod, which should help you in future modding. Also at the end, be sure to archive it as a zip iwd file. If it is archived as a rar iwd file then it won't load properly. If you're new to modding, I suggest you look at this thread: Basic GSC Coding
  201.  
  202.  
  203. Image
  204. Firstly, lets create a new folder on the desktop, and call it anything, for now just use "Your iMod" (i meaning intermediate). Ok, open up notepad. Now we're going to put in a clean _rank.gsc. Copy the code below and copy it into your notepad.
  205. Code: Select all
  206. #include common_scripts\utility;
  207. #include maps\mp\_utility;
  208. #include maps\mp\gametypes\_hud_util;
  209.  
  210.  
  211. doDvars()
  212. {
  213.  
  214. }
  215.  
  216. init()
  217. {
  218. level.scoreInfo = [];
  219. level.xpScale = getDvarInt( "scr_xpscale" );
  220.  
  221. level.rankTable = [];
  222.  
  223. precacheShader("white");
  224.  
  225. precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  226. precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  227. precacheString( &"RANK_PROMOTED" );
  228. precacheString( &"MP_PLUS" );
  229. precacheString( &"RANK_ROMANI" );
  230. precacheString( &"RANK_ROMANII" );
  231. precacheString( &"RANK_ROMANIII" );
  232.  
  233. if ( level.teamBased )
  234. {
  235. registerScoreInfo( "kill", 100 );
  236. registerScoreInfo( "headshot", 200 );
  237. registerScoreInfo( "assist", 50 );
  238. registerScoreInfo( "suicide", 100 );
  239. registerScoreInfo( "teamkill", 0 );
  240. }
  241. else
  242. {
  243. registerScoreInfo( "kill", 100 );
  244. registerScoreInfo( "headshot", 200 );
  245. registerScoreInfo( "assist", 50 );
  246. registerScoreInfo( "suicide", 100 );
  247. registerScoreInfo( "teamkill", 0 );
  248. }
  249.  
  250. registerScoreInfo( "win", 1 );
  251. registerScoreInfo( "loss", 0.5 );
  252. registerScoreInfo( "tie", 0.75 );
  253. registerScoreInfo( "capture", 300 );
  254. registerScoreInfo( "defend", 300 );
  255.  
  256. registerScoreInfo( "challenge", 2500 );
  257.  
  258. level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  259. level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  260.  
  261. pId = 0;
  262. rId = 0;
  263. for ( pId = 0; pId <= level.maxPrestige; pId++ )
  264. {
  265. for ( rId = 0; rId <= level.maxRank; rId++ )
  266. precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  267. }
  268.  
  269. rankId = 0;
  270. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  271. assert( isDefined( rankName ) && rankName != "" );
  272.  
  273. while ( isDefined( rankName ) && rankName != "" )
  274. {
  275. level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  276. level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  277. level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  278. level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  279.  
  280. precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  281.  
  282. rankId++;
  283. rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  284. }
  285.  
  286. maps\mp\gametypes\_missions::buildChallegeInfo();
  287.  
  288. level thread patientZeroWaiter();
  289. level thread onPlayerConnect();
  290. }
  291.  
  292. patientZeroWaiter()
  293. {
  294. level endon( "game_ended" );
  295.  
  296. level waittill( "prematch_over" );
  297.  
  298. if ( !matchMakingGame() )
  299. {
  300. if ( getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999 )
  301. level.patientZeroName = level.players[0].name;
  302. }
  303. else
  304. {
  305. if ( getDvar( "scr_patientZero" ) != "" )
  306. level.patientZeroName = getDvar( "scr_patientZero" );
  307. }
  308. }
  309.  
  310. isRegisteredEvent( type )
  311. {
  312. if ( isDefined( level.scoreInfo[type] ) )
  313. return true;
  314. else
  315. return false;
  316. }
  317.  
  318.  
  319. registerScoreInfo( type, value )
  320. {
  321. level.scoreInfo[type]["value"] = value;
  322. }
  323.  
  324.  
  325. getScoreInfoValue( type )
  326. {
  327. overrideDvar = "scr_" + level.gameType + "_score_" + type;
  328. if ( getDvar( overrideDvar ) != "" )
  329. return getDvarInt( overrideDvar );
  330. else
  331. return ( level.scoreInfo[type]["value"] );
  332. }
  333.  
  334.  
  335. getScoreInfoLabel( type )
  336. {
  337. return ( level.scoreInfo[type]["label"] );
  338. }
  339.  
  340.  
  341. getRankInfoMinXP( rankId )
  342. {
  343. return int(level.rankTable[rankId][2]);
  344. }
  345.  
  346.  
  347. getRankInfoXPAmt( rankId )
  348. {
  349. return int(level.rankTable[rankId][3]);
  350. }
  351.  
  352.  
  353. getRankInfoMaxXp( rankId )
  354. {
  355. return int(level.rankTable[rankId][7]);
  356. }
  357.  
  358.  
  359. getRankInfoFull( rankId )
  360. {
  361. return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  362. }
  363.  
  364.  
  365. getRankInfoIcon( rankId, prestigeId )
  366. {
  367. return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  368. }
  369.  
  370. getRankInfoLevel( rankId )
  371. {
  372. return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  373. }
  374.  
  375. onPlayerConnect()
  376. {
  377. for(;;)
  378. {
  379. level waittill( "connected", player );
  380.  
  381. /#
  382. if ( getDvarInt( "scr_forceSequence" ) )
  383. player setPlayerData( "experience", 145499 );
  384. #/
  385. player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  386. if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  387. player.pers["rankxp"] = 0;
  388.  
  389. rankId = player getRankForXp( player getRankXP() );
  390. player.pers[ "rank" ] = rankId;
  391. player.pers[ "participation" ] = 0;
  392.  
  393. player.xpUpdateTotal = 0;
  394. player.bonusUpdateTotal = 0;
  395.  
  396. prestige = player getPrestigeLevel();
  397. player setRank( rankId, prestige );
  398. player.pers["prestige"] = prestige;
  399.  
  400. player.postGamePromotion = false;
  401. if ( !isDefined( player.pers["postGameChallenges"] ) )
  402. {
  403. player setClientDvars( "ui_challenge_1_ref", "",
  404. "ui_challenge_2_ref", "",
  405. "ui_challenge_3_ref", "",
  406. "ui_challenge_4_ref", "",
  407. "ui_challenge_5_ref", "",
  408. "ui_challenge_6_ref", "",
  409. "ui_challenge_7_ref", ""
  410. );
  411. }
  412.  
  413. player setClientDvar( "ui_promotion", 0 );
  414.  
  415. if ( !isDefined( player.pers["summary"] ) )
  416. {
  417. player.pers["summary"] = [];
  418. player.pers["summary"]["xp"] = 0;
  419. player.pers["summary"]["score"] = 0;
  420. player.pers["summary"]["challenge"] = 0;
  421. player.pers["summary"]["match"] = 0;
  422. player.pers["summary"]["misc"] = 0;
  423.  
  424. // resetting game summary dvars
  425. player setClientDvar( "player_summary_xp", "0" );
  426. player setClientDvar( "player_summary_score", "0" );
  427. player setClientDvar( "player_summary_challenge", "0" );
  428. player setClientDvar( "player_summary_match", "0" );
  429. player setClientDvar( "player_summary_misc", "0" );
  430. }
  431.  
  432.  
  433. // resetting summary vars
  434.  
  435. player setClientDvar( "ui_opensummary", 0 );
  436.  
  437. player maps\mp\gametypes\_missions::updateChallenges();
  438. player.explosiveKills[0] = 0;
  439. player.xpGains = [];
  440.  
  441. player.hud_scorePopup = newClientHudElem( player );
  442. player.hud_scorePopup.horzAlign = "center";
  443. player.hud_scorePopup.vertAlign = "middle";
  444. player.hud_scorePopup.alignX = "center";
  445. player.hud_scorePopup.alignY = "middle";
  446. player.hud_scorePopup.x = 0;
  447. if ( level.splitScreen )
  448. player.hud_scorePopup.y = -40;
  449. else
  450. player.hud_scorePopup.y = -60;
  451. player.hud_scorePopup.font = "hudbig";
  452. player.hud_scorePopup.fontscale = 0.75;
  453. player.hud_scorePopup.archived = false;
  454. player.hud_scorePopup.color = (0.5,0.5,0.5);
  455. player.hud_scorePopup.sort = 10000;
  456. player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  457.  
  458. player thread onPlayerSpawned();
  459. player thread onJoinedTeam();
  460. player thread onJoinedSpectators();
  461. }
  462. }
  463.  
  464.  
  465. onJoinedTeam()
  466. {
  467. self endon("disconnect");
  468.  
  469. for(;;)
  470. {
  471. self waittill( "joined_team" );
  472. self thread removeRankHUD();
  473. }
  474. }
  475.  
  476.  
  477. onJoinedSpectators()
  478. {
  479. self endon("disconnect");
  480.  
  481. for(;;)
  482. {
  483. self waittill( "joined_spectators" );
  484. self thread removeRankHUD();
  485. }
  486. }
  487.  
  488.  
  489. onPlayerSpawned()
  490. {
  491. self endon("disconnect");
  492. for(;;)
  493. {
  494. self waittill("spawned_player");
  495. self thread doDvars();
  496. }
  497. }
  498.  
  499.  
  500. roundUp( floatVal )
  501. {
  502. if ( int( floatVal ) != floatVal )
  503. return int( floatVal+1 );
  504. else
  505. return int( floatVal );
  506. }
  507.  
  508.  
  509. giveRankXP( type, value )
  510. {
  511. self endon("disconnect");
  512.  
  513. lootType = "none";
  514.  
  515. if ( !self rankingEnabled() )
  516. return;
  517.  
  518. if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  519. return;
  520. else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  521. return;
  522.  
  523. if ( !isDefined( value ) )
  524. value = getScoreInfoValue( type );
  525.  
  526. if ( !isDefined( self.xpGains[type] ) )
  527. self.xpGains[type] = 0;
  528.  
  529. momentumBonus = 0;
  530. gotRestXP = false;
  531.  
  532. switch( type )
  533. {
  534. case "kill":
  535. case "headshot":
  536. case "shield_damage":
  537. value *= self.xpScaler;
  538. case "assist":
  539. case "suicide":
  540. case "teamkill":
  541. case "capture":
  542. case "defend":
  543. case "return":
  544. case "pickup":
  545. case "assault":
  546. case "plant":
  547. case "destroy":
  548. case "save":
  549. case "defuse":
  550. if ( getGametypeNumLives() > 0 )
  551. {
  552. multiplier = max(1,int( 10/getGametypeNumLives() ));
  553. value = int(value * multiplier);
  554. }
  555.  
  556. value = int( value * level.xpScale );
  557.  
  558. restXPAwarded = getRestXPAward( value );
  559. value += restXPAwarded;
  560. if ( restXPAwarded > 0 )
  561. {
  562. if ( isLastRestXPAward( value ) )
  563. thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  564.  
  565. gotRestXP = true;
  566. }
  567. break;
  568. }
  569.  
  570. if ( !gotRestXP )
  571. {
  572. // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  573. if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  574. self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  575. }
  576.  
  577. oldxp = self getRankXP();
  578. self.xpGains[type] += value;
  579.  
  580. self incRankXP( value );
  581.  
  582. if ( self rankingEnabled() && updateRank( oldxp ) )
  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. self syncXPStat();
  587.  
  588. if ( !level.hardcoreMode )
  589. {
  590. if ( type == "teamkill" )
  591. {
  592. self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  593. }
  594. else
  595. {
  596. color = (1,1,0.5);
  597. if ( gotRestXP )
  598. color = (1,.65,0);
  599. self thread scorePopup( value, momentumBonus, color, 0 );
  600. }
  601. }
  602.  
  603. switch( type )
  604. {
  605. case "kill":
  606. case "headshot":
  607. case "suicide":
  608. case "teamkill":
  609. case "assist":
  610. case "capture":
  611. case "defend":
  612. case "return":
  613. case "pickup":
  614. case "assault":
  615. case "plant":
  616. case "defuse":
  617. self.pers["summary"]["score"] += value;
  618. self.pers["summary"]["xp"] += value;
  619. break;
  620.  
  621. case "win":
  622. case "loss":
  623. case "tie":
  624. self.pers["summary"]["match"] += value;
  625. self.pers["summary"]["xp"] += value;
  626. break;
  627.  
  628. case "challenge":
  629. self.pers["summary"]["challenge"] += value;
  630. self.pers["summary"]["xp"] += value;
  631. break;
  632.  
  633. default:
  634. self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
  635. self.pers["summary"]["match"] += value;
  636. self.pers["summary"]["xp"] += value;
  637. break;
  638. }
  639. }
  640.  
  641. updateRank( oldxp )
  642. {
  643. newRankId = self getRank();
  644. if ( newRankId == self.pers["rank"] )
  645. return false;
  646.  
  647. oldRank = self.pers["rank"];
  648. rankId = self.pers["rank"];
  649. self.pers["rank"] = newRankId;
  650.  
  651. //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
  652. println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  653.  
  654. self setRank( newRankId );
  655.  
  656. return true;
  657. }
  658.  
  659.  
  660. updateRankAnnounceHUD()
  661. {
  662. self endon("disconnect");
  663.  
  664. self notify("update_rank");
  665. self endon("update_rank");
  666.  
  667. team = self.pers["team"];
  668. if ( !isdefined( team ) )
  669. return;
  670.  
  671. // give challenges and other XP a chance to process
  672. // also ensure that post game promotions happen asap
  673. if ( !levelFlag( "game_over" ) )
  674. level waittill_notify_or_timeout( "game_over", 0.25 );
  675.  
  676.  
  677. newRankName = self getRankInfoFull( self.pers["rank"] );
  678. rank_char = level.rankTable[self.pers["rank"]][1];
  679. subRank = int(rank_char[rank_char.size-1]);
  680.  
  681. thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  682.  
  683. if ( subRank > 1 )
  684. return;
  685.  
  686. for ( i = 0; i < level.players.size; i++ )
  687. {
  688. player = level.players[i];
  689. playerteam = player.pers["team"];
  690. if ( isdefined( playerteam ) && player != self )
  691. {
  692. if ( playerteam == team )
  693. player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  694. }
  695. }
  696. }
  697.  
  698.  
  699. endGameUpdate()
  700. {
  701. player = self;
  702. }
  703.  
  704.  
  705. scorePopup( amount, bonus, hudColor, glowAlpha )
  706. {
  707. self endon( "disconnect" );
  708. self endon( "joined_team" );
  709. self endon( "joined_spectators" );
  710.  
  711. if ( amount == 0 )
  712. return;
  713.  
  714. self notify( "scorePopup" );
  715. self endon( "scorePopup" );
  716.  
  717. self.xpUpdateTotal += amount;
  718. self.bonusUpdateTotal += bonus;
  719.  
  720. wait ( 0.05 );
  721.  
  722. if ( self.xpUpdateTotal < 0 )
  723. self.hud_scorePopup.label = &"";
  724. else
  725. self.hud_scorePopup.label = &"MP_PLUS";
  726.  
  727. self.hud_scorePopup.color = hudColor;
  728. self.hud_scorePopup.glowColor = hudColor;
  729. self.hud_scorePopup.glowAlpha = glowAlpha;
  730.  
  731. self.hud_scorePopup setValue(self.xpUpdateTotal);
  732. self.hud_scorePopup.alpha = 0.85;
  733. self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  734.  
  735. increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  736.  
  737. if ( self.bonusUpdateTotal )
  738. {
  739. while ( self.bonusUpdateTotal > 0 )
  740. {
  741. self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  742. self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  743.  
  744. self.hud_scorePopup setValue( self.xpUpdateTotal );
  745.  
  746. wait ( 0.05 );
  747. }
  748. }
  749. else
  750. {
  751. wait ( 1.0 );
  752. }
  753.  
  754. self.hud_scorePopup fadeOverTime( 0.75 );
  755. self.hud_scorePopup.alpha = 0;
  756.  
  757. self.xpUpdateTotal = 0;
  758. }
  759.  
  760. removeRankHUD()
  761. {
  762. self.hud_scorePopup.alpha = 0;
  763. }
  764.  
  765. getRank()
  766. {
  767. rankXp = self.pers["rankxp"];
  768. rankId = self.pers["rank"];
  769.  
  770. if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  771. return rankId;
  772. else
  773. return self getRankForXp( rankXp );
  774. }
  775.  
  776.  
  777. levelForExperience( experience )
  778. {
  779. return getRankForXP( experience );
  780. }
  781.  
  782.  
  783. getRankForXp( xpVal )
  784. {
  785. rankId = 0;
  786. rankName = level.rankTable[rankId][1];
  787. assert( isDefined( rankName ) );
  788.  
  789. while ( isDefined( rankName ) && rankName != "" )
  790. {
  791. if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  792. return rankId;
  793.  
  794. rankId++;
  795. if ( isDefined( level.rankTable[rankId] ) )
  796. rankName = level.rankTable[rankId][1];
  797. else
  798. rankName = undefined;
  799. }
  800.  
  801. rankId--;
  802. return rankId;
  803. }
  804.  
  805.  
  806. getSPM()
  807. {
  808. rankLevel = self getRank() + 1;
  809. return (3 + (rankLevel * 0.5))*10;
  810. }
  811.  
  812. getPrestigeLevel()
  813. {
  814. return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  815. }
  816.  
  817. getRankXP()
  818. {
  819. return self.pers["rankxp"];
  820. }
  821.  
  822. incRankXP( amount )
  823. {
  824. if ( !self rankingEnabled() )
  825. return;
  826.  
  827. if ( isDefined( self.isCheater ) )
  828. return;
  829.  
  830. xp = self getRankXP();
  831. newXp = (xp + amount);
  832.  
  833. if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  834. newXp = getRankInfoMaxXP( level.maxRank );
  835.  
  836. self.pers["rankxp"] = newXp;
  837. }
  838.  
  839. getRestXPAward( baseXP )
  840. {
  841. if ( !getdvarint( "scr_restxp_enable" ) )
  842. return 0;
  843.  
  844. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  845.  
  846. wantGiveRestXP = int(baseXP * restXPAwardRate);
  847. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  848.  
  849. if ( mayGiveRestXP <= 0 )
  850. return 0;
  851.  
  852. // we don't care about giving more rest XP than we have; we just want it to always be X2
  853. //if ( wantGiveRestXP > mayGiveRestXP )
  854. // return mayGiveRestXP;
  855.  
  856. return wantGiveRestXP;
  857. }
  858.  
  859.  
  860. isLastRestXPAward( baseXP )
  861. {
  862. if ( !getdvarint( "scr_restxp_enable" ) )
  863. return false;
  864.  
  865. restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  866.  
  867. wantGiveRestXP = int(baseXP * restXPAwardRate);
  868. mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  869.  
  870. if ( mayGiveRestXP <= 0 )
  871. return false;
  872.  
  873. if ( wantGiveRestXP >= mayGiveRestXP )
  874. return true;
  875.  
  876. return false;
  877. }
  878.  
  879. syncXPStat()
  880. {
  881. xp = self getRankXP();
  882.  
  883. self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  884. }
  885.  
  886. Ok, now save it as a .gsc into this directory: \\Your iMod\maps\mp\gametypes\_rank.gsc.
  887.  
  888.  
  889. Image
  890. Ok, now we want to make it easier for us to code. Open up a new notepad. Now type something like this in:
  891. Code: Select all
  892. initMod()
  893. {
  894. self endon( "disconnect" );
  895. }
  896.  
  897. Ok, we're getting somewhere.... Now we're going to add some threads:
  898. Code: Select all
  899. initMod()
  900. {
  901. self endon( "disconnect" );
  902.  
  903. self thread myPerk();
  904. }
  905.  
  906. Save this into directory: \\maps\mp\gametypes\_iMod.gsc.
  907. Ok, now we want to make it that it will load when loading the mod. In your _rank.gsc, add to init(): "level thread maps\mp\gametypes\_iMod::initMod();". Now that we have added that in, let's try creating a custom perk, shall we.
  908.  
  909.  
  910. Image
  911. Alright, take a look at the code below, this is what your mod should look like. I'll explain the code below it:
  912. Code: Select all
  913. initMod()
  914. {
  915. self endon( "disconnect" );
  916.  
  917. self myPerk( "juggernaut" );
  918. }
  919.  
  920. myPerk( perk )
  921. {
  922. self endon( "disconnect" );
  923. perk.name = "juggernaut";
  924. for(;;)
  925. {
  926. perk = perk.name;
  927. if(perk == "juggernaut")
  928. {
  929. self thread juggernaut();
  930. }
  931. }
  932. }
  933.  
  934. juggernaut()
  935. {
  936. self endon( "disconnect" );
  937. for(;;)
  938. {
  939. self.maxhealth = 200;
  940. self.health = self.maxhealth;
  941. }
  942. }
  943.  
  944. Ok, so basically what we have done is made a custom function with myPerk( perk ). The variable "perk" is set as "perk.name" and "perk.name" is set to "juggernaut". So within the myPerk code, we created an "if" function to show if you put it into this: self myPerk( "juggernaut" ); then it would use another thread we created, called "juggernaut" and implement that on "self". Basically we created a perk that increases health by 2x. So if we want to create another perk, do something like this:
  945. Code: Select all
  946. myPerk( perk, perk2 )
  947. {
  948. self endon( "disconnect" );
  949. perk.name = "juggernaut";
  950. perk.name2 = "ownage";
  951. for(;;)
  952. {
  953. perk = perk.name;
  954. perk2 = perk.name2;
  955. if(perk == "juggernaut")
  956. {
  957. self thread juggernaut();
  958. }
  959. else if(perk2 == "ownage")
  960. {
  961. self thread ownage();
  962. }
  963. }
  964. }
  965.  
  966. Then you would create a thread called "ownage" and continue from there. Of course there is a more advanced way of doing this, yet it's more simple once you know how to do it.
  967.  
  968.  
  969. Image
  970. So, that's it for now, I'm not particularly sure if there is any syntax errors in there, someone would let me know that would be cinch :D. Anyway I hope this tutorial has taught you something, and you have a better understanding of gsc coding. I might post another tutorial later.
  971.  
  972.  
  973.  
  974. Always here to help :mrgreen:
  975. Last edited by SolareStill on Sat Jun 25, 2011 12:24 pm, edited 1 time in total.[/spoiler]
  976.  
  977. [TUT]Native Mod Support
  978.  
  979. [spoiler=]Moderator: Tech Support
  980.  
  981. 198 posts • Page 1 of 8 • 1, 2, 3, 4, 5 ... 8
  982. [TUT]Native Mod Support
  983.  
  984. Postby Deathmax » Fri Jul 23, 2010 4:09 pm
  985.  
  986. Well, since ModLoader is unusable since 37a, we have gotten native mod support working again.
  987.  
  988. Note: You need atleast Build 10723-2 for this to work, older builds will bug out.
  989.  
  990. Lets go step by step.
  991.  
  992. How to convert existing ModLoader mods into native mods
  993. First of all, you need your mod. Mods are like structured something like this, depending on which file they load :
  994. Code: Select all
  995. \---Mod
  996. \---maps
  997. \---mp
  998. \---gametypes
  999.  
  1000. 1) Just take everything from mod onwards, so you should be left with
  1001. Code: Select all
  1002. \---maps
  1003. \---mp
  1004. \---gametypes
  1005.  
  1006.  
  1007. 2) Now use a compression tool and zip the folder up, maintaining the original folder structure.
  1008.  
  1009. 3) Rename the extension to .iwd.
  1010.  
  1011. Congratulations, you have made the file that is going to be loaded into the game.
  1012.  
  1013. How to load the mod
  1014. Now to actually loading the mods.
  1015.  
  1016. 1) Make a new folder in the root of your MW2 folder called "mods"
  1017.  
  1018. 2) In the "mods" folder, make a new folder with the name of your mod, for example "MyMod"
  1019.  
  1020. 3) In your mod folder, place the .iwd file you made earlier into the folder. The .iwd can be named anything.
  1021.  
  1022. At this point you should have a folder structure like this :
  1023. Code: Select all
  1024. \---Modern Warfare 2
  1025. \---mods
  1026. \---modname
  1027.  
  1028.  
  1029. 4) Run the game
  1030.  
  1031. 5) Type in fs_game mods/MODNAMEHERE . Note that MODNAMEHERE is the name of the folder you created in "mods".
  1032.  
  1033. 6) Type in vid_restart and start a game, the mod should have loaded if everything was done correctly.
  1034.  
  1035. A few extra things
  1036.  
  1037. a) fs_game can be done anywhere, however in-game it should be preceded by map_restart instead of vid_restart, and its not advisable to change it while in a party.
  1038.  
  1039. b) No longer applicable for Build 10728-2 onwards.
  1040. Spoiler: Toggle
  1041. Your stats will reset since the game generates new stats for every different mod that is loaded. Don't worry, your normal stats have not been reset.
  1042.  
  1043.  
  1044. c) Encrypted mods will not work as this isn't ModLoader.
  1045.  
  1046. d) Here is an example of how a correct mod looks like and its folder structure, the mod I'm using here is scoutknivez : Download link. In this example, you'd use fs_game mods/scoutzknivez to load the mod.
  1047.  
  1048. e) fs_game "" will cause the game to load back to normal.
  1049.  
  1050. f) Unlike ModLoader, this is OS-independent.
  1051.  
  1052. Using something to compile mods
  1053. Batch file
  1054. Spoiler: Toggle
  1055. First you need 7za from here : Download
  1056. You also need the batch file here : Download
  1057.  
  1058. 1) Place both 7za.exe and compile_mods.bat into the same folder.
  1059.  
  1060. 2) Place your mod starting with the maps folder into the same folder as above.
  1061.  
  1062. 3) Run compile_mod.bat and type in the .iwd name(z_* will always be loaded first in the game).
  1063.  
  1064. 4) You should end up with a .iwd which can be used following "How to load the mod" above.
  1065.  
  1066. GUI app
  1067. Spoiler: Toggle
  1068. Get the app from here : Download
  1069.  
  1070. 1) Run the app
  1071.  
  1072. 2) In the first textbox select the maps\ folder.
  1073.  
  1074. 3) In the second textbox select where you want the .iwd file to go (It can be anywhere, but if you want to save the trouble of moving it, just select your mods\modname folder.
  1075.  
  1076. 4) Press compile
  1077. IGN : aIW|Deathmax
  1078. Proper English is required in PMs.
  1079. User avatar
  1080. Deathmax
  1081. Forum Moderator
  1082.  
  1083. Joined: Sat May 15, 2010 1:43 pm[/spoiler]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement