Creating a gamemode

From WiCWiki

Jump to: navigation, search

Here's a very simple tutorial for setting up your own game mode in World in Conflict. It includes juice, fruit and python file editing so fire up your texteditors! (Yes, I now it's possible to use the Juicemaker for most of this, so if you want to, feel free to do so. I like to use text editors. ;)

So, to start with locate the gamemodes.juice file in: "X:\Path to World in Conflict ModKit\juice\game\" and open gamemodes.juice with your texteditor. You'll see something like this:

INCLUDE juice/game/gamemode.fruit
GameModeList GameModes
{
       GameMode Domination
       {
               myName DOMINATION
               myKillBattleHonorFactor 1
               myGameLength 20
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 3.3
               myWarningSoundFile sound/sfx/alarm_domination.mp3
               myMaxTeamImbalanceCount 2
               myGameExtendedText "Game is extended"
               myGameExtendedTextDisplayTime 15.0
               myGameExtendedSoundFile sound/sfx/hits/basket_01_1.wav
               myGameExtendedSoundLoopCount 3
               myExtendGameTime 0.0
               myDescription "Capture Command Points by controlling all circles (Perimeter Points). If you control more than the enemy your flag will start to dominate (visible in the Domination bar at the top of the screen)."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode Assault
       {
               myName ASSAULT
               myKillBattleHonorFactor 1
               myGameLength 10
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile sound/sfx/alarm_domination.mp3
               myMaxTeamImbalanceCount 2
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "In the Assault mode there is one defending team and one attacking. Both teams get to defend and attack during one half of the match each. You only fight over one Command Point at a time."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode TugOfWar
       {
               myName "TUG OF WAR"
               myKillBattleHonorFactor 0.0
               myGameLength 20
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 2
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "In Tug of War one extended Command Point acts as a frontline. Your team needs to control all Perimeter Points (circles) to push the frontline forward."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode TeamDeathmatch
       {
               myName "TEAM DEATHMATCH"
               myKillBattleHonorFactor 1.0
               myGameLength 10
               myMaxDeploymentZoneSize 40
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 1
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "Kill. Other. Team."
               myPythonClass <empty>
               myPythonModule <empty>
       }
}

Here is where you create the game mod and defining some basic stuff like it's name, how low games are going to be etc. This is where we make a new entry for our mod, called TA_Party and it looks like this.

       GameMode TA_Party
       {
               myName "TA PARTY"
               myKillBattleHonorFactor 1.0
               myGameLength 10
               myMaxDeploymentZoneSize 40
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 1
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "Kill. Other. Team."
               myPythonClass TA_Party
               myPythonModule ta_party
       }

The two last lines are important. They tell WiC what your Python mod class is and in which module the class is in. In our case, the module equals a normal .py-file in "X:\Path to World in Conflict ModKit\python\". Add this piece of code after where the TeamDeathmatch code ends and before the last } so it looks something like this.


INCLUDE juice/game/gamemode.fruit
GameModeList GameModes
{
       GameMode Domination
       {
               myName DOMINATION
               myKillBattleHonorFactor 1
               myGameLength 20
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 3.3
               myWarningSoundFile sound/sfx/alarm_domination.mp3
               myMaxTeamImbalanceCount 2
               myGameExtendedText "Game is extended"
               myGameExtendedTextDisplayTime 15.0
               myGameExtendedSoundFile sound/sfx/hits/basket_01_1.wav
               myGameExtendedSoundLoopCount 3
               myExtendGameTime 0.0
               myDescription "Capture Command Points by controlling all circles (Perimeter Points). If you control more than the enemy your flag will start to dominate (visible in the Domination bar at the top of the screen)."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode Assault
       {
               myName ASSAULT
               myKillBattleHonorFactor 1
               myGameLength 10
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile sound/sfx/alarm_domination.mp3
               myMaxTeamImbalanceCount 2
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "In the Assault mode there is one defending team and one attacking. Both teams get to defend and attack during one half of the match each. You only fight over one Command Point at a time."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode TugOfWar
       {
               myName "TUG OF WAR"
               myKillBattleHonorFactor 0.0
               myGameLength 20
               myMaxDeploymentZoneSize 30
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 2
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "In Tug of War one extended Command Point acts as a frontline. Your team needs to control all Perimeter Points (circles) to push the frontline forward."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode TeamDeathmatch
       {
               myName "TEAM DEATHMATCH"
               myKillBattleHonorFactor 1.0
               myGameLength 10
               myMaxDeploymentZoneSize 40
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 1
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "Kill. Other. Team."
               myPythonClass <empty>
               myPythonModule <empty>
       }
       GameMode TA_Party
       {
               myName "TA PARTY"
               myKillBattleHonorFactor 1.0
               myGameLength 10
               myMaxDeploymentZoneSize 40
               myKotHGameStartDelay 0.0
               myDomTotalDominationFactor 0
               myWarningSoundFile <empty>
               myMaxTeamImbalanceCount 1
               myGameExtendedText <empty>
               myGameExtendedTextDisplayTime 0.0
               myGameExtendedSoundFile <empty>
               myGameExtendedSoundLoopCount 0
               myExtendGameTime 0.0
               myDescription "Nuke em all!"
               myPythonClass TA_Party
               myPythonModule ta_party
       }
}

Done? Okey. Let's move on then. The next step is to convert the juice-file with Juicemaker into a ice-file. Open Juicemaker in the Modkit directory go to "File -> Open" in the menu bar and browse to "juice/game/gamemodes.juice" and click open. Hopefully now errors will show up and we can go to "File -> Save" to convert it to gamemodes.ice. So the next thing we need to do now is adding our mod to the available game modes. To do this we go to "X:\Path to WiC Modkit\editordata\wiced\fruit\" and open wicedmissionstats.juice with our text editor. Search for "Gamemode" inside the file and you will find:

TYPE GameMode
{
   Domination
   Assault
   TugOfWar
   TeamDeathmatch
}

Here we need to add our game mode we made before in the gamemodes.juice, and after doing that it will look something like this:

TYPE GameMode
{
   Domination
   Assault
   TugOfWar
   TeamDeathmatch
   TA_Party
}

We do not need to convert this file to something, this will be included when we convert the map's juice-file. So, moving on. The next step is to make a python script in the "X:\Path to WiC Modkit\python\" directory. I assume you know how to make a new python file, but you have to give it the same name as you gave the myPythonModule before, so in our case it's ta_party.py and it looks like this:

import wic
import player
import wicg
class TA_Party(wic.game.GameModeBase):
   def __init__(self):
       pass
   def Init(self):
       return True    
   def StartGameTime(self):
       self.GameEndTime = self.MaxGameLength + wic.common.GetCurrentTime()
       self.GameStatus = wic.game.GAMESTATUS_NO_WIN    
       return True
   def Update(self):
       self.DisplayTime = self.GameEndTime - wic.common.GetCurrentTime()
       if self.DisplayTime < 0:
           self.GameStatus = wic.game.GAMESTATUS_TEAM_WIN
           self.GameOver(0)
       self.Doom()
       return self.GameStatus
   def Doom(self):
       for i in range(16):
           try:
               player.thePlayers[ i ].myMaxTacticalAid = 500
               player.thePlayers[ i ].myTacticalAid = 500
           except Exception:
               pass
       return 1    
   def GetCurrentWinner(self):
       return 0
   def WasFlawlessVictory(self):
       return False
   def InitDeploymentZones(self):
       #wic.game.AddDeploymentZone( 'startLZ' )
       #wic.game.AddDeploymentZoneToTeam( 'startLZ', 1 )
       #wic.game.AddDeploymentZoneToTeam( 'startLZ', 2 )
       return True
   def OnPlayerJoinsTeam(self, aPlayerId, aTeamId):
       return True
   def OnPlayerChangedTeam(self, aPlayerId, aTeamId):
       return True        
   def OnSetCommandPointOwner(self, aPlayerId, aTeamId):
       return True
#(If this doesn't work, the tabs might be screwed)

This is the same python file that Mir provided in one of her posts on the forums, but with some minor changes. Every timet the game ticks it sets all players' TA points to 500, which equals infinite TA. A very important thing in this file is that you name your class the same as you did named myPythonClass. Now what? We have our gamemodes.ice, edited the missionstats.fruit and made a python script with our stuff in it. So now it's time to edit the map's juice-file. I'm assuming you have a compiled map (not sure if it's needed, maybe someone else has info on this?) so go to "X:\Path to WiC Modkit\maps\<yourmap>\" and open the <yourmap>.juice with Juicemaker. Scroll down until you see the "myMissionStats" and click the to the left of the text. You'll see a "myGameMode" value, so right click that and choose your own game mode and click OK. Now go and click save to convert it to an ice-file and if now errors show up you should be able to open wic.exe, select your map (which shows your new game mode!) and play it. I hope you learned something out of this, which I'm writing at 04 AM, and good luck with your new game modes! Now go and nuke something.

// Krakel, with a little help from truppo

Personal tools
User Created Content