Quick Modding Questions Thread

How to add "pushMission" in this code?
Code:
        def checkTurn(self, iGameTurn):
		
		if (iGameTurn == 2):
                        self.makeUnit(gc.getInfoTypeForString('UNIT_SETTLER'), iRome, tArezzo, 3)
                self.flipCity(2, tMilano, 0, 1, iRome, [])
And what should I write in "pushMission"?
 
What mission do you want to push?

If you just want the settler to go settle somewhere else then ensuring it has the UNITAI_SETTLE AI type set may be enough for you.

Pushing a mission in Python is done via the CySelectionGroup rather than an individual unit. You can see the API for it here: http://civ4bug.sourceforge.net/PythonAPI/index.html.

I want settler to move in landing plot. I suppose code must be like this:
Code:
units[0].getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, landingPlot, units[0])
?
 
I'm more of a C++ coder than Python so I can't comment on the exact syntax you need but if you just want the unit to move to a location then you can probably forget most of those arguments and accept the defaults. Try just using the following:

Code:
units[0].getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY())
 
Code:
units[0].getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY())
Fine, but how to insert this into my code?
 
If you look at the API again there is a method CyUnit method called getGroup() that returns the CySelectionGroup and CyPlayer has a method initUnit() so given the player that you want to create the unit for the following should work:

PHP:
eSettler = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNITCLASS_SETTLER')
pUnit = pPlayer.initUnit(eSettler, [xCoord], [yCoord], UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
pUnit.getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY())

You would need to plug in the xCoord & yCoord values to get that to work.

Again, I am not a Python coder, but reading the API that seems like it should work. You probably need someone who uses Python more than me if you want a good solution :)
 
Need help! Why this code doesn't work? This is in one file.
Code:
class FlipCity:

    def giveTech( self, iTech, iPlayer ):
        for iPlayer in range(gc.getMAX_PLAYERS()):
        pPlayer = gc.getPlayer(iPlayer)
        iteam = pPlayer.getTeam()
        TheTeam = gc.getTeam(iTeam)
        for iTech in range(gc.getNumTechInfos ()):
            TheTeam.setHasTech(iTech,True,iPlayer,False,False)


    def setup(self):
             
        # display welcome message
        self.displayWelcomePopup()
				
	##techs
            teamRome.setHasTech(iGunpowder, True, iRome, False, False)
 
Guys thanks for the responses. My apologies for late responses from me, I work in film production and my days are 12-15 hours long (just work) + travel, etc. So when I work I can't even check emails.

Lets move this to another thread as you suggested.
 
How to add techs for civs by Python in one file? What is wrong in this code?
Code:
# initialise player variables to player IDs from WBS
iRome = 0


pRome = gc.getPlayer(iRome)

teamRome = gc.getTeam(pRome.getTeam())

iGunpowder = CvUtil.findInfoTypeNum(gc.getTechInfo,gc.getNumTechInfos(),'TECH_GUNPOWDER')

class NewTechs:

	def giveTech( self, iTech, iPlayer ):
		"""Gives advance iTech to iPlayer."""
		iTeam = gc.getPlayer(iPlayer).getTeam()
		gc.getTeam(iTeam).setHasTech(iTech, True, 0, False, False)

	def setup(self):
             
		# display welcome message
		self.displayWelcomePopup()

			
                def checkTurn(self, iGameTurn):
		        ##techs
		        if (iGameTurn == 2):
				        teamRome.setHasTech(iGunpowder, True, iRome, False, False)
 
@Dniwe: it's impossible to answer your questions the way you ask them.

We require a bit more context for what you are trying to accomplish, and what exactly "doesn't work". Does nothing happen? Does something unexpected happen? Do you get a Python exception (and are they even enabled)?

I'd also like to know if these new Python classes you have defined are integrated into the code somehow. The methods you write here need to be called from somewhere to have an effect, otherwise it is not surprising if nothing happens.
 
@Dniwe: it's impossible to answer your questions the way you ask them.

We require a bit more context for what you are trying to accomplish, and what exactly "doesn't work". Does nothing happen? Does something unexpected happen? Do you get a Python exception (and are they even enabled)?

I'd also like to know if these new Python classes you have defined are integrated into the code somehow. The methods you write here need to be called from somewhere to have an effect, otherwise it is not surprising if nothing happens.
i would like make it like at RFC, but if I try copying code from several files, nothing happens. My knowledge about Python is small so ask you to help me.
 
Are you modding RFC? The code there relies on several assumptions and a code framework that does not exist in base BtS or other mods.

In any case, you should answer the questions I've asked.
 
CIV Gold.
 
Hello, I got this question
Could someone please explain in detail (as much as possible) exactly how these work for units:

iCultureGarrison
iAsset
iPower

thanks!

http://modiki.civfanatics.com/index.php/Civ4UnitInfos

iCultureGarrison - The suppression value of a unit while garrisoned in a rebelling city.
iAsset - Affects the AI's behaviour towards it in some way.
iPower - Affects the amount that the AI factors it into the equation when determining your military power.

iPower - this is for how many soldiers you have similar that, and make good balance for this if you modding, because AI calculate this, and this is important for declaring war (AI), stronger or weaker with military from AI. Calculate is AI(total power)/your(total power) or conversely.
 
The power value of a civ is summed up over all units that civ controls plus a little extra for e.g. population and technologies. Look for calls to CvPlayer::changePower in the DLL code for full details.
The power of a unit typically equals its combat strength (iCombat). Units with really useful abilities, like Axeman, get 1 extra power. Units with significant drawbacks, such as Missiles or Machine Gun, have less power than strength. To the AI, two Axemen are as powerful as one Cuirassier. :undecide:
 
thanks guys!
So it is still a mystery what Asset exactly does?

Maybe yes maybe no, but i tested lots of Asset and i have one personal conclusion. If you have several similar units with different strength at same time (you can build them in this era) like LIGHT_TANK, MEDIUM_TANK, HEAVY_TANK, all of this units have same UNIT_AI example (ATTACK and COUNTER) different is only, they have different cost, strength, Power. In this moment you confuse AI if you haven't different Assets, and AI will build lots of HEAVY_TANK for example. With Assets you give AI to these similar units treated different, for example LIGHT_TANK will have Asset=4, MEDIUM_TANK will have Asset=5, HEAVY_TANK will have Asset=6, and AI will not be confused and build this 3 units more balanced, than you have same Asset for all of these 3 units.
 
yes this does make sense. I keep this in mind ;)
However does Asset in this still scales up with rest of the stats or only used to differentiate for units of same rank/era?

For example say you have following units with assets:

Spearman (2), Pikeman (2), Rifleman (2), Infantry(2), Tank (3)

vs

Spearman (2), Pikeman (4), Rifleman (6), Infantry(8), Tank (10)
 
Back
Top Bottom