Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

continued implementation…

File size: 2.9 KB
Line 
1-- Global Variables
2allOk = true
3cellReached = false
4guidePositionReached = false
5prisonerReachedLock = false
6hangarReached = false
7
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 observeGuard()
16guardX = guard:getAbsCoorX()
17guardY = guard:getAbsCoorY()
18guardZ = guard:getAbsCoorZ()
19
20if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
21allOk = false
22end
23
24end
25
26function observePrisoner()
27
28prisonerX = Prisoner:getAbsCoorX()
29prisonerY = Prisoner:getAbsCoorY()
30prisonerZ = Prisoner:getAbsCoorZ()
31
32if dist( prisonerX,prisonerY,prisonerZ,161.76,49,358.87 ) < 60 then
33prisonerReachedLock = true
34end
35
36end
37
38cellProgrammed = false
39function goToCell(timestep)
40
41if not cellProgrammed then
42--io.write("Guard called \n")
43secondguard:walkTo(-132, 29, 238.381805)
44secondguard:walkTo(-138.41, 29, 275.25)
45secondguard:walkTo(-143.70, 29, 275.35)
46secondguard:walkTo(-149.10, 29, 226.66)
47secondguard:walkTo(-149.10, 29, 196.83)
48secondguard:walkTo(-145.82, 29, 189.74)
49secondguard:walkTo(-138.48, 29, 184.28)
50secondguard:walkTo(35.48, 29, 191.28)
51secondguard:runTo(102, 29, 203.28)
52secondguard:runTo(164, 29, 245.28)
53
54cellProgrammed = true
55end
56
57if secondguard:finalGoalReached() then
58return true
59end
60
61return false
62end
63
64guideProgrammed = false
65function goToGuidePosition(timestep)
66
67if not guideProgrammed then
68--io.write("Guard called \n")
69secondguard:walkTo(-132, 29, 238.381805)
70secondguard:walkTo(-138.41, 29, 275.25)
71secondguard:walkTo(-143.70, 29, 275.35)
72secondguard:walkTo(-149.10, 29, 226.66)
73secondguard:walkTo(-149.10, 29, 196.83)
74secondguard:walkTo(-145.82, 29, 189.74)
75secondguard:walkTo(-138.48, 29, 184.28)
76secondguard:walkTo(35.48, 29, 191.28)
77secondguard:runTo(102, 29, 203.28)
78secondguard:runTo(164, 29, 245.28)
79
80guideProgrammed = true
81end
82
83if secondguard:finalGoalReached() then
84return true
85end
86
87return false
88end
89
90hangarProgrammed = false
91function goToHangar(timestep)
92
93if not hangarProgrammed then
94--io.write("Guard called \n")
95secondguard:walkTo(-132, 29, 238.381805)
96secondguard:walkTo(-138.41, 29, 275.25)
97secondguard:walkTo(-143.70, 29, 275.35)
98secondguard:walkTo(-149.10, 29, 226.66)
99secondguard:walkTo(-149.10, 29, 196.83)
100secondguard:walkTo(-145.82, 29, 189.74)
101secondguard:walkTo(-138.48, 29, 184.28)
102secondguard:walkTo(35.48, 29, 191.28)
103secondguard:runTo(102, 29, 203.28)
104secondguard:runTo(164, 29, 245.28)
105
106hangarProgrammed = true
107end
108
109if secondguard:finalGoalReached() then
110return true
111end
112
113return false
114
115end
116
117function tick(timestep)
118--io.write("Secondguard called \n")
119 
120observePrisoner()
121
122if not allOk then
123cellReached = goToCell(timestep)
124end
125
126if cellReached and not guidePositionReached then
127guidePositionReached = goToGuidePosition(timestep)
128end
129
130if guidePositionReached and prisonerReachedLock then
131hangarReached = goToHangar(timestep)
132end
133
134if hangarReached then
135return true
136end
137
138return false
139end
Note: See TracBrowser for help on using the repository browser.