Modders Guide to FfH2

On a side note, does python do automatic garbage collection for you? If I create an unit then delete that unit, will the unit go away when the function that did it is done?
 
Thanks.

I used this:

Spoiler :

Code:
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pOtherPlayer = gc.getPlayer(iPlayer)
		eOtherTeam = TeamTypes(pOtherPlayer.getTeam())
		if (pOtherPlayer.isAlive()):
			[b]if pOtherPlayer != gc.getPlayer(gc.getBARBARIAN_PLAYER()):[/b]
				if gc.getTeam(pPlayer.getTeam()).isHasMet(eOtherTeam):
					listPlayers.append(pOtherPlayer)


And ran through at least a dozen kill/spawns in one turn without a CTD. I did eventually have the python stop on this line, though:

Code:
		pCity = listPlayers[iGift].getCapitalCity()

It's where a city is supposed to be picked for a non-Scions newUnit.
 
Code:
[b]if pOtherPlayer != gc.getPlayer(gc.getBARBARIAN_PLAYER()):[/b]

this will not work. Even pOtherPlayer defined as the barbarian player will pass the test. For python this is two object located at different pointer so different.

You should use :
Code:
	for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
And the barbarian player will be skipped.

Tcho !
 
You should use : /snip/

Excellent - thanks!

Here's what I've got now. I still need to add in the bits where experience and promos are passed on, but that shouldn't be a problem. I had to back off and restructure everything to get it to work, though. Probably a case off too much going on in the code that I didn't really understand.

This seems to work without CTDs or lapses (fingers crossed), with the exception that uncontacted civs still receive the newUnit. (That's acceptable.) I also didn't toss in the line that'd keep the Scions from getting the unit when the coin flip goes against them. 50% go home,50% chose randomly (maybe home ) is fine.

Thanks for all your help, everybody. Should we ever happen to meet I owe you a drink!

Any further suggestions would be appreciated. And, OfTopic, if you've got a suggestion for a flavorful but not especially powerful ability fitting for a mad undead mage, I'm looking for one. :)

Spoiler :

Code:
def MIT0(pCaster):
	if CyGame().getSorenRandNum(100, "Check") <= 50:
		for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
			pPlayer = gc.getPlayer(iPlayer)
			if (pPlayer.isAlive()):			
				if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SCIONS'):
					pCity = pPlayer.getCapitalCity()
					newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_MIT0'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
	else:
		listPlayers = []
		for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
			pPlayer = gc.getPlayer(iPlayer)
			eOtherTeam = TeamTypes(pPlayer.getTeam())
			if (pPlayer.isAlive()):
				if gc.getTeam(pPlayer.getTeam()).isHasMet(eOtherTeam):
				listPlayers.append(pPlayer)
					
		iGift = CyGame().getSorenRandNum(len(listPlayers) * 1, "Gift")
		pCity = listPlayers[iGift].getCapitalCity()
		pPlayer = listPlayers[iGift]
		newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_MIT0'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
 
Sending the kill command on the unit cleans it up, if that is what you mean?

Are you sure? I know that I was able to use .convert() after .kill(), which resulted in the unit being converted basically the normal way but losing the Immortal Promotion and half the xp if the unit had spirit guide.
 
Did you use kill(false) or kill(true)? Because kill(true) won't clean up the unit till the end of the turn (or some time later, haven't looked for precisely when yet), but does block most interactions with it by non-code means. If you just use plain kill() from python, I would imagine it defaults to delayed death.
 
Is there a way to disable the way a civ's allignment changes when they follow a particular religion? i have played a game where i am the only evil civ before. i don;t like to think of calabim or Sheaim, 'redeeming' themselves.
 
Religions' Alignment effectss are handled in the SDK/XML. The xml file handling it is C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2 032\Assets\XML\Gameinfo\CIV4ReligionInfos.xml, specifically the least 3 lines of each religion's define.
Code:
			<Alignment>ALIGNMENT_NEUTRAL</Alignment>
			<AlignmentBest>ALIGNMENT_GOOD</AlignmentBest>
			<AlignmentWorst>ALIGNMENT_EVIL</AlignmentWorst>
I don't think the "Alignment" tag is ever actually used. AlignmentBest means "the most good" alignment the religion will allow. If a civ is more good than that, they will become that good. In practice, ALIGNMENT_GOOD means it won't change anything, ALIGNMENT_NEUTRAL means it will turn Good Civs neutral, and ALIGNMENT_EVIL means it will turn any civ evil. You could add several intermediate stages between alignments, but it would still work the same way. The AlignmentWorst tag is the same thing, but in reverse. The example given is from FoL, and is what you would use if you want to make a religion not effect alignments.


There is no way to make religions effect different civ differently, at least not directy. It might be doable in python.


You could always try a Broader Alisgnment mod if you don't think that Religion should be the sole determining factor of alignment.



It is very easy to block leaders from adopting a religion that would "redeem" them. Just edit C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2 032\Assets\XML\Civilizations\CIV4LeaderHeadInfos.cml so that they have a -100 weight towards the religion.
Code:
<ReligionWeightModifiers>
                 <ReligionWeightModifier>
                    <ReligionType>RELIGION_THE_EMPYREAN</ReligionType>
                    <iWeightModifier>-100</iWeightModifier>
                 </ReligionWeightModifier>
                 <ReligionWeightModifier>
                    <ReligionType>RELIGION_THE_ORDER</ReligionType>
                    <iWeightModifier>-100</iWeightModifier>
                 </ReligionWeightModifier>
            </ReligionWeightModifiers>
 
is the Unit's Tier exposed to python? It'd be nice to say "give me tier 1 units" or "tier 2 units" etc. I looked in CyInfos.h and getTier isn't DLLExported..
 
There's no file called CyInfos.h, DLL export I believe is for exposing functions to the exe and getTier is exposed to python in CyInfoInterface1.cpp.
 
Well i have changed the files accordingly as it says in the post above and in my new game now all the religions are being founded by all the right civs, thank yooou
 
Version 0.33 of the source code is linked in the first post.
 
The source for patch "b" is linked in the first post. Its only a 1 line change in CvUnit.cpp to fix a problem being able to cast spells that require a player to own a building (ie: Sirona's Touch).
 
For anyone who does not want to re-download the entire zip for the one line, in CvUnit.cpp - CvUnit::canCast

Change from:
Code:
    if (GC.getSpellInfo(eSpell).getBuildingClassOwnedPrereq() != NO_BUILDINGCLASS)
    {
        if (GET_PLAYER(getOwnerINLINE()).getBuildingClassCount((BuildingClassTypes)GC.getSpellInfo(eSpell).getBuildingClassOwnedPrereq()))
        {
            return false;
        }
    }

to

Code:
    if (GC.getSpellInfo(eSpell).getBuildingClassOwnedPrereq() != NO_BUILDINGCLASS)
    {
        if (GET_PLAYER(getOwnerINLINE()).getBuildingClassCount((BuildingClassTypes)GC.getSpellInfo(eSpell).getBuildingClassOwnedPrereq())[COLOR="Lime"]  == 0[/COLOR])
        {
            return false;
        }
    }


the small bit in green is all you need to add.
 
Is there a way to force all special terrain features to appear on all maps, regardless of size? Some file to tinker with, some values to adjust?...
 
yea go to your assets dir and load the CIV4worldinfo.xml and change <iUniqueFeatureChance>-15</iUniqueFeatureChance>
to 100 for each map you use. This will have to be done each patch. I think the erabus map does not spawn the new ones though, Cephelo(sp) would be the one to fix this *I think*
 
Back
Top Bottom