JUnitSpace: Limited Units on Tiles

Jeckel

Great Reverend
Joined
Nov 16, 2005
Messages
1,637
Location
Peoria, IL
BtS 3.17

This mod allows you to set a default amount of Space that a Tile has. This default amount of Space on a Tile can be controled with a new GameDefinesAlt option.
Bonuses, Features, Improvements, Routes, Terrain, City Buildings, City Culture Levels, City Population, and the Cities themselves, can be used to modify the amount of Space on a Tile by setting new Tags in their Info.xml files. Whether or not most of these new XML values are check is controlable with new GameDefinesAlt options.

Each unit has a default Size that can be modified with new Tags in the UnitClassInfos and the UnitInfos. UnitInfos also has a new Tag that will allow units to move into Tiles regardless of the Open Space, but still count that units size for other units try to join it on a Tile. In addition new GameDefinesAlt options have been added to control the default Size of Units and whether or not the mod processes units of the built in 4 types of Unit Domains, Land, Sea, Air, and Immobile. Both Civilization and individual Leaders can have a new Tag set that will make them and all their units noticed my the mod. Lastly, Promotions can modify a unit's Size, as well as make it ignore the Space limits on Tiles.

I have updated most Flying Help Texts (the little windows of information that appear when you hover you cursor over things) to show relavent Tile Space Data. There are a few I haven't gotten yet, most notably, nothing in game tells you what Civilizations and Leaders ignore the Tile Space Rules. Those two specificly will be fixed in the next Stable version (looking like v0.700 right now), but if I realize I have missed others, and if more become neccessary, they will be at the top of my todo list always.

All of the text updating has been done in SDK. However, CvPediaUnit.py has had several lines of code added to a single spot so unit Sizes will display with their Movement, Attack, Range, ect. Also, CvMainInterface.py had a block of code added to one spot so I could display the Selected Unit's Size in the Unit Info Panel at the bottom right of the Main Interface screen.

If you haven't noticed, I like to have information avalable to me when I play Civ4, and I mod things that way. To this end I have add a popup screen that will display all the relevent data for the Tile your Cursor is current over, just hold the 'Shift' Key and press the 'S' Key.

I have included a single Scenario. It is the Scenario I use to test things as I'm changing the mod. Just about every major situation and combination I can think of is potrayed some where on this little map.

For some, slightly more specific info see the following spoiler. There isn't much in there, but I will be adding to it.
Spoiler :
Units ave a default Size set in the UnitClassInfo.xml.
A Unit's default Size can be modified by a tag in the UnitInfo.xml.
BaseUnitSize = DefaultSize + UnitClassInfo iUnitSizeChange + UnitInfo iUnitSizeChange

If a CivilizationInfo or a LeaderHeadInfo are set to ignore Tile Space Rules then a Unit object will ignore the rules.
By default both the Barbarian Civilization and the Barbarian Leader are set to ignore Tile Space Rules.

When the Cursor is held over a plot in the Main Interface Screen the Open Tile Space and the Total Tile Space of a Tile will be displayed.
Open Tile Space: iOpenTileSpace/iTotalTileSpace


New XML Tags (All New Tags Are Optional) v0.670
Spoiler :
All changes marked with:
<!-- JUnitSpace Mod Start -->
<!-- JUnitSpace Mod End -->

CIV4CivilizationInfos.xml
-bIgnoreTileSpaceRules

CIV4LeaderHeadInfos.xml
-bIgnoreTileSpaceRules

CIV4UnitClassInfos.xml
-iDefaultUnitSize

CIV4UnitInfos.xml
-iUnitSize
-bIgnoreTileSpaceLimit
-bIgnoreTileSpaceRules - Not Implemented in XML or SDK

CIV4BonusInfos.xml
-iTileSpaceChange

CIV4FeatureInfos.xml
-iTileSpaceChange

CIV4ImprovementInfos.xml
-iTileSpaceChange

CIV4TerrainInfos.xml
-iTileSpaceChange

CIV4PromotionInfos.xml
-iTileSpaceChange
-bIgnoreTileSpaceLimit

CIV4BuildingInfos.xml
-iTileSpaceChange

CIV4CultureLevelInfos.xml
-iTileSpaceChange


Python Changes v0.670
Spoiler :
All changes marked with:
# < JUnitSpace Mod Start >
# < JUnitSpace Mod End >

I modded the MainInterface.py and the PediaUnit.py files.
I added a new Screen.
I also use Dr. Elmer Jiggles CustomEventManager to catch the SHIFT + S event
to launch my new screen.

Lots of new methods to access all the new data.
Check out the new screen to see some of them in use.


SDK functions added and Exposed to Python v0.670
Spoiler :
All changes marked with:
// < JUnitSpace Mod Start >
// < JUnitSpace Mod End >

CyCivilizationInfo
-bool isIgnoreTileSpaceRules()

CyLeaderHeadInfo
-bool isIgnoreTileSpaceRules()

CyUnitClassInfo
-int getDefaultUnitSize()

CyUnitInfo
-int getUnitSize()
-int getBaseUnitSize()
-bool isIgnoreTileSpaceLimit()
-bool isIgnoreTileSpaceRules()

CyBonusInfo
-int getTileSpaceChange()

CyFeatureInfo
-int getTileSpaceChange()

CyImprovementInfo
-int getTileSpaceChange()

CyTerrainInfo
-int getTileSpaceChange()

CyPromotionInfo
-int getUnitSizeChange()
-bool isIgnoreTileSpaceUnit()

CyBuildingInfo
-int getTileSpaceChange()

CyCultureLevelInfo
-int getTileSpaceChange()

CyUnit
-int getUnitSize()
-int getTotalUnitSize()
-int getExtraUnitSize()
-bool ignoreTileSpaceLimit()
-bool ignoreTileSpaceRules()

CyPlot
-int getBaseTileSpace()
-int getTileSpace()
-int getBonusSpaceChange()
-int getFeatureSpaceChange()
-int getImprovementSpaceChange()
-int getTerrainSpaceChange()
-int getCityBuildingSpaceChange()
-int getCityCultureLevelSpaceChange()
-int getHillSpaceChange()
-int getUsedTileSpace(bool bCountCargo)
-int getOpenTileSpace(bool bCountCargo)
-bool isTileSpaceFull(bool bCountCargo)


Download: JUnitSpace v0.693bts3.17 - Released June 24, 2008
 
I have v0.680 to the Beta stage.
Here is the Change Log since v0.660b3.02
Spoiler :
v0.670
Updated DLL, XML, and Python to BtS v3.13.

Fixed a few typos.
Changed Settler Unit bIgnoreTileSpaceLimit to True.
DEFAULT_TILE_SPACE changed from 6 back to 10.
Added mising TXT_KEY to show Unit Size in the Unit Pedia Page.
Added new GlobalDefineAlt that allows enabling/disabling of Route Tile Space Modifiers.
Added XML Tags for Route Tile Space Modifiers. (New Tags NOT Used Yet)

New XML Tags:
CIV4RouteInfos.xml
iTileSpaceChange
bIgnoreTileSpaceLimit - Not Used, May Be Removed

v0.680
Changed Road iTileSpaceChange from 6 to 4.
Changed Railroad iTileSpaceChange from 12 to 8.
Fixed CvUnitInfo getBaseUnitSize() to be more intuitive.
-Was: UnitInfo Size or UnitClassInfo Size or Default Size.
-Now: Default Size + UnitClassInfo Size + UnitInfo Size
Fixed CvUnitInfo isIgnoreTileSpaceRules(). Units with 0 Size declared in XML Ignore Tile Space Rules.
Fixed CvGameTextMgr setBasicUnitHelp to not show Size for Units that Ignore Tile Space Rules.
Updated CIV4UnitInfos.xml and CIV4UnitClassInfos.xml to iUnitSpaceChange Tag.
Updated CIV4UnitSchema.xml to iUnitSpaceChange Tag.
Updated JUnitSpace Test Map Scenario to show Promotion and Route effects.
Updated Tile Space Data Popup to show Route Data.
Rewrote Tile Space Data Popup code to be more effecient and clear.


New SDK Methods: (all exposed to python)
CyRouteInfo
int getTileSpaceChange()
CyPlot
int getRouteSpaceChange()


Changed SDK Methods: (all exposed to python)
CyUnitInfo
int getUnitSize() --> int getUnitSizeChange()
CyUnitClassInfo
int getDefualtUnitSize() --> int getUnitSizeChange()


If you would like to download and beta test this version for me, it would really help out. The file is attached to this post.




ToDO:

v0.670 + v0.680 - Done
-Add a RouteInfo Modifier.

v0.681 - Done
-Update City Screen's Building List to show Building's Tile Space Change.
-Update City Flying Help Text to show City's Open Tile Space and Total Tile Space.

v0.682 - Done
-Add same functionality to BuildingClassInfo/BuildingInfo as UnitClassInfo/UnitInfo.

-Add accual bIgnoreTileSpaceRules Tag to UnitInfo.

v0.683 - Done
-Add Crowded promotion and maybe some others.
--Also need GameDefinesAlt options to set which promo is used for Crowded ect.
--And some GameDefinesAlt options to turn promos on and off.

-Update CvGameTextMgr parseLeaderTraits.

-Update CvGameTextMgr parseLeaderHeadHelp.

-Update CvGameTextMgr parseCivInfos.

v0.69x - In Progress
-Add a HandicapInfo Modifier.
--Need Tile Space Modifier.
--Also Unit Size Modifier.

vUnknown
-Add icons to City Billboards to show city's Space State.

-Add an EraInfo Modifier.
--Definetly a Tile Space Modifier.
--Maaayyybe a Unit Size Modifier.

-Add a TechnologyInfo Modifier.

-Add a Trait Modifier and maybe some Ignore Limit and/or Rules code.

-Give Buildings a Size.

-Give Units ability to add Space to the Tile they are in.

-Update CvGameTextMgr ?parseLeaderShortTraits?.

-Update CvGameTextMgr ?paseLeaderLineHelp?.
 

Attachments

  • JUnitSpace_v0.680bts3.13.zip
    2.2 MB · Views: 211
Wow, this sounds AWESOME! I asked for something like this and I'm glad that you were able to bring it to light.

My only question is, how does the AI react to these changes? Using the default AI would not work, I believe, because the AI would spam units on a tile, fill up the space quota, and not be able to move any more units on that tile without knowing why. I fear it could break AI logistics, especially when waging war.
 
I haven't noticed any apparent problems with the AI. I am outlining an update that will make the AI a little smarted to know to move out weaker units to make space for stronger units. But for most instances, the AI doesn't really need to know why it can't enter a square.

Its going to need a little tweaking, but for the most part the AI seems to handle it fine in my test games. However, I don't get much time to accually play Civ4, so please, any that play post up suggestions or issues with the AI. :)
 
This is a pretty cool idea. I've always felt that there was too much stack vs stack in Civ, and not enough incentive to think about actual arrangements.
 
In the UnitInfos you can also set Units to ignore the Tile Space Rules or just
the Tile Space Limit.
What's the difference, exactly?
 
Is this compatible with BTS 3.13?
 
Echo of Shqype's question , 3.13 ?

This blended with Fanatic Demon's ranged bombardment work would make for a very interesting mod indeed.

The Total Realism boys had both these elements in their mod, but it seems this mod takes it up a level.
 
Thank you for this, very much what ive been looking for since i purchased the game a few weeks ago.

However, and its probably beaten to death somewhere on the forums but im blind.. how would i combine this with another mod, specifically, Rise of Mankind?

when all is said and done, im really just looking to place unit per tile limitations, with cities getting a few more for defense then normal tiles- i dont suppose there is an.. easy *cringe* way to do this?
 
Yes. Despite the damn hacker, I have a zip of the latest version of this mod. I am reuploading it now. :)
 
Alright, I took a little time and updated this to BtS v3.13.

I fixed a few typos and a few other things, but no real code changes. Just wanted to get it to 3.13 compatabilty.

New version is uploaded and linked in OP. :king:
 
In the UnitInfos you can also set Units to ignore the Tile Space Rules or just
the Tile Space Limit.
What's the difference, exactly?

Sorry its taken me so long to answer. I ran into some RL probs that keep me away for away and now that I'm back I haven't gotten around to reading all my mods' threads.

To answer your question.
UnitA
bIgnoreTileSpaceLimit = True

UnitA can move into any tile and won't check the Open Space of the tile. However its size will still use available space of the tile it is in, effecting what other units can move into its tile.

UnitA
bIgnoreTileSpaceRules = True

UnitA's size will not be calculated for any of the mod's code. Basicly the unit is ignored. If bIgnoreTileSpaceRules is True then bIgnoreTileSpaceLimit will also be return True.....
Or that is how it should work. After going back and looking at the code, I didn't acually code that bit in. I will fix that in the next version. :cool:

EDIT: After looking at the code more, that is not totally correct. You can't set units to ignore the Tile Space Rules per unit. A unit is Ignore Tile Space Rules if you set its Domain Type to be ignored in the GameDefinesAlt.xml. Sorry for the confusion, its been awhile since I wrote this mod. I will be adding a bIgnoreTileSpaceRules Tag to the UnitInfos in a future version.
 
Ok, one last thing, then I'm done for the night.

In the second post I added an attachment.
Its a zip of the beta of v0.680bts3.13. There is also a spoiler with the changes since v0.660.

Check it out, try and tear it apart in game and let me know what problems you find. :)
 
Anyone know how I could merge this with Civ Rev DCM?
 
Anyone know how I could merge this with Civ Rev DCM?

First, be able to compile a dll from the sdk.

Then, download WinMerge.

Procced to merge all the cpp and h files.

Compile and from there its all python/xml.
 
An update for those that are interested.

I'm just about done with the next stable release. I just finished adding a Tile Space Modifier to the Handicap Info xml file. I'm going to do some clean up of the code, add an API for the added python methods, set up a new test map, and I'm also going to merge jdog5000's AIAutoPlay code so I can run some test games and see how the AI handles my changes.

Anyway, give me another week and I'll have a stable version polished and ready to go.
 
Ok, I'm all done with all the main work of the mod. I've put in all the primary functionality I wanted in the mod and I've got jdog5000's AIAutoPlay SDK code merged with mine. I also have updated and expanded the readme file aswell as adding an API to document the python exposed methods I added.

I was logging on to upload this almost final version, but it seems the BtS v3.17 patch was just released, so I'm going to update to that before I upload.

I am a little swamped this weekend, so it will probly be next week some time.
 
Top Bottom