Browse Source

joytimers rewrite

shuvit 8 months ago
parent
commit
87404093dd
2 changed files with 171 additions and 539 deletions
  1. 91
    539
      scripts/controller2.py
  2. 80
    0
      scripts/joytimers.py

+ 91
- 539
scripts/controller2.py View File

@@ -9,37 +9,18 @@ import math
9 9
 from sys import platform
10 10
 from mathutils import Vector
11 11
 import mathutils
12
+import joytimers
12 13
 
13 14
 def main():
14 15
     scene = bge.logic.getCurrentScene()
15 16
 
16
-    #initialize quadrant variables
17
-    q1on = 0
18
-    q2on = 0
19
-    q3on = 0
20
-    q4on = 0
21
-    q5on = 0
22
-    q6on = 0
23
-    q7on = 0
24
-    q8on = 0
25
-    lq1on = 0
26
-    lq2on = 0
27
-    lq3on = 0
28
-    lq4on = 0
29
-    lq5on = 0
30
-    lq6on = 0
31
-    lq7on = 0
32
-    lq8on = 0
33
-
34 17
     #number of frames / length of the location timers
35 18
     countdown = 20
36 19
 
37
-
38 20
     cont = GameLogic.getCurrentController()
39 21
     char = bge.constraints.getCharacter
40 22
     own = cont.owner
41 23
     dict = bge.logic.globalDict #Get the global dictionary
42
-    #dict['trick_string'] = ''
43 24
 
44 25
     #last frame stuff
45 26
     lGRAB_ON = own["lGRAB_ON"]
@@ -77,9 +58,7 @@ def main():
77 58
     pumpon = own["Pump"]
78 59
     vib_countdown = own["vib_Countdown"]
79 60
     grindold = own['grindOld']
80
-    #grindHit = own["LAST_GRIND"]
81 61
     LAST_GRIND = own["LAST_GRIND"]
82
-    #grindTouch = cont.sensors['grindCol']
83 62
     grindTouch = cont.sensors['grindCol_bottom']
84 63
     touched = grindTouch.triggered
85 64
     leftgrabon = own["Leftgrabon"]
@@ -97,7 +76,6 @@ def main():
97 76
     pos = own.localPosition
98 77
     rot = own.getAxisVect([0.0, 0.0, 1.0])
99 78
     gray = cont.sensors["gRay"]
100
-    #airconst = cont.actuators["airConst"]
101 79
     pop = cont.actuators["pop"]
102 80
     grindHit = own["grindHit"]
103 81
     grindCement = cont.actuators["grind_cement"]
@@ -139,23 +117,6 @@ def main():
139 117
     own['grinding'] = False
140 118
     #own['fall'] = 0
141 119
 
142
-    #joystick location timers
143
-    q1oncd = own["Q1oncd"]
144
-    q2oncd = own["Q2oncd"]
145
-    q3oncd = own["Q3oncd"]
146
-    q4oncd = own["Q4oncd"]
147
-    q5oncd = own["Q5oncd"]
148
-    q6oncd = own["Q6oncd"]
149
-    q7oncd = own["Q7oncd"]
150
-    q8oncd = own["Q8oncd"]
151
-    q1oncdl = own["Q1oncdl"]
152
-    q2oncdl = own["Q2oncdl"]
153
-    q3oncdl = own["Q3oncdl"]
154
-    q4oncdl = own["Q4oncdl"]
155
-    q5oncdl = own["Q5oncdl"]
156
-    q6oncdl = own["Q6oncdl"]
157
-    q7oncdl = own["Q7oncdl"]
158
-    q8oncdl = own["Q8oncdl"]
159 120
     fliplay = 3
160 121
 
161 122
     #setable
@@ -203,8 +164,9 @@ def main():
203 164
     land_overRideLb = False
204 165
     land_overRideRb = False
205 166
 
206
-
207
-    #print(linVelocity, 'linvely')
167
+    joytimers.main(own)
168
+    sr = own['jsr']
169
+    sl = own['jsl']
208 170
 
209 171
     #2019 ground ray detection
210 172
     Axis = 2
@@ -217,19 +179,13 @@ def main():
217 179
         groundRay = own.rayCast(End, Start, 10,'ground', 1, 0, 0, 61439)
218 180
     grindRay = own.rayCast(End, Start, 1,'grind', 1, 1, 0, 61439)
219 181
     
220
-    #bge.render.drawLine(Start, End, [255,0,0])
221
-
222 182
     if groundRay[0]:
223 183
 
224 184
         localHitDist = (own.worldPosition - groundRay[1]).length
225 185
         if localHitDist < .4 and own['jump_timer'] < 32:
226 186
             onGround = True
227
-            #print('rayed', localHitDist)
228 187
         else:
229
-            
230 188
             onGround = False   
231
-            #print('jumptimer', own['jump_timer'])
232
-            #print('not on ground', localHitDist, own['jump_timer']) 
233 189
        
234 190
     else:
235 191
         #if own['LAST_GRIND'] == True:
@@ -339,29 +295,6 @@ def main():
339 295
             deck.stopAction(x)
340 296
             trucks.stopAction(x)
341 297
 
342
-    def reset_rtimers_done():
343
-        pass
344
-        #print('rtimer reset:', q1oncd, q2oncd, q3oncd, q4oncd, q5oncd, q6oncd, q7oncd, q8oncd)
345
-
346
-    def reset_rtimers():
347
-        own["Q1oncd"] = 0
348
-        own["Q2oncd"] = 0
349
-        own["Q3oncd"] = 0
350
-        own["Q4oncd"] = 0
351
-        own["Q5oncd"] = 0
352
-        own["Q6oncd"] = 0
353
-        own["Q7oncd"] = 0
354
-        own["Q8oncd"] = 0
355
-        q1oncd = 0
356
-        q2oncd = 0
357
-        q3oncd = 0
358
-        q4oncd = 0
359
-        q5oncd = 0
360
-        q6oncd = 0
361
-        q7oncd = 0
362
-        q8oncd = 0
363
-        reset_rtimers_done()
364
-
365 298
     def check_fall():
366 299
         playing_frame = 20
367 300
         #hitDistance = own.worldPosition.z - r_ground.hitPosition.z
@@ -912,14 +845,6 @@ def main():
912 845
                 jump_timer = 60
913 846
                 own['jump_timer'] = jump_timer
914 847
 
915
-                own["Q1oncd"] = 0
916
-            own["Q2oncd"] = 0
917
-            own["Q3oncd"] = 0
918
-            own["Q4oncd"] = 0
919
-            own["Q5oncd"] = 0
920
-            own["Q6oncd"] = 0
921
-            own["Q7oncd"] = 0
922
-            own["Q8oncd"] = 0
923 848
         if own['jump_timer'] == 60:
924 849
             own['jump_timer'] = 59
925 850
 
@@ -2626,11 +2551,6 @@ def main():
2626 2551
         pass
2627 2552
 
2628 2553
     def revert():
2629
-        own["Q3oncdl"] = 0
2630
-        own["Q4oncdl"] = 0
2631
-        own["Q5oncdl"] = 0
2632
-        own["Q6oncdl"] = 0
2633
-        own["Q7oncdl"] = 0
2634 2554
         local = True
2635 2555
         rot = [0.0, 0.0, 3.14]
2636 2556
         own.applyRotation(rot, local)
@@ -2657,11 +2577,6 @@ def main():
2657 2577
         dict['trick_string'] = 'Revert'
2658 2578
 
2659 2579
     def revert2():
2660
-        own["Q3oncdl"] = 0
2661
-        own["Q4oncdl"] = 0
2662
-        own["Q5oncdl"] = 0
2663
-        own["Q6oncdl"] = 0
2664
-        own["Q7oncdl"] = 0
2665 2580
         local = True
2666 2581
         rot = [0.0, 0.0, -3.14]
2667 2582
         own.applyRotation(rot, local)
@@ -2684,11 +2599,6 @@ def main():
2684 2599
         dict['trick_string'] = 'Revert'
2685 2600
 
2686 2601
     def revert3():
2687
-        own["Q7oncdl"] = 0
2688
-        own["Q8oncdl"] = 0
2689
-        own["Q1oncdl"] = 0
2690
-        own["Q2oncdl"] = 0
2691
-        own["Q3oncdl"] = 0
2692 2602
         local = True
2693 2603
         rot = [0.0, 0.0, 3.14]
2694 2604
         own.applyRotation(rot, local)
@@ -2711,11 +2621,6 @@ def main():
2711 2621
         dict['trick_string'] = 'Revert'
2712 2622
 
2713 2623
     def revert4():
2714
-        own["Q7oncdl"] = 0
2715
-        own["Q8oncdl"] = 0
2716
-        own["Q1oncdl"] = 0
2717
-        own["Q2oncdl"] = 0
2718
-        own["Q3oncdl"] = 0
2719 2624
         local = True
2720 2625
         rot = [0.0, 0.0, 3.14]
2721 2626
         own.applyRotation(rot, local)
@@ -2858,151 +2763,34 @@ def main():
2858 2763
     #    q6    q4
2859 2764
     #       q5
2860 2765
     ##################
2861
-    #lq6
2862
-    if lUD > .04 and lLR < -0.04:
2863
-        lq6on = 1
2864
-        q6oncdl = countdown
2865
-        own["Q6oncdl"] = q6oncdl
2866
-    elif q6oncdl > 0:
2867
-        lq6on = 0
2868
-        q6oncdl = q6oncdl - 1
2869
-        own["Q6oncdl"] = q6oncdl
2870
-    #lq8
2871
-    if lUD < -.04 and lLR < -0.04:
2872
-        lq8on = 1
2873
-        q8oncdl = countdown
2874
-        own["Q8oncdl"] = q8oncdl
2875
-    elif q8oncdl > 0:
2876
-        lq8on = 0
2877
-        q8oncdl = q8oncdl - 1
2878
-        own["Q8oncdl"] = q8oncdl
2879
-    #lq2
2880
-    if lUD < -.04 and lLR > 0.04:
2881
-        lq2on = 1
2882
-        q2oncdl = countdown
2883
-        own["Q2oncdl"] = q2oncdl
2884
-    elif q2oncdl > 0:
2885
-        lq2on = 0
2886
-        q2oncdl = q2oncdl - 1
2887
-        own["Q2oncdl"] = q2oncdl
2888
-    #q4
2889
-    if lUD > 0.04 and lLR > 0.04:
2890
-        lq4on = 1
2891
-        q4oncdl = countdown
2892
-        own["Q4oncdl"] = q4oncdl
2893
-    elif q4oncdl > 0:
2894
-        lq4on = 0
2895
-        q4oncdl = q4oncdl - 1
2896
-        own["Q4oncdl"] = q4oncdl
2897
-    #q5
2898
-    if lUD > .070 and lq4on == 0 and lq6on == 0:
2899
-        lq5on = 1
2900
-        q5oncdl = countdown
2901
-        own["Q5oncdl"] = q5oncdl
2902
-    elif q5oncdl > 0:
2903
-        lq5on = 0
2904
-        q5oncdl = q5oncdl - 1
2905
-        own["Q5oncdl"] = q5oncdl
2906
-    #q1
2907
-    if lUD < -0.070 and lq8on != 1 and lq2on != 1:
2908
-        lq1on = 1
2909
-        q1oncdl = countdown
2910
-        own["Q1oncdl"] = q1oncdl
2911
-    elif q1oncdl > 0:
2912
-        lq1on = 0
2913
-        q1oncdl = q1oncdl - 1
2914
-        own["Q1oncdl"] = q1oncdl
2915
-    #q7
2916
-    if lLR < -0.070 and lq8on != 1 and lq6on != 1:
2917
-        lq7on = 1
2918
-        q7oncdl = countdown
2919
-        own["Q7oncdl"] = q7oncdl
2920
-    elif q7oncdl > 0:
2921
-        lq7on = 0
2922
-        q7oncdl = q7oncdl - 1
2923
-        own["Q7oncdl"] = q7oncdl
2924
-    #q3
2925
-    if lLR > 0.070 and lq2on != 1 and lq4on != 1:
2926
-        lq3on = 1
2927
-        q3oncdl = countdown
2928
-        own["Q3oncdl"] = q3oncdl
2929
-    elif q3oncdl > 0:
2930
-        lq3on = 0
2931
-        q3oncdl = q3oncdl - 1
2932
-        own["Q3oncdl"] = q3oncdl
2933
-
2766
+    
2934 2767
     own['set_revert_timer'] = 0
2935 2768
     ground_since = own["framenum"] - own['lF_air_frame']
2936 2769
     if (ground_since > 80 and frames_since_grinding > 40) and ((rLR > -turnsens and rLR < turnsens and rUD > -turnsens and rUD < turnsens) or own['manual'] == 1):
2937 2770
 
2938
-        if q3oncdl < q4oncdl < q5oncdl < q6oncdl < q7oncdl:
2771
+        if sl.q3 < sl.q4 < sl.q5 < sl.q6 < sl.q7:
2939 2772
             if onGround:
2940 2773
                 revert()
2774
+                sl.reset()
2941 2775
                 own['set_revert_timer'] = 1
2942
-        if q3oncdl > q4oncdl > q5oncdl > q6oncdl > q7oncdl:
2776
+        if sl.q3 > sl.q4 > sl.q5 > sl.q6 > sl.q7:
2943 2777
             if onGround:
2944 2778
                 revert2()
2779
+                sl.reset()
2945 2780
                 own['set_revert_timer'] = 1
2946
-        if q7oncdl < q8oncdl < q1oncdl < q2oncdl < q3oncdl:
2781
+        if sl.q7 < sl.q8 < sl.q1 < sl.q2 < sl.q3:        
2947 2782
             if onGround:
2948 2783
                 revert3()
2949 2784
                 own['set_revert_timer'] = 1
2950
-        if q7oncdl > q8oncdl > q1oncdl > q2oncdl > q3oncdl:
2785
+                sl.reset()
2786
+        if sl.q7 > sl.q8 > sl.q1 > sl.q2 > sl.q3:
2951 2787
             if onGround:
2952 2788
                 revert4()
2953 2789
                 own['set_revert_timer'] = 1
2954
-    ################
2955
-    #q6
2956
-    if rUD > .04 and rLR < -0.04:
2957
-        q6on = 1
2958
-        q6oncd = countdown
2959
-        own["Q6oncd"] = q6oncd
2960
-        #print("q6on")
2961
-    elif q6oncd > 0:
2962
-        q6on = 0
2963
-        q6oncd = q6oncd - 1
2964
-        own["Q6oncd"] = q6oncd
2965
-
2966
-    #q8
2967
-    if rUD < -.04 and rLR < -0.04:
2968
-        q8on = 1
2969
-        q8oncd = countdown
2970
-        own["Q8oncd"] = q8oncd
2971
-        #print("q8on")
2972
-    elif q8oncd > 0:
2973
-        q8on = 0
2974
-        q8oncd = q8oncd - 1
2975
-        own["Q8oncd"] = q8oncd
2976
-    #q2
2977
-    if rUD < -.04 and rLR > 0.04:
2978
-        q2on = 1
2979
-        q2oncd = countdown
2980
-        own["Q2oncd"] = q2oncd
2981
-        #print("q2on")
2982
-    elif q2oncd > 0:
2983
-        q2on = 0
2984
-        q2oncd = q2oncd - 1
2985
-        own["Q2oncd"] = q2oncd
2986
-
2987
-    #q4
2988
-    if rUD > 0.04 and rLR > 0.04:
2989
-        q4on = 1
2990
-        q4oncd = countdown
2991
-        own["Q4oncd"] = q4oncd
2992
-        #print("q4on")
2993
-    elif q4oncd > 0:
2994
-        q4on = 0
2995
-        q4oncd = q4oncd - 1
2996
-        own["Q4oncd"] = q4oncd
2997
-    #q5
2790
+                sl.reset()
2791
+
2998 2792
     if rUD > .070 or dict['kb_space'] == 2:
2999
-        if q4on == 0 and q6on == 0:
3000
-            #print("q5on")
3001
-            q5on = 1
3002
-            q5oncd = countdown
3003
-            own["Q5oncd"] = q5oncd
3004 2793
         oposin()
3005
-        #print('oposin')
3006 2794
     ground_since = own["framenum"] - own['lF_air_frame']
3007 2795
     if ((rTrig > 0.02 or dict['kb_lsh'] == 2) and GRAB_ON == False and onGround) or (lTrig > 0.02 and GRAB_ON == False and onGround) and ground_since > 10:
3008 2796
         pump()
@@ -3063,25 +2851,17 @@ def main():
3063 2851
                 if jumpstance == 1:
3064 2852
                     grindtype("fak_tailg")
3065 2853
 
3066
-    if q5oncd > 0:
3067
-        q5on = 0
3068
-        q5oncd = q5oncd - 1
3069
-        own["Q5oncd"] = q5oncd
2854
+    #if q5oncd > 0:
2855
+    if sl.q5 > 0:
3070 2856
         own["last_Opos"] = False
3071 2857
     #q1
3072 2858
     if rUD < -0.070:
3073
-        if q2on == 0 and q8on == 0:
3074
-            #print("q1on")
3075
-            q1on = 1
3076
-            q1oncd = countdown
3077
-            own["Q1oncd"] = q1oncd
3078 2859
         noposin()
3079 2860
     if rUD < -0.020 and grindHit == True:
3080 2861
         grindpos = own['grindpos']
3081 2862
         jumpstance = own["jump_stance"]
3082 2863
         if LAST_GRIND == False:
3083 2864
             if grindpos == "reg_5050":
3084
-                #print("nose something")
3085 2865
                 if jumpstance != 3:
3086 2866
                     if jumpstance == 0:
3087 2867
                         if rLR > .02:
@@ -3132,32 +2912,8 @@ def main():
3132 2912
         if own['grindpos'] == 'fak_5050':
3133 2913
             grindtype("fak_5050")
3134 2914
 
3135
-    if q1oncd > 0:
3136
-        q1on = 0
3137
-        q1oncd = q1oncd - 1
3138
-        own["Q1oncd"] = q1oncd
2915
+    if sl.q1 > 0:
3139 2916
         own["last_nOpos"] = False
3140
-    #q7
3141
-    if rLR < -0.070:
3142
-        if q8on == 0 and q6on == 0:
3143
-            q7on = 1
3144
-            q7oncd = countdown
3145
-            own["Q7oncd"] = q7oncd
3146
-    elif q7oncd > 0:
3147
-        q7on = 0
3148
-        q7oncd = q7oncd - 1
3149
-        own["Q7oncd"] = q7oncd
3150
-    #q3
3151
-    if rLR > 0.070:
3152
-        if q4on == 0 and q2on == 0:
3153
-            q3on = 1
3154
-            q3oncd = countdown
3155
-            own["Q3oncd"] = q3oncd
3156
-            #print("q3on")
3157
-    elif q3oncd > 0:
3158
-        q3on = 0
3159
-        q3oncd = q3oncd - 1
3160
-        own["Q3oncd"] = q3oncd
3161 2917
 
3162 2918
 ###keyboard fliptricks
3163 2919
     if dict['kb_space'] == 3:
@@ -3176,335 +2932,130 @@ def main():
3176 2932
 ##########################################
3177 2933
     #trick calls
3178 2934
 ##########################################
3179
-
2935
+    
3180 2936
     # hard flip
3181 2937
     # 6 > 5 > 8
3182
-    if q6oncd > 0 and q5oncd > 0 and q8oncd > 0 and q6oncd <= q5oncd <= q8oncd:
3183
-        print ("Hardflip")
2938
+    if sr.q6 > 0 and sr.q5 > 0 and sr.q8 > 0 and sr.q6 <= sr.q5 <= sr.q8:   
2939
+        print ("Hardflip --- 2")
3184 2940
         dict['trick_string'] = 'Hardflip'
3185 2941
         hardflip()
3186
-        reset_rtimers()
3187
-        q1oncd = 0
3188
-        q2oncd = 0
3189
-        q3oncd = 0
3190
-        q4oncd = 0
3191
-        q5oncd = 0
3192
-        q6oncd = 0
3193
-        q7oncd = 0
3194
-        q8oncd = 0
2942
+        sr.reset()
3195 2943
 
3196 2944
     # inward heelflip
3197 2945
     # 4 > 5 > 2
3198
-    if q4oncd > 0 and q5oncd > 0 and q2oncd > 0 and q4oncd <= q5oncd <= q2oncd:
3199
-        print ("Inward Heelflip")
3200
-        dict['trick_string'] = 'Inward Heelflip'
2946
+    if sr.q4 > 0 and sr.q5 > 0 and sr.q2 > 0 and sr.q4 <= sr.q5 <= sr.q2:
3201 2947
         inward_heelflip()
3202
-        reset_rtimers()
3203
-        q1oncd = 0
3204
-        q2oncd = 0
3205
-        q3oncd = 0
3206
-        q4oncd = 0
3207
-        q5oncd = 0
3208
-        q6oncd = 0
3209
-        q7oncd = 0
3210
-        q8oncd = 0
2948
+        sr.reset()
3211 2949
 
3212 2950
     # nollie hard flip
3213 2951
     # 8 > 1 > 6
3214
-    if q8oncd > 0 and q1oncd > 0 and q6oncd > 0 and q8oncd <= q1oncd <= q6oncd:
3215
-        print ("Nollie Hardflip")
3216
-        dict['trick_string'] = 'Nollie Hardflip'
2952
+    if sr.q8 > 0 and sr.q1 > 0 and sr.q6 > 0 and sr.q8 <= sr.q1 <= sr.q6:
3217 2953
         nollie_hardflip()
3218
-        reset_rtimers()
3219
-        q1oncd = 0
3220
-        q2oncd = 0
3221
-        q3oncd = 0
3222
-        q4oncd = 0
3223
-        q5oncd = 0
3224
-        q6oncd = 0
3225
-        q7oncd = 0
3226
-        q8oncd = 0
2954
+        sr.reset()
3227 2955
 
3228 2956
     # nollie inward heelflip
3229 2957
     # 2 > 1 > 4
3230
-    if q2oncd > 0 and q1oncd > 0 and q4oncd > 0 and q2oncd <= q1oncd <= q4oncd:
3231
-        print ("Nollie Inward Heelflip")
3232
-        dict['trick_string'] = 'Nollie Inward Heelflip'
2958
+    if sr.q2 > 0 and sr.q1 > 0 and sr.q4 > 0 and sr.q2 <= sr.q1 <= sr.q4:
3233 2959
         nollie_inward_heelflip()
3234
-        reset_rtimers()
3235
-        q1oncd = 0
3236
-        q2oncd = 0
3237
-        q3oncd = 0
3238
-        q4oncd = 0
3239
-        q5oncd = 0
3240
-        q6oncd = 0
3241
-        q7oncd = 0
3242
-        q8oncd = 0
2960
+        sr.reset()
3243 2961
 
3244 2962
     #nollie 360 shuvit
3245
-    if q7oncd > 0 and q8oncd > 0 and q1oncd > 0 and q2oncd > 0 and q3oncd > 0 and q7oncd <= q8oncd <= q1oncd <= q2oncd <= q3oncd:
3246
-        print ("Nollie 360 shuvit")
3247
-        dict['trick_string'] = 'Nollie 360 shuvit'
2963
+    if sr.q7 > 0 and sr.q8 > 0 and sr.q1 > 0 and sr.q2 > 0 and sr.q3 > 0 and sr.q7 <= sr.q8 <= sr.q1 <= sr.q2 <= sr.q3:
3248 2964
         nollie_shuvit360()
3249
-        reset_rtimers()
3250
-        q1oncd = 0
3251
-        q2oncd = 0
3252
-        q3oncd = 0
3253
-        q4oncd = 0
3254
-        q5oncd = 0
3255
-        q6oncd = 0
3256
-        q7oncd = 0
3257
-        q8oncd = 0
2965
+        sr.reset()
2966
+        print('*nollie 360 shuvit')
3258 2967
 
3259 2968
     #nollie fs 360 shuvit
3260
-    if q7oncd > 0 and q8oncd > 0 and q1oncd > 0 and q2oncd > 0 and q3oncd > 0 and q3oncd <= q2oncd <= q1oncd <= q8oncd <= q7oncd:
3261
-        #print("q4oncd: ", q4oncd, " q5oncd: ", q5oncd, " q6oncd: ", q6oncd)
3262
-        print ("Nollie Front Side 360 shuvit")
3263
-        dict['trick_string'] = 'Nollie FS 360 shuvit'
2969
+    if sr.q7 > 0 and sr.q8 > 0 and sr.q1 > 0 and sr.q2 > 0 and sr.q3 > 0 and sr.q3 <= sr.q2 <= sr.q1 <= sr.q8 <= sr.q7:
3264 2970
         nollie_fsshuvit360()
3265
-        reset_rtimers()
3266
-        q1oncd = 0
3267
-        q2oncd = 0
3268
-        q3oncd = 0
3269
-        q4oncd = 0
3270
-        q5oncd = 0
3271
-        q6oncd = 0
3272
-        q7oncd = 0
3273
-        q8oncd = 0
2971
+        sr.reset()
2972
+        print('*nollie fs 360 shuvit')
3274 2973
 
3275 2974
     # varial heelflip
3276 2975
     # 7 < 6 < 2
3277
-    if q7oncd > 0 and q6oncd > 0 and q2oncd > 0 and q7oncd < q6oncd < q2oncd:
3278
-        dict['trick_string'] = 'Varial Heelflip'
2976
+    if sr.q7 > 0 and sr.q6 > 0 and sr.q2 > 0 and sr.q7 <= sr.q6 <= sr.q2:
3279 2977
         varial_heelflip()
3280
-        reset_rtimers()
3281
-        q1oncd = 0
3282
-        q2oncd = 0
3283
-        q3oncd = 0
3284
-        q4oncd = 0
3285
-        q5oncd = 0
3286
-        q6oncd = 0
3287
-        q7oncd = 0
3288
-        q8oncd = 0
2978
+        sr.reset()
3289 2979
 
3290 2980
     # varial kickflip
3291 2981
     # 3 < 4 < 8
3292
-    if q3oncd > 0 and q4oncd > 0 and q8oncd > 0 and q3oncd < q4oncd < q8oncd:
3293
-        dict['trick_string'] = 'Varial Kickflip'
2982
+    if sr.q3 > 0 and sr.q4 > 0 and sr.q8 > 0 and sr.q3 <= sr.q4 <= sr.q8: 
3294 2983
         varial_kickflip()
3295
-        reset_rtimers()
3296
-        q1oncd = 0
3297
-        q2oncd = 0
3298
-        q3oncd = 0
3299
-        q4oncd = 0
3300
-        q5oncd = 0
3301
-        q6oncd = 0
3302
-        q7oncd = 0
3303
-        q8oncd = 0
2984
+        sr.reset()
3304 2985
 
3305 2986
     # nollie varial kickflip
3306 2987
     # 3 < 2 < 6
3307
-    if q3oncd > 0 and q2oncd > 0 and q6oncd > 0 and q3oncd <= q2oncd <= q6oncd:
3308
-        dict['trick_string'] = 'Nollie Varial Kickflip'
3309
-        print('Nollie Varial Kickflip')
2988
+    if sr.q3 > 0 and sr.q2 > 0 and sr.q6 > 0 and sr.q3 <= sr.q2 <= sr.q6:
3310 2989
         nollie_varial_kickflip()
3311
-        reset_rtimers()
3312
-        q1oncd = 0
3313
-        q2oncd = 0
3314
-        q3oncd = 0
3315
-        q4oncd = 0
3316
-        q5oncd = 0
3317
-        q6oncd = 0
3318
-        q7oncd = 0
3319
-        q8oncd = 0
2990
+        sr.reset()
3320 2991
 
3321 2992
     # nollie varial heelflip
3322 2993
     # 7 < 8 < 4
3323
-    if q7oncd > 0 and q8oncd > 0 and q4oncd > 0 and q7oncd <= q8oncd <= q4oncd:
3324
-        dict['trick_string'] = 'Nollie Varial Heelflip'
3325
-        print('Nollie Varial Heelflip')
2994
+    if sr.q7 > 0 and sr.q8 > 0 and sr.q4 > 0 and sr.q7 <= sr.q8 <= sr.q4: 
3326 2995
         nollie_varial_heelflip()
3327
-        reset_rtimers()
3328
-        q1oncd = 0
3329
-        q2oncd = 0
3330
-        q3oncd = 0
3331
-        q4oncd = 0
3332
-        q5oncd = 0
3333
-        q6oncd = 0
3334
-        q7oncd = 0
3335
-        q8oncd = 0
2996
+        sr.reset()
3336 2997
 
3337 2998
     #360 shuvit
3338
-    if q3oncd > 0 and q4oncd > 0 and q5oncd > 0 and q6oncd > 0 and q7oncd > 0 and q7oncd >= q6oncd >= q5oncd >= q4oncd >= q3oncd:
3339
-    #    print("q4oncd: ", q4oncd, " q5oncd: ", q5oncd, " q6oncd: ", q6oncd)
3340
-        #print ("______-------360 shuvit")
3341
-        dict['trick_string'] = '360 shuvit'
2999
+    if sr.q3 > 0 and sr.q4 > 0 and sr.q5 > 0 and sr.q6 > 0 and sr.q7 > 0 and sr.q7 <= sr.q6 <= sr.q5 <= sr.q4 <= sr.q3:
3342 3000
         shuvit360()
3343
-        reset_rtimers()
3344
-        q1oncd = 0
3345
-        q2oncd = 0
3346
-        q3oncd = 0
3347
-        q4oncd = 0
3348
-        q5oncd = 0
3349
-        q6oncd = 0
3350
-        q7oncd = 0
3351
-        q8oncd = 0
3001
+        sr.reset()
3352 3002
 
3353 3003
     #360 fs shuvit
3354
-    if q3oncd > 0 and q4oncd > 0 and q5oncd > 0 and q6oncd >= 0 and q7oncd > 0 and q7oncd <= q6oncd <= q5oncd <= q4oncd <= q3oncd:
3355
-        dict['trick_string'] = '360 Frontside shuvit'
3004
+    if sr.q3 > 0 and sr.q4 > 0 and sr.q5 > 0 and sr.q6 > 0 and sr.q7 > 0 and sr.q7 <= sr.q6 <= sr.q5 <= sr.q4 <= sr.q3:
3356 3005
         fsshuvit360()
3357
-        reset_rtimers()
3358
-        q1oncd = 0
3359
-        q2oncd = 0
3360
-        q3oncd = 0
3361
-        q4oncd = 0
3362
-        q5oncd = 0
3363
-        q6oncd = 0
3364
-        q7oncd = 0
3365
-        q8oncd = 0
3006
+        sr.reset()
3366 3007
 
3367 3008
     #ollie
3368
-    if q5oncd > 0 and q1oncd > 0 and q5oncd < q1oncd:
3369
-        JUMPSTRENGTH = q1oncd - q5oncd
3370
-        #4,7
3371
-        if JUMPSTRENGTH <= 4:
3372
-            JUMPSTRENGTH = 1.1
3373
-        if JUMPSTRENGTH > 4 and JUMPSTRENGTH < 7:
3374
-            JUMPSTRENGTH = 1
3375
-        if JUMPSTRENGTH >= 7:
3376
-            JUMPSTRENGTH = .9
3009
+    if sr.q5 > 0 and sr.q1 > 0 and sr.q5 < sr.q1:
3377 3010
         aollie()
3378
-        #varial_heelflip()
3379
-        reset_rtimers()
3380
-        q1oncd = 0
3381
-        q2oncd = 0
3382
-        q3oncd = 0
3383
-        q4oncd = 0
3384
-        q5oncd = 0
3385
-        q6oncd = 0
3386
-        q7oncd = 0
3387
-        q8oncd = 0
3011
+        sr.reset()        
3012
+
3388 3013
     #nollie
3389
-    if q5oncd > 0 and q1oncd > 0 and q5oncd > q1oncd:
3390
-        JUMPSTRENGTH = q5oncd - q1oncd
3391
-        #4,7
3392
-        if JUMPSTRENGTH <= 4:
3393
-           JUMPSTRENGTH = 1.1
3394
-        if JUMPSTRENGTH > 4 and JUMPSTRENGTH < 7:
3395
-           JUMPSTRENGTH = 1
3396
-        if JUMPSTRENGTH >= 7:
3397
-           JUMPSTRENGTH = .9
3014
+    if sr.q5 > 0 and sr.q1 > 0 and sr.q5 < sr.q1:
3398 3015
         nollie()
3399
-        reset_rtimers()
3400
-        print("nollie")
3401
-        q1oncd = 0
3402
-        q2oncd = 0
3403
-        q3oncd = 0
3404
-        q4oncd = 0
3405
-        q5oncd = 0
3406
-        q6oncd = 0
3407
-        q7oncd = 0
3408
-        q8oncd = 0
3016
+        sr.reset()
3017
+
3409 3018
     #kickflip
3410
-    if q5oncd > 0 and q8oncd > 0 and q5oncd < q8oncd and q3oncd < 1:
3019
+    if sr.q5 > 0 and sr.q8 > 0 and sr.q5 < sr.q8:
3411 3020
         kickflip()
3412
-        reset_rtimers()
3413
-        q1oncd = 0
3414
-        q2oncd = 0
3415
-        q3oncd = 0
3416
-        q4oncd = 0
3417
-        q5oncd = 0
3418
-        q6oncd = 0
3419
-        q7oncd = 0
3420
-        q8oncd = 0
3021
+        sr.reset()
3022
+
3421 3023
     #nollie kickflip
3422
-    if q1oncd > 0 and q6oncd > 0 and q1oncd < q6oncd:
3024
+    if sr.q1 > 0 and sr.q6 > 0 and sr.q2 < sr.q6:
3423 3025
         nollie_kickflip()
3424
-        reset_rtimers()
3425
-        q1oncd = 0
3426
-        q2oncd = 0
3427
-        q3oncd = 0
3428
-        q4oncd = 0
3429
-        q5oncd = 0
3430
-        q6oncd = 0
3431
-        q7oncd = 0
3432
-        q8oncd = 0
3026
+        sr.reset()
3027
+
3433 3028
     #heelflip
3434
-    if q5oncd > 0 and q2oncd > 0 and q5oncd < q2oncd:
3029
+    if sr.q5 > 0 and sr.q2 > 0 and sr.q5 < sr.q2:
3435 3030
         heelflip()
3436
-        reset_rtimers()
3437
-        q1oncd = 0
3438
-        q2oncd = 0
3439
-        q3oncd = 0
3440
-        q4oncd = 0
3441
-        q5oncd = 0
3442
-        q6oncd = 0
3443
-        q7oncd = 0
3444
-        q8oncd = 0
3031
+        sr.reset()
3032
+
3445 3033
     #nollie_heelflip
3446
-    if q1oncd > 0 and q4oncd > 0 and q1oncd < q4oncd:
3034
+    if sr.q1 > 0 and sr.q4 > 0 and sr.q1 < sr.q4:
3447 3035
         nollie_heelflip()
3448
-        reset_rtimers()
3449
-        q1oncd = 0
3450
-        q2oncd = 0
3451
-        q3oncd = 0
3452
-        q4oncd = 0
3453
-        q5oncd = 0
3454
-        q6oncd = 0
3455
-        q7oncd = 0
3456
-        q8oncd = 0
3036
+        sr.reset()
3457 3037
 
3458 3038
     #shuvit
3459
-    if q7oncd > 0 and q5oncd > 0 and q6oncd > 0 and q5oncd <= q6oncd <= q7oncd:# and q3oncd < 1:
3039
+    if sr.q7 > 0 and sr.q5 > 0 and sr.q6 > 0 and sr.q5 <= sr.q6 <= sr.q7:
3460 3040
         shuvit()
3461
-        reset_rtimers()
3462
-        q1oncd = 0
3463
-        q2oncd = 0
3464
-        q3oncd = 0
3465
-        q4oncd = 0
3466
-        q5oncd = 0
3467
-        q6oncd = 0
3468
-        q7oncd = 0
3469
-        q8oncd = 0
3041
+        sr.reset()
3042
+
3470 3043
     #nollie_shuvit
3471
-    if q7oncd > 0 and q1oncd > 0 and q8oncd > 0 and q1oncd <= q8oncd <= q7oncd:# and q3oncd == 0:
3044
+    if sr.q7 > 0 and sr.q1 > 0 and sr.q8 > 0 and sr.q1 <= sr.q8 <= sr.q7:
3472 3045
         nollie_shuvit()
3473
-        print('nollie shuvit')
3474
-        reset_rtimers()
3475
-        q1oncd = 0
3476
-        q2oncd = 0
3477
-        q3oncd = 0
3478
-        q4oncd = 0
3479
-        q5oncd = 0
3480
-        q6oncd = 0
3481
-        q7oncd = 0
3482
-        q8oncd = 0
3046
+        sr.reset()
3047
+        print('*nollie shuvit')
3048
+
3483 3049
     #fsshuvit
3484
-    if q4oncd > 0 and q5oncd > 0 and q3oncd > 0 and q5oncd <= q4oncd <= q3oncd:# and q7oncd < 1:
3050
+    if sr.q4 > 0 and sr.q5 > 0 and sr.q3 > 0 and sr.q5 <= sr.q4 <= sr.q3:
3485 3051
         fsshuvit()
3486
-        reset_rtimers()
3487
-        q1oncd = 0
3488
-        q2oncd = 0
3489
-        q3oncd = 0
3490
-        q4oncd = 0
3491
-        q5oncd = 0
3492
-        q6oncd = 0
3493
-        q7oncd = 0
3494
-        q8oncd = 0
3052
+        sr.reset()
3053
+
3495 3054
     #nollie_fsshuvit
3496
-    if q3oncd > 0 and q1oncd > 0 and q2oncd > 0 and q1oncd <= q2oncd <= q3oncd:# and q7oncd == 0:
3497
-        print ("nollie fsshuvit")
3055
+    if sr.q3 > 0 and sr.q1 > 0 and sr.q2 > 0 and sr.q1 <= sr.q2 <= sr.q3:
3498 3056
         nollie_fsshuvit()
3499
-        reset_rtimers()
3500
-        q1oncd = 0
3501
-        q2oncd = 0
3502
-        q3oncd = 0
3503
-        q4oncd = 0
3504
-        q5oncd = 0
3505
-        q6oncd = 0
3506
-        q7oncd = 0
3507
-        q8oncd = 0
3057
+        sr.reset()
3058
+        print('*nollie fs shuvit')
3508 3059
 
3509 3060
     def hippy_jump():
3510 3061
         STANCE = own["stance"]
@@ -4148,7 +3699,8 @@ def main():
4148 3699
             if 'reg' in own['l_actionState']:
4149 3700
                 STANCE = 0
4150 3701
             if own['grindpos'] == 'reg_5050':
4151
-                if lq3on == 1 or lq2on or dict['kb_ra'] == 2:
3702
+                if sl.q3 >= countdown or sl.q2 >= countdown or dict['kb_ra'] == 2:
3703
+                #if lq3on == 1 or lq2on or dict['kb_ra'] == 2:
4152 3704
                     if own['gt_cd2'] == 0:
4153 3705
                         own['gt_cd2'] = 60
4154 3706
 
@@ -4159,7 +3711,8 @@ def main():
4159 3711
                         if own['grind_out_type'] == None:
4160 3712
                             own['grind_out_type'] = 'reg right'
4161 3713
                     own["grindoutturn"] = gotcd
4162
-                if lq7on == 1 or lq8on or dict['kb_la'] == 2:
3714
+                if sl.q7 >= countdown or sl.q8 >= countdown or dict['kb_la'] == 2:
3715
+                #if lq7on == 1 or lq8on or dict['kb_la'] == 2:
4163 3716
                     if own['gt_cd2'] == 0:
4164 3717
                         own['gt_cd2'] = 60
4165 3718
                     if STANCE == True:
@@ -4169,7 +3722,8 @@ def main():
4169 3722
                         if own['grind_out_type'] == None:
4170 3723
                             own['grind_out_type'] = 'reg left'
4171 3724
                     own["grindoutturn"] = gotcd
4172
-                if lq4on == 1:
3725
+                #if lq4on == 1:
3726
+                if sl.q4 >= countdown:   
4173 3727
                     if own['gt_cd2'] == 0:
4174 3728
                         own['gt_cd2'] = 60
4175 3729
                     if STANCE == True:
@@ -4179,7 +3733,8 @@ def main():
4179 3733
                         if own['grind_out_type'] == None:
4180 3734
                              own['grind_out_type'] = 'reg fak right'
4181 3735
                     own["grindoutturn"] = gotcd
4182
-                if lq6on == 1:
3736
+                #if lq6on == 1:
3737
+                if sl.q6 >= countdown:
4183 3738
                     if own['gt_cd2'] == 0:
4184 3739
                         own['gt_cd2'] = 60
4185 3740
                     if STANCE == True:
@@ -4196,7 +3751,8 @@ def main():
4196 3751
                 outact.dRot = [0, 0, 0]
4197 3752
 
4198 3753
 
4199
-                if lq5on == 1 or dict['kb_da'] == 2:
3754
+                #if lq5on == 1 or dict['kb_da'] == 2:
3755
+                if sl.q5 >= countdown or dict['kb_da'] == 2:
4200 3756
                     if own['gt_cd2'] == 0:
4201 3757
                         own['gt_cd2'] = 60
4202 3758
                     if STANCE == True:
@@ -4219,7 +3775,8 @@ def main():
4219 3775
                         print('board out')
4220 3776
                     own["grindoutturn"] = gotcd
4221 3777
                     own['invert_on'] = 0
4222
-                if lq1on == 1 or dict['kb_ua'] == 2:
3778
+                if sl.q1 >= countdown or dict['kb_ua'] == 2:
3779
+                #if lq1on == 1 or dict['kb_ua'] == 2:
4223 3780
                     if own['gt_cd2'] == 0:
4224 3781
                         own['gt_cd2'] = 60
4225 3782
                     if STANCE == True:
@@ -4238,7 +3795,8 @@ def main():
4238 3795
                         #own.applyRotation((0, -.15, 0), True)
4239 3796
                     own["grindoutturn"] = gotcd
4240 3797
                     own['invert_on'] = 0
4241
-            if lq1on or lq2on or lq3on or lq4on or lq5on or lq6on or lq7on or lq8on:
3798
+            #if lq1on or lq2on or lq3on or lq4on or lq5on or lq6on or lq7on or lq8on:
3799
+            if sl.q1 >= countdown or sl.q2 >= countdown or sl.q3 >= countdown or sl.q4 >= countdown or sl.q5 >= countdown or sl.q6 >= countdown or sl.q7 >= countdown:
4242 3800
                 gt_cd = own['gt_cd']
4243 3801
                 if gt_cd == 0:
4244 3802
                     gt_cd = 30
@@ -4398,14 +3956,8 @@ def main():
4398 3956
 
4399 3957
     def shutoff_timers():
4400 3958
         if (LAST_GRIND == False and grindHit == True) or (jump_timer > 10 and own['wallride'] == None):
4401
-            own["Q1oncd"] = 0
4402
-            own["Q2oncd"] = 0
4403
-            own["Q3oncd"] = 0
4404
-            own["Q4oncd"] = 0
4405
-            own["Q5oncd"] = 0
4406
-            own["Q6oncd"] = 0
4407
-            own["Q7oncd"] = 0
4408
-            own["Q8oncd"] = 0
3959
+            sr.reset()
3960
+            sl.reset()
4409 3961
 
4410 3962
     def grindout_cleanup():
4411 3963
         lgf = own['last_grind_frame']

+ 80
- 0
scripts/joytimers.py View File

@@ -0,0 +1,80 @@
1
+#joytimers.py
2
+import bge
3
+countdown = 20
4
+
5
+def main(own):
6
+	
7
+	class stick:
8
+		def __init__(self, ud, lr):
9
+			self.q1 = 0
10
+			self.q2 = 0
11
+			self.q3 = 0
12
+			self.q4 = 0
13
+			self.q5 = 0
14
+			self.q6 = 0
15
+			self.q7 = 0
16
+			self.q8 = 0
17
+			self.ud = ud
18
+			self.lr = lr
19
+			self.qs = ['q6', 'q8', 'q2', 'q4', 'q5', 'q1', 'q3', 'q7']
20
+
21
+		def reset(self):
22
+			self.q1 = 0
23
+			self.q2 = 0
24
+			self.q3 = 0
25
+			self.q4 = 0
26
+			self.q5 = 0
27
+			self.q6 = 0
28
+			self.q7 = 0
29
+			self.q8 = 0			
30
+	
31
+		def update(self):
32
+			dict = bge.logic.globalDict
33
+	
34
+			def q6(val):
35
+				if dict[self.ud] > .04 and dict[self.lr] < -0.04:
36
+					return countdown
37
+				
38
+			def q8(val):
39
+				if dict[self.ud] < -.04 and dict[self.lr] < -0.04:
40
+					return countdown
41
+								
42
+			def q2(val):
43
+				if dict[self.ud] < -.04 and dict[self.lr] > 0.04:
44
+					return countdown
45
+
46
+			def q4(val):
47
+				if dict[self.ud] > .04 and dict[self.lr] > 0.04:
48
+					return countdown		
49
+
50
+			def q5(val):
51
+				if dict[self.ud] > .07 and self.q4 is not countdown and self.q6 is not countdown:
52
+					return countdown		
53
+
54
+			def q1(val):
55
+				if dict[self.ud] < -.07 and self.q8 is not countdown and self.q2 is not countdown:
56
+					return countdown		
57
+
58
+			def q3(val):
59
+				if dict[self.lr] > .07 and self.q2 is not countdown and self.q4 is not countdown:
60
+					return countdown				
61
+
62
+			def q7(val):
63
+				if dict[self.lr] < -.07 and self.q6 is not countdown and self.q8 is not countdown:
64
+					return countdown		
65
+
66
+			for cur_q in self.qs:
67
+				val = getattr(self, cur_q)
68
+				v2 = locals()[cur_q](val)
69
+				if v2 is not None:
70
+					setattr(self, cur_q, v2) 
71
+				elif val > 0:
72
+					setattr(self, cur_q, val - 1) 
73
+
74
+	if 'jt_inited' not in own:
75
+		own['jt_inited'] = True
76
+		own['jsl'] = stick('lUD', 'lLR')
77
+		own['jsr'] = stick('rUD', 'rLR')
78
+
79
+	own['jsl'].update()	
80
+	own['jsr'].update()	

Loading…
Cancel
Save