Modders Guide to FfH2

Xienwolf's Woodsman promotion works neat.

I got the error when I tried to update:
TerrainDefenses
TerrainType
iTerrainDefense
TerrainType
iTerrainDefense

With:
TerrainDefenses
TerrainType: TERRAIN_JUNGLE
iTerrainDefense: 40
TerrainType: TERRAIN_FOREST
iTerrainDefense: 20



As for the FfH Editor error, you get it when you click on the "Export Unit Information" Even if you have not made any changes.
Attached is a screen shot of the error.
 

Attachments

  • Error.jpg
    Error.jpg
    46.1 KB · Views: 136
Hmm...I was just thinking. Would it be possible to add targeted spells work though the airstrike mechanism (with SDL changes of course) ? I'm talking offensive spells that target tiles of course, not those that target specific units.

I was thinking that if you could it would give us more control over spells, be faster than python (which often seemed to freeze up when the old targeted spell mechanism was in effect), and possibly even be easier for the AI to understand (since they don't have a problem with airstrikes). Of course, it could be complicated by the fact that they may have multiple ranged spells available to them.

It would probably take considerable work, but I do really want to have the ability to target spells eventually, and think that handling them in the SDK would probably make the game run more smoothly.
 
I do believe you could do that through a promotion with a 100% chance to wear off which raises the mage's Rangecombat stat. Only problem there is you are unable to set a CombatLimit to keep the spell from being able to fully kill. Benefit is that the mage can actually gain XP this way.


It would be nice if a Promotion could affect your Combat Limit. Many spell ideas could be had to cause a unit to become unable to filly damage other units, it would be an enjoyable mechanic to play with.
 
Yes, I am stumped.

I tried to add a new unit to FfH2 game. Just to play around, i made a separate copy of the entire FfH2 mod directory, called it something else and revised all internal references.

I then set about, as an expiriment, creating a new equipment object called a POTION_OF_FLYING. I basically found all instances of HEALING_SALVE and TAKE_HEALING_SALVE etc. in the python files and xml files, copied the block and then altered to POTION_OF FLYING references. I even changed the associated python script to make the spell grant the promotion of flying.

So the only thing different from FfH2 is the new option unit, and its associated spells and promotions.

After doing all this, the mod loaded fine. But the new unit IS NOT accessable in the worldbuilder, or anywhere in the civilopedia.

What did I miss?

Do I need to change the dll file, too?

Please help!
 
That does not seem to be the problem: unit class is as below

<UnitClassInfo>
<Type>EQUIPMENTCLASS_POTION_OF_FLYING</Type>
<Description>TXT_KEY_EQUIPMENT_POTION_OF_FLYING</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>-1</iMaxPlayerInstances>
<iInstanceCostModifier>0</iInstanceCostModifier>
<DefaultUnit>EQUIPMENT_POTION_OF_FLYING</DefaultUnit>
</UnitClassInfo>


Any other suggestions?
 
Yes, I am stumped.

I tried to add a new unit to FfH2 game. Just to play around, i made a separate copy of the entire FfH2 mod directory, called it something else and revised all internal references.

I then set about, as an expiriment, creating a new equipment object called a POTION_OF_FLYING. I basically found all instances of HEALING_SALVE and TAKE_HEALING_SALVE etc. in the python files and xml files, copied the block and then altered to POTION_OF FLYING references. I even changed the associated python script to make the spell grant the promotion of flying.

So the only thing different from FfH2 is the new option unit, and its associated spells and promotions.

After doing all this, the mod loaded fine. But the new unit IS NOT accessable in the worldbuilder, or anywhere in the civilopedia.

What did I miss?

Do I need to change the dll file, too?

Please help!

Your probably not running your new mod. The shortcut is probably still pointing back to the original FfH directory.
 
Your probably not running your new mod. The shortcut is probably still pointing back to the original FfH directory.

The shortcut was okay, but I did figure out what I was doing wrong. I was using open office write to edit xml and python file. I suspect it caused them to lose some formatting that made CIV4 just sort of ignore them.

I downloaded Notepad++ for xml and Python 2.5 for the python files. My initial test change to the xml (changing warrior strength to 6) finally showed up iin the mod, so I think I'm on the right track now.

Thanks for all the good suggestions!
 
I downloaded Notepad++ for xml and Python 2.5 for the python files.

Be carefull when you introduce a new python function with python . Civ4 use python 2.4 .

Tcho !
 
Turns out the problem I had was definitely with the XML files.

Do I even really need Python? Isn't it possible to edit the Python files with notepad? Or is there hidden formatting there, too?

Incidentaly, I now have a cool, operational "Potion of Command." If anyone can tell me a clean way to package it, I'd be happy to share. Right now, the XML additions are scattered all over several XML files.

Cheers!
 
Looks like notepad works fine for the simpler python files.

I need a suggestion however:

I am trying to create a section in the cvSpellInterface file that sets the requirements to cast a new spell.

It works, but I want to add a few lines in the "def reqNewSpell (caster): sections of the file. How do I look to see if the caster has a certain promotion and, if he does, deny access to the spell?

I tried this:

if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_VAMPIRE')):
return False

and the engine choked on it. If I simply "#" comment out those offending lines, everything works fine otherwise. Edit: in the text box above it looks like there is a space between "PRO" and "MOTION." There isn't.

Any suggestions?

BTW, is it okay for me to be asking coding questions in this thread, as long as they are specific to FfH2?

Thanks!
 
And what a difference a single parenthesis makes!

I had the attempted code correct in my post, but when I checked the actual game file, I had dropped out the penultimate closing parenthesis. Duh.

The spells work perfectly fine now. Thanks for all of the patient help!

It is now possible in my mod for units to "steal" horses and other livestock bonuses off of the map, wrangle them to a new location, and then set them free.

If anyone is interested in how to do this, I'd be happy to post the coding examples.

Cheers!
 
Any idea where the XML code is that determines what religion a unit has upon creation? I've been unsuccessful at locating a line anywhere that affect the outcome one way or the other, it seems completely random.

I'm a bit frustrated, because while I have successfully managed to create Faeryl's Hero with the CoE tag in one game, I have been completely thwarted in trying to produce Sandalphon's Rathus with the CoE religious tag attached.

Any advice?:confused:
 
Thanks alot, Xien! :) That can't be the way that the program decides what religion to assign random units, though, can it? I've done some testing, and with only CoE in a city, and CoE adopted as the state religion, I still only get, at most, one unit in three being born with the CoE religion tag (and thus all the cool stealing/masking abilities), the rest having no religion at all. Is there a % flag somewhere that the program checks against when creating a new unit to see what religion, if any it will adopt?

I can fall back on the Unit Infos to change Rathus in particular, but that will be awkward in my next game where I take the OO route with the Sidar, instead of the CoE and he is created with the CoE flag and I don't even have that religion yet...

Your thoughts?
 
I think he means how are religions randomly assigned to units in a city with said religions (it won't effect units that start with the religion to begin with).

That would actually be Python or C++ code, but it would probably have to read some xml. I've actually been looking for this myself, but haven't founded it yet.
 
Well I can tell you that it isn't done through Python. If it was it would be done in the CvEventManager.py under def onUnitBuilt(self, argsList):
, but there is nothing in that section about religions. Cult of the Dragon is done there however, not that it helps much.
 
Did a broader search for religious information, found that the Olympic Games event information is still in the Python for FfH :p Among a few other old Vanilla Event code lines. Also found that we still have code available for selecting your own religion, even though that is most certainly NOT an option for FfH.


Anyway, if you want to set it up yourself, the important lines will be:

Code:
	iReligion = pPlayer.getStateReligion()
			newUnit.setReligion(iReligion)

You'll need more than just that, but put it in the proper format in the proper location in the def onUnitBuilt section and you should be able to define the religious aspect of a unit yourself.

Grabbed that code from Religious Fervor, which is the only place in all of the python to use setReligion.
 
Back
Top Bottom