1 | cellDoorOpened = false |
---|
2 | walkinCellFinished = false |
---|
3 | cellExitReached = false |
---|
4 | exitReached = false |
---|
5 | hangarReached = false |
---|
6 | spaceShipReached = false |
---|
7 | spaceShipEntered = false |
---|
8 | playerInLock = false |
---|
9 | |
---|
10 | randTime = 0 |
---|
11 | |
---|
12 | function observeGuard() |
---|
13 | guardX = guard:getAbsCoorX() |
---|
14 | guardY = guard:getAbsCoorY() |
---|
15 | guardZ = guard:getAbsCoorZ() |
---|
16 | |
---|
17 | if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then |
---|
18 | cellDoorOpened = true |
---|
19 | end |
---|
20 | |
---|
21 | end |
---|
22 | |
---|
23 | function observePlayer() |
---|
24 | playerX = Player:getAbsCoorX() |
---|
25 | playerY = Player:getAbsCoorY() |
---|
26 | playerZ = Player:getAbsCoorZ() |
---|
27 | |
---|
28 | if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then |
---|
29 | playerInLock = true |
---|
30 | end |
---|
31 | |
---|
32 | walkProgrammed = false |
---|
33 | exitProgrammed = false |
---|
34 | function walkInCell(timestep) |
---|
35 | |
---|
36 | if not walkProgrammed then |
---|
37 | --io.write("Guard called \n") |
---|
38 | prisoner:walkTo(-132, 29, 238.381805) |
---|
39 | prisoner:walkTo(-138.41, 29, 275.25) |
---|
40 | prisoner:walkTo(-143.70, 29, 275.35) |
---|
41 | prisoner:walkTo(-149.10, 29, 226.66) |
---|
42 | prisoner:walkTo(-149.10, 29, 196.83) |
---|
43 | prisoner:walkTo(-145.82, 29, 189.74) |
---|
44 | prisoner:walkTo(-138.48, 29, 184.28) |
---|
45 | prisoner:walkTo(35.48, 29, 191.28) |
---|
46 | prisoner:runTo(102, 29, 203.28) |
---|
47 | prisoner:runTo(164, 29, 245.28) |
---|
48 | |
---|
49 | walkProgrammed = true |
---|
50 | end |
---|
51 | |
---|
52 | if cellDoorOpened then |
---|
53 | |
---|
54 | if randTime == 0 then |
---|
55 | randTime = 30 * math.random() |
---|
56 | else |
---|
57 | randTime = randTime - timestep |
---|
58 | end |
---|
59 | |
---|
60 | if randTime < 0 then |
---|
61 | -- goto cellexit |
---|
62 | if not exitProgrammed then |
---|
63 | prisoner:walkTo(-132, 29, 238.381805) |
---|
64 | prisoner:walkTo(-138.41, 29, 275.25) |
---|
65 | prisoner:walkTo(-143.70, 29, 275.35) |
---|
66 | prisoner:walkTo(-149.10, 29, 226.66) |
---|
67 | prisoner:walkTo(-149.10, 29, 196.83) |
---|
68 | prisoner:walkTo(-145.82, 29, 189.74) |
---|
69 | prisoner:walkTo(-138.48, 29, 184.28) |
---|
70 | prisoner:walkTo(35.48, 29, 191.28) |
---|
71 | prisoner:runTo(102, 29, 203.28) |
---|
72 | prisoner:runTo(164, 29, 245.28) |
---|
73 | |
---|
74 | exitProgrammed = true |
---|
75 | end |
---|
76 | |
---|
77 | if guard:finalGoalReached() then |
---|
78 | return true |
---|
79 | end |
---|
80 | |
---|
81 | end |
---|
82 | |
---|
83 | return false |
---|
84 | end |
---|
85 | |
---|
86 | |
---|
87 | return false |
---|
88 | |
---|
89 | end |
---|
90 | |
---|
91 | |
---|
92 | gotoExitProgrammed = false |
---|
93 | function goToExit(timestep) |
---|
94 | -- do not forget to make him wait until the player triggeres the trip to the hangar |
---|
95 | if not gotoExitProgrammed and playerInLock then |
---|
96 | prisoner:walkTo(-132, 29, 238.381805) |
---|
97 | prisoner:walkTo(-138.41, 29, 275.25) |
---|
98 | prisoner:walkTo(-143.70, 29, 275.35) |
---|
99 | prisoner:walkTo(-149.10, 29, 226.66) |
---|
100 | prisoner:walkTo(-149.10, 29, 196.83) |
---|
101 | prisoner:walkTo(-145.82, 29, 189.74) |
---|
102 | prisoner:walkTo(-138.48, 29, 184.28) |
---|
103 | prisoner:walkTo(35.48, 29, 191.28) |
---|
104 | prisoner:runTo(102, 29, 203.28) |
---|
105 | prisoner:runTo(164, 29, 245.28) |
---|
106 | |
---|
107 | gotoExitProgrammed = true |
---|
108 | end |
---|
109 | |
---|
110 | if prisoner:finalGoalReached() then |
---|
111 | return true |
---|
112 | end |
---|
113 | |
---|
114 | return false |
---|
115 | end |
---|
116 | |
---|
117 | hangarRouteProgrammed = false |
---|
118 | function goToHangar(timestep) |
---|
119 | |
---|
120 | if not hangarRouteProgrammed then |
---|
121 | prisoner:walkTo(-132, 29, 238.381805) |
---|
122 | prisoner:walkTo(-138.41, 29, 275.25) |
---|
123 | prisoner:walkTo(-143.70, 29, 275.35) |
---|
124 | prisoner:walkTo(-149.10, 29, 226.66) |
---|
125 | prisoner:walkTo(-149.10, 29, 196.83) |
---|
126 | prisoner:walkTo(-145.82, 29, 189.74) |
---|
127 | prisoner:walkTo(-138.48, 29, 184.28) |
---|
128 | prisoner:walkTo(35.48, 29, 191.28) |
---|
129 | prisoner:runTo(102, 29, 203.28) |
---|
130 | prisoner:runTo(164, 29, 245.28) |
---|
131 | |
---|
132 | hangarRouteProgrammed = true |
---|
133 | end |
---|
134 | |
---|
135 | if prisoner:finalGoalReached() then |
---|
136 | return true |
---|
137 | end |
---|
138 | |
---|
139 | return false |
---|
140 | |
---|
141 | end |
---|
142 | |
---|
143 | spaceshipRouteProgrammed = false |
---|
144 | function goToSpaceship(timestep) |
---|
145 | |
---|
146 | if not spaceshipRouteProgrammed then |
---|
147 | prisoner:walkTo(-132, 29, 238.381805) |
---|
148 | prisoner:walkTo(-138.41, 29, 275.25) |
---|
149 | prisoner:walkTo(-143.70, 29, 275.35) |
---|
150 | prisoner:walkTo(-149.10, 29, 226.66) |
---|
151 | prisoner:walkTo(-149.10, 29, 196.83) |
---|
152 | prisoner:walkTo(-145.82, 29, 189.74) |
---|
153 | prisoner:walkTo(-138.48, 29, 184.28) |
---|
154 | prisoner:walkTo(35.48, 29, 191.28) |
---|
155 | prisoner:runTo(102, 29, 203.28) |
---|
156 | prisoner:runTo(164, 29, 245.28) |
---|
157 | |
---|
158 | spaceshipRouteProgrammed = true |
---|
159 | end |
---|
160 | |
---|
161 | if prisoner:finalGoalReached() then |
---|
162 | return true |
---|
163 | end |
---|
164 | |
---|
165 | return false |
---|
166 | |
---|
167 | end |
---|
168 | |
---|
169 | |
---|
170 | function enterSpaceship(timestep) |
---|
171 | |
---|
172 | return false |
---|
173 | end |
---|
174 | |
---|
175 | |
---|
176 | |
---|
177 | function tick(timestep) |
---|
178 | |
---|
179 | --io.write("Prisoner called \n") |
---|
180 | |
---|
181 | observeGuard() |
---|
182 | observePlayer() |
---|
183 | |
---|
184 | |
---|
185 | if not cellDoorOpend then |
---|
186 | walkinCellFinished = walkInCell(timestep) |
---|
187 | end |
---|
188 | |
---|
189 | if walkinCellFinished and not exitReached then |
---|
190 | exitReached = goToExit(timestep) |
---|
191 | end |
---|
192 | |
---|
193 | if exitReached and not hangarReached then |
---|
194 | hangarReached = goToHangar(timestep) |
---|
195 | end |
---|
196 | |
---|
197 | if hangarReached and not spaceShipReached then |
---|
198 | spaceShipReached = goToSpaceship(timestep) |
---|
199 | end |
---|
200 | |
---|
201 | if spaceShipReached and not spaceShipEntered then |
---|
202 | spaceShipEntered = enterSpaceship(timestep) |
---|
203 | end |
---|
204 | |
---|
205 | if spaceShipEntered then |
---|
206 | return true |
---|
207 | end |
---|
208 | |
---|
209 | return false |
---|
210 | end |
---|