Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/scripts/guard.lua @ 4059

Last change on this file since 4059 was 3991, checked in by bensch, 18 years ago

data/trunk: merged the single_player_map branche back.
merged with command:
svn merge -r523:HEAD https://svn.orxonox.net/data/branches/single_player_map .

conflicts resolved in all sp_levels in favour of the branche

File size: 7.1 KB
Line 
1-- Global Variables
2walkingRouteOne = true   -- True if thestranger is walking route one
3exitPositionReached = false
4playerInLock = false
5hangarReached = false
6
7height = 80
8
9-- Returns the distance between (x1,x2,x3) and (y1,y2,y3)
10function dist( x1,x2,x3, y1,y2,y3 )
11return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
12end
13
14
15function observePlayer()
16playerX = Player:getAbsCoorX()
17playerY = Player:getAbsCoorY()
18playerZ = Player:getAbsCoorZ()
19
20if dist( playerX,playerY,playerZ,167.361526,29,483.163818 ) < 60 then
21playerInLock = true
22end
23
24end
25
26routeOneProgrammed = false
27function walkRouteOne(timestep)
28
29if not routeOneProgrammed then
30guard:walkTo( 266.396362, height, 241.398544)
31guard:walkTo( 254.577255, height, 241.159897)
32guard:walkTo( 221.120651, height, 240.484360)
33guard:walkTo( 187.732651, height, 239.810196)
34guard:walkTo( 165.661865, height, 239.364563)
35guard:walkTo( 148.642044, height, 239.020889)
36guard:walkTo( 128.012802, height, 238.604340)
37guard:walkTo( 65.664688, height, 237.345383)
38guard:walkTo( 30.099592, height, 236.627243)
39guard:walkTo( -14.031926, height, 236.483414)
40guard:walkTo( -52.224205, height, 241.776978)
41guard:walkTo( -83.528168, height, 245.757629)
42guard:walkTo( -98.730980, height, 247.394043)
43guard:walkTo( -111.666504, height, 246.585648)
44guard:walkTo( -111.666504, height, 246.585648)
45guard:walkTo( -114.805542, height, 246.144440)
46guard:walkTo( -119.267967, height, 245.360168)
47guard:walkTo( -138.284515, height, 239.281021)
48guard:walkTo( -146.166840, height, 234.512054)
49guard:walkTo( -157.210480, height, 222.620941)
50guard:walkTo( -158.519867, height, 219.674301)
51guard:walkTo( -158.519867, height, 219.674301)
52guard:walkTo( -158.478958, height, 213.490570)
53guard:walkTo( -158.478958, height, 213.490570)
54guard:walkTo( -155.965332, height, 210.303101)
55guard:walkTo( -150.804489, height, 203.959869)
56guard:walkTo( -148.853012, height, 201.561295)
57guard:walkTo( -145.451157, height, 197.554382)
58guard:walkTo( -143.694107, height, 196.373535)
59guard:walkTo( -139.281479, height, 193.407990)
60guard:walkTo( -137.526047, height, 192.228226)
61guard:walkTo( -103.046753, height, 182.510071)
62guard:runTo( -14.992087, height, 181.910767)
63guard:runTo( 46.347664, height, 181.493317)
64guard:runTo( 86.343376, height, 181.221130)
65guard:runTo( 124.465179, height, 194.251617)
66guard:runTo( 136.548996, height, 219.682953)
67guard:runTo( 145.162140, height, 244.268982)
68guard:runTo( 149.328720, height, 256.993256)
69guard:runTo( 162.649582, height, 268.181732)
70
71routeOneProgrammed = true
72end
73
74if guard:finalGoalReached() then
75return false
76end
77
78return true
79end
80
81
82exitRouteProgrammed = false
83function goToExitPosition(timestep)
84
85if not exitRouteProgrammed then
86guard:walkTo( 162.096558, height, 274.944366)
87guard:walkTo( 161.519516, height, 286.673370)
88guard:walkTo( 161.098618, height, 295.228699)
89guard:walkTo( 160.568466, height, 306.004486)
90guard:walkTo( 160.151169, height, 314.486572)
91guard:walkTo( 159.416641, height, 324.925232)
92guard:walkTo( 158.700073, height, 335.108154)
93guard:walkTo( 157.943298, height, 345.862610)
94guard:walkTo( 157.418381, height, 356.131256)
95guard:walkTo( 156.908035, height, 366.115417)
96guard:walkTo( 156.940308, height, 377.467712)
97guard:walkTo( 156.965408, height, 386.287933)
98guard:walkTo( 156.924698, height, 394.296417)
99guard:walkTo( 156.816116, height, 401.564911)
100guard:walkTo( 156.147583, height, 446.314850)
101guard:walkTo( 155.145660, height, 515.473877)
102guard:walkTo( 148.450058, height, 524.572571)
103guard:walkTo( 135.599609, height, 533.407166)
104guard:walkTo( 119.772217, height, 539.609192)
105guard:walkTo( 108.926720, height, 537.174927)
106guard:walkTo( 100.885788, height, 524.737793)
107guard:walkTo( 99.870834, height, 512.540100)
108guard:walkTo( 108.219215, height, 502.064178)
109
110exitRouteProgrammed = true
111end
112
113if guard:finalGoalReached() and playerInLock then
114return true
115end
116
117return false
118end
119
120
121hangarRouteProgrammed = false
122function goToHangar(timestep)
123
124if not hangarRouteProgrammed and playerInLock then
125guard:walkTo( 138.422943, height, 504.832733)
126guard:walkTo( 188.685089, height, 509.034851)
127guard:walkTo( 259.451904, height, 515.326111)
128guard:walkTo( 351.655762, height, 519.210571)
129guard:walkTo( 495.821381, height, 517.551392)
130guard:walkTo( 650.267029, height, 516.826843)
131guard:walkTo( 752.277100, height, 506.265289)
132guard:walkTo( 780.652405, height, 397.283752)
133guard:walkTo( 780.212830, height, 317.386017)
134guard:walkTo( 778.699158, height, 241.875305)
135guard:walkTo( 776.305542, height, 120.869957)
136guard:walkTo( 774.626343, height, 26.204597)
137guard:walkTo( 773.148804, height, -30.654911)
138guard:walkTo( 771.164978, height, -106.990250)
139guard:walkTo( 756.719971, height, -197.656296)
140guard:walkTo( 730.690796, height, -269.808075)
141guard:walkTo( 702.250854, height, -341.732147)
142guard:walkTo( 681.786011, height, -393.487030)
143guard:walkTo( 664.005981, height, -441.609131)
144guard:walkTo( 655.612671, height, -523.194153)
145guard:walkTo( 664.289978, height, -585.003540)
146guard:walkTo( 670.221069, height, -645.366333)
147guard:walkTo( 674.347290, height, -704.953674)
148guard:walkTo( 677.495605, height, -750.421082)
149guard:walkTo( 680.699280, height, -796.687073)
150guard:walkTo( 686.407043, height, -879.117859)
151guard:walkTo( 692.573364, height, -952.031555)
152guard:walkTo( 701.940552, height, -1025.037964)
153guard:walkTo( 710.218628, height, -1086.598389)
154guard:walkTo( 719.834900, height, -1142.248779)
155guard:walkTo( 731.087158, height, -1198.201538)
156guard:walkTo( 745.157715, height, -1258.461182)
157guard:walkTo( 753.189331, height, -1290.539551)
158guard:walkTo( 763.940369, height, -1347.249268)
159guard:walkTo( 768.509949, height, -1377.040039)
160guard:walkTo( 770.845215, height, -1408.751953)
161guard:walkTo( 770.785583, height, -1435.573608)
162guard:walkTo( 765.031799, height, -1462.657593)
163guard:walkTo( 753.982727, height, -1483.425415)
164guard:walkTo( 735.194580, height, -1500.978394)
165guard:walkTo( 707.312500, height, -1514.814575)
166guard:walkTo( 672.638550, height, -1522.803589)
167guard:walkTo( 560.158936, height, -1530.277344)
168guard:walkTo( 500.429626, height, -1532.241577)
169guard:walkTo( 371.231262, height, -1535.953613)
170guard:walkTo( 204.211609, height, -1539.026611)
171guard:walkTo( 104.032593, height, -1546.350220)
172guard:walkTo( 45.058315, height, -1550.720337)
173guard:walkTo( 1.504358, height, -1574.713745)
174guard:walkTo( -20.050890, height, -1627.849854)
175guard:walkTo( -28.036245, height, -1674.240479)
176guard:walkTo( -29.157598, height, -1702.924316)
177guard:walkTo( -29.760004, height, -1730.014526)
178guard:walkTo( -29.538343, height, -1759.887329)
179guard:walkTo( -21.584003, height, -1790.162842)
180guard:walkTo( -8.572795, height, -1823.067871)
181guard:walkTo( 13.254844, height, -1861.705688)
182hangarRouteProgrammed  = true
183end
184
185if guard:finalGoalReached() then
186return true
187end
188
189return false
190end
191
192
193function waveToSpaceship(timestep)
194
195end
196
197
198function tick(timestep)
199--io.write("Guard called \n")
200observePlayer()
201
202if walkingRouteOne then
203walkingRouteOne = walkRouteOne(timestep)
204end
205
206if not walkingRouteOne and not exitPositionReached then
207exitPositionReached = goToExitPosition(timestep)
208end
209
210if not hangarReached and exitPositionReached then
211hangarReached = goToHangar(timestep)
212end
213
214if hangarReached then
215waveToSpaceship(timestep)
216end
217
218return false
219end
220 
Note: See TracBrowser for help on using the repository browser.