ModModder's Guide

Can anyone tell me how I would, using python get the number of a specific resource owned by a specific player.

Like if the target player is iPPQ and the target resource is Fire Mana, and if PPQ has 3 Fire Mana the function returns 3.
 
GC.getPlayer(iPPQ).countOwnedBonuses(GC.getInfoTypeForString("BONUS_MANA_FIRE"))
That will give you the number of fire mana within the civilizations territory.


GC.getPlayer(iPPQ).getNumAvailableBonuses(GC.getInfoTypeForString("BONUS_MANA_FIRE"))
Will tell you the number of bonuses they have in their capital (which is the same as how many the player has available).

There's a bunch of others too I won't explain, like
GC.getPlayer(iPPQ).getNumTradeableBonuses(GC.getInfoTypeForString("BONUS_MANA_FIRE"))
 
Thanks, that did what I needed it to do.

Also, can I have a confirmation of what I heard about 1.4 that buildings will have an XML tags for N :health: and N :) per Resource?


It is essential for my project.
 
There is a tag called <bForceOverwrite>; Set it for your entry. This will force the game to completely replace the standard entry with that of your module, only way to load default values back in.

However, that means you must have the entire entry for the unit/building/civ/whatever you are modifying. Otherwise, it will simply delete everything that is not listed. So make sure you have the entire entry when using that tag. ;)

In what file do I find the <bForceOverwrite> tag? And what other files do I need to update the name of the Bannor Palace to "Halls of Sabbathiel"?

Of course, the simplest solution would be to just hack the basic CIV4GameText.xml file and be done with it, but I wanted to prove that I could make this change in a modular fashion.
 
In what file do I find the <bForceOverwrite> tag? And what other files do I need to update the name of the Bannor Palace to "Halls of Sabbathiel"?

Of course, the simplest solution would be to just hack the basic CIV4GameText.xml file and be done with it, but I wanted to prove that I could make this change in a modular fashion.

ForceOverwrite should be available in all files.

As for changing a name... Text isn't modular (as in, can't change txtkeys, can only swap them), so just list a new txtkey in the name field for the palace, and then add a textfile with the new txtkey.
 
Can summonable civs be added modularly? And if so, can you tell me which file the triggers are in?
 
I wanted to try a bit of modding, while waiting for a new version with some CTD fixes of this great mod :).

Im having some trouble with the onUnitMove event:


The following code is in the same file, but only on a new turn a textbox is displayed, onUnitMove does not appear to work ( what was the event I started experimenting with :crazyeye: ).

Code:
def onBeginPlayerTurn(self, argsList):
	iGameTurn, iPlayer = argsList
	
	popupInfo = CyPopupInfo()
	popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
	popupInfo.setText("Hi im a text")
	popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_CLOSE", ()), "")
	popupInfo.addPopup(iPlayer)


def onUnitMove(self, argsList):
	pPlot, pUnit, pOldPlot = argsList
	
	iPlayer = pUnit.getOwner()
	
	popupInfo = CyPopupInfo()
	popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
	popupInfo.setText("Hi am a text")
	popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_CLOSE", ()), "")
	popupInfo.addPopup(iPlayer)

Thanks in advance.
 
Can summonable civs be added modularly? And if so, can you tell me which file the triggers are in?

Yes, same way as any other civ for the most part.

Make the civ non-playable (like Infernals, Mercs, etc; It's done in xml). The rest depends on how you want it summoned... Tech researched, ritual, building, etc. Each of the three I listed already has an example (Infernal, Frozen, Mercurians), so shouldn't be too hard. All code would go in an EventManager function, so modular python is required; Can check out the Mekaran module to see how to do that.

I wanted to try a bit of modding, while waiting for a new version with some CTD fixes of this great mod :).

Im having some trouble with the onUnitMove event:


The following code is in the same file, but only on a new turn a textbox is displayed, onUnitMove does not appear to work ( what was the event I started experimenting with :crazyeye: ).

Code:
def onBeginPlayerTurn(self, argsList):
	iGameTurn, iPlayer = argsList
	
	popupInfo = CyPopupInfo()
	popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
	popupInfo.setText("Hi im a text")
	popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_CLOSE", ()), "")
	popupInfo.addPopup(iPlayer)


def onUnitMove(self, argsList):
	pPlot, pUnit, pOldPlot = argsList
	
	iPlayer = pUnit.getOwner()
	
	popupInfo = CyPopupInfo()
	popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
	popupInfo.setText("Hi am a text")
	popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_CLOSE", ()), "")
	popupInfo.addPopup(iPlayer)

Thanks in advance.

onUnitMove is not currently modular (each function needs a small bit of code added to become modular); I'll fix all of EventManager and GameUtils to be modular today.
 
For future reference, if you aren't sure and want to check... Open up the EventInterface, go to the function you want to work with, and check the very end of it; If it has something like the following code, you're good.

Code:
		## *******************
		## Modular Python: ANW 29-may-2010

		for module in command['onBuildingBuilt']:
			module.onBuildingBuilt(self, argsList)

		## Modular Python End
		## *******************

Note that where that code says 'onBuildingBuilt' you should see the specific function name for whatever function you're checking.
 
This is going to come off as a strange question, but I figure it would be smarter to ask here than to dig through the entire game not knowing if I will find anything.

So, here it is.
Is there any model in the game (base, FFH, any FFH modmods or anywhere else that anyone knows.) that is armed with a hand slingshot, like the ones used in ancient times?

If yes, please tell me where to look for it.
 
Define what you mean by 'slingshot'. If you mean "rubber band strung between a two-pronged stick you shoot projectiles out of", I doubt it exists.

If you mean the ancient sling, "pouch spun overhead with a projectile inside, capable of launching projectile in a controlled direction", then the Dwarven Slinger.
 
Define what you mean by 'slingshot'. If you mean "rubber band strung between a two-pronged stick you shoot projectiles out of", I doubt it exists.

If you mean the ancient sling, "pouch spun overhead with a projectile inside, capable of launching projectile in a controlled direction", then the Dwarven Slinger.
The 2nd. Thanks, I will see if I can make something of it. Since it would make for a perfect skirmisher.
Do you per chance know if the unit was custom made from the ground up or converted from another fireaxis unit?
Does not matter, I will work with what I have.
 
One more thing, I got an idea for a unit and need advice from you experts. I just think a lot more people read this thread than they do mine. So here it is for everyone to comment. (since it is a totaly radical shift on the scouting line.)

Update: Idea for both Scout and Hunter replacements:

:strength: Same as normal + 1 and +10% per Fire Mana
:move: Same as normal, maybe normal +1
Free promotions: Blitz, Skirmisher
Unit is capped at 60% or 70% damage.

What do you people think? It should give them a good line of skirmishers that can hit a lot of targets at once but can't kill. The can't kill factor will also mean they can take on multiple units in the same stack if they do win.

What does everyone think? (Also if this is the wrong place, I will edit this out, sorry if it is.)
 
How can i put those lines together so that they can work ?
I tried manny variations but nothing worked. :(
Or do it only works with an upgradeble unit like Adept Mage ?

<PrereqTech>TECH_KNOWLEDGE_OF_THE_ETHER</PrereqTech>
<PromotionType>PROMOTION_CHANNELING2</PromotionType>
<bFreePromotion>1</bFreePromotion>

PS: <-- Beginner in Modding.
 
How can i put those lines together so that they can work ?
I tried manny variations but nothing worked. :(
Or do it only works with an upgradeble unit like Adept Mage ?

<PrereqTech>TECH_KNOWLEDGE_OF_THE_ETHER</PrereqTech>
<PromotionType>PROMOTION_CHANNELING2</PromotionType>
<bFreePromotion>1</bFreePromotion>

PS: <-- Beginner in Modding.

Uhh... What exactly do you mean? What are you trying to accomplish?
 
Double post, but I'd like to announce a new feature. :lol:

I've been working on a module recently (too burned out to do much else atm, lots going on, sorry), and I needed a few mechanics for it. :lol:

The first change is just a graphical addition... A civ's racial type will be displayed in the pedia, under the civ trait.

The second change is potentially useful (and required for something I needed to do involving artstyles...): PyOnPromoTaken. Runs a specified python function as soon as the promotion is taken, and never again (unless stackable, though admittedly I have not tested that part!).

The third change could potentially be very useful, though I'm of the opinion that it should be used sparingly. What is it? SecondaryUnitCombats.

Essentially, promotions can now allow units to take promotions belonging to other unitclasses. I required it for something I wanted to do with commanders... Special promotion which can grant any unit access to all Commander promotions, no matter what we add, remove, change via module, etc. You can list any number of unitcombats, and it will function; I tested it by granting Combat5 both Commander and Adept unitcombats. A warrior became eligible for promotions from both combats. ;)

As of now, it only grants promotions. All other features tied to unitcombat (combat penalties/bonuses, many spells, etc) all remain untouched. These are secondary unitcombats.
 
I tried to give a unit the propability to aquire Channeling 2 with Techdiscoveries.
Is it possible or not and when, then how?
 
Top Bottom