Ormand
Posts: 682
Joined: 2/17/2009 Status: offline
|
Back home (for a week at least). I think the overall comments for the first event, are appropriate for the second two as well. For the aircraft, you would have to check that the Loctype is a capitol, city, airfield or aircraft factory. So, instead of CHECK: CheckLocTypeXY(TempVar0, TempVar1) == -1 you would need to check that this equals, 0, 1, 9, or 10. This will set the area slot to 1 if it is one of these. And, it has to be otherwise, you won't be able to move it (except via strategic transfer). For the ships, you need to check the landscape type. In principle, you can place a ship in a city, but if it is not adjacent to water, it is stuck. Here, you only need to check the landscape type. I believe that you can't own sea hexes. This will set area slot 0 equal to 1 for all sea hexes.
' Pre Event Sea Placement
EXECUTE: ExecClearMatrix(0, 0)
SETVAR: TempVar11 = 0
SETVAR: TempVar12 = CheckMapWidth
SETVAR: TempVar21 = 0
SETVAR: TempVar22 = CheckMapHeight
LOOPER: TempVar0 FROM TempVar11 TO TempVar12
LOOPER: TempVar1 FROM TempVar21 TO TempVar22
CHECK: CheckLandscapeType(TempVar0, TempVar1) == 1
EXECUTE: ExecSetSlot(TempVar0, TempVar1, 0, 1)
END CHECK
END LOOPER
END LOOPER
This is probably overly broad, in that you could place a naval unit in any sea hex, anywhere. You could do something more restrictive. Say port cities. In this case, you would check if the hex is a capitol, city, port, or shipyard, check that the current player owns it, and then set the area slot. You can do this much more efficiently, however, by looping over all the locations on the map, instead of all the hexes. This is an event that will probably work. I haven't debugged it. The idea is to check the location types, see if they are owned by the current regime, with the same people. Then, check if the loctype is a capitol or city (if you want towns, you need to add another check right there). Then, determine if the capitol or city is adjacent to a sea or rainy sea hex. Do this by checking the six adjacent hexes. You could write a function to get the new hex, but here it is. If it is adjacent to a sea hex, then set TempVar20 to 1 (start with it set to zero). Then check if the loctype is a port or shipyard, and set TempVar20=1 (they should be adjacent by definition). Then, if TempVar20, put the value of 1 in slot #0 for this hex. Note that a few things are redundant, like lines 21 and 22. I used this block as a template for all six, so it was easier to have these things in and paste the whole block later. Obviously, if I add zero to x or y I don't need to check. But, since placing the ends can be confusing, it was just easier to do it this way. Also, obviously at line 131, I could skip the check on TempVar20 and just set the slot value equal to TempVar20 since it is either zero or one. But, I wanted to leave in an explicit check for you to see what is going on. 0) ' Get regime # and regime people 1) SETVAR: TempVar0 = CheckTurn 2) SETVAR: TempVar1 = CheckRegimePeople(TempVar0) 3) ' Clear matrix for slot #0 4) EXECUTE: ExecClearMatrix(0, 0) 5) ' Loop over all location types 6) LOOPER: TempVar10 FROM 0 TO CheckLocCounter 7) ' Get x & y coordinates 8) SETVAR: TempVar11 = CheckLocX(TempVar10) 9) SETVAR: TempVar12 = CheckLocX(TempVar10) 10) ' Check if owned by regime 11) CHECK: CheckHexOwner(TempVar11, TempVar12) == TempVar0 12) ' Initialize TempVar20 which we will use to see if location type is port 13) SETVAR: TempVar20 = 0 14) ' Check if location is capitol or city 15) CHECK: CheckLocTypeXY(TempVar11, TempVar12) == 0 16) CHECK: CheckLocTypeXY(TempVar11, TempVar12) == 1 17) ' Now check if any of the six adjacent hexes are sea 18) ' Check all six hexes 19) ' hex #1 =(x,y-1), make sure the hexes are on the map 20) SETVAR: TempVar111 = TempVar10 21) SETVAR: TempVar111 + 0 22) CHECK: TempVar111 => 0 23) SETVAR: TempVar112 = TempVar12 24) SETVAR: TempVar112 - 1 25) CHECK: TempVar112 => 0 26) ' Check if sea 27) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 28) ' Check if rainy sea 29) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 30) ' Is sea hex, so set TempVar20=1 31) SETVAR: TempVar20 = 1 32) END CHECK 33) END CHECK 34) END CHECK 35) END CHECK 36) ' hex #2 =(x+1,y-1), make sure the hexes are on the map 37) SETVAR: TempVar111 = TempVar10 38) SETVAR: TempVar111 + 1 39) CHECK: TempVar111 =< CheckMapWidth 40) SETVAR: TempVar112 = TempVar12 41) SETVAR: TempVar112 - 1 42) CHECK: TempVar112 => 0 43) ' Check if sea 44) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 45) ' Check if rainy sea 46) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 47) ' Is sea hex, so set TempVar20=1 48) SETVAR: TempVar20 = 1 49) END CHECK 50) END CHECK 51) END CHECK 52) END CHECK 53) ' hex #3 =(x+1,y), make sure the hexes are on the map 54) SETVAR: TempVar111 = TempVar10 55) SETVAR: TempVar111 + 1 56) CHECK: TempVar111 =< CheckMapWidth 57) SETVAR: TempVar112 = TempVar12 58) SETVAR: TempVar112 + 0 59) CHECK: TempVar112 => 0 60) ' Check if sea 61) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 62) ' Check if rainy sea 63) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 64) ' Is sea hex, so set TempVar20=1 65) SETVAR: TempVar20 = 1 66) END CHECK 67) END CHECK 68) END CHECK 69) END CHECK 70) ' hex #4 =(x,y+1), make sure the hexes are on the map 71) SETVAR: TempVar111 = TempVar10 72) SETVAR: TempVar111 + 0 73) CHECK: TempVar111 => 0 74) SETVAR: TempVar112 = TempVar12 75) SETVAR: TempVar112 + 1 76) CHECK: TempVar112 =< CheckMapHeight 77) ' Check if sea 78) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 79) ' Check if rainy sea 80) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 81) ' Is sea hex, so set TempVar20=1 82) SETVAR: TempVar20 = 1 83) END CHECK 84) END CHECK 85) END CHECK 86) END CHECK 87) ' hex #1 =(x-1,y), make sure the hexes are on the map 88) SETVAR: TempVar111 = TempVar10 89) SETVAR: TempVar111 - 1 90) CHECK: TempVar111 => 0 91) SETVAR: TempVar112 = TempVar12 92) SETVAR: TempVar112 + 0 93) CHECK: TempVar112 => 0 94) ' Check if sea 95) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 96) ' Check if rainy sea 97) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 98) ' Is sea hex, so set TempVar20=1 99) SETVAR: TempVar20 = 1 100) END CHECK 101) END CHECK 102) END CHECK 103) END CHECK 104) ' hex #6 =(x-1,y-1), make sure the hexes are on the map 105) SETVAR: TempVar111 = TempVar10 106) SETVAR: TempVar111 - 1 107) CHECK: TempVar111 => 0 108) SETVAR: TempVar112 = TempVar12 109) SETVAR: TempVar112 - 1 110) CHECK: TempVar112 => 0 111) ' Check if sea 112) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 1 113) ' Check if rainy sea 114) CHECK: CheckLandscapeType(TempVar111, TempVar112) == 49 115) ' Is sea hex, so set TempVar20=1 116) SETVAR: TempVar20 = 1 117) END CHECK 118) END CHECK 119) END CHECK 120) END CHECK 121) ' Finished checking if Capitol or cities are ports 122) ' Now check if loctype is port or shipyard 123) CHECK: CheckLocTypeXY(TempVar11, TempVar12) == 8 124) CHECK: CheckLocTypeXY(TempVar11, TempVar12) == 13 125) ' They are so, set TempVar20 = 1 126) SETVAR: TempVar20 = 1 127) END CHECK 128) END CHECK 129) ' Now set slot#0 for this hex equal to 1 130) CHECK: TempVar20 == 1 131) EXECUTE: ExecSetSlot(TempVar11, TempVar12, 0, TempVar20) 132) END CHECK 133) END CHECK 134) END CHECK 135) END CHECK 136) END LOOPER
< Message edited by Ormand -- 10/17/2015 8:47:01 PM >
|