Modding

Wish to create your own content for **Hospitalize**, AND share it with others? Modding with let you do just that! Creating mods can be done by anyone, no matter your programatic background. Using a simple language called XML, you will be able to change almost anything in the game and implement your very own creations. From character behaviour to diseases and treatments.

### Hospitalize Vanilla Content

* In order to greater understand the XML coding in Hospitalize, we have released the original Hospitalize XML files for you to download.
* There will be more documentation surrounding this in the future, but at least releasing it publicly, anyone can see how Illeris has set up their XML code and use it as reference for their own creations!
* You can download a zip file containing all the XML files here.

## Getting Started: Tutorial

* To get started with creating your own mod, you first need to create a folder with some files in it. Start out by navigating to your Hospitalize install location. *(That is the folder containing Hospitalize.exe. The default location is "**C:\Program Files (x86)\Steam\steamapps\common\Hospitalize**")*

* Once there, navigate to "**Hospitalize\_Data/StreamingAssets/Mods**". This is where you want to put your mod folder. Let's create a new folder and call it whatever you want. In this example, we will be creating the grim reaper, so we are going to call the folder "**The Grim Reaper**". Open the folder you just created.

Next, open your text editor of choice. *(In this guide, we will be using Notepad++.)* Create a new file in your text editor, and add the following:

**author**=YOUR NAME
**version**=VERSION OF THE MOD

*(Save this file as "**mod.data"**)*

* Now we need to actually create the grim reaper and all of its uses. To begin with, create a new file in your text editor and save it as "***modContent.xml***" in the SAME directory as your "***mod.data***" file. The "***modContent.xml***" file will contain all of the grim reaper's actions and attributes. Let's start filling that in.
* Begin by creating a resource node with the name of your mod.

```
<Resources name="GrimReaper">
</Resources>

```

Within this node, you can start setting up essential assets to your mod like sounds, graphics, etc. Let's try setting up a texture for our grim reaper by adding the "*texturemap*" node.

```
<var textureMap="NAME OF YOUR TEXTUREMAP" path="FILENAME OF THE TEXTUREMAP"/>

```

In our case, it would look somthing like this:

```
<Resources name="GrimReaper">
	<var textureMap="characters" path="Character.png"/>
      </Resources>

```

Note that you actually need to have the png file in your mod folder. You can choose to create your own texture or simply use the one I created:

* Next, create a new node to put your character data in, like so:

```
<Resources name="GrimReaper">
	<var textureMap="characters" path="Character.png"/>
          	<ReaperChar>
          	</ReaperChar>
</Resources>

```

Let's start by giving our new character a name using the "***name***" node.

```
<var name="CHARCTER NAME"/>

```

In our case, it would look something like this:

```
<ReaperChar>
	<var name="The Grim Reaper"/>
       </ReaperChar>

```

* Now, let's add some definitions as to what this character actually is. For this, we will use a couple of nodes.

 employable
 entity
 frequency

You might ask yourself "What is an entity?". In Hospitalize, an "*entity*" is a character that is **not** spawnable by traditional means (Though the hiring menu for example.). Our "**Grim Reaper**" is not spawned via the hiring menu and so it is indeed an "*entity*". In addition, we will need to add the "*frequency*" node to make sure there is actually a chance for our "**Grim Reaper**" to spawn. And so, in our case, these nodes should look something like this:

```
<var role="true"/>
      <var employable="false"/>
      <var entity="true"/>
      <var frequency="0.01"/> *(Keep in mind this is from 0-1 as stated above.)*

```

* Next, we will add a couple more nodes to define what the player can do with this character.

 showsalary
 showtask
 canfire

In this case, we want all of the fields above to be false.

```
<var showskills="false"/>
      <var showsalary="false"/>
      <var showtask="false"/>
      <var canfire="false"/>

```

* Now, let's actually give our character some graphics. To do this, we first need to load a sprite for our character by using the "*sprite*" node.

```
<var sprite="" textureMap="" mapLocation="" unitToPixel="" offset=""/>

```

```
sprite - The name of this sprite *(string)*
textureMap - The name of the texture map you want to use for this sprite *(string)*
mapLocation - The location and dimensions of the sprite on the character sheet starting in the bottom left corner *(x;y;w;h)*
unitToPixel - A scale factor. The default for hospitalize is 192. *(int)*
offset - The offset of the sprite to the center of the character. *(x;y;z)*

```

In our case, it would look somthing like this:

```
<var sprite="normal_s" textureMap="characters" mapLocation="0;0;192;192" unitToPixel="192" offset="0;0;0"/>

```

* Next, we need to tell the character which sprite to use depending on the direction he is facing. We do this by adding "*objectview*" nodes.

```
<var objectView="" dir="" sprite="" footprint="" flipXaxis="" flipYaxis="" transparency=""/>

```

```
objectview - The name of this view, following a specific naming pattern.
dir - The direction this view is for *(n/e/s/w)*
sprite - The sprite to use for this direction
footprint - 16 bits, representing a 4x4 grid, which defines which part of this object obstruct pathfinding. *(0000000000000000)*
flipxaxis - Flip the sprite on the X axis *(true/false)*
flipyaxis - Flip the sprite on the Y axis *(true/false)*
transparency - The transparency of this object view *(0 - 1)*

```

The naming convention for the objectview is as follows: BODYPART\_KEYWORD\_DIRECTION. The bodypart is either "body" or "head". The keyword is "normal" by default. The player can add more keywords to toggle different states of the sprite, e.g. the cleaner sweeping the floor. The direction refers to the direction of this object view.

* Let's add 4 of these object views to account for all 4 directions a character can move. Note that we only have one sprite for the reaper, but in theory you could create an individual sprite for each direction.

```
<var objectView="body_normal_n" dir="n" sprite="normal_s" footprint="1000000000000000" flipXaxis="false" flipYaxis="false" transparency="0.6"/>
      <var objectView="body_normal_e" dir="e" sprite="normal_s" footprint="1000000000000000" flipXaxis="false" flipYaxis="false" transparency="0.6"/>
      <var objectView="body_normal_s" dir="s" sprite="normal_s" footprint="1000000000000000" flipXaxis="false" flipYaxis="false" transparency="0.6"/>
      <var objectView="body_normal_w" dir="w" sprite="normal_s" footprint="1000000000000000" flipXaxis="true" flipYaxis="false" transparency="0.6"/>

```

Your entire code should at this point look somewhat like this:

At this point, you can go ahead and test your mod. For testing purposes, you should increase the spawning frequency to something higher like 1.

Start up your game, and go into the **mods** menu. If everything went well, your mod should show up in the list and you should be able to tick the check box next to it. After pressing the "back" button, the game will reload and your mod is enabled. Upon starting a new game, you should now see your grim reapers spawn.

**Great!** The reaper is in the game! However, he doesn't really do much yet.. Let's try to add some functionality to our reaper! To do that, we need to create a **task** for him. Start by creating a new node under your "*ReaperChar*" node.

```
<ReaperChar>
[ ... ]
</ReaperChar>
<ReaperTask>
</ReaperTask>

```

* Now, just like we did for the reaper, we need to specify a name for this blueprint, and some extra nodes telling the game what this blueprint is. In this case, a **task**.

 personaltask
 taskQueue
 taskBasePriority

Our task should now look like this:

```
<ReaperTask>
      <var name="Harvest souls"/>
                <var task="true"/>
                <var personalTask="false"/>
                <var taskqueue="Cleaning"/>
                <var taskBasePriority="100"/>
          </ReaperTask>

```

We set "*personalTask*" to false, since there is no personal reason we need this task to cover.

* In order for our task to actually do anything, we need to add some actions to tell the game what to do. Note that this is a very basic example. *(See the documentation page for Actions for more info.)*

```
<var action="" nr="Auto" primary="" secondary="" tertiary="" text="" pre="Auto"/>

```

```
action - The action to execute.
nr - The index of this action. Leave this as auto.
primary, secondary and tertiary - Three variables to pass into this action
text - The text that will be shown as the current activity
pre - What action needs to be finished for this to execute. Leave this as auto.

```

In this example, I will be using 6 simple actions to create the reaper's behaviour.

```
GetClosestPatient - Gets the patient closest to the task owner
Move - Move Object A to location B
Delay - Wait for a bit
KillCharacter - Kill the closest character we found earlier
MoveToRandomSpotInWorld - Move somehwere on the map
RemoveCharacter - Remove the reaper from existence.

```

In this example, my actions look something like this:

* Finally, let's add a line to our ReaperChar node.

```
<var idletask="Harvest souls"/>

```

This tells our reaper to automatically go and reap souls of unknowing victims!

* Your entire "***modContent.xml***" file should now look something like this:

With all of this completed, **The Grim Reaper** should now be flying around, killing innocent patients, before disappearing into the Aether again.

#### Sharing your own mods:

* Move your mod folder from the "StreamingAssets/Mods" folder to some other directory.
* Open Hospitalize.
* In the main menu, navigate to the "Mods -> Workshop" menu.
* Click the "Create new item" button.
* For the source folder, navigate into your mod folder *(To the same directory where your mod.data is located)*
* Enter a title for your mod.
* Optionally select an image, enter a description and change visability settings for your mod.
* Hit the "Submit" button.
* **Congratulations!** You can now subscribe to your mod from the Steam Workshop page. After restarting Hospitalize, your mod should be ready to go!

## Mod Examples

### Mod Example One: **Usable Object**

The **Big Chair** mod is very simple and is just an extra chair to your hospital.

It is a *furniture object* and can be used by **patients** and **staff** alike.

*(If you haven't already, it's **strongly** recommended that you read the tutorial section before looking at this code if you aren't familiar with it.)*

    The "**mod.data**" file for the **Big Chair** looks like this:

 **version**=0.1

The "**modContent.xml**" file looks like this:

*(In XML, lines between <!-- **these** --> are comments and will not affect the code in any way, they are simply a way to keep track of what does what)*

```
<Resources name="Illeris examples">
<var textureMap="chair_sprite_sheet" path="spritesheet.png"/>
            <ExampleConstruct>
	<BigChair>
		<var name="Big chair"/>
         		<var constructable="true"/> <!-- (Can it be constructed by the player?) -->
         		<var price="6500"/> <!-- (The price of the object in NOK currency) -->
         		<var category="Furniture"/> <!-- (If constructable, in what category should it be put in?) -->
         		<var icon="default_s"/> <!-- (What icon to use in the construction menu) -->
         		<var storable="true"/> <!-- (Can it be stored?) -->
         		<var unlocked="true"/> <!-- (Is it unlocked from the start?) -->
         		<var canBePlacedInside="true"/> <!-- (Can it be placed inside? -->
         	        <var canBePlacedOutside="true"/> <!-- (Can it be placed outside?) -->
         		<var staticsprite="true"/>

                <var objectView="object_normal_n" dir="n"   sprite="default_n" footprint="1000000000000000" flipXaxis="False" 	flipYaxis="False"/>
         		<var objectView="object_normal_e" dir="e" 	sprite="default_w" footprint="1000000000000000" flipXaxis="True" 	flipYaxis="False"/>
         		<var objectView="object_normal_s" dir="s"   sprite="default_s" footprint="1000000000000000" flipXaxis="False" 	flipYaxis="False"/>
         		<var objectView="object_normal_w" dir="w" 	sprite="default_w" footprint="1000000000000000" flipXaxis="False" 	flipYaxis="False"/>

                         <var sprite="default_s" textureMap="chair_sprite_sheet" mapLocation="0;0;192;192" 	unitToPixel="192" offset="0;0;0.25"/>
         		<var sprite="default_n" textureMap="chair_sprite_sheet" mapLocation="192;0;192;192" unitToPixel="192" offset="0;0;0.1"/>
         		<var sprite="default_w" textureMap="chair_sprite_sheet" mapLocation="384;0;192;384" unitToPixel="192" offset="0.1;0;0"/>

         		<var wayPoint="seat" objectView="object_normal_s" depthModifier="0" type="sit" positionModifier="0;0;0.1"/>
         		<var wayPoint="seat" objectView="object_normal_n" depthModifier="0" type="sit" positionModifier="0;-0.4;0.1"/>
         		<var wayPoint="seat" objectView="object_normal_e" depthModifier="0" type="sit" positionModifier="0;0;-0.28"/>
         		<var wayPoint="seat" objectView="object_normal_w" depthModifier="0" type="sit" positionModifier="0;0;-0.28"/>
         	</BigChair>
            </ExampleConstruct>
</Resources>

```

In this example, *nodes* that weren't used in the modding tutorial is demonstrated. There are many of them in **Hospitalize*,*** all for the purpose of being as modable as possible. There will be a documentation page up for all the different *nodes* in the near future.

### Mod Example Two: **Decorative Object**

The **Red Oak** mod is another very simple mod. It's an additional tree to the already excisting bunch.

As this is just a *decorative object*, the XML file is very simple and you could use this same XML file for reference if you wish to add your own *decorative objects*. Keep in mind that some of the *nodes* used here are explicitly for **Trees**.

    *(If you haven't already, it's **strongly** recommended that you read the tutorial section before looking at this code if you aren't familiar with it.)*

The "**mod.data**" file for the **Red Oak** looks like this:

 **version**=0.1

The "**modContent.xml**" file looks like this:

*(In XML, lines between <!-- **these** --> are comments and will not affect the code in any way, they are simply a way to keep track of what does what)*

```
<Resources name="Illeris examples">
<var textureMap="oak_sprite_sheed" path="spritesheet.png"/>
            <ExampleConstruct>
	<RedOak>
		<var name="Red oak"/>
             		<var constructable="true"/> <!-- (Can it be constructed by the player?) -->
            		<var price="2500" /> <!-- (The price of the object in NOK currency) -->
            		<var randomizeAtStartMap="true" frequency="0.05" /> <!-- (Should it spawn randomly on the map?) -->
            		<var category="Decoration" /> <!-- (If constructable, in what category should it be put in?) -->
            		<var envvalue="3" /> <!-- (How much does it positively affect guests/patients?) -->
            		<var shed="Leafs" /> <!-- (Does it shed leaves?) -->
            		<var waveinwind="true" /> <!-- (Does it wave in the wind?) -->
            		<var unlocked="true" /> <!-- (Is it unlocked from the start?) -->
            		<var icon="default_n" /> <!-- (What icon to use in the construction menu) -->
            		<var canBePlacedInside="true" /> <!-- (Can it be placed inside?) -->
            		<var transportItem="Crate" /> <!-- (What item does it come in from the truck?) -->
            		<var obstacle="false" /> <!-- (Can it be walked through? "false" if yes) -->
            		<var shade="oakshade" /> <!-- (The shade referenced below) -->

            		<var dir="n" objectView="object_normal_n" sprite="default_n" footprint="1000000000000000" flipXaxis="False" flipYaxis="False" />

            		<var sprite="default_n" textureMap="oak_sprite_sheed" mapLocation="0;0;384;384" unitToPixel="192" offset="0.0;0.0;0.64" flipXaxis="No" flipYaxis="No" />
            	</RedOak>
           </ExampleConstruct>
   <ExampleShade>
	<RedOakShade>
		<var name="oakshade"/>
             		<var randomizeAtStartMap="false"/>

             		<var objectView="shade_normal_n" dir="n" sprite="default_n" footprint="1000000000000000" flipXaxis="False" flipYaxis="False" transparency="1"/>

             		<var sprite="default_n" textureMap="oak_sprite_sheed" mapLocation="384;0;192;192" unitToPixel="192" offset="0.0;0.0;0.0" flipXaxis="No" flipYaxis="No" sunshadow="true"/>
             	</RedOakShade>
   </ExampleShade>
</Resources>

```

### Mod Example Three: **Scope Template**

The **ENT** **template** is a *scope template*created through modding. You will be able to make your own templates through modding by following this example.

The templates require little to no code at all, so it's very simple.

The "**mod.data**" for the **ENT template** looks like this:

 **version**=0.1

The "**modContent.xml**" file looks like this:

*(In XML, lines between <!-- **these** --> are comments and will not affect the code in any way, they are simply a way to keep track of what does what)*

```
<Resources name="Illeris examples">
   <ExampleScope>
	<ENTtemplate>
		<var name="ENT (Ear, nose and throat)"/>
     		<var isrulegroup="true"/>

     		<var rulegroup="Tonsillitis"/>
     		<var rulegroup="Fever,Sore throat,Fatigue,Cough,Runny nose"/>

     		<var rulegroup="Pneumonia"/>
     		<var rulegroup="Fever,Cough,Runny nose,Chest pain,Fatigue"/>

     	        <var rulegroup="Ear infection"/>
     		<var rulegroup="Pain in the ear,Discharge form the ear,Reduced hearing"/>

     		<var rulegroup="Physical examination"/>
     		<var rulegroup="Blood analysis"/>
     	</ENTtemplate>
        </ExampleScope>
</Resources>

```

### Mod Example Four: **Disease and Treatment**

Making *diseases* is a little more complicated and requires you to look up the correct Actions.

In this example, **Migraine**, you can see how to setup a working *disease* and a corresponding *treatment*.

The "**mod.data**" file for **Migraine** looks like this:

 **version**=0.1

The "**modContent.xml**" looks like this:

*(Keep in mind that the XML files are **quite sensitive** and you will need to make sure to have your quotation marks and closing brackets just like in this example, or it will throw you **errors**.)*

```
<Resources name="Illeris examples">
  <ExampleIllness>
    <Migraine>
             <var name="Migraine"/>
             <var handbook="Illness: Migraine"/>
             <var description="Typical Symptoms:
                - Red eyes
                - Nausea
                - Vomiting
                - Head ache

                Typical Examinations:
                - Physical examination

                Treatments:
                - Prescription: Painkillers
                - Prescription: Sumatriptan

     A migraine is a primary headache disorder characterized by recurrent headaches that are moderate to severe. Typically, the headaches affect one half of the head, are pulsating in nature, and last from two to 72 hours. Associated symptoms may include nausea, vomiting, and sensitivity to light, sound, or smell."/>

             <var illness="true"/>
             <var illnessFrequency="30"/>

             <var illSymptom="Red eyes" probability="70" strength="75"/>
             <var illSymptom="Nausea" probability="70" strength="65"/>
             <var illSymptom="Vomiting" probability="70" strength="55"/>
             <var illSymptom="Head ache" probability="100" strength="60"/>

             <var illExamin="Physical examination" probability="100" effect="80"/>

             <var illTreat="Prescription: Painkillers" probability="60" effect="40"/>
             <var illTreat="Prescription: Sumatriptan" probability="40" effect="60"/>
         </Migraine>
       </ExampleIllness>
  <ExampleTreatment>
     <PrescriptionSumatriptan>
        <var name="Prescription: Sumatriptan"/>
             <var handbook="Treatment: Sumatriptan"/>
             <var description="Requires a Pharmacy

         Sumatriptan is effective for ending or relieving the intensity of migraine and cluster headaches.It is most effective when taken early after the start of the pain. Injected sumatriptan is more effective than other formulations."/>
             <var price="350"/>
             <var task="true"/>
             <var treatment="true"/>

             <var action="GetDepartment" nr="Auto" primary="owner" secondary="dep" tertiary="" text="" pre="Auto"/>
             <var action="GetRoom" nr="Auto" primary="Pharmacy" department="dep" secondary="vPharmacy" tertiary="owner" text="Go to pharmacy" pre="Auto"/>
             <var action="MoveToRoom" nr="Auto" primary="owner" secondary="vPharmacy" tertiary="" text="" pre="Auto"/>
             <var action="GetObjectInRoomFree" nr="Auto" primary="Counter" secondary="vPharmacy" tertiary="vCounter" text=""  pre="Auto"/>
             <var action="MoveToWP" nr="Auto" primary="owner" secondary="vCounter" tertiary="infront" text="" pre="Auto"/>
             <var action="GetEmployeeNearFree" nr="Auto" isactor="true" 	primary="Nurse" department="dep" secondary="vNurse" tertiary="vCounter" text="" pre="Auto"/>
             <var action="GetObjectInRoomFree" nr="Auto" primary="Medical locker" secondary="vPharmacy" tertiary="vLocker" text="" pre="Auto"/>
             <var action="Move" nr="Auto" primary="vNurse" secondary="vLocker" 					tertiary="" text="" pre="Auto"/>
             <var action="Delay"  nr="Auto" primary="2" secondary="4" 		  					tertiary="" text="" pre="Auto"/>
             <var action="ToggleObjectInUse" nr="Auto" primary="vLocker" secondary="false" tertiary=""  text="" pre="Auto"/>
             <var action="MoveToWP" nr="Auto" primary="vNurse" secondary="vCounter" tertiary="behind" text="" pre="Auto"/>
             <var action="Face" nr="Auto" 					primary="vNurse" secondary="vCounter" tertiary="1" text="Help customer"	pre="Auto"/>
             <var action="Face" nr="Auto" primary="owner" secondary="vCounter"	      			tertiary="" text="" pre="Auto"/>
             <var action="Delay"  nr="Auto" primary="3" secondary="4" tertiary="" 	    text="" pre="Auto"/>
             <var action="Treatment" nr="Auto" primary="owner" secondary="Prescription: Sumatriptan"	tertiary=""  text="" pre="Auto"/>
             <var action="AddToInvoice" nr="Auto" primary="owner" secondary="350" tertiary="None" text="" pre="Auto"/>
             <var action="ToggleObjectInUse" nr="Auto" primary="vCounter" secondary="false" tertiary="" text="" pre="Auto"/>
             <var action="EvaluateDepartment"  nr="Auto" primary="vNurse" secondary="owner" tertiary=""  text="" pre="Auto"/>

          </PrescriptionSumatriptan>
  </ExampleTreatment>
</Resources>

```

As you can see, it requires a lot more code than *objects* or *templates.* In the Actions documentation you will find exactly what an action does and what its parameters need to be. *Primary, secondary* and *tertiary* are always specified in the Actions documentation. *(It is your friend!)*