Posted July 14, 2019 by Artur Smiarowski
#devlog #modding
Hey guys,
As promised in the last week devlog, this weekend I'll dive into explaining how you can modify or create content for Soulash. This will be a bit technical devlog, but I'll try to explain everything as simple as possible. As you may know, the proper modding support with tools assisting with the creation of mods and a way to share them with other players will be the theme of a v0.4 major release, but it's possible to change a lot right now. Some things would be a pain to edit without an editor, like maps or animations, so today we'll dive into modifying spawns and creating new enemies in the game.
First, let's consider spawns. In Soulash enemies don't respawn during play. The game generates the AI entities with their equipment based on a predefined template - a set of rules. In your game folder, you can find a "data/organizations.json" file. This file specifies who and where should be created during the generation of a new world. If you're not familiar with JSON data format, essentially what you need to know is that array or list of things are defined inside brackets "[]", while objects or definition of things inside "{}". You can read about this in depth here, but we'll go through an example, so hopefully, everything will become apparent soon.
Player starting region in the v0.2.5 is 30,27,0 (x,y,z). The region at position 31,27,0 is positioned directly to the east, while 30,28,0 up north. Let's look through the organizations.json file in your text editor of choice and see what's up at 30,28,0. In most editors to find something inside a file, you need to press ctrl + f. We're looking for a line: "map": "30,28,0".
And this is what you should find in the file:
{
"id": 11,
"level": 1,
"name": "Fishmen",
"map": "30,28,0",
"workers": [313, 313, 313, 313, 313, 313, 313, 313],
"recipes": [],
"leader": -1
}
It's an object inside {} that describes what kind of entities the world generator will create on a region map with position 30,28,0. On the left side is the name of object properties, while on the right side, their values. Let's go through them one by one.
Some entries also have "mark" and "mark_color" properties. These describe how to render the points of interest you can see on the world map (question marks and exclamation mark). We will skip them for today.
The most important properties are "workers", "map", and "leader". Now to create new groups of enemies or replace the ones we see right now, we need to know how to get their unique identifiers. Let's open the biggest of the data files: "data/entities.json".
This file describes everything you encounter in the game from a simple grass patch to random trees or mushroom spawners and all AI entities available. Soulash entities are created from 74 different components, and the count is still increasing during the development of the game. Describing them all would be out of the scope of this article, but I'll make a wiki for it at some point. Today we will focus on AI entities specifically, so we can create new enemies and spawn them inside the game. Let's take a Fishman as an example.
{
"artificial_intelligence": {
"allies": [
8
],
"enemies": [
5
]
},
"components": [
"artificial_intelligence",
"actor",
"collidable",
"fighter",
"glyph",
"health",
"humanoid",
"name",
"moveable",
"position_2d",
"stamina",
"statistics",
"sight",
"tags",
"equipment",
"experience_gainer"
],
"corpse": "Fishman corpse",
"description": "Placeholder",
"equipment": {
"backpack": [
{
"chance": 0.4,
"name": "Perch"
}
],
"right_hand": [
{
"chance": 0.33,
"name": "Primitive knife"
},
{
"chance": 0.33,
"name": "Primitive spear"
},
{
"chance": 0.34,
"name": "Primitive sword"
}
]
},
"experience_gainer": {
"exp": 5,
"level": 1
},
"glyph": {
"color": [
46,
136,
154
],
"id": 150,
"tile_type": 0,
"tiles": [
0
]
},
"fighter": {
"attackNames": ["Fist", "Kick", "Fin", "Bite"]
},
"health": 45,
"id": 313,
"moveable": {
"speed": 1.2
},
"name": "Fishman",
"sight": {
"infravision": false,
"range": 7
},
"statistics": {
"dexterity": [
7,
12
],
"endurance": [
10,
13
],
"intelligence": [
6,
9
],
"strength": [
10,
16
],
"willpower": [
7,
10
]
},
"tags": [
8,
9,
13
]
}
Whew, that's a lot more data. Fortunately, it's not as complicated as it looks (I hope). Let's go from the top.
I hope I didn't bore you to death by now. Feel free to experiment, but remember to make copies of the changed files. An update to the game could replace your changes. There are a lot of things that you can do with these components, but also a lot of unusual combinations can probably result in crashes, so if it does happen, make sure to let me know what you changed. You can send me the zipped data files to support@wizardsofthecode.pro.
I know these are not easy to change, require some technical knowledge, and remembering different numbers. It's a problem we will be tackling in v0.4 with editors for maps, entities, abilities, and animations that will abstract all of these technical things so everyone who would like to, can create new regions, adventures, even new races, and professions and share them with others for truly unlimited number of unique experiences.
Let me know in the comments below if this is something you guys are interested at all and would like me to expand further into items and abilities before v0.4 that will come next year, or if it's way too hard to bother without editors. If your text editor doesn't support JSON validation, you can use one online to determine if the file structure is invalid.
Can't wait to see worlds with anvils made out of human corpses and scissors on Fishman. Crafting shirts on a sleeping Fishman sounds pretty epic, maybe it should be in the main game? Have fun!