Modmodding Q&A Thread

OK, this is weird. Upon loading up a German game, I noticed an Egyptian lion loitering near Vienna. I quickly deleted it (sorry I don't have a save) and went back to remove it from the scenario. I was 100% sure that was what was causing it. But I can't find the lion anywhere. I looked at the entire map in WB with all units highlighted, and clicked on each stack to search. There's nothing there. Maybe it was just the game acting screwy again... I've known it to put Ethiopian catapults randomly in Antarctica. But still, it's a huge coincidence that it happened to be an Egyptian lion. I had just opened WB and don't see how I could have accidentally placed it there.

Anyway, maybe it's because of Ethiopia? I put them in the scenario.
 
Eyptian lions often spring into existence as a result of WorldBuilder unit adding misclicks, since Egypt is the first civ in the list, while lion is the first unit.
 
Eyptian lions often spring into existence as a result of WorldBuilder unit adding misclicks, since Egypt is the first civ in the list, while lion is the first unit.

I know, I've done them aplenty.
 
It says "PlayableCiv=0." Which means that Egypt isn't actually playable, right? Or am I looking in the wrong area?
Yeah, that's right, so that's not the reason. The game doesn't create Egyptian lions on its own so if you see one, that was your doing (the catapults in Antarctica are related to the autoplay mode).

Could you give a quick summary of your changes? Most importantly, what's your starting date?

Hmm, how do I put in new soundtracks? I have the DoCsoundtracks installed but I'm not sure how to edit it... and I don't know what the base soundtracks apply to. What does "Christian" or "South Asia" mean? Are they supposed to last throughout the game?
Since the normal ancient/classical/medieval etc. sequence of soundtracks already contains Christian chants for the Middle Ages, you have to be Christian to have them as soundtracks (I have also added 1-2 extra Christian music pieces from SoI).

Then there are a couple of special cases that "override" the normal eras under the following conditions:

- Muslim: different music for the Medieval era (and Renaissance maybe? Not sure) if state religion is Islam or Zoroastrianism
- East Asia: different music for the Classical, Medieval and Renaissance eras if state religion is Confucianism or Taoism, or your state religion is Buddhism and you're China, Korea, Mongolia or Japan
- South Asia: different music for the Classical, Medieval and Renaissance if state religion is Hinduism or state religion is Buddhism and you're not China, Korea, Mongolia or Japan
- "Heathens": civs without a state religion will continue to get the Classical soundtrack in the Medieval era (typical civs are the early Vikings and Congolese, as well as the Native Americans)

(I should note that the South Asia soundtrack is identical to the East Asia soundtrack unless you have the soundtrack module.)

You can easily change the tracks of the single soundtracks by locating the respective dummy era. Adding new conditional soundtracks or changing the conditions requires a DLL change.
 
Do you know anything about my communications/interface bugs?
 
Yeah, that's right, so that's not the reason. The game doesn't create Egyptian lions on its own so if you see one, that was your doing (the catapults in Antarctica are related to the autoplay mode).

Could you give a quick summary of your changes? Most importantly, what's your starting date?

Take a look here: View attachment Mouthwash's 600 AD.CivBeyondSwordWBSave

I can't even remember all the changes. The starting date is still 600 AD and I added and then removed the Tamils. It's not done, but I'll have to learn how to edit stability maps and spawn areas before I can really balance it.

Why does Guiyang disappear ingame if I add it to the scenario? China never founds it on its own.

Since the normal ancient/classical/medieval etc. sequence of soundtracks already contains Christian chants for the Middle Ages, you have to be Christian to have them as soundtracks (I have also added 1-2 extra Christian music pieces from SoI).

Then there are a couple of special cases that "override" the normal eras under the following conditions:

- Muslim: different music for the Medieval era (and Renaissance maybe? Not sure) if state religion is Islam or Zoroastrianism
- East Asia: different music for the Classical, Medieval and Renaissance eras if state religion is Confucianism or Taoism, or your state religion is Buddhism and you're China, Korea, Mongolia or Japan
- South Asia: different music for the Classical, Medieval and Renaissance if state religion is Hinduism or state religion is Buddhism and you're not China, Korea, Mongolia or Japan
- "Heathens": civs without a state religion will continue to get the Classical soundtrack in the Medieval era (typical civs are the early Vikings and Congolese, as well as the Native Americans)

(I should note that the South Asia soundtrack is identical to the East Asia soundtrack unless you have the soundtrack module.)

You can easily change the tracks of the single soundtracks by locating the respective dummy era. Adding new conditional soundtracks or changing the conditions requires a DLL change.

How do I edit the soundtrack module? Is there a guide for editing the DLL?
 
Take a look here: View attachment 366784

I can't even remember all the changes. The starting date is still 600 AD and I added and then removed the Tamils. It's not done, but I'll have to learn how to edit stability maps and spawn areas before I can really balance it.
I'll glance over it later.

Why does Guiyang disappear ingame if I add it to the scenario? China never founds it on its own.
Guiyang also exists in the 600 AD scenario so that its culture covers areas that are meant to be surrounded by the Great Wall, and afterwards removed. Look in initScenario() RiseAndFall.py, for the 600 AD scenario (and every other scenario that starts in 600 AD) there should a method like prepareChina or something that does that.

How do I edit the soundtrack module? Is there a guide for editing the DLL?
You can edit the soundtrack module like the main mod, the only difference is that its Assets are in the Modules folder. There are guides for compiling the DLL in the Creation & Customization -> Modding Tutorials subforum.
 
How do you make the flip area of a civ bigger or smaller, like you did for Persia? What I'm trying to do is make the Moor's flip area smaller if Carthage is controlled by the player.

Additionally, how do you make the core area of a civ change later? Right now a Carthage without Sur has no core population, and I'm trying to change that.
 
Guiyang also exists in the 600 AD scenario so that its culture covers areas that are meant to be surrounded by the Great Wall, and afterwards removed. Look in initScenario() RiseAndFall.py, for the 600 AD scenario (and every other scenario that starts in 600 AD) there should a method like prepareChina or something that does that.

Thanks. I found this and deleted it:

def prepareChina(self):
pGuiyang = gc.getMap().plot(102, 41)
pGuiyang.getPlotCity().kill()
pGuiyang.setImprovementType(-1)
pGuiyang.setRouteType(-1)
pGuiyang.setFeatureType(con.iForest, 0)

It worked, but now I get a exception message when I start a game. Have I done something wrong?
 
None, at least in PythonDbg.log and PythonErr.log
What if you only change the starting year without renaming the scenario?

How do you make the flip area of a civ bigger or smaller, like you did for Persia? What I'm trying to do is make the Moor's flip area smaller if Carthage is controlled by the player.
Look in initBirth() in RiseAndFall.py.

Additionally, how do you make the core area of a civ change later? Right now a Carthage without Sur has no core population, and I'm trying to change that.
Every player has a reborn value. I use it to implement actual rebirths, so a reborn civ has a different stability map / core area than its "unreborn" predecessor. I abuse this mechanic to change the stability areas for civs whose slot isn't used by a rebirth.

This already happens for Phoenicia as soon as they acquire Carthage, though.

Thanks. I found this and deleted it:

It worked, but now I get a exception message when I start a game. Have I done something wrong?
You should not delete the complete method, because the code still tries to call it somewhere and produces an error when it doesn't find it. Instead, just make "return" the first line after "def prepareChina", you can even keep everything after it.
 
What if you only change the starting year without renaming the scenario?

Look in initBirth() in RiseAndFall.py.

Every player has a reborn value. I use it to implement actual rebirths, so a reborn civ has a different stability map / core area than its "unreborn" predecessor. I abuse this mechanic to change the stability areas for civs whose slot isn't used by a rebirth.

This already happens for Phoenicia as soon as they acquire Carthage, though.

Thanks for your quick responses. However, even when I make Carthage reborn at the beginning of the scenario, it shows the proper core areas but does not register them as core population. Also, I am having a problem with communicAtions. Everyone knows each other for a while, and everyone has a few votes in the AP. Do you know what the problem is,
 
You should not delete the complete method, because the code still tries to call it somewhere and produces an error when it doesn't find it. Instead, just make "return" the first line after "def prepareChina", you can even keep everything after it.

Tried it and it gave me the defeated at startup bug. Can you show me how in the code I gave?
 
Thanks for your quick responses. However, even when I make Carthage reborn at the beginning of the scenario, it shows the proper core areas but does not register them as core population.
This could be a bug ...

Also, I am having a problem with communicAtions. Everyone knows each other for a while, and everyone has a few votes in the AP. Do you know what the problem is,
I have no idea.

Tried it and it gave me the defeated at startup bug. Can you show me how in the code I gave?
You should enable Python exceptions.

Do we need a makefile to compile the .dll or is there a way of making it yourself?
I suggest just following the guides in the tutorial section, which also provide a makefile.
 
This could be a bug ...


I have no idea.

I think the stability is just a bug, or I actually need to manually reset the stability rather than just put:
Code:
if getScenario()==500AD:
        #blah blah blah random definitions relating to the scenario
        pCarthage.setReborn()

Not that I'm typing from memory on my iPad and I'm too lazy to spell out the other definitions here, so that isn't the problem.

I think the communications bugs have to do with the communications pool. I tried to solve the problem by doing:

Code:
#blah blah blah 3rd pool stuff
        while self.getScenario() == con.i500AD and self.getTurnForYear < (900):
                break
To break from the communications loop. That doesn't work, however. How would I break from a communications loop?
 
I think the stability is just a bug, or I actually need to manually reset the stability rather than just put:
Code:
if getScenario()==500AD:
        #blah blah blah random definitions relating to the scenario
        pCarthage.setReborn()

Not that I'm typing from memory on my iPad and I'm too lazy to spell out the other definitions here, so that isn't the problem.
Nope, that should be enough, I'm also not doing more than that. But I'll check this.

I think the communications bugs have to do with the communications pool. I tried to solve the problem by doing:

Code:
#blah blah blah 3rd pool stuff
        while self.getScenario() == con.i500AD and self.getTurnForYear < (900):
                break
To break from the communications loop. That doesn't work, however. How would I break from a communications loop?
Which loop are you talking about (line number)?
 
I've succeeded in limiting some units to a certain number of instances per resource instance controlled by the player. here is the code in CvPlot::canTrain:

Spoiler :
Code:
		if (GC.getUnitInfo(eUnit).getPrereqAndBonus() != NO_BONUS)
		{
			if (NULL == pCity)
			{
				if (!isPlotGroupConnectedBonus(getOwnerINLINE(), (BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus()))
				{
					return false;
				}
			}
			else
			{
				if (!pCity->hasBonus((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus()))
				{
					return false;
				}
			}
		//}
		// srpt resource unit restriction mk II
			int iJ = 0;
			for (int iI = 0; iI < GC.getNumUnitInfos(); iI++)
			{
				if ( GC.getUnitInfo((UnitTypes)iI).getPrereqAndBonus() == GC.getUnitInfo(eUnit).getPrereqAndBonus() )
				{
					UnitClassTypes eUnitClass = ((UnitClassTypes)(GC.getUnitInfo((UnitTypes)iI).getUnitClassType()));
					iJ += (GET_PLAYER(getOwnerINLINE()).getUnitClassCountPlusMaking(eUnitClass));
				}
			}
			if (iJ > ((pCity->getNumBonuses((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus())) * 6) )
			{
				return false;
			}
		}
		// srpt end

this seems to work in all cases including units being restricted by either of 2 resouces required.

I'm now trying to make a tooltip. this is my attempt in CvGameTextMgr::setUnitHelp:

Spoiler :
Code:
	// srpt resource unit restriction
	if( GC.getUnitInfo(eUnit).getPrereqAndBonus() != NO_BONUS )
	{
		int iJ = 0;
		int iK = 0;
		for (int iI = 0; iI < GC.getNumUnitInfos(); iI++)
		{
			if ( GC.getUnitInfo((UnitTypes)iI).getPrereqAndBonus() == GC.getUnitInfo(eUnit).getPrereqAndBonus() )
			{
				UnitClassTypes eUnitClass = (UnitClassTypes)GC.getUnitInfo(eUnit).getUnitClassType();
				iJ += (GET_PLAYER(ePlayer).getUnitClassCountPlusMaking(eUnitClass));
			}
		}
		iK = pCity->getNumBonuses((BonusTypes)GC.getUnitInfo(eUnit).getPrereqAndBonus());
		szBuffer.append(NEWLINE);
		szBuffer.append(gDLL->getText("TXT_KEY_UNIT_RESOURCE_BASED_UNIT_LEFT", (iK - iJ)));
	}

however, it causes a very strange unidentified C++ exception when you try to open WB:

Spoiler :
Traceback (most recent call last):

File "CvScreensInterface", line 385, in showWorldBuilderScreen

File "CvWorldBuilderScreen", line 122, in interfaceScreen

File "CvWorldBuilderScreen", line 2370, in refreshPlayerTabCtrl

RuntimeError: unidentifiable C++ exception
ERR: Python function showWorldBuilderScreen failed, module CvScreensInterface
 
Back
Top Bottom