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

Loading…
Cancel
Save