[Tutorial] How to create a balance mod

By on November 20, 2009 7:25:28 PM from Demigod Forums Demigod Forums

pacov

Join Date 02/2008
+182

Hi all.  I'm not exactly great at modding, but I've recently learned quite a few things that I am happy to share.  So, if you are interested in learning how to create your own balance mod, read on.  Also, be aware that I do speak a few programming languages, but don't fully understand lua.  Enough to get by, but that's about it. 

Sorian provided a basic example for the community to use for modding called Boots of Better Speed.  The boots of better speed mod can be downloaded here: http://sorian-ai-mod.googlecode.com/files/Boots%20of%20better%20speed.zip and was originally posted/discussed here: http://forums.demigodthegame.com/369563

Start by downloading the zip file linked above.  Just extract it to your desktop for now and then open the folder that was created. 

MOD_INFO.LUA

Open up mod_info.lua using notepad if you like.  Take a moment to look over the file.  Not alot of cool code going on here, but it provides quite a bit of information that will appear in the mod manager later.  Sorian was kind enough to provide several inline comments in the lua code.  For those of you not familiar with the language, -- means comment or REM in old dos speak.  You can write notes, etc, in lua by inputing -- followed by text, etc.  Moving on.  The info that really makes a big difference is as follows: 

exclusive = false
ui_only = false
uid = "48C629B6-09B1-11DC-9B89-F34356D89598"

Again, Sorian's comments come in handy.  Exclusive can be set to true or false.  If it's set to true, then this is the ONLY mod that can be active.  I'm guessing most mods will have false as the value for this setting.   

ui_only means this mod is a UI mod and can be used even if other players are not using it.  Bottom line, you can have this type of mod running in MP even if no one else does. 

UID - per Sorian, this has to be a unique value and he provided a link in the mod_info.lua file to a uid generator.  I used that when I created my own mod.  I don't know why or how the uid itself works within the mod, other than to say that it works within the mod.

Ok.  We are done looking at MOD_INFO.lua for now.  Let's learn some more.  Start moving through the directories in the extracted zip file.  Double click on hook, then lua, then common, then items and boom.  Now you find a file called Boot_Items.lua.  This is where the actual coding will take place for the mod. 

BOOT_ITEMS.LUA

Open up the file in notepad if you like.  Take a moment and look over the file now.  Things that came to my mind initially was the naming conventions I was seeing.  I know what Boots of speed means, but its tied somehow to ITEM_BOOT_0002 and Item_Boot_020.  This also meant to me that most likely, all of the items in the game have some sort of other name (eg boots of speed is really item_boot_020 in the game).  Anyway, going on that understanding, I wanted to figure out what the names were for the other items.  This led me to dgdata.zip

DGDATA.ZIP

Find your demigod folder.  For me, its "C:\Program Files (x86)\Stardock Games\Demigod".  Double click on dgdata.zip.  Remember a few steps back when we opened boot_items.lua?  Well, we had to step through several directories to get there (hook\lua\common\items\).  What we stepped through there is essentially what we'll step through in the dgdata.zip file.  Click on lua, then common, then items.  Notice what you see in the folder now?  All of the code for various items is broken out into separate files.  Take a look at boot_items.lua.  Now, look back at the code for the mod that Sorian compiled.  See how he simply copied and pasted information from this file there?  If you dig a little deeper, you can see the exact changes that he made to give boots of speed a 200% buff instead of the default 10% buff.  And you can follow the same process to make your own modified items. 

Anyway, I played around with this for about 5 minutes and was able to make a simple mod that increased the health and mana for footman's sabatons. 

How to make your own item balance mod

For now, just focus on creating 1 modified item.  Pick some type of boots to simplify things for now.  Pick one that you want to tweak and then move on.  Use Sorian's mod as a template.  Extract the zip file you downloaded.  Rename the folder to whatever you want to call the mod.  Update the mod_info.lua file with your info.  Generate a new UID using the link Sorian provided and insert that into the mod_info.lua file.  Save the mod_info.lua file.  Open the boot_items.lua in both dgdata.zip and within your new mod folder structure.  Go ahead and clear the results in the mod boot_items.lua.  You'll be copying and pasting info from the dgdata.zip boot_items.lua.  Find the item you want to modify in the dgdata.zip boot_items.lua.  Select the appropriate item's code.  For instance, if you wanted to modify the assassin's footguards, you'd start selecting the line above assassin's footguards in the code and copy all the way down to the final }.  It should look like this:

########################
#Assassin's Footguards
########################
ItemBlueprint {
A BUNCH OF OTHER CODE THAT I'M NOT LISTING HERE
                        }
            }
}

Select all of that code only and copy it.  Flip back to your mod version of boot_items.lua (that you blanked out earlier).  You'll paste this data in a moment, but you need to do one more thing.  At the top of the file, type in the following:

do

Then hit enter twice.  Now, paste the code in.  It should look like:

do

########################
#Assassin's Footguards
########################
ItemBlueprint {
A BUNCH OF OTHER CODE THAT I'M NOT LISTING HERE
                        }
            }
}

At the very bottom of the code after the last }, hit enter twice and enter the following:

end

So, the final product of your modded boot_items.lua file should look like this:

do

########################
#Assassin's Footguards
########################
ItemBlueprint {
A BUNCH OF OTHER CODE THAT I'M NOT LISTING HERE
                        }
            }
}

end

Save the file.  Examine the code for assassin's footguards now in your file.  Modify the appropriate values to implement a change.  For instance, change Evasion = {Add = 10}, to Evasion = {Add = 25},.  Save the file again.  Navigate to C:\Program Files (x86)\Stardock Games\Demigod\bindata\mods or whatever it is on your computer and paste the entire mod folder you created in there.  Launch demigod, enable it in the mod manager, and try it out in single player or multiplayer vs an AI.  See if you change took.  Worked for me.

Locked Post 13 Replies
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 7:25:33 PM from Demigod Forums Demigod Forums

NT

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 7:47:40 PM from Demigod Forums Demigod Forums

It should be extremely easy to balance things now. Thanks pacov!

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 8:02:05 PM from Demigod Forums Demigod Forums

nope, the scripting is the least work that has to be done to balance the game.

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 8:16:44 PM from Demigod Forums Demigod Forums

nope, the scripting is the least work that has to be done to balance the game.

yeah... we can at least do the work ourselves though

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 10:59:59 PM from Demigod Forums Demigod Forums

LOL pacov!

I did exactly the same thing to figure out how the basic things work, but with Chirmaya's mod of boots.

And then i read your post here.

LOL if i had read your post earlier i would have saved time from figuring it out on my own.

Oh well....at least scripts are easy 

Edit: btw Sorian forgot to add some of the code listed in the original LUA files for his sample mod. The code that specifies your minions movement speed. Normally your minions have the same speed your demigod has. And if you get a speed item, like "boots of speed", your minions speed increase automatically. This code is missed from his sample. I have a feeling that he did it on purpose....

In order for us noobs to spot it and correct it.......

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 11:17:07 PM from Demigod Forums Demigod Forums

LOL if i had read your post earlier

Yah blew it

hehe!

Reason for Karma (Optional)
Successfully updated karma reason!
November 20, 2009 11:21:32 PM from Demigod Forums Demigod Forums

The UID is needed to differentiate mods. If two mods have the same UID, only one will be shown. You might want to add this into your post and tell people to make theirs different.

Reason for Karma (Optional)
Successfully updated karma reason!
November 23, 2009 1:05:07 PM from Demigod Forums Demigod Forums

new title.  woooooo

Reason for Karma (Optional)
Successfully updated karma reason!
January 2, 2010 11:49:02 AM from Demigod Forums Demigod Forums

I read DeadMG's post on 'Hooking' and I didnt quite understand it. Is there anywhere I could find more info on that?

Reason for Karma (Optional)
Successfully updated karma reason!
February 1, 2010 11:03:16 AM from Demigod Forums Demigod Forums

This tutorial needs to also mention how to change costs.

Clearly it can be done, as mods have done it, but there is no info on doing such a thing that I could find with search.

Reason for Karma (Optional)
Successfully updated karma reason!
February 2, 2010 12:03:12 PM from Demigod Forums Demigod Forums

costs are avaliable in the shop_unit.bp

For example if you want to change achievement item costs goto:

dgdata.zip/units/ug/b/ugbshop08/ugbshop08_unit.bp

now scroll to the bottom and you will see: (as an example)

                    #Optic Enhancement
            AchievementOptics = {
                Cost = 1,
                ItemBP = 'AchievementOptics',
        },

Edit the bolded section above.

Reason for Karma (Optional)
Successfully updated karma reason!
February 2, 2010 1:02:01 PM from Demigod Forums Demigod Forums

This tutorial needs to also mention how to change costs.

Clearly it can be done, as mods have done it, but there is no info on doing such a thing that I could find with search.

That would be nice, but I didn't even know how to do it outside of exxcentric making his post.  Thanks Exxcentric!

Reason for Karma (Optional)
Successfully updated karma reason!
February 3, 2010 3:36:11 AM from Demigod Forums Demigod Forums

NP! if anyone wants any other help/has questions with coding post it up.

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #101114  walnut1   Server Load Time: 00:00:00.0000828   Page Render Time:

Stardock Magazine | Register | Online Privacy Policy | Terms of Use

Copyright © 2016 Stardock Entertainment and Gas Powered Games. Demigod is a trademark of Gas Powered Games. All rights reserved. All other trademarks and copyrights are the properties of their respective owners. Windows, the Windows Vista Start button and Xbox 360 are trademarks of the Microsoft group of companies, and 'Games for Windows' and the Windows Vista Start button logo are used under license from Microsoft. © 2012 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc.