Advertisement
Civilization Fanatics' Center

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - Modding Tutorials & Reference

Notices

Civ5 - Modding Tutorials & Reference Post tutorials, guides, and documentations related to Civ5 modding here.

Reply
 
Thread Tools
Old Sep 26, 2013, 02:15 AM   #1
epicss
Warlord
 
epicss's Avatar
 
Join Date: Mar 2012
Posts: 188
How to add Hero Units in Your MOD

This tutorial explains how to add Heroes to your MOD by extending the Civlization Allstars MOD. And you can create bridge MOD to add Heroes to other people's MOD too.

This tutorial assume you have basic knowledge of modding, can use Modbuddy, create XML files, and create iconatlas. I'll use this Civ Scotland mod to explain how to create an allstars bridge mod, to add heroes to the Scotland Civilization.

Before you start
you can try create a game with both mod enabled. Since there are no Heroes defined for Scotland, you can see the allstars mod assign some random Heroes to Scotland.
Spoiler:

This feature allow you to play a hero game with custom civilization MOD. But that's good enough, if you want to add custom heroes for Scotland, follow these steps to create a bridge mod.

Create the MOD
Create an empty MOD in Modbuddy, and add dependencies to both Allstars and Scotland MOD:
Spoiler:

The mod ID and name can be found at the head of modinfo file in the root of these mod's dir.

Add your first Hero
Now let's add William Wallace through XML file. Create a new XML file and add an "OnModActivated" -> "UpdateDatabase" entry in the "Actions" tab of mod properties page. Then enter the following codes in the XML file:
Spoiler:

Let's take a deeper look at the context of this file.

The <Type> tag is used as a string key to index the table. For easier display, this key must be the same as <Description>. Here we enter TXT_KEY_HERO_SCOTLAND_WALLACE. And add this english language string at end of file.

The <Description>, <Civilopedia> and <Help> as you may expect, are the text keys for your Hero. <Description> is the name key, <Civilopedia> is the history info of this Hero, you need to provide these text keys. <Help> is the help info, your can provide your own, or use the default ones for each Hero Class. Here we add an <Civilopedia> string from wikipedia, and use the default help key, in this case, TXT_KEY_HERO_AGILITY_HELP for agility hero.

The <PortraitIndex> and <IconAtlas> are the portrait picture for the Heroes, provide your altas in the following sizes:
256, 128, 80, 64, 45, 32
We create the SCOT_HERO_ATLAS atlas, add the arts and atlas files.

The <Civilization> defines the owner of this Hero, enter CIVILIZATION_SCOT for the Scotland Civilization.

The <TalentClass> define the start talent pillar of the Hero, the Hero's Class can be also infered from the start pillar. Hero we define Wallace as a Ranger and give him the start talent of TALENTCLASS_AGILITY. the 7 talent cass and corresponding hero class are:
Spoiler:
TALENTCLASS_SAVAGE - Berserker
TALENTCLASS_MIGHT - Martialist
TALENTCLASS_COURAGE - Paladin
TALENTCLASS_AGILITY - Ranger
TALENTCLASS_ENDURANCE - Ninja
TALENTCLASS_WISDOM - Magician
TALENTCLASS_SORCERY - Sorcerer


Add 2 more Heroes
Let's repeat to add 2 more heroes : Robert the Bruce and Princess Isabelle. For balance reason, each Civ should start with 3 heroes and they are Martialist, Ranger and Magician. Since Isabelle is a female hero, you need to add a <Female>true</Female> tag for her, so she can use female only spell.
Don't forget to add "UpdateDatabase" actions for these files.

Test in game
Test this bridge mod by enable all 3 mods together:
Spoiler:

you should be able to setup a game with Scotland heroes now:
Spoiler:


Customize your Hero
Every hero will start with default unit type, and receive a random hero trait at a different game. But you can customize these by modifing the xml file, now let's make Wallace a Highlander(UU of Scotland) and give him a trait of Flying General, which increase skill damage and grant him extra moves and promotions. You can do this by add the following two line in green:
Spoiler:
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<Heroes>
		<Row>
			<Type>TXT_KEY_HERO_SCOTLAND_WALLACE</Type>
			<Description>TXT_KEY_HERO_SCOTLAND_WALLACE</Description>
			<Civilopedia>TXT_KEY_HERO_SCOTLAND_WALLACE_PEDIA</Civilopedia>
			<Help>TXT_KEY_HERO_AGILITY_HELP</Help>
			<PortraitIndex>0</PortraitIndex>
			<IconAtlas>SCOT_HERO_ATLAS</IconAtlas>
			<Civilization>CIVILIZATION_SCOT</Civilization>
			<TalentClass>TALENTCLASS_AGILITY</TalentClass>
			<UnitType>UNIT_HIGHLANDER</UnitType>
			<HeroTraitType>HEROTRAIT_FLYING4</HeroTraitType>
		</Row>
	</Heroes>
	<Language_en_US>
		<Row Tag="TXT_KEY_HERO_SCOTLAND_WALLACE">
			<Text>William Wallace</Text>
		</Row>
		<Row Tag="TXT_KEY_HERO_SCOTLAND_WALLACE_PEDIA">
			<Text>...</Text>
		</Row>
	</Language_en_US>
</GameData>


Now rebuild your mod and check in game for the changes:
Spoiler:


The full list of Hero Traits can be found at this file in Civilization Allstars MOD:
XML\Heroes\HeroesTraits.xml

You can download this example mod here:
Example - Allstars Bridge for Civ Scotland MOD (v 1).civ5mod

And feel free to ask any questions.

Last edited by epicss; Apr 12, 2014 at 08:19 PM.
epicss is offline   Reply With Quote
Old Sep 26, 2013, 02:17 AM   #2
epicss
Warlord
 
epicss's Avatar
 
Join Date: Mar 2012
Posts: 188
Advanced features
You can also customize abilities, artifacts, hero traits and many other features of this mod by XML. And if you want to add custom effect through LUA, there are special GameEvents and LuaEvents defined, you can add LUA callback functions to these events. I'll write in more detail later.

Last edited by epicss; Apr 09, 2014 at 07:48 PM.
epicss is offline   Reply With Quote
Old Sep 29, 2013, 07:55 PM   #3
Stephan Reiken
Chieftain
 
Join Date: Sep 2013
Posts: 2
From a third party, worked for me. I just wanted to add my own heroes with their own art and descriptions. You can see the result in the last screenshot on my mod's steam page here.
Stephan Reiken is offline   Reply With Quote
Old Apr 11, 2014, 01:43 PM   #4
azurial
Chieftain
 
Join Date: Sep 2010
Location: Greece
Posts: 38
Can i add a hero from a tech, building or wonder ?
azurial is offline   Reply With Quote
Old Apr 11, 2014, 07:03 PM   #5
epicss
Warlord
 
epicss's Avatar
 
Join Date: Mar 2012
Posts: 188
you can add a hero for world wonder, replace the <Civilization>...</Civilization> tag with a wonder tag like this:
<Wonder>BUILDINGCLASS_STONEHENGE</Wonder>
the content is the wonder class of your custom wonder.

But you can not add hero for tech, since a wonder only have 1 global instance, but tech is for all players and may create duplicate hero
epicss is offline   Reply With Quote
Old Apr 12, 2014, 01:46 AM   #6
azurial
Chieftain
 
Join Date: Sep 2010
Location: Greece
Posts: 38
Thx for the info epicss
azurial is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - Modding Tutorials & Reference > [TUTORIAL] How to add Hero Units in Your MOD

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 05:43 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR