Multiple Unit Overrides

Steves247365

Chieftain
Joined
Jul 27, 2011
Messages
18
Having a problem with UnitClassOverrides... I want to override the WORKER class entirely, modified unit will serve as an armed worker. I use the UnitClassOverride to remove the worker, and also to swap out the ARCHER for with my civilizations special unit. When I use more than one UnitClassOverrides entry, it works okay, but the text in the civilopedia is gone?? :mad: At some point the civilopedia errs when tryine to populate the unique unit attribute... what am I doing wrong? Here is the code I am using...

<Civilization_UnitClassOverrides>
<Row>
<CivilizationType>CIVILIZATION_NWATCH</CivilizationType>
<UnitClassType>UNITCLASS_WORKER</UnitClassType>
<UnitType/>
</Row>
<Row>
<CivilizationType>CIVILIZATION_NWATCH</CivilizationType>
<UnitClassType>UNITCLASS_ARCHER</UnitClassType>
<UnitType>UNIT_NWATCH_BUILDER</UnitType>
</Row>
</Civilization_UnitClassOverrides>

Does it matter if this code goes under the Units XML, or the Civilizations??
 
Having a problem with UnitClassOverrides... I want to override the WORKER class entirely, modified unit will serve as an armed worker. I use the UnitClassOverride to remove the worker, and also to swap out the ARCHER for with my civilizations special unit.

In theory this shouldn't be a problem, and your XML looks okay, but there are two other possibilities:
1> You screwed something else up, which caused everything to break. Without seeing the rest of your mod we have no way to tell if that's the case.
2> The game uses a certain amount of hard-coding. There needs to be at least one "settler" type unit, one "worker"-type unit, and one resourceless combat unit for each civilization, because these three categories are what the game uses to populate the starting units. If I had to guess, the settler-type and worker-type unit have to be noncombat units, so your attempt to remove the worker would partially fail.


But before we continue to guess, what did your logfiles say? Especially the xml.log? And I'm assuming you're also running the Tuner and there were no error messages in there.

Does it matter if this code goes under the Units XML, or the Civilizations??

If by "under" you mean "in the same file as", then no, it doesn't matter. If you mean "under" as "inside", then that's not how it works.
 
Appreciate the response...and I am sure it is something I am screwing up, just not able to pin point where. I switched out the code so that the new 'Builder' unit replaces the worker vice the Archer, and the Archer class override did not show a unit <Unit Type/>... but either way I do it, it screws up the text entries in the Civilopedia for the civilization and the special unit???... not sure what the connection is.. did not mess with the text reference lines. The actual game aspects seem to work fine however... the worker and archer units are gone, and the 'builder' unit is available and functions as desired. Something with the multiple overrides is causing the problem...

I placed The UnitClassOverride element in the same XML file as the defenition for the mod civilization rather than in the XML file for the mod unit...

...and now to show what a neophyte I am with modding - no, I am not using the Tuner... have not got that far yet... working my way through Kael's modders guide, but replacing my civ for the Celt civ he uses as a demo... I learn better that way... and not even sure how to view the xml.log... or what I would be looking for.

:cowboy:
So the fix here may be beyond my ability at this point, but thanks again for the response... will get up to speed on the Tuner and the xml.log file...
 
I switched out the code so that the new 'Builder' unit replaces the worker vice the Archer, and the Archer class override did not show a unit <Unit Type/>... but either way I do it, it screws up the text entries in the Civilopedia for the civilization and the special unit???

What I was trying to explain is, the game doesn't care WHAT you call it. It needs one unit with the <Found> ability (that lets a Settler build a city), one unit capable of doing worker actions, and one combat unit that requires no resources. If the game's objection is that you no longer have a noncombat worker unit, then it won't matter which unit class you make it replace, it just won't work.

You see, the game assembles lists of units in these three categories and picks the best available one at whatever era you've chosen to start in. If you start in the Industrial Era, for instance, the resourceless combat unit will be the Rifleman, while a Modern Era start would use Infantry and a Future Era start would use MechInfantry. It does this for all three categories; in my own mod I added the "Combat Engineer" unit in the Industrial era, which has better movement and builds faster; when I start a game in the Modern era, I get those instead of Workers as my starting worker unit.

The point is, by adding a combat rating to your worker, it might have kicked it out of that "worker" category, which screws everything up. The way to check this would be to go back, re-enable the worker, and try changing it into your unit, stat-wise, to see if it still works. If it works, then something else specific to your unit is wrong, but if it doesn't, then you know that you just can't do this idea.

I placed The UnitClassOverride element in the same XML file as the defenition for the mod civilization rather than in the XML file for the mod unit...

Doesn't matter at all. You could stick it all in a single file named "Bob.xml" and it'd all still work the same. That's how GameData XML modding works.

working my way through Kael's modders guide, but replacing my civ for the Celt civ he uses as a demo...

Kael's guide is a great starting point, but try to remember that it's a year old. Quite a few things in it just aren't correct any more, because patches have changed things. For instance, that guide predates the entire VFS change; any .dds files you're adding, for instance, will need to be set to import; without that you'll get a ton of error messages if you try to play.

As to the Tuner and logs, do this:
1> Find your working directory. In Windows 7 it'll be
My Documents/My Games/Sid Meier's Civilization V/
In that directory are three things we care about: the config.ini file, the /Logs directory, and the /MODS directory. (You might care about more than that, but those three matter for this discussion.)
2> Open the config.ini file. Notepad works fine.
Near the top you should see a line that says "EnableTuner = 0". Change it to a 1.
Deeper in the file will be something like "EnableLogging = 0". Change it to a 1 as well.
Right after that will be about a dozen or so more logging flags, all set to 0. These'll turn onor off various types of messages in the log files. Change whatever you want from 0 to 1; at the least you probably want the messaging logs on, but quite a few of the things in there aren't worth looking at unless you're debugging something specific.
3> Now, the next time you run the game, also run FireTuner. It's in the SDK. FireTuner has a bunch of useful features, like on-the-fly map editing and such that make it great for playtesting, and you can also type Lua commands into it directly (by switching the mode to InGame), but for the moment we just care about the messages it displays automatically. Any Lua function that executes a print("moo"); type statement will display here, as will any error messages if a Lua function crashes.
4> Now, back in that directory I pointed you to in #1, go into the Logs directory. Look for xml.log. Open it; again, Notepad's fine, it's just text. In there will generally be one block of error messages per mod you load. Note that there WILL be error messages and a couple warnings, because the core game actually has a few unresolved errors in it; I'd recommend starting up a game without any mods, just so you have an idea of what the baseline errors are, and then when you try to run your own mod you'll know which things are safe to ignore.
5> The /MODS directory I mentioned before is where your modfiles will be placed by the game. If you ever want to know exactly which files the game has access to, this is where you'll see that. This is useful if you stored the intermediate steps in your mod's creation in your working directory, especially if you've been doing graphical work.
 
I got the Tuner up and running - thanks - uncovered a Runtime error where the code was looking for a number or a string... would not accept a 'null', so chaned the code on the UnitClassOverride Function to read <UnitType>0<UnitType/>, which seemed to do the trick for the most part. Now the only text that is not showing up is the text for the modified unit in the Civilopedia...

As far as references are concerned, that was pretty much what I fugured, as long as the tag was correct because it compiles before sticking it into SQL. The game functionality works fine, it is only the Civilopedia references that get hosed up...

Anyway, works to a degree I can accept for now. Thanks for the heads up on the Tuner.. :)
 
The game functionality works fine, it is only the Civilopedia references that get hosed up...

Attach your mod to a post and we can try to debug that for you. While it might be playable in the current state, that sort of Civilopedia issue generally means there's still something slightly wrong, and who knows how that will manifest down the road.
 
I figured it out... and the UnitClassOverrides and the issue with the Civilopedia were not related... I was just tweaking bith at the same time, so poor logic on my part with the cause and effect relationship. I did find out that text entries to be displayed in the Civilopedia are particular with the Tag syntax.. and that was the issue. Also found the database.log... that helps. I'm learning, but at a glacial pace. Next step... Nexus and skinning... :P Then I might tackle Lua coding...
 
Back
Top Bottom