Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [TUTORIAL] Creating a Gametype
- [spoiler=]Moderator: Tech Support
- 39 posts • Page 1 of 2 • 1, 2
- [TUTORIAL] Creating a Gametype
- Postby Vekiorus » Fri Oct 22, 2010 2:51 am
- Hey
- WHATS UP
- //fluffee off
- As i did some research into making a mod-gametype, i found a quite interesting way to make your own.
- This is addressed to server admins, whole for example wants to rotate one in the chamber, gungame from zxz and, lets say, my mod.
- Using the maprotation command of course.
- As you know, we can change gametypes AND maps witht the map rotation command.
- So here is how to make your own gametype.
- 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 ;)
- Creating the base
- First step, navigate to your mw2 "main" directory.
- Backup the file "iw_25.iwd"
- Now open the original copy. If you have the alterIwnet one, your iwd should look like this:
- maps/mp/gametypes. In the gametype folder:
- Spoiler: Toggle
- Image
- Now, open the _gametypes.txt file. It should look like:
- Spoiler: Toggle
- Code: Select all
- dm
- dom
- sd
- sab
- war
- koth
- oneflag
- arena
- dd
- vip
- ctf
- gtnw
- oitc
- For the purpose of this tutorial, my gametype is going to be called "vek1"
- So add "vek1" under "oitc":
- Spoiler: Toggle
- Code: Select all
- dm
- dom
- sd
- sab
- war
- koth
- oneflag
- arena
- dd
- vip
- ctf
- gtnw
- oitc
- vek1
- My gametype is going to be based on Free For All.
- So, i am going to find the "dm.gsc" file. You can get it from a gsc rip, google it.
- 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.
- Last step of this part :
- You need to create a "vek1.txt" file. In it, i'm going to put this content:
- Code: Select all
- "Veki's Arena"
- YES, with the quotes. It's important.
- Your IWD now looks like:
- Spoiler: Toggle
- Image
- Dont mind the whited out part.
- Converting the mod
- Okay.
- This might be the easiest part.
- 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.
- Put it into your "gametypes" folder in your iwd25.
- Thats all for this part!
- Calling the mod into the gametype
- Okay, last part.
- You are now going to open your "vek1.gsc" file. (the GAMETYPE one, without the underscore.)
- Find this:
- Spoiler: Toggle
- Code: Select all
- main()
- {
- maps\mp\gametypes\_globallogic::init();
- maps\mp\gametypes\_callbacksetup::SetupCallbacks();
- maps\mp\gametypes\_globallogic::SetupCallbacks();
- registerTimeLimitDvar( level.gameType, 10, 0, 1440 );
- registerScoreLimitDvar( level.gameType, 1000, 0, 5000 );
- registerWinLimitDvar( level.gameType, 1, 0, 5000 );
- registerRoundLimitDvar( level.gameType, 1, 0, 10 );
- registerNumLivesDvar( level.gameType, 0, 0, 10 );
- registerHalfTimeDvar( level.gameType, 0, 0, 1 );
- level.onStartGameType = ::onStartGameType;
- level.getSpawnPoint = ::getSpawnPoint;
- game["dialog"]["gametype"] = "freeforall";
- if ( getDvarInt( "g_hardcore" ) )
- game["dialog"]["gametype"] = "hc_" + game["dialog"]["gametype"];
- else if ( getDvarInt( "camera_thirdPerson" ) )
- game["dialog"]["gametype"] = "thirdp_" + game["dialog"]["gametype"];
- else if ( getDvarInt( "scr_diehard" ) )
- game["dialog"]["gametype"] = "dh_" + game["dialog"]["gametype"];
- else if (getDvarInt( "scr_" + level.gameType + "_promode" ) )
- game["dialog"]["gametype"] = game["dialog"]["gametype"] + "_pro";
- }
- Under the maps\mp\gametypes\_globallogic::init();, you want to add:
- Code: Select all
- maps\mp\gametypes\_vek1::init();
- This calls the INIT function of your mod. If your mod doesent have one, then i wonder what the fuck game are you modding.
- Now save the file.
- You are done.
- Good job Delta Squad.
- By the way, your rar should look like :
- Spoiler: Toggle
- Image
- Ah, and to call your gametype, type in console
- Code: Select all
- g_gametype vek1
- It will then say:
- Code: Select all
- g_gametype will be changed upon restarting.
- Just start the map or do map_restart if you are in game.
- Proof the method works
- Screenshots:
- Spoiler: Toggle
- Image
- Spoiler: Toggle
- Image
- Good luck, and have fun!
- Note: However, because changing to dm gametype is bugged, you will need a couple extra commands to make it look like a real ffa.
- I let you find out,
- And please dont steal this tutorial/claim it as yours.
- Thanks
- Edit: If anyone wants my iw_25 PM me.
- Downloads
- Roll the Dice 4 Gametype
- -> g_gametype rtdwar Team Deathmatch RTD
- -> g_gametype rtdffa FFA RTD
- Last edited by Vekiorus on Sat Nov 06, 2010 11:49 pm, edited 1 time in total.
- Image
- Image
- User avatar
- Vekiorus
- Joined: Mon May 17, 2010 2:29 am
- Top[/spoiler]
- [Tutorial] Making an intermediate mod.
- [spoiler=]Moderator: Tech Support
- 26 posts • Page 1 of 2 • 1, 2
- [Tutorial] Making an intermediate mod.
- Postby SolareStill » Sat Jun 25, 2011 9:41 am
- Making an Intermediate Mod.
- __________________________________________________________________________________________________
- Image
- 1. Introduction
- 2. Getting your _rank.gsc
- 3. Creating / Loading a custom gsc
- 4. Coding
- 5. Conclusion
- Image
- 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
- Image
- 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.
- Code: Select all
- #include common_scripts\utility;
- #include maps\mp\_utility;
- #include maps\mp\gametypes\_hud_util;
- doDvars()
- {
- }
- init()
- {
- level.scoreInfo = [];
- level.xpScale = getDvarInt( "scr_xpscale" );
- level.rankTable = [];
- precacheShader("white");
- precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
- precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
- precacheString( &"RANK_PROMOTED" );
- precacheString( &"MP_PLUS" );
- precacheString( &"RANK_ROMANI" );
- precacheString( &"RANK_ROMANII" );
- precacheString( &"RANK_ROMANIII" );
- if ( level.teamBased )
- {
- registerScoreInfo( "kill", 100 );
- registerScoreInfo( "headshot", 200 );
- registerScoreInfo( "assist", 50 );
- registerScoreInfo( "suicide", 100 );
- registerScoreInfo( "teamkill", 0 );
- }
- else
- {
- registerScoreInfo( "kill", 100 );
- registerScoreInfo( "headshot", 200 );
- registerScoreInfo( "assist", 50 );
- registerScoreInfo( "suicide", 100 );
- registerScoreInfo( "teamkill", 0 );
- }
- 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++ )
- {
- 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 );
- precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
- rankId++;
- rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
- }
- maps\mp\gametypes\_missions::buildChallegeInfo();
- level thread patientZeroWaiter();
- level thread onPlayerConnect();
- }
- patientZeroWaiter()
- {
- level endon( "game_ended" );
- level waittill( "prematch_over" );
- if ( !matchMakingGame() )
- {
- if ( getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999 )
- level.patientZeroName = level.players[0].name;
- }
- else
- {
- if ( getDvar( "scr_patientZero" ) != "" )
- level.patientZeroName = getDvar( "scr_patientZero" );
- }
- }
- 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 ) );
- }
- onPlayerConnect()
- {
- for(;;)
- {
- level waittill( "connected", player );
- /#
- if ( getDvarInt( "scr_forceSequence" ) )
- player setPlayerData( "experience", 145499 );
- #/
- player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
- if ( player.pers["rankxp"] < 0 ) // paranoid defensive
- player.pers["rankxp"] = 0;
- rankId = player getRankForXp( player getRankXP() );
- player.pers[ "rank" ] = rankId;
- player.pers[ "participation" ] = 0;
- player.xpUpdateTotal = 0;
- player.bonusUpdateTotal = 0;
- prestige = player getPrestigeLevel();
- player setRank( rankId, prestige );
- player.pers["prestige"] = prestige;
- player.postGamePromotion = false;
- if ( !isDefined( player.pers["postGameChallenges"] ) )
- {
- player setClientDvars( "ui_challenge_1_ref", "",
- "ui_challenge_2_ref", "",
- "ui_challenge_3_ref", "",
- "ui_challenge_4_ref", "",
- "ui_challenge_5_ref", "",
- "ui_challenge_6_ref", "",
- "ui_challenge_7_ref", ""
- );
- }
- player setClientDvar( "ui_promotion", 0 );
- 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;
- // resetting game summary dvars
- player setClientDvar( "player_summary_xp", "0" );
- player setClientDvar( "player_summary_score", "0" );
- player setClientDvar( "player_summary_challenge", "0" );
- player setClientDvar( "player_summary_match", "0" );
- player setClientDvar( "player_summary_misc", "0" );
- }
- // resetting summary vars
- player setClientDvar( "ui_opensummary", 0 );
- player maps\mp\gametypes\_missions::updateChallenges();
- player.explosiveKills[0] = 0;
- player.xpGains = [];
- player.hud_scorePopup = newClientHudElem( player );
- player.hud_scorePopup.horzAlign = "center";
- player.hud_scorePopup.vertAlign = "middle";
- player.hud_scorePopup.alignX = "center";
- player.hud_scorePopup.alignY = "middle";
- player.hud_scorePopup.x = 0;
- if ( level.splitScreen )
- player.hud_scorePopup.y = -40;
- else
- player.hud_scorePopup.y = -60;
- player.hud_scorePopup.font = "hudbig";
- player.hud_scorePopup.fontscale = 0.75;
- player.hud_scorePopup.archived = false;
- player.hud_scorePopup.color = (0.5,0.5,0.5);
- player.hud_scorePopup.sort = 10000;
- player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
- 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 doDvars();
- }
- }
- roundUp( floatVal )
- {
- if ( int( floatVal ) != floatVal )
- return int( floatVal+1 );
- else
- return int( floatVal );
- }
- giveRankXP( type, value )
- {
- self endon("disconnect");
- lootType = "none";
- if ( !self rankingEnabled() )
- return;
- if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
- return;
- else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
- return;
- if ( !isDefined( value ) )
- value = getScoreInfoValue( type );
- if ( !isDefined( self.xpGains[type] ) )
- self.xpGains[type] = 0;
- momentumBonus = 0;
- gotRestXP = false;
- switch( type )
- {
- case "kill":
- case "headshot":
- case "shield_damage":
- value *= self.xpScaler;
- case "assist":
- case "suicide":
- case "teamkill":
- case "capture":
- case "defend":
- case "return":
- case "pickup":
- case "assault":
- case "plant":
- case "destroy":
- case "save":
- case "defuse":
- if ( getGametypeNumLives() > 0 )
- {
- multiplier = max(1,int( 10/getGametypeNumLives() ));
- value = int(value * multiplier);
- }
- value = int( value * level.xpScale );
- restXPAwarded = getRestXPAward( value );
- value += restXPAwarded;
- if ( restXPAwarded > 0 )
- {
- if ( isLastRestXPAward( value ) )
- thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
- gotRestXP = true;
- }
- break;
- }
- if ( !gotRestXP )
- {
- // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
- if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
- self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
- }
- oldxp = self getRankXP();
- self.xpGains[type] += value;
- self incRankXP( value );
- if ( self rankingEnabled() && updateRank( oldxp ) )
- 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.
- self syncXPStat();
- if ( !level.hardcoreMode )
- {
- if ( type == "teamkill" )
- {
- self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
- }
- else
- {
- color = (1,1,0.5);
- if ( gotRestXP )
- color = (1,.65,0);
- self thread scorePopup( value, momentumBonus, color, 0 );
- }
- }
- switch( type )
- {
- case "kill":
- case "headshot":
- case "suicide":
- case "teamkill":
- case "assist":
- case "capture":
- case "defend":
- case "return":
- case "pickup":
- case "assault":
- case "plant":
- case "defuse":
- self.pers["summary"]["score"] += value;
- self.pers["summary"]["xp"] += value;
- break;
- case "win":
- case "loss":
- case "tie":
- self.pers["summary"]["match"] += value;
- self.pers["summary"]["xp"] += value;
- break;
- case "challenge":
- self.pers["summary"]["challenge"] += value;
- self.pers["summary"]["xp"] += value;
- break;
- default:
- self.pers["summary"]["misc"] += value; //keeps track of ungrouped match xp reward
- self.pers["summary"]["match"] += value;
- self.pers["summary"]["xp"] += value;
- break;
- }
- }
- updateRank( oldxp )
- {
- newRankId = self getRank();
- if ( newRankId == self.pers["rank"] )
- return false;
- oldRank = self.pers["rank"];
- rankId = self.pers["rank"];
- self.pers["rank"] = newRankId;
- //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );
- println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
- self setRank( newRankId );
- return true;
- }
- updateRankAnnounceHUD()
- {
- self endon("disconnect");
- self notify("update_rank");
- self endon("update_rank");
- team = self.pers["team"];
- if ( !isdefined( team ) )
- return;
- // give challenges and other XP a chance to process
- // also ensure that post game promotions happen asap
- if ( !levelFlag( "game_over" ) )
- level waittill_notify_or_timeout( "game_over", 0.25 );
- newRankName = self getRankInfoFull( self.pers["rank"] );
- rank_char = level.rankTable[self.pers["rank"]][1];
- subRank = int(rank_char[rank_char.size-1]);
- thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
- if ( subRank > 1 )
- return;
- for ( i = 0; i < level.players.size; i++ )
- {
- player = level.players[i];
- playerteam = player.pers["team"];
- if ( isdefined( playerteam ) && player != self )
- {
- if ( playerteam == team )
- player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
- }
- }
- }
- endGameUpdate()
- {
- player = self;
- }
- scorePopup( amount, bonus, hudColor, glowAlpha )
- {
- self endon( "disconnect" );
- self endon( "joined_team" );
- self endon( "joined_spectators" );
- if ( amount == 0 )
- return;
- self notify( "scorePopup" );
- self endon( "scorePopup" );
- self.xpUpdateTotal += amount;
- self.bonusUpdateTotal += bonus;
- wait ( 0.05 );
- if ( self.xpUpdateTotal < 0 )
- self.hud_scorePopup.label = &"";
- else
- self.hud_scorePopup.label = &"MP_PLUS";
- self.hud_scorePopup.color = hudColor;
- self.hud_scorePopup.glowColor = hudColor;
- self.hud_scorePopup.glowAlpha = glowAlpha;
- self.hud_scorePopup setValue(self.xpUpdateTotal);
- self.hud_scorePopup.alpha = 0.85;
- self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
- increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
- if ( self.bonusUpdateTotal )
- {
- while ( self.bonusUpdateTotal > 0 )
- {
- self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
- self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
- self.hud_scorePopup setValue( self.xpUpdateTotal );
- wait ( 0.05 );
- }
- }
- else
- {
- wait ( 1.0 );
- }
- self.hud_scorePopup fadeOverTime( 0.75 );
- self.hud_scorePopup.alpha = 0;
- self.xpUpdateTotal = 0;
- }
- removeRankHUD()
- {
- self.hud_scorePopup.alpha = 0;
- }
- getRank()
- {
- rankXp = self.pers["rankxp"];
- rankId = self.pers["rank"];
- if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
- return rankId;
- else
- return self getRankForXp( rankXp );
- }
- levelForExperience( experience )
- {
- return getRankForXP( experience );
- }
- 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( "prestige" );
- }
- getRankXP()
- {
- return self.pers["rankxp"];
- }
- incRankXP( amount )
- {
- if ( !self rankingEnabled() )
- return;
- if ( isDefined( self.isCheater ) )
- return;
- xp = self getRankXP();
- newXp = (xp + amount);
- if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
- newXp = getRankInfoMaxXP( level.maxRank );
- self.pers["rankxp"] = newXp;
- }
- getRestXPAward( baseXP )
- {
- if ( !getdvarint( "scr_restxp_enable" ) )
- return 0;
- restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
- wantGiveRestXP = int(baseXP * restXPAwardRate);
- mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
- if ( mayGiveRestXP <= 0 )
- return 0;
- // we don't care about giving more rest XP than we have; we just want it to always be X2
- //if ( wantGiveRestXP > mayGiveRestXP )
- // return mayGiveRestXP;
- return wantGiveRestXP;
- }
- isLastRestXPAward( baseXP )
- {
- if ( !getdvarint( "scr_restxp_enable" ) )
- return false;
- restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
- wantGiveRestXP = int(baseXP * restXPAwardRate);
- mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
- if ( mayGiveRestXP <= 0 )
- return false;
- if ( wantGiveRestXP >= mayGiveRestXP )
- return true;
- return false;
- }
- syncXPStat()
- {
- xp = self getRankXP();
- self maps\mp\gametypes\_persistence::statSet( "experience", xp );
- }
- Ok, now save it as a .gsc into this directory: \\Your iMod\maps\mp\gametypes\_rank.gsc.
- Image
- Ok, now we want to make it easier for us to code. Open up a new notepad. Now type something like this in:
- Code: Select all
- initMod()
- {
- self endon( "disconnect" );
- }
- Ok, we're getting somewhere.... Now we're going to add some threads:
- Code: Select all
- initMod()
- {
- self endon( "disconnect" );
- self thread myPerk();
- }
- Save this into directory: \\maps\mp\gametypes\_iMod.gsc.
- 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.
- Image
- Alright, take a look at the code below, this is what your mod should look like. I'll explain the code below it:
- Code: Select all
- initMod()
- {
- self endon( "disconnect" );
- self myPerk( "juggernaut" );
- }
- myPerk( perk )
- {
- self endon( "disconnect" );
- perk.name = "juggernaut";
- for(;;)
- {
- perk = perk.name;
- if(perk == "juggernaut")
- {
- self thread juggernaut();
- }
- }
- }
- juggernaut()
- {
- self endon( "disconnect" );
- for(;;)
- {
- self.maxhealth = 200;
- self.health = self.maxhealth;
- }
- }
- 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:
- Code: Select all
- myPerk( perk, perk2 )
- {
- self endon( "disconnect" );
- perk.name = "juggernaut";
- perk.name2 = "ownage";
- for(;;)
- {
- perk = perk.name;
- perk2 = perk.name2;
- if(perk == "juggernaut")
- {
- self thread juggernaut();
- }
- else if(perk2 == "ownage")
- {
- self thread ownage();
- }
- }
- }
- 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.
- Image
- 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.
- Always here to help :mrgreen:
- Last edited by SolareStill on Sat Jun 25, 2011 12:24 pm, edited 1 time in total.[/spoiler]
- [TUT]Native Mod Support
- [spoiler=]Moderator: Tech Support
- 198 posts • Page 1 of 8 • 1, 2, 3, 4, 5 ... 8
- [TUT]Native Mod Support
- Postby Deathmax » Fri Jul 23, 2010 4:09 pm
- Well, since ModLoader is unusable since 37a, we have gotten native mod support working again.
- Note: You need atleast Build 10723-2 for this to work, older builds will bug out.
- Lets go step by step.
- How to convert existing ModLoader mods into native mods
- First of all, you need your mod. Mods are like structured something like this, depending on which file they load :
- Code: Select all
- \---Mod
- \---maps
- \---mp
- \---gametypes
- 1) Just take everything from mod onwards, so you should be left with
- Code: Select all
- \---maps
- \---mp
- \---gametypes
- 2) Now use a compression tool and zip the folder up, maintaining the original folder structure.
- 3) Rename the extension to .iwd.
- Congratulations, you have made the file that is going to be loaded into the game.
- How to load the mod
- Now to actually loading the mods.
- 1) Make a new folder in the root of your MW2 folder called "mods"
- 2) In the "mods" folder, make a new folder with the name of your mod, for example "MyMod"
- 3) In your mod folder, place the .iwd file you made earlier into the folder. The .iwd can be named anything.
- At this point you should have a folder structure like this :
- Code: Select all
- \---Modern Warfare 2
- \---mods
- \---modname
- 4) Run the game
- 5) Type in fs_game mods/MODNAMEHERE . Note that MODNAMEHERE is the name of the folder you created in "mods".
- 6) Type in vid_restart and start a game, the mod should have loaded if everything was done correctly.
- A few extra things
- 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.
- b) No longer applicable for Build 10728-2 onwards.
- Spoiler: Toggle
- 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.
- c) Encrypted mods will not work as this isn't ModLoader.
- 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.
- e) fs_game "" will cause the game to load back to normal.
- f) Unlike ModLoader, this is OS-independent.
- Using something to compile mods
- Batch file
- Spoiler: Toggle
- First you need 7za from here : Download
- You also need the batch file here : Download
- 1) Place both 7za.exe and compile_mods.bat into the same folder.
- 2) Place your mod starting with the maps folder into the same folder as above.
- 3) Run compile_mod.bat and type in the .iwd name(z_* will always be loaded first in the game).
- 4) You should end up with a .iwd which can be used following "How to load the mod" above.
- GUI app
- Spoiler: Toggle
- Get the app from here : Download
- 1) Run the app
- 2) In the first textbox select the maps\ folder.
- 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.
- 4) Press compile
- IGN : aIW|Deathmax
- Proper English is required in PMs.
- User avatar
- Deathmax
- Forum Moderator
- Joined: Sat May 15, 2010 1:43 pm[/spoiler]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement