Adding Global Unit Limit

Sifaus

Adramelech
Joined
Mar 9, 2007
Messages
259
Hello.

I want to add global unit limit to the Dune Wars mod. I ask this, they directed me to this thread. But after that, i couldn't do anything with my non-existent python knowledge.

Can anybody help me with this? :)

Thanks.
 
I can't be of much help on the technical side, but if your concern is one of performance (basically; having so many units that the game slows dramatically or crashes) then I'd mostly suggest playing smaller maps with fewer factions. A hardcoded cap might make the game play very strangely.
 
My concern is stacks of doom. ^^ I love more less units and tactical combat. Yep, it might be strange against AI but i think about this for multiplayer games.

I see Master of Mana using this thing and it was awesome. But i don't know if they coded an AI for this.
 
I dunno, for multiplayer it sounds like it would set up really nasty snowballing problems, where I kill a bunch of your units, which reduces the global number of units, then instantly purchase my own through Dune Wars' offworld purchase mechanism, and now you have a smaller army than me and can't build any more units with which to fight off my army.
 
Solution (based on 1.9.7):
1) Edit "Beyond the Sword\Mods\Dune Wars\Assets\Python\DuneWars.py"
find function cannotTrain (looks as below):
def cannotTrain(self, pCity, iUnitType):
self.Initialize()
if iUnitType == self.iUSpwork:
pPlay = gc.getPlayer(pCity.getOwner())
if pPlay.getCivics(self.iCArrak) != self.iCSpind:
return true

and edit the function body to:
def cannotTrain(self, pCity, iUnitType):
self.Initialize()
if iUnitType == self.iUSpwork:
pPlay = gc.getPlayer(pCity.getOwner())
if pPlay.getCivics(self.iCArrak) != self.iCSpind:
return true

pPlayer = gc.getPlayer(pCity.getOwner())
iUnitPerCity = 2
iUnitPerPopulation = 0.25
iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
iPopulationUnitLimit = pPlayer.getNumCities() * iUnitPerCity + int(pPlayer.getTotalPopulation() * iUnitPerPopulation)
return iNumMilitaryUnits >= iPopulationUnitLimit

2) if you wish to see total units out of total allowed, edit
"Beyond the Sword\Mods\Dune Wars\Assets\Python\Screens\CvMainInterface.py"
I've just added it to the clock. Find "def updateTimeText( self ):"
In the function definition find the g_szTimeText = ""
Just add these lines right after it:
bShowGameTurn = false
pPlayer = gc.getActivePlayer()
iUnitPerCity = 2
iUnitPerPopulation = 0.25
iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
iPopulationUnitLimit = pPlayer.getNumCities() * iUnitPerCity + int(pPlayer.getTotalPopulation() * iUnitPerPopulation)
g_szTimeText += u"(%d" %( pPlayer.getNumMilitaryUnits() )
g_szTimeText += u"/%d) " %( iPopulationUnitLimit )

Note: limit in the case above is "Number of Cities" * 2 + TotalPopulation*0.25. I was considering early game when population is very low (so just number of cities *2) + late game, when population is 100+. Feel free to play with values as see fit.

Note: you may want to disable something in the updateTimeText, or it won't fit.
mind the "tabs" in the edited file - the indents are important in python :) For some reason tabs in my post got cleared.

Note: I've been looking for something akin max unit per tile or global unit limit option for dune wars for some time. In the end decided to just see if i can edit it in myself (won't lie, got hints from other posts). Awesome mod, that I haven't played for a few years, but decided to play it again. Got used to 1 UPT in CivV, and, to tell the truth, I always hated stacks of doom in Civ4, but so much more after playing CivV.
 
Top Bottom