Modmodding Q&A Thread

2 Major exception messages. One is when I started the game, and another one is when I found new city.

Spoiler :
Civ4_Screen_Shot1093.jpg
Civ4_Screen_Shot1094.jpg


Currently I'm not working on it, because I have important test 2 days later. I'll start working again after that.
 
As I said before.
Step 24): DynamicCivs.py

In the beginning, you should make a copy of the constant from Consts.py and get the PyPlayer and PyTeam objects for your player. (same as step 19)

Add the new civ in self.defaultNames and self.peopleNames.


If you don't do this, you will get some python errors when launching a game. (Which happened to me) Adding the default name and people name will resolve them. The other dynamic names can be added later on.
 
Is there a way to force collapse and rebirth of a civ through the python console?


Sent from my Lumia 800 using Tapatalk
 
Yes, just do the following:
Code:
from Consts import *
import Stability as sta
sta.completeCollapse(iEgypt)
You can use any civilization's identifier from Consts.py in the same way.
 
A quick question.

Code:
		elif iPlayer == iAustralia:
			if pAustralia.isAlive():
				if (iGameTurn == getTurnForYear(1950)): 
					if (self.getGoal(iAustralia, 0) == -1):					
						bWA = self.checkOwnedArea(iAustralia, tWATL, tWABR, 3)
						bNT = self.checkOwnedArea(iAustralia, tNTTL, tNTBR, 1)
						bSA = self.checkOwnedArea(iAustralia, tSATL, tSABR, 1)
						bQld = self.checkOwnedArea(iAustralia, tQldTL, tQldBR, 2)
						bNSW = self.checkOwnedArea(iAustralia, tNSWTL, tNSWTL, 2)

						if bWA and bNT and bSA and bQld and bNSW:
							self.setGoal(iAustralia, 0, 1)   
						else:
							self.setGoal(iAustralia, 0, 0)

I always fails the 1st UHV even though I made enough cities. Is there any suspicious error part in my codes?
 
You are using tNSWTL where it should be tNSWBR.
 
Have you coded the UHV display yet? It would have helped you find out what to look for.
 
Since it works through events, it's spread out over multiple files. What exactly do you want to change?
 
Two quick questions.

1. How can I count number of military units that gifted to other civs? Am I need to add a new counter method?
2. How can I make new event?
I'm trying to make a new event for australia civ that occurs in year 1859.
 
Two quick questions.

1. How can I count number of military units that gifted to other civs? Am I need to add a new counter method?
2. How can I make new event?
I'm trying to make a new event for australia civ that occurs in year 1859.

1. There is a function onUnitGift. You should add a counter in the stored data. (I think the Korean sinking ship UHV is a nice example how a counter works)

Something like this: (NOTE: You can't just copy this below. Some parts are just to let you know how you should structure the code, but you have to do the code itself.)
In Victory.py
Code:
def onUnitGift:
	if oldowner is iAustralia:
		sd.changeGiftCounter(1)
And where you define the UHV:
Code:
elif (iPlayer == iAustralia):
	if sd.getGiftCounter() >= xxx
		setGoal(iAustralia, X, 1)
	else:
		setGoal(iAustralia, x, 0)


In StoredData.py
add this in the list of UHV counters.
Code:
'iGiftCounter' : 0,
Also add this in the list of def xxx:
Code:
	def getGiftCounter(self):
		return self.scriptDict['iGiftCounter']
		
	def changeGiftCounter(self, iChange):
		self.scriptDict['iGiftCounter'] += iChange

2. What kind of event do you want to create? If you want something like an earthquake in 1859 AD, you can do that in CvEventManager.py.
 
Is there really an onUnitGift method? Didn't expect that.
 
Is there really an onUnitGift method? Didn't expect that.

I didn't know it either. But I had a feeling such a thing could exist. So I checked the python files whether I could find something.
 
I'm sorry about asking it directly, but can you guess what could be a problem? The code was written on Victory.py by myself and it couldn't count number of gifted Digger and Mechanized Infantry units.

Code:
def onUnitGifted(self, argsList):
	if (not gc.getGame().isVictoryValid(7)): #7 == historical
                return
		
	pUnit, iGiftingPlayer, pPlotLocation = argsList
	iPlayer = iGiftingPlayer.getID()
		
	if self.isIgnoreAI() and utils.getHumanID() != iPlayer:
		return
		
	if iPlayer == iAustralia:
		if (self.getGoal(iAustralia, 1) == -1):
			if pUnit.getUnitType() in [con.iANZAC, con.iMechanizedInfantry]:
				self.setAustralianGifted(self.getAustraliaGifted() + 1)
				if (self.getAustraliaGifted() >= 15):
					self.setGoal(iAustralia, 1, 1)
 
The iPlayer = iGiftingPlayer.getID() part is yours, right?

Unless someone made a mistake in creating this event, iGiftingPlayer already is a player ID. So you can either use it directly, or just reassign it as iPlayer = iGiftingPlayer.

Generally variables starting with an i indicate that they're integers and therefore not objects that can have methods such as getID(). I don't know how familiar you are with object oriented programming.

Are you still doing this without enabled Python exceptions, by the way? You should have noticed that at least something went wrong in that line.
 
Back
Top Bottom