Browse Source

z123 - sat stuff

shuvit 6 years ago
parent
commit
2ef583da8b
3 changed files with 59 additions and 21 deletions
  1. 12
    9
      co_ActionState.py
  2. 24
    9
      controller2.py
  3. 23
    3
      grindV2.py

+ 12
- 9
co_ActionState.py
File diff suppressed because it is too large
View File


+ 24
- 9
controller2.py View File

3483
         if own['invert_on'] == 1 and own['last_invert'] == False:
3483
         if own['invert_on'] == 1 and own['last_invert'] == False:
3484
             #killall()
3484
             #killall()
3485
             cont.activate(own.actuators['invertOn_sound'])
3485
             cont.activate(own.actuators['invertOn_sound'])
3486
-            if STANCE == False:
3486
+            if STANCE == True:
3487
                 own['invert_type'] = "reg_back_invert_in"
3487
                 own['invert_type'] = "reg_back_invert_in"
3488
             #     skater.playAction("reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1) 
3488
             #     skater.playAction("reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1) 
3489
             #     deck.playAction("a_reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1)
3489
             #     deck.playAction("a_reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1)
3490
             #     trucks.playAction("a_reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1) 
3490
             #     trucks.playAction("a_reg_back_invert_in", 10,30, layer=303, play_mode=0, speed=1) 
3491
-            if STANCE == True:
3491
+            if STANCE == False:
3492
                 own['invert_type'] = "fak_fr_invert"
3492
                 own['invert_type'] = "fak_fr_invert"
3493
             #     skater.playAction("fak_fr_invert", 10,30, layer=303, play_mode=0, speed=1) 
3493
             #     skater.playAction("fak_fr_invert", 10,30, layer=303, play_mode=0, speed=1) 
3494
             #     deck.playAction("a_fak_fr_invert", 10,30, layer=303, play_mode=0, speed=1)
3494
             #     deck.playAction("a_fak_fr_invert", 10,30, layer=303, play_mode=0, speed=1)
3533
     lif = own['last_invert_frame'] 
3533
     lif = own['last_invert_frame'] 
3534
     if frame - lif > 3 and invert_on == 0:
3534
     if frame - lif > 3 and invert_on == 0:
3535
         own['invert_type'] = None
3535
         own['invert_type'] = None
3536
+        
3537
+    if grindHit == False:
3538
+        own['invert_on'] = False    
3536
 invert() 
3539
 invert() 
3537
 footplant()
3540
 footplant()
3538
     
3541
     
3577
 
3580
 
3578
 
3581
 
3579
    
3582
    
3580
-#start button    
3583
+#start button
3584
+#print(own['last_stBut'])
3585
+#print(own['pause_on'])    
3581
 if stBut == True:
3586
 if stBut == True:
3582
     own.actuators["sroll"].volume = .0001
3587
     own.actuators["sroll"].volume = .0001
3583
     cont.deactivate(own.actuators["sroll"])
3588
     cont.deactivate(own.actuators["sroll"])
3584
     own.actuators["sroll"].stopSound()
3589
     own.actuators["sroll"].stopSound()
3590
+if stBut == False and own['last_stBut'] == True:
3591
+    if own['pause_on'] == True:
3592
+        own['pause_on'] = False
3593
+        own.restoreDynamics()     
3594
+    else:
3595
+        own['pause_on'] = True
3596
+        own.suspendDynamics()            
3597
+    
3598
+own['last_stBut'] = stBut
3585
      
3599
      
3586
 def ylimit():
3600
 def ylimit():
3587
     lgf = own['last_grind_frame']
3601
     lgf = own['last_grind_frame']
3905
     jumping = None
3919
     jumping = None
3906
     gotcd = 25
3920
     gotcd = 25
3907
     force = [0,0,0]
3921
     force = [0,0,0]
3908
-    grindHit = own['grindTouch']      
3922
+    grindHit = own['grindTouch'] 
3923
+    #print("grindHit: ", grindHit)     
3909
     sincegrinding = own['framenum']  - own['grindstartFrame']
3924
     sincegrinding = own['framenum']  - own['grindstartFrame']
3910
     STANCE = own['stance']
3925
     STANCE = own['stance']
3911
     if rUD > turnsens or rLR > turnsens or rUD < -turnsens or rLR < -turnsens:
3926
     if rUD > turnsens or rLR > turnsens or rUD < -turnsens or rLR < -turnsens:
3913
     if grindHit == False:
3928
     if grindHit == False:
3914
         cont.deactivate(own.actuators['grindoutRight'])
3929
         cont.deactivate(own.actuators['grindoutRight'])
3915
         cont.deactivate(own.actuators['grindoutLeft'])   
3930
         cont.deactivate(own.actuators['grindoutLeft'])   
3916
-    if grindHit == True and jumping == None and sincegrinding > 20:
3931
+    if (grindHit == True and jumping == None and sincegrinding > 20)or own['invert_on'] == True:
3917
     #if grindHit == True and jumping == None:
3932
     #if grindHit == True and jumping == None:
3918
         outloc = 0.022
3933
         outloc = 0.022
3919
         bsoutloc = .07
3934
         bsoutloc = .07
3971
             if lq5on == 1:
3986
             if lq5on == 1:
3972
                 if own['gt_cd2'] == 0:
3987
                 if own['gt_cd2'] == 0:
3973
                     own['gt_cd2'] = 60                 
3988
                     own['gt_cd2'] = 60                 
3974
-                if own['grind_stance'] == True:
3989
+                if STANCE == True:
3975
                     if own['footplant_on'] == True:
3990
                     if own['footplant_on'] == True:
3976
                         own.setLinearVelocity([(outvel.x + -bsoutvel), outvel.y, outvel.z], 1)
3991
                         own.setLinearVelocity([(outvel.x + -bsoutvel), outvel.y, outvel.z], 1)
3977
                         cont.activate(own.actuators["grindoutRight"])                   
3992
                         cont.activate(own.actuators["grindoutRight"])                   
3978
                     if own['grind_out_type'] == None:
3993
                     if own['grind_out_type'] == None:
3979
                          own['grind_out_type'] = 'bs fak back'                     
3994
                          own['grind_out_type'] = 'bs fak back'                     
3980
-                if own['grind_stance'] == False:
3995
+                if STANCE == False:
3981
                     if own['footplant_on'] == True:
3996
                     if own['footplant_on'] == True:
3982
                         own.setLinearVelocity([(outvel.x + bsoutvel), outvel.y, outvel.z], 1)
3997
                         own.setLinearVelocity([(outvel.x + bsoutvel), outvel.y, outvel.z], 1)
3983
                         cont.activate(own.actuators["grindoutRight"]) 
3998
                         cont.activate(own.actuators["grindoutRight"]) 
3988
             if lq1on == 1:
4003
             if lq1on == 1:
3989
                 if own['gt_cd2'] == 0:
4004
                 if own['gt_cd2'] == 0:
3990
                     own['gt_cd2'] = 60                 
4005
                     own['gt_cd2'] = 60                 
3991
-                if own['grind_stance'] == True:
4006
+                if STANCE == True:
3992
                     if own['footplant_on'] == True:                   
4007
                     if own['footplant_on'] == True:                   
3993
                         own.setLinearVelocity([(outvel.x + bsoutvel), outvel.y, outvel.z], 1)
4008
                         own.setLinearVelocity([(outvel.x + bsoutvel), outvel.y, outvel.z], 1)
3994
                         cont.activate(own.actuators["grindoutRight"])
4009
                         cont.activate(own.actuators["grindoutRight"])
3995
                     if own['grind_out_type'] == None:
4010
                     if own['grind_out_type'] == None:
3996
                          own['grind_out_type'] = 'bs fak forward'                                            
4011
                          own['grind_out_type'] = 'bs fak forward'                                            
3997
-                if own['grind_stance'] == False:
4012
+                if STANCE == False:
3998
                     if own['footplant_on'] == True:                    
4013
                     if own['footplant_on'] == True:                    
3999
                         own.setLinearVelocity([(outvel.x + -bsoutvel), outvel.y, outvel.z], 1)
4014
                         own.setLinearVelocity([(outvel.x + -bsoutvel), outvel.y, outvel.z], 1)
4000
                         cont.activate(own.actuators["grindoutRight"])
4015
                         cont.activate(own.actuators["grindoutRight"])

+ 23
- 3
grindV2.py View File

16
     #grindTouch = cont.sensors['grindCol']
16
     #grindTouch = cont.sensors['grindCol']
17
     invertCol = cont.sensors['invertCol']
17
     invertCol = cont.sensors['invertCol']
18
     invertObjs = invertCol.hitObjectList
18
     invertObjs = invertCol.hitObjectList
19
+    invert_on = own['invert_on']
19
     detectedObjects = grindDar.hitObjectList
20
     detectedObjects = grindDar.hitObjectList
20
     lastObject = own['grindTrackObj']
21
     lastObject = own['grindTrackObj']
21
     nearestObject = None
22
     nearestObject = None
217
 
218
 
218
 
219
 
219
         if rot >= 45 and rot < 90:  
220
         if rot >= 45 and rot < 90:  
220
-                             
221
+            #90 degrees CW about z-axis: (x, y, z) -> (y, -x, z)                 
221
             player.alignAxisToVect(grinder_vect, 0, align_strength) 
222
             player.alignAxisToVect(grinder_vect, 0, align_strength) 
222
             grindvect = "pos"
223
             grindvect = "pos"
223
             player.applyRotation(bsrot, 1)
224
             player.applyRotation(bsrot, 1)
507
             
508
             
508
     #else:
509
     #else:
509
         #own['grind_rot'] = None 
510
         #own['grind_rot'] = None 
511
+        
512
+    def invertpos(detectedObjects):
513
+        minDist = None
514
+        nearestObject = None
515
+        for obj in detectedObjects:
516
+            dist = own.getDistanceTo(obj)
517
+            if (minDist is None or dist < minDist):
518
+                nearestObject = obj
519
+                minDist = dist
520
+        if nearestObject != None:        
521
+            vect = nearestObject.getAxisVect( [1.0, 0.0, 0.0])
522
+        #own.alignAxisToVect(vect, 0, 0)
523
+            own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
524
+            #own.setLinearVelocity([0, 0.0, 0], 1)                    
525
+        
510
                
526
                
511
             
527
             
512
     
528
     
525
         
541
         
526
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
542
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
527
         #init grind
543
         #init grind
544
+        
545
+        if invert_on:
546
+            invertpos(detectedObjects)
547
+            print('invertOn')
528
 
548
 
529
         grind_dist = .8#.6
549
         grind_dist = .8#.6
530
-        if dist < grind_dist and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0:
550
+        if dist < grind_dist and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and invert_on == False:
531
         #if grindold == 0 and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject:    
551
         #if grindold == 0 and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject:    
532
             print("new grind trigger")           
552
             print("new grind trigger")           
533
             npos = nearestObject.worldPosition
553
             npos = nearestObject.worldPosition
545
 
565
 
546
         #grind
566
         #grind
547
         #print(dist)
567
         #print(dist)
548
-        if dist < grind_dist and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and own['airup'] == 0 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 50:
568
+        if dist < grind_dist and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and own['airup'] == 0 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 50 and invert_on == False:
549
             #print("grind")    
569
             #print("grind")    
550
             hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
570
             hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
551
             if grindold == 0:
571
             if grindold == 0:

Loading…
Cancel
Save