View Full Version : Unit Renaming and WB Saves


Gaius Octavius
Jan 06, 2008, 07:05 PM
Every time I try to give my units custom names in the worldbuilder and then save the file, all the names reset to the default unit name. I thought perhaps I would work around this by manually setting names in Notepad, along the lines of "Uniquename=blahblahblah" under the individual unit entries, but that does not work, either.

Does anyone know how to preserve renamed units in a WB file for a scenario? Do you have to resort to some kind of automatic renaming mechanism on the first turn? It seems like a shame that we can rename units only to have them lost upon save.

Gen. Maximus
Jan 10, 2008, 04:24 AM
Can somebody answer this plz... i got the same problem

Gaius Octavius
Jan 10, 2008, 07:42 AM
There was one stop-gap idea I had, but I don't know if it would work... you could set the unique names in the XML unitinfos file, and then the game would rename each unit in sequential order, presumably based on its map location (with the lower left corner being first). But like I said, I have no idea if this would work for units already placed.

Problem is, either way this isn't really a solution, but more of a workaround. And it would be very hard to do for maps with hundreds of units, where you'd have to know exactly how and where each one was placed to order them correctly.

Gen. Maximus
Jan 11, 2008, 07:21 AM
Spent one freaking day surfing the forum to figure this out and i think i found it. You need to edit the unit name in the \Assets\XML\Text\CIV4GameTextInfos_Objects.xml
I try it yesterday but it didn't before i go to bed. Thinking it over it, I'd just realise I forgot to add the mod path in the wbs file. I'm confident it gonna work when i get home later :)

Gaius Octavius
Jan 11, 2008, 11:54 AM
I really don't understand how that would affect this issue. TextInfos_Objects deals with the translation of your unit type names (e.g. "Infantry", "Marine", "Carrier", etc.) but not unique names, like "CV Hornet". I think we are talking about two entirely different things here.

Gaius Octavius
Feb 17, 2008, 11:02 AM
The funny thing is that all unit names are saved within the actual savegame file, but not with the WB saves. I wish there were an easy way to script it to save it in a regular scenario map... maybe an SDK change would do the trick?

Other than that I guess you'd just have to use a Python script to rename each unit at the start of your scenario. :(

Wolfshanze
Feb 17, 2008, 11:13 AM
Wow... I didn't even know this was a problem... I always rename my ships in-game, and figured pre-set scenarios would have named ships too (USS Hornet, KMS Bismarck, etc), but I didn't know this problem occured... weird.

My Pre-Dreadnought Battleship "SMS Brandenburg" just sank four enemy age of sail ships in one turn last night! That was great!

Dale
Feb 17, 2008, 01:36 PM
The unit name field is not saved into the WBS file. This is controlled via python so give me a few days and I should have it sorted out. Remember, save games are DLL controlled and totally separate.

GO, I got your PM, just hadn't had time to respond yet. :)

Gaius Octavius
Feb 29, 2008, 12:07 PM
The unit name field is not saved into the WBS file. This is controlled via python so give me a few days and I should have it sorted out.

And... did you? :D


:bump:

Shiggs713
Feb 29, 2008, 05:11 PM
you should see the civ specific GP mod. It gets around it in the way you described above.

Gaius Octavius
Feb 29, 2008, 05:20 PM
you should see the civ specific GP mod. It gets around it in the way you described above.

...............You are kidding, right? :lol:

Dale
Feb 29, 2008, 05:54 PM
Sorry I forgot. :p

Shiggs713
Feb 29, 2008, 06:08 PM
well I think so, its been awhile since I've used it, I think its made by Mexico if memory serves.

Gaius Octavius
Feb 29, 2008, 06:22 PM
well I think so, its been awhile since I've used it, I think its made by Mexico if memory serves.

No, what I mean is, I made the Civ-Specific Great People mod... I know how it works! :D That's what I'm trying to avoid--having to write a clumsy Python function to do this, which would be very hard when you have identical units on the same tile. Mexico's mod just checks for the presence of a UU. It doesn't deal with savegame ability.

Dale
Feb 29, 2008, 06:22 PM
GO:

Just what the doctor ordered. This updated WbDesc.py allows unit names to be saved and loaded in WBS scenarios.

Definition:

BeginUnit
UnitType=UNIT_AZTEC_JAGUAR, UnitOwner=11
UnitName=My Units Name Here
Level=1, Experience=0
EndUnit


Just unzip to your python folder (will end up in the PyWb folder). :)

Gaius Octavius
Feb 29, 2008, 06:26 PM
Just what the doctor ordered. This updated WbDesc.py allows unit names to be saved and loaded in WBS scenarios.


Perhaps the understatement of the year! :lol:

I'm surprised that this has such a simple solution. There's not even a need for an SDK check! I think this is worthy of an upload to the DB even though it's just one file. :goodjob:

:thanx:

Dale
Feb 29, 2008, 06:27 PM
Perhaps the understatement of the year! :lol:

I'm surprised that this has such a simple solution. There's not even a need for an SDK check! I think this is worthy of an upload to the DB even though it's just one file. :goodjob:

:thanx:

Nah, I've asked Alex to put it in the next patch. ;)

Gaius Octavius
Feb 29, 2008, 06:30 PM
You'd better tell all those nuts in the BtS subforum that there will be a next patch first... They spend all day arguing whether Firaxis has abandoned BtS. :crazyeye: :D

Dale
Feb 29, 2008, 06:32 PM
Bah! Let them stress out over it. :D

But I uploaded it for those that want it. http://forums.civfanatics.com/downloads.php?do=file&id=8587

Dom Pedro II
Feb 29, 2008, 06:48 PM
Hey, Gaius, you ever answer your PMs? ;) Is your inbox full, or should I take it as a snub? :p

Gaius Octavius
Feb 29, 2008, 06:53 PM
Hey, Gaius, you ever answer your PMs? ;) Is your inbox full, or should I take it as a snub? :p


-------->
Sorry I forgot. :p

:lol:

Normally I try to answer every one but sometimes I get busy and forget. :p I suppose this is a good sign that I shouldn't be a playtester. But I do hope you get that mod out soon. :mischief:

Shiggs713
Feb 29, 2008, 07:09 PM
thanks Dale, I'll be using this as well.

Dale
Mar 01, 2008, 10:50 PM
Hey guys, found a bug that needs fixing. Use this python file instead.

Before, empty names were being saved as the unit description. Which means when loaded it would come up as Cavalry (Cavalry).

This fixes it so if the unit's name is empty, then it does not save the UnitName field. :)

Gaius Octavius
Mar 01, 2008, 11:32 PM
Dale: might be a new bug now. I renamed the units at Pearl Harbor in my scenario to test it out, but when I reloaded I got "BB Arizona (Battleship) (Battleship)" when it should obviously just have one Battleship tag. The names are being saved correctly though.

Shqype
Mar 02, 2008, 02:39 AM
Nah, I've asked Alex to put it in the next patch. ;)

:Faints:

Do you have any kind of timeframe for the next patch?

Dale
Mar 02, 2008, 03:00 AM
Dale: might be a new bug now. I renamed the units at Pearl Harbor in my scenario to test it out, but when I reloaded I got "BB Arizona (Battleship) (Battleship)" when it should obviously just have one Battleship tag. The names are being saved correctly though.

No that's the same bug. It was saving the full name + type, instead of the entered name + type.

Sorry. Don't worry, the easiest way to negate all UnitName keys in the WBS (in other words flush all the UnitName entries like I had to do in a new RtW scenario) is to remove the python file from the mod, and then save a new WBS file. That'll get rid of all the UnitName entries.

Dale
Mar 02, 2008, 03:00 AM
:Faints:

Do you have any kind of timeframe for the next patch?

Sometime in the future. I don't know their plans, just that my emails to Alex still get read. :p

wotan321
Mar 02, 2008, 07:03 AM
Wow! I have been asking about this functionality since the first week BtS came out! Thank-you so much for making it work. This is a GIGANTIC upgrade, now those WW2 scenarios can actually start with all the divisions, armies, and warships named and in position.

Uh... next question.... could you now create an event that is triggered by a particular unit?

Gaius Octavius
Mar 02, 2008, 10:34 AM
I imagine you could have the game check the unit's name and thereby activate an event.

Gaius Octavius
Mar 03, 2008, 10:25 AM
No that's the same bug. It was saving the full name + type, instead of the entered name + type.


So is it supposed to be taken care of in your new file? Because I still get the same problem... (I'm looking into fixing it, however.) ;)

Gaius Octavius
Mar 03, 2008, 10:55 AM
Okay, I have edited Dale's Python script to account for the unit type. Instead of getting that extra (UNIT NAME HERE) tag, it will now correctly save only the unit's actual name.

I have tested this and did not find any bugs, but it is good to double-check. :)

Ambreville
Mar 03, 2008, 11:32 AM
Tested it. Seems to work just fine. Thanks!

Dale
Mar 03, 2008, 01:07 PM
Okay, I have edited Dale's Python script to account for the unit type. Instead of getting that extra (UNIT NAME HERE) tag, it will now correctly save only the unit's actual name.

I have tested this and did not find any bugs, but it is good to double-check. :)

GO, your script will only work in your situation where you saved it under the original script I produced.

The new one I produced does not save the unitType in the description. Thus, your's will keep reducing the unitName on subsequent saves. :)

Gaius Octavius
Mar 03, 2008, 01:14 PM
Dale, check it again to be sure. The second file you posted does save the unit type with the WB! ;)

EDIT: It can't keep reducing the names upon every save, since I've tested it. In fact, I've already added my unique unit names to WWII in the Pacific, and I saved it probably upwards of 20 times in the process. The names appear just fine. :crazyeye:

Dale
Mar 03, 2008, 01:30 PM
I just checked my script, and it works fine. I've compared all three (mine, yours and what I posted up above) and all three are different. I can only conclude I uploaded the first one again above.

The one posted above uses unit->getName() which includes the unitType, yours then strips out the unitType, but mine (attached to this post) which is what should've be uploaded before, uses unit->getNameNoDesc() which doesn't include the unitType.

I get this:

BeginPlot
x=46,y=32
TerrainType=TERRAIN_PLAINS
PlotType=2
BeginUnit
UnitType=UNIT_SETTLER, UnitOwner=0
UnitName=John
Damage=0
Level=1, Experience=0
FacingDirection=4
UnitAIType=UNITAI_SETTLE
EndUnit
BeginUnit
UnitType=UNIT_SETTLER, UnitOwner=0
UnitName=Name Test
Damage=0
Level=1, Experience=0
FacingDirection=4
UnitAIType=UNITAI_SETTLE
EndUnit
BeginUnit
UnitType=UNIT_SETTLER, UnitOwner=0
Damage=0
Level=1, Experience=0
FacingDirection=4
UnitAIType=UNITAI_SETTLE
EndUnit
TeamReveal=0,1,2,3,4,5,6,7,8,9,10,11,
EndPlot


So, my code is right, I just uploaded the wrong one before. :blush:

Dale
Mar 03, 2008, 01:34 PM
Dale, check it again to be sure. The second file you posted does save the unit type with the WB! ;)

EDIT: It can't keep reducing the names upon every save, since I've tested it. In fact, I've already added my unique unit names to WWII in the Pacific, and I saved it probably upwards of 20 times in the process. The names appear just fine. :crazyeye:

Yeah sorry, I thought the script WAS using getNameNoDesc() which would've produced the correct result, then with you removing characters from the end would've been wrong.

I was wrong, as I explained above. :)

Gaius Octavius
Mar 03, 2008, 02:16 PM
Yeah, I figured it was just some kind of snafu. :mischief:

So I guess we have two versions that work, not that it really matters, since this will be in the next patch. Anyways, I'm glad to see that we can finally give our armies real names for our scenarios now!

:cheers:

Ambreville
Mar 05, 2008, 01:30 PM
One very minor point...

Using this ability to give historical tags to units is that the tag itself is used in the combat log to refer to units, rather than their actual types. So you end up with logs like "Your Squadron 222 shot down a German 1./JG 26 unit." :crazyeye:

------------------------

EDIT

On the other hand, there is a benefit in that the actual units involved can be better identified this way, especially in my project where many units of the same type are involved. This is particularly true to air units.

Dom Pedro II
Mar 05, 2008, 02:25 PM
It's possible to have the combat logs display the unit type rather than the unit's specific name.

Would also be possible to have them display "Unit Name (Unit Type)"... so you could say "Our Bismark (Battleship) has killed an enemy HMS Hood (Battleship)" *I mean Battlecruiser!* ;)

Shqype
Mar 05, 2008, 02:33 PM
It's possible to have the combat logs display the unit type rather than the unit's specific name.

Would also be possible to have them display "Unit Name (Unit Type)"... so you could say "Our Bismark (Battleship) has killed an enemy HMS Hood (Battleship)" *I mean Battlecruiser!* ;)

Even cooler would be "Our Battleship 'Bismarck' has killed the enemy Battleship 'HMS Hood.'" ;)

Dom Pedro II
Mar 05, 2008, 02:45 PM
Even cooler would be "Our Battleship 'Bismarck' has killed the enemy Battleship 'HMS Hood.'" ;)

That's also possible as well. Heck, you could even have it say "The Bismarck, which is a type of Battleship, sank the enemy Battlecruiser the HMS Hood which Wolfshanze insists is really a Battleship." It's all just a matter of how much time you're willing to put into designing the logs system so that it's grammatically correct for each instance.

Shqype
Mar 05, 2008, 02:48 PM
haha, that's pretty funny.

You're right, though. :)

Ambreville
Mar 05, 2008, 06:13 PM
Changing the log format is in what -- SDK? XML? (Sorry -- I've never dealt with this, neither do I know how to work with SDK).

Dom Pedro II
Mar 05, 2008, 06:55 PM
Changing the log format is in what -- SDK? XML? (Sorry -- I've never dealt with this, neither do I know how to work with SDK).

Depends on what you want to change. If you just want to change the wording, you can do that in the XML. I don't know the tag name for it, so you'll just have to hunt around the game text files. If you want to change the information it provides you with, that will probably be in the SDK.

So, for example... in the XML, you'll see something like this:

Our %s1_Unit has been killed by a %s2_Adj %s3_Unit.

In the SDK, you basically provide it with the information you want... in this case it would be the namekey for our unit, the name key for the opposing player, and the name key for their unit.

If you want it changed to something like this:

Our %s1_Unit was destroyed by an %s2_Adj %s2_Unit.

You could do that in the XML. You can also choose to omit information too in the XML without needing SDK changes. If you delete the killing player's adjective, it won't cause problems.

But let's say you want it to provide the name of the city that's nearest to the tile:

Our %s1_Unit has been killed by a %s2_Adj %s3_Unit near %s4_City.

That would require SDK work because you'd have to find the nearest city and then tell the program to include that information in this message.

Ambreville
Mar 05, 2008, 07:03 PM
Changing wording would be very useful so it would include the unit type (sounds like this can be done in XML -- which I might be able to swing). What you suggest about adding the nearest city reference would be great. I'll have to wait for someone else to come up with the SDK coding though. :(

Which XML file is connected with the log format by the way?

Dom Pedro II
Mar 05, 2008, 07:35 PM
It's one of the game text files... I don't know which.

But you are going to need SDK work to include the unit's type as well because that's not provided by default. You're going to need the SDK to grab essentially five pieces of information: The unit's name key, the unit's type, the other player's adjective, the other unit's name key, and the other unit's type.

It's basically like electronic madlibs. The XML provides the basic text, but to fill in the blanks, you need the SDK.

Ambreville
Mar 05, 2008, 07:56 PM
Sounds like I'll have to leave that alone then... thanks for checking into that stuff for me.