UI Question: how to change location of unit icons?

Arkatakor

King
Joined
Mar 11, 2006
Messages
620
Location
Stockholm, Sweden
I am eyeballing the creation of a mini mod to allow for multiple units per tile.

While technically a simple XML tag edit allows for this, the UI does not support multiple units (of the same type) in a tile. For example if 2 warriors are in the same tile, you will not be able to pick out and choose between them as their unit icons overlap 100%. On the other hand if a military and non military unit occupy the same tile, their icons are separated, not only because their shape is different but because one unit icon is positioned slightly above the other (see screenshot).

So what I would like to do at this point is to extend the separation of unit icons for units of the same type (raise the icons above each other slightly, as in the screenshot). So in the case of multiple military units in a tile, the unit icon circles would be slightly above each other so that they would be slightly separated, thus clickable.

Where is the logic that defines where (or in this case how far above) the unit icons appear above the units? I am new to modding, however I know C++ but have never touched Lua and am not sure how it interacts with the DLL. If someone could point me in the right direction as to where the logic is that displays the placement of the unit icons (be it lua or c++), I would appreciate it very much.

Btw if anyone is aware of a mod that already does what i'm attempting to do, let me know and i'll stop dead in my tracks :)
 

Attachments

  • Civ5UnitIcons2.png
    Civ5UnitIcons2.png
    277.1 KB · Views: 137
Ok great to know someone has already taken the initiative to implement this. I did a google search a few days back to see if there were any proper multiple unit per tile mods and there seemed to be only one on steam workshop which only modified an xml parameter (no UI modifications). This brings me to my next question - how come your mod is not on the steam workshop? Maybe it is but I could not find it.

I have another active mod that sets the PLOT_UNIT_LIMIT to 2 in GlobalDefines.xml. However when using your mod in conjunction with that mod, I only was allowed 1UPT. How and where can I change the number of units allowed in ordinary tiles in your mod?
 
You don't really need whoward69's DLL (though it is spectacular), you just need to grab the UnitFlagManager.lua out of the Airbases mod, and add it to your mod (VFS=True).

As far as whoward69 and Steam, see post #39 here
 
You don't really need whoward69's DLL (though it is spectacular), you just need to grab the UnitFlagManager.lua out of the Airbases mod, and add it to your mod (VFS=True).
Thank you for pointing that out to me. I was curious to know where the logic was as I might be interested in isolating just that functionality. That said I don't see how just tweaking the UI and extending the limit of units allowed per tile addresses the following 2 concerns:

1) You would still need logic to handle what happens when a unit attacks a city with zero hp and 3 units with full health in the city. Otherwise the 3 units would just die by default I presume.
2) I am guessing you also need logic so that when attacking a stack, the strongest or most likely unit to survive defends against the attacker.

I suppose to cater of the 2 aforementioned concerns, DLL modifications would be necessary because you are tweaking with the core combat mechanics of the game. Or am I wrong? Can the above two issues be handled in Lua alone?
As far as whoward69 and Steam, see post #39 here
I understand his frustration. However its been 2 years since so things might have changed since then. That said I would not blame him for not going back on principle, considering what he has been through.
 
1) You would still need logic to handle what happens when a unit attacks a city with zero hp and 3 units with full health in the city. Otherwise the 3 units would just die by default I presume.
This is no different in the standard game if the three units are a melee, a ship and a plane - all die when the city falls.

2) I am guessing you also need logic so that when attacking a stack, the strongest or most likely unit to survive defends against the attacker.
IIRC that logic still exists in the DLL (probably an artefact from CivIV)
 
This is no different in the standard game if the three units are a melee, a ship and a plane - all die when the city falls.
well considering that one can tweak it so more units are allowed in a city as opposed to an ordinary tile, maybe thats not a bad thing.
IIRC that logic still exists in the DLL (probably an artefact from CivIV)
I'll do some testing over the weekend and keep you posted on this :) EDIT: just saw some code in the dll titled "getBestDefender()" - looking good sofar!
 
You don't really need whoward69's DLL (though it is spectacular), you just need to grab the UnitFlagManager.lua out of the Airbases mod, and add it to your mod (VFS=True).

As far as whoward69 and Steam, see post #39 here
I copied the UnitFlagManager.lua file as well as its parent folders into one of the existing mods that i'm using (bolded in the below link). That mod modifies global defines for number of units per tile.

C:\Users\Arkatakor\Documents\My Games\Sid Meier's Civilization 5\MODS\3 Units per Tile (v 1)\UI\InGame\UnitFlagManager.lua

The UnitFlagManager.xml is also in the aforementioned directory. However the UI effects to separate the unit icons are not occurring - I guess I missed a step. I understand VFS means virtual file system; does it mean I have to do something to make it activated?
 
I guess I missed a step. I understand VFS means virtual file system; does it mean I have to do something to make it activated?

See 3rd link in my sig
 
See 3rd link in my sig
Lots of info there - I created a new mod with modbuddy, created a single XML with the following changes:

Spoiler :
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by ModBuddy on 3/21/2015 7:42:21 PM -->
<GameData>
<Defines>
<Update>
<Where Name="PLOT_UNIT_LIMIT"/>
<Set Value="2"/>
</Update>
</Defines>
</GameData>
I then created a new LUA file and pasted all the code in your ImprovementAirbases.lua file into it. I set VFS=True, build it and tossed the mod into my mods directory. Unfortunately its still not working. I'm assuming I need to do something related to importing icon art.
Thanks for bringing this up Arkatakor, this is pure gold :D
Welcome - i'm guessing this has been brought up many times before though :p
 
Not quite. ImprovementAirbases.lua should be VFS=False, and instead use InGameUIAddin (see the link mentioned above again).

EDIT: However, are you sure that's the file you want to add? We were saying you wanted UnitFlagManager.lua [also UnitFlagManager.xml], which are supposed to be VFS=True since they overwrite base game files.

Also, building your mod should automatically put it in your Mods folder.
 
Not quite. ImprovementAirbases.lua should be VFS=False, and instead use InGameUIAddin (see the link mentioned above again).

EDIT: However, are you sure that's the file you want to add? We were saying you wanted UnitFlagManager.lua [also UnitFlagManager.xml], which are supposed to be VFS=True since they overwrite base game files.
My bad - somehow I got confused between the files. Ok here is what I did:

1) I removed ImprovementAirbases.lua from my mod

2) I added UnitFlagManager.lua and UnitFlagManager.xml to my mod, set VFS for both to true. I put them in sub folders, reflecting the directory structure in the original mod.

3) I started another game using my mod and what effectively happened is that the unit flags were removed completely. I'm guessing there is a bug in the lua file (references to airbases logic that points to nowhere maybe).

For the sake of simplicity, I have gone ahead and uploaded my mod so people can scrutinize it. Also, I am not using any of whoward69's mods in conjunction with mine so there should be no conflict there.
Also, building your mod should automatically put it in your Mods folder..
No it does not. Building it means that your game looks for local mods in the local Firaxis ModBuddy folder, but it does not copy it over to the mods folder (unless i'm doing something wrong).

Edit: I am now re-reading post #3 in whoward69d's link. Looks like I missed a few steps. Will go over it and get back to you guys.
 

Attachments

Building it means that your game looks for local mods in the local Firaxis ModBuddy folder, but it does not copy it over to the mods folder (unless i'm doing something wrong).

In that case your ModBuddy is set up wrong. Building the mod will create the .modinfo file and package that and the rest of the XML/SQL/Lua/dds/etc files in the project into a .civ5mod file. It will also copy the contents of that package into a (correctly named) sub-directory of the "...\My Games\Sid Meier's Civilization 5\MODS" directory

Edit: You've attached the ModBuddy project, just attach the mod (second link in my sig)
 
In that case your ModBuddy is set up wrong. Building the mod will create the .modinfo file and package that and the rest of the XML/SQL/Lua/dds/etc files in the project into a .civ5mod file. It will also copy the contents of that package into a (correctly named) sub-directory of the "...\My Games\Sid Meier's Civilization 5\MODS" directory

Edit: You've attached the ModBuddy project, just attach the mod (second link in my sig)
I am presuming one needs to upload the .Civ5sln file. I'll take a look at your link shortly - got to head out now and will try uploading again later following your steps.
 
I am presuming one needs to upload the .Civ5sln file.

Nope. The .civ5sln/.civ5suo and .civ5proj files define the project to ModBuddy (Visual Studio) and are not what is needed - we need either the .civ5mod file OR a zip of the mod sub-directory under the "...\My Games\Sid Meier's Civilization 5\MODS" directory
 
Nope. The .civ5sln/.civ5suo and .civ5proj files define the project to ModBuddy (Visual Studio) and are not what is needed - we need either the .civ5mod file OR a zip of the mod sub-directory under the "...\My Games\Sid Meier's Civilization 5\MODS" directory
Got it - i've gone ahead and uploaded the correct file which I just built. I will in the meanwhile continue to investigate what I could have done wrong. Clearly i'm missing some steps so I might start another project and see if I can at least get it to copy into the mods directory upon building.

Thanks again for your support on this :)
 

Attachments

Ok I got it to work - the unit flags now display and split up correctly. It turns out like the idiot that I am, while creating the UnitFlagManager.xml file I forgot to include the logic from your xml file itself - so it was just an empty xml file.

I still can't get the project to deploy on the mods directory upon build though.
 
I still can't get the project to deploy on the mods directory upon build though.

In ModBuddy, Tools menu, Options item, expand Civilization 5 (at bottom of left hand list), click on General

The path under the Civ 5 User Path should look like "C:\Users\XYZ\Documents\My Games\Sid Meier's Civilization 5"

(where XYZ is your login name)
 
In ModBuddy, Tools menu, Options item, expand Civilization 5 (at bottom of left hand list), click on General

The path under the Civ 5 User Path should look like "C:\Users\XYZ\Documents\My Games\Sid Meier's Civilization 5"

(where XYZ is your login name)
Sorry for not responding earlier, had an unusually busy week. It turned out I had two extra sub directories on top of the path you gave me. I must have messed up on my initial setup of modbuddy.

Thanks again for taking the time to respond to my questions. I will certainly have more of them :)
 
Back
Top Bottom