Quick Modding Questions Thread

Code didn't work. I pasted it here in the CvEventManager.
Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
###CityNameChange###
if pCity.getName() == "Indraprastha": 
    if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_MAURYA"): 
        pCity.setName("Dillika"); 
###CityNameChange###
Could anyone provide some help, please.
 
The tabs seems to be wrong. You need to remove the spaces in front of the lines and add tabs. This is what I meant with python being picky about tabs.

What seems to happen is that onCityAcquiredAndKept starts. When it encounters a line, which starts with less than two tabs, it ends. Likewise when the if sentence is encountered, it checks that the if has two tabs. If the if sentence is true, it runs the following code with 3 or more tabs. If it is false, it skips to the next line with two tabs.

You absolutely have to understand the python tab system if you are to modify any python files.
 
Nope, still doesn't work, I used tabs this time.
Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
###CityNameChange###
		if pCity.getName() == "Indraprastha": 
			if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_MAURYA"): 
				pCity.setName("Dillika"); 
###CityNameChange###
 
I add new formations in my mod and i get this errors:

Code:
Assert Failed

File:  CvInfos.cpp
Line:  7454
Expression:  false
Message:  [Jason] Unknown unit formation entry type.

Code:
Assert Failed

File:  CvInfos.cpp
Line:  7462
Expression:  m_vctSiegeUnitEntries.size() > 0
Message:  [Jason] Formation missing siege tower entry.

Code:
Assert Failed

File:  CvXMLLoadUtilitySet.cpp
Line:  1605
Expression:  bSuccess
Message:  OWN TYPE - dependency not found: (null), in file: "NONE"

The 3rd assert just tells of an incorrect xml setup. I hate that one because it doesn't tell what went wrong, just that something went wrong.

The first two tells of incorrect xml setup as well, but at least they are more descriptive. However they aren't vanilla and I haven't seen them before. It looks like missing formation type in XML, though it doesn't tell precisely which unit. It would have been nice if the assert had added getType() as this would tell precisely which one failed.

Here is my Formations file in attachment.
Yes that is not vanilla, this is LoR + my mod components + merged mod components = new Reconstruction version. I just get error in CIV4FormationInfos. If i remove this new formations it all will work without any error. File is from my Zlatko Mini Formation Mod Component.

new tags in my mod (all are tested and work well), this tags now allow you to use my mod component as graphic option in game:
Code:
			<iAsset>2</iAsset>
			<iPower>6</iPower>
			<UnitMeshGroups>
				<iGroupSize>3</iGroupSize>
				[COLOR="Red"][B]<iGroupSizeMiniFormation>28</iGroupSizeMiniFormation>[/B][/COLOR]
				<fMaxSpeed>1.75</fMaxSpeed>
				<fPadTime>1</fPadTime>
				<iMeleeWaveSize>3</iMeleeWaveSize>
				<iRangedWaveSize>3</iRangedWaveSize>
				[COLOR="Red"][B]<iMeleeWaveSizeMiniFormation>7</iMeleeWaveSizeMiniFormation>
				<iRangedWaveSizeMiniFormation>14</iRangedWaveSizeMiniFormation>[/B][/COLOR]
				<UnitMeshGroup>
					<iRequired>3</iRequired>
					<EarlyArtDefineTag>ART_DEF_UNIT_LONGBOWMAN</EarlyArtDefineTag>
				</UnitMeshGroup>
			</UnitMeshGroups>
			<FormationType>FORMATION_TYPE_RANGED</FormationType>
			[COLOR="Red"][B]<FormationTypeMiniFormation>FORMATION_TYPE_NEW_RANGED</FormationTypeMiniFormation>[/B][/COLOR]
			<HotKey/>

Code:
		<UnitArtInfo>
			<Type>ART_DEF_UNIT_LONGBOWMAN</Type>
			<Button>,Art/Interface/Buttons/Units/Longbowman.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,8,7</Button>
			<fScale>0.44</fScale>
			[B][COLOR="Red"]<fScaleMiniFormation>0.22</fScaleMiniFormation>[/COLOR][/B]
			<fInterfaceScale>1.0</fInterfaceScale>
			<bActAsLand>0</bActAsLand>
			<bActAsAir>0</bActAsAir>
			<NIF>Art/Units/Longbowman/Longbowman.nif</NIF>
			<KFM>Art/Units/Longbowman/Longbowman.kfm</KFM>
			<SHADERNIF>Art/Units/Longbowman/Longbowman.nif</SHADERNIF>
			<ShadowDef>
				<ShadowNIF>Art/Units/01_UnitShadows/UnitShadow.nif</ShadowNIF>
				<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
				<fShadowScale>1.0</fShadowScale>
			</ShadowDef>
			<fBattleDistance>0.35</fBattleDistance>
			[COLOR="Red"][B]<fBattleDistanceMiniFormation>0.175</fBattleDistanceMiniFormation>[/B][/COLOR]
			<fRangedDeathTime>0.31</fRangedDeathTime>
			<bActAsRanged>1</bActAsRanged>
			<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
			<AudioRunSounds>
				<AudioRunTypeLoop/>
				<AudioRunTypeEnd/>
			</AudioRunSounds>
		</UnitArtInfo>
 

Attachments

I suppose that is about the extra siege tower art that is displayed whenever a melee unit attacks a city. I have no idea how formations work but maybe that is defined as part of the formation and you forgot to add it? Just a shot in the dark. This may or may not take care of the other errors as well but it seems to be the most concrete place to start.
 
hi guys, i was wondering if someone can help :) . i am looking for a way to export a rigged unit from blender 2.6.3 and then import it to blender 2.4.9 without losing the skeleton/vertex groups info. so what type of file keeps that info and is compatible with both blender 2.4.9 & 2.6.3?
i already tried dae & obj but to no avail, all the info was lost.
so has anyone tried that before?
 
Uh, a little help would be nice? I can't gind out where to paste this code.
Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
###CityNameChange###
		if pCity.getName() == "Indraprastha": 
			if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_MAURYA"): 
				pCity.setName("Dillika"); 
###CityNameChange###
 
Vanilla:
PHP:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))
The code I wrote used pCity and pNewOwner as variables. pCity is present (assuming you didn't remove the line assigning it from argsList). pNewOwner is not, which mean either the code needs to be changed or it should be added. Something like:
Code:
	def onCityAcquiredAndKept(self, argsList):
	iOwner,pCity = argsList
	pNewOwner = PyPlayer(iOwner)
###CityNameChange###
With that in place, the python code should be ok (I think, didn't test).
 
@All

Ok here is my current source of entire mod in attachment, download them and see all infos in Search Strings.txt, in files // ZLATKO RECONSTRUCTION START // MiniFormation this is comment for MiniFormation component.
 

Attachments

Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		pNewOwner = PyPlayer(iOwner)
###CityNameChange###
		if pCity.getName() == "Indraprastha": 
			if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_MAURYA"): 
				pCity.setName("Dillika"); 
###CityNameChange###
	
	def onCityLost(self, argsList):
Nope, doesn't work, sorry.
 
Does it need a return true/false statement at the end?

Most of the python I used to use was covered in them!
Possibly, however I do not know how to construct such a thing, so I'll wait for a python expert.
 
Where is it defined which units are gunpowder-based for the purpose of ignoring wall/castle defense?

hi DarkLunaPhantom,
i think that has to do with the entry

<bIgnoreBuildingDefense>1</bIgnoreBuildingDefense>

that exists in the CIV4UnitInfos.xml. if i'm not mistaken, all units that are supposed to ignore building defenses, like the gunpowder units, have "1" and other units that are not supposed to ignore building defenses, like the melee units (swordsman,axeman,etc), have "0".
 
hi DarkLunaPhantom,
i think that has to do with the entry

<bIgnoreBuildingDefense>1</bIgnoreBuildingDefense>

that exists in the CIV4UnitInfos.xml. if i'm not mistaken, all units that are supposed to ignore building defenses, like the gunpowder units, have "1" and other units that are not supposed to ignore building defenses, like the melee units (swordsman,axeman,etc), have "0".

Thanks!
 
So does anybody know how to fix this code?
Code:
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList
		pNewOwner = PyPlayer(iOwner)
###CityNameChange###
		if pCity.getName() == "Indraprastha": 
			if pNewOwner.getCivilizationType() == gc.getDefineInt("CIVILIZATION_MAURYA"): 
				pCity.setName("Dillika"); 
###CityNameChange###
	
	def onCityLost(self, argsList):
 
Hello and a Question.

I have recently added an 8th religion to my mod along with new missionary, buildings etc.
All works well, except one thing:
when my new missionary spreads religion to a new city, the music that is played is NOT my new religion music but Hindu music.
In all other places, religion spread report music, buildings build music - is all correct new religion music.

I can't seem to figure out hows is music attached to a specific missionary.

Thank You!
 
There is no sound associated with specific missionaries. When a missionary spreads a religion to city, it simply calls the code that adds the religion to the city, no matter if spread by missionary or from random spread. The sound you hear is always the one associated with the religion.

Are you sure it already works for normal spread? It's the sound file specified in the CIV4ReligionInfos.xml. Buildings do have separate building sounds that are only identical by convention, so it's not sufficient to only check those.
 
Back
Top Bottom