Captain Cruft
Posts: 3652
Joined: 3/17/2004 From: England Status: offline
|
Automated Rail Conversion This is another critical path item. Playing WitE it gets utterly tedious having to manually convert rail hexes every turn. Having it automated also means you don't have to clutter up the map with lots of non-combat engineering units. I thought this might be impossible. It certainly was tricky. However to my surprise I have come up with some code which works pretty well. When entering enemy territory each side will get its own rail network extended by a minimum of 2 hexes and maximum of 4 hexes per map row, without player intervention. The code is presented below, if you're really keen. The other thing I want to treat in a similar manner is Partisan effects. However that will need a full OOB on the map to test properly, so I am leaving it for now. quote:
0) ' Germany 1) CHECK: CheckTurn == 0 2) ' Change all SO Rail in GE territory 3) ' Scan map 4 times (east to west) with decreasing chance of conversion each time 4) LOOPER: TempVar99 FROM 1 TO 4 5) LOOPER: TempVar13 FROM 4 TO 187 6) LOOPER: TempVar1 FROM 0 TO 140 7) SETVAR: TempVar0 = 191 8) SETVAR: TempVar0 - TempVar13 9) CHECK: CheckHexOwner(TempVar0, TempVar1) == 0 10) CHECK: CheckRoadType(TempVar0, TempVar1, -1) == 1 11) ' Check adjacent hexes for home rail type 12) SETVAR: TempVar9 = 0 13) SETVAR: TempVar2 = TempVar0 14) SETVAR: TempVar2 + 1 15) SETVAR: TempVar3 = TempVar0 16) SETVAR: TempVar3 - 1 17) SETVAR: TempVar4 = TempVar1 18) SETVAR: TempVar4 + 1 19) SETVAR: TempVar5 = TempVar1 20) SETVAR: TempVar5 - 1 21) CHECK: CheckRoadType(TempVar3, TempVar1, -1) == 0 22) SETVAR: TempVar9 = 1 23) END CHECK 24) CHECK: CheckRoadType(TempVar3, TempVar4, -1) == 0 25) SETVAR: TempVar9 = 1 26) END CHECK 27) CHECK: CheckRoadType(TempVar0, TempVar4, -1) == 0 28) SETVAR: TempVar9 = 1 29) END CHECK 30) CHECK: CheckRoadType(TempVar2, TempVar4, -1) == 0 31) SETVAR: TempVar9 = 1 32) END CHECK 33) CHECK: CheckRoadType(TempVar2, TempVar1, -1) == 0 34) SETVAR: TempVar9 = 1 35) END CHECK 36) CHECK: CheckRoadType(TempVar0, TempVar5, -1) == 0 37) SETVAR: TempVar9 = 1 38) END CHECK 39) CHECK: TempVar9 == 1 40) CHECK: TempVar99 == 1 41) SETVAR: TempVar33 = 100 42) END CHECK 43) CHECK: TempVar99 == 2 44) SETVAR: TempVar33 = 100 45) END CHECK 46) CHECK: TempVar99 == 3 47) SETVAR: TempVar33 = 80 48) END CHECK 49) CHECK: TempVar99 == 4 50) SETVAR: TempVar33 = 50 51) END CHECK 52) CHECK: CheckRandomPercent =< TempVar33 53) EXECUTE: ExecChangeRoad(TempVar0, TempVar1, 1, 0) 54) END CHECK 55) END CHECK 56) END CHECK 57) END CHECK 58) ' Change movement rulevars 59) EXECUTE: ExecSetRuleVar(2, 15, 0) 60) EXECUTE: ExecSetRuleVar(32, 0, 0) 61) EXECUTE: ExecSetRuleVar(99, 17, 0) 62) END LOOPER 63) END LOOPER 64) END LOOPER 65) END CHECK 66) ' Soviet Union 67) CHECK: CheckTurn == 1 68) ' Change all GE Rail in SO territory 69) ' Scan map 4 times (west to east) with decreasing chance of conversion each time 70) LOOPER: TempVar99 FROM 1 TO 4 71) LOOPER: TempVar0 FROM 4 TO 187 72) LOOPER: TempVar1 FROM 0 TO 140 73) CHECK: CheckHexOwner(TempVar0, TempVar1) == 1 74) CHECK: CheckRoadType(TempVar0, TempVar1, -1) == 0 75) ' Check adjacent hexes for home rail type 76) SETVAR: TempVar9 = 0 77) SETVAR: TempVar2 = TempVar0 78) SETVAR: TempVar2 + 1 79) SETVAR: TempVar3 = TempVar0 80) SETVAR: TempVar3 - 1 81) SETVAR: TempVar4 = TempVar1 82) SETVAR: TempVar4 + 1 83) SETVAR: TempVar5 = TempVar1 84) SETVAR: TempVar5 - 1 85) CHECK: CheckRoadType(TempVar3, TempVar1, -1) == 1 86) SETVAR: TempVar9 = 1 87) END CHECK 88) CHECK: CheckRoadType(TempVar3, TempVar4, -1) == 1 89) SETVAR: TempVar9 = 1 90) END CHECK 91) CHECK: CheckRoadType(TempVar0, TempVar4, -1) == 1 92) SETVAR: TempVar9 = 1 93) END CHECK 94) CHECK: CheckRoadType(TempVar2, TempVar4, -1) == 1 95) SETVAR: TempVar9 = 1 96) END CHECK 97) CHECK: CheckRoadType(TempVar2, TempVar1, -1) == 1 98) SETVAR: TempVar9 = 1 99) END CHECK 100) CHECK: CheckRoadType(TempVar0, TempVar5, -1) == 1 101) SETVAR: TempVar9 = 1 102) END CHECK 103) CHECK: TempVar9 == 1 104) CHECK: TempVar99 == 1 105) SETVAR: TempVar33 = 100 106) END CHECK 107) CHECK: TempVar99 == 2 108) SETVAR: TempVar33 = 100 109) END CHECK 110) CHECK: TempVar99 == 3 111) SETVAR: TempVar33 = 80 112) END CHECK 113) CHECK: TempVar99 == 4 114) SETVAR: TempVar33 = 50 115) END CHECK 116) CHECK: CheckRandomPercent =< TempVar33 117) EXECUTE: ExecChangeRoad(TempVar0, TempVar1, 0, 1) 118) END CHECK 119) END CHECK 120) END CHECK 121) END CHECK 122) ' Change movement rulevars 123) EXECUTE: ExecSetRuleVar(2, 16, 0) 124) EXECUTE: ExecSetRuleVar(32, 1, 0) 125) EXECUTE: ExecSetRuleVar(99, 18, 0) 126) END LOOPER 127) END LOOPER 128) END LOOPER 129) END CHECK
< Message edited by Captain Cruft -- 11/28/2013 12:28:54 AM >
|