Browse Source

prepre_v2

shuvit 5 years ago
parent
commit
9276337883
1 changed files with 10 additions and 43 deletions
  1. 10
    43
      scripts/grindV2.py

+ 10
- 43
scripts/grindV2.py View File

@@ -11,14 +11,11 @@ def main():
11 11
     player = cont.owner
12 12
     scene = bge.logic.getCurrentScene()
13 13
     dict = bge.logic.globalDict
14
-    #grindDar = cont.sensors['grindDar']
15 14
     grindEmpty = scene.objects['grindEmpty']
16 15
     grindDar = grindEmpty.sensors['grindDar2']
17 16
     rGround = cont.sensors['r_Ground']
18 17
     control_bottom = scene.objects['control_bottom']
19
-    #grindCol_bottom
20 18
     grindTouch = control_bottom.sensors['grindCol_bottom']
21
-    #grindTouch = cont.sensors['grindCol']
22 19
     invertCol = cont.sensors['invertCol']
23 20
     invertObjs = invertCol.hitObjectList
24 21
     invert_on = own['invert_on']
@@ -26,13 +23,11 @@ def main():
26 23
     lastObject = own['grindTrackObj']
27 24
     nearestObject = None
28 25
     minDist = None
29
-    #act = cont.actuators["Target"]
30 26
     test = own["test"]
31 27
     grindold = own["grindOld"]
32 28
     lgobj = own["lGobj"]
33 29
     countdown = own['grindCountdown']
34
-    #print(lgobj)
35
-    ray = cont.sensors["GuardDuty"] # get the ray sensor attached to the controller named GuardDuty
30
+    ray = cont.sensors["gRay"] # get the ray sensor attached to the controller named GuardDuty
36 31
     gt_cd = own["gt_cd"]
37 32
     pos = ray.hitPosition # get position where the game object hit by ray
38 33
     linVelocity = own.getLinearVelocity(False)
@@ -45,7 +40,6 @@ def main():
45 40
     xyz = own.worldOrientation.to_euler()
46 41
     rotz = math.degrees(xyz[2])
47 42
     roty = math.degrees(xyz[1])
48
-    #print(roty)
49 43
     roty = abs(roty)
50 44
     sub = 0
51 45
     align_strength = .1#.3
@@ -92,13 +86,6 @@ def main():
92 86
         no_grind = 0
93 87
         own['no_grind_timer'] -= 1
94 88
 
95
-    
96
-
97
-    # if frames_since_ground > 30 or since_jumped < 120:
98
-    #     no_grind = 0
99
-    # if jump_timer > 50:
100
-    #     no_grind = 1
101
-
102 89
     if (own['fak_nmanual'] == 1 or own['reg_nmanual'] == 1 or own['fak_manual'] == 1 or own['reg_manual'] == 1):
103 90
         manual = 1
104 91
     else:
@@ -155,6 +142,7 @@ def main():
155 142
         convely = vely
156 143
     else:
157 144
         convely = vely
145
+
158 146
     def grindvect(obj):
159 147
         STANCE = own['stance']
160 148
         if obj != None:
@@ -224,6 +212,7 @@ def main():
224 212
                 #print("-90 reg stance")
225 213
                 own['stance'] = 0
226 214
                 STANCE = 0
215
+
227 216
     def grindrotvel(obj):
228 217
         joinit = 0
229 218
         grinder_e = obj.worldOrientation.to_euler()
@@ -245,6 +234,7 @@ def main():
245 234
         negbsrot = [0.0, 0.0, -1.570796327]
246 235
         zvel = own.linearVelocity
247 236
         zvel = zvel.z * .95
237
+
248 238
         if grindold == 0:
249 239
             if rotz < 0:
250 240
                 rotz = rotz + 360
@@ -256,7 +246,7 @@ def main():
256 246
                 sub_converted = rotzb - rotz
257 247
 
258 248
         #z align
259
-        #print("zalign")
249
+
260 250
         stre = .15#.075#.15
261 251
         player.alignAxisToVect(grinder_vectz, 2, stre)
262 252
 
@@ -276,7 +266,6 @@ def main():
276 266
             player.setLinearVelocity([0, convely, zvel], 1)
277 267
             grindpos = "reg_board"
278 268
             grindyvect = "pos"
279
-            #print("bs1, don't switch")
280 269
 
281 270
         elif rot >= 90 and rot < 135:
282 271
             grinder_vect = grinder_vect * -1
@@ -430,7 +419,6 @@ def main():
430 419
                 try:
431 420
                     delta = player_pos - grinder_pos
432 421
                 except:
433
-                    #print("delta broke: ", player_pos, grinder_pos)
434 422
                     pass
435 423
                 delta = delta.cross(vect)
436 424
                 if delta[2] >= 0:
@@ -449,7 +437,7 @@ def main():
449 437
                     grinder_e = obj.worldOrientation.to_euler()
450 438
                     grinder_rotz = math.degrees(grinder_e[2])
451 439
                     deltamove = delta[2] * .3
452
-                    #print(round(deltamove, 4), "deltamove")
440
+
453 441
                     #5050
454 442
                     if own["grindpos"] == "reg_5050":
455 443
                         #print("missing delta")
@@ -554,7 +542,7 @@ def main():
554 542
         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 or dict['rBump'] == 1 or dict['lBump'] == 1):
555 543
             #print("grinding")
556 544
             grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
557
-            #worldPos = own.worldPosition
545
+
558 546
             if grind_height_dif > -.05:#02:
559 547
 
560 548
                 if own['grinder_rot'] != None:
@@ -564,8 +552,6 @@ def main():
564 552
                         print('skipping grind, angle is', dif)
565 553
                         skipper = 1
566 554
 
567
-
568
-                    #print((grot - own['grinder_rot']), 'grinder_rot')
569 555
                 own['grinder_rot'] = nearestObject.getAxisVect([1, 0, 0]).x
570 556
                 if skipper != 1:
571 557
                     grindvect(nearestObject)
@@ -581,12 +567,9 @@ def main():
581 567
                             if hitNormal != None:
582 568
                                 stre = .15
583 569
                                 own.alignAxisToVect(hitNormal, 2, stre)
584
-                                #print("align")
585
-                            #own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
586
-                            print('new moving world')
570
+
587 571
 
588 572
     else:
589
-        #grindold = False
590 573
         own['grindold_timer'] += 1
591 574
         own["grindHit"] = False
592 575
         own['inverting'] = False
@@ -625,7 +608,6 @@ def main():
625 608
         lgobj = ray.hitObject
626 609
         own['lGobj'] = lgobj
627 610
         obj = ray.hitObject
628
-        #prop = obj.get("property", None)
629 611
         linVelocity3 = own.getLinearVelocity(True)
630 612
         grindpos2 = own["grindpos"]
631 613
         if obj is not None:
@@ -662,9 +644,7 @@ def main():
662 644
                 nearestObject = obj
663 645
                 minDist = dist
664 646
         vect = nearestObject.getAxisVect([1.0, 0.0, 0.0])
665
-        #own.alignAxisToVect(vect, 0, 0)
666 647
         own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
667
-       #own.setLinearVelocity([0, 0.0, 0], 1)
668 648
 
669 649
     def set_pregrind_vel():
670 650
         if grindDar.triggered == False and ray.triggered == False:
@@ -691,29 +671,18 @@ def main():
691 671
             nearpos = obj.worldPosition
692 672
         except:
693 673
             pass
694
-    #if ray.triggered == False:
695
-        #own["nogrindsound"] = 1
674
+
696 675
     def slow_roty():
697
-      #print(abs(roty - own['last_roty']))
698
-      #print(roty)
699 676
 
700
-      #if roted > 5:
701
-        #pass
702
-        #align slow
703 677
         constraint = cont.actuators['gConstraint']
704 678
         if (own['framenum'] - own['grind_start_frame'] < 40) and touched == 1:
705
-          #print('limit rot')
706
-          #constraint.damp = 80
707
-        #else:
708
-          #constraint.damp = 30
709
-        #constraint.rotDamp = 80
710 679
             cont.activate(constraint)
711 680
         else:
712 681
             cont.deactivate(constraint)
713 682
     timer()
714 683
     aligntimer()
715 684
     stop_bounce()
716
-    slow_roty()
685
+    #slow_roty()
717 686
 
718 687
 
719 688
     own['grindOld'] = grindold
@@ -729,5 +698,3 @@ def main():
729 698
     set_pregrind_vel()
730 699
     own['last_z'] = own.worldPosition.z
731 700
     own["manual"] = manual
732
-
733
-

Loading…
Cancel
Save