Macros/Leveling
< Macros
//version 6
constants
//Game States
CurrentGameState = 0 //main state variable
StateMap = 1
StateCombat = 2
StateVictory = 3
StateLoss = 4
StateOurTurn = 5
StateUnitAttack = 6
//states for units
//State 0 = No Unit
UnitAttack = 1
UnitDefend = 2
UnitWait = 3
UnitOther = 4
//Unit variables
Unit1Action = 0
Unit2Action = 0
Unit3Action = 0
Unit4Action = 0
Unit5Action = 0
Unit6Action = 0
Unit7Action = 0
CurrentUnit = 0
UnitIdleCount = 0
//Random variables for computation
CheckX = 0
CheckFlag = 0
UnitFoundFlag = 0
end
procedure GetGameState
//checking for brown on level number area of character portrain
LoadRGB 50, 100
if {RGBRed} < 50 and {RGBGreen} < 40 and {RGBBlue} < 20
compute CurrentGameState = $StateMap
end
//checking for default eye in upper right
//px =1012,32
//140,186,0
if $CurrentGameState <> $StateOurTurn
LoadRGB 1012, 32
if {RGBRed} > 120 and {RGBRed} < 160 and {RGBGreen} > 159 and {RGBGreen} < 203 and {RGBBlue} < 50
compute CurrentGameState = $StateCombat
end
end
//checking for combat victory screen
//checks the X and the +
//px of X = 818,155
//color of X = 214,186,123
//px of + = 502,361
//color of + = 231,142,57
LoadRGB 818,155 // X
if {RGBRed} > 210 and {RGBRed} < 220 and {RGBGreen} > 180 and {RGBGreen} < 190 and {RGBBlue} > 120 and {RGBBlue} < 130
LoadRGB 502,361 // +
if {RGBRed} > 228 and {RGBRed} < 235 and {RGBGreen} > 138 and {RGBGreen} < 146 and {RGBBlue} > 53 and {RGBBlue} < 63
compute CurrentGameState = $StateVictory
end
end
if $CurrentGameState = $StateVictory
//soul bar height = 313
//start x = 174
//end x = 824
Compute CheckX = 174
Compute CheckFlag = 0
LoadRGB 203,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 297,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 393,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 487,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 582,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 677,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
LoadRGB 772,315
if {RGBRed} > 240 and {RGBGreen} > 240 and {RGBBlue} > 240
Compute CheckFlag = 1
end
if $CheckFlag = 1
compute CurrentGameState = $StateLoss
end
end
end
procedure ClickSlow
MousePos 526, 760
delay 100
LeftClick
end
procedure ClickAttack
MousePos 823, 763
delay 100
LeftClick
delay 1 sec
MousePos 823, 763
delay 100
LeftClick
end
procedure ClickDefend
MousePos 868, 766
delay 100
LeftClick
delay 1 sec
end
procedure ClickWait
MousePos 910, 766
delay 100
LeftClick
delay 1 sec
end
procedure ClickEndTurn
MousePos 869, 588
delay 100
LeftClick
end
procedure ClickAcceptBattleResult
MousePos 536, 541
delay 100
LeftClick
end
procedure ClickCameraAngle3
MousePos 987, 34
delay 100
LeftClick
end
procedure ClickCameraShrink
MousePos 923, 33
delay 100
LeftClick
end
procedure ClickMarch
MousePos 820, 589
delay 100
LeftClick
end
procedure InitilizeUnitActions
compute Unit1Action = $UnitAttack
compute Unit2Action = $UnitAttack
compute Unit3Action = $UnitAttack
compute Unit4Action = $UnitAttack
compute Unit5Action = $UnitAttack
compute Unit6Action = $UnitAttack
compute Unit7Action = $UnitOther
end
procedure DoMapState When $CurrentGameState = $StateMap
//194,53 mana bar
//13,80,123
compute CheckFlag = 1
compute CheckX = 0
while $CheckFlag = 1
loadrgb 194,53
if {RGBRed} < 25 and {RGBGreen} > 70 and {RGBGreen} < 90 and {RGBBlue} > 115 and {RGBBlue} < 135
if $CheckX > 3
compute CheckFlag = 0
end
end
call GetGameState
if $CurrentGameState <> $StateMap
compute CheckFlag = 0
end
compute CheckX = $CheckX + 1
call ClickEndTurn
delay 500
end
delay 3 sec
call ClickMarch
delay 6 sec
end
procedure CheckUnit Using StartX,StartY,UnitID
if $UnitFoundFlag = 0
LoadRGB $StartX,$StartY
if {RGBRed} > 240 and {RGBRed} < 255 and {RGBGreen} > 168 and {RGBGreen} < 196 and {RGBBlue} > 0 and {RGBBlue} < 20
compute CurrentUnit = $UnitID
compute UnitFoundFlag = 1
end
end
end
procedure OurTurnState When $CurrentGameState = $StateOurTurn
compute CurrentUnit = 0
if $UnitIdleCount = 0
call ClickCameraAngle3
end
//check unit statuses
//rgb = 250,181,5
compute UnitIdleCount = $UnitIdleCount + 1
compute UnitFoundFlag = 0
//unit 1 = 162,28
call CheckUnit 162,28,1
//unit 2 = 189,118
call CheckUnit 189,118,2
//unit 3 = 130,248
call CheckUnit 130,248,3
//unit 4 = 153,383
call CheckUnit 153,383,4
//unit 5 = 179,477
call CheckUnit 150,477,5
//unit 6 = 172,570
call CheckUnit 148,570,6
//unit 7 = 145,662
call CheckUnit 174,662,7
//idle/error handler
if $UnitIdleCount > 10
compute CurrentUnit = 99
end
compute CurrentGameState = $StateUnitAttack
ProcessMessages
call GetGameState
if $CurrentGameState <> $StateVictory
if $CurrentGameState <> $StateLoss
compute CurrentGameState = $StateOurTurn
end
end
//must set no unit as active before processing messages
compute CurrentUnit = 0
ProcessMessages
end
procedure DoBattleState When $CurrentGameState = $StateCombat
//set the camera angle
call ClickCameraAngle3
delay 1 sec
loop 6
call ClickCameraShrink
end
compute CurrentGameState = $StateOurTurn
compute UnitIdleCount = 0
ProcessMessages
end
procedure DoErrorState When $CurrentGameState = $StateLoss
bell Exclamation
delay 5 sec
Call GetGameState
ProcessMessages
end
procedure DoVictoryState When $CurrentGameState = $StateVictory
if $CurrentGameState = $StateLoss
ProcessMessages
else
call ClickAcceptBattleResult
end
delay 2 sec
Call GetGameState
end
//unit functions
procedure DoUnit1Action When $CurrentUnit = 1
if $Unit1Action = $UnitAttack
call ClickAttack
end
if $Unit1Action = $UnitDefend
call ClickDefend
end
if $Unit1Action = $UnitWait
call ClickWait
end
if $Unit1Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit2Action When $CurrentUnit = 2
if $Unit2Action = $UnitAttack
call ClickAttack
end
if $Unit2Action = $UnitDefend
call ClickDefend
end
if $Unit2Action = $UnitWait
call ClickWait
end
if $Unit2Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit3Action When $CurrentUnit = 3
if $Unit3Action = $UnitAttack
call ClickAttack
end
if $Unit3Action = $UnitDefend
call ClickDefend
end
if $Unit3Action = $UnitWait
call ClickWait
end
if $Unit3Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit4Action When $CurrentUnit = 4
if $Unit4Action = $UnitAttack
call ClickAttack
end
if $Unit4Action = $UnitDefend
call ClickDefend
end
if $Unit4Action = $UnitWait
call ClickWait
end
if $Unit4Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit5Action When $CurrentUnit = 5
if $Unit5Action = $UnitAttack
call ClickAttack
end
if $Unit5Action = $UnitDefend
call ClickDefend
end
if $Unit5Action = $UnitWait
call ClickWait
end
if $Unit5Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit6Action When $CurrentUnit = 6
if $Unit6Action = $UnitAttack
call ClickAttack
end
if $Unit6Action = $UnitDefend
call ClickDefend
end
if $Unit6Action = $UnitWait
call ClickWait
end
if $Unit6Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnit7Action When $CurrentUnit = 7
if $Unit7Action = $UnitAttack
call ClickAttack
end
if $Unit7Action = $UnitDefend
call ClickDefend
end
if $Unit7Action = $UnitWait
call ClickWait
end
if $Unit7Action = $UnitOther
call ClickSlow
delay 500
call ClickDefend
end
compute UnitIdleCount = 0
end
procedure DoUnitIdleAction When $CurrentUnit = 99
//Idle Unit Handler
call ClickAttack
compute UnitIdleCount = 0
end
//main macro code here
call InitilizeUnitActions
//main loop
While 1 = 1
ProcessMessages
Call GetGameState
End
//end main macro code