Quick Modding Questions Thread

For a modcomp I was also working on, I am using this code to make a list of a player's cities:
Your indentation is all over the place, but other than that you could just use PyHelpers for this:
Code:
import PyHelpers
...
pyPlayer = PyHelpers.PyPlayer(player)
lPlayerCities = pyPlayer.getCityList()

I am also having trouble with this code.
Here you don't wanna use PyHelpers:
Code:
pPlayer = gc.getPlayer(iPlayer)
if pPlayer.isGoldenAge():
(You can leave out the extra set of parenthesis and also the actual True value. Because the logic would just be "if True == True" and if that equals "True" then... One True is enough.)
 
For a modcomp I was also working on, I am using this code to make a list of a player's cities:

Code:
playercities = []
NumCities = player.getNumCities()
                                while (len(playercities) <= NumCities):
                                        city = player.nextCity()
                                        playercities.append(city.getName())

How can I modify this code to make it work? Right now this function is getting a callback.
Code:
city = player.nextCity()

I don't understand the problem (it's technically wrong phrased imho).
It is also a bit buggy, correct would be:
PHP:
                        playercities = []
			pCity, iNextCity = player.firstCity(False)
			while (pCity):
                                playercities.append(pCity.getName())
                                pCity, iNextCity = player.nextCity(iNextCity, False)

Edit: The indentation looks here like crap, as usual.
 
Scenario setting: Should you set starting units in "sleep" mode or "non-sleep" mode ?
 
What is sleep mode?
 
It's "fortify" for every unit which can't really fortify.

Scenario setting: Should you set starting units in "sleep" mode or "non-sleep" mode ?

Depends...partially i'd say.
Some units in every city should sleep, if you designed them as city defenders, the rest probably not.
 
It's "fortify" for every unit which can't really fortify.
So its a unit action then? Can you set preset unit actions in the WBS? :confused:
 
You can set the status of an unit, not what it will do next.
And i haven't been sure, if you can do it in the WB or only ingame, and had to search for an example quite a bit, but it's possible:
PHP:
	BeginUnit
		UnitType=UNIT_SWORDSMAN, UnitOwner=6
		Damage=0
		Level=1, Experience=0
		FacingDirection=4
		Sleep
		UnitAIType=UNITAI_ATTACK
	EndUnit
 
Well there you go! I guess you learn something new every day! :king:
 
Depends...partially i'd say.
Some units in every city should sleep, if you designed them as city defenders, the rest probably not.
OK ... That makes it easier to decide.

It's just when you start a scenario, you can often have to make 100's of starting action decisions.
 
Question: how do I modify a Wonder so that only a specific civ can build it? I can't find anything in CIV4BuildingInfos.xml...
 
You can restrict it by making it into a unique building for the civ by either:

1) making the building class have a DefaultBuilding type of NONE in CIV4BuildingClassInfos.xml and adding it to the Buildings list in CIV4CivilizationInfos.xml for the civ that should be able to built it so that it can build the actual type for that class
or
2) adding it to all of the other civ's Buildings lists in CIV4CivilizationInfos.xml, specifying a BuildingType of NONE for that class for them, thereby blocking them from building it (this is how the barbarians are blocked from building a lot of stuff, including all of the wonders, in the unmoded game).

Option 1 may sound easier since it involves fewer actual changes that need to be entered, but it tends to fail for some people (it may be related to them running Vista, or something like that).

Because of that, option 2 is probably better - it also involves making changes to only 1 file instead of 2 (just CIV4CivilizationInfos.xml) but you have to add stuff for every civ except one. This could make things more complicated if you are using modular loading of civilizations (you need to go through them all and block them from building the wonder in each of the individual CivilizationInfos files).
 
You can restrict it by making it into a unique building for the civ by either:

1) making the building class have a DefaultBuilding type of NONE in CIV4BuildingClassInfos.xml and adding it to the Buildings list in CIV4CivilizationInfos.xml for the civ that should be able to built it so that it can build the actual type for that class
or
2) adding it to all of the other civ's Buildings lists in CIV4CivilizationInfos.xml, specifying a BuildingType of NONE for that class for them, thereby blocking them from building it (this is how the barbarians are blocked from building a lot of stuff, including all of the wonders, in the unmoded game).

Option 1 may sound easier since it involves fewer actual changes that need to be entered, but it tends to fail for some people (it may be related to them running Vista, or something like that).

Not Vista related, i had the problem myself, on a XP machine. Started a game with a civ which had a unit where the default class was none. The game then crashed after the first turn.
-> go with option 2.
 
I don't know of any list of explanations for UNITAI, but for the most part they do what their names suggests. If you are familiar with C++ you can look in CvUnits.cpp in the SDK source code to figure out what they do. If you're not familiar with C++ and you have a question about a particular UNITAI just ask and myself or somebody else who happens along will hopefully be able to answer it.
 
For now, we will say 'not yet', but I get the feeling I'll soon have to know the basics at least. But alright, I will keep your offer in mind. The one I was really wondering about was the counter, and the city counter... I can imagine what they do, but specifics could save me backwork later.
 
Can be done with a small python addition in Assets\Python\CvGameUtils.py, change the entry for canRazeCity to this here:
PHP:
	def canRazeCity(self,argsList):
		iRazingPlayer, pCity = argsList
###new code - barbs can't raze holy cities start
		if pCity.isHolyCity () and gc.getPlayer(iRazingPlayer).isBarbarian():
                        return False
###new code - barbs can't raze holy cities end		
		return True

If you're not familiar with python: Attention, the white spaces here are important, if you copy anything over to the file, then copy the white spaces too.
 
Back
Top Bottom