I figured some things out!
After doing some google searching for the phrase "civ iv changemoves", I found a Tutorial that discussed modifying CvMainInterface.py. In there is a function called "updateSelectionButtons" that has the following:
Using this as an example, I came up with:
I still don't understand other things though...
For example, when I run this, the currently selected unit's selection circle goes from green to yellow, showing the unit doesn't have 100% movement, but in the unit stats in the bottom-left, it still does. In other words, I have a Scout selected, he has 2/2 moves, I run the code, he still has 2/2 moves, but now his ring is yellow.
So, thinking it might be a percentage based thing, I increased the value to 49, and got the same effect. I increase the iChange value to 50, and it turns yellow. Just for kicks, I do it one more time, and it drops to 1/2. Do it a third time, and it drops to 0/2, and the ring turns red. So iChange = 50 x 3 = 0/2 moves? I try iChange = 150, and voila! It drops from 2/2 to 0/2. Well, that's solved...kind of. I tested some more values and here was the outcome:
125 = 0/2, red ring
101 = 1/2, yellow ring
110 = 1/2, yellow ring
120 = 0/2, red ring
115 = 1/2, yellow ring
So apparently, 120 move is required to drain -2 moves. I wonder if iChange = 60 per move? Will have to test with higher move units.
Also, I now need to insert this inside an Event that occurs after a unit has attacked, and it only needs to affect the attacker. What I'm going for here is I want all of the unit's moves to be consumed if it attacks, no matter how many moves it may have left.
I have the following 3 events to work with (I think?):
onCombatResult(), 'Combat Result'
onCombatLogCalc(), 'Combat Result'
onCombatLogHit(), 'Combat Message'
In the first one of those, the args are used for pWinner and pLoser. Nothing else in this function definition that I see indicates who the attacker is and who the defender is. Btw, this function has the baffling following conditional:
Which displays the message about one unit defeating another. How the heck...?
If playerX = true, and playerX = true (twice?), and unitX = true and playerY = true, a unit got defeated?
Anyway, the second event looks much more promising. As from my post above, it has:
So cdAttacker seems to be the unit I'm interested in, and I should try to figure out how to reduce all of its moves to 0. What is a 'cd' anyway? I know i = integer, b = boolean, p = pointer, l = list, but I haven't seen 'cd' until I looked at this function.
Again, any help is appreciated. In the meantime, I'm going to continue beating my face on this, and maybe I'll come back with another breakthrough and more questions.
After doing some google searching for the phrase "civ iv changemoves", I found a Tutorial that discussed modifying CvMainInterface.py. In there is a function called "updateSelectionButtons" that has the following:
Code:
global SELECTION_BUTTON_COLUMNS
global MAX_SELECTION_BUTTONS
global g_pSelectedUnit
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
pHeadSelectedCity = CyInterface().getHeadSelectedCity()
pHeadSelectedUnit = CyInterface().getHeadSelectedUnit()
Code:
def changeMoves():
global g_pUnit
# Test
g_pUnit = CyInterface().getHeadSelectedUnit()
g_pUnit.changeMoves(1)
I still don't understand other things though...
For example, when I run this, the currently selected unit's selection circle goes from green to yellow, showing the unit doesn't have 100% movement, but in the unit stats in the bottom-left, it still does. In other words, I have a Scout selected, he has 2/2 moves, I run the code, he still has 2/2 moves, but now his ring is yellow.
So, thinking it might be a percentage based thing, I increased the value to 49, and got the same effect. I increase the iChange value to 50, and it turns yellow. Just for kicks, I do it one more time, and it drops to 1/2. Do it a third time, and it drops to 0/2, and the ring turns red. So iChange = 50 x 3 = 0/2 moves? I try iChange = 150, and voila! It drops from 2/2 to 0/2. Well, that's solved...kind of. I tested some more values and here was the outcome:
125 = 0/2, red ring
101 = 1/2, yellow ring
110 = 1/2, yellow ring
120 = 0/2, red ring
115 = 1/2, yellow ring
So apparently, 120 move is required to drain -2 moves. I wonder if iChange = 60 per move? Will have to test with higher move units.
Also, I now need to insert this inside an Event that occurs after a unit has attacked, and it only needs to affect the attacker. What I'm going for here is I want all of the unit's moves to be consumed if it attacks, no matter how many moves it may have left.
I have the following 3 events to work with (I think?):
onCombatResult(), 'Combat Result'
onCombatLogCalc(), 'Combat Result'
onCombatLogHit(), 'Combat Message'
In the first one of those, the args are used for pWinner and pLoser. Nothing else in this function definition that I see indicates who the attacker is and who the defender is. Btw, this function has the baffling following conditional:
Code:
if playerX and playerX and unitX and playerY:
If playerX = true, and playerX = true (twice?), and unitX = true and playerY = true, a unit got defeated?

Anyway, the second event looks much more promising. As from my post above, it has:
Code:
def onCombatLogHit(self, argsList):
'Combat Message'
global gCombatMessages, gCombatLog
genericArgs = argsList[0][0]
cdAttacker = genericArgs[0]
cdDefender = genericArgs[1]
iIsAttacker = genericArgs[2]
So cdAttacker seems to be the unit I'm interested in, and I should try to figure out how to reduce all of its moves to 0. What is a 'cd' anyway? I know i = integer, b = boolean, p = pointer, l = list, but I haven't seen 'cd' until I looked at this function.
Again, any help is appreciated. In the meantime, I'm going to continue beating my face on this, and maybe I'll come back with another breakthrough and more questions.
