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
RevLine 
[3945]1-- Global Variables
2allOk = true
[3951]3cellReached = false
[3945]4guidePositionReached = false
5prisonerReachedLock = false
6hangarReached = false
7
[3946]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
[3951]15function observeGuard()
16guardX = guard:getAbsCoorX()
17guardY = guard:getAbsCoorY()
18guardZ = guard:getAbsCoorZ()
19
[3954]20if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
[3945]21allOk = false
22end
23
[3951]24end
25
[3946]26function observePrisoner()
[3945]27
[3951]28prisonerX = Prisoner:getAbsCoorX()
29prisonerY = Prisoner:getAbsCoorY()
30prisonerZ = Prisoner:getAbsCoorZ()
[3946]31
[3951]32if dist( prisonerX,prisonerY,prisonerZ,161.76,49,358.87 ) < 60 then
33prisonerReachedLock = true
[3945]34end
35
[3951]36end
[3945]37
[3954]38cellProgrammed = false
[3951]39function goToCell(timestep)
40
[3954]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
[3945]61return false
62end
63
[3954]64guideProgrammed = false
[3945]65function goToGuidePosition(timestep)
66
[3954]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
[3945]87return false
88end
89
[3954]90hangarProgrammed = false
[3945]91function goToHangar(timestep)
92
[3954]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
[3945]113return false
[3954]114
[3945]115end
116
117function tick(timestep)
[3946]118--io.write("Secondguard called \n")
119 
120observePrisoner()
[3945]121
122if not allOk then
[3951]123cellReached = goToCell(timestep)
[3945]124end
125
[3951]126if cellReached and not guidePositionReached then
[3945]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.