Modders Guide to FfH2

I'm thinking about adding a gatherer unit for a mod, similar to the resource crawlers from Alpha Centauri. That, or a gather command for workers. You would park the unit on an unimproved tile in the BFC of one of your cities and choose (through a custom dialog or separate action buttons/hotkeys) whether you want to gather food, production, or commerce. The amount gathered would be the bonus added by the most appropriate raw resource tile improvement (i.e. not cottages), if any. So, on a plains tile you would have the option to gather 1 food per turn as if you'd built a farm. On a plains tile with a horse resource you would have the option to gather either 2 production or 1 commerce per turn as if you'd built a pasture. You wouldn't be able to gather food because a more specific improvement can be built than a farm. One gatherer per tile, one bonus type (food/hammers/commerce) per gatherer, and you can't gather from a tile with an improvement built. So gatherers are like mobile ghetto improvements, except that they need to be built, stop growth while being built, are as vulnerable as workers/settlers, and cost maintenance.

Can anyone tell me how I'd go about implementing this? Can I do this with Python or would I need to modify the DLL? Thanks!
 
To add new actions you'll need to use the DLL. The tricky bit will be to determine what the best possible improvement is for each yield type, unless you only allow them one option, then you just have to determine flat out which improvement provides the most gain for the tile.

I think that the easiest implementation once you got the command created would be to modify the tile yields themselves, but then a city still has to work the tile, which you may not be aiming for (but if they are supposed to work like a mobile improvement that is EXACTLY what you are aiming for). Just be careful to ensure that if the unit moves/dies it clears the tile back to basic values.
 
Is the text on the action button tooltip static, or is there a way to set it dynamically? If yield gathered depends on terrain and whether a bonus is present, I'm going to need to show the player exactly what they're going to get.
 
Thanks for the replies. Is there anything I need to know about tech prereqs? I've been trying to get my tech tree into the game, but getting the prereqs to work is driving me crazy. I know the XML is formatted properly, I know there are no typos, and I know about OrPreReqs/AndPreReqs. New techs I add have prereqs assigned seemingly at random, sometimes to each other, and existing techs refuse to accept the ones I assign.
 
You mean graphically, or when researching them, or checking the Pedia screen? Graphically there are some funky issues to deal with to get the arrows to work how you want them to in the tree IIRC, haven't dealt with them personally, so someone else will have to assist you there. I'd say check the pedia and attempt researching them yourself to see if things are working properly outside of the tech tree drawing itself.
 
I figured it out. When you modify techs in a module, the prereqs use the named tech's index in the original CIV4TechInfos.xml file. I was inserting my new techs so everything is in alphabetical order, which changed the indexes around.

Thanks again.
 
All I had to do was add new techs after the existing entries, rather than mixing them in. If you need to reference labels from another file, like for tech names, you just make sure the files are named so they load in alphabetical order:

Fall from Heaven 2\Assets\Module\MyModule\MyModule1_CIV4GameText.xml
Fall from Heaven 2\Assets\Module\MyModule\MyModule2_CIV4TechInfos.xml
Fall from Heaven 2\Assets\Module\MyModule\MyModule2_CIV4TechnologiesSchema.xml
Fall from Heaven 2\Assets\Module\MyModule\MyModule3_CIV4UnitInfos.xml
Fall from Heaven 2\Assets\Module\MyModule\MyModule3_CIV4UnitSchema.xml

...and so on. Seems to work for me, anyway. I'm happily inputting my tech tree from a giant chart. :)
 
Oh, you included every entry from the original file? Typically modular mods don't do that, but doing so will allow you to bypass the issue of indexing, though it means you still have just as much work to do in order to update for a patch of the base mod :)
 
So, I'm working on a variety of odd problems, and coming up with even odder solutions. I'm probably being a little lazy, but it's at least interesting.

The current one is that I don't want Pyre Zombies as City Defense. They don't give military bonuses, and it's a huge problem.

So I tried NoUnitAi, that didn't work, and it just ignores me.

I tried beelining Archery hoping they could replace the Pyre Zombies, it works as some minor level, but is totally unsatisfactory.

The most successful I've gotten is changing the UnitAI manually. Right now, every time a Pyre Zombie gets a promotion, they switch to UnitAI_Attack. huge success!

Problem. They don't group afterwards. They take their new UnitAI and wander off to go find something to kill barbarian, or if at war another Civ.

This is a good thing, but I want them grouped and managed in an intelligent way with the Selection grouping.

Any ideas why manually changing the UnitAI would screw up grouping? You'd think it'd be just another available unit for a mission.

Aside from that one issue, it's working surprisingly well. I want to do it to heros too once they hit a certain Xp level (say 25), but they need to be grouped together after their unitAi switch so they aren't picked off at first opportunity.

Thanks

EDIT: Possible options off the top of my head.

1. The act of setting unitAi even if the same unitAi disconnects from a group. If so, check for current unitAI in the check.
2. UnitAI_Attack doesn't group particularly well. Switch to UnitAI_CityAttack or UnitAI_Collatoral. Or Rand it since I'm fond of those. Give some options.
.... Maybe something else :)
 
I would just list City_Defense, City_Reserve, and City_Counter as <NotUnitAIs> for the PZs, then they should ever be built/selected for the role. And possibly also add consideration of their explosive status to the weighting for City_Attack and heavily to City_Attack_Lemming so that the AI doesn't reduce their production of the unit (since right now I would guess their City_Defense score is pretty high, hence the overproduction)
 
I would just list City_Defense, City_Reserve, and City_Counter as <NotUnitAIs> for the PZs, then they should ever be built/selected for the role. And possibly also add consideration of their explosive status to the weighting for City_Attack and heavily to City_Attack_Lemming so that the AI doesn't reduce their production of the unit (since right now I would guess their City_Defense score is pretty high, hence the overproduction)

I mentioned in my post that I put no City_* into NotUnitAIs and it has no effect for me for Pyre Zombies. They continue to be City Defense regardless.

NotUnitAIs seem to be working for me for things like Pirates, but I think there is something that is compelling them to be built as one thing, and then changed to City Defense when they move with a new Settler, or a City needs a defender.

Maybe I'll run threw the DLL code on it again. Right now, I'm getting good progress by changing them on the fly based on actions. I just need to make sure they group.

There's a City_Attack_Lemming? :) I've never seen that.
 
I figured out I was right. Setting UnitAi removes you from the selection group. So if I check for it when setting it so I don't do it when I don't need to, I'll be fine.
 
Doh, missed the line about the NOT already being used. But if you got it working nicely that is enough. My other advice would have been to modify: CvPlayerAI::AI_unitValue, make it significabtly lower the value for City_Def if the unit does not offer Military Happiness (or raise if it does)
 
City_Attack_Lemming was added specifically for the Defense scenario that came with BtS I believe. Makes them beeline for cities ignoring all units or something like that.
 
It's not really about FFH, but since I play nothing else and it's probably an easy question, but I didn't find a tutorial: I want to add options to the Tectonics map script for more land. Could anyone tell me what I have to add in the map script? I tried it myself, didn't work.
 
I'm trying to get an event to Trigger when the Cult of the Dragon is spread to a city

I think that I have everything right but I keep on getting this Python Error:

Code:
File "CvEventManager", line 23, in onEvent

File "CvEventManager", line 213, in handle Event

File "CvEventManager", line 1911, in onCorporationSpread

Attribute Error: 'int' object has no attribute 'initTriggeredData'

Here is the code that I am using:

Code:
def onCorporationSpread(self, argsList):
		'Corporation Has Spread to a City'
		iCorporation, iOwner, pSpreadCity = argsList
		player = PyPlayer(iOwner)

		iDragon = gc.getInfoTypeForString('CORPORATION_CULT_OF_THE_DRAGON')
		if iCorporation == iDragon:
			pPlayer = iOwner
			iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_CULT_SPREAD_1')
			triggerData = pPlayer.initTriggeredData(iEvent, true, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)
			CyInterface().addMessage(pSpreadCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_CULT_SPREAD1", ()),'',1,'Art/Interface/Buttons/Corporations/CultoftheDragon.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
			pPlayer.setHasTech(gc.getInfoTypeForString('TECH_DRAGON_CALL'))

Does anyone know how to get this to work?
 
Does anyone know how to get this to work?
Change this line:
Code:
pPlayer = iOwner
to:
Code:
pPlayer = gc.getPlayer(iOwner)
or even better use the player object you already have and delete the line above:
Code:
player = PyPlayer(iOwner)
At the moment pPlaywer contains only the player id, not the player object.
 
Is there a way to make a python call (like def onUnitKilled(self, argsList) or PythonOnCombatLose) run only if the unit was killed, and not captured?


(In my version I have set it up so that whenever a Dragon dies it creates a Dragon Bones improvement and that civ's mana type on the tile, and so that it is possible to revive the dragon through a spell that must be cast on the appropriate bones. (Eurabatres and Abashi are no longer considered their civ's heroes for the purposes of Ressurection. That distinction now goes to Herne and Malchiavic, whom I added as an archmage hero who died in a previous age and so can never be built, only resurrected. I also made the Sheaim unable to build the Shrine of the Champion, as it would otherwise be availible too soon, and since they aren't really the heroic types.) This works fine, except that when you capture a dragon it still leaves the bones behind and thus lets you have multiple versions of each dragon.)

Edit: I've experimented a few different ways and, while I can't technically find a way to stop the improvement/resource from being played when the unit is captured, I can pretty easily cycle through every tile on the map and remove the dragon bones with the appropriate mana whenever a new dragon is created and get the same effect. This also means that is someone cheats and gets the dragon in worldbuilder that they won't be able to get another one another way. Hmm...this might also mean I could make actually reviving the dragons be XML-only spells, apart from a tiny python prereq to make sure the mana is the right type. I probably won't though, since that would mean the dragons could get summon perks from the unit that freed them.
 
Back
Top Bottom