Quick Modding Questions Thread

Well, the problem has to do with the interception, seeing as when I added 10% interception chance to Range I, Range I also didn't appear as a selectable promotion.
 
You should know that in regular BtS the fighter and jet fighter type units can not take the interception promotions (but the SAM infantry and such can). This is due to the upper limit of 100. The base unit has an interception of 100 so it can't take interception 1, which would push it over the limit.

Also, the airship can not take it. This is due to another restriction I didn't mention. A unit that does not have an interception chance without any promotions can not take a promotion that gives it an interception chance. That stops the airship from taking it. It also stops the regular infantry unit from taking it, since the promotions are assigned by unitcombat and both the SAM infantry and the regular infantry (not to mention the musketman) are all in the gunpoweder unitcombat category which is one of the categories (along with air units) that is listed as valid for the interception promotions.

If you're messing with promotions you should also know that a unit that does not have the ability to inflict collateral damage can not take a promotion that increases collateral damage.

Also, contrary to the above properties a unit that has no withdrawal chance can actually take a promotion that gives it one except for one case: a unit that can not attack (the bOnlyDefensive flag is set to 1) can not take any promotion that increases the withdrawal chance whether or not the unit itself has a withdrawal chance (which is normally useless anyway, but I tried it for the case where a promotion had multiple bonuses so that withdrawal was only one of them only to find that the unit still could not take the promotion).

And, as I more or less pointed out in that last parenthetical remark, the restrictions apply for promotions that do multiple things. If any one of those things is not allowed, the entire promotion is not allowed.

Note that in the civilopedia it will show promotions as available to the unit that the unit can not actually take due to that upper limit on interception. The fighter can not take the interception 1 promotion (or interception 2 either) but it shows up as available in the list of promotions shown for the unit in the civilopedia.

And finally, some DLLs change at least some of these rules. If, for example, a mod allows tanks to take collateral damage promotions then the mod either gives the base tank a small amount of collateral damage or it removes that particular restriction (which was added in the patch that removed the ability of tanks to take those promotions, as I recall).
 
Thank you for your detailed post. Do you perhaps also know the answer to this:

Also, is there a way to make promotions... Well, like, you can have Combat 1 or Drill 1, but not both. Because, if you have both Draftee (free upgrades, but -20% strength) and Quick Training (-20% upgrade cost), upgrading will actually cost -20%, in other words, you receive 20% of the normal upgrade cost...

EDIT: So Guerilla 3 would never be available to the Machine Gunner? Stupid rules...
EDIT2: What if I allow the Machine Gunner to attack, but give it -100% attack strength? However, if I do that via a promotion, that promotion would carry over when they upgrade. I could of course make them unupgradable, but is there some way to do it in the UnitInfos (I know there is CityAttack and such)?
EDIT3: I overlooked the TerrainAttacks tag. That, combined with FeatureAttacks, will hopefully do the trick.
EDIT4: Well, even with -1000000 (yes, a million), a Machine Gunner has about 50% odds against a Warrior. Apparantly, those percentages are added to the defender, instead of subtracted from the attacker. Besides, it looks ugly when you hover over the unit and such. So, what else can I do?
EDIT5: Hmm, changing the CombatLimit to 0 seems to have worked. The Machine Gunner can't attack, can receive those promotions, and defends like it always did.
 
Does somebody have a reference for the log files?

My mod currently crashes before it is completely launched. The init.txt file ends with the "DBG: Python Init" line, and from the loading screen it seems like the XML loading process isn't completed before the crash occurs. Is it possible that the crash is related to conflicts between modified XML Schemas and the respective read function in the DLL, or could I expect a proper error message in that case?

For reference, this is how the init.txt looks like for a mod that loads properly:

Code:
[5112.718] DBG: FILE Cat Init
[5114.390] DBG: Game Init
[5114.390] DBG: Multiplayer Init BEGIN
[5114.500] DBG: Multiplayer Init END
[5114.500] DBG: Audio Init
[5116.171] DBG: ArtFileMgr Init
[5116.187] DBG: Python Init
[B]// what happens here?[/B]
[5128.015] VERSION: CIV Version: 319
[5128.015] VERSION: Minimum Version: 0
[5128.015] VERSION: Save Version: 302
[5128.015] DBG: Input Init
[5128.015] DBG: Engine Init
[5128.109] DBG: Checking available screen resolution
[5128.343] DBG: Validating screen resolution
[5128.343] DBG: Creating rendererer
[5134.640] DBG: Engine: renderer Initialized
[5135.437] DBG: Engine: Shaders Initialized
[5135.718] DBG: Engine: Scene Lights Initialized
[5136.093] DBG: Music Start
[5136.265] DBG: Font Init
[5136.421] DBG: Begin MenuManager

Edit: Okay, I've narrowed it down to an XML problem (should've paid more intention to the XML log). That log ends before the line "Wrote Units to cache" usually appears. The next XML file to be loaded would be CIV4UnitArtStyleTypeInfos.xml, but I didn't tackle it ...
 
I posted this question in the rhye's and fall modmods/modding Q&A thread but sometimes that thread doesn't get much attention so I'm hoping its ok to post it here too. If its not ok I promise I wont do it again.

I am trying to merge the BonusCommerceModifier mod (available here: http://forums.civfanatics.com/showthread.php?t=336730&highlight=BCM+mod&page=2) with a stock SDK from Asaf's tutorial and I am getting this:

Spoiler :
1>c:\Documents and Settings\user\Desktop\CvGameCoreDLL\CvGame.h(513) : error C2143: syntax error : missing ';' before '*'
1>c:\Documents and Settings\user\Desktop\CvGameCoreDLL\CvGame.h(513) : error C2071: 'CvGame::CvArtInfoBuilding' : illegal storage class
1>c:\Documents and Settings\user\Desktop\CvGameCoreDLL\CvGame.h(513) : error C2501: 'CvGame::getBuildingArtInfo' : missing storage-class or type specifiers
1>c:\Documents and Settings\user\Desktop\CvGameCoreDLL\CvGame.h(513) : warning C4183: 'getBuildingArtInfo': missing return type; assumed to be a member function returning 'int'
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\cl.exe"' : return code '0x2'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://c:\Documents and Settings\user\Desktop\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 5 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


the only files in the BCM source are CvCity.h, CvCity.cpp, CvCityAI.cpp, CvGameTextManager.cpp, CvInfos.h and CvInfos.cpp

the CvGame.h file in the error message compiles just fine with the regular files.
 
So is it an RFC modmod? Because merging this with the base SDK code. There are too many things missing or different.
Specifically this will be solved by adding a declaration 'class CvArtInfoBuilding;' close to the beginning of CvGame.h, but then you'll just get a whole lot of other compilation errors (I tried ;) ).
 
Its going to be an RFC mod but for now I'm working with the source files from your tutorial.
 
Is it already based on RFC? because currently it's based on something that is not the normal BTS code.

You can't pull a few files from a mod and hope it works with another one.
These files have code which is dependent on functions (and maybe classes) defined in other files, so you'd need to either change this code so it won't need them, or import the rest of the code for the needed environment.

It looks like SaibotLieh based her mod on TheLopez's code, so I guess start from there? I'm not sure exactly what's needed there. You can PM SaibotLieh.

On the other hand - you could try adapting this code to BTS code. I've noticed the missing 'clear' and 'isEmpty' functions, a get method for the event reporter and a few more.
You can probably change the code so it won't need these (compare the new source files with the original ones to find how it was originally done when possible).
 
Sorry I don't think I was being clear. This is not an RFC modmod. Actually forget the mod because its unrelated to this problem.

All I am trying to do is add BCM to a vanilla DLL. BCM as published includes only a compiled DLL and 5 or 6 source files, only the ones that were changed. So I copy those files into the vanilla CvGameCoreDLL folder which is compiling perfectly on its own, replacing the ones of the same name that are there. I get an error in a file which, according to the mod as published, wasn't changed. I know changes in one file necessitate changes in others but then you would publish those files as well right?

Interestingly enough, I also cannot run the BCM mod. It crashes right after clicking "ok" to launch... hmmmm... and I can't complile a debug cause I can't compile...

looking at it with winmerge there are many differences besides the notated ones, including things like:

"gDLL->getEventReporterIFace()->cityLost(this);" instead of: "CvEventReporter::getInstance().cityLost(this);"
 
I looked at some old code (which comes with vanilla and Warlords), and it seems that this matches the code there.
So this mod was created based on an older version (either vanilla or Warlords, or maybe an older BTS - not sure when these changes were made).
So you can manually replace all
Code:
gDLL->getEventReporterIFace()->
with
Code:
CvEventReporter::getInstance().

I guess all the other changes should also be fixable.

It'll probably be easier, though, to find all the sections commented with "BCM:" and add them to the base BTS code files (with the needed changes).
 
well that's just exactly what I did and it worked.

I have a more general question: if I was to make an RFC modmod, do you think it would be better to start with vanilla DLL code, add the other changes I want (like BCM) and then merge with rhye's or should I start with rhye's and go from there?

and I guess I should mention that the map, civs, religions and their behavior, and corporations and their behavior are all different from rhye's.
 
well that's just exactly what I did and it worked.

I have a more general question: if I was to make an RFC modmod, do you think it would be better to start with vanilla DLL code, add the other changes I want (like BCM) and then merge with rhye's or should I start with rhye's and go from there?

I think it's really easier to merge a small codepart into a big, big, big code, than to merge a big codepart into only big, big code -> i'd start with Rhy's Dll.

and I guess I should mention that the map, civs, religions and their behavior, and corporations and their behavior are all different from rhye's.

I think that hardcoded stuff about all the details is only done in Python.
 
I don't know RFC's code, but I agree with The J about the big, big, big code merge order.

(And when you say vanilla it's a bit confusing, because there's vanilla as in no expansions - Warlords or BTS, and there's vanilla as in unmodded BTS)
 
thanks for the advice. and yes sorry I meant BTS. its all going well so far, maybe I will have a mod in few days.
 
Is there a fast and easy way to format XMLs? I'm trying to move modded leaders into modded civilizations, and that's a pain- putting in units/leaders/buildings without XML files is also very painful. Help a brother out here?
 
Actually, wait, a follow up question: Are XML files even needed for units? (Or buildings- I haven't even tried to mod those yet.) If not, why aren't they showing up in my civpedia?

Also, another question: Can I get the maps I mod in to be accessable from the 'custom games' settings? I'd like to be able to turn barbarians off, as well as to access the world builder.
 
Is there a fast and easy way to format XMLs?

If you only have a big clutter of text when you open a XML, then activate the line breaks in the editor, or use another editor.

Actually, wait, a follow up question: Are XML files even needed for units? (Or buildings- I haven't even tried to mod those yet.) If not, why aren't they showing up in my civpedia?

Everything you can put in will have its data in one of the XML files.

Also, another question: Can I get the maps I mod in to be accessable from the 'custom games' settings? I'd like to be able to turn barbarians off, as well as to access the world builder.

"Custom scenario" ;).
 
First of all, many thanks. You're awesome for responding so quickly. ;)

If you only have a big clutter of text when you open a XML, then activate the line breaks in the editor, or use another editor.

Everything you can put in will have its data in one of the XML files.

"Custom scenario" ;).

1) It's not that. The file just... isn't loading. And for the life of me I can't find out why. I was hoping that there'd be a 'base templant' where I could just fill in the blanks... but I guess that doesn't exist. Without that, my question becomes a bit impossible to answer on this forum. ^^

2) Huh... weird. I can't find where the XML files actually go, even for mods like Next War.

3) This is kind of a stupid question, but where can I mod that..? (Really, really sorry. I just started modding yesterday for Civ4.)
 
You can open an XML file in a browser to see if it is a valid XML. If not - it will show you the exact position where it breaks. (This only refers to the XML structure itself, not to the Civ-specific requirements).
 
Back
Top Bottom