Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/single_player_map/scripts/prisoner.lua @ 3964

Last change on this file since 3964 was 3964, checked in by snellen, 18 years ago

scripts updated

File size: 4.6 KB
Line 
1cellDoorOpened = false
2walkinCellFinished = false
3cellExitReached = false
4exitReached = false
5hangarReached = false
6spaceShipReached = false
7spaceShipEntered = false
8playerInLock = false
9
10randTime = 0
11height = 29
12
13
14function dist( x1,x2,x3, y1,y2,y3 )
15
16return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
17
18end
19
20function observeGuard()
21guardX = guard:getAbsCoorX()
22guardY = guard:getAbsCoorY()
23guardZ = guard:getAbsCoorZ()
24
25if dist( guardX,guardY,guardZ, 198.427155, 29, 243.656113 ) < 60 then
26cellDoorOpened = true
27end
28
29end
30
31function observePlayer()
32playerX = Player:getAbsCoorX()
33playerY = Player:getAbsCoorY()
34playerZ = Player:getAbsCoorZ()
35
36if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
37playerInLock = true
38end
39
40end
41
42walkProgrammed = false
43exitProgrammed = false
44function walkInCell(timestep)
45
46if not walkProgrammed then
47prisoner:walkTo( -66.454849, height, 62.363449)
48prisoner:walkTo( -66.454849, height, 62.363449)
49prisoner:walkTo( -63.214821, height, 62.429710)
50prisoner:walkTo( -56.661182, height, 62.563740)
51prisoner:walkTo( -46.779755, height, 62.765827)
52prisoner:walkTo( -41.634224, height, 71.319214)
53prisoner:walkTo( -38.168526, height, 79.655807)
54prisoner:walkTo( -40.782196, height, 101.285233)
55prisoner:walkTo( -47.722874, height, 114.314980)
56prisoner:walkTo( -54.593349, height, 118.605423)
57prisoner:walkTo( -62.802982, height, 117.947144)
58prisoner:walkTo( -73.180130, height, 116.720863)
59prisoner:walkTo( -85.028603, height, 114.952316)
60prisoner:walkTo( -113.125824, height, 96.362946)
61prisoner:walkTo( -118.218887, height, 87.702599)
62prisoner:walkTo( -120.596275, height, 80.304184)
63prisoner:walkTo( -114.928169, height, 68.971840)
64prisoner:walkTo( -108.606766, height, 62.085098)
65prisoner:walkTo( -90.078171, height, 59.558804)
66prisoner:walkTo( -83.558510, height, 60.516567)
67prisoner:walkTo( -71.352402, height, 63.920750)
68walkProgrammed = true
69end
70
71
72if prisoner:finalGoalReached() and not cellDoorOpened then
73   walkProgrammed = false
74  end
75
76if cellDoorOpened then
77
78  if not exitProgrammed then
79prisoner:walkTo( -61.875267, height, 158.254517)
80prisoner:walkTo( -62.335995, height, 170.318756)
81prisoner:walkTo( -62.358681, height, 179.232559)
82prisoner:walkTo( -55.998741, height, 189.289749)
83prisoner:walkTo( -49.237957, height, 195.076263)
84prisoner:walkTo( -39.007496, height, 195.889221)
85prisoner:walkTo( -24.234095, height, 195.547043)
86prisoner:walkTo( -11.409116, height, 196.236069)
87prisoner:walkTo( 2.545602, height, 196.805954)
88prisoner:walkTo( 13.875313, height, 196.377563)
89prisoner:walkTo( 28.379402, height, 195.829132)
90prisoner:walkTo( 41.672989, height, 195.326477)
91prisoner:walkTo( 57.125935, height, 194.742126)
92prisoner:walkTo( 70.114609, height, 194.251007)
93prisoner:walkTo( 81.857407, height, 193.806961)
94prisoner:walkTo( 97.840607, height, 193.974030)
95prisoner:walkTo( 107.569641, height, 196.299652)
96prisoner:walkTo( 120.975266, height, 202.754532)
97prisoner:walkTo( 129.063812, height, 207.099640)
98prisoner:walkTo( 140.468765, height, 214.389191)
99prisoner:walkTo( 145.902267, height, 224.194229)
100prisoner:walkTo( 148.106079, height, 233.095215)
101prisoner:walkTo( 150.907532, height, 244.410049)
102prisoner:walkTo( 153.191757, height, 253.635788)
103prisoner:walkTo( 153.191757, height, 253.635788)
104   exitProgrammed = true
105  end
106
107  if prisoner:finalGoalReached() then
108   return true
109  end
110
111 end 
112
113return false
114
115end
116
117
118return false
119
120end
121
122
123gotoExitProgrammed = false
124function goToExit(timestep)
125-- do not forget to make him wait until the player triggeres the trip to the hangar
126if not gotoExitProgrammed and playerInLock then
127
128gotoExitProgrammed = true
129end
130
131if prisoner:finalGoalReached() then
132   return true
133end
134
135return false
136end
137
138hangarRouteProgrammed = false
139function goToHangar(timestep)
140
141if not hangarRouteProgrammed then
142
143hangarRouteProgrammed = true
144end
145
146if prisoner:finalGoalReached() then
147   return true
148end
149
150return false
151
152end
153
154spaceshipRouteProgrammed = false
155function goToSpaceship(timestep)
156
157if not spaceshipRouteProgrammed then
158
159
160spaceshipRouteProgrammed = true
161end
162
163if prisoner:finalGoalReached() then
164   return true
165end
166
167return false
168
169end
170
171
172function enterSpaceship(timestep)
173
174return false
175end
176
177
178
179function tick(timestep)
180
181 observeGuard()
182 observePlayer()
183
184
185if not cellDoorOpend then
186walkinCellFinished = walkInCell(timestep)
187end
188
189if walkinCellFinished and not exitReached then
190exitReached = goToExit(timestep)
191end
192
193if exitReached and not hangarReached then
194hangarReached = goToHangar(timestep)
195end
196
197if hangarReached and not spaceShipReached then 
198spaceShipReached = goToSpaceship(timestep)
199end
200
201if spaceShipReached and not spaceShipEntered then
202spaceShipEntered = enterSpaceship(timestep)
203end
204
205if spaceShipEntered then
206return true
207end
208
209return false
210end
Note: See TracBrowser for help on using the repository browser.