Python Modding

Yes to everything

The mapscript adds plains and rivers and it also has the ice polar caps

The Death Star Code makes it fallout exactly like a regular ICBM

In the mapscript, does it have three game options called "Solar System Density", "Feature Density", and "Hostile Feature Density" when starting a custom game?

Then, in the .ini file, there should be something like this:

Code:
; Allow public maps to be used with this mod
AllowPublicMaps = 0

Make sure that value is set to 0, then test it again.

Then, what did you name the Death Star unit? I mean exactly, in the XML. The python defines it as UNIT_DEATH_STAR... is this what you have?
 
It's defined just like that in the XML
 
Please turn on python exceptions in your _CivilizationIV/Civilization.ini file (in the BTS folder and the vanilla Civ folder, just in case). Change the value of "set to 1 to hide python exception popups" to a 0. I forgot to mention this, but it would have saved me a few hours of wondering about the problem- which was that I missed a parenthesis. The python exception would have reported this. It will also help in diagnosing the mapscript error.

For a quick fix, in this post I've uploaded a new event manager to this post. Please drop it into the Python folder and overwrite the old one. I'll reupload a python folder to the first post when I have time.


What about the other stuff for the mapscript?
 
I don't have that option in the ini file would I just drop it in there if so where
 
I don't have that option in the ini file would I just drop it in there if so where

For what? Python exceptions or the mod ini?

For the mod ini, copy over something like the Gods of Old ini file- if you're using the ini file originally from the old Star Wars mod, there have been new additions to the file since BTS was released. Your ini should look something like this:

Code:
[CONFIG]

; Modular XML Loading
ModularLoading = 0

; Read Game options from XML, not .ini
ForceGameOptions = 0

; Custom Art from user folder is not loaded
NoCustomArt = 1

; Custom XML and Python from user folder are not loaded
NoCustomAssets = 1

; No Custom Scenario option in main menu
NoCustomScenario = 0

; Scenario file (Single player)
ForceScenario = 0

; No team play allowed
NoTeams = 0

; Always start in the standard era
ForceStandardEra = 0

; Skip the Main menu
SkipMainMenu = 0

; This mod is only for single player games
SinglePlayerOnly = 0

; Allow public maps to be used with this mod
AllowPublicMaps = 0

; Mod Image file
ImageFile = 0

; Name of Mod
Name = Star Wars

; Description of Mod
Description = Star Wars Mod

For python exceptions, I messed up- it's called the "_Civ4Config" file, but is really CivilizationIV.ini. It should be there:

Code:
; Set to 1 for no python exception popups
HidePythonExceptions = 0
 
Wheres the civ4config file
Its not in the ini
 
Wheres the civ4config file
Its not in the ini

Civilization IV\Beyond the Sword directory (no mods).

For python exceptions, I'm not talking about specific mod ini files, but python exception popups are enabled in the CivilizationIV.ini file, labeled for some reason as the _Civ4Config file. Can you find it? It should be in your BTS main directory.
 
Currrently there are no errors until you get into loading the actual map
Then this comes up
Code:
File "StarWars", line 585, in findStartingPlot
IndexError: list index out of range
Then another one comes up
Code:
File "StarWars", line 514, in addFeatures
File "StarWars", line 350, in addFeatures
ArgumentError Python  argument types in
    Cyplot.setTerrainType CyPlot, int
didn't match C++ signature:
    setTerrainType(classCyPlot{lvalue}, int, bool, bool)
 
Code:
Tis is what the error message in the game says
Traceback (most recent call last):
File "string", line 1, in ?
File "string", line 35, in load_module
File "string", line 13, in _get_code
File "StarWars", line 352
    if iRnd = 1:


        ^


    SyntaxError invalid syntax

shouldn't you change this:
if iRnd = 1:
to:
if iRnd == 1:

I'm guessing i don't know much about python but i think i know that

Aha! Almost as bad as missing a parenthesis! It's the old "compare versus define" (== is a comparison, = is defining a variable) error.

I'd reupload a file, but since you found the error, you can fix it (Yes, it should be "iRnd == 1") in your version. I've fixed it in mine.
 
None here now just ones when you try loading a game
 
Yes, those one-line box popups are annoying...

Anyway, here's the correct code, from line 370 to line 381 in CvEventManager.py (I was missing parenthesis). You should be able to insert it there. It should overwrite the function def onBeginPlayerTurn.

Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
		pPlayer = gc.getPlayer(iPlayer)
		for i in range(pPlayer.getNumUnits()):
			pUnit = pPlayer.getUnit(i)
			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND_TRICKED')):
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND_TRICKED'), false)
			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_FORCE_CONCEALED')):
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FORCE_CONCEALED'), false)
			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_BATTLE_MEDITATION')):
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BATTLE_MEDITATION'), false)

After we get all of these bugs fixed, I'll reupload a new python folder and mapscript to the first post.
 
I updated the errors to what I got after your fixes
 
Another one... (= versus ==) or rather, 7.

Drop the code below between lines 498 and lines 556 (the def onPlotPicked function), overwrite it:

Spoiler :
Code:
	def onPlotPicked(self, argsList):
		'Plot Picked'
		pPlot = argsList[0]
		CvUtil.pyPrint('Plot was picked at %d, %d'
			%(pPlot.getX(), pPlot.getY()))
		pCaster = StarWars.iPushedButtonUnit
		pCaster.changeMoves(60)
		pPlayer = pCaster.getOwner()
		iUnitX = pCaster.plot().getX()
		iUnitY = pCaster.plot().getY()
		iX = pPlot.getX()
		iY = pPlot.getY()
		pUnit = pPlot.getUnit(0)
		iDmgRnd += 25 + CyGame().getSorenRandNum(25, "Force Power")
		if plotDistance(iUnitX,iUnitY, iX, iY) == 1:
			if StarWars.iPushButton == 1:
				pUnit.setDamage(pUnit.getDamage()+iDmgRnd, False)
				if pCaster.getDamage() > 0:
					pCaster.setDamage(0, PlayerTypes.NO_PLAYER)
			if StarWars.iPushButton == 2:
				pUnit.setDamage(pUnit.getDamage()+iDmgRnd, False)
			if StarWars.iPushButton == 3:
				if (iX = iUnitX + 1 and iY = iUnitY + 1):
					pPushPlot = CyMap().plot(iX+1, iY+1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX+1, iY+1)
				if (iX = iUnitX + 1 and iY = iUnitY - 1):
					pPushPlot = CyMap().plot(iX+1, iY-1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX+1, iY-1)
				if (iX = iUnitX - 1 and iY = iUnitY + 1):
					pPushPlot = CyMap().plot(iX-1, iY+1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX-1, iY+1)
				if (iX = iUnitX - 1 and iY = iUnitY - 1):
					pPushPlot = CyMap().plot(iX-1, iY-1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX-1, iY-1)
			if StarWars.iPushButton == 4:
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND_TRICKED'), True)
			if StarWars.iPushButton == 5:
				pUnit.setDamage(0, PlayerTypes.NO_PLAYER)
			if StarWars.iPushButton == 6:
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIGHT_SIDE_1'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIGHT_SIDE_2'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIGHT_SIDE_3'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIGHT_SIDE_4'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_SIDE_1'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_SIDE_2'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_SIDE_3'), False)
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DARK_SIDE_4'), False)
			if StarWars.iPushButton == 7:
				newUnit = pPlayer.initUnit(pUnit.getUnitType(), iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
				newUnit.convert(pUnit)
				pCaster.setScriptData("Has cast Mind Control")
 
I updated it again
 
Again, the same bug!

This should overwrite the code from lines 520 to 529:

Spoiler :
Code:
				if (iX == iUnitX + 1 and iY == iUnitY + 1):
					pPushPlot = CyMap().plot(iX+1, iY+1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX+1, iY+1)
				if (iX == iUnitX + 1 and iY == iUnitY - 1):
					pPushPlot = CyMap().plot(iX+1, iY-1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX+1, iY-1)
				if (iX == iUnitX - 1 and iY == iUnitY + 1):
					pPushPlot = CyMap().plot(iX-1, iY+1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX-1, iY+1)
				if (iX == iUnitX - 1 and iY == iUnitY - 1):
					pPushPlot = CyMap().plot(iX-1, iY-1)
					if not pPushPlot.isNone():
						if pUnit.canMoveInto(pPushPlot,False,False,False):
							pUnit.setXY(iX-1, iY-1)
 
I've updated it yet again
 
I've updated it yet again

Are you sure that's what it says? Because in my code I have this:

Code:
if pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_DEATH_STAR'):

Go into your file and check, and if you don't have what's above, copy and paste it in. In yours, there's two errors at least ("pNukeeUnit", and no colon at the end of the line).
 
What i have now is what it says
 
Thanks.

I think the error's indentation problem. But I'm not sure. Try copying this code over lines 558 to 577:

Code:
	def onNukeExplosion(self, argsList):
		'Nuke Explosion'
		pPlot, pNukeUnit = argsList
		CvUtil.pyPrint('Nuke detonated at %d, %d'
			%(pPlot.getX(), pPlot.getY()))
		if pNukeUnit.getUnitType() == gc.getInfoTypeForString('UNIT_DEATH_STAR'):  
			iX = pPlot.getX()
			iY = pPlot.getY()
			for iiX in range(iX - 2, iX + 3, 1):
				for iiY in range(iY - 2, iY + 3, 1):
					pTarget = CyMap().plot(iiX, iiY)
					if not pTarget.getTerrainType() == gc.getInfoTypeForString('TERRAIN_TUNDRA'):
						pTarget.setTerrainType(gc.getInfoTypeForString('TERRAIN_TUNDRA'))
						pTarget.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'),0)
						for i in range(pTarget.getNumUnits()):
							pUnit = pTarget.getUnit(i)
							pUnit.kill(false, -1)
					if pTarget.isCity()
						pCity = pPlot.getPlotCity()
						pCity.kill()
 
Updated again
 
Back
Top Bottom