Platyping's Python

see above :p mine allows for a change in capital...

by one time effect are you saying that you get to see it for one turn? becuase that causes problems if the city is destroyed that turn or the capital changed that turn.

otherwise it means the visibility is always tracked to that city, even if it is destroyed.
 
No, I meant that he should just reveal the one cities, and don't keep track of changes. It's normally totally unlikely that the AI moves its capital, so it should not be a big problem for the effect. And if a civ is already competely conquered before you can see it, then something's wrong with your play style :p. (not serious ^^)
 
Actually I thought of a solution before, but just never bother to test it :D

Adding vision to a plot was done before in CN Tower which provides a vision around the city itself, as well as hubble space telescope which moves around the world.

Both of them use the same type of code:
CN Tower: pPlot.changeVisibilityCount(iTeam, 5, 0)
Hubble: pPlotX.changeVisibilityCount(iTeam, 5, -1)

The first input is obvious, team ID, the third input determines whether you can see invisible units.
The second input is an integer change that I don't know what it is about, so I just randomly input a value and try.

I wonder if I use a super high value like 999, then when a palace is built, loop through each city and check if plot visibility > 999, then that must be the old capital, so - 999 from that plot.

Same thing for onCityAcquired, if visibility is > 999, this must be old capital, so - 999, then search for new capital and add 999 to it.

Just a theory, since I dunno what the heck is the integer change about :D

To be complete, additional codes have to be done when a new colony is born as well, to add vision to his/her capital

P.S.
Of course adding permanent vision on Built and ignoring changes thereafter is the easiest solution, but you know I don't really like on-built effects for benefits that should not be so.

If the benefit states "Provides vision on Rivals' Capitals", then I want it to change when locations change :D
 
I would say that "random" variable is probably something to do with strength of visibilty and could cause some problem down the line, if I were you I would use the ScriptData() as it is... shall we say... safer.

But at least the script data works on capital change :p
 
Hey quick question
Code:
if CyMap().getMapScriptName () =="Korean War.CivBeyondSwordWBSave":
			if iGameTurn == 8:
				iNorthKorea = -1
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive():
						if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_TURK"):
							iNorthKorea = pPlayerX.getTeam()
				pNewUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNIT_ICBM"), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
So adding units per turn in my korean scenario, i beleive so far it is good correct (beside the last line)?
So for the adding unit line, the X and Y spots, I am just going to put the plots x,y I want it to go. do I need to put those in quotes or just the number? For Unitai do I put just UNITAI_XXXX or again quotes? And for direction what are the options?
 
hmmm couple of things here, the CyMap().getMapScriptName () you have copied from the API and it has a whitespace between the Name and the () this must be removed. Also it seems as if the indentation is too great... It is fine in the main block but after the first line there is too much.

you can keep the pCity.getX() and pCity.getY() as they are they are fine and they return a number but if you want constant coords then use the numbers!

who do those ICBM's belong to (I know you said ignore the last line but I can't help it :p)

The DirectionTypes:

-1 = NO_DIRECTION
0 = DIRECTION_NORTH
1 = DIRECTION_NORTHEAST
2 = DIRECTION_EAST
3 = DIRECTION_SOUTHEAST
4 = DIRECTION_SOUTH
5 = DIRECTION_SOUTHWEST
6 = DIRECTION_WEST
7 = DIRECTION_NORTHWEST

so you can either replace DirectionTypes.DIRECTION_NONE with one of the above numbers or replace the DIRECTION_NONE with one of the Words above and no the unitAI is not a string so do not need to be in quotation marks

hope that helped!

edit:

here is the fixed whitespace and indentation!:
Code:
if CyMap().getMapScriptName() == "Korean War.CivBeyondSwordWBSave":
    if iGameTurn == 8:
        iNorthKorea = -1
        for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
            pPlayerX = gc.getPlayer(iPlayerX)
            if pPlayerX.isAlive():
                if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_TURK"):
		    iNorthKorea = pPlayerX.getTeam()
        pNewUnit = pPlayer.initUnit(gc.getInfoTypeForString("UNIT_ICBM"), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)

edit edit:

heres the link to where you can find the types!:

http://civ4bug.sourceforge.net/PythonAPI/Types/TypeList.html
 
I was asking about the last line, but I was also saying is the rest right too

hmm thats weird, theres a space in my 1914 scenario one and it works

yess I want to replace the city things with numbers since Im telling them to spawn in an ocean so there aint no cities:lol:

I should replace pPlayer with iNorthKorea on the last line correct?
I coppied this code from another part, don't worry Im not really giving NK nukes in a korean war scenario:lol:

Last question
I want to place a bunch of troops on a transport in the ocean, is there anyway to put units on a transport? Beccause if I make them go into the ocean, the units will probably not be on the transport and when transport moves the units are just in the middle of the ocean. Anyway around that?
 
it should work by just spawning the units onto the transport (which you would spawn before the units)... try it out

remember what I said:

i represents a number
p represents a pointer

so no, iNorthKorea will not work... for one it is a team number and even if you got the team it is a method of CyPlayer() and it is a number. who do you want the units to go to? every member of the team or the leader? if so:

pNorthKorea = gc.getPlayer(gc.getTeam(iNorthKorea).getLeaderID())
then pNorthKorea.initUnit(....)

otherwise you need to loop through all game player and find if they are on that team and if they are then spawn the unit for that player and continue
 
So this should spawn a North Korean infantry on plot 15,29 and it will have the ai_attackcity and will be facing south east
Code:
## Korean War Start ##
		if CyMap().getMapScriptName() =="Korean War.CivBeyondSwordWBSave":
			if iGameTurn == 8:
				iNorthKorea = -1
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive():
						if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_NORTH_KOREA"):
							iNorthKorea = pPlayerX.getTeam()
							pNorthKorea = gc.getPlayer(gc.getTeam(iNorthKorea).getLeaderID())
				pNewUnit = pNorthKorea.initUnit(gc.getInfoTypeForString("UNIT_INFANTRY"), 15, 29, 5, 3)	
		## Korean War End ##
The only thing Im not sure is right is for the direction and ai type, do I need to do
Code:
UnitAITypes.5
or just the 5?
Same with direction does it need to be
Code:
DirectionTypes.3
or just 3
 
just 5 and just 3, however I would recommend using:

UnitAITypes.UNITAI_ATTACK_CITY
DirectionTypes.DIRECTION_SOUTHEAST

both for your own reference and incase I am wrong and you can't use ints

also you don't need to say iNorthKorea = -1 and the initUnit should be at the same indentation as pNorthKorea is defined otherwise there is nothing there if the if statement says false. Also I don't think you need to say pNewUnit = pNorthKorea.initUnit(...) you can just say pNorthKorea.initUnit()

the API also says this:

CyUnit initUnit (UnitType iIndex, INT iX, INT iY, UnitAIType eUnitAI, DirectionType eFacingDirection)
CyUnit* initUnit(UnitTypes iIndex, plotX, plotY, UnitAITypes iIndex) - place Unit at X,Y NOTE: Always use UnitAITypes.NO_UNITAI

I am pretty sure that is wrong as we have used other ai before... suggestions from plat, the_J. is the API wrong?

edit:
here is the code as I see it:
Code:
iKoreaUnitX = 15
iKoreaUnitY = 29
## Korean War Start ##
		if CyMap().getMapScriptName() =="Korean War.CivBeyondSwordWBSave":
			if iGameTurn == 8:
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive():
						if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_NORTH_KOREA"):
							iNorthKorea = pPlayerX.getTeam()
							pNorthKorea = gc.getPlayer(gc.getTeam(iNorthKorea).getLeaderID())
                                                        pNorthKorea.initUnit(gc.getInfoTypeForString("UNIT_INFANTRY"), iKoreaUnitX, iKoreaUnitY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.DIRECTION_SOUTHEAST)	
## Korean War End ##
note I defined iKoreaUnitX and iKoreaUnitY for convience define them where appropriate or not at all if you wish (and replace with original numbers in code
 
I would also say that you could use xrange instead of range, I believe it is faster.

Oh and plat, don;t forget to go back and read my other post
 
just 5 and just 3, however I would recommend using:

UnitAITypes.UNITAI_ATTACK_CITY
DirectionTypes.DIRECTION_SOUTHEAST

both for your own reference and incase I am wrong and you can't use ints

also you don't need to say iNorthKorea = -1 and the initUnit should be at the same indentation as pNorthKorea is defined otherwise there is nothing there if the if statement says false. Also I don't think you need to say pNewUnit = pNorthKorea.initUnit(...) you can just say pNorthKorea.initUnit()

the API also says this:

CyUnit initUnit (UnitType iIndex, INT iX, INT iY, UnitAIType eUnitAI, DirectionType eFacingDirection)
CyUnit* initUnit(UnitTypes iIndex, plotX, plotY, UnitAITypes iIndex) - place Unit at X,Y NOTE: Always use UnitAITypes.NO_UNITAI

I am pretty sure that is wrong as we have used other ai before... suggestions from plat, the_J. is the API wrong?

edit:
here is the code as I see it:
Code:
iKoreaUnitX = 15
iKoreaUnitY = 29
## Korean War Start ##
		if CyMap().getMapScriptName() =="Korean War.CivBeyondSwordWBSave":
			if iGameTurn == 8:
				for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
					pPlayerX = gc.getPlayer(iPlayerX)
					if pPlayerX.isAlive():
						if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_NORTH_KOREA"):
							iNorthKorea = pPlayerX.getTeam()
							pNorthKorea = gc.getPlayer(gc.getTeam(iNorthKorea).getLeaderID())
                                                        pNorthKorea.initUnit(gc.getInfoTypeForString("UNIT_INFANTRY"), iKoreaUnitX, iKoreaUnitY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.DIRECTION_SOUTHEAST)	
## Korean War End ##
note I defined iKoreaUnitX and iKoreaUnitY for convience define them where appropriate or not at all if you wish (and replace with original numbers in code

You know, if you want to add units to NorthKorea player...
After the if pPlayerX.getCivization blah blah blah == NorthKorea:
Just use pPlayerX.initUnit blah blah blah, and break the loop.
Why is there a need to use iNorthKorea to find NK's team ID, then use the team ID to find the team leader?
The team leader may not even be NK if there are more than 1 player in the same team

As for the AI type, yeah it is suggested to use NONE although I tried others before.
NONE is suggested because it will then use the default ones for that unit I suppose, so it is easy to copy and paste without editing for me :D
If you use Attack City AI for instance on a worker unit, then some of the worker actions options are missing, which is why I always use NONE unless I really intend it to be just attack city or others

Lastly, where did those 2 numbers 15 and 29 come from? :D
You never know what may have happened from turn 1 till the event activates.
If a rival has built a city at (15,29) and you are at war with him, spawning a unit directly at that plot will capture it immediately.
Of course, since this is a mod, if you know for sure that will not happen, so be it :D

@scriptdata
Never use scriptdata before, so probably have to do some testings first :D
Anyway, why will you define it under onCityBuilt?
 
You know, if you want to add units to NorthKorea player...
After the if pPlayerX.getCivization blah blah blah == NorthKorea:
Just use pPlayerX.initUnit blah blah blah, and break the loop.
Why is there a need to use iNorthKorea to find NK's team ID, then use the team ID to find the team leader?
The team leader may not even be NK if there are more than 1 player in the same team
Can't say I follow you to well here (due to my lack of python skill), i mean I get what your saying but I do not get what to shorten in the code
As for the AI type, yeah it is suggested to use NONE although I tried others before.
NONE is suggested because it will then use the default ones for that unit I suppose, so it is easy to copy and paste without editing for me :D
If you use Attack City AI for instance on a worker unit, then some of the worker actions options are missing, which is why I always use NONE unless I really intend it to be just attack city or others
Since its korean war, and you place a bunch of NK infantry at border, they will by ai defualt, go guard the nearest city instade of invade SK so that wouldnt help:lol:
Lastly, where did those 2 numbers 15 and 29 come from? :D
You never know what may have happened from turn 1 till the event activates.
If a rival has built a city at (15,29) and you are at war with him, spawning a unit directly at that plot will capture it immediately.
Of course, since this is a mod, if you know for sure that will not happen, so be it :D
Since this code is 2 turns after start of game, and it is one square next to SK city that has been capture by NK every time in the 15 times ive tested the mod in the first turn I think it will be fine:lol:
 
Code:
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_NORTH_KOREA"):
This line already told you this player is North Korea, so don't play merry go round and ask him for his team ID, then guess that the leader of his team is North Korea.

Thus, after that line, just use the initUnit codes.
Code:
if pPlayerX.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_NORTH_KOREA"):
        pPlayerX.initUnit(gc.getInfoTypeForString("UNIT_INFANTRY"), 15, 29, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.DIRECTION_SOUTHEAST)
        break
And since you already found who you want, break the for loop

If you are so sure about the co-ords, you can plug the numbers in directly if you want
 
Alright makes pretty good sence

I know how to display a message, but I am not sure how you split it so it says something different to the player receiving then the others.

Also I want to display one of those circle buttons with a "!" in it similar to the global warming, is that possible to display via ptyhon?
 
Code:
CyInterface().addMessage(iPlayer,true,15,CyTranslator().getText("TXT_ALIEN_ASSAULT",(capital.getName(),)),'',0, pNewUnit.getButton(),ColorTypes(11),pPlot.getX(),pPlot.getY(), true,true)
CyInterface().addMessage(iPlayerX,true,15,CyTranslator().getText("TXT_ALIEN_ASSAULT",(capital.getName(),)),'',0, pNewUnit.getButton(),ColorTypes(7),pPlot.getX(),pPlot.getY(), true,true)

Extracted from SETI
iPlayer and iPlayerX will determine who this message is displayed to.
This is player ID, not team ID
As for the picture in the circle, for this case I am using pNewUnit.getButton() to show the unit button in the circle.
If you want to display a "!" in the circle, that is pretty easy as well, just need to know where the artfile is located
 
@plat The reason I do oncitybuilt aswell is to make that when the civ founds it's capital it becomes a "Player Capital" otherwise only when it is conquored or moved will it register as the new capital. though you could probably have the capital script data assigned on building built I guess. just have a check a turn for the Player Capital and reassign when city is taken or new palace built.
 
btw I found that PyHelpers has a function for returning the city list of a civ,

for pCity in (city.GetCy() for city in PyHelpers.PyPlayer(iRome).getCityList()) #iRome being player index

saves you some lines in code, if you wanna use it! It works pretty much how you currently do it. PyHelpers is also imported into CvEventManager by default
 
Hows the script data working?

also I found the purpose of setCultureTimes100()!

as it takes an int when using setCulture() you have to round your floats. where as setCultureTimes100() can allow a city to have float culture. so if you wanted to give 7.5 culture to a city you do setCultureTimes100(iPlayer, 750) whereas setCulture(iPlayer, int(round(7.5))) gives 8
 
Been buzy with other stuff, so didnt try that.

Simple stuff:
Patent
Spoiler :
Civ4ScreenShot0002-16.jpg

The initial idea was prevent others from trading tech that you researched first, but that didnt work so now you get royalty/copyrights whatever fees when others researched what you have.

Doesn't matter if you are the first to research


Countdown to 200: 4
 
Back
Top Bottom