Modders Guide to FfH2

Holy . .. .. .. .. Tried adding the functional parts, which meant multiple new functions in CvUnit, CvPlayer and CvGame.

And it works! o.O

I made a small logical error in that the damage bonus is not reduced to 0 when you "convert" to no state religion, but other than that, no CtD's, no hangs, no nothing.

Can't say I'm unhappy, but it's rather silly that now I can't know what was different/wrong before.

Ah well, I'm glad it finally works :) Thanks again for the help!
 
I don't mean to be impatient, but I suspect this was lost amongst Castar's and xienwolf's discussion, so I thought I'd repost it anyway.

I've ran into an issue with the "pPlayer.getCivilizationType()" function, as you can see below, in my attempt to make Ascension do two different things for different civilizations. Nothing occurs when either civ builds Ascension. I get no python errors or anything... these conditions are just not being triggered.

For my new civ, I wanted to make it so that both they and the Illians could "ascend", so they each gained a unit on completing Ascension. This was the code I added to that ritual in the Event Manager, instead of just spawning Auric.

Code:
		if iProjectType == gc.getInfoTypeForString('PROJECT_ASCENSION'):
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIATION_ILLIANS'):
				pPlayer.initUnit(gc.getInfoTypeForString('UNIT_AURIC_ASCENDED'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIATION_FROZEN'):
				pPlayer.initUnit(gc.getInfoTypeForString('UNIT_TARANIS_ASCENDED'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
				for iPlot in range(CyMap().numPlots()):
					pTaranisPlot = CyMap().plotByIndex(iPlot)
					for iUnit in range(pTaranisPlot.getNumUnits()):
						pTaranis = pTaranisPlot.getUnit(iUnit)
						if pTaranis.getUnitType() == gc.getInfoTypeForString('UNIT_TARANIS'):
							pTaranis.kill(false, -1)

It should check if you are the Illians or Frozen, give you the correct unit based on that, then (if you are the Frozen) find where Taranis is on the map and kill him. (since he is spawned as Taranis Ascended).

But it doesn't work, no units are spawned for either Illians or Frozen. I am apparently using the wrong function to identify a player's civilization, it seems. How should I be doing this?
 
Similar test in Fall Further code:
Code:
if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_SCIONS'):

Far as I can tell that ought to be working. Some debugging text outputs may be of use for you in testing:

Code:
CyInterface().addMessage(0,True,25,CyTranslator().getText("Civilization Type %d1 (illians = %d2, Frozen = %d3)",(pPlayer.getCivilizationType(), gc.getInfoTypeForString('CIVILIATION_ILLIANS'), gc.getInfoTypeForString('CIVILIATION_FROZEN'))),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Buildings/Soulforge.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)

Cludged together, but should work. Put this in right after the check for ritual type and it should let you know when it is checked.
 
Well, it gives me Civilization type = 21, which is correct since I added Frozen to the top of CIV4CivilizationInfos.xml, but then it goes on to say that illians = -1, and frozen = -1.

Which, I just discovered is because I left out a "Z" in CIVILIZATION. :blush: Guess it was a rather stupid mistake after all... but I probably wouldn't have noticed it otherwise. Upon adding in that Z, everything works fine for both civilizations.

Thanks xienwolf!
 
A very general Python/XML question:

Can I call all attributes of a unit that are defined in the XML via Python like:

if 5 >=gc.getInfoTypeForString('UNIT_FLESH_GOLEM').baseCombatStrDefense():

or does that only work for specific attributes that are defined for use in Python?

Thanks in advance!
 
getInfoTypeForString gives you a number only. So you basically just wrote:

5 >= 128.base CombatStrDefense():

Or whatever number Flesh Golems are.

But, if you write

5 >=gc.getUnitInfo(gc.getInfoTypeForString('UNIT_FLESH_GOLEM').base CombatStrDefense()):

Then you are checking the data loaded by the DLL from the XML (Note, if you add a new field to the XML and try to use this you will get nothing. the DLL MUST process the field to store the data)
 
Im trying to edit the AI in CvGameUtils.py and I dont seem to be having much luck with the def cannotResearch callback. It is enabled in PythonCallbackDefines.xml yet the below code refuses to stop the Svarts from teching Bronze like it should:

Code:
	def cannotResearch(self,argsList):
		ePlayer = argsList[0]
		eTech = argsList[1]
		bTrade = argsList[2]
		pPlayer = gc.getPlayer(ePlayer)
		eTeam = gc.getTeam(pPlayer.getTeam())

		if pPlayer.isHuman() == False:
			if eTech == gc.getInfoTypeForString('TECH_BRONZE_WORKING'):
				if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
					if eTeam.isHasTech(gc.getInfoTypeForString('TECH_TRACKING')) == True:
						return False					
					else:
						return True

(This is in FF btw)
 
What you are telling the game is: if the player's civ is different than Svarts, then check if it has Tracking: if it has, then it can research BW; if not, then it can't. This should work:
Code:
		if pPlayer.isHuman() == False:
			if eTech == gc.getInfoTypeForString('TECH_BRONZE_WORKING'):
				if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
					return True
 
Thanks, how would I go about adding the Tracking pre-requisite as what i want specifically is for the Svarts not to tech Bronze unless they have Tracking.
 
This should work:
Code:
		if pPlayer.isHuman() == False:
			if eTech == gc.getInfoTypeForString('TECH_BRONZE_WORKING'):
				if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
					if not eTeam.hasTech(gc.getInfoTypeForString('TECH_TRACKING')):
						return True
 
I'm having some trouble with the new art for Elohim. Even though I added all the art in the correct directory, changed all the artdefines to point to it and changed the UnitArtStyle file, the new art still don't show up. Specifically, the new models don't; the new buttons do!
 
No, not any.

Can't see the artdefines even with chipotle... Unless it's the big number in brackets?
 
How would I make code trigger when a promotion is removed from a unit?

I've made a promotion applied via combat have a chance of expiring. When it expires, I want the unit to die and my new civ, the Frozen, to gain a few units. Also, I want those units to be durational (last for a few turns only).

I think that doing this via spell would be easiest. But how can I make a spell triggered when a promotion expires? And if I can't, is there an easier way to do what I want?
 
How would I make code trigger when a promotion is removed from a unit?

I've made a promotion applied via combat have a chance of expiring. When it expires, I want the unit to die and my new civ, the Frozen, to gain a few units. Also, I want those units to be durational (last for a few turns only).

I think that doing this via spell would be easiest. But how can I make a spell triggered when a promotion expires? And if I can't, is there an easier way to do what I want?
The easiest way I think is to give your Promotion a PyPerTurn rather than an expire chance. Make a random check and if it is true, remove the promotion and apply whatever effect you want via python.
 
Back
Top Bottom