Questions for the Team

Psychic_Llamas

Wizard in the Making
Joined
Nov 25, 2005
Messages
6,366
Location
Western Australia
well, i have a couple of questions for the team about modding, and i couldnt find any threads that seemed relevent (and i really didnt want to go through the whole forum ;) ) i also thought that perhaps other people with modding questions could post here.


My questions:

1) how do you add a new promotion (such as one like Orthus's Axe)
2) how would i go about adding in a hero that is linked to a specific leader (like each of the ljosalphar leaders spawning a hero unit that is unique to them)
3) how do you make a new leader trait, and how mush is involved in making new mechanisms for a new trait (such as making a trait that grants a free unit to the first 5 cities built)

I wanted to know these because im looking at re-modding all the civs for the Warhammer mod which is based strongly off FfH, and seeing as it is currently quite similar mechanics wise you guys would be able to help out better than other modders in the other forums.
here is a link to my ideas for reworking one of the civs so you can get a better idea of what im thinking about (LINK)

Thanks
PL
 
Your probably best asking these sorts of questions in the general forum, just because there are a ton of skilled Civ4 modders out there that can answer questions like this rather than just waiting for someone on the team to answer.

I'll give this my best shot but I can promise about answering further questions in this thread. Not because Im not happy to help, in fact I spend a lot of time writing guides here because I think they are generally more helpful to the community that responding to individual questions that get buried in a few days.

1) how do you add a new promotion (such as one like Orthus's Axe)

New promotions need to be added to the CIV4PromotionInfos.xml file. There is a ton of examples

2) how would i go about adding in a hero that is linked to a specific leader (like each of the ljosalphar leaders spawning a hero unit that is unique to them)

There isnt a clean mechanism to assign a unit to a leader. You can apply units to civs like UUs (which is how we do the heroes in FfH). But its isnt that hard to use python to modify the CvGameUtils.py CannotTrain function to limit a unit to only a specific hero (ie: python coding required).

3) how do you make a new leader trait, and how mush is involved in making new mechanisms for a new trait (such as making a trait that grants a free unit to the first 5 cities built)

New traits are easy, they are just a new entry in the CIV4TraitInfos.xml file.

Making new mechanics for those traits is significantly more complex, usually requiring SDK work. But the specific trait you mentioned isn't to bad, just a python update in the CvEventManager.py in the cityBuilt function.
 
yeh, i wasnt sure where to ask this, thanks for the answers too btw :)

New promotions need to be added to the CIV4PromotionInfos.xml file. There is a ton of examples
ive searched the forums for examples of how to add promotions, but they came up blank :(

bugger, both the other things need python :(

thanks for your help, ill post the questions in the general forum too :)
 
Is there any way to negotiate a "line in the sand" between 2 cultures?
It's a real bummer to have an ally mad at you once your culture expands and deprives him/her of resources, thus leading to a possible war.
A diplomatic solution could be to fix the borders in place for a fixed, or permanent time.
Not sure how this could be implemented though.....
 
Is there any way to negotiate a "line in the sand" between 2 cultures?
It's a real bummer to have an ally mad at you once your culture expands and deprives him/her of resources, thus leading to a possible war.
A diplomatic solution could be to fix the borders in place for a fixed, or permanent time.

i wanted the same thing for awhile too not just for ffh but for all of civ 4 that would imo be a great feature.
 
Negotiable borders would be sweet. It is a PITA that "close borders spark tensions" is invariably going to force you to have enemies in any long game, but that the AI won't leave ANY open space unoccupied even with the penalty for large number of cities.
 
:bump:

now i know im being a pain, but...

im just gonna ask can someone from the team write up a tutorial on how exactly to add spells? i really want to fiddle around with spells and magic, but have no idea what files to use etc. (i know the spell tags and have all my new spells planned, just dont know how to get them working)

Thanks if someone can do this, sorry about being a pest :p
 
I wrote a guide for my team members in my RPG project, but it's for vanilla based ffh mods, not sure how much has changed since the BtS conversion.

Lemme check and get back to ya.
 
Exclaimer: This is based on my cIVRPG mod, so some parts might differ. But in essential it should help you out.

Tutorial: How to add a spell

PART 1 - XML

Preparations

  • First you need a good text editor. Now, Notepad works, but I prefer another, almost as simple, but improved editor; Notepad2. Why do I suggest Notepad2? Cause its small, fast, and it got all the features necessary like Syntax Highlighting, Auto indentation, a good Find and Replace function, etc. Get Notepad2 here!
  • Come up with the Design of your skill. Name, what it should do, etc, etc.
  • Backup the Champs mod in case you screw up!

Let's get started!

OK, the order at which we do this is not really important. Once you know what your doing, it doesn't really matter. But for simplicity, let's start with the xml\units\Civ4SpellInfos.xml file. This is the new XML file which Talchas added when he made the Spell system for Fall from Heaven 2. If your spell/skill is going to be Active it will need an entry here.

This is what the current entry of the Skill Maim Thrust looks like in my Notepad2:


Everything from <SpellInfo> to </SpellInfo> is one spell/skill. Lets go over each tag one by one.

The <Type> tag is the game's XML reference to this entry. It can actually be called anything, as long as it isn't called the same as another skill, which will mean the last one Civ4 loads will overwrite the previous one. We should call these SKILL_*** when it's a skill, SPELL_*** when it's a spell, ACTION_*** when it's an action.

The <Description> tag leads to the XML description of the skill. Just name it TXT_KEY_ + Whatever you wrote in the <Type> tag. We'll get to more about this tag later.
The <Civilopedia> tag leads to the XML civilopedia entry of the skill. Just name it TXT_KEY_ + Whatever you wrote in the <Type> tag. + _PEDIA. We'll get to more about this tag later.

The <Strategy> tag is normally the Sid's Tips part of a unit/tech etc. I'm not sure it does anything in for Spells in FfH atm, so just skip this one for now.

The <Help> tag leads to an XML entry which should describe what the skill does, it will show up in the Mousover of the skill's button. We'll get to more about this tag later.

The <PromotionPrereq1> tag should have an entry pointing to what Promotion enables the skill. The entry is the <Type> entry from the CIV4PromotionInfos.xml file. You can go back and change this later, but enter what you think you will call the promotion.

The <PromotionPrereq2> tag should almost always have NONE in it's field. The only time you should use this is when this version of the skill should be limited to a certain race or class, etc.

The <iRangeSelectNum> tag tells the game if the spell needs a target, -1 means no target, 0 means a target plot but you don't get the selection pop-up. 1 means you get the selection pop-up and you need to select 1 target from it, etc.

The <Effect> tag should link to an effect if you want one to show up. NONE means no effect obviously. EFFECT_SPELL1 is one effect for example. More effects can be found in xml\misc\CIV4EffectInfos.xml

The <Sound> tag should link to a sound if you want one. NONE means no sound. You see an example in the picture. More sounds can be found in xml\audio\Audio2DScripts.xml or xml\audio\Audio3DScripts.xml, the entry you want here is the <ScriptID> from one of those files.

The <PyResult> tag points to the Python entry for the result of this Skill. Copy what I have entered here, and Rename the MaimThrust part to whatever your skill's name is. If the skill needs a target use the (pCaster, pTarget) as it is, if not, only use (pCaster).

The <PyRequirement> tag points to the Python entry for the requirement of this Skill. Copy what I have entered here, and Rename the MaimThrust part to whatever your skill's name is.

The <PyValidUnitTargets> tag points to the Python entry for the target validation of this Skill. If your skill needs a target, copy what I have entered here, and Rename the MaimThrust part to whatever your skill's name is. If not, dont enter anything and let this field be empty like so; <PyValidUnitTargets></PyValidUnitTargets>

The <HotKey> tag's entry should be empty if you dont intend the skill to have a hotkey, if you want a hotkey, enter it like I have above. KB_A would be the A key. Be SURE to not use duplicate hotkeys for skills on one character. If you do, the whole universe could collapse.

The <Button> tag is should point to a graphics file for the ingame Button. I'm not gonna explain how to make those in this tutorial.

Ok, that was every tag you need to worry your little head about in this file.

What you should do when making a skill is Copying an entire entry of an existing Skill, Paste it in, then edit it. The above info should help you do that. Now on to the Promotions file.

You will find the file at xml\units\CIV4PromotionInfos.xml

Each promotion got many more tags than a spell, so I'm not gonna go over every one here. They are rather self-explanatory anyways. The important ones are the <Type>, <PromotionPrereq...> ones, the <PromotionNextLevel> one in some cases, and for these Promotion type Promotions (eh? Yes, the ones you pick when you level up) the <UnitCombats> is important as well.



OK, the <Type> should have the name you entered in the <PromotionPrereq1> in the SpellInfos. The <Description> tag can link to the same TXT as the one in the spell, unless you want them to differ somehow (like in the above example).

<PromotionPrereqOr1> should always point to the CLASS_ that this skill is for. The CLASS_*** is another Promotion, that exists in this file, which is given to the Unit in question.
<PromotionPrereqOr2...4> can point to other class promotions if the skill could be used by another class. Otherwise use NONE here. (Remember, these are OR statements, if you want to make the skill for a single class, move the CLASS_ promotion to the AND preReq)
<PromotionPrereqAnd1> should have the Level requirement, which also is a promotion the unit gets automatically when he levels. This might be a temporary solution for skills level requirement, but as long as we use that system, you need to do this.
<PromotionPrereqAnd2> should point to another promotion that the unit HAS to have for it to be able to get this promotion.

<PromotionNextLevel> points to the next promotion in this line of promotions. This is ONLY for graphical reasons, so that for example the Combat I-V promotions are stacked.



<UnitCombats> here, work a little differently then other tags so far. It has Sub-entries like you can see. Kind of self-explanatory. The UNITCOMBAT_MOUNTED isnt really needed for this skill, but keeping it makes it easier for copying. I should probably remove it for the sake of the civilopedia. The IMPORTANT part here, is that the promotion NEEDS the unitcombat of the units which you want to get this promotion or they wont be able to get it at level up.


Now this promotion should be done (except for the button tag at the bottom which you add in the same way as for the spell entry). This promotion shouldn't give any stats or anything since it's purpose is to open up for the active skill.

If your skill applies a buff, you should also Search for a BUFF_ and copy one, name it appropriately, and add whatever effects you deem appropriate. DO NOT add a UNITCOMBAT for a buff, since it should NOT appear as an available promotion at level up.
The <Type> should be named like this; BUFF_***_1TURNS, and you need to add one promotion for every turn the buff should last, for example; BUFF_***_4TURNS, BUFF_***_3TURNS, BUFF_***_2TURNS, BUFF_***_1TURNS.
You could also add TECH_NEVER to the <TechPrereq> tag, to make sure you can't get the promotion in any way (except through your skill). I'm not entirely sure if this is needed, but I seem to have done this with every buff so far. ;)

Now, the last thing that needs to be done in XML is adding the TXT_ entries, etc. This isn't a requirement for it to work, but it sure looks better.

Spoiler Example :


That should be all for the XML part of this tutorial. If I've forgotten anything, or if anything should be unclear, please post and I'll update.



 
PART 2 - PYTHON

OK, so you've created the necessary XML entries and want to add the actual skill script. First, locate the python folder in the ...\Assets\ folder, go inside it. Here we got One file you need to edit; FFHSpells.py. Open it with Notepad2, scroll down till you find the other skills I've already added.

Here's my maim thrust code.

As you can see, these are the functions that the first XML file we edited pointed to.

The first function, reqSkillMaimThrust() is very simple. What it does is check if the caster has 2 action points or not, and it will return True or False. The do.hasActionPoints() is a function from the CustomFunctions file which I've written to make this as simple as possible for me and you. Exclaimer: Actionpoints and this function are specific to my cIVRPG mod.

The 2nd function, skillMaimThrust() is the actual effect of the skill, the (caster, target) is the pCaster and pTarget we sent with the function from the XML.
pPlot = target is pretty unnecessary, I could just have called it pPlot in the (caster, target) part. But this way, its easier to see that the pPlot comes from the target (from the xml).
pUnit is then derived by getting the best defender from the plot, with the function you see on the next row.
And finally, we do damage to the pUnit, on the 3rd row. the doDamage function is part of the Unit object, thats why you call it by doing a pUnit.doDamage(). The attributes you send with doDamage is in order; Type of damage, 0 means physical, 1 means Cold, 2 Death, 3 Fire, 4 Holy, 5 Lightning, 6 Poison and 7 Unholy. The next attribute, which in this case is false, is whether it's a spell or not. False means it's not a spell, and True means its a spell. The next attribute is the damage limit of the skill, the one after that how many action points the skill uses up. The 2nd last attribute is the CritRate of this skill and the last attribute is the object of the attacker, which in this case is caster.
Exclaimer: This doDamage function differs from the FfH version of the same function. Check other spells from FfH for the correct function.

validMaimThrust() creates a list of all the valid targets on the plot. This list is never used for this skill, but it has to be larger then 0 or the skill cant be used. The if inRange(caster, pPlot, 1) == false part makes sure that a populated list can only be returned if you click within 1 tiles range in this case.
The actual check only checks if the units in the plot is of another owner than the attacker, and if so adds them to the list.

Now, if you've copied everything I've done so far, you should copy these three functions, and rename them appropriately.

I'm not gonna explain how to program with python, but Gingerbread Man has written a pretty good tutorial here. It's the tutorial from the thread; Let's learn how to mod Civ4 today! or something such, but more up to date, and it got a civ4 module documentation of every function from vanilla civ4 that is exposed to python.

Now, you don't need to know python to add these skills. Not if you are just gonna make new skills that work similar to other skills we already have. Then you just have to do like above, and copy, rename, and maybe edit some values.

A tip is also to check the FFHSpells.py file from FallFromHeaven2, to see how they made some of their spells.

That's all for now. Post if you require clarification or additional help.
 
Ok, so ive got the spells working. now i want to add this one spell which adds a promotion wit hthe same mechanic that the 'mutated' promotion uses. ie granting benefits from a random selection of promotions. this is what i want to do:

SPELL: SUMMON SPITE SWARM:
---Buff Spells
---AddPromotionType1-'Spite Swarm'. uses mechanism that FfH 'mutation' does in that it gives each unit in the stack a random promotion (all permanent) selected from the list below:
-A Blight of terrors (unit causes Fear)
-A befuddlement of Mischiefs (can cast "Mischiefs" spell which adds the 'stupidity' promotion to the nearest enemy unit.)
-A Murder of Spites (+1 poison attack bonus and +1 first strike)
-A Muster of malevolents (+1 magic and 1 +poison attack bonus)
-An Annoyance of Netlings (counters opponents first strike bonuses)
-A Resplendence of Luminescents (+2 magical attack damage)
-A Lamentation of Despairs (one use only, can cast "Despairs" spell. target unit takes leadership test, or lose 75% strength permanently. dosnt effect heroes.)
-A Cluster of Radiants (unit is more resistant to magic)
-A Pageant of Shrikes (unit can cast "shrikes' on target unit (selected from stack like assassins) which deals 30% poison damage.)

so, can someone please explain how i can change this mutation mechanic to do what i want? and also please point me to the code that does this (and as a bonus, explain it to me :p)

i know there is a tag <bMutation>0</bMutation> or <bMutation>1</bMutation> to say whether that promotion is one of those that can become a mutation, but i want to keep the original mutaions and add mine, so im guessing ill need to duplicate this tag?
 
The reason I created the mutation mechanic is because its called from so many places. The freak always starts mutated, mutation is applied to units randomly because of buildings/bonuses in the building city, mutation can be applied by events or spell. In that case it was easier for me to make a mutation mechanic they could all call into.

In your case I would try to make a second mutation mechanic. Of course you could add the attribute and make all the SDK changes required to do it. But in the end its going to be so much simplier for you just to create a python script that has a 10% (or whatever you want) chance of applying each of the prmotions you listed instead of making a new mechanic.
 
And create a promotion that is always applied to the unit which makes them immune to the spell being cast on them again. That way you get Mutation's 1 time only functionality, which is probably mainly what you are after?


Also, if you are aiming to be like mutation, remember that things can be BAD from mutation. Your list is all quite beneficial. But if that is what you want, then it does look interesting.
 
Top Bottom