Unheard Software

The modding system #1

BANNER

Hello fellow city conquerors!

Today we have prepared for you a devlog about modding. This whole thing won't fit into a single devlog, so we are going to make it a series. That's why it's part 1. Don't get us wrong, modding is not in the game just yet, well, not in our intended official way. This series is going to focus on our progress of working on the official modding system, its documentation and maybe something extra along the way (I would do blink, but there are no eyes).

In this first modding devlog, we will go over:

Our official modding

-> Philosophy

Modding is a broad term. If a developer says that their game supports modding, it does not tell you much. Technically speaking every game or software is modifiable. So it's not about whether a game can be modded, but how and to which degree.

When we started working on Ripper we very early on discovered that what we are making could heavily benefit from having community made content. And thus we made design decisions early on to support future community made content. For example we made it so all the game content is being loaded while the game is running. This means we can also load mods while the game is running.

So we have a game that is capable of loading content at runtime. But that's not really modding yet. What we want to achieve is to allow players with no coding knowledge to be able to add content into the game. Just put some textures and files in the correct directories and the game eats it and you can now use it in game. That's our goal. So there are a few things we had to decide:

MC_DELETING_COMPUTER_GIF

-> What is the mod structure?

There are several modding structures out there. Usually each game defines its own. Since our game is multiplayer we want to have all the textures and visual assets separated from the data that the server will use. And also given that we have some experience with Minecraft modding we have decided to borrow their layout.

This is how the mod structure looks:

- Mods/
  - ExampleMod-1.2.3.zip
    - assets/
      - example_mod/
        - lang/
          - en_us.toml
		- texture/
		  - item/
		    - ...
		  - furniture/
		    - ...
		  - ...
    - data/
      - example_mod/
	- item/
	  - my_added_gun.toml
	  - ...
	- ...
    - metadata.toml

The fact that we have namespace (example_mod) as a sub directory in both data and assets also has the benefit of allowing users to mod other mods. If you are not following or want more information, don't worry, we will go over that in a future blog post.

-> Which format do mods use?

Mods in other games also have different configuration or coding languages for adding or altering content. Most commonly JSON or XML languages are used. Although JSON is most common, it is not the most readable for fleshy humans.

Let's do a comparison between JSON and Toml:

JSON:

{
  "item": {
    "type": "ripper:health",
    "icon": "ripper:item/banana_full",
    "heal_amount": 20,
    "additional_uses": 2,
    "texture": [
      {
        "id": "ripper:item/banana_empty",
        "conditions": [
          "[ItemDurability]=0b"
        ]
      },
      {
        "id": "ripper:item/banana_half",
        "conditions": [
          "[ItemDurability]=1b"
        ]
      },
      {
        "id": "ripper:item/banana_full"
      }
    ]
  }
}

TOML:

[item]
type="ripper:health"

icon = "ripper:item/banana_full"

heal_amount = 20
additional_uses = 2

# Texture set (this is a comment)
[[item.texture]]
id = "ripper:item/banana_empty"
conditions = ["[ItemDurability]=0b"]

[[item.texture]]
id = "ripper:item/banana_half"
conditions = ["[ItemDurability]=1b"]

[[item.texture]]
id = "ripper:item/banana_full"

In this example we can see the difference between JSON (at the top) and Toml (at the bottom) of the banana item we discussed in a previous devlog. Not sure how you see it, but for us, Toml felt way easier to understand what is happening, and also it removes the curly braces. The only complicated part in this example is textures. Each texture is its own block, whereas JSON has everything as a separate {} block, Toml just adds a new [[item.texture]]. Point being, the curly braces can be confusing and cause a lot of headaches, especially if not viewed in a code editor. Another benefit of Toml is the fact that it supports comments, which JSON does not.

Of course, there is always an option to make Toml unreadable:

"item" = { "type" = "ripper:health", "icon" = "ripper:item/banana_full", "heal_amount" = 20, "additional_uses" = 2, "texture" = [
  { "id" = "ripper:item/banana_empty", "conditions" = [ "[ItemDurability]=0b" ] },
  { "id" = "ripper:item/banana_half",  "conditions" = [ "[ItemDurability]=1b" ] },
  { "id" = "ripper:item/banana_full" }
] }

WHY would anyone want to write it like this?

-> Is scripting allowed?

Yes, BUT with player confirmation. The plan is to use GDScript. The mod itself would declare in its metadata that it offers scripts. This is what we came up so far. This part is still in early progress and we are not even sure how this is going to go. Either way, we want the community to mod the game, more than just adding re-skins of existing features. So some sort of scripting is in order. This would be for the bit more advanced modders.

Enabling scripts would also allow for:

Of course, allowing scripts is a double-edged sword. If we allow anyone to run any code on your machine, it also means that your computer can get some malware. Even if we tried to sandbox or limit what the scripts can do, it is impossible for us to ensure your computer does not get bricked. So at least, as a small bandage on a dead body, we are going to show the player a modal window that asks for permissions to run the mod scripts. It's the best we can offer, and thus the player is now responsible for breaking his computer (we don't assume any legal liability). There is no warranty. There always has been -- no warranty.

Modding Items

Now for the headline content of this blog post. We have moved all Ripper items to use the modding API. Yes, we use Toml files internally to add base-game content.

There are several reasons why we use the Toml files for the base game. But the primary one is: we want to test our own modding system. What this means is that if it works for us, it should work for the community. One additional benefit of this is that you can mod the base game content. So if you want to mod the base sniper gun to shoot 100 projectiles instead of 1, that is possible.

We have split the items into categories, aka Item types:

If we bring back the banana example from before, you can clearly see the type = "ripper:health".

[item]
type="ripper:health" # <- Type of the item

icon = "ripper:item/banana_full"

heal_amount = 20 # <- how much health should the player gain when consumed
additional_uses = 2 # <- How many times can this item be used (-1) before the item is destroyed (eaten). => 3 uses
# ...

Here you can see that, since it's a health supply item, it also has heal_amount and additional_uses fields.

Wrapping up

In the next modding devlog we might go over:

We are hard at work, on the next Ripper update. With the time we have, the new update is a bit too ambitious so it might take more time than we have scheduled...

If you want to help us out, please wishlist or review Ripper on Steam! This started as a passion project and has turned into something we are genuinely excited about. We want to keep working on it for a long time. And sharing it around helps us a ton!

Okay, that's everything we have for this month. Thanks for reading and see ya next time!

Unheard Software

FOOTER

#gamedev #godot #indiedev #ripper #shooter #topdown #unheard #unheardsoftware