Browse Source

grind fixes

shuvit 6 years ago
parent
commit
79e6fca2a5
5 changed files with 63 additions and 39 deletions
  1. 9
    1
      Manager.py
  2. 4
    2
      controller2.py
  3. 42
    33
      grindV2.py
  4. 2
    1
      scene_init.py
  5. 6
    2
      walk.py

+ 9
- 1
Manager.py View File

353
             camspeed2 = .1 #.055
353
             camspeed2 = .1 #.055
354
             camrot1 = .02 #.005
354
             camrot1 = .02 #.005
355
             camrot2 = .04 #.02
355
             camrot2 = .04 #.02
356
+#            perc = (lUD * 100 * (10 / 80)) *2
357
+#            perc = round(perc,2)
358
+#            print(perc)
359
+#            perc = .025 * perc
360
+#            newUD = (lUD * .1) * 5
361
+#            if lUD > .0005 or lUD < -.0005:
362
+#                camspeed1 = abs(perc)
363
+#                camspeed2 = abs(perc)
356
             #up
364
             #up
357
             if lUD < -0.080:
365
             if lUD < -0.080:
358
                 followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
366
                 followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
359
                 cont.activate(followcam.actuators["up"])
367
                 cont.activate(followcam.actuators["up"])
360
-                #print("fastup")
368
+                print("fastup")
361
             else:
369
             else:
362
                 cont.deactivate(followcam.actuators["up"])    
370
                 cont.deactivate(followcam.actuators["up"])    
363
     #            #down    
371
     #            #down    

+ 4
- 2
controller2.py View File

2205
                 own['airup'] = 1
2205
                 own['airup'] = 1
2206
             if pos > own['last_posz']:
2206
             if pos > own['last_posz']:
2207
                 own["air_height"] = pos  
2207
                 own["air_height"] = pos  
2208
-            own['last_posz'] = pos
2209
-            
2208
+            own['last_posz'] = pos   
2209
+        else:
2210
+            own['airup'] = 0  
2211
+              
2210
     def onramp():
2212
     def onramp():
2211
         if r_ground.positive:
2213
         if r_ground.positive:
2212
             if 'ramp' in r_ground.hitObject:
2214
             if 'ramp' in r_ground.hitObject:

+ 42
- 33
grindV2.py View File

116
          velx = linVelocity2.x
116
          velx = linVelocity2.x
117
          vely = linVelocity2.y     
117
          vely = linVelocity2.y     
118
     if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
118
     if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
119
-        convely = own['pregrind_vely']
119
+        #convely = own['pregrind_vely']
120
+        #print('changing convely')
121
+        convely = vely
120
     else:
122
     else:
121
         convely = vely  
123
         convely = vely  
122
     def grindvect(obj):
124
     def grindvect(obj):
478
                 minDist = dist
480
                 minDist = dist
479
         if nearestObject != None:                            
481
         if nearestObject != None:                            
480
             own.linearVelocity.x = 0
482
             own.linearVelocity.x = 0
481
-            own.linearVelocity.y = 0
482
-               
483
-            
483
+            own.linearVelocity.y = 0            
484
     
484
     
485
-    if grindDar.positive == False and grindTouch.positive 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 own['air_mover'] == False:
485
+    if grindDar.positive == False and grindTouch.triggered 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 own['air_mover'] == False:
486
         #print("touching, no dar")
486
         #print("touching, no dar")
487
         pass
487
         pass
488
     #print(grindold, "grindold")        
488
     #print(grindold, "grindold")        
489
-    if grindDar.positive:
490
-        detectedObjects = grindDar.hitObjectList
491
-        dist = 0
492
-        for obj in detectedObjects:
493
-            dist = own.getDistanceTo(obj)
494
-            if (minDist is None or dist < minDist):
495
-                nearestObject = obj
496
-                minDist = dist     
489
+    if grindDar.positive or grindTouch.positive:        
490
+        if grindDar.positive:
491
+            detectedObjects = grindDar.hitObjectList
492
+            dist = 0
493
+            for obj in detectedObjects:
494
+                dist = own.getDistanceTo(obj)
495
+                if (minDist is None or dist < minDist):
496
+                    nearestObject = obj
497
+                    minDist = dist     
498
+        elif grindTouch.positive:
499
+            nearestObject = grindTouch.hitObject
500
+            dist = .7
501
+            #print('using touch object')                    
497
         
502
         
498
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
503
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
499
         #init grind
504
         #init grind
504
         else:
509
         else:
505
             own['inverting'] = False
510
             own['inverting'] = False
506
         grind_dist = .8#.6
511
         grind_dist = .8#.6
507
-        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 and own['air_mover'] == False and no_grind_pull == 0:   
508
-            #print("new grind trigger")           
509
-            npos = nearestObject.worldPosition
510
-            
511
-            
512
-        #grind
513
-        #print(dist)
514
-        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'] < 55 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0 and own['last_invert'] == False:
515
-            #print("grind")    
512
+
513
+        if dist < grind_dist and dropin == 0 and manual == 0 and no_grind == 0 and own['grindoutturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 40 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0 and own['last_invert'] == False and own['grindjumpturn'] == 0 and grind_jump == 0 and own['airup'] == 0:
514
+            #print('grind')      
516
             hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
515
             hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
517
             if grindold == 0:
516
             if grindold == 0:
518
-                if grindTouch.positive:
517
+                if grindTouch.triggered:
519
                     nearpos = nearestObject.worldPosition
518
                     nearpos = nearestObject.worldPosition
520
                     if hitNormal != None:
519
                     if hitNormal != None:
521
                         stre = .05
520
                         stre = .05
523
                         #print("align")                   
522
                         #print("align")                   
524
                     own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
523
                     own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
525
                     #print('moving world')
524
                     #print('moving world')
526
-
527
-
528
             #print("grinding")
525
             #print("grinding")
529
             grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
526
             grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
530
             worldPos = own.worldPosition
527
             worldPos = own.worldPosition
534
                 grind(nearestObject)
531
                 grind(nearestObject)
535
                 grindold = True
532
                 grindold = True
536
                 own['grindold_timer'] = 0
533
                 own['grindold_timer'] = 0
537
-                own["grindHit"] = True                
538
-
534
+                own["grindHit"] = True
535
+                own['grindnew_timer'] += 1
536
+                
537
+                if own['grindnew_timer'] < 1:
538
+                    if grindTouch.triggered:
539
+                        nearpos = nearestObject.worldPosition
540
+                        if hitNormal != None:
541
+                            stre = .05
542
+                            own.alignAxisToVect(hitNormal, 2, stre) 
543
+                            #print("align")                   
544
+                        own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
545
+                        print('new moving world')                    
539
 
546
 
540
     else:
547
     else:
541
         #grindold = False 
548
         #grindold = False 
548
         own['grind_start_frame'] = framenum
555
         own['grind_start_frame'] = framenum
549
         own["grindSound"] = None
556
         own["grindSound"] = None
550
     
557
     
551
-    
558
+    if own['grindHit'] == False:
559
+        own['grindnew_timer'] = 0  
560
+ 
552
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    
561
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    
553
        
562
        
554
 #if you are touching grinder and last_manual is off keep manual off
563
 #if you are touching grinder and last_manual is off keep manual off
616
         #own.alignAxisToVect(vect, 0, 0)
625
         #own.alignAxisToVect(vect, 0, 0)
617
         own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
626
         own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
618
        #own.setLinearVelocity([0, 0.0, 0], 1)                    
627
        #own.setLinearVelocity([0, 0.0, 0], 1)                    
619
-
620
-
621
-
622
             
628
             
623
     def set_pregrind_vel():
629
     def set_pregrind_vel():
624
         if grindDar.triggered == False and ray.triggered == False:
630
         if grindDar.triggered == False and ray.triggered == False:
639
         
645
         
640
     if grindDar_timer > 0:
646
     if grindDar_timer > 0:
641
         grindDar_timer -= 1
647
         grindDar_timer -= 1
642
-    if grindDar_timer > 0 and ray.triggered == False and touched == True  and own['footplant_on'] == False and manual == 0:
648
+    if ray.triggered == False and touched == True  and own['footplant_on'] == False and manual == 0 and own['gt_cd2'] < 55 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 :        
643
         obj = grindTouch.hitObject 
649
         obj = grindTouch.hitObject 
644
-        own.worlPosition = obj.worldPosition
650
+        try:
651
+            nearpos = obj.worldPosition
652
+        except:
653
+            pass    
645
     if ray.triggered == False:
654
     if ray.triggered == False:
646
         own["nogrindsound"] = 1                               
655
         own["nogrindsound"] = 1                               
647
     timer()    
656
     timer()    

+ 2
- 1
scene_init.py View File

150
     cam['sun_pos_y'] = dict['sun_rot_y']
150
     cam['sun_pos_y'] = dict['sun_rot_y']
151
     #cam['shadow_on'] = dict['shadow_on']
151
     #cam['shadow_on'] = dict['shadow_on']
152
     cam['dof_on'] = dict['dof_on']
152
     cam['dof_on'] = dict['dof_on']
153
-    cam['bloom_on'] = dict['bloom_on']    
153
+    cam['bloom_on'] = dict['bloom_on'] 
154
+    own['grindnew_timer'] = 0   
154
            
155
            
155
 main()
156
 main()

+ 6
- 2
walk.py View File

342
             trucks.stopAction(truckon)
342
             trucks.stopAction(truckon)
343
             own['requestAction'] = 'fak_offboard'                          
343
             own['requestAction'] = 'fak_offboard'                          
344
 def jump():
344
 def jump():
345
+    #limit fall speed
346
+    if linvel.z < -10:
347
+        own.linearVelocity.z = -10
345
     if xBut == True or dict['kb_space'] == 1: 
348
     if xBut == True or dict['kb_space'] == 1: 
346
         if own['lastx'] == 0:
349
         if own['lastx'] == 0:
347
             killact(3)
350
             killact(3)
359
             force = [ 0.0, 0.0, JUMPHEIGHT]
362
             force = [ 0.0, 0.0, JUMPHEIGHT]
360
             # use local axis
363
             # use local axis
361
             local = False
364
             local = False
362
-            # apply force
363
-            own.applyForce(force, local)
365
+            # apply force -- limit jump speed
366
+            if linvel.z < 10:
367
+                own.applyForce(force, local)
364
         own['lastx'] = 1
368
         own['lastx'] = 1
365
     else:
369
     else:
366
         own['lastx'] = 0
370
         own['lastx'] = 0

Loading…
Cancel
Save