Rust Mods So Far

4 minute read Published:

Rust modding -- RustEdit, SteamCMD, Visual Studio 19...

I’ve been playing around the past couple of weeks with modding Rust maps and behaviour. With the little amount so far I’ve spent modding, I thought I’d write down my experiences with the tools I’ve used so far.

SteamCMD

First we use SteamCMD to download and run our local server. Rustafied provides and excellent walk through with how to use SteamCMD to download, install, and run your own local Rust server for development purposes. This is a MUST and you can find the instructions here.

RustEdit

RustEdit is your go-to map editing tool. There maybe more tools like RustEdit but RustEdit is probably the oldest and most mature. You can use this tool create maps from scratch (probably don’t do this unless you’re super experienced) or modify existing maps from seeds of your choice. The easiest approach is typically to find the map that you want to use from PlayRust.io map gallery, identify the seed, run your local server referencing that map size and seed, then use the map your server downloads as your RustEdit starting point. This gives you all the topology build in (spawn points, etc) with some extra goodies that you can modify later within the editor.

Once you have your map loaded in RustEdit you can follow the tutorial above to learn the basics.

Plugins

You’ll need an IDE. I like to use Visual Studio 19 with JetBrains ReSharper.

Editing the map is one thing, but it doesn’t complete everything we need. We still need to be able to modify and edit the behavior of things. The map editor alone (other than topology) will just affect static prefabs within the map you load. So if you position a prefab (e.g., car) then typically that car is going to be completely static, no life, no degredation, etc. So, for example, if we want to create a parkour map where some of our items are say rotating or elevating up and down, the map editor alone won’t cut it.

We need to download and install Umod oxide server side. This gives us all of the libraries we need and an API full of hooks that we can use to modify behavior. To create and modify plugins you’ll need to know the basics of C#. If you’ve worked with Java in the past then C# should be exceedingly recognizable and easy to write plugins with.

Below is a quick example of a plugin that just sends a message to a user.

 0namespace Oxide.Plugins
 1{
 2    [Info("MyPlugin","Cahlen Humphreys",0.1)]
 3    [Description("Simple Test Plugin")]
 4    public class MyPlugin : RustPlugin
 5    {
 6        [ChatCommand("hello")]
 7        void HelloCommand(BasePlayer player)
 8        {
 9            SendMessage(player, "Hi " + player.displayName + "!");
10        }
11
12        void Broadcast(string msg, params object[] args)
13        {
14            PrintToChat(msg);
15        }
16
17        void Loaded()
18        {
19            Broadcast("MyPlugin has been loaded.");
20        }
21    }
22}

The above is a functioning working plugin. The behavior is simplistic, when the plugin is loaded, it broadcasts a message. But by combining the above with the hooks that Oxide provides you can do some pretty cool things.

Copying your plugin into the oxide/plugins directory within your server will activate the plugin within the server. A couple of things to note – Loaded() executes immediately after the plugin has been loaded, while the HelloCommand that is annotated registers the /hello command within the server.

TODO

  • On my list to complete, I’ve been working on creating a custom elevator for my parkour map. This involves me having the plugin that loads spawning the prefab (whatever I’m using as an elevator) in a specific position. Then I gradually change the position of the object continuously and send the position updates to the server. This allows me to create a crude elevator more or less.

  • Feature to spawn animals on command. One thought was that I could associate the animals with the weapons hook in oxide. So that, for example, each time I shoot a fire arrow it would spawn 10 bears or something whereever the arrow landed.

  • I’d also like to see if with Oxide/Rust that I could identify one of the prefabs in the map and manipulate it, instead of having the plugin spawn in the item that I want to manipulate. I’m not sure if this is possible, so I’ll update my progress on that.

  • Create unit tests for the plugin.