shuvit 2 years ago
parent
commit
d11284bf21
11 changed files with 389 additions and 55 deletions
  1. 2
    2
      assets/ramps.blend
  2. 2
    2
      assets/user2.blend
  3. 2
    2
      config.ini
  4. 2
    1
      scripts/FSM.py
  5. 195
    19
      scripts/StatesPlayer.py
  6. 1
    1
      scripts/controller2.py
  7. 1
    5
      scripts/game.py
  8. 178
    21
      scripts/player.py
  9. 3
    0
      scripts/ragdoll.py
  10. 1
    0
      scripts/scene_init.py
  11. 2
    2
      shuvit.blend

+ 2
- 2
assets/ramps.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:dac8bd740361ce271c1b6590f2a9127bd17b0e1e6320a8c457160678af7fffac
3
-size 44741748
2
+oid sha256:5395502faddbee5158b7c9ffd14807408fbb2a6b14b148db93ef53ea011a4a9b
3
+size 48154268

+ 2
- 2
assets/user2.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:71ee4f8556b82e3b8e0c7b7424152a63b31f0a1b43bf75bf64fe1e16684aea35
3
-size 579232
2
+oid sha256:ab1b42cf5d4aee552dc3f4f15e5e04b0c16882a41ce75c79726a9dceb04b1463
3
+size 662960

+ 2
- 2
config.ini View File

@@ -153,10 +153,10 @@ gravity = -10.5
153 153
 fall_height = 0.5
154 154
 
155 155
 walk_force = 15
156
-run_force = 35
156
+run_force = 40
157 157
 max_walk_vel = 1.5
158 158
 max_run_vel = 5
159
-walk_turn_amt = .03
159
+walk_turn_amt = 0.03
160 160
 walk_jump_force = 1300
161 161
 
162 162
 #controller mappings

+ 2
- 1
scripts/FSM.py View File

@@ -103,7 +103,8 @@ class PlayerFSM(Char):
103 103
         'WalkHang',
104 104
         'WalkClimb',
105 105
         'WalkHurdle',
106
-        'Roll']
106
+        'Roll',
107
+        'Ragdoll']
107 108
         
108 109
         for s in state_list:
109 110
             self.FSM.AddState(s, getattr(StatesPlayer, s)(self.FSM))

+ 195
- 19
scripts/StatesPlayer.py View File

@@ -70,7 +70,7 @@ class Walk(State):
70 70
         if c.arm == None:
71 71
             
72 72
             c.arm = o.childrenRecursive['Char4']
73
-
73
+            c.deck_arm = o.childrenRecursive['deck_arm']
74 74
         self.walk_weight = 1
75 75
         self.run_weight = 1
76 76
         self.run_speed = 0.0
@@ -100,10 +100,21 @@ class Walk(State):
100 100
         #         print('request reg offboard') 
101 101
         # if self.FSM.stateLife > 5:
102 102
         #     o['requestAction'] = 'reg_idle'                 
103
+        c.align_walk_z()
103 104
         ground_rays = c.get_ground_ray()
105
+        #77777777777777777777777777777777777777777777777777777777777777777777777777777777777
106
+        c.get_hang_align_ray()
107
+        c.move_walk_cam()
108
+        c.check_reset_point()       
109
+        c.check_throw()
110
+
104 111
         if ground_rays[0][0] != None:
105 112
             dist = c.get_ground_dist(ground_rays)
106
-            c.set_walk_z(dist)
113
+            if dist > .7:
114
+                self.FSM.ToTransition('toWalkAir')
115
+                print('---falling')
116
+            else:
117
+                c.set_walk_z(dist)
107 118
             #print(dist, 'setting height')
108 119
 
109 120
         if self.FSM.stateLife > 4:
@@ -121,14 +132,14 @@ class Walk(State):
121 132
     def check_onboard(self):
122 133
 
123 134
         o = self.FSM.owner.obj
124
-        print(o['getonboard'], 'getonboard')
135
+        #print(o['getonboard'], 'getonboard')
125 136
 
126 137
 
127 138
 
128 139
         if dict['walk'] == 0:
129 140
             o['getonboard'] = True
130 141
             self.FSM.ToTransition('toRoll')
131
-            print('onboard', dict['walk'], o['getonboard'])
142
+            #print('onboard', dict['walk'], o['getonboard'])
132 143
 
133 144
 
134 145
 
@@ -145,14 +156,20 @@ class Walk(State):
145 156
 
146 157
     def idle_blend(self):
147 158
         arm = self.FSM.owner.arm
159
+        deck = self.FSM.owner.deck_arm
148 160
         arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=10)
161
+        deck.playAction('b_reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=10)
149 162
         if self.FSM.stateLife > 20:
150 163
             frame = arm.getActionFrame(2) + .5 * self.run_speed
151 164
             if frame > 30:
152 165
                 frame = 0
153 166
             arm.stopAction(2)
167
+            deck.stopAction(2)
154 168
             arm.playAction('reg_nwalk3', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
169
+            deck.playAction('b_reg_walk', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
170
+            #b_reg_walk
155 171
             arm.setActionFrame(frame, 2)
172
+            deck.setActionFrame(frame, 2)
156 173
             #print(self.walk_weight, frame)
157 174
 
158 175
             
@@ -161,8 +178,12 @@ class Walk(State):
161 178
             if frame > 30:
162 179
                 frame = 0
163 180
             arm.stopAction(3)
181
+            deck.stopAction(3)
164 182
             arm.playAction('reg_run.003', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
183
+            deck.playAction('b_reg_run', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
184
+            
165 185
             arm.setActionFrame(frame, 3)
186
+            deck.setActionFrame(frame, 3)
166 187
             #print(frame, 'frame')
167 188
             #print(self.run_weight, frame)
168 189
             
@@ -229,6 +250,10 @@ class Walk(State):
229 250
         self.FSM.owner.arm.stopAction(1)
230 251
         self.FSM.owner.arm.stopAction(2)
231 252
         self.FSM.owner.arm.stopAction(3)
253
+        self.FSM.owner.deck_arm.stopAction(0)
254
+        self.FSM.owner.deck_arm.stopAction(1)
255
+        self.FSM.owner.deck_arm.stopAction(2)
256
+        self.FSM.owner.deck_arm.stopAction(3)
232 257
         dict['walk'] = 0
233 258
 
234 259
 
@@ -240,35 +265,50 @@ class WalkAir(State):
240 265
         
241 266
     def Enter(self):
242 267
         self.FSM.stateLife = 1
243
-        #arm = self.FSM.owner.arm
244
-        #arm.playAction('a_jump_t', 27, 27, layer=1, play_mode=0, speed=1, blendin=5)
245 268
         super(WalkAir, self).Enter()        
246 269
         
247 270
     def Execute(self):
248 271
         self.FSM.stateLife += 1
249
-        #self.FSM.ToTransition('toLand')
272
+        self.FSM.owner.check_reset_point()  
250 273
         arm = self.FSM.owner.arm
251
-        arm.playAction('a_jump_t', 23, 23, layer=3, play_mode=1, speed=1, blendin=5)
252
-        #if self.FSM.stateLife > 50:
253
-            #self.FSM.ToTransition('toWalk')
254
-        #limit fall speed
274
+        deck_arm = self.FSM.owner.deck_arm
275
+        #arm.playAction('a_jump_t', 23, 23, layer=3, play_mode=1, speed=1, blendin=5)
276
+        arm.playAction('c_jump_up', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
277
+        deck_arm.playAction('b_walk_jump', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
278
+
255 279
         if self.FSM.owner.obj.linearVelocity.z < -10:
256 280
             self.FSM.owner.obj.linearVelocity.z = -10
257
-        #ground_rays = self.FSM.owner.get_ground_ray()    
281
+        moving = self.FSM.owner.walk_movement() 
258 282
         ground_rays = self.FSM.owner.get_ground_ray() 
259
-        if ground_rays[0][0] != None:
260 283
 
284
+        self.FSM.owner.check_throw()
285
+        if ground_rays[0][0] != None:
261 286
             dist = self.FSM.owner.get_ground_dist(ground_rays)
262 287
             if dist < .4:
263
-                self.FSM.ToTransition('toWalkLand')  
288
+                    self.FSM.ToTransition('toWalkLand')  
264 289
 
265
-        moving = self.FSM.owner.walk_movement()              
290
+
291
+
292
+            if dist > .5 and self.FSM.owner.obj.worldPosition.z < self.FSM.owner.last_pos.z: 
293
+                hang_ray = self.FSM.owner.get_hang_ray()           
294
+                hang_align_ray = self.FSM.owner.get_hang_align_ray()
295
+
296
+                if hang_ray[0] != None and hang_align_ray[0] != None and self.FSM.prevState != 'WalkHang' and dict['lUD'] < .04:
297
+                    hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
298
+                    if hr_dist < .1:
299
+                        self.FSM.owner.obj.linearVelocity = [0,0,0]
300
+                        self.FSM.owner.obj.worldPosition.z = hang_ray[1].z - 1
301
+                        self.FSM.ToTransition('toWalkHang')
266 302
         
267 303
     def Exit(self):
268 304
         self.FSM.owner.arm.stopAction(0)
269 305
         self.FSM.owner.arm.stopAction(1)
270 306
         self.FSM.owner.arm.stopAction(2)
271 307
         self.FSM.owner.arm.stopAction(3)
308
+        self.FSM.owner.deck_arm.stopAction(0)
309
+        self.FSM.owner.deck_arm.stopAction(1)
310
+        self.FSM.owner.deck_arm.stopAction(2)
311
+        self.FSM.owner.deck_arm.stopAction(3)
272 312
 
273 313
 #==================================== 
274 314
             
@@ -280,7 +320,10 @@ class WalkJump(State):
280 320
         self.FSM.stateLife = 1
281 321
 
282 322
         arm = self.FSM.owner.arm
283
-        arm.playAction('a_jump_t', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
323
+        deck = self.FSM.owner.deck_arm
324
+        #arm.playAction('a_jump_t', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
325
+        arm.playAction('c_jump_up', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
326
+        deck.playAction('b_walk_jump', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
284 327
             
285 328
 
286 329
         super(WalkJump, self).Enter()        
@@ -311,7 +354,10 @@ class WalkLand(State):
311 354
         
312 355
     def Enter(self):
313 356
         self.FSM.stateLife = 1
314
-        self.FSM.owner.arm.playAction('a_jump_t', 23, 50, layer=5, play_mode=0, speed=1, blendin=5)
357
+        #self.FSM.owner.arm.playAction('a_jump_t', 23, 50, layer=5, play_mode=0, speed=1, blendin=5)
358
+        self.FSM.owner.arm.playAction('c_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
359
+        self.FSM.owner.deck_arm.playAction('b_walk_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
360
+        #c_land
315 361
         super(WalkLand, self).Enter()        
316 362
         
317 363
     def Execute(self):
@@ -325,7 +371,7 @@ class WalkLand(State):
325 371
         #     print('stopping land')
326 372
         #     arm.stopAction(5)
327 373
         #     arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=2)
328
-        if self.FSM.stateLife > 8:
374
+        if self.FSM.stateLife > 30:
329 375
             self.FSM.ToTransition('toWalk')
330 376
 
331 377
         ground_rays = self.FSM.owner.get_ground_ray() 
@@ -344,12 +390,56 @@ class WalkHang(State):
344 390
         
345 391
     def Enter(self):
346 392
         self.FSM.stateLife = 1
393
+        self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
394
+        self.moveable = False
395
+        #self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
347 396
         super(WalkHang, self).Enter()        
348 397
         
349 398
     def Execute(self):
350 399
         self.FSM.stateLife += 1
351
-        #self.FSM.ToTransition('toLand')
400
+        self.FSM.owner.obj.linearVelocity = [0,0,0]
401
+        #self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
402
+        self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
403
+        if dict['lUD'] > .04:
404
+            self.FSM.ToTransition('toWalkAir')
405
+           
352 406
         
407
+        self.FSM.owner.move_walk_cam()
408
+        if self.FSM.stateLife > 25:
409
+            self.moveable = True
410
+        if self.moveable:
411
+            if dict['lUD'] < -.04:
412
+                self.FSM.ToTransition('toWalkClimb') 
413
+            self.FSM.owner.hang_move()
414
+        ground_rays = self.FSM.owner.get_ground_ray() 
415
+        if ground_rays[0][0] != None:
416
+            dist = self.FSM.owner.get_ground_dist(ground_rays)
417
+            if dist < .4:
418
+                self.FSM.ToTransition('toWalkLand') 
419
+
420
+        hang_ray = self.FSM.owner.get_hang_ray()           
421
+        hang_align_ray = self.FSM.owner.get_hang_align_ray()
422
+        #print(hang_align_ray, 'hang_align_ray')
423
+        #self.FSM.owner.hang_move()
424
+
425
+
426
+
427
+        if hang_ray[0] != None:
428
+            hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
429
+            print(hr_dist, 'hang dist')
430
+            if hr_dist < .5:
431
+                self.FSM.owner.obj.linearVelocity = [0,0,0]
432
+                self.FSM.owner.obj.worldPosition.z = hang_ray[1].z  - 1
433
+            if hang_align_ray[0] != None:
434
+                print(hang_align_ray[0])
435
+                v = hang_align_ray[2]
436
+                self.FSM.owner.obj.alignAxisToVect(v, 0, .5)    
437
+        else:
438
+            self.FSM.ToTransition('toWalkAir')
439
+        if hang_align_ray[0] == None:
440
+            self.FSM.ToTransition('toWalkAir')
441
+
442
+        self.FSM.owner.align_walk_z()
353 443
     def Exit(self):
354 444
         pass
355 445
 
@@ -361,12 +451,20 @@ class WalkClimb(State):
361 451
         
362 452
     def Enter(self):
363 453
         self.FSM.stateLife = 1
454
+        self.FSM.owner.arm.playAction('c_wallclimb', 1, 50, layer=3, play_mode=0, speed=1, blendin=10)
364 455
         super(WalkClimb, self).Enter()        
365 456
         
366 457
     def Execute(self):
367 458
         self.FSM.stateLife += 1
368 459
         #self.FSM.ToTransition('toLand')
369 460
         
461
+        if self.FSM.stateLife > 25:
462
+            self.FSM.owner.obj.applyForce([-300, 0, 80], True)
463
+        else:
464
+            self.FSM.owner.obj.applyForce([-20, 0, 80], True)    
465
+        if self.FSM.stateLife > 35:
466
+            self.FSM.ToTransition('toWalkLand')
467
+        
370 468
     def Exit(self):
371 469
         pass                                
372 470
 
@@ -389,6 +487,60 @@ class WalkHurdle(State):
389 487
 
390 488
 
391 489
 #==================================== 
490
+
491
+            
492
+class Example(State):
493
+    def __init__(self,FSM):
494
+        super(Example, self).__init__(FSM)    
495
+        
496
+    def Enter(self):
497
+        self.FSM.stateLife = 1
498
+        super(Example, self).Enter()        
499
+        
500
+    def Execute(self):
501
+        self.FSM.stateLife += 1
502
+        #self.FSM.ToTransition('toExample')
503
+        
504
+    def Exit(self):
505
+        pass
506
+
507
+#==================================== 
508
+
509
+            
510
+class Example(State):
511
+    def __init__(self,FSM):
512
+        super(Example, self).__init__(FSM)    
513
+        
514
+    def Enter(self):
515
+        self.FSM.stateLife = 1
516
+        super(Example, self).Enter()        
517
+        
518
+    def Execute(self):
519
+        self.FSM.stateLife += 1
520
+        #self.FSM.ToTransition('toExample')
521
+        
522
+    def Exit(self):
523
+        pass
524
+
525
+#==================================== 
526
+
527
+            
528
+class Example(State):
529
+    def __init__(self,FSM):
530
+        super(Example, self).__init__(FSM)    
531
+        
532
+    def Enter(self):
533
+        self.FSM.stateLife = 1
534
+        super(Example, self).Enter()        
535
+        
536
+    def Execute(self):
537
+        self.FSM.stateLife += 1
538
+        #self.FSM.ToTransition('toExample')
539
+        
540
+    def Exit(self):
541
+        pass
542
+
543
+#==================================== 
392 544
             
393 545
 class Roll(State):
394 546
     def __init__(self,FSM):
@@ -397,6 +549,7 @@ class Roll(State):
397 549
     def Enter(self):
398 550
         self.FSM.stateLife = 1
399 551
         self.FSM.owner.walking = False
552
+        self.FSM.owner.obj['getonboard'] = False
400 553
         dict['walking'] = False
401 554
         super(Roll, self).Enter()        
402 555
         
@@ -407,6 +560,8 @@ class Roll(State):
407 560
             self.FSM.owner.obj['getoffboard'] = True
408 561
             self.FSM.ToTransition('toWalk')
409 562
             print('fsm to walk')
563
+        if self.FSM.owner.obj['fall'] == True:
564
+            self.FSM.ToTransition('toRagdoll')    
410 565
         print('rolling')
411 566
         #self.FSM.ToTransition('toLand')
412 567
         
@@ -414,3 +569,24 @@ class Roll(State):
414 569
         pass
415 570
 
416 571
 #==================================== 
572
+
573
+class Ragdoll(State):
574
+    def __init__(self,FSM):
575
+        super(Ragdoll, self).__init__(FSM)    
576
+        
577
+    def Enter(self):
578
+        self.FSM.stateLife = 1
579
+        super(Ragdoll, self).Enter()        
580
+        
581
+    def Execute(self):
582
+        self.FSM.stateLife += 1
583
+        print('ragdolling')
584
+        if dict['yBut'] == 1:
585
+            self.FSM.owner.obj['fall'] = False
586
+            self.FSM.owner.cont.activate(self.FSM.owner.cont.actuators['walk'])
587
+            self.FSM.ToTransition('toWalk')
588
+        
589
+    def Exit(self):
590
+        pass                                
591
+
592
+#==================================== 

+ 1
- 1
scripts/controller2.py View File

@@ -4322,4 +4322,4 @@ def main():
4322 4322
     elif own['actionState'] in ['fak_backside_grab_out', 'fak_frontside_grab_out', 'fak_frontside_nose_grab_out', 'fak_frontside_tail_grab_out', 'fak_backside_nose_grab_out', 'fak_backside_tail_grab_out', 'fak_walk_air_out', 'fak_air-walk_air', 'fak_judo_out', 'fak_frigid_out', 'fak_fsonefoot_out', 'fak_onefoot_out'] and own['requestAction'] in  ['reg_land', 'fak_land']:
4323 4323
         own['requestAction'] = 'fak_land'   
4324 4324
 
4325
-    print(dict['walk'], 'controller walk')
4325
+    print(own['getonboard'], 'controller geton', '--controller running')

+ 1
- 5
scripts/game.py View File

@@ -4,14 +4,10 @@ import requests
4 4
 import platform
5 5
 
6 6
 def phone_home():
7
-
8
-
9
-	#url = 'https://www.w3schools.com/python/demopage.php'
10 7
 	url = 'https://shuvit.org/phone_home.php'
11 8
 	n = platform.uname()
12 9
 	n = platform.platform()
13 10
 	myobj = {'somekey': n}
14
-
15 11
 	x = requests.post(url, data = myobj, timeout=3.50)
16 12
 	print('phone home response')
17 13
 	print(x.text)
@@ -20,10 +16,10 @@ def main(cont):
20 16
 	own = cont.owner
21 17
 	dict = bge.logic.globalDict
22 18
 	if 'game_inited' not in own:
19
+		info = bge.logic.PrintGLInfo()
23 20
 		own['game_inited'] = True
24 21
 		own['cont'] = cont
25 22
 		dict['gameFSM'] = FSM.GameFSM(own)
26 23
 		#phone_home()
27 24
 
28
-
29 25
 	dict['gameFSM'].Execute()

+ 178
- 21
scripts/player.py View File

@@ -10,6 +10,11 @@ class Player:
10 10
 		self.obj = cont.owner
11 11
 		self.FSM = FSM.PlayerFSM(self)
12 12
 		self.walking = True
13
+		self.last_pos = self.obj.worldPosition.copy()
14
+		self.throw_timer = 0
15
+		self.throw_deck = None
16
+		self.throw_deck_empty = self.obj.childrenRecursive["throw_deck_empty"]
17
+		#self.throw_deck_obj = dict['level_scene'].objects['throw_deck']
13 18
 		dict['walking'] = True
14 19
 		#print(self.obj.childrenRecursive)
15 20
 		#self.arm = self.obj.childrenRecursive['Char4']
@@ -17,68 +22,108 @@ class Player:
17 22
 
18 23
 	def update(self):
19 24
 		self.FSM.Execute()
25
+		self.last_pos = self.obj.worldPosition.copy()
20 26
 
21 27
 	def get_ground_ray(self):
22
-
23 28
 		v = self.obj.worldOrientation.col[0]
24 29
 		tv = v.normalized()
25
-
26 30
 		axis = 2
27
-		distance = -5
31
+		distance = -50
28 32
 		start = self.obj.worldPosition.copy()
29
-		#front_start = start - 0.30 * tvfront_start = start - 0.30 * tv
30 33
 		back_start = start + 0.15 * tv
31 34
 		start.z += .1
32 35
 		end = Vector.copy(self.obj.worldPosition + (self.obj.worldOrientation.col[axis] * distance))
33
-		
34
-		ray = self.obj.rayCast(end, back_start, 0, 'ground', 1, 0, 0)
35
-
36
+		ray = self.obj.rayCast(end, back_start, 0, 'ground', 1, 0, 0, 53247)
36 37
 		v = self.obj.linearVelocity.copy()
37
-
38 38
 		v = self.obj.worldOrientation.col[0]
39 39
 		tv = v.normalized()
40 40
 		front_start = start - 0.30 * tv
41 41
 		start.z += .1
42 42
 		front_end = Vector(front_start + (self.obj.worldOrientation.col[axis] * distance))
43 43
 		frontray = self.obj.rayCast(front_end, front_start, 0, 'ground', 1, 1, 0, 53247)
44
-
45
-		bge.render.drawLine(front_start, front_end, [1,0,0])
46
-		#print(ray)
44
+		#bge.render.drawLine(front_start, front_end, [1,0,0])
47 45
 		return [ray, frontray]
48 46
 
47
+
48
+	def get_hang_ray(self):
49
+
50
+		v = self.obj.worldOrientation.col[0]
51
+		tv = v.normalized()
52
+
53
+		axis = 2
54
+		distance = -5
55
+		start = self.obj.worldPosition.copy()
56
+		start.z += 1.8
57
+		mstart = start - 0.40 * tv
58
+		
59
+		end = Vector(mstart + (self.obj.worldOrientation.col[axis] * distance))
60
+		ray = self.obj.rayCast(end, mstart, 0, 'ground', 1, 1, 0, 53247)
61
+		#ray = self.obj.rayCast(end, mstart, 0, '', 1, 1, 0, 53247)
62
+		#bge.render.drawLine(mstart, end, [0,0,1])
63
+
64
+		return ray
65
+
66
+	def get_hang_align_ray(self):
67
+
68
+		v = self.obj.worldOrientation.col[0]
69
+		tv = v.normalized()
70
+
71
+		axis = 0
72
+		distance = -2
73
+		start = self.obj.worldPosition.copy()
74
+		start.z += 1
75
+		#mstart = start - 0.40 * tv
76
+		#mstart = start * tv
77
+		mstart = start 
78
+
79
+		end = Vector(mstart + (self.obj.worldOrientation.col[axis] * distance))
80
+		#ray = self.obj.rayCast(end, mstart, 0, 'ground', 1, 0, 0, 53247)
81
+		ray = self.obj.rayCast(end, mstart, 0, '', 1, 0, 0, 53247)
82
+		#if ray[0] != None:
83
+			#print(ray[0], 'player funct')
84
+		#bge.render.drawLine(mstart, end, [0,1,0])
85
+		
86
+		return ray
87
+
88
+
89
+
49 90
 	def get_ground_dist(self, groundray):
50 91
 		gr = groundray[0]
51 92
 		fgr = groundray[1]
52
-		#when player is on the ground, dist is .25
53 93
 		d = None
54 94
 		
55 95
 		if gr[0] != None:
56
-
57 96
 			p_z = self.obj.worldPosition.z
58 97
 			g_z = gr[1].z
59
-
60 98
 			distance_to_ground = p_z - g_z
61
-
62 99
 			p2 = None
63 100
 			if fgr[0] != None:
64 101
 				p2 = p_z - fgr[1].z 
65 102
 
66 103
 				if p2 < distance_to_ground:
67
-					#front to ground is bigger than back to ground
68
-					#val = p2 - distance_to_ground
69
-					#val *= .1
70
-					print(fgr[0], 'ray hit obj')
71 104
 					distance_to_ground = p2
72 105
 
73 106
 			return distance_to_ground
74 107
 
108
+
109
+
110
+	def get_hang_dist(self, groundray):
111
+		if groundray[0] != None:
112
+			p_z = self.obj.worldPosition.z
113
+			g_z = groundray[1].z
114
+			distance_to_ground = p_z - g_z
115
+			return distance_to_ground
116
+
117
+
75 118
 	def set_walk_z(self, dist):
76 119
 		if dist < .6:
77 120
 			target_dist = .3
78
-			#z_targ = self.obj.worldPosition.z + (target_dist - dist)
79 121
 			self.obj.worldPosition.z += (target_dist - dist)
80 122
 			self.obj.linearVelocity.z = 0
81 123
 
124
+	def align_walk_z(self):
125
+		self.obj.alignAxisToVect([0,0,1], 2, .05)
126
+
82 127
 	def walk_movement(self):
83 128
 		
84 129
 		moving = False
@@ -105,7 +150,8 @@ class Player:
105 150
 
106 151
 		if dict['kb_s'] == 2 or dict['lUD'] > .06:
107 152
 			#o.applyForce([10, 0, 0], True)
108
-			o.linearVelocity.x -= 1
153
+			if o.linearVelocity.x < (dict['max_walk_vel'] / 2):
154
+				o.linearVelocity.x += .05
109 155
 			#print('w')
110 156
 
111 157
 		if dict['kb_a'] == 2 or dict['lLR'] < -.03:
@@ -121,6 +167,117 @@ class Player:
121 167
 
122 168
 		return moving
123 169
 
170
+	def move_walk_cam(self):
171
+		amt = -.05
172
+		amt2 = -.07
173
+		if dict['rLR'] > .04:
174
+			dict['camera'].applyMovement([amt, 0, 0], True)
175
+		elif dict['rLR'] < -.04:
176
+			dict['camera'].applyMovement([-amt, 0, 0], True)	
177
+
178
+		if dict['rUD'] > .04:
179
+			dict['camera'].applyMovement([0, -amt2, 0], True)
180
+		elif dict['rUD'] < -.04:
181
+			dict['camera'].applyMovement([0, amt2, 0], True)	
182
+
183
+	def check_reset_point(self):
184
+		print(dict['udPad'], dict['ddPad'])
185
+		if dict['udPad'] == 1:
186
+			print('set reset')
187
+		elif dict['ddPad'] == 1:
188
+			print('go to reset')			
189
+#reset
190
+		if dict['ddPad'] == 1:
191
+			spawn_pos = self.obj['spawn_pos']
192
+			spawn_rot = self.obj['spawn_rot']
193
+			spawn_cam_pos = self.obj['spawn_cam_pos']
194
+			spawn_cam_rot = self.obj['spawn_cam_rot']
195
+			try:
196
+				self.obj.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
197
+				self.obj.worldOrientation = [[spawn_rot[0][0], spawn_rot[0][1],spawn_rot[0][2]], [spawn_rot[1][0],spawn_rot[1][1], spawn_rot[1][2]], [0.0, 0.0, 1.0]]
198
+				dict['camera'].worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
199
+				dict['camera'].worldOrientation = [[spawn_cam_rot[0][0], spawn_cam_rot[0][1], spawn_cam_rot[0][2]], [spawn_cam_rot[1][0], spawn_cam_rot[1][1], spawn_cam_rot[1][2]], [0.0, 0.0, 1.0]]
200
+			except:
201
+				self.obj.worldPosition = (0, 0, .1)
202
+				self.obj.worldOrientation = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
203
+
204
+			if self.obj["spawn_stance"] == 1:
205
+				self.obj.setLinearVelocity([.1,0,0], 1)
206
+
207
+			else:
208
+				self.obj.setLinearVelocity([-.1,0,0], 1)
209
+
210
+		if dict['udPad'] == 1:
211
+			self.obj['spawn_pos'] = [self.obj.worldPosition[0], self.obj.worldPosition[1], self.obj.worldPosition[2]]
212
+			self.obj['spawn_rot'] = [[self.obj.worldOrientation[0][0], self.obj.worldOrientation[0][1],self.obj.worldOrientation[0][2]], [self.obj.worldOrientation[1][0], self.obj.worldOrientation[1][1], self.obj.worldOrientation[1][2]], self.obj.worldOrientation[2][2]]
213
+			self.obj['spawn_cam_pos'] = [dict['camera'].worldPosition[0], dict['camera'].worldPosition[1], dict['camera'].worldPosition[2]]
214
+			self.obj['spawn_cam_rot'] = [[dict['camera'].worldOrientation[0][0], dict['camera'].worldOrientation[0][1],dict['camera'].worldOrientation[0][2]], [dict['camera'].worldOrientation[1][0], dict['camera'].worldOrientation[1][1], dict['camera'].worldOrientation[1][2]], dict['camera'].worldOrientation[2][2]]
215
+			stance = self.obj["stance"]
216
+			self.obj["spawn_stance"] = stance
217
+
218
+
219
+	def hang_move(self):
220
+		if dict['lLR'] > .04:
221
+			#self.arm.playAction('c_hanghopleft', 0, 45, layer=3, play_mode=0, speed=.75, blendin=10)
222
+			self.arm.playAction('c_shimmy_l', 0, 34, layer=3, play_mode=0, speed=.75, blendin=10)
223
+			self.obj.applyForce([0,235,0], True)
224
+		if dict['lLR'] < -.04:
225
+			#self.arm.playAction('c_hanghopright', 0, 45, layer=3, play_mode=0, speed=.75, blendin=10)
226
+			self.arm.playAction('c_shimmy_r', 0, 34, layer=3, play_mode=0, speed=.75, blendin=10)
227
+			self.obj.applyForce([0,-235,0], True)
228
+
229
+
230
+	def check_throw(self):
231
+
232
+		def throw(strength):
233
+			print('throwing with strength', strength)
234
+			if self.throw_deck != None:
235
+				self.throw_deck.endObject()
236
+				self.throw_deck = None
237
+			self.throw_deck = dict['level_scene'].addObject('throw_deck', self.throw_deck_empty, 0)
238
+			self.throw_deck.worldOrientation = self.throw_deck_empty.worldOrientation
239
+			#self.throw_deck.applyForce([0, 0, -300], True)
240
+			#-z = forward +y = height
241
+			self.throw_deck.applyForce([0, 150, -200], True)
242
+			self.hide_deck()
243
+
244
+		if self.throw_deck == None:	
245
+			strength = self.throw_timer
246
+			
247
+			if strength > 19:
248
+				strength = 19
249
+
250
+			if dict['bBut'] == 0 and dict['last_bBut'] == 1:
251
+				self.throw_timer = 0
252
+				self.arm.playAction('c_throw', 19, 45, layer=7, play_mode=0, speed=.75, blendin=5)
253
+				self.deck_arm.playAction('b_throw', 19, 45, layer=7, play_mode=0, speed=.75, blendin=5)
254
+				throw(strength)
255
+			elif dict['bBut'] == 1:
256
+				self.arm.playAction('c_throw', 0, 45, layer=7, play_mode=1, speed=.75, blendin=5)
257
+				self.deck_arm.playAction('b_throw', 0, 45, layer=7, play_mode=1, speed=.75, blendin=5)
258
+				self.arm.setActionFrame(strength, 7)
259
+				self.deck_arm.setActionFrame(strength, 7)
260
+				self.throw_timer += 1
261
+			else:
262
+				self.throw_timer = 0
263
+		else:
264
+			if dict['bBut'] == 0 and dict['last_bBut'] == 1:
265
+				self.show_deck()
266
+				self.throw_deck.endObject()
267
+				self.throw_deck = None
268
+
269
+
270
+
271
+		#if self.throw_timer > 0:
272
+	def hide_deck(self):
273
+		for x in self.deck_arm.childrenRecursive:
274
+			x.visible = False
275
+			
276
+	def show_deck(self):
277
+		for x in self.deck_arm.childrenRecursive:
278
+			x.visible = True
279
+
280
+
124 281
 
125 282
 
126 283
 def update(cont):

+ 3
- 0
scripts/ragdoll.py View File

@@ -189,6 +189,9 @@ def main():
189 189
                 own.worldPosition = scene.objects['npc_ed_arm_phys_master'].worldPosition
190 190
                 own.worldPosition.z += .4
191 191
                 cont.activate(cont.actuators['walk']) 
192
+                own['getonboard'] = True
193
+                dict['walk'] = 0
194
+                own['fall'] = False
192 195
 
193 196
             if dict['lUD'] < -.08 and own['rd_incer'] > 200:
194 197
                 physBody = own['rd_rb']

+ 1
- 0
scripts/scene_init.py View File

@@ -15,6 +15,7 @@ def main():
15 15
         
16 16
         cam = scene.objects['Camera.003']
17 17
         curscene = bge.logic.getCurrentScene()
18
+        dict['level_scene'] = curscene
18 19
 
19 20
         dict['overlay_fadeout'] = 1
20 21
         scenes = bge.logic.getSceneList()

+ 2
- 2
shuvit.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:8ff6a17a5eb21ea481bc3cda4b94b326bbc186b271d726331066ba550059de59
3
-size 128961440
2
+oid sha256:ed9ccab1cd84ac46d7e14d38f51a2a6c4c23d4bc182f4cb05510ee43188ef47f
3
+size 125585980

Loading…
Cancel
Save