Quick Modding Questions Thread

Why would my game lag (what do you exactly mean by the way, the inbetween turn time takes longer?), and more importantly, how to prevent it / work around it? Or would I have to use the SDK for that? The Missionary requires Monastery thing doesn't make the game lag, right?
Basically any Python modding causes lag, because Python isn't compiled into machine code and has to be continuously interpreted in real-time by the computer/game.

Using some of the calls found in CvGameUtils would be done so often that they are disabled by default! Because making some Python call 100 or 1000 times within the turn of one single player is consuming huge amounts of processing power. So only enabling the callup - without even editing it - will cause lag. And the more code you add - the more lag will it cause.

Now, there can be more or less good or bad code. You could probably get around some of the additional lag caused by your Python mod with clever scripting, like caching techniques. But I'd rather write the code than try to explain how something like that works. The idea is however that you don't make the interpreter repeat some code when not really necessary, like if a city has already been checked for unit building it doesn't need to be checked again - on the same game turn.

But the only good solution would be to alter the SDK directly - then everything is pretty much immediate and there wouldn't be any measurable lag.
 
But altering the SDK requires creating a new CvGameCore.dll, right? Well, I'll perhaps look into it sometimes later, but nevermind.

Do you perhaps have any idea why my game takes ages to load (the main menu, it takes literally minutes to load)? This probably has something to do with me using modules (for new civilizations and leaders (although I've created the LeaderHeadInfos.xml, audio entries, and text entries in the original files, so they aren't in the modules).
 
I'm no good at the XML stuff, but you're probably correct. Someone else would be able to advice more, however.
 
need my speed, I'm not saying that making a Python mod will ruin your entire mod or render it unplayable. You could test the Python solution and evaluate if you really need the "real" fix. Your call.
 
Ok, I'll try something and see wether it noticeably lags more or not.
 
Shouldn't be noticable.
I have 6 or 7 units in my mod which are restricted by civic and i didn't notice any lag.

That's exactly what I did.
Same result.
Identical.

hhmmm...strange.
What are the consequences ingame?

A. I have been editing the DLL appropriately.
B. I thought if you correctly edited the schema, you didn't have to change the dll unless you wanted it to actually do something.

You are totally right :yup:.

So I've been trying to make a mod and it crashes on my at random. I'll explain the problem in detail here:
[...]

No real idea :/.
Do you know how to compile a debug dll? If not, your dll has only the 50 civs modification, right?
 
@Baldyr & need: Ypu could concievably do it that way, but it would be easier to do it in XML with the PrereqBuilding tag in CvUnitInfos.xml. You don't even have to use Python.

http://modiki.civfanatics.com/index.php/Civ4UnitInfos

@The_J: After I ignore the first error, I get:
Tag: TECH_SPIRITUALITY in Info class was incorret
Current XML file is xml\GameInfo/CIV4ReligionInfos.xml
Assert Failed

File: CvGlobals.cpp
Line: 3493
Expression: strcmp(szType, "NONE")==0 || strcmp(szType, "")==0
Message: info type TECH_ORGANIZATION2 not found, Current XML file is: xml\GameInfo/CIV4ReligionInfo.xml
//The next one can be explained as a tag matching error.
Assert Failed

File: CvGlobals.cpp
Line: 3493
Expression: strcmp(szType, "NONE")==0 || strcmp(szType, "")==0
Message: info type TECH_WARFARE not found, Current XML file is: xml\GameInfo/CIV4ReligionInfo.xml

Tag: TECH_WARFARE in Info class was incorret
Current XML file is xml\GameInfo/CIV4ReligionInfos.xml

And so on for all the techs mentioned in ReligionInfos.

Tag: UNITCOMBAT_HELICOPTER in Info class was incorret
Current XML file is xml\Units/CIV4PromotionInfos.xml
This can be explained, as well as all others pretaining to UNITCOMBAT_HELICOPTER, which was removed.

Failed Loading XML file xml\Civilizations/CIV4TraitInfos.xml

LoadXML call failed for Civilizations/CIV4TraitInfos.xml

Allocating zero or less memory in
CvXMLLoadUtility::SetVariableListTagPair
Current XML file is: xml\GameInfo/CIV4CivicOptionInfos.xml
repeated
repeated again
again
one more time

Is that enough to understand what's going on?
 
@Baldyr & need: Ypu could concievably do it that way, but it would be easier to do it in XML with the PrereqBuilding tag in CvUnitInfos.xml. You don't even have to use Python.

I know that, but I want to have multiple Guilds, that all enable the same Merchant. However, I may do it via the XML, if there is some way to make the game randomly determine wether the Guild building produces +25% production, +25% gold, or +25% science when it is built. I'll try to create some code for it (which most likely will be completely wrong, but I have to learn Python (which is kind of useless, seeing as there is C++, but Python is easier :P) somehow, and you learn from your faults).

EDIT: I'm looking at this code for some sort of base:

PHP:
### start Casino script
		eCasino = gc.getInfoTypeForString("BUILDINGCLASS_CASINO")
		iBaseGold = pCity.getBaseCommerceRate(0)
		iPercentage = gc.getGame().getSorenRandNum(21, "Casino") * 5 - 25
		pCity.setBuildingCommerceChange( eCasino, 0, int(iPercentage * iBaseGold / 100.0) )
### end Casino script

And I have a question. The code gets the city's commerce rate (and uses it to change the commerce of the city, as far as I can see), but, in the game, this building adds gold, not commerce. I know commerce is divided into gold, science, culture, and espionage, but as far as I can see, the code doesn't make the building add gold.
 
I'll try to create some code for it (which most likely will be completely wrong, but I have to learn Python (which is kind of useless, seeing as there is C++, but Python is easier :P) somehow, and you learn from your faults).
Pick up a textbook and you'll be scripting in no time at all. Looking at some sample code will take forever and not get you very far. Unless you're able to read sample code you're simply copying it without ever even understanding what it does, and you've learned nothing. Copy-pasting is not programming.

And I have a question. The code gets the city's commerce rate (and uses it to change the commerce of the city, as far as I can see), but, in the game, this building adds gold, not commerce. I know commerce is divided into gold, science, culture, and espionage, but as far as I can see, the code doesn't make the building add gold.
The integer value zero used in two places in the code is key here. Because Gold is the first CommerceType.

Since learning is the objective here, you really should look all the concerned methods up in the API. Because this is the Application Programming Interface you have to work with.
 
k ive got 2 minor problems with my added nation and 1 leaderhead, ill try and explain everything

1) when you load the game and go into civilopedia/civilization u see my nation in the list with the others, the problem is the flag is right just the background color is wrong. in game the units and cities have the right symbol and color. im using the flagDecal.AmericaInc i changed my player color to red, yet on the civilopedia page and a few other minor areas, it still has its blue background.


2)going back to the civilopedia/civilization, if you click on the nation it shows my starting techs, unique unit/building, my 1st leaderhead looks fine (used alexander the great) but my 2nd leaderhead pic is half size (used cochise). yet if you click on cochise everything works with his movements and background is good. only when looking at my nation and seeing him as a leaderhead is he half sized. even playing a single player game/play now option he looks fine. its just the damn civilopedia

hope i have posted this in the right area, i am new to this site. but this site rocks
 
Worked for me... But I realize nobody will ever be prepared to do the homework. :p

Hey! I'm working with a Python textbook right now!

@
Don't get an error with spirituality.

Oh, great, don't tell me it's a dll error!
 
I must've somehow corrected the spirituality error, then forgotten to update the mod (I'm running Windows 7, so I have two folders for the mod (three actually, I also have a backup), one in the Mods folder and one in my working folder. ) I must've forgotten to copy the one in my working folder to my mods folder.
 
is there any thread where the xml-tags are explained? I think that would be very useful for new modders like me.
 
Quick question that is bugging me, why does the Settler iCost = 0 in UnitInfo.xml? All the other units in the file have the correct iCost, but the Settler has 0?

EDIT: Another question. What exactly are MapScripts? Can I combine them with other mods? Can I use them with the regular game?

Thanks for the help!
 
Back
Top Bottom