Most of my monsters have configurable settings. This tutorial will show you how to set that up. I will be using the MagdalenaMonster we made in the first tutorial. The magdalena base class can be downloaded from here:Magdalana Base Class
Its usually best to assign variables at the beginning of the script in a function like PostBeginPlay(). To make them configurable we need to declare this at the top when we first create them with the special “config” property. We also need to declare what the config file (.ini) file is called. We do this on the very top line. In this tutorial I have chosen 3 different default properties to make configurable.
class MagdalenaMonster extends Monster config(MyMagdalenaConfigs); var config float NewHealth; var config float NewJumpZ; var config float NewGroundSpeed; simulated function PostBeginPlay() { Super.PostBeginPlay(); Health = NewHealth; JumpZ = NewJumpZ; GroundSpeed = NewGroundSpeed; }
Ok, so here I have said that our monster (MagdalenaMonster) extends Monster and is configurable in the MyMagdalenaConfigs.ini file. Then I have declared 3 new global variables and have said these are to be configured. In PostBeginPlay I have assigned these to the relevant properties we want to change. Please note if the .ini file is missing when you play the game these settings will default to 0. To avoid this you can place the configurable properties in the defaults so the monster has some settings to fall back on. I generally set the defaults to the default of whatever we was changing. Like so.
defaultproperties { NewHealth=100 NewJumpZ=340 NewGroundSpeed=440 }
Now for the .ini file. The .ini file must go in the \System folder. To make it simply create a new file and change the extension to .ini or copy and paste an existing .ini file and rename it. If your computer will not allow you to change the extension by simply renaming it then you might need to set up your folders with “Hide extensions for known file types” turned off. To do this in WindowsXP in a navigation window go to Tools>Folder Options… on the top bar.
Then go to the View tab, scroll down to where it says “Hide extensions for known file types” and make sure it is dechecked.
Now when you try to change the file type by renaming something it should allow it. For example create a new Text Document. Right click it and click rename or double click the files name to highlight it. Now type in for the new name something like “MyMagdalenaConfigs.ini” without the quotation marks and hit return/enter. This should now successfully rename and the icon should also change. For other operating systems you will have to google it!
Finally the .ini file itself. In the .ini file you need to create the correct subheading that holds our config options. Because our configurable properties were declared in the “MyMagdalenaMonster.MagdalenaMonster” class that is the heading we need. Under the heading we then type in our configurable properties. Its as easy as that!
If you want to give the server admin or instant action player the choice to disable these or enable these then simply add a configurable boolean variable like “UseConfigs” and check this in the PostBeginPlay before you assign the new settings. Your code would then look like this. Don’t forget to update the .ini file with the new option!
var config float NewHealth; var config float NewJumpZ; var config float NewGroundSpeed; var config bool UseConfigs; simulated function PostBeginPlay() { Super.PostBeginPlay(); if(UseConfigs == true) { Health = NewHealth; JumpZ = NewJumpZ; GroundSpeed = NewGroundSpeed; } } defaultproperties { UseConfigs=true NewHealth=100 NewJumpZ=340 NewGroundSpeed=440 }
TIP – Making things configurable can really help to customize monsters. But don’t make everything configurable. Stick to appropriate things.
Recent Comments