Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/single_player_map/scripts/guard.lua @ 3959

Last change on this file since 3959 was 3951, checked in by snellen, 19 years ago

added some npcs

File size: 2.5 KB
Line 
1-- Global Variables
2walkingRouteOne = true   -- True if thestranger is walking route one
3exitPositionReached = false
4playerInLock = false
5hangarReached = false
6
7-- Returns the distance between (x1,x2,x3) and (y1,y2,y3)
8function dist( x1,x2,x3, y1,y2,y3 )
9return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
10end
11
12
13function observePlayer()
14playerX = Player:getAbsCoorX()
15playerY = Player:getAbsCoorY()
16playerZ = Player:getAbsCoorZ()
17
18if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
19playerInLock = true
20end
21
22end
23
24routeOneProgrammed = false
25function walkRouteOne(timestep)
26
27if not routeOneProgrammed then
28--io.write("Guard called \n")
29guard:walkTo(-132, 29, 238.381805)
30guard:walkTo(-138.41, 29, 275.25)
31guard:walkTo(-143.70, 29, 275.35)
32guard:walkTo(-149.10, 29, 226.66)
33guard:walkTo(-149.10, 29, 196.83)
34guard:walkTo(-145.82, 29, 189.74)
35guard:walkTo(-138.48, 29, 184.28)
36guard:walkTo(35.48, 29, 191.28)
37guard:runTo(102, 29, 203.28)
38guard:runTo(164, 29, 245.28)
39
40routeOneProgrammed = true
41end
42
43if guard:finalGoalReached() then
44return false
45end
46
47return true
48end
49
50
51exitRouteProgrammed = false
52function goToExitPosition(timestep)
53
54if not exitRouteProgrammed then
55guard:walkTo(-132, 29, 238.381805)
56guard:walkTo(-138.41, 29, 275.25)
57guard:walkTo(-143.70, 29, 275.35)
58guard:walkTo(-149.10, 29, 226.66)
59guard:walkTo(-149.10, 29, 196.83)
60guard:walkTo(-145.82, 29, 189.74)
61guard:walkTo(-138.48, 29, 184.28)
62guard:walkTo(35.48, 29, 191.28)
63guard:runTo(102, 29, 203.28)
64guard:runTo(164, 29, 245.28)
65
66exitRouteProgrammed = true
67end
68
69if guard:finalGoalReached() and playerInLock then
70return true
71end
72
73return false
74end
75
76
77hangarRouteProgrammed = false
78function goToHangar(timestep)
79
80if not hangarRouteProgrammed  then
81guard:walkTo(-132, 29, 238.381805)
82guard:walkTo(-138.41, 29, 275.25)
83guard:walkTo(-143.70, 29, 275.35)
84guard:walkTo(-149.10, 29, 226.66)
85guard:walkTo(-149.10, 29, 196.83)
86guard:walkTo(-145.82, 29, 189.74)
87guard:walkTo(-138.48, 29, 184.28)
88guard:walkTo(35.48, 29, 191.28)
89guard:runTo(102, 29, 203.28)
90guard:runTo(164, 29, 245.28)
91
92hangarRouteProgrammed  = true
93end
94
95if guard:finalGoalReached() then
96return true
97end
98
99return false
100end
101
102
103function waveToSpaceship(timestep)
104
105end
106
107
108function tick(timestep)
109--io.write("Guard called \n")
110observePlayer()
111
112if walkingRouteOne then
113walkingRouteOne = walkRouteOne(timestep)
114end
115
116if not walkingRouteOne and not exitPositionReached then
117exitPositionReached = goToExitPosition(timestep)
118end
119
120if playerInLock and exitPositionReached then
121hangarReached = goToHangar(timestep)
122end
123
124if hangarReached then
125waveToSpaceship(timestep)
126end
127
128return false
129end
130 
Note: See TracBrowser for help on using the repository browser.