Simple Python Things

Attached :).
I've been busy this afternoon :D.

Okay, what has been changed:
- Civs will not respawn
- If there's a spawn chance, the spawning can only trigger the first time

To transport the first info between savegames, i use scriptData, which is stored in a savegame, at a specific plot (in this case at 3,3, does not really matter which plot).
You have to remerge the CvEventManager, because this info has to be provided in the file.
If you now load a game which has been saved before, you'll get a python exception, but that should not have an influence on the game.
You also should not swap/exchange civs in the XML and then use an old savegame, because that will mix up the saved data.
 

Attachments

Wow. That was even quicker than expected. :eek:

Kudos to you again, and thanks a lot!

(actually, to be honest, I wasn't going to play my old save games again, since I want to play against some of the other leaders I added to test their personalities; however, thank you for the tip on the saved games, regardless)
 
Hey, The J, I've been testing your changes to your Spawn A Civ, and it seems the respawning issue has been fixed. :D

However, I've noticed that my capital city units (heroes, in this case) have not been spawning with the civ. Do you think you might have missed something in your new code, or is it probably just an error I made while merging?
 
Crap, right.
I made a small adjustment before to make sure, that the units will only be added if there's really a city, but tied it a wrong variable.
Took that check out (well, should not have really an impact if it's there or not), changed file is attached.
 

Attachments

Hello J, I've a request. You wrote a piece of code which added some culture to all of your cities after finishing a project. Here it is:

Code:
		## LASCAUX CAVE PAINTINGS - START ## 
		if iProjectType == gc.getInfoTypeForString("PROJECT_LASCAUX"): 
			iPlayerID = pCity.getOwner()
			pPlayer = gc.getPlayer(iPlayerID)
			pPID = pPlayer.getID()
			iX = pCity.getX()
			iY = pCity.getY()
			numCities = pPlayer.getNumCities()
			TheNumberOfCultureWhichShouldBeAdded = 20
			(loopCity, iter) = pPlayer.firstCity(false)
			while(loopCity):
				cityOwner = loopCity.getOwner()
				if ( not loopCity.isNone() and loopCity.getOwner() == iPlayerID ): #only valid cities
					loopCity.changeCulture(iPlayerID, TheNumberOfCultureWhichShouldBeAdded,True) 
				(loopCity, iter) = pPlayer.nextCity(iter, false)
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_LASCAUX",()),'',0,'Art/Interface/Buttons/Buildings/Lascaux.dds',ColorTypes(11), iX, iY, True,True)
		## LASCAUX CAVE PAINTINGS - END ##

I'd like the TheNumberOfCultureWhichShouldBeAdded be depended of gamespeed, i.e. on quick speed 5 culture to all cities, on normal speed 10 culture, on epic speed 20 culture to all cities...etc...
Is this possible?
 
Mathematics...that took now a bit time, more than i thought...a shame for my skills
But sure, yes:

PHP:
TheNumberOfCultureWhichShouldBeAdded = 40*(2**(-1* CyGame().getGameSpeedType () ))

Should add 40 for marathon, 20 for epic, 10 for normal and 5 for quick.
 
Mathematics...that took now a bit time, more than i thought...a shame for my skills
But sure, yes:

PHP:
TheNumberOfCultureWhichShouldBeAdded = 40*(2**(-1* CyGame().getGameSpeedType () ))

Should add 40 for marathon, 20 for epic, 10 for normal and 5 for quick.

Thanks, but I've also two custom made gamespeeds: odyssey and endless...
If I understand this correctly speed quick=-3, normal=-2, epic=-1, marathon=0, odyssey=1 and endless...=2 thus
culture(quick)=40 * (2^-3)= 40 * 1/8 =5
culture(normal)=40 * (2^-2)= 40 * 1/4 =10
culture(epic)=40 * (2^-1)= 40 * 1/2 =20
culture(marathon)=40 * (2^0)= 40 * 1 =40
culture(odyssey)=40 * (2^1)= 40 * 2 = 80
culture(endless...)=40 * (2^2)= 40 * 4 = 160

Am I right?
 
The "number" of the gamespeeds is determined by their order in the GameSpeedInfos.xml.
The first one has 0, the second 1, etc.
If you added your new gamespeeds at the beginning (i guess so, because they are slower than marathon, so before marathon), the algorithm itself should stay the same (Endless then would be 0, until quick = 5), you only have to replace the 40 with 160.
 
The "number" of the gamespeeds is determined by their order in the GameSpeedInfos.xml.
The first one has 0, the second 1, etc.
If you added your new gamespeeds at the beginning (i guess so, because they are slower than marathon, so before marathon), the algorithm itself should stay the same (Endless then would be 0, until quick = 5), you only have to replace the 40 with 160.

Thanks, I understand now :goodjob:
 
Hey TJ,

I hope you have the time to take a look at a Python-error I'm having with Lascaux since I upgraded and added some modcomps. Here's the info:

Python-code in CvEventManager.py, the red line is causing the trouble:
Code:
		## LASCAUX CAVE PAINTINGS - START ## 
		if iProjectType == gc.getInfoTypeForString("PROJECT_LASCAUX"): 
			iPlayerID = pCity.getOwner()
			pPlayer = gc.getPlayer(iPlayerID)
			pPID = pPlayer.getID()
			iX = pCity.getX()
			iY = pCity.getY()
			numCities = pPlayer.getNumCities()
			TheNumberOfCultureWhichShouldBeAdded = 160*(2**(-1* CyGame().getGameSpeedType () ))
			(loopCity, iter) = pPlayer.firstCity(false)
			while(loopCity):
				cityOwner = loopCity.getOwner()
				if ( not loopCity.isNone() and loopCity.getOwner() == iPlayerID ): #only valid cities
					[COLOR="Red"]loopCity.changeCulture(iPlayerID, TheNumberOfCultureWhichShouldBeAdded,True)[/COLOR] 
				(loopCity, iter) = pPlayer.nextCity(iter, false)
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_LASCAUX",()),'',0,'Art/Interface/Buttons/Buildings/Lascaux.dds',ColorTypes(11), iX, iY, True,True)
		## LASCAUX CAVE PAINTINGS - END ##

The PythonErr.log:
Traceback (most recent call last):
File "BugEventManager", line 350, in _handleDefaultEvent
File "CvEventManager", line 968, in onProjectBuilt
ArgumentError: Python argument types in
CyCity.changeCulture(CyCity, int, float, bool)
did not match C++ signature:
changeCulture(class CyCity {lvalue}, int, int, bool)

Screenies:
Spoiler :
lascauxpythonerror1.jpg

lascauxpythonerror2.jpg

The added modcomps since last properly version:
0447. Added Project Help Tag v0.1BtS by TheLopez
0448. Updated Route Pillage to 0.4BtS by TheLopez (found no differences!)
0449. Updated Bonus Commerce Modifier by saibotlieh (CvGameTextMgr.cpp)
0450. Updated Building Heal Rate to 0.3BtS by TheLopez
0451. Updated Pirates to 0.51BtS by TheLopez
0452. Added modcomp Building Commerce Yields by davidlallen and Afforess, Civilopedia not working
0453. Added modcomp Combat Attack Defense Mod v0.1BtS by TheLopez
0454. Tweaked promotions fieldsman, quell revolt, desert combat and arctic combat
0455. Updated to Better BTS AI v1.01f by jdog
0456. Added Advanced Diplomacy by Afforess
0457. Fixed fish bonus. Fish will no longer appear in ocean
0458. Added Civic Infos Plus by Aussie_Lurker
0459. Adjusted civics
0460. Added Extra Trade Commerce Modifiers by TheLopez
0461. Added Occasional Promotions by killmeplease

And the occurence of "changeCulture" in the SDK:
CvUnit.cpp(17653): pLoopPlot->changeCulture(eTargetPlayer, -iCultureTransfer, false); // IDW CHANGE, NOTHING CHANGED
CvUnit.cpp(17660): pLoopPlot->changeCulture(getOwnerINLINE(), iCultureTransfer, true); // IDW CHANGE, NOTHING CHANGED
CvUnit.cpp(17716): pPlot->changeCulture(eTargetPlayer, -iCultureTransfer, false); // IDW CHANGE, NOTHING CHANGED
CvUnit.cpp(17718): pPlot->changeCulture(getOwnerINLINE(), iCultureTransfer, true); // IDW CHANGE, NOTHING CHANGED
CvUnit.cpp(17875): pNearestCity->changeCulture(getOwnerINLINE(), iTotalCommerce, true, true); // NOTHING CHANGED

CyCity.cpp(1738): void CyCity::changeCulture(int /*PlayerTypes*/ eIndex, int iChange, bool bPlots) // NOTHING CHANGED
CyCity.cpp(1741): m_pCity->changeCulture((PlayerTypes)eIndex, iChange, bPlots, true); // NOTHING CHANGED

CyCity.h(390): void changeCulture(int /*PlayerTypes*/ eIndex, int iChange, bool bPlots); // NOTHING CHANGED

CyCityInterface1.cpp(373): .def("changeCulture", &CyCity::changeCulture, "void (int PlayerTypes eIndex, int iChange, bool bPlots)") // NOTHING CHANGED

CyPlot.cpp(899): void CyPlot::changeCulture(int /*PlayerTypes*/ eIndex, int iChange, bool bUpdate) // NOTHING CHANGED
CyPlot.cpp(902): m_pPlot->changeCulture((PlayerTypes)eIndex, iChange, bUpdate); // NOTHING CHANGED

CyPlot.h(222): void changeCulture(int /*PlayerTypes*/ eIndex, int iChange, bool bUpdate); // NOTHING CHANGED

CyPlotInterface1.cpp(217): .def("changeCulture", &CyPlot::changeCulture, "void (int /*PlayerTypes*/ eIndex, int iChange, bool bUpdate)") // NOTHING CHANGED
Basically it seems nothing has changed in the SDK since the last working version of Lascaux, or did I miss something here :confused:

Again, I hope you can help despite the release of CiV :)
 
Ups, sorry, had lots of things to do with Civ5 tech support, and have not looked into Civ4 C&C for 2 days.

To fix the problem, change the line:
PHP:
            TheNumberOfCultureWhichShouldBeAdded = 160*(2**(-1* CyGame().getGameSpeedType () ))

to:
PHP:
            TheNumberOfCultureWhichShouldBeAdded = int(160*(2**(-1* CyGame().getGameSpeedType () )))
 
I've tried it. The warrior of god doesn't required state religion! they are available in the game all the time :confused:
 
The J. Can you create a python function to call up a popup showing all of the units on a specific tile and be able to select more than one unit for further action? After selecting the 3 units, I want to obtain attributes from each unit for modification. I can write the modification code. All I need is the unit selection popup. The popup should be similar to the choose Unit to Lead popup that is available with a Great General; only it will need selection capability and an OK button to execute. See attachment.
 

Attachments

  • ChooseUnitToLeadPopup.JPG
    ChooseUnitToLeadPopup.JPG
    17.3 KB · Views: 74
I've tried it. The warrior of god doesn't required state religion! they are available in the game all the time :confused:

Did you use it directly, or did you merge it?

The J. Can you create a python function to call up a popup showing all of the units on a specific tile and be able to select more than one unit for further action? After selecting the 3 units, I want to obtain attributes from each unit for modification. I can write the modification code. All I need is the unit selection popup. The popup should be similar to the choose Unit to Lead popup that is available with a Great General; only it will need selection capability and an OK button to execute. See attachment.

I have to say no, not possible for me at the moment.
I'm not at my Civ computer, i don't have enough experience with popups to make this without testing, and i have no idea how much time i'll have when i'm back at my gaming pc.
Sorry :(.
 
Back
Top Bottom