Flintlock1415
Emperor
Hi all, I'm trying to add a route restrictor to my train unit for my mod, but I'm having some trouble. I'm trying to just do it through CvGameUtils.py; modelling it on Zebra 9's modcomp. This mod is for Colonization, so I can't use the mod outright, and I don't really need to have ini configuring.
I don't exactly what to use to define my unit, (I think its iUnit?) nor the route. (Again I'm thinking iUnit, but what does in range do?)
I also don't understand what to make the route/unit do to tell the game what's true.
Here is as far as I got without completely screwing things up:
And here's Zebra 9's code:
Thanks for help in advance!
I don't exactly what to use to define my unit, (I think its iUnit?) nor the route. (Again I'm thinking iUnit, but what does in range do?)
I also don't understand what to make the route/unit do to tell the game what's true.
Here is as far as I got without completely screwing things up:
PHP:
def unitCannotMoveInto(self,argsList):
ePlayer = argsList[0]
iUnitId = argsList[1]
iPlotX = argsList[2]
iPlotY = argsList[3]
## Locomotive Route Restriction
pPlot = CyMap().plot(iPlotX, iPlotY)
iUnit = gc.getInfotypeForString ( "UNIT_TRAIN" )
iRoute = gc.getInfotypeForString ( "ROUTE_ROAD" )
for iRoute
if iUnit
## End Edit
return False
PHP:
def unitCannotMoveInto(self,argsList):
ePlayer = argsList[0]
iUnitId = argsList[1]
iPlotX = argsList[2]
iPlotY = argsList[3]
## Edited by Zebra 9
pPlot = CyMap().plot(iPlotX, iPlotY)
pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
szUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType()
szUnitClassType = gc.getUnitInfo(pUnit.getUnitType()).getXmlVal()
for iRoute in range(gc.getNumRouteInfos()):
if pConfig.getboolean(szUnitType, gc.getRouteInfo(iRoute).getType(), False):
if pPlot.getRouteType() != iRoute:
return True
for iRoute in range(gc.getNumRouteInfos()):
if pConfig.getboolean(szUnitClassType, gc.getRouteInfo(iRoute).getType(), False):
if pPlot.getRouteType() != iRoute:
return True
## End Edit
return False