Hegemony III: Clash of the Ancients

Hegemony III: Clash of the Ancients

Not enough ratings
My Way to Modding
By Canute VII
An Introduction to Modding Hegemony III: Clash of the Ancients
   
Award
Favorite
Favorited
Unfavorite
What is a Mod?
Mods, short for 'modifications', are changes or additions to Hegemony III created by its players. The purpose of a mod is to change the game and add an extra dimension of customization and replayability.

A mod can range from a total conversion with new gameplay, look and feel through to minor alterations which could include new brigades, maps, skills etc. A mod can be anything the creator(s) want(s) it to be!

Here's the good news: anyone can mod, whether you consider yourself a coder, an artist or a musician. Having fun with tinkering certainly helps, however.
Why Mod?
There's a number of potential reasons you might want to create a mod:
  • patch the game to remove a feature you don't like or conversely add something you miss
  • learn new skills
  • express yourself artistically
  • get a foot into the door of the video game industry
  • have fun

Your mod might be as small as changing just one single attribute of a brigade ("Yes, legions should absolutely have +200% morale!") or as big as creating a completely new scenario ("Ha, the Punic Wars!") or mechanic ("Vassalage!" anyone?).

You don't necessarily need to be able to code, either. As long as you just want to change some stats or create a new map or game art, no coding is required at all! True, coding is a key modding skill once you really want to create advanced features, but there are modders who specialize in graphics, sound and map design as well.
Type of Mods
Typically, the following objects lend themselves to starting to learn to mod Hegemony III:
  • a new map and/or faction
  • a new brigade or stance
  • a new city or brigade upgrade
  • a new skill or skill tree
  • a new event and/or quest
  • an new localization / language

Longbow has created a very helpful series of Modding Tutorials and a Map Editing Video Tutorial, covering each of these objects.

Official Entity files from the game can be accessed at Longbow's Google Drive [drive.google.com] and are an important prerequisite for modding, since most relevant files are not simply available in the game folder per se.

Gernerally speaking, there are various type of mods classified according to size and contents:
  • An add-on or addon is a typically small mod which adds one particular element to the original content of the game.
  • An overhaul mod significantly changes an entire game's graphics and gameplay, usually with the intent to improve on the original, but not going as far as being a completely different experience. This can also include adding revised GUI and music.
  • A total conversion is a mod of an existing game that replaces virtually all of the artistic assets in the original game, and sometimes core aspects of gameplay. Total conversions can result in a completely different genre from the original.
Needless to say, that you should start with creating smaller add-on mods. Building an overhaul mod or even total conversion mod often requires months if not years of deligent work, often by a modding team.

The Mod Folder
Whatever your interest, try to start with something small and simple and build your skills from there. A good way is to download a small existing mod from the steam workshop and try to understand what the modder did there. For example, we're going to subscribe to the "Long-Ranged Stance" mod.




The mod will show up in \\Steam\steamapps\workshop\content\308173\steamid, where steamid is a number under which Steam registers the mod.



You may even copy the mod to your personal mod folder, tweak the files to your liking and see how that works out in game. To create a mod, you'll need to

  • create a folder for the mod in My Documents/Longbow Digital Arts/Hegemony III/Mods/BestModEver
  • create a .../BestModEver/Resources folder, where you will later place all the functional mod files
  • possibly add a cover.str into /BestModEver folder to contain a short description of your mod and
  • add a guicover.png file which will later be shown in the Steam workshop as your mods trademark picture (*.png files definitely work, *.jpg less so), also into /BestModEver folder

That's it and you're good to go!

At this point, however, even if the BestModEver will already show up in your game, your mod doesn't have any functional contents. So the next step is to create files in the /BestModEver/Resources folder, that will actually change the game!
Tweaking the Files
Now that you have the files at your disposal, you can dive into the Resources folder and see what you would like to change. For our mod there are two image files, which we take as given, and a text file with descriptions that will show up in game ("rangedstances.str").



For the latter, only the marked text is relevant (there's some more text before that, but we don't really need that). So if you just want to rewrite e.g. a tooptip, then this is the place to go. Here you can add your own personalized description of the modded stance (Name and/or Tooltip).



However, if you want to tweak the effects of the longrange stance, then you need to look at the "longrange.xnt" file. Let's try and tweak this! The two highlighted lines are those that add the effects:
  • missilerange will be increased by 40% and
  • missiledamage will be decreased by 30%



We can simply change this into:

Easy Coding
Configuration files are simply files which contain a list of instructions for the Source engine to perform. The instructions are developer console commands, so therefore anything that can be typed in the console can be placed in a configuration file.

The wiki features a list of common console commands[hegemony.fandom.com] and it is a good idea to make yourself familiar with using them. Instead tweaking the file in above example, you could also select a brigade in-game, open the console using the F2 key and then type in these commands:

getselected():setattribute("missilerange", 0.4, mult);
getselected():setattribute("missiledamage", -0.3, mult);



This will permanently apply the attributes to the single selected brigade instead of tying them to a stance.



It's now easy to see how these commands - instead of typing them into the console manually - can be written into a file, from where the game executes them automatically. Add some conditions, when you would like that to happen (at game start? for your king/general, hurray?) and you already have an idea for an event.

Coding in it's simplest form is really just about defining the conditions, when such instructions should be executed, and combining these with the intended instructions (aka console commands). This can be a rather simple event with a simple structure.

If, however, you want to add more logic, e.g. the effects should be applied to your 7th brigade, because this is a lucky number, then some more instructions are required. For example, to find out how many brigades of a specific type (e.g. generals) you have, you need to loop through all your brigades, determine if it's a general or not and count the generals.

To do this, a bit of more intricate coding know-how is required, but it's easy to pick up. Hegemony uses the scipting language LUA[www.lua.org] (portuguese for "Moon"), which is beginner friendly and is widely used in the modding community.
Workshop Integration
You can create a mod for you to enjoy privately or you can share your mod with others, either on ModDB and/or on the Steam Workshop.

To upload a mod to the steam workshop, open a save game and press F2, this will open the console window. Here you can enter the workshopupload() script command. In our example enter workshopupload("BestModEver") and your mod will be created in the Steam workshop!



You can add more details like a title and description or screenshots illustrating your mod later in the workshop:



Your mod in Steam is hidden from the public and private until you publish it.



in the /BestModEver folder appears a little text file "steamid.txt", which contains the steam ID of your mod. Later on you can update your mod in the Steam workshop using the very same workshopupload("BestModEver") command.

Hint: Currently, there's a little bug, however, with how the game generates a Steam ID for your mod. You can fix it by going to your steam workshop in a webbrowser and then you read the steam id off the internet adress: it's the long positive number at the end. Now just copy this number and overwrite the negative number in the steamid.txt file.

Hint 2: if the upload to steam fails with an error message "Limit exceeded" that usually means that you need to scale down your guicover image
Modding Resources
Longbow has created a very helpful series of modding tutorials, which you may find here:

Modding Tutorial Index

For an introduction how to set up new maps and use the map editor, here's an introductory video tutorial series:

Map Editing Video Series

These video tutorials should be consumed in conjunction with the following additional map modding guides, which kind of fill in the gaps:

Additional Steps 1 & 2 & 3 & 4

There is also plenty of information on the Official Wiki:

Modding Repository on the Official H3:CotA Wiki [hegemony.fandom.com]

Longbow offers a variety of tools and assets such as entity files or StringWrangler.exe to edit .str files:

Tools and Assets on Longbow's Google Drive [drive.google.com]

Online version of the first edition of the book Programming in Lua, a detailed and authoritative introduction to all aspects of Lua programming written by Lua's chief architect:

Programming in Lua[www.lua.org]

If you get stuck, then the Steam Workshop Discussion Forum is a good place to search for answers or ask modding questions:

Workshop Discussion Forum
2 Comments
Canute VII  [author] 27 Jul, 2021 @ 10:34am 
Ah, I knew there would be something I've missed. I have added a hint to StringWrangler and your map modding guides in the resources section, now. Cheers!
Fristi61 27 Jul, 2021 @ 9:44am 
Interesting, you prefer not to use Stringwrangler for .str file editing?

I'd also like to point out that the Map Editing Video series is incomplete and missing several steps necessary to making playable custom maps. For that reason, I made these tutorials that cover the last required steps and would like to submit them for addition to the 'Modding Resources' page at the end in some format:

https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=830903307
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=842088401
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=880513993

Otherwise excellent guide :)