[BIG IDEA] UnitStack in Cities via Buildings

poncratias

Prince
Joined
Feb 9, 2010
Messages
336
I'll just copy this from an other thread, because here it should be as a mod proposal/request to anyone skilled enough to do it:)

-------
Let's cut to the point:
What if you could stack units in cities, but you need to build special buildings to do so?

For example: 1 Barrack could host 1 Unit.


So you could build multiple barracks, raising the unit capacity +1 for each.
This is also kind of realistic, as you need a place/building where your troops can stay in real life too.
The same could work for Airports/Airfields.

It doesn't have to be the barracks building, just as an example, name it what ever you like;)

This would also enhance the rest of the Civ V gameplay greatly in return:
Empires would spread out more, as there is an important reason for building cities etc.

This also would not lead to defensive Stacks of Doom, as you can only stack as many units as you have buildings/space for them, and this buildings can be expensive and take a while to build.

So no too big stacks, no overpowering!
-----



If this won't get patched in (probably not), we need someone able to do it!

I try my best at the moment, but I'm just not good in modding so far...


Things to do:

Code:
1)Building:
Create/change a building (Barracks, Military Base, Quarters,etc) to give +1 unit-space to the city , with some upkeep for that building.

2)Production:
make this building be multiple buildable

3)Gold management:
 when units are fortified in the city, they cost no money, but the building has some upkeep.
as soon as they leave, the unit upkeep for them is to be paid again.

4)City defense system:
add Unit strength to the city defense OR add unit strength to city HP OR let the units fight when enemy attacks
 
Nice idea, this could swing the late-game balance a little bit more into cities' favor.

I would not allow multiple instances of one building though, I would just change the existing military building (where housing of military units makes sense - barracks, military base, castle...) to increase the unit limit.
 
Right now I'm searching through the xml's but I can't find any entry to alter the units per tile rule for cities.

Am I missing something?
 
Well, you can do what Dale did in the Legions mod:

change GlobalDefines.xml
<Where Name="PLOT_UNIT_LIMIT"/>
<Set Value="999"/>

Which would change all plot limits, not just cities

But that wouldn't solve the current main problem of stacking: which is the fact that in cities only one unit counts for defense, and once the city lost you've lost all the units that were in it.
 
Well, you can do what Dale did in the Legions mod:

change GlobalDefines.xml
<Where Name="PLOT_UNIT_LIMIT"/>
<Set Value="999"/>

Which would change all plot limits, not just cities

But that wouldn't solve the current main problem of stacking: which is the fact that in cities only one unit counts for defense, and once the city lost you've lost all the units that were in it.

Reminds me of civ2: if you had 50 units stacked, and one died, they all died.
 
This would need some additional coding and not just a xml fiddle I think, but it would be helpful if cities could host more units instead of having them scattered around. Even if they didn't contribute to city health, I often find that large armies with small empires often have to get parked around to no avail.
 
Here's my solution to the problem:
Step 1, Define 2 additional units: Army and Navy. These units should act like a transport for Land and Sea units, respectively (like carriers act for jets).
Step 2, figure out a way to add an Army/Navy unit wherever two or more combat units get in the same tile in it.

I thought about it a couple of weeks ago but didn't have the time to put it to the test. I hope to get started on it sometimes next week, but in the meantime, if someone else picks up the glove and shares his progress I would be very appreciative.
 
I'm afraid that we are not able to mod such things as it's not possible twith the given tools till now...
 
yea you'd pretty much have to add a new tag for the buildings, which would require adding to the schema, which would require editing the DLL, so its probably not happening for awhile.
 
Unless someone can find out how to do it via LUA. But this would need to be updated for every building that you would add, and it wouldn't be very friendly to peeps that don't understand Lua... Well time to learn Lua callbacks, I did with Python in Civ 4 got my mods to work that way. I'd imagine it wouldn't work with SQL since that mods the XMLs instead of raw callbacks, hooks & definitions. I myself am interested in this since I would need the Silo building to be able to house multiple nukes at once in the same city. I'll go look into this with Lua.
 
Civ Fuehrer, I'm already very familiar with the callbacks and function available, and this mod is not possible with what we have ATM.
 
Interesting idea, but it cannot be done with XML alone. And while it might just be possible to code something to that effect in LUA (IF someone manage to uncover some type of "canMoveInto" check for LUA) then the only proper way to implement something like this - with XML tag support for buildings etc. - will be with a moded DLL.


Well, you can do what Dale did in the Legions mod ...
That would be "what Kael did in the Legions mod" btw.
 
If it were possible with Lua, you could do it with a new DB table (rather than a new field in an existing one), keeping it modular. No need for callbacks to be added by later mods. On the other hand, it doesn't seem possible with Lua as-is. You'd need to be able to act on building gain/loss, and set stack limit per-tile (for one implementation strategy, anyway).
 
Afaik then you cannot make entirely new tables that are not already defined by the current structure without also changing the DLL code.
 
Afaik then you cannot make entirely new tables that are not already defined by the current structure without also changing the DLL code.
Really? The XML template spat out by ModBuddy implies you can (has a place where it says to add table definition). It oughtn't to need changes to the DLL, given the way SQL works and the ease of creating a structured access to it resembling that available in Lua (that is, representing the SQL tables as nested Lua tables).
 
If the Civ5 DLL works anything like the Civ4 DLL then the XML/SQL schemas has to be defined in the DLL as well - new XML/SQL tables straying from what the DLL knows about would most likely be rejected and thus not available to LUA.

Of course, they could have been clever about this and allow the creation of entirely new SQL tables that the DLL have no clue about which would be directly accessible to LUA, but seeing they haven't been all that clever about much else then I doubt it.
 
If the Civ5 DLL works anything like the Civ4 DLL then the XML/SQL schemas has to be defined in the DLL as well - new XML/SQL tables straying from what the DLL knows about would most likely be rejected and thus not available to LUA.

Of course, they could have been clever about this and allow the creation of entirely new SQL tables that the DLL have no clue about which would be directly accessible to LUA, but seeing they haven't been all that clever about much else then I doubt it.
My impression in CivIV (and I admittedly didn't get deeply into it) was that didn't use a direct XML-to-SQL mapping, so the DLL had to mediate between the XML and whatever the runtime data format was (SQL for all I know, or anything else). The new format is XML-as-proxy-for-SQL, so it is dealing with pure SQL the whole time. It's easier to make the Lua directly access the SQL than it is to restrict it.

Of course, if someone with more time than me wants to test this, it shouldn't be too hard.
 
Speed aside, then it doesn't matter whether the DLL reads the data from XML or SQL. The DLL still has it's own internally defined references for the various data, so if you add or change something in the SQL that are not also defined within the DLL, then the DLL will either be clueless about the additions/changes (meaning it wont make them available to LUA) or reject the modified SQL altogether - and go back to using the default one.
 
Speed aside, then it doesn't matter whether the DLL reads the data from XML or SQL. The DLL still has it's own internally defined references for the various data, so if you add or change something in the SQL that are not also defined within the DLL, then the DLL will either be clueless about the additions/changes (meaning it wont make them available to LUA) or reject the modified SQL altogether - and go back to using the default one.
I cannot speak about a DLL none of us has access to, but I've already been creating new tables and using them via Lua. Apparently, Firaxis was smart enough about that to hook up the plumbing. They provide a 'generic' API to get into the SQL tables via GameInfo. Any table you add can be accessed via "GameInfo.MyNewTable"

I haven't tested adding new elements to an existing table, so I won't speculate on that more than to say, you won't know until you try.
 
Top Bottom