Zindar
Mar 30, 2007, 03:48 PM
While playing civ I had two minor problems:
what should I use my scouts to, after reveling the whole map
while building my large armies, there was a lot of mouse action to move them into place
So, reading talchas Action Button MOD I found a simple solution. If you have a scout unit then all other units will display a "Goto the flag" button. When pressed the unit will automaticly move to the scout unit plot.
The interesting bit of code is in CvActionButtonsGameUtils.py It will show how to add a GOTO mission to a player unit (SelectionGroup).
def moveUnitToFlagScout(unit):
iScoutType = gc.getInfoTypeForString("UNIT_SCOUT")
# find first scout unit
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
while (loopUnit):
if (loopUnit.getUnitType() == iScoutType) and unit.canMoveThrough(loopUnit.plot()):
break
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
# move whole selectiongroup to scout if found
if ((not type(loopUnit) is NoneType) and (not loopUnit.isNone())):
unit.getGroup().pushMission(MissionTypes.MISSION_M OVE_TO, loopUnit.getX(), loopUnit.getY(), 0, False, False, MissionAITypes.NO_MISSIONAI, unit.plot(), unit)
goFlag = ActionButtons.ActionButton("Art/Interface/Buttons/gotoflag.dds", moveUnitToFlagScout)
def buttons(unit):
iScoutType = gc.getInfoTypeForString("UNIT_SCOUT")
# no sence with goFlag for boats and confusing with scouts
if (unit.getUnitType() == iScoutType) or (unit.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
return []
# enable (return) goFlag button only if any scout unit found among player units
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
while (loopUnit):
if (loopUnit.getUnitType() == iScoutType) and unit.canMoveThrough(loopUnit.plot()):
return [goFlag]
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
return []
The rest is no different from the Action Button MOD. The zip-file includes button graphics (although I'm no Picasso ;) ) and complete MOD working for the v1.61 patch. Unzip in your my document's\my games\sid... folder as usual.
I choosed Python instead of C++/SDK, but those modding at that level shouldn't have any problems with porting. As always when coding more ideas came along...
I'we stopped naval units but what about airplanes?
How should multiple scouts be handled?
What if my scout dies in late 1970's, should the action belong to UNITCOMBAT_RECON instead?
Maybe this should be done with some "Army Flag" promotion?
Here's some sample code (not complete) for the promotion version, but personally I think I'll stick with the scout version.
def moveUnitToFlagPromotion(unit):
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
iFlagPromotion = gc.getInfoTypeForString('PROMOTION_WOODSMAN1')
while (loopUnit):
if (loopUnit.isHasPromotion(iFlagPromotion) and unit.canMoveThrough(loopUnit.plot())):
break
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
Cheat & balancing issues: none, the AI doesn't have a mouse and the purpose is to enhance the game interface nothing more.
what should I use my scouts to, after reveling the whole map
while building my large armies, there was a lot of mouse action to move them into place
So, reading talchas Action Button MOD I found a simple solution. If you have a scout unit then all other units will display a "Goto the flag" button. When pressed the unit will automaticly move to the scout unit plot.
The interesting bit of code is in CvActionButtonsGameUtils.py It will show how to add a GOTO mission to a player unit (SelectionGroup).
def moveUnitToFlagScout(unit):
iScoutType = gc.getInfoTypeForString("UNIT_SCOUT")
# find first scout unit
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
while (loopUnit):
if (loopUnit.getUnitType() == iScoutType) and unit.canMoveThrough(loopUnit.plot()):
break
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
# move whole selectiongroup to scout if found
if ((not type(loopUnit) is NoneType) and (not loopUnit.isNone())):
unit.getGroup().pushMission(MissionTypes.MISSION_M OVE_TO, loopUnit.getX(), loopUnit.getY(), 0, False, False, MissionAITypes.NO_MISSIONAI, unit.plot(), unit)
goFlag = ActionButtons.ActionButton("Art/Interface/Buttons/gotoflag.dds", moveUnitToFlagScout)
def buttons(unit):
iScoutType = gc.getInfoTypeForString("UNIT_SCOUT")
# no sence with goFlag for boats and confusing with scouts
if (unit.getUnitType() == iScoutType) or (unit.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
return []
# enable (return) goFlag button only if any scout unit found among player units
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
while (loopUnit):
if (loopUnit.getUnitType() == iScoutType) and unit.canMoveThrough(loopUnit.plot()):
return [goFlag]
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
return []
The rest is no different from the Action Button MOD. The zip-file includes button graphics (although I'm no Picasso ;) ) and complete MOD working for the v1.61 patch. Unzip in your my document's\my games\sid... folder as usual.
I choosed Python instead of C++/SDK, but those modding at that level shouldn't have any problems with porting. As always when coding more ideas came along...
I'we stopped naval units but what about airplanes?
How should multiple scouts be handled?
What if my scout dies in late 1970's, should the action belong to UNITCOMBAT_RECON instead?
Maybe this should be done with some "Army Flag" promotion?
Here's some sample code (not complete) for the promotion version, but personally I think I'll stick with the scout version.
def moveUnitToFlagPromotion(unit):
(loopUnit, iter) = gc.getActivePlayer().firstUnit(false)
iFlagPromotion = gc.getInfoTypeForString('PROMOTION_WOODSMAN1')
while (loopUnit):
if (loopUnit.isHasPromotion(iFlagPromotion) and unit.canMoveThrough(loopUnit.plot())):
break
(loopUnit, iter) = gc.getActivePlayer().nextUnit(iter, false)
Cheat & balancing issues: none, the AI doesn't have a mouse and the purpose is to enhance the game interface nothing more.