|
@@ -45,11 +45,16 @@ class Target1(State):
|
45
|
45
|
self.scene = bge.logic.getCurrentScene()
|
46
|
46
|
self.actu = self.cont.actuators['Steering']
|
47
|
47
|
|
|
48
|
+ nm = self.own['navMesh']
|
|
49
|
+ pt = nm.findPath(self.own.worldPosition, self.scene.objects[self.target].worldPosition)
|
|
50
|
+ print('path is', pt)
|
|
51
|
+
|
48
|
52
|
if 'larryTarget' in self.scene.objects:
|
49
|
53
|
self.actu.target = self.target
|
50
|
54
|
self.actu.velocity = 1.5
|
51
|
|
- self.actu.turnspeed = 100
|
52
|
|
- self.actu.facingMode = True
|
|
55
|
+ self.actu.turnspeed = 20
|
|
56
|
+ self.actu.facingMode = False
|
|
57
|
+ self.actu.navmesh = self.own['navMesh']
|
53
|
58
|
self.cont.activate(self.actu)
|
54
|
59
|
|
55
|
60
|
super(Target1, self).Enter()
|
|
@@ -57,9 +62,9 @@ class Target1(State):
|
57
|
62
|
def Execute(self):
|
58
|
63
|
#print('Tracking target 1.', self.FSM.stateLife)
|
59
|
64
|
self.FSM.stateLife += 1
|
60
|
|
- duration = 1000
|
|
65
|
+ duration = 500
|
61
|
66
|
if self.FSM.stateLife > duration:
|
62
|
|
- num = randint(1,3)
|
|
67
|
+ num = randint(1,2)
|
63
|
68
|
if num == 1:
|
64
|
69
|
self.FSM.ToTransition('toTarget2')
|
65
|
70
|
elif num ==2:
|
|
@@ -90,10 +95,11 @@ class Target2(State):
|
90
|
95
|
|
91
|
96
|
if 'larryTarget.001' in self.scene.objects:
|
92
|
97
|
self.actu.target = self.target
|
93
|
|
- self.actu.velocity = 1.5
|
94
|
|
- self.actu.turnspeed = 100
|
95
|
|
- self.actu.facingMode = True
|
96
|
|
- self.cont.activate(self.actu)
|
|
98
|
+ #self.actu.velocity = 1.5
|
|
99
|
+ #self.actu.turnspeed = 20
|
|
100
|
+ #self.actu.facingMode = False
|
|
101
|
+ #self.actu.navmesh = self.own['navMesh']
|
|
102
|
+ #self.cont.activate(self.actu)
|
97
|
103
|
|
98
|
104
|
super(Target2, self).Enter()
|
99
|
105
|
|
|
@@ -134,28 +140,28 @@ class Target3(State):
|
134
|
140
|
|
135
|
141
|
if 'larryTarget.002' in self.scene.objects:
|
136
|
142
|
self.actu.target = self.target
|
137
|
|
- self.actu.velocity = 1.5
|
138
|
|
- self.actu.turnspeed = 100
|
139
|
|
- self.actu.facingMode = True
|
|
143
|
+ #self.actu.velocity = 1.5
|
|
144
|
+ #self.actu.turnspeed = 20
|
|
145
|
+ #self.actu.facingMode = False
|
|
146
|
+ #self.actu.navmesh = self.own['navMesh']
|
140
|
147
|
self.cont.activate(self.actu)
|
141
|
148
|
super(Target3, self).Enter()
|
142
|
149
|
|
143
|
150
|
|
144
|
151
|
def Execute(self):
|
145
|
|
- #print('Vacumming.', self.FSM.stateLife)
|
146
|
152
|
self.FSM.stateLife += 1
|
147
|
153
|
duration = 1200
|
148
|
154
|
if self.FSM.stateLife > duration:
|
149
|
155
|
if not (randint(1,3) % 2):
|
150
|
156
|
self.FSM.ToTransition('toTarget1')
|
151
|
157
|
else:
|
152
|
|
- self.FSM.ToTransition('toIdle')
|
|
158
|
+ self.FSM.ToTransition('toTarget2')
|
153
|
159
|
else:
|
154
|
160
|
cont = bge.logic.getCurrentController()
|
155
|
161
|
own = cont.owner
|
156
|
162
|
npcArm = own.children['npc']
|
157
|
163
|
npcArm.playAction('g_walk2', 1,62, layer=2, play_mode=0, speed=.5)
|
158
|
|
- #npcArm.playAction('npcImpatient', 2,135, layer=2, play_mode=0, speed=.25)
|
|
164
|
+
|
159
|
165
|
|
160
|
166
|
def Exit(self):
|
161
|
167
|
#print('Finished target 3')
|
|
@@ -169,39 +175,59 @@ class Idle(State):
|
169
|
175
|
|
170
|
176
|
def Enter(self):
|
171
|
177
|
#print('Starting to idle.')
|
172
|
|
-
|
173
|
|
-
|
174
|
178
|
self.cont = bge.logic.getCurrentController()
|
175
|
|
- self.FSM.stateLife = 1
|
176
|
179
|
self.own = self.cont.owner
|
177
|
180
|
self.npcArm = self.own.children['npc']
|
|
181
|
+ self.FSM.stateLife = 1
|
178
|
182
|
|
179
|
183
|
super(Idle, self).Enter()
|
180
|
184
|
|
181
|
185
|
def Execute(self):
|
182
|
186
|
#print('Idleing.', self.FSM.stateLife)
|
183
|
187
|
self.FSM.stateLife += 1
|
184
|
|
- duration = 600
|
|
188
|
+ duration = 300
|
185
|
189
|
if self.FSM.stateLife > duration:
|
186
|
|
- num = randint(1,4)
|
187
|
|
- if num == 1:
|
188
|
|
- self.FSM.ToTransition('toTarget1')
|
189
|
|
- elif num == 2:
|
190
|
|
- self.FSM.ToTransition('toTarget2')
|
191
|
|
- elif num == 3:
|
192
|
|
- self.FSM.ToTransition('toTarget3')
|
193
|
|
- elif num == 4 or num == 5 or num == 6:
|
194
|
|
- self.FSM.ToTransition('toImpatient')
|
195
|
|
- else:
|
196
|
|
- self.FSM.ToTransition('toIdle')
|
|
190
|
+ #num = randint(1,4)
|
|
191
|
+ self.FSM.ToTransition('toTarget1')
|
|
192
|
+ # if num == 1:
|
|
193
|
+ # self.FSM.ToTransition('toTarget1')
|
|
194
|
+ # elif num == 2:
|
|
195
|
+ # self.FSM.ToTransition('toTarget2')
|
|
196
|
+ # elif num == 3:
|
|
197
|
+ # self.FSM.ToTransition('toTarget3')
|
|
198
|
+ # elif num == 4 or num == 5 or num == 6:
|
|
199
|
+ # self.FSM.ToTransition('toImpatient')
|
|
200
|
+ # else:
|
|
201
|
+ # self.FSM.ToTransition('toIdle')
|
197
|
202
|
else:
|
198
|
203
|
#pass
|
|
204
|
+ #print(self.own.children)
|
199
|
205
|
self.npcArm.playAction('g_idle', 1,201, layer=2, play_mode=0, speed=.5)
|
200
|
206
|
|
201
|
207
|
def Exit(self):
|
202
|
208
|
pass
|
203
|
209
|
##print('Waking up from idle.')
|
204
|
210
|
|
|
211
|
+
|
|
212
|
+class Startup(State):
|
|
213
|
+
|
|
214
|
+ def __init__(self,FSM):
|
|
215
|
+ super(Startup, self).__init__(FSM)
|
|
216
|
+
|
|
217
|
+ def Enter(self):
|
|
218
|
+ self.FSM.stateLife = 1
|
|
219
|
+ super(Startup, self).Enter()
|
|
220
|
+
|
|
221
|
+ def Execute(self):
|
|
222
|
+ self.FSM.stateLife += 1
|
|
223
|
+ duration = 4
|
|
224
|
+ if self.FSM.stateLife > duration:
|
|
225
|
+ self.FSM.ToTransition('toIdle')
|
|
226
|
+
|
|
227
|
+ def Exit(self):
|
|
228
|
+ #pass
|
|
229
|
+ print('Exiting npc startup.')
|
|
230
|
+
|
205
|
231
|
class Impatient(State):
|
206
|
232
|
|
207
|
233
|
def __init__(self,FSM):
|
|
@@ -218,11 +244,12 @@ class Impatient(State):
|
218
|
244
|
def Execute(self):
|
219
|
245
|
##print('being Impatient.', self.FSM.stateLife)
|
220
|
246
|
self.FSM.stateLife += 1
|
221
|
|
- duration = 600
|
|
247
|
+ duration = 300
|
222
|
248
|
if self.FSM.stateLife > duration:
|
223
|
249
|
self.FSM.ToTransition('toIdle')
|
224
|
250
|
else:
|
225
|
|
- self.npcArm.playAction('npcImpatient', 1,201, layer=2, play_mode=0, speed=.5)
|
|
251
|
+ pass
|
|
252
|
+ #self.npcArm.playAction('npcImpatient', 1,201, layer=2, play_mode=0, speed=.5)
|
226
|
253
|
|
227
|
254
|
def Exit(self):
|
228
|
255
|
pass
|
|
@@ -275,14 +302,15 @@ class Walker(Char):
|
275
|
302
|
#self.LightOn = own['state']
|
276
|
303
|
|
277
|
304
|
##STATES
|
|
305
|
+ self.FSM.AddState("Startup", Startup(self.FSM))
|
278
|
306
|
self.FSM.AddState("Idle", Idle(self.FSM))
|
279
|
|
-
|
280
|
307
|
self.FSM.AddState("Impatient", Impatient(self.FSM))
|
281
|
308
|
self.FSM.AddState('Target1', Target1(self.FSM))
|
282
|
309
|
self.FSM.AddState('Target3', Target3(self.FSM))
|
283
|
310
|
self.FSM.AddState('Target2', Target2(self.FSM))
|
284
|
311
|
|
285
|
312
|
#TRANSITIONS
|
|
313
|
+ self.FSM.AddTransition('toStartup', Transition('Startup'))
|
286
|
314
|
self.FSM.AddTransition('toIdle', Transition('Idle'))
|
287
|
315
|
self.FSM.AddTransition('toImpatient', Transition('Impatient'))
|
288
|
316
|
self.FSM.AddTransition('toTarget3', Transition('Target3'))
|
|
@@ -291,7 +319,8 @@ class Walker(Char):
|
291
|
319
|
|
292
|
320
|
|
293
|
321
|
if self.FSM.curState == None:
|
294
|
|
- self.FSM.SetState('Idle')
|
|
322
|
+ self.FSM.SetState('Startup')
|
|
323
|
+ #self.FSM.ToTransition('toIdle')
|
295
|
324
|
#print('setting none')
|
296
|
325
|
|
297
|
326
|
def Execute(self):
|
|
@@ -305,6 +334,11 @@ def main(cont):
|
305
|
334
|
own['inited'] = True
|
306
|
335
|
own['frame'] = 0
|
307
|
336
|
own['state'] = 'On'
|
|
337
|
+ own['navMesh'] = None
|
|
338
|
+
|
|
339
|
+ for x in scene.objects:
|
|
340
|
+ if 'npcNavmesh' in x:
|
|
341
|
+ own['navMesh'] = x
|
308
|
342
|
#print('initing')
|
309
|
343
|
|
310
|
344
|
if own['frame'] == 40:
|
|
@@ -319,5 +353,10 @@ def main(cont):
|
319
|
353
|
|
320
|
354
|
r.Execute()
|
321
|
355
|
##print(r.FSM.curState)
|
322
|
|
-
|
323
|
|
- own['frame'] += 1
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+ own['frame'] += 1
|
|
359
|
+ yvel = own.linearVelocity.y
|
|
360
|
+ yvel = yvel *.05
|
|
361
|
+ if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
|
|
362
|
+ own.applyRotation([0,0,yvel], True)
|