Mod-Modders Guide to Fall Further

@Vermicious Kid: you have to do a getAlignment() to a Leaderhead I think. Something like
Code:
gc.getLeaderHeadInfo(gc.getLeaderType(pPlayer)).getAlignment()
Assuming that pPlayer or such is available.

@Ahwaric: May be in FlavourMod? IIRC from the Dbg.log, it fires after the map and all... I think you may hijack lairs in it.
 
2 quick questions :
Where is the file for changing the odds of lair results,
And Valkrionn, how would I change D'tesh wastelands to look like deserts like they used to?
 
If the lairs are added after the map initializes, I would think they'd be either in Flavourmod like Opera said, or OnGameStart.
Thanks, put it in ongamestart and works fine. AI seems to work better with this change.
2 quick questions :
Where is the file for changing the odds of lair results,
And Valkrionn, how would I change D'tesh wastelands to look like deserts like they used to?
Depends what type of changes do you want. The odds of happenning of each category (bigbad, biggood, good, neutral) are controled in CvSpellInterface.py Deatails are set in CustomFunctions.py
For wastelands, just change artdefinetag for wastelands to ART_DEF_TERRAIN_DESERT in
CIV4TerrainInfos.xml

I have recently gave another try to spawning limits for improvements to control animal invasions in Orbis and can confir the thing I have reported before.
In CvPlot.cpp the following line I think makes spawning impossible if no positive value is entered. Especially that both are set to 0 ( minOccurs="0"/) so it would require -1 existing spawns to work
Code:
	if (getNumSpawnsEver() < GC.getImprovementInfo(getImprovementType()).getSpawnPerGameLimit() && getNumSpawnsAlive() < GC.getImprovementInfo(getImprovementType()).getSpawnAtOnceLimit())

I am using SpawnAtOnceLimit only, so my fix was simple:
Code:
	if ((getNumSpawnsAlive() < GC.getImprovementInfo(getImprovementType()).getSpawnAtOnceLimit()) || (GC.getImprovementInfo(getImprovementType()).getSpawnAtOnceLimit() == 0))
And spawning works fine.

Also, a question. Did anyone find a way to make trait gaining/removal work in 3.19? I have seen Xienwolf's suggestion in FfH bug thread, but I think I need better explanation on what has to be done.
This bug disables adaptative, insane and minor mechanics.
 
Use this change instead, in CvInfos:

Code:
int CvImprovementInfo::getSpawnPerGameLimit() const						{return m_iSpawnPerGameLimit < 0 ? MAX_INT : m_iSpawnPerGameLimit;}
int CvImprovementInfo::getSpawnAtOnceLimit() const						{return m_iSpawnAtOnceLimit < 0 ? MAX_INT : m_iSpawnAtOnceLimit;}

And combine that with

Code:
	pXML->GetChildXmlValByName(&m_iSpawnPerGameLimit, "iSpawnPerGameLimit", -1);
	pXML->GetChildXmlValByName(&m_iSpawnAtOnceLimit, "iSpawnAtOnceLimit", -1);

This makes the limit load as a default value of -1, and any negative value makes the limit essentially not exist. That allows you to specify a limit of 0 to prevent a lair from spawning, but still have it list a unit and civilization to spawn for (useful for linking to various things in python)
 
Hi all,

I was looking for a way SDK-free to create some kind of "global variable" used in the python scripts.
To be more precise, I would like to set the variable (let's call it "iCountLand") in CvEventManager.py every turn, and use it's value in CvMainInterface.py

Do you know a way to do such thing ?
I saw some appealing functions :
Code:
def sdGetGlobal( ModID, var ):
def sdSetGlobal( ModID, var, val ):

But they seem not used anywhere in the Python code, so I'm hesistant to use them.
 
It seems my previous question has no answer :)

So an easier one: is there a way to destroy a city through python code ?

I tried to set the population to 0 but then I have a 0 population city :)
 
It seems my previous question has no answer :)

So an easier one: is there a way to destroy a city through python code ?

I tried to set the population to 0 but then I have a 0 population city :)

Using pCity.kill() works.

Just be careful where you use it. If you destroy the city from within a call *from* the city (such as onBuildingBuilt or doCityTurn) it is quite likely to cause a CtD. That's why the Pax Diabolis ritual requires a unit to perform the final step and damn the city...
 
Makin a spell to upgrade a unit. I'm looking at the doviello for an example:
Code:
def reqUpgradeDovielloWarrior(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if not pPlayer.isHuman():
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) == 0:
			return False
		if eTeam.getAtWarCount(True) == 1:
			if pPlayer.getNumCities() > 1:
				return False
	return True

My python knowledge is pretty poor, so I'm probably understanding this incorrectly. But as far as I read the above,

1. Checks if the player is human. And if not:
2. Checks if their team is at war. Returns false if not. If true...
3. Checks if they have more than one city, and returns false if true?

Why would you want to prevent the AI doviello from upgrading units if they have more than one city (which is going to be 95% of the game) ? Am I misunderstanding this, or is that what it does?
 
Well, worker is 90 :hammers: and Beastmen is 25 :hammers:

anyway unless you also change UNITAI upon upgrading the AI should never upgrade its workers. Beastmen with a UNITAI_WORKER are pretty useless.
 
That tells the AI that if they are not at war, leave the workers alone. And if you are not at war with MULTIPLE opponents, leave the workers alone unless you have settled at least your second city. It just keeps them from having to devote their ONLY city to rebuilding that worker which is needed for expansion.

I see, that sounds logical. But I can't see that in the code.

Code:
if pPlayer.getNumCities() > 1:
		return False

This seems to be returning false (don't build) if you have more than one city. Ie, it would only allow the upgrade if they only have a single city, which is the opposite of what you're saying it does.

am I just reading it wrongly, or is there a bug here?


to me it looks like

Code:
if player has more than one city
     don't upgrade


Shouldn't it be this?
Code:
if pPlayer.getNumCities() < 2:
		return False
 
Yeah, I was coding elsewhere while I let that sit without re-reading it. I edited my post before seeing if you had already read/responded, NOW it says it right :) It says it how you broke it down, if they DO have only one city, they are allowed to upgrade the workers. That is anti-Dogpile thinking, which is also somewhat logical, but will lead to them building nothing but workers unless on the defensive I think.
 
oh, riight. I understand now.

Although, it seems like the AI doviello are depriving themselves of a valuable asset by not upgrading slaves as they take them. that's one of their best features, building an army on the move.
 
Is there a simple way to make a single world/team/national unit limit apply to more than one unit? So, for example, to make it so there are two types of knight and a player can build four total of any combination of the two.
 
yeah, just use python cannottrain callback in cvgameutils.py

if getunitclasscountplusmaking(unitclass a)+getunitclasscountplusmaking(unitclass b)>X:
return false
 
Back
Top Bottom