Browse Source

npc origins

shuvit 4 years ago
parent
commit
598154c10e

+ 1
- 1
assets/user2.blend View File

1
 version https://git-lfs.github.com/spec/v1
1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:1f24f97dbd1be9394811c0c5ca1ef2f42a07da4fae255bad599ab261f214e50d
2
+oid sha256:b5462737156707708069790b93349c0ce1a35524db2a57fa43e11aaf5c7a5d19
3
 size 6860928
3
 size 6860928

+ 3
- 0
assets/utils/building_genV2_1.blend View File

1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:9b3b29d0a66a18c0011466662b2a331064e7a7a248fe4fe538c35b85d7ad7d2c
3
+size 26858216

+ 2
- 2
npc_walkers/larry.blend View File

1
 version https://git-lfs.github.com/spec/v1
1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:3f20d8d1e3b7b809089f2483347932b2d5d40e37ed3ae11df37f0981236b034e
3
-size 3687104
2
+oid sha256:dcfb9f4e7338db59784f183eb08030a73aef2883fb6ab1584dce2db9b2820bf2
3
+size 3686384

+ 11
- 3
scripts/StatesWalker.py View File

120
     if self.obj.linearVelocity.x < self.speed_targ:
120
     if self.obj.linearVelocity.x < self.speed_targ:
121
         self.obj.applyForce([self.speed_inc, 0, 0], True)
121
         self.obj.applyForce([self.speed_inc, 0, 0], True)
122
 
122
 
123
+def walk_anim(self):
124
+    if self.obj.linearVelocity.x > .5:
125
+        arm = self.obj.children['npc']
126
+        arm.playAction('g_walk2', 1,62, layer=1, play_mode=0, speed=.5) 
127
+
123
 #====================================     
128
 #====================================     
124
 
129
 
125
 State = type("State", (object,), {})
130
 State = type("State", (object,), {})
144
         
149
         
145
     def Enter(self):
150
     def Enter(self):
146
         self.FSM.stateLife = 1
151
         self.FSM.stateLife = 1
147
-        self.FSM.owner.resumePhysics()
148
-        self.FSM.owner.resumeDynamics()
149
-        print('physics resumed')
152
+        #self.FSM.owner.obj.worldPosition = self.FSM.owner.start_empty.obj.worldPosition
153
+        #self.FSM.owner.resumePhysics()
154
+        #self.FSM.owner.resumeDynamics()
155
+        #print('physics resumed')
150
         super(Example, self).Enter()        
156
         super(Example, self).Enter()        
151
         
157
         
152
     def Execute(self):
158
     def Execute(self):
235
         set_height(self.FSM.owner)
241
         set_height(self.FSM.owner)
236
         delta_to_vect(self.FSM.owner)
242
         delta_to_vect(self.FSM.owner)
237
         apply_gas(self.FSM.owner)
243
         apply_gas(self.FSM.owner)
244
+        walk_anim(self.FSM.owner)
238
 
245
 
239
         if self.FSM.stateLife > 30 * 180 * 3:
246
         if self.FSM.stateLife > 30 * 180 * 3:
240
             self.FSM.ToTransition('toEnterParallelPark')
247
             self.FSM.ToTransition('toEnterParallelPark')
281
         self.FSM.stateLife += 1
288
         self.FSM.stateLife += 1
282
 
289
 
283
     def Exit(self):
290
     def Exit(self):
291
+        pass

+ 1
- 1
scripts/cars.py View File

135
 			self.cars_active.append(car)
135
 			self.cars_active.append(car)
136
 			car.active = True
136
 			car.active = True
137
 			car.FSM.FSM.ToTransition('toRequestPath')
137
 			car.FSM.FSM.ToTransition('toRequestPath')
138
-			print('activate car', car)
138
+			#print('activate car', car)
139
 
139
 
140
 	def update(self):
140
 	def update(self):
141
 		self.life += 1
141
 		self.life += 1

+ 26
- 24
scripts/walker_states.py View File

1
+#not used - delete
1
 import bge
2
 import bge
2
 from random import randint
3
 from random import randint
3
 from time import clock
4
 from time import clock
314
 		self.npcFSM.Execute()    
315
 		self.npcFSM.Execute()    
315
 
316
 
316
 #====================================     
317
 #====================================     
317
-r = Walker()
318
+#r = Walker()
318
 def main(cont):
319
 def main(cont):
319
-	own = cont.owner   
320
-	scene = bge.logic.getCurrentScene()
321
-	if 'inited' not in own:
322
-		own['inited'] = True
323
-		own['frame'] = 0
324
-		own['state'] = 'On'
325
-		own['navMesh'] = None
320
+	pass
321
+	# own = cont.owner   
322
+	# scene = bge.logic.getCurrentScene()
323
+	# if 'inited' not in own:
324
+	# 	own['inited'] = True
325
+	# 	own['frame'] = 0
326
+	# 	own['state'] = 'On'
327
+	# 	own['navMesh'] = None
326
 
328
 
327
-		for x in scene.objects:
328
-			if 'npcNavmesh' in x:
329
-				own['navMesh'] = x
329
+	# 	for x in scene.objects:
330
+	# 		if 'npcNavmesh' in x:
331
+	# 			own['navMesh'] = x
330
 
332
 
331
-	if own['frame'] == 40:
332
-		own.worldPosition = [0,0,50]	
333
+	# if own['frame'] == 40:
334
+	# 	own.worldPosition = [0,0,50]	
333
 
335
 
334
-		ln = own['cName'] + '_loader'
335
-		if ln in scene.objects:
336
-			to = scene.objects[ln]	
337
-			own.worldPosition = to.worldPosition
338
-			own.worldOrientation = to.worldOrientation
336
+	# 	ln = own['cName'] + '_loader'
337
+	# 	if ln in scene.objects:
338
+	# 		to = scene.objects[ln]	
339
+	# 		own.worldPosition = to.worldPosition
340
+	# 		own.worldOrientation = to.worldOrientation
339
 
341
 
340
-	r.Execute()    
342
+	# r.Execute()    
341
 
343
 
342
-	own['frame'] += 1
343
-	yvel = own.linearVelocity.y
344
-	yvel = yvel *.05
345
-	if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
346
-		own.applyRotation([0,0,yvel], True)		
344
+	# own['frame'] += 1
345
+	# yvel = own.linearVelocity.y
346
+	# yvel = yvel *.05
347
+	# if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
348
+	# 	own.applyRotation([0,0,yvel], True)		

+ 13
- 4
scripts/walkers.py View File

9
 def idle_run_check(self):
9
 def idle_run_check(self):
10
 	output = False
10
 	output = False
11
 	for x in bge.logic.getCurrentScene().objects:
11
 	for x in bge.logic.getCurrentScene().objects:
12
-		if 'walker_idle_empty' in x.name:
12
+		if 'walker_idle_spot' in x.name:
13
 			self.idle_spots.append(x)
13
 			self.idle_spots.append(x)
14
 			x['in_use'] = False
14
 			x['in_use'] = False
15
 			output = True
15
 			output = True
16
+	print(output, 'walker idle spots')
16
 	return output
17
 	return output
17
 			
18
 			
18
 
19
 
19
 def get_idle_spots():
20
 def get_idle_spots():
20
 	op = []
21
 	op = []
21
 	for obj in bge.logic.getCurrentScene().objects:
22
 	for obj in bge.logic.getCurrentScene().objects:
22
-		if 'idle_spot' in obj:
23
+		if 'idle_spot' in obj.name:
23
 			ps = IdleSpot(obj, 'available')
24
 			ps = IdleSpot(obj, 'available')
24
 			op.append(ps)
25
 			op.append(ps)
26
+	print('&&&&&& idle spots')
27
+	print(op)		
25
 	return op
28
 	return op
26
 
29
 
27
 def get_intersections():
30
 def get_intersections():
32
 	return op		
35
 	return op		
33
 
36
 
34
 def add_walker(self, x):
37
 def add_walker(self, x):
38
+	print(x.obj.worldPosition, '--walker here')
35
 	walker = bge.logic.getCurrentScene().addObject('larryCube', x.obj, 0)
39
 	walker = bge.logic.getCurrentScene().addObject('larryCube', x.obj, 0)
40
+	print(walker.worldPosition)
41
+	
42
+	#walker.worldPosition = x.obj.worldPosition
36
 	walker.worldOrientation = x.obj.worldOrientation
43
 	walker.worldOrientation = x.obj.worldOrientation
37
-	walker.worldPosition.z += .8
44
+	walker.worldPosition.z += 2.8
38
 	walker.name = 'lwalker' + str(len(self.manager.walkers))
45
 	walker.name = 'lwalker' + str(len(self.manager.walkers))
39
 	x.status = 'in_use'
46
 	x.status = 'in_use'
40
 
47
 
64
 		self.path_index = 0
71
 		self.path_index = 0
65
 		self.path_display = []
72
 		self.path_display = []
66
 		self.manager.pub.register("path found", self)
73
 		self.manager.pub.register("path found", self)
74
+		#self.obj.worldPosition = self.start_empty.obj.worldPosition
67
 
75
 
68
 	def Execute(self):
76
 	def Execute(self):
69
 		self.FSM.Execute()
77
 		self.FSM.Execute()
117
 			path = bge.logic.expandPath(fileName)
125
 			path = bge.logic.expandPath(fileName)
118
 			print('loading npc')
126
 			print('loading npc')
119
 			try:
127
 			try:
120
-				bge.logic.LibLoad(fileName, 'Scene') 
128
+				bge.logic.LibLoad(fileName, 'Scene', load_actions=True) 
121
 				print('larry loaded')
129
 				print('larry loaded')
122
 			except Exception as e:
130
 			except Exception as e:
123
 				print('loading', fileName, 'failed', e)   
131
 				print('loading', fileName, 'failed', e)   
131
 			walker = random.choice(l)
139
 			walker = random.choice(l)
132
 			self.walkers_active.append(walker)
140
 			self.walkers_active.append(walker)
133
 			walker.active = True
141
 			walker.active = True
142
+			walker.obj.worldPosition = walker.start_empty.obj.worldPosition
134
 			walker.FSM.FSM.ToTransition('toRequestPath')
143
 			walker.FSM.FSM.ToTransition('toRequestPath')
135
 
144
 
136
 	def update(self):
145
 	def update(self):

Loading…
Cancel
Save