• Civilization 7 has been announced. For more info please check the forum here .

Quick Modding Questions Thread

You have iXPValueAttack and iXPValueDefense both at 100.

Try to lower this value to a more reasonable one (like 30 or 70) and see what it does.

@ Lib., Clanky: the space in the path is automatically generated by the forum.
 
Just add a folder of art stuff that is not linked by XML values

Yes. I thought it might be something wrong with the art itself but then I found that it doing this even when I just duplicated the same assets over and over again. Oddly it works under a certain tolerance. But if I add ever one more dds file than that tolerance the python button will not show up anymore.
 
it has to do with the last section
<iEvasionProbability>0</iEvasionProbability>
<iWithdrawalProb>0</iWithdrawalProb>
<iCollateralDamage>0</iCollateralDamage>
<iCollateralDamageLimit>0</iCollateralDamageLimit>
<iCollateralDamageMaxUnits>0</iCollateralDamageMaxUnits>
<iCityAttack>0</iCityAttack>
<iCityDefense>0</iCityDefense>
<iAnimalCombat>0</iAnimalCombat>
<iHillsAttack>0</iHillsAttack>
<iHillsDefense>0</iHillsDefense>
one of these

Hum... you actually have 100 as iWithdrawalProb which is also problematic as the MAX_WITHDRAWAL_PROBABILITY is set at 90 in the GlobalDefines.xml.
 
Yes. I thought it might be something wrong with the art itself but then I found that it doing this even when I just duplicated the same assets over and over again. Oddly it works under a certain tolerance. But if I add ever one more dds file than that tolerance the python button will not show up anymore.

Do you know more or less how many buttons/dds files would be that tolerance? I'm thinking now that all numbers should be contained within a certain range depending on their data types.

In the meantime, a little experiment: could you insert the CyInterface().addMessage... line in CvMainInterface like this:
Spoiler :
Code:
						# Refugee and truck resettle
						n = CvEventInterface.getEventManager().resettleID(iUnitType)
						if n > 0:
							art = ArtFileMgr.getInterfaceArtInfo("INTERFACE_FURY_RESETTLE").getPath()
							CyInterface().addMessage(gc.getGame().getActivePlayer(), True, 10, CyTranslator().getText("TXT_KEY_MESSAGE_TEST",(n,art,)), None, 0, None, ColorTypes(7), 0, 0, False, False)
							screen.appendMultiListButton("BottomButtonContainer", art, 0, WidgetTypes.WIDGET_GENERAL, n, n, False)
Plus this TEXT in any text file of the mod:
Spoiler :
Code:
	<TEXT>
		<Tag>TXT_KEY_MESSAGE_TEST</Tag>
		<English>Message Test %d1, %d2</English>
		<French>Message Test %d1, %d2</French>
		<German>Message Test %d1, %d2</German>
		<Italian>Message Test %d1, %d2</Italian>
		<Spanish>Message Test %d1, %d2</Spanish>
	</TEXT>
When you have such a unit that can use the button, two numbers sould appear as a message: the first one should be 665 or 667 (a refugee or a caravan) and a number that possibly defines the art button number (?). It changes each turn on my end so I'm not sure at all what I'm doing! :lol:
 
Well this is narrowing things down in the wrong way. The game didn't even display the message. Then when I removed the added art it displayed the proper numbers for the proper units: 665 for refugees, 667 for trucks. I never thought adding 33.8 mb of art assets would make python so sad.

Hold on. I think I figured out what was wrong with it. It seems that a lot of the dds files I was using were saved with mipmaps. I don't know why, but after I resaved them all without mipmaps, like 40 files, the resettle button shows up fine.

consensus: do not save dds files with mipmaps. Pythons hate that.

I really need to keep which games require mipmaps and which don't in line. Thank you all very much for your help. I really would not have figured this out on my own.


Link to video.
 
Well, you really did find it by yourself. :goodjob:
 
I'm trying to get a version of Regicide working whereby, when a civ's King unit is killed, every city enters 8 turns of revolt.

So far the only Regicide code I've been able to get working *at all* with my mod is this, which of course destroys every city of the civ whose King is killed:
Code:
		'determine owner of lost unit'
		player = PyPlayer(unit.getOwner())
		attacker = PyPlayer(iAttacker)
		'check if unit killed was a king'
		if unit.getUnitType() == gc.getInfoTypeForString("UNIT_KING"):
			'loop through cities and destroy each one'
			CityList = player.getCityList()
       	        	for City in CityList:
               	        	City.GetCy().kill()
		if (not self.__LOG_UNITKILLED):
			return

		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
Can anybody show me the code to put in place of "City.GetCy().kill()" (or wherever it should go) to force 8 turns of revolt in all cities? I'm not exactly conversant in Python :sad:

And if that's not even possible, I'd settle for the line of code that triggers an event. I know how to force 8 turns of revolt in the capital (which is better than nothing) through events.
 
Assuming that you're talking about Platyping's Mod Comp, it is already on the original version. If you just want the Anarchy, replace in CvEventManager 'def onUnitKilled' the code
Code:
Regicide.Regicide().Death(unit.getOwner(), unit)
by the corresponding code in the file Regicide 'Death' function.

With some necessary adjustmemts of the variables used, it gives:
Spoiler :
Code:
	def onUnitKilled(self, argsList):
		'Unit Killed'
		unit, iAttacker = argsList
		player = PyPlayer(unit.getOwner())
		attacker = PyPlayer(iAttacker)
## Regicide Start ##
		if unit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_KING"):
			pPlayer = gc.getPlayer(unit.getOwner())
			pPlayer.changeAnarchyTurns(8)
			CyInterface().addMessage(unit.getOwner(),True,15,CyTranslator().getText("TXT_KEY_KING_DIED",()),'',0, gc.getUnitCombatInfo(gc.getInfoTypeForString("UNITCOMBAT_KING")).getButton(), gc.getInfoTypeForString("COLOR_WARNING_TEXT"), unit.getX(), unit.getY(), True,True)
## Regicide End ##
		if (not self.__LOG_UNITKILLED):
			return
		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
 
I'm actually not using Platyping's mod comp. Would the code you posted require Platy's "Regicide.py" and all that other stuff? Because it seems to have no effect for me.
 
The code is self sufficient if you have a UNITCLASS_KING. Adjust it in the code if needed.

The message will trigger if you have a TXT_KEY_KING_DIED and a UNITCOMBAT_KING. Just replace the button by, for example:
Code:
'Art/Interface/Buttons/Crown.dds'

or the text by something like:
Code:
CyInterface().addMessage(unit.getOwner(),True,15,'The empire mourns at the death of the king!','',0,'Art/Interface/Buttons/Crown.dds', gc.getInfoTypeForString("COLOR_WARNING_TEXT"), unit.getX(), unit.getY(), True, True)
 
I made the changes you suggested (I don't have a separate UnitCombat for the king), but when I test it with a fresh game, nothing happens when my king is killed by barb warriors I place there via WorldBuilder.

This is everything I have under OnUnitKilled (it includes one of Platyping's promotions, which I've given a new name to). Am I missing something simple?
Code:
	def onUnitKilled(self, argsList):
		'Unit Killed'
		unit, iAttacker = argsList
		'determine owner of lost unit'
		player = PyPlayer(unit.getOwner())
		attacker = PyPlayer(iAttacker)
## Regicide Start ##
		if unit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_KING"):
			pPlayer = gc.getPlayer(unit.getOwner())
			pPlayer.changeAnarchyTurns(8)
			CyInterface().addMessage(unit.getOwner(),True,15,'The empire mourns at the death of the king!','',0,'Art/Interface/Buttons/Units/king.dds', gc.getInfoTypeForString("COLOR_WARNING_TEXT"), unit.getX(), unit.getY(), True, True)
## Regicide End ##
## Blood Pact (Revenge) Start ##
		if unit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_REVENGE")):
			pPlot = unit.plot()
			for iUnit in xrange(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(iUnit)
				if pUnit.isNone(): continue
				if pUnit.isDead(): continue
				if pUnit.getOwner() == unit.getOwner():	
					pUnit.setDamage(pUnit.getDamage() - (unit.getLevel() * 10), false)
## Blood Pact (Revenge) End ##
		if (not self.__LOG_UNITKILLED):
			return
		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
Again, the original code I posted (that destroys every city) works fine. I'm very confused :sad: ...Does it only trigger if the king unit is actually a *combat* unit? Mine is coded as a "SPECIALUNIT_PEOPLE" but I can certainly change that if I have to.
 
What Class is your UNIT_KING?

Try it with
Code:
if unit.getUnitType() == gc.getInfoTypeForString("UNIT_KING"):
otherwise.
 
The King is UNITCLASS_KING. I tried it with "gc.getInfoTypeForString("UNIT_KING")" but no luck there either.
 
Oh, yes, re-reading your posts: your unit probably needs to have a UNITCOMBAT_ defined for the onUnitKilled to trigger! try recon or whatever.
 
That worked *after* I gave the King both a UNITCOMBAT other than "none" AND a nonzero iCombat score.

Of course, now the trouble is that the King model I'm using has no combat animations! So I guess I get to find a new unit model. Unless there's some other way?...

Very strange that the "destroy all cities" version of the code worked even though the King had no UNITCOMBAT and no iCombat.
 
It all depends on the conditions set in the dll. You could try it with onUnitLost instead but it requires a Python Callback.
 
All python functions you for Civ 4 you can found here
http://civ4bug.sourceforge.net/PythonAPI/
I don't read all post, but i will try to help.
How i can see KING is very important unit.
If he die, empire die too.
You put king in game, what that unit really do in your game ? Does AI will know what to do with their own king (attack, retreat with them, etc..) ? If AI don't know, give KING survivor promotion, that will be more interesting, or PROMOTION_REBIRTH (Platy's promotion).
I start from that if AI can't use this it's not fun and i don't want that, or try to do that AI can indirect use that.
You can write your code in several functions, unitKilled, unitLost, BeginGameTurn, BeginPlayerTurn, and write if player haven't KING (die, lost, removed via WB), kill player, empire, etc.. that is idea.
If you have problem with king send me i unit i will try to found animation for them.
 
The king unit I'm using is set up to use Great General animations. If there are animations out there that enable that unit to fight, I'd love to get them... I hunted around in the Downloads section most of last night with no luck finding that or anything similar. I'm even happy to switch unit graphics provided that the new one looks fairly generic.
 
Me need little help. I want to make 4 scenarios about Tiberium Wars on Global Earth Map. First, Second, Third and Fourth Tiberium War. For now i am only found this ( http://cnc.wikia.com/wiki/Tiberium_universe_timeline ), and i am played Command & Conquer 3 Kane Edition and Kane's Wrath, and i know some story about this war (3rd Tiberium War). I don't know on beginning of each war, which fraction (GDI, NOD, or some another(Scrin, Forgotten, etc)) controlled which territory (sorry for this bad phrase, i don't know how better to translate in on English), and positions of main divisions, and most important battles in each wars. Because i want to make reconstruction of these wars, not 100% accurate, but with 75% and more i will be so happy, and all of you will be so happy too, because i will incorporate these scenarios in my mod RECONSTRUCTION.
 
Perhaps we will be very happy but this really has nothing to do with this thread. ;)
 
Top Bottom