Modders Guide to FfH2

for techs you could use this

iUnimproved=pPlayer.countOwnedBonuses(iBonus)
if pPlayer.getNumAvailableBonuses(iBonus)>0:
iUnimproved=0
 
It should, yes. I honestly haven't used it in any of my OWN code before, but I've seen how others have so I'm fairly sure it will work here. Let me know how it goes. ;)

Normally I'd say to not use it, as this code is ran EVERY time the unit is selected... But in this case, with a simple one-line effect, I don't think it's too intensive.

It works like magic! (did I say magic? :lol:) It set the unit as has casted so work just as I intended. Thank you guys, it simplified everything! (me soo happy :p)
 
Afaik you have to loop over all plots for this: In my mod I used this to determine whether a civ has a copper resource and should research bronze working:
Spoiler :
Code:
		if eTeam.isHasTech(gc.getInfoTypeForString('TECH_BRONZE_WORKING')) == False:
			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_MINING')):
				if eTeam.getAtWarCount(True) >= 1:
					bhascopper=0
					for i in range (CyMap().numPlots()):
						pPlot = CyMap().plotByIndex(i)
						if pPlot.isOwned():
							if pPlot.getOwner() == ePlayer:
								eBonus = pPlot.getBonusType(TeamTypes.NO_TEAM)
								if eBonus == gc.getInfoTypeForString('BONUS_COPPER') :
									bhascopper=1
					if bhascopper==1:
						iTech = gc.getInfoTypeForString('TECH_BRONZE_WORKING')


Will this check each plot in each turn? Wouldn't that resources intensive? My poor old comp.:(
 
Will this check each plot in each turn? Wouldn't that resources intensive? My poor old comp.:(

It is resource intensive, however it only checks each plot each time the AI evaluates its tech choice (which is afaik only triggered if it has to pick a new tech, or if someone grabs a first-to-a-tech bonus like grabbing a religion) and only as long as the first condition(no bronze working) is valid. So later in the game once the slowdown comes, it doesn't get checked at all.
 
In my version I removed the Vampire as a distinct unit (to balance the fact that the vampire promotion gives access to death, body, shadow, and mind magic with the right mana, and the feed ability works more like it did pre-BtS), and I can't find any reference to UNIT_VAMPIRE in any of my xml, yet for some reason when loading the game always says that there is a UNIT_VAMPIRE in CIV4SpellInfos.xml that it does not know what to do with. It still loads fine when you say ok to that warning thouh. What could be causing this?
 
Sorry if this has been asked before, but I was curious about the FfH editor. For the text keys the language order seems to have switch Italian and Spanish compared to the normal game files. Has anyone else noticed this? I am guessing that this will result in someone choosing either of those languages will get the other, right? It's no problem to change the VB I am sure, but I was just curious as to what others thought.
 
For some reason my mod is crashing on init audio, and I have no idea why...

EDIT: Problem solved- when I removed the comments surrounding these two added defines in the XML, the game loaded fine...

It seems to be another case of too many comments in an XML file causing problems. It's happened in Colonization to other modders and it happened to me once before in CIV4CivilizationInfos.xml, where I commented the many changes I had made.
 
Commenting in XML is a bad idea in general. In many cases in the DLL it doesn't check to ensure that the next line is a non-comment, just that it exists. Then it skips the comments, and attempts to work with what it reads, which now might be nothing, and thus a crash. Can also wind up being that it is in a specialized loop, thinks there is more, turns out it was just a comment, which it skips, now it is trying to stay in the special loop, but loading data not intended for it, and now instead of a crash you just have REALLY weird errors.
 
I've successfully added a new spell by simply imitating the format of a similar existing one, and now want to add a new world spell for a custom civilization. However, in looking at the XML, I don't see any place where I could define what the spell does in the same way as I did the ordinary spell. How do I set what a world spell does and in what file is the code found?

Also, what I'd like the spell to do is give a number of beakers per city when cast; is that possible in the FfH game engine as it stands?

The spell I successfully added gives the target unit a "Slayer" promotion, which would gives the recipient a +40% bonus against units with the Vampire promotion. My intent was to make the Slayer promotion +40% against any of the following promotions (Vampire, Werewolf, Entropy). Looking through the promotions file, I did not see any line where I could make Slayer a "catch-all" promotion. Is it possible to make a single promotion that gives bonuses against multiple categories, and if so, how?
 
I had almost mentioned the "no line to themselves" thing, but then I remembered that XML doesn't care at all about linebreaks. It is a coincidental rule of thumb.


Hamster: Most of what spells do, especially complicated things like world spells, are done in python, CvSpellInterface.py in Assets/Python/entrypoints.

Look at the spell "Sacrifice" that can be cast in a city with a Demon's Altar (not the one cast on the Pyre of the Seraphic by Angels) for a sample of adding beakers upon casting a spell.

You are correct about slayer, you cannot grant a bonus against multiple promotions in the XML, you would have to grant 3 promotions, each giving a bonus against a single other promotion.
 
Commenting in XML is a bad idea in general. In many cases in the DLL it doesn't check to ensure that the next line is a non-comment, just that it exists. Then it skips the comments, and attempts to work with what it reads, which now might be nothing, and thus a crash. Can also wind up being that it is in a specialized loop, thinks there is more, turns out it was just a comment, which it skips, now it is trying to stay in the special loop, but loading data not intended for it, and now instead of a crash you just have REALLY weird errors.

You made me just understand what happen with a f***g promo which should have been free but was not because just after anotgher one i commented.

Just removed all "alone-on-the-line" comments. :D
 
Hamster: Most of what spells do, especially complicated things like world spells, are done in python, CvSpellInterface.py in Assets/Python/entrypoints.

Look at the spell "Sacrifice" that can be cast in a city with a Demon's Altar (not the one cast on the Pyre of the Seraphic by Angels) for a sample of adding beakers upon casting a spell.

You are correct about slayer, you cannot grant a bonus against multiple promotions in the XML, you would have to grant 3 promotions, each giving a bonus against a single other promotion.
Thanks, xienwolf. I had a bad feeling it would be in the Python: I know nothing about Python, so it's not something I'll be editing anytime soon.

I'll take a look at the "sacrifice" spell you've mentioned and see what I can do with it. Hey, Savants can be sacrificed for beakers too. I'll look at how that works as well.
 
Savants work through UnitInfos, just like a Great Person.

Python is pretty intuitive and readable. There are some format rules which you may not get right away, but if you copy from what exists already, you make few mistakes, and people here can usually point them out for you pretty quickly as they have made the same mistake at some point previously.
 
Savants work through UnitInfos, just like a Great Person.

Python is pretty intuitive and readable. There are some format rules which you may not get right away, but if you copy from what exists already, you make few mistakes, and people here can usually point them out for you pretty quickly as they have made the same mistake at some point previously.


Dear god, have I. Err, we. :lol:
 
Savants work through UnitInfos, just like a Great Person.

Python is pretty intuitive and readable. There are some format rules which you may not get right away, but if you copy from what exists already, you make few mistakes, and people here can usually point them out for you pretty quickly as they have made the same mistake at some point previously.
Thank you for your encouragement. With everything backed up, I suppose there's no harm in experimenting with the Python. The Kuriotates world spell is similar to what I want, except it produces culture and not beakers.

By the way, what is <AddPromotionType1>NONE</AddPromotionType1> from the Spellinfos file for?

Usually the field says "NONE", but a few like "Join Great Commander" or "Blur" have PROMOTION_GREAT_COMMANDER or PROMOTION_BLUR in that field respectively. I tried to use it to make "Slayer" a catch-all, but it did not work.
 
By the way, what is <AddPromotionType1>NONE</AddPromotionType1> from the Spellinfos file for?

Usually the field says "NONE", but a few like "Join Great Commander" or "Blur" have PROMOTION_GREAT_COMMANDER or PROMOTION_BLUR in that field respectively.

It adds a promotion to your unit. So in your example, it will grant PROMOTION_BLUR to any valid units being targeted by the spell.

I tried to use it to make "Slayer" a catch-all, but it did not work.

Have you set which unit the promotion will apply? It is in promotioninfo. You should specify PROMOTION_SLAYER is valid to UNIT_MELEE (or was it UNITCOMBAT?) Otherwise, Civ4 will see that NO UNIT is valid to get the promotion. Thus, your promotion will not be applied to all units.
 
AddPromotion1 (and 2 and 3) will add that promotion to all units in the stack who can gain the promotion (note esvath's comment about unitcombat), or if you also set bCasterOnly, it will apply the promotion ONLY to the person who cast the spell, even if they cannot normally gain the promotion (this is how the Great Commander one works).
 
Back
Top Bottom