Handling mods

From Running With Rifles Wiki
Jump to: navigation, search

How to obtain a mod from Workshop?[edit | edit source]

  • Go to http://steamcommunity.com/app/270150/workshop/ or access RWR's Workshop in Steam client
  • Browse the shop for mods you wish to try
  • Access a mod page and click on Subscribe - Steam will begin downloading the mod content
  • Once downloaded, the mod shows up in the game in either Start new Campaign menu or Start Quickmatch menu in Setup mods -- depends on the mod
    • Generally mods are encouraged to be made as campaigns, look there first unless described otherwise
  • Alternatively, if you attempt to join an online game using Workshop content, the game offers you to subscribe to the mod
    • Accepting subscription, Steam begins the download and once done, the game will let you attempt joining the server again

How to upload a mod to Workshop?[edit | edit source]

How to create a mod?[edit | edit source]

  • General mod types
    • Campaign mod - appears in Start new Campaign menu (preferred)
    • Quickmatch - appears in Quickmatch mod list
      • usually used for testing content in various maps, or testing custom maps
    • simply content for other mods
      • models, sounds, weapons, vehicles, items, factions, maps, etc
      • in most cases can't be played directly, needs a Campaign or Quickmatch mod to utilize the content
        • only exception is maps; if the map allows it, the map will show up among the maps in Start Quickmatch menu
  • Create a local folder for your mod
    • Locate where RWR is stored on your system
      • On Windows, most of the time it's at C:\Program Files\Steam\SteamApps\common\RunningWithRifles
      • Linux: TODO
      • Mac OSX: TODO
    • Create a new folder in the RWR folder, in subfolder media/packages, e.g. media/packages/my_mod
    • It's a good idea to avoid spaces and try to keep at lower case letters in folder names, but not required
  • Create a new text file package_config.xml in the folder with such content as

<package name="my mod" description="my very own mod" />

    • If it's a Campaign mod, you'll be using a script to define what happens when the Campaign is started - usually starting from a map change, starting the match, handling what happens when the match ends
      • You'd add show_in_campaigns="1" and campaign_entry_script="start_campaign.as" in <package> in package_config.xml, so that it says

<package name="my mod" description="my very own mod" show_in_campaigns="1" campaign_entry_script="start_my_mod.as"/>

      • You can control which UI controls are shown in Start Campaign menu for your Campaign with by adding attributes like faction, presets, friendly_capacity, enemy_capacity, friendly_accuracy, enemy_accuracy, xp_multiplier, rp_multiplier, with value of 0 (disable) or 1 (enable) in the package element; by default all are enabled
    • If it's a Quickmatch mod, the mod is loaded as additional content after the map resources chosen in the Quickmatch menu
      • You'd add show_in_quick_match_mods="1" in the package element to make the mod available there
    • If it's just a content package meant to be used by other packages, you're done - in fact you wouldn't need the package_config.xml file at all
  • Some templates exist targeted for Campaign mods, find them in media/packages
    • simple_template: simple 1-map Campaign with looping and script side save/load enablers, see media/packages/simple_template/readme.txt for details
    • full_campaign_template: Vanilla Campaign with enablers for replacing factions, item deliveries and unlock items
  • Let's extend it into a simple Campaign mod!
    • Copy all files from media/packages/simple_template/scripts to your own mod e.g. media/packages/my_mod/scripts
    • Edit the files, start_campaign.as and my_gamemode.as and work out the marked TODO points
    • Start RWR, choose Start new Campaign, your mod should show up in the list of available campaigns, select it and continue
    • Start the Campaign - the sliders won't have an effect yet as your script is not prepared to handle the settings
    • If the map loads, congrats, you've just made a new Campaign mod
    • If nothing happens, there's a problem in the script
      • Navigate to %appdata%\Running with rifles (~/.running_with_rifles/ on Linux), and open rwr_game.log
        • On Windows, you might eventually want to use something like Notepad++ to work with the files, but the good old Notepad will work too
      • Scroll to the end of the log to see what's the problem
      • Most of the time it's about syntax errors in the script, read the error descriptions, fix them and retry
        • It's a good idea to run RWR in a window (Configure in Steam to change fullscreen to No) when working with mods
        • With Notepad++ you can keep rwr_game.log open and reload it when it changes (use the File menu)
        • You can then switch between windows quickly and try starting your Campaign in RWR, look at errors in rwr_game.log in Notepad++ and fix the scripts
    • What's next?
      • a) Create new content into the mod; TODO: Content mod link
      • b) Use scripts to create new logic into your mod; TODO: Script work link
      • c) Extend the Campaign into a multimap scenario - look into full_campaign_template to use Vanilla Campaign as a basis or come up with a custom solution of your own
      • d) look at other mods to learn how they did it
      • e) look at what Vanilla did (media/packages/vanilla/scripts)
    • Eventually you'll want to publish the mod, see SteamWUT; TODO link
    • Watch out for weird stuff if you subscribe to your own mod and have it located under RWR's media/packages with the same name.

How to create mod content?[edit | edit source]

  • General things about packages and overlay resource system
    • Files are added in an in-game resource system
    • Most resources are referred to by filename only, no path, also in all XML and Angelscript files
    • In case there are several similarly named files in the system, only the one loaded last is used
    • This makes it possible for a content mod to replace how an AK47 looks in otherwise a vanilla game
    • e.g. resource meshes, textures, sounds, specifications can be changed this way without having to locally change vanilla files
  • How to create voxel items? TODO: link
  • How to create weapons?
  • How to get various faction resources (like weapons) into the game?
    • Faction files, e.g. media/packages/vanilla/factions/green.xml control which items are available for the faction
    • In Vanilla, such faction resources are listed for each soldier group in *.resources files
    • To add your new weapon mod for a faction, for example
      • 1) Ensure the weapon is loaded by the game in the first place, you generally need to have it in all_weapons.xml (or invasion_all_weapons.xml if you're overlaying Vanilla Campaign)
      • 2) Duplicate green_default.resources file into your mod to overlay the Vanilla version of the file
      • 3) Edit the file and add your weapon key (usually you'd define the key in the weapon file to be same as the filename, but it's up to you) in the list similar to others
      • 4) Ensure your weapon specification doesn't have in_stock="0" which makes the weapon unavailable in an armory
      • 5) Done! Playing as Greenbelts with the mod enabled, the basic type soldiers would now have a chance to spawn carrying your weapon, and players can find it in the armory
  • How to create factions?
    • See media/packages/vanilla/factions, green.xml, grey.xml or brown.xml
    • These files refer to the additional faction specific files *.models, *.resources, *.character, *.ai for convenience
    • Adding another faction can be basically done by duplicating one of these in your mod with another name
    • To get that faction playable in a Campaign, you'd likely want to pick full_campaign_template as a basis for your mod's scripts
      • In my_stage_configurator.as you'd refer to your custom faction as one of the three available factions
      • You could also extend the Vanilla Campaign to deal with 4+ factions scenario, by e.g. introducing your own version of media/packages/vanilla/scripts/gamemodes/invasion/stage_configurator_invasion.as, with 1-4 factions defined for each stage
    • Note that all_factions.xml is used by the Start new Campaign menu for the list of available factions; only the name field is used

How to run a mod on a dedicated server?[edit | edit source]

  • Use SteamCMD to download RWR on the server, see http://runningwithrifles.com/phpBB3/viewtopic.php?f=9&t=1843
  • Use SteamCMD to download the mod
    • TODO: instructions
    • Figure out the Workshop item ID from the URL: TODO instructions
  • Copy the mod SteamCMD downloaded to a location where the RWR server knows to look for it, media/packages/
  • Create steam_workshop_items.txt in RWR server root folder and list the required Workshop item ID(s) there, one per line; clients use this info to ensure they have the correct resources
  • Duplicate the mod's gamemode script and edit server settings in it
    • It's possible the mod's author has created a server specific starter script, located in media/packages/the_mod_folder/scripts/start_mod_server.as, filename may vary
    • If there's no such example script, you may have to create it yourself from mod's campaign start script
      • It totally depends on the mod, but if it's based on Vanilla campaign or templates, chances are you'll need to add something like this in the script
        settings.m_startServerCommand = """
<command class='start_server'
        server_name='MyModServer'
        server_port='1240'
        comment='Yes yes very nice mod server come see'
        url=''
        register_in_serverlist='1'
        mode='COOP'
        persistency='forever'
        max_players='24'>
        <client_faction id='0' />
</command>
""";

What to do with scripts?[edit | edit source]

  • http://runningwithrifles.gamepedia.com/Remote_control_/_Metagame_interface
  • XML commands described behind above link can be executed
    • From a script by sending a command to the game
    • With init_match.xml, usually in a map folder, to run a bunch of commands at the start of a match
    • When a radio call is made, if the call supplies <command>s inside its <round>s
    • As a <result class="xml_command"><command ... /></result> in events in grenade or vehicle specifications
    • As a local player by typing /_execute file.xml with file.xml in RWR root folder, the file consisting of a <command /> or <commands><command>...</commands>
    • From server console by typing execute file.xml, like above
  • Angelscript reference docs http://www.angelcode.com/angelscript/sd ... cript.html
  • Look at what vanilla does media/packages/vanilla/scripts/
  • If there's a problem with a script, %appdata%\Running with rifles\rwr_game.log will tell you about it