Modding tutorial: creating new mods
+6
slink
Adventure4u1
Butch
Luki2410
QEUH
jan.oxymoron
10 posters
Page 1 of 2 • 1, 2
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Modding tutorial: creating new mods
Mon Feb 18, 2019 2:08 pm
This short tutorial will walk you through how the folder structure for mods works and how to add your files in such a way that they load properly and can exist alongside other mods.
Each mod needs to reside in its own folder under StreamingAssets\Addons - let's call it StreamingAssets\Addons\[ModNameOfYourMod]
Note: the name needs to start with 'Mod', the game uses this to only show mods and not other folders under Addons.
All xml files with data then belong to the subfolder StreamingAssets\Addons\[ModNameOfYourMod]\Database (note: it's case sensitive!)
Registering your mod
The first step is to create the ModAddon.xml file which will make the game aware of your mod (and it will show it in the main menu). This is important for multiple mods to exist side-by-side and to ensure saved games know what content they're using.
Make sure you choose an unique ID!
Adding and loading graphical assets
The ModAssetLists.xml file lists all files that will be loaded. Note: the file location is relative to the root of the mod (start the path with MOD_ROOT/), so you can use subfolders, in the following example all textures are directly in the folder next to Database.
StreamingAssets\Addons\[NameOfYourMod]\Database\ModAssetLists.xml
Make sure the IDs for each asset are unique, otherwise loading of the mod can prevent existing game data from being loaded correctly!
Custom icons
Custom icons are currently supported for objects, composite objects, floors, doors and walls.
The icons themselves need to be a 64x64 px png, while the game creates a sprite from the inner 60x60 px area - make sure you leave some space around the icon graphics.
Asset type in the asset lists xml is TEXTURE_CUSTOM_SPRITE.
The parameter of the object is then, instead of IconIndex, CustomIconAssetRef:
Modding floor and wall graphics
Unlike for objects, for floors, walls and doors only one texture is supported, which means that when modding the content, the game needs to be redirected to the new texture, which still needs to contain the original graphics (which you can change and there's usually some space left for additions).
To load the new texture, add it to ModAssetLists.xml so the game loads it:
Then override the matching tweakable in ModTweakables.xml so your texture is used:
Each mod needs to reside in its own folder under StreamingAssets\Addons - let's call it StreamingAssets\Addons\[ModNameOfYourMod]
Note: the name needs to start with 'Mod', the game uses this to only show mods and not other folders under Addons.
All xml files with data then belong to the subfolder StreamingAssets\Addons\[ModNameOfYourMod]\Database (note: it's case sensitive!)
Registering your mod
The first step is to create the ModAddon.xml file which will make the game aware of your mod (and it will show it in the main menu). This is important for multiple mods to exist side-by-side and to ensure saved games know what content they're using.
- Code:
<Database>
<GameDBAddon ID="ADDON_MOD_TEST"> <Author>Oxymoron Games</Author> </GameDBAddon>
</Database>
Make sure you choose an unique ID!
Adding and loading graphical assets
The ModAssetLists.xml file lists all files that will be loaded. Note: the file location is relative to the root of the mod (start the path with MOD_ROOT/), so you can use subfolders, in the following example all textures are directly in the folder next to Database.
StreamingAssets\Addons\[NameOfYourMod]\Database\ModAssetLists.xml
- Code:
<Database>
<GameDBAsset ID="ASSET_TEX_MOD_TEST_OBJECTS"> <Type>TEXTURE_OBJECTS</Type> <File>MOD_ROOT/mod_objects_big_atlas.png</File> </GameDBAsset>
<GameDBAsset ID="ASSET_TEX_MOD_TEST_ICON_TREE"> <Type>TEXTURE_CUSTOM_SPRITE</Type> <File>MOD_ROOT/mod_icon_01_tree.png</File> </GameDBAsset>
<GameDBAsset ID="ASSET_TEX_MOD_TEST_ICON_LAMP"> <Type>TEXTURE_CUSTOM_SPRITE</Type> <File>MOD_ROOT/mod_icon_02_lamp.png</File> </GameDBAsset>
</Database>
Make sure the IDs for each asset are unique, otherwise loading of the mod can prevent existing game data from being loaded correctly!
Custom icons
Custom icons are currently supported for objects, composite objects, floors, doors and walls.
The icons themselves need to be a 64x64 px png, while the game creates a sprite from the inner 60x60 px area - make sure you leave some space around the icon graphics.
Asset type in the asset lists xml is TEXTURE_CUSTOM_SPRITE.
The parameter of the object is then, instead of IconIndex, CustomIconAssetRef:
- Code:
<CustomIconAssetRef>ASSET_TEX_MOD_NAME_CUSTOM_ICON</CustomIconAssetRef>
Modding floor and wall graphics
Unlike for objects, for floors, walls and doors only one texture is supported, which means that when modding the content, the game needs to be redirected to the new texture, which still needs to contain the original graphics (which you can change and there's usually some space left for additions).
To load the new texture, add it to ModAssetLists.xml so the game loads it:
- Code:
<Database>
<GameDBAsset ID="ASSET_TEX_MOD_WALL_PATTERNS"> <Type>TEXTURE</Type> <File>mod_walls_patterns_atlas.png</File> </GameDBAsset>
</Database>
Then override the matching tweakable in ModTweakables.xml so your texture is used:
- Code:
<Database>
<!-- Override the default tweakable value -->
<GameDBTweakableString ID="TEXTURE_ASSET_WALLS_PATTERN"> <Value>ASSET_TEX_MOD_WALL_PATTERNS</Value> </GameDBTweakableString>
</Database>
- QEUHspecialist
- Posts : 239
Reputation : 42
Join date : 2018-03-26
Location : Glasgow
Re: Modding tutorial: creating new mods
Thu May 30, 2019 3:53 pm
Hi,
Is it possible to, for example, create a mod that simply replaces the tweakables file when active?
Is it possible to, for example, create a mod that simply replaces the tweakables file when active?
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Thu May 30, 2019 4:02 pm
QEUH wrote:Hi,
Is it possible to, for example, create a mod that simply replaces the tweakables file when active?
Hi, yes, it is - although best practice would be to only copy-paste and change the lines you want to modify, that way a couple of mods could coexist and each one can tweak something different, otherwise the mod that gets loaded last would just override everything.
- QEUHspecialist
- Posts : 239
Reputation : 42
Join date : 2018-03-26
Location : Glasgow
Re: Modding tutorial: creating new mods
Thu May 30, 2019 4:17 pm
Thanks Jan, good point.
- Luki2410intern
- Posts : 4
Reputation : 0
Join date : 2018-10-23
Re: Modding tutorial: creating new mods
Sun Jun 09, 2019 1:37 pm
I tried to add the ability to make temperature meassurement in the inpatient ward.
After adding the required room type to the Examinations.xml as well as adding the needed equipment to the section in RoomTypes.xml, the equipment is now shown as optional in building mode, but the patient is still transfered to diagnostics room.
Also I recognized, that I have to add the whole GameDBExamination and the whole GameDBRoomType. Otherwhise the room would be broken. In my opinion this is not a good idea, because if you as a developer change something on the examinations or rooms, while having my mod active it would be overwritten by my files, if i dont make this changes either. Would be nice if I only need to add my lines to the RequiredRoomTypeList and so on.
EDIT:
After changing the original files it worked. Obviously the mod files does not overwrite the original files properly.
After adding the required room type to the Examinations.xml as well as adding the needed equipment to the section in RoomTypes.xml, the equipment is now shown as optional in building mode, but the patient is still transfered to diagnostics room.
Also I recognized, that I have to add the whole GameDBExamination and the whole GameDBRoomType. Otherwhise the room would be broken. In my opinion this is not a good idea, because if you as a developer change something on the examinations or rooms, while having my mod active it would be overwritten by my files, if i dont make this changes either. Would be nice if I only need to add my lines to the RequiredRoomTypeList and so on.
EDIT:
After changing the original files it worked. Obviously the mod files does not overwrite the original files properly.
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Mon Jun 10, 2019 3:55 pm
Hi, just a quick comment - we're planning some changes to the way rooms are linked to examinations, the system will use tags in the future and should be much more universal (you can check the mod support roadmap:
https://projecthospital.forumotion.com/t1843-mod-support-roadmap).
But, generally, new items in modded XMLs override the original data with the same ID - so if you copy the original examination to a new file and then modify some lines there, that's the approach that should currently work. Support for partial changes/merging the XML data sounds quite dangerous and probably not even possible within the current database framework I'm afraid.
https://projecthospital.forumotion.com/t1843-mod-support-roadmap).
But, generally, new items in modded XMLs override the original data with the same ID - so if you copy the original examination to a new file and then modify some lines there, that's the approach that should currently work. Support for partial changes/merging the XML data sounds quite dangerous and probably not even possible within the current database framework I'm afraid.
- Butchattending
- Posts : 46
Reputation : 7
Join date : 2019-06-06
Re: Modding tutorial: creating new mods
Sat Oct 05, 2019 7:47 pm
The guide mentions that custom icons are currently supported for objects, composite objects, floors, doors and walls. What about custom icons for new treatments, exams, diagnoses or symptoms created by modders? Is there a way to add custom icons for these things? If not, are there any plans to support this in the future?
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Mon Oct 07, 2019 5:29 pm
Hi, we'll be adding support for this soon, it's actually relatively high on our list - basically the next round of mod support changes will be the improvements in room-examination assignment mentioned above, custom icons for the medical side of the database and a full guide for adding new departments/diagnoses/examinations/treatments. Should be either in the next minor patch or right before we release the first DLC.
- Butchattending
- Posts : 46
Reputation : 7
Join date : 2019-06-06
Re: Modding tutorial: creating new mods
Mon Oct 07, 2019 5:30 pm
Wonderful.
- Adventure4u1attending
- Posts : 34
Reputation : 3
Join date : 2020-02-24
Re: Modding tutorial: creating new mods
Thu May 07, 2020 8:34 pm
What should be included in a mod that simply edits some tweakables? The
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Mon May 11, 2020 9:07 am
Hi, you can copy the tweakables.xml file from the game, clean most of it and only keep the lines you want to modify. The file should then reside in a Database subfolder under your mod's folder.
- slinkspecialist
- Posts : 142
Reputation : 9
Join date : 2018-11-01
Re: Modding tutorial: creating new mods
Sun May 24, 2020 10:16 pm
jan.oxymoron wrote:QEUH wrote:Hi,
Is it possible to, for example, create a mod that simply replaces the tweakables file when active?
Hi, yes, it is - although best practice would be to only copy-paste and change the lines you want to modify, that way a couple of mods could coexist and each one can tweak something different, otherwise the mod that gets loaded last would just override everything.
I have a problem with my implementation of this. I made a mod that is recognized by the game and displays the name and author properly. I created a ModTweakables.xml in my database directory, and attempted to override some values in Tweakables.xml. The one that I could test was resale of equipment. I found that not only was my file being ignored, but the game isn't doing what it says it is doing. Here are my numbers.
This part was the same for all cases.
Balance: 54892
Bought: 24999, displayed that number
Balance: 29893
Nothing changed in either file, and also with only my mod supposedly changing the value to 100%.
Sell item for 12499 as displayed
Balance: 51891
This is not 50%. This is 88%.
Changed in the game's copy of the file to 100%, and also when changed in both files to 100%.
Sell item for 24999 as displayed
Balance: 73891
This is not 100%. This is 175%. or twice 87.5%.
So the game is ignoring my changes, and it is not selling at the price it is displaying when the sale occurs.
How can I get the game to recognize my file?
- Attachments
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Tue May 26, 2020 2:14 pm
Hi - first a quick thanks for discovering a problem with the Angiography object, one part had a price incorrectly set and was causing a double refund, a fix is ready for the next patch, in the meantime feel free to use for example MRI for the testing.
Regarding the mod files themselves, at first glance everything looks ok - do you have these in StreamingAssets\Addons\Mod_Slink\Database? In either case it will be worth checking the log, it should show that database is getting loaded from the different folders and something along the lines:
Duplicate database entry, overriding the original one: TWEAKABLE_BUILDING_REFUND_PERCENT
Regarding the mod files themselves, at first glance everything looks ok - do you have these in StreamingAssets\Addons\Mod_Slink\Database? In either case it will be worth checking the log, it should show that database is getting loaded from the different folders and something along the lines:
Duplicate database entry, overriding the original one: TWEAKABLE_BUILDING_REFUND_PERCENT
- slinkspecialist
- Posts : 142
Reputation : 9
Join date : 2018-11-01
Re: Modding tutorial: creating new mods
Tue May 26, 2020 3:37 pm
jan.oxymoron wrote:Hi - first a quick thanks for discovering a problem with the Angiography object, one part had a price incorrectly set and was causing a double refund, a fix is ready for the next patch, in the meantime feel free to use for example MRI for the testing.
Regarding the mod files themselves, at first glance everything looks ok - do you have these in StreamingAssets\Addons\Mod_Slink\Database? In either case it will be worth checking the log, it should show that database is getting loaded from the different folders and something along the lines:
Duplicate database entry, overriding the original one: TWEAKABLE_BUILDING_REFUND_PERCENT
In the log, I found mention of my file:
Database - ReadFiles C:\GOG Games\Project Hospital\ProjectHospital_Data\StreamingAssets\Addons\Mod_Slink
And yes, they are in Mod_Slink\Database under Addons. The mod shows up properly on the initial screen.
But the only overrides I found applicable to my mod were:
Duplicate database entry, overriding the original one: TWEAKABLE_MAX_FLOORS
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 43)
Duplicate database entry, overriding the original one: TWEAKABLE_EMPLOYEE_LIMIT
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug.bindings.h Line: 43)
And I don't actually change those values. I only included those in the event I should want to change them.
Figures that I would use the one defective item for my testing. *laughing*
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Tue May 26, 2020 4:26 pm
Hi, there's actually an issue in the names string table, a broken tag in the line with Austin - unfortunately the xml reader doesn't complain and just stops loading the rest of the files if it comes across a broken file - hopefully this was it!
Edit: ...and it's not possible to use the & character in the contributors names, you'd need to use & instead.
Edit: ...and it's not possible to use the & character in the contributors names, you'd need to use & instead.
- slinkspecialist
- Posts : 142
Reputation : 9
Join date : 2018-11-01
Re: Modding tutorial: creating new mods
Tue May 26, 2020 5:54 pm
jan.oxymoron wrote:Hi, there's actually an issue in the names string table, a broken tag in the line with Austin - unfortunately the xml reader doesn't complain and just stops loading the rest of the files if it comes across a broken file - hopefully this was it!
Edit: ...and it's not possible to use the & character in the contributors names, you'd need to use & instead.
Looks like that did it! Thank you ever so much. From now on I will check the file with IE after I edit it in Notepad, to make sure it loads correctly as XML. And I replaced the "&" with "and". I do understand HTML markup language, but "and" is easier to read than "&".
I edited your part of the male first names because you had Frank in there twice. I replaced one with George. I also noticed that three surnames slipped into the 40 most popular names in 1990. Barkley, Foster, and Cole slipped in there mid-list. I left those alone. I figure everyone needs their moment of fame. *grin*
- Ukrainianintern
- Posts : 9
Reputation : 6
Join date : 2020-06-03
Re: Modding tutorial: creating new mods
Fri Jun 05, 2020 9:18 am
Is it possible to make new diagnoses in other languages (Russian), or how then to make a translation?
- Jamesfellow
- Posts : 82
Reputation : 6
Join date : 2019-11-10
Location : Malaysia, Kuala Lumpur
Re: Modding tutorial: creating new mods
Fri Jun 05, 2020 10:21 am
Hello, James here, I just want to ask, what does this code actually do?
<GameDBTweakableInt ID="TWEAKABLE_COLLAPSE_TIME_PERCENT"> <Value>100</Value> </GameDBTweakableInt>
<GameDBTweakableInt ID="TWEAKABLE_COLLAPSE_TIME_PERCENT"> <Value>100</Value> </GameDBTweakableInt>
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Fri Jun 05, 2020 12:40 pm
James wrote:Hello, James here, I just want to ask, what does this code actually do?
<GameDBTweakableInt ID="TWEAKABLE_COLLAPSE_TIME_PERCENT"> <Value>100</Value> </GameDBTweakableInt>
Hi, this tweakable can adjust how long it takes for patients with untreated critical symptoms to collapse, so increasing it can be used to make all patients more resilient.
- Jamesfellow
- Posts : 82
Reputation : 6
Join date : 2019-11-10
Location : Malaysia, Kuala Lumpur
Re: Modding tutorial: creating new mods
Fri Jun 05, 2020 1:00 pm
@jan.oxymoron Any other purposes?
- M0n3yresident
- Posts : 22
Reputation : 3
Join date : 2020-04-05
Location : Belgium
Re: Modding tutorial: creating new mods
Thu Jul 09, 2020 8:08 pm
jan.oxymoron wrote:QEUH wrote:Hi,
Is it possible to, for example, create a mod that simply replaces the tweakables file when active?
Hi, yes, it is - although best practice would be to only copy-paste and change the lines you want to modify, that way a couple of mods could coexist and each one can tweak something different, otherwise the mod that gets loaded last would just override everything.
I'm trying to adjust the amount of patients each ambulance can have each day. Turns out it was a very easy thing to adjust, in the tweakables file.
If I want to upload this on the workshop but want other people to use multiple adjustments in their tweakables file, do I just copy-paste that one specific line I changed into a new tweakables file? So the new tweakables file that I upload would only have that one line?
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Fri Jul 10, 2020 9:38 am
Hi, thanks for the question - not exactly, the file still needs to include the <Database></Database> tags, but yes, you can have just one tweakable in between.
M0n3y likes this post
- M0n3yresident
- Posts : 22
Reputation : 3
Join date : 2020-04-05
Location : Belgium
Re: Modding tutorial: creating new mods
Fri Jul 10, 2020 12:26 pm
Thanks for the feedback, I'll try it out soon then
- juanferiveraintern
- Posts : 5
Reputation : 0
Join date : 2021-03-10
Re: Modding tutorial: creating new mods
Wed Mar 10, 2021 6:50 pm
Hi,
i find it excellent that you can add textures and objects yourself.
But would it be possible to have an explanation on how to do it, when you just know the basics of coding?
Also i am trying to change textures on a macbook computer.
I bought the game from Steam... does this change the way of adding wall textures?
Thnx
i find it excellent that you can add textures and objects yourself.
But would it be possible to have an explanation on how to do it, when you just know the basics of coding?
Also i am trying to change textures on a macbook computer.
I bought the game from Steam... does this change the way of adding wall textures?
Thnx
- jan.oxymorondeveloper
- Posts : 2309
Reputation : 336
Join date : 2018-03-23
Re: Modding tutorial: creating new mods
Thu Mar 11, 2021 9:25 am
Hi Juan, I also got your message, but let me reply here:
First, I'd really recommend going through the other modding tutorials, the one about objects/graphics (https://projecthospital.forumotion.com/t1477-modding-tutorial-objects) has all the details about wall textures.
The TL/DR: walls need to be in a single texture (mostly because of optimizations), but you can copy the existing one to your mod, add more materials and tell the game to load it instead of the texture included in the game.
I hope this helps!
First, I'd really recommend going through the other modding tutorials, the one about objects/graphics (https://projecthospital.forumotion.com/t1477-modding-tutorial-objects) has all the details about wall textures.
The TL/DR: walls need to be in a single texture (mostly because of optimizations), but you can copy the existing one to your mod, add more materials and tell the game to load it instead of the texture included in the game.
I hope this helps!
Page 1 of 2 • 1, 2
Permissions in this forum:
You cannot reply to topics in this forum
|
|