Browse Source

adding files

shuvit 3 years ago
parent
commit
b09d6913fa
6 changed files with 1853 additions and 0 deletions
  1. 566
    0
      aiRecord.py
  2. 553
    0
      aiSortData.py
  3. 229
    0
      ai_manager.py
  4. 318
    0
      bike.py
  5. 139
    0
      load_npc.py
  6. 48
    0
      npcChangeAnim.py

+ 566
- 0
aiRecord.py View File

@@ -0,0 +1,566 @@
1
+#record
2
+from bge import logic
3
+from mathutils import Vector
4
+from aiSortData import *
5
+import math
6
+
7
+cont = logic.getCurrentController()
8
+own = cont.owner
9
+scene = logic.getCurrentScene()
10
+cube = cont.owner
11
+#obj = scene.objects["control_cube.002"]
12
+#sound_empty = scene.objects['replay_sound_empty']
13
+#path = logic.expandPath(own["filePath"])
14
+dict = logic.globalDict
15
+PAF = 0
16
+DAF = 0
17
+
18
+npc_index = own['npc_index']
19
+#print(dict['spawned_npc_decks'], npc_index, 'spawned deck list')
20
+deck = dict['spawned_npc_decks'][npc_index]
21
+trucks = dict['spawned_npc_trucks'][npc_index]
22
+#deck = scene.objects[deck]
23
+
24
+#print(own.children)
25
+#deck = own.children['npc_ed_deck']
26
+#trucks = own.children["npc_ed_trucks"]
27
+
28
+#throw_deck_empty = scene.objects["throw_deck_empty"]
29
+#wheel1 = trucks.children["npc_ed_rollen.000"]
30
+#wheel2 = trucks.children["npc_ed_rollen.001"]
31
+#wheel3 = trucks.children["npc_ed_rollen.002"]
32
+#wheel4 = trucks.children["npc_ed_rollen.003"]
33
+
34
+#try:
35
+#    throw_deck = scene.objects['throw_deck']
36
+#except:
37
+#    throw_deck = None    
38
+
39
+#deckact = deck.actuators["Visibility"]
40
+#trucksact = trucks.actuators["Visibility"]
41
+#wheel1act = wheel1.actuators["Visibility"]
42
+#wheel2act = wheel2.actuators["Visibility"]
43
+#wheel3act = wheel3.actuators["Visibility"]
44
+#wheel4act = wheel4.actuators["Visibility"]
45
+
46
+class getData:
47
+
48
+
49
+
50
+    def savePosition(obj, cut):
51
+        position = [Vector(obj.worldPosition)[0],
52
+            Vector(obj.worldPosition)[1],
53
+            Vector(obj.worldPosition)[2]]
54
+        position = str(position).strip("[]")
55
+        position = position.replace(", ",",")
56
+        writeData.addPosition(obj, position, cut)
57
+     
58
+    def saveOrientation(obj, cut): 
59
+        orientation = [Vector(obj.localOrientation.to_euler())[0],
60
+            Vector(obj.localOrientation.to_euler())[1],
61
+            Vector(obj.localOrientation.to_euler())[2]]
62
+        orientation = str(orientation).strip("[]")
63
+        orientation = orientation.replace(", ",",")     
64
+        writeData.addOrientation(obj, orientation, cut)
65
+                    
66
+                                              
67
+              
68
+def loadData(cont, own):
69
+    
70
+    npc_index = own['npc_index']
71
+    #print(dict['spawned_npc_decks'], npc_index, 'spawned deck list')
72
+    deck = dict['spawned_npc_decks'][npc_index]
73
+    trucks = dict['spawned_npc_trucks'][npc_index]    
74
+    skater = dict['spawned_npcs'][npc_index]
75
+    cube = own 
76
+    #Function for loading the data from
77
+    #the disk and setting it.
78
+    #print('load_data', own)
79
+    objIndex = own["objIndex"]
80
+    #print(own['objIndex'], 'objindex')
81
+    own["valueIndex"] = objIndex + 1
82
+    valueIndex = own["valueIndex"]
83
+    playbackSpeed = own["playbackSpeed"]
84
+    loadedPosition = own["loadedPosition"]
85
+    loadedOrientation = own["loadedOrientation"]
86
+#    print(loadedPosition)
87
+#    loadedScale = own["loadedScale"]
88
+#    loadedColor = own["loadedColor"]
89
+#    loadedVisibility = own["loadedVisibility"]
90
+    loadedSkaterAnim = own["loadedSkaterAnim"]
91
+    loadedSkaterAnimf = own["loadedSkaterAnimF"]
92
+    loadedDeckAnim = own["loadedDeckAnim"]
93
+    loadedDeckAnimf = own["loadedDeckAnimF"]
94
+#    loadedSrollVol = own["loadedSrollVol"]
95
+#    loadedSrollPitch = own["loadedSrollPitch"]
96
+#    loadedSgrind_cementlVol = own["loadedSgrind_cementVol"]
97
+#    loadedSgrind_cementPitch = own["loadedSgrind_cementPitch"]
98
+#    loadedSgrind_railVol = own["loadedSgrind_railVol"]
99
+#    loadedSgrind_railPitch = own["loadedSgrind_railPitch"] 
100
+#    loadedSpopsound = own["loadedSpopsound"]            
101
+#    loadedSlandsound = own["loadedSlandsound"] 
102
+#    loadedSdeckvis = own["loadedSdeckvis"]  
103
+#    loadedtdPosition = own["loadedtdPosition"]
104
+#    loadedtdOrientation = own["loadedtdOrientation"]      
105
+#    loadedSrevertsound = own["loadedSrevertsound"] 
106
+       
107
+    #skater = own.children["npc_ed_arm"]
108
+    #deck = own.children["deck"]
109
+    #trucks = own.children["trucks"]
110
+    
111
+    num = 1
112
+    obj = own
113
+
114
+                     
115
+    readData.loadAll(own)    #Load the file!!!
116
+    
117
+    #-----Position-----#
118
+    own["lengthPos"] = readData.getLengthPos(own)
119
+    lengthPos = own["lengthPos"] 
120
+    positionList = own['positionList']
121
+    if lengthPos:
122
+        if objIndex > lengthPos-1:
123
+            own["objIndex"] = 0
124
+        if objIndex < 0:
125
+            own["objIndex"] = lengthPos-2
126
+
127
+        name, position = readData.returnPosition(objIndex, valueIndex, own)
128
+        name2, orientation = readData.returnOrientation(objIndex, valueIndex, own)
129
+        try:
130
+            if own['rpStartLoc_set'] == False:
131
+                own['rpStartLoc'] = position
132
+                print('setting npc_start_pos', position)
133
+                
134
+                own['npc_playback'] = False
135
+                own['move'] = True
136
+                tracker = scene.addObject('npc_tracker', own, 0)
137
+                own['target_object_name'] = tracker
138
+                tracker.worldPosition = position
139
+                
140
+                oXYZ = own.localOrientation.to_euler()
141
+
142
+                oXYZ[0] = float(orientation[0])
143
+                oXYZ[1] = float(orientation[1])
144
+                oXYZ[2] = float(orientation[2])                
145
+                tracker.localOrientation = oXYZ.to_matrix()
146
+                rot = [ 0.0, 0.0, -1.570796327]
147
+                #tracker.applyRotation(rot,True) 
148
+    
149
+                rotz = math.degrees(oXYZ[2])
150
+                rotz -= 90
151
+                if rotz < -180:
152
+                    rotz = rotz + 360
153
+                own['rpStartZ'] = rotz               
154
+                
155
+            else:  
156
+                cube.worldPosition = position
157
+                deck.worldPosition = position
158
+                trucks.worldPosition = position
159
+        except:
160
+            print('npc positioning not working')
161
+            #pass
162
+    #-----Orientation-----#
163
+    own["lengthOri"] = readData.getLengthOri(own)   
164
+    lengthOri = own["lengthOri"]
165
+
166
+    valueIndex = own['valueIndex']
167
+    #print(valueIndex, objIndex, 'value Index')
168
+    #if lengthPos:
169
+    if lengthOri:
170
+        if valueIndex > lengthOri-1:
171
+            own["valueIndex"] = 0
172
+        if objIndex < 0:
173
+            own["objIndex"] = lengthOri-2
174
+        name, orientation = readData.returnOrientation(objIndex, valueIndex, own)
175
+        oXYZ = own.localOrientation.to_euler()
176
+        oXYZ[0] = float(orientation[0])
177
+        oXYZ[1] = float(orientation[1])
178
+        oXYZ[2] = float(orientation[2])    
179
+        try:
180
+            if own['rpStartLoc_set'] == True:
181
+                own.localOrientation = oXYZ.to_matrix()
182
+                deck.localOrientation = oXYZ.to_matrix()
183
+                trucks.localOrientation = oXYZ.to_matrix()
184
+                rot = [ 0.0, 0.0, -1.570796327]
185
+                own.applyRotation(rot,True) 
186
+            else:
187
+                own['rpStartLoc_set'] = True
188
+        except:
189
+            print('npc orientation not working')
190
+#    #-----Scale-----#
191
+#    own["lengthSca"] = readData.getLengthSca()
192
+#    lengthSca = own["lengthSca"]
193
+#    
194
+#    if lengthSca:
195
+#    
196
+#        if valueIndex > lengthSca-1:
197
+#            own["valueIndex"] = 0
198
+#        if objIndex < 0:
199
+#            own["objIndex"] = lengthSca-2
200
+#       
201
+#        name, scale = readData.returnScale(objIndex, valueIndex)
202
+#        
203
+#        if name in scene.objects:
204
+#            try:
205
+#                scene.objects[name].localScale = scale
206
+#            except:
207
+#                pass
208
+#    #-----Color-----#
209
+#    own["lengthCol"] = readData.getLengthCol()   
210
+#    lengthCol = own["lengthCol"]
211
+#    
212
+#    if lengthCol:
213
+
214
+#        if valueIndex > lengthCol-1:
215
+#            own["valueIndex"] = 0
216
+#        if objIndex < 0:
217
+#            own["objIndex"] = lengthCol-2
218
+
219
+#        name, color = readData.returnColor(objIndex, valueIndex)
220
+#        
221
+#        if name in scene.objects:
222
+#            try:
223
+#                scene.objects[name].color = color
224
+#            except:
225
+#                pass
226
+#    #-----Visibility-----#
227
+#    own["lengthVis"] = readData.getLengthVis()
228
+#    lengthVis = own["lengthVis"]
229
+#    
230
+#    if lengthVis:
231
+
232
+#        if valueIndex > lengthVis-1:
233
+#            own["valueIndex"] = 0
234
+#        if objIndex < 0:
235
+#            own["objIndex"] = lengthVis-2
236
+
237
+#        name, visible = readData.returnVisibility(objIndex, valueIndex)
238
+#        
239
+#        if name in scene.objects:
240
+#            try:
241
+#                scene.objects[name].visible = int(visible)
242
+#            except:
243
+#                pass
244
+    #-----Skater Animation Name-----#
245
+    own["lengthSkaterAnim"] = readData.getLengthSkaterAnim(own)
246
+    lengthSkaterAnim = own["lengthSkaterAnim"]
247
+    #print("lengthskateranim", lengthSkaterAnim)
248
+    if lengthSkaterAnim:
249
+
250
+        if valueIndex > lengthSkaterAnim-1:
251
+            own["valueIndex"] = 0
252
+        if objIndex < 0:
253
+            own["objIndex"] = lengthSkaterAnim-2
254
+
255
+        name, skateranim = readData.returnSkaterAnim(objIndex, valueIndex, own)
256
+        name, PAF = readData.returnSkaterAnimF(objIndex, valueIndex, own)
257
+        PAF = round(float(PAF), 1)
258
+        #print(valueIndex, skateranim, PAF,  'sa')
259
+        PAF = float(PAF)
260
+        if skater in own.children:
261
+            #print("name in")
262
+            try:
263
+                skater.stopAction(0)
264
+                skater.stopAction(1)
265
+                skater.stopAction(2)
266
+                skater.stopAction(3)
267
+                skater.stopAction(9999)
268
+                if skater != '' and skateranim != 'control_cube.002':
269
+                    skater.playAction(skateranim, PAF,PAF, layer=2, play_mode=1, speed=1)
270
+                #print("Playing: ", skater, skateranim, PAF)
271
+            except:
272
+                print("something is wrong")
273
+                
274
+    #-----Deck Animation Name-----#
275
+    own["lengthDeckAnim"] = readData.getLengthDeckAnim(own)
276
+    lengthDeckAnim = own["lengthDeckAnim"]
277
+    #print("lengthDeckanim", lengthDeckAnim)
278
+    if lengthDeckAnim:
279
+
280
+        if valueIndex > lengthDeckAnim-1:
281
+            own["valueIndex"] = 0
282
+        if objIndex < 0:
283
+            own["objIndex"] = lengthDeckAnim-2
284
+
285
+        name, deckanim = readData.returnDeckAnim(objIndex, valueIndex, own)
286
+        name, DAF = readData.returnDeckAnimF(objIndex, valueIndex, own)
287
+        name = 'npc_ed_deck'
288
+
289
+        DAF = float(DAF)
290
+        if deck in own.children:
291
+            #print("name in")
292
+            try:
293
+                if deck != '' and deckanim != 'control_cube.002':
294
+                    deck.playAction(deckanim, DAF,DAF, layer=2, play_mode=1, speed=1)
295
+                    trucks.playAction(deckanim, DAF,DAF, layer=2, play_mode=1, speed=1)
296
+                #print("Playing: ", deckanim, PAF)
297
+                #print("Playing: ", deck, deckanim, DAF)
298
+            except:
299
+                print("deck something is wrong")
300
+                #pass  
301
+
302
+##
303
+#    #-----sroll-----#
304
+#    own["lengthSrollVol"] = readData.getLengthSrollVol()
305
+#    lengthSrollVol = own["lengthSrollVol"]
306
+#    if lengthSrollVol:
307
+#        if valueIndex > lengthSrollVol-1:
308
+#            own["valueIndex"] = 0
309
+#        if objIndex < 0:
310
+#            own["objIndex"] = lengthSrollVol-2
311
+#        name, srollVol = readData.returnSrollVol(objIndex, valueIndex)
312
+#        name, srollPitch = readData.returnSrollPitch(objIndex, valueIndex)    
313
+#        if name in scene.objects:
314
+#            try:
315
+#                cube = scene.objects["control_cube.002"]
316
+#                srollVol = round(srollVol, 2)
317
+#                act = cube.actuators["sroll"]
318
+#                if srollVol < .12:
319
+#                    act.volume = srollVol
320
+#                    act.pitch = srollPitch
321
+#                act.startSound()
322
+#            except:
323
+#                pass
324
+####            
325
+##
326
+#    #-----grind cement-----#
327
+#    own["lengthSgrind_cementVol"] = readData.getLengthSgrind_cementVol()
328
+#    lengthSgrind_cementVol = own["lengthSgrind_cementVol"]
329
+#    if lengthSgrind_cementVol:
330
+#        if valueIndex > lengthSgrind_cementVol-1:
331
+#            own["valueIndex"] = 0
332
+#        if objIndex < 0:
333
+#            own["objIndex"] = lengthSgrind_cementVol-2
334
+#        name, sgrind_cementVol = readData.returnSgrind_cementVol(objIndex, valueIndex)
335
+#        name, sgrind_cementPitch = readData.returnSgrind_cementPitch(objIndex, valueIndex)    
336
+#        if name in scene.objects:
337
+#            try:
338
+#                cube = scene.objects["control_cube.002"]
339
+#                sgrind_cementVol = round(sgrind_cementVol, 2)
340
+#                act = cube.actuators["grind_cement"]
341
+#                if sgrind_cementVol < .2:
342
+#                    act.volume = sgrind_cementVol
343
+#                    act.pitch = sgrind_cementPitch
344
+#                act.startSound()
345
+#                
346
+#            except:
347
+#                pass
348
+####    
349
+##
350
+#    #-----grind rail-----#
351
+#    own["lengthSgrind_railVol"] = readData.getLengthSgrind_railVol()
352
+#    lengthSgrind_railVol = own["lengthSgrind_railVol"]
353
+#    if lengthSgrind_railVol:
354
+#        if valueIndex > lengthSgrind_railVol-1:
355
+#            own["valueIndex"] = 0
356
+#        if objIndex < 0:
357
+#            own["objIndex"] = lengthSgrind_railVol-2
358
+#        name, sgrind_railVol = readData.returnSgrind_railVol(objIndex, valueIndex)
359
+#        name, sgrind_railPitch = readData.returnSgrind_railPitch(objIndex, valueIndex)    
360
+#        if name in scene.objects:
361
+#            try:
362
+#                cube = scene.objects["control_cube.002"]
363
+#                sgrind_railVol = round(sgrind_railVol, 2)
364
+#                act = cube.actuators["grind_rail"]
365
+#                if sgrind_railVol < .2:
366
+#                    act.volume = sgrind_railVol
367
+#                    act.pitch = sgrind_railPitch
368
+#                act.startSound()
369
+#                #print("grindsound = ", sgrind_railVol, sgrind_railPitch)
370
+#            except:
371
+#                pass
372
+####  
373
+##
374
+#    #-----pop sound-----#
375
+#    own["lengthSpopsound"] = readData.getLengthSpopsound()
376
+#    lengthSpopsound = own["lengthSpopsound"]
377
+#    if lengthSpopsound:
378
+#        if valueIndex > lengthSpopsound-1:
379
+#            own["valueIndex"] = 0
380
+#        if objIndex < 0:
381
+#            own["objIndex"] = lengthSpopsound-2
382
+#        name, spopsound = readData.returnSpopsound(objIndex, valueIndex)   
383
+#        if name in scene.objects:
384
+#            #act = sound_empty.actuators["pop"]
385
+#            try:
386
+#                #cube = scene.objects[sound_empty]
387
+#                spopsound = round(spopsound, 2)
388
+#                act = cube.actuators["pop"]
389
+#                #act = sound_empty.actuators["pop"]
390
+#                if spopsound == 1:
391
+#                    #act.volume_maximum = .7
392
+#                    #act.is3D = True
393
+#                    #act.distance_reference = 10.0
394
+#                    #act.distance_maximum = 50.0
395
+#                    act.volume = .6
396
+#                    act.startSound()
397
+#                #print("grindsound = ", spopsound, sgrind_railPitch)
398
+#            except:
399
+#                print("sound passed")
400
+#                pass
401
+####
402
+##
403
+#    #-----land sound-----#
404
+#    own["lengthSlandsound"] = readData.getLengthSlandsound()
405
+#    lengthSlandsound = own["lengthSlandsound"]
406
+#    if lengthSlandsound:
407
+#        if valueIndex > lengthSlandsound-1:
408
+#            own["valueIndex"] = 0
409
+#        if objIndex < 0:
410
+#            own["objIndex"] = lengthSlandsound-2
411
+#        name, slandsound = readData.returnSlandsound(objIndex, valueIndex)   
412
+#        if name in scene.objects:
413
+#            try:
414
+#                cube = scene.objects["control_cube.002"]
415
+#                slandsound = round(slandsound, 2)
416
+#                act = cube.actuators["land"]
417
+#                if slandsound == 1:
418
+#                    act.volume = .6
419
+#                    act.startSound()
420
+#                #print("grindsound = ", slandsound, sgrind_railPitch)
421
+#            except:
422
+#                pass
423
+####  
424
+####
425
+##
426
+#    #-----land sound-----#
427
+#    own["lengthSdeckvis"] = readData.getLengthSdeckvis()
428
+#    lengthSdeckvis = own["lengthSdeckvis"]
429
+#    if lengthSdeckvis:
430
+#        if valueIndex > lengthSdeckvis-1:
431
+#            own["valueIndex"] = 0
432
+#        if objIndex < 0:
433
+#            own["objIndex"] = lengthSdeckvis-2
434
+#        name, sdeckvis = readData.returnSdeckvis(objIndex, valueIndex)   
435
+#        
436
+#        
437
+#        if name in scene.objects:
438
+#            try:
439
+#                cube = scene.objects["control_cube.002"]
440
+#                if sdeckvis == 1:
441
+#                    #print('setting deck visible')
442
+#                    deckact.visibility = True
443
+#                    trucksact.visibility = True
444
+#                    wheel1act.visibility = True
445
+#                    wheel2act.visibility = True
446
+#                    wheel3act.visibility = True
447
+#                    wheel4act.visibility = True   
448
+#                    cont.activate(deck.actuators['Visibility'])
449
+#                    cont.activate(trucks.actuators['Visibility'])
450
+#                    cont.activate(wheel1.actuators['Visibility'])
451
+#                    cont.activate(wheel2.actuators['Visibility'])
452
+#                    cont.activate(wheel3.actuators['Visibility'])
453
+#                    cont.activate(wheel4.actuators['Visibility'])  
454
+#                    for n in scene.objects:
455
+#                        if 'throw_deck' in n.name and 'empty' not in n.name:
456
+#                            n.endObject() 
457
+##                    if 'throw_deck' in scene.objects:
458
+#                            #print('ending td', n)
459
+#                            cont.activate(throw_deck.actuators['end_throw_deck'])                   
460
+#                     
461
+#                    #throwdeck.visibility = False                               
462
+#                else:
463
+#                    #print('setting deck invisible')
464
+#                    deckact.visibility = False
465
+#                    trucksact.visibility = False
466
+#                    wheel1act.visibility = False
467
+#                    wheel2act.visibility = False
468
+#                    wheel3act.visibility = False
469
+#                    wheel4act.visibility = False   
470
+#                    cont.activate(deck.actuators['Visibility'])
471
+#                    cont.activate(trucks.actuators['Visibility'])
472
+#                    cont.activate(wheel1.actuators['Visibility'])
473
+#                    cont.activate(wheel2.actuators['Visibility'])
474
+#                    cont.activate(wheel3.actuators['Visibility'])
475
+#                    cont.activate(wheel4.actuators['Visibility'])  
476
+#                    #if throw_deck == None:
477
+#                    if 'throw_deck' not in scene.objects:
478
+#                        #print('no throwdeck')
479
+#                        #cont.deactivate(throw_deck.actuators['end_throw_deck']) 
480
+#                        #throw_deck_empty.wordPosition.z = throw_deck_empty.wordPosition.z + 1
481
+#                        cont.activate(throw_deck_empty.actuators['throw_dec_act']) 
482
+#                        #scene.addObject('throw_deck')
483
+#                    #throwdeck.visibility = True
484
+#                    throw_deck.suspendDynamics()
485
+
486
+#            except:
487
+#                pass
488
+###    
489
+#    #-----Position-----#
490
+#    own["lengthtdPos"] = readData.getLengthtdPos()
491
+#    lengthPos = own["lengthtdPos"] 
492
+#    
493
+#    if lengthPos:
494
+#        
495
+#        if objIndex > lengthPos-1:
496
+#            own["objIndex"] = 0
497
+#        if objIndex < 0:
498
+#            own["objIndex"] = lengthPos-2
499
+
500
+#        name, position = readData.returntdPosition(objIndex, valueIndex)
501
+#        name = 'throw_deck'
502
+#        if name in scene.objects:
503
+#            try:
504
+#                scene.objects[name].worldPosition = position
505
+#                #print('recording tdPos', position)
506
+#            except:
507
+#                pass
508
+#    #-----Orientation-----#
509
+#    own["lengthtdOri"] = readData.getLengthtdOri()   
510
+#    lengthOri = own["lengthtdOri"]
511
+#    
512
+#    #if lengthPos:
513
+#    if lengthOri:
514
+#  
515
+#        if valueIndex > lengthOri-1:
516
+#            own["valueIndex"] = 0
517
+#        if objIndex < 0:
518
+#            own["objIndex"] = lengthOri-2
519
+
520
+#        name, orientation = readData.returntdOrientation(objIndex, valueIndex)
521
+#        name = 'throw_deck'
522
+#        if name in scene.objects:
523
+#            
524
+#            oXYZ = scene.objects[name].localOrientation.to_euler()
525
+
526
+#            oXYZ[0] = float(orientation[0])
527
+#            oXYZ[1] = float(orientation[1])
528
+#            oXYZ[2] = float(orientation[2])
529
+#            
530
+#            try:
531
+#                #print('recording tdOri')
532
+#                scene.objects[name].localOrientation = oXYZ.to_matrix()
533
+#            except:
534
+#                pass
535
+
536
+##
537
+#    #-----revert sound-----#
538
+#    own["lengthSrevertsound"] = readData.getLengthSrevertsound()
539
+#    lengthSrevertsound = own["lengthSrevertsound"]
540
+#    if lengthSrevertsound:
541
+#        if valueIndex > lengthSrevertsound-1:
542
+#            own["valueIndex"] = 0
543
+#        if objIndex < 0:
544
+#            own["objIndex"] = lengthSrevertsound-2
545
+#        name, srevertsound = readData.returnSrevertsound(objIndex, valueIndex)   
546
+#        if name in scene.objects:
547
+#            try:
548
+#                #cube = scene.objects[sound_empty]
549
+#                srevertsound = round(srevertsound, 2)
550
+#                act = cube.actuators["revertSound"]
551
+#                if srevertsound == 1:
552
+#                    act.startSound()
553
+#                #print("grindsound = ", spopsound, sgrind_railPitch)
554
+#            except:
555
+#                print("sound passed")
556
+#                pass
557
+
558
+                                            
559
+                       
560
+def main(recording_cutoff, cc):
561
+    pass
562
+              
563
+            
564
+         
565
+def breakOut():
566
+    pass

+ 553
- 0
aiSortData.py View File

@@ -0,0 +1,553 @@
1
+from bge import logic
2
+
3
+printDebug = True    #Set to True to see some basic debug info
4
+
5
+cont = logic.getCurrentController()
6
+own = cont.owner
7
+
8
+gameName = "shuvit"    #Set this to the name of your game!
9
+
10
+path = logic.expandPath(own["filePath"])
11
+
12
+positionList = []
13
+orientationList = []
14
+scaleList = []
15
+colorList = []
16
+stateList = []
17
+visibilityList = []
18
+skaterAnimList = []
19
+skaterAnimFList = []
20
+deckAnimList = []
21
+deckAnimFList = []
22
+srollVolList = []
23
+srollPitchList = []
24
+sgrind_cementVolList = []
25
+sgrind_cementPitchList = []
26
+sgrind_railVolList = []
27
+sgrind_railPitchList = []
28
+spopsoundList = []
29
+slandsoundList = []
30
+sdeckvisList = []
31
+positiontdList = []
32
+orientationtdList = []
33
+srevertsoundList = []
34
+
35
+allDataList = []
36
+allDataPath = path+ own['npc_replay_name']
37
+
38
+      
39
+
40
+class readData:
41
+                                   
42
+    def loadAll(own):
43
+#        
44
+#        global allDataList
45
+#        global positionList
46
+#        global orientationList
47
+#        global scaleList
48
+#        global colorList
49
+#        global stateList
50
+#        global visibilityList
51
+#        global skaterAnimList
52
+#        global skaterAnimFList
53
+#        global deckAnimList
54
+#        global deckAnimFList 
55
+#        global srollVolList
56
+#        global srollPitchList 
57
+#        global sgrind_cementVolList
58
+#        global sgrind_cementPitchList 
59
+#        global sgrind_railVolList
60
+#        global sgrind_railPitchList
61
+#        global spopsoundList
62
+#        global slandsoundList 
63
+#        global sdeckvisList     
64
+#        global positiontdList
65
+#        global orientationtdList 
66
+#        global srevertsoundList  
67
+
68
+#        own['allDataList'] = []
69
+#        own['positionList'] = []
70
+#        own['orientationList'] = []
71
+#        own['scaleList'] = []
72
+#        own['colorList'] = []
73
+#        own['stateList'] = []
74
+#        own['visibilityList'] = []
75
+#        own['skaterAnimList'] = []
76
+#        own['skaterAnimFList'] = []
77
+#        own['deckAnimList'] = []
78
+#        own['deckAnimFList'] = []
79
+#        own['srollVolList'] = []
80
+#        own['srollPitchList']  = []
81
+#        own['sgrind_cementVolList'] = []
82
+#        own['sgrind_cementPitchList']  = []
83
+#        own['sgrind_railVolList'] = []
84
+#        own['sgrind_railPitchList'] = []
85
+#        own['spopsoundList'] = []
86
+#        own['slandsoundList']  = []
87
+#        own['sdeckvisList'] = []
88
+#        own['positiontdList'] = []
89
+#        own['orientationtdList']  = []
90
+#        own['srevertsoundList']  = []
91
+        
92
+        allDataPath = path+ own['npc_replay_name']    
93
+        
94
+        #if not allDataList:
95
+        if own['inited'] == False:
96
+            #own['inited'] = True
97
+            try:
98
+                with open(allDataPath) as all:
99
+                    data = all.read()
100
+                    all.close()
101
+
102
+                    allDataList = data.split("|",22)#6)
103
+                    own['allDataList'] = allDataList
104
+                    loadedGameName = str(allDataList[0].split("=",1)[1]).strip()
105
+            
106
+                    #skaterAnimList = allDataList[7].split()
107
+                    #skaterAnimFList = allDataList[8].split()                    
108
+                    
109
+                    try:
110
+                        if loadedGameName == gameName:
111
+
112
+#                            positionList = allDataList[1].split()
113
+#                            orientationList = allDataList[2].split()
114
+#                            scaleList = allDataList[3].split()
115
+#                            colorList = allDataList[4].split()
116
+#                            stateList = allDataList[5].split()
117
+#                            visibilityList = allDataList[6].split()
118
+#                            skaterAnimList = allDataList[7].split()
119
+#                            skaterAnimFList = allDataList[8].split()
120
+#                            deckAnimList = allDataList[9].split()
121
+#                            deckAnimFList = allDataList[10].split()
122
+#                            srollVolList = allDataList[11].split()
123
+#                            srollPitchList = allDataList[12].split()
124
+#                            sgrind_cementVolList = allDataList[13].split()
125
+#                            sgrind_cementPitchList = allDataList[14].split()
126
+#                            sgrind_railVolList = allDataList[15].split() 
127
+#                            sgrind_railPitchList = allDataList[16].split()
128
+#                            spopsoundList = allDataList[17].split()
129
+#                            slandsoundList = allDataList[18].split()
130
+#                            sdeckvisList = allDataList[19].split()
131
+#                            positiontdList = allDataList[20].split()
132
+#                            orientationtdList = allDataList[21].split() 
133
+#                            srevertsoundList = allDataList[22].split()
134
+#                            
135
+                            own['positionList'] = allDataList[1].split()
136
+                            own['orientationList'] = allDataList[2].split()
137
+                            own['scaleList'] = allDataList[3].split()
138
+                            own['colorList'] = allDataList[4].split()
139
+                            own['stateList'] = allDataList[5].split()
140
+                            own['visibilityList'] = allDataList[6].split()
141
+                            own['skaterAnimList'] = allDataList[7].split()
142
+                            own['skaterAnimFList'] = allDataList[8].split()
143
+                            own['deckAnimList'] = allDataList[9].split()
144
+                            own['deckAnimFList'] = allDataList[10].split()
145
+                            own['srollVolList'] = allDataList[11].split()
146
+                            own['srollPitchList'] = allDataList[12].split()
147
+                            own['sgrind_cementVolList'] = allDataList[13].split()
148
+                            own['sgrind_cementPitchList'] = allDataList[14].split()
149
+                            own['sgrind_railVolList'] = allDataList[15].split() 
150
+                            own['sgrind_railPitchList'] = allDataList[16].split()
151
+                            own['spopsoundList'] = allDataList[17].split()
152
+                            own['slandsoundList'] = allDataList[18].split()
153
+                            own['sdeckvisList'] = allDataList[19].split()
154
+                            own['positiontdList'] = allDataList[20].split()
155
+                            own['orientationtdList'] = allDataList[21].split() 
156
+                            own['srevertsoundList'] = allDataList[22].split()             
157
+                            
158
+                            
159
+                            
160
+
161
+                            positionList = own['positionList'
162
+                            ]
163
+                            orientationList = own['orientationList']
164
+                            scaleList = own['scaleList']
165
+                            colorList = own['colorList']
166
+                            stateList = own['stateList']
167
+                            visibilityList = own['visibilityList']
168
+                            skaterAnimList = own['skaterAnimList']
169
+                            skaterAnimFList = own['skaterAnimFList']
170
+                            deckAnimList = own['deckAnimList']
171
+                            deckAnimFList = own['deckAnimFList']
172
+                            srollVolList = own['srollVolList']
173
+                            srollPitchList = own['srollPitchList']
174
+                            sgrind_cementVolList = own['sgrind_cementVolList']
175
+                            sgrind_cementPitchList = own['sgrind_cementPitchList']
176
+                            sgrind_railVolList = own['sgrind_railVolList']
177
+                            sgrind_railPitchList = own['sgrind_railPitchList']
178
+                            spopsoundList = own['spopsoundList']
179
+                            slandsoundList = own['slandsoundList']
180
+                            sdeckvisList = own['sdeckvisList']
181
+                            positiontdList = own['positiontdList']
182
+                            orientationtdList = own['orientationtdList']
183
+                            srevertsoundList = own['srevertsoundList']
184
+                                                        
185
+                            
186
+                                           
187
+                            
188
+                            if printDebug:
189
+                                print("Read file "+allDataPath)
190
+                                own['inited'] = True
191
+                    except:
192
+                        print("error reading replay data")        
193
+            except IOError:
194
+                if printDebug:
195
+                    print("Error reading "+allDataPath)
196
+
197
+    def returnPosition(objIndex, valueIndex, own):
198
+        positionList = own['positionList']
199
+        if positionList:
200
+            name = positionList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
201
+            
202
+            position = positionList[valueIndex-2]
203
+            name = name.replace(" ","")
204
+            #print(position)
205
+            position = str(position)
206
+            position = position.replace(","," ")
207
+            pX = float(position.split()[0])
208
+            pY = float(position.split()[1])
209
+            pZ = float(position.split()[2])
210
+            position = [pX,pY,pZ]
211
+            #print(name, position)
212
+            return(name, position)
213
+
214
+    def returnOrientation(objIndex, valueIndex, own):
215
+        orientationList = own['orientationList']
216
+        if orientationList:
217
+            name = orientationList[objIndex-2]
218
+            orientation = orientationList[valueIndex-2]
219
+            name = name.replace(" ","")
220
+            orientation = str(orientation)
221
+            orientation = orientation.replace(","," ")
222
+            orientation = orientation.split()
223
+            return(name, orientation)
224
+
225
+    def returnScale(objIndex, valueIndex):
226
+
227
+        if scaleList:
228
+            name = scaleList[objIndex-2]
229
+            scale = scaleList[valueIndex-2]
230
+            
231
+            name = name.replace(" ","")
232
+            
233
+            scale = str(scale)
234
+            scale = scale.replace(","," ")
235
+            
236
+            sX = float(scale.split()[0])
237
+            sY = float(scale.split()[1])
238
+            sZ = float(scale.split()[2])
239
+            
240
+            scale = [sX,sY,sZ]
241
+
242
+            return(name, scale)
243
+
244
+    def returnColor(objIndex, valueIndex):
245
+
246
+        if colorList:
247
+            name = colorList[objIndex-2]
248
+            color = colorList[valueIndex-2]
249
+            
250
+            name = name.replace(" ","")
251
+            
252
+            color = str(color)
253
+            color = color.replace(","," ")
254
+            
255
+            cR = float(color.split()[0])
256
+            cG = float(color.split()[1])
257
+            cB = float(color.split()[2])
258
+            cA = float(color.split()[3])
259
+            
260
+            color = [cR,cG,cB,cA]
261
+
262
+            return(name, color)
263
+    
264
+    def returnState(objIndex, valueIndex):
265
+        
266
+        if stateList:
267
+            name = stateList[objIndex-2]
268
+            state = stateList[valueIndex-2]
269
+            
270
+            name = name.replace(" ","")
271
+            
272
+            state = str(state)
273
+            state = state.replace(","," ")
274
+            state = int(state)
275
+            
276
+            return(name, state)
277
+    
278
+    def returnVisibility(objIndex, valueIndex):
279
+        
280
+        if visibilityList:
281
+            name = visibilityList[objIndex-2]
282
+            visible = visibilityList[valueIndex-2]
283
+            
284
+            name = name.replace(" ","")
285
+            
286
+            visible = str(visible)
287
+            visible = visible.replace(","," ")
288
+            
289
+            return(name, visible)
290
+        
291
+    def returnSkaterAnim(objIndex, valueIndex, own):  
292
+        #print('getting anim list') 
293
+        #print(objIndex-2)     
294
+        skaterAnimList = own['skaterAnimList']
295
+        #print(skaterAnimList)
296
+        if skaterAnimList:
297
+            name = skaterAnimList[objIndex-2]
298
+
299
+            skaterAnim = skaterAnimList[valueIndex-2]
300
+            name = name.replace(" ","")           
301
+            skaterAnim = str(skaterAnim)
302
+            skaterAnim = skaterAnim.replace(","," ") 
303
+            if skaterAnim == 'control_cube.002':
304
+                skaterAnim = skaterAnimList[valueIndex-3]
305
+                name = name.replace(" ","")           
306
+                skaterAnim = str(skaterAnim)
307
+                skaterAnim = skaterAnim.replace(","," ") 
308
+            #print(skaterAnim, (objIndex-2), (valueIndex-2)) 
309
+            #print(skaterAnimList)         
310
+            return(name, skaterAnim) 
311
+        
312
+    def returnSkaterAnimF(objIndex, valueIndex, own): 
313
+        skaterAnimFList =  own['skaterAnimFList']      
314
+        if skaterAnimFList:
315
+            name = skaterAnimFList[objIndex-2]
316
+            skaterAnimF = skaterAnimFList[valueIndex-2]
317
+            name = name.replace(" ","")
318
+            skaterAnimF = str(skaterAnimF)
319
+            skaterAnimF = skaterAnimF.replace(","," ")
320
+            #print('sOi', objIndex, 'sVi', valueIndex)
321
+            return(name, skaterAnimF)  
322
+        
323
+    def returnDeckAnim(objIndex, valueIndex, own): 
324
+        #print(objIndex-2)   
325
+        deckAnimList = own['deckAnimList']
326
+        if deckAnimList:
327
+            name = deckAnimList[objIndex-2]
328
+            deckAnim = deckAnimList[valueIndex-2]
329
+            name = name.replace(" ","")
330
+            deckAnim = str(deckAnim)
331
+            deckAnim = deckAnim.replace(","," ")
332
+            if deckAnim == 'control_cube.002':
333
+                deckAnim = deckAnimList[valueIndex-3]
334
+                name = name.replace(" ","")
335
+                deckAnim = str(deckAnim)
336
+                deckAnim = deckAnim.replace(","," ")
337
+            #print(deckAnim, (objIndex-2), (valueIndex-2))
338
+            #print('dOi', objIndex, 'dVi', valueIndex)            
339
+            return(name, deckAnim) 
340
+        
341
+    def returnDeckAnimF(objIndex, valueIndex, own):
342
+        deckAnimFList = own['deckAnimFList']
343
+        if deckAnimFList:
344
+            name = deckAnimFList[objIndex-2]
345
+            deckAnimF = deckAnimFList[valueIndex-2]
346
+            name = name.replace(" ","")
347
+            deckAnimF = str(deckAnimF)
348
+            deckAnimF = deckAnimF.replace(","," ")            
349
+            return(name, deckAnimF)
350
+###
351
+    def returnSrollVol(objIndex, valueIndex):
352
+        if srollVolList:
353
+            name = srollVolList[objIndex-2]
354
+            srollVol = srollVolList[valueIndex-2]
355
+            name = name.replace(" ","")
356
+            srollVol = str(srollVol)
357
+            srollVol = srollVol.replace(","," ")
358
+            srollVol = float(srollVol)
359
+            return(name, srollVol)
360
+        
361
+    def returnSrollPitch(objIndex, valueIndex):
362
+        if srollPitchList:
363
+            name = srollPitchList[objIndex-2]
364
+            srollPitch = srollPitchList[valueIndex-2]
365
+            name = name.replace(" ","")
366
+            srollPitch = str(srollPitch)
367
+            srollPitch = srollPitch.replace(","," ")
368
+            srollPitch = float(srollPitch)
369
+            return(name, srollPitch)                             ####
370
+###
371
+    def returnSgrind_cementVol(objIndex, valueIndex):
372
+        if sgrind_cementVolList:
373
+            name = sgrind_cementVolList[objIndex-2]
374
+            sgrind_cementVol = sgrind_cementVolList[valueIndex-2]
375
+            name = name.replace(" ","")
376
+            sgrind_cementVol = str(sgrind_cementVol)
377
+            sgrind_cementVol = sgrind_cementVol.replace(","," ")
378
+            sgrind_cementVol = float(sgrind_cementVol)
379
+            return(name, sgrind_cementVol)
380
+        
381
+    def returnSgrind_cementPitch(objIndex, valueIndex):
382
+        if sgrind_cementPitchList:
383
+            name = sgrind_cementPitchList[objIndex-2]
384
+            sgrind_cementPitch = sgrind_cementPitchList[valueIndex-2]
385
+            name = name.replace(" ","")
386
+            sgrind_cementPitch = str(sgrind_cementPitch)
387
+            sgrind_cementPitch = sgrind_cementPitch.replace(","," ")
388
+            sgrind_cementPitch = float(sgrind_cementPitch)
389
+            return(name, sgrind_cementPitch)                             ####              
390
+###
391
+    def returnSgrind_railVol(objIndex, valueIndex):
392
+        if sgrind_railVolList:
393
+            name = sgrind_railVolList[objIndex-2]
394
+            sgrind_railVol = sgrind_railVolList[valueIndex-2]
395
+            name = name.replace(" ","")
396
+            sgrind_railVol = str(sgrind_railVol)
397
+            sgrind_railVol = sgrind_railVol.replace(","," ")
398
+            sgrind_railVol = float(sgrind_railVol)
399
+            return(name, sgrind_railVol)
400
+        
401
+    def returnSgrind_railPitch(objIndex, valueIndex):
402
+        if sgrind_railPitchList:
403
+            name = sgrind_railPitchList[objIndex-2]
404
+            sgrind_railPitch = sgrind_railPitchList[valueIndex-2]
405
+            name = name.replace(" ","")
406
+            sgrind_railPitch = str(sgrind_railPitch)
407
+            sgrind_railPitch = sgrind_railPitch.replace(","," ")
408
+            sgrind_railPitch = float(sgrind_railPitch)
409
+            return(name, sgrind_railPitch)                             ####
410
+    def returnSpopsound(objIndex, valueIndex):
411
+        if spopsoundList:
412
+            name = spopsoundList[objIndex-2]
413
+            spopsound = spopsoundList[valueIndex-2]
414
+            name = name.replace(" ","")
415
+            spopsound = str(spopsound)
416
+            spopsound = spopsound.replace(","," ")
417
+            spopsound = int(spopsound)
418
+            return(name, spopsound)
419
+    def returnSlandsound(objIndex, valueIndex):
420
+        if slandsoundList:
421
+            name = slandsoundList[objIndex-2]
422
+            slandsound = slandsoundList[valueIndex-2]
423
+            name = name.replace(" ","")
424
+            slandsound = str(slandsound)
425
+            slandsound = slandsound.replace(","," ")
426
+            slandsound = int(slandsound)
427
+            return(name, slandsound) 
428
+    def returnSdeckvis(objIndex, valueIndex):
429
+        if sdeckvisList:
430
+            name = sdeckvisList[objIndex-2]
431
+            sdeckvis = sdeckvisList[valueIndex-2]
432
+            name = name.replace(" ","")
433
+            sdeckvis = str(sdeckvis)
434
+            sdeckvis = sdeckvis.replace(","," ")
435
+            sdeckvis = int(sdeckvis)
436
+            return(name, sdeckvis) 
437
+        
438
+    def returntdPosition(objIndex, valueIndex):
439
+        
440
+        if positiontdList:
441
+            name = positiontdList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
442
+            position = positiontdList[valueIndex-2]
443
+            name = name.replace(" ","")
444
+            position = str(position)
445
+            position = position.replace(","," ")
446
+            pX = float(position.split()[0])
447
+            pY = float(position.split()[1])
448
+            pZ = float(position.split()[2])
449
+            position = [pX,pY,pZ]
450
+            return(name, position)
451
+
452
+    def returntdOrientation(objIndex, valueIndex):
453
+        if orientationtdList:
454
+            name = orientationtdList[objIndex-2]
455
+            orientation = orientationtdList[valueIndex-2]
456
+            name = name.replace(" ","")
457
+            orientation = str(orientation)
458
+            orientation = orientation.replace(","," ")
459
+            orientation = orientation.split()
460
+            return(name, orientation)     
461
+        
462
+    def returnSrevertsound(objIndex, valueIndex):
463
+        if srevertsoundList:
464
+            name = srevertsoundList[objIndex-2]
465
+            srevertsound = srevertsoundList[valueIndex-2]
466
+            name = name.replace(" ","")
467
+            srevertsound = str(srevertsound)
468
+            srevertsound = srevertsound.replace(","," ")
469
+            srevertsound = int(srevertsound)
470
+            return(name, srevertsound)           
471
+                       
472
+###                
473
+
474
+    def getLengthPos(own):
475
+        positionList = own['positionList'] 
476
+        if positionList:
477
+            return(len(positionList))
478
+
479
+    def getLengthOri(own):
480
+        orientationList = own['orientationList']
481
+        if orientationList:
482
+            return(len(orientationList))
483
+
484
+    def getLengthSca():
485
+        if scaleList:
486
+            return(len(scaleList))
487
+
488
+    def getLengthCol():
489
+        if colorList:
490
+            return(len(colorList))
491
+    
492
+    def getLengthSta():
493
+        if stateList:
494
+            return(len(stateList))
495
+    
496
+    def getLengthVis():
497
+        if visibilityList:
498
+            return(len(visibilityList))
499
+    def getLengthSkaterAnim(own):
500
+        skaterAnimList = own['skaterAnimList']
501
+        if skaterAnimList:
502
+            return(len(skaterAnimList)) 
503
+    def getLengthSkaterAnimF(own):
504
+        skaterAnimFList = own['skaterAnimFList']
505
+        if skaterAnimFList:
506
+            return(len(skaterAnimFList)) 
507
+    def getLengthDeckAnim(own):
508
+        deckAnimList = own['deckAnimList']
509
+        if deckAnimList:
510
+            return(len(deckAnimList)) 
511
+    def getLengthDeckAnimF(own):
512
+        deckAnimFList = own['deckAnimFList']
513
+        if deckAnimFList:
514
+            #print(len(deckAnimFList), 'deckanimflisht')
515
+            return(len(deckAnimFList))
516
+    def getLengthSrollVol():
517
+        if srollVolList:
518
+            return(len(srollVolList)) 
519
+    def getLengthSrollPitch():
520
+        if srollPitchList:
521
+            return(len(srollPitchList)) 
522
+    def getLengthSgrind_cementVol():
523
+        if sgrind_cementVolList:
524
+            return(len(sgrind_cementVolList)) 
525
+    def getLengthSgrind_cementPitch():
526
+        if sgrind_cementPitchList:
527
+            return(len(sgrind_cementPitchList))
528
+    def getLengthSgrind_railVol():
529
+        if sgrind_railVolList:
530
+            return(len(sgrind_railVolList)) 
531
+    def getLengthSgrind_railPitch():
532
+        if sgrind_railPitchList:
533
+            return(len(sgrind_railPitchList))
534
+    def getLengthSpopsound():
535
+        if spopsoundList:
536
+            return(len(spopsoundList)) 
537
+    def getLengthSlandsound():
538
+        if slandsoundList:
539
+            return(len(slandsoundList)) 
540
+    def getLengthSdeckvis():
541
+        if sdeckvisList:
542
+            return(len(sdeckvisList))   
543
+    def getLengthtdPos():
544
+        if positiontdList:
545
+            return(len(positiontdList))
546
+    def getLengthtdOri():
547
+        if orientationtdList:
548
+            return(len(orientationtdList))
549
+    def getLengthSrevertsound():
550
+        if srevertsoundList:
551
+            return(len(srevertsoundList))    
552
+             
553
+                                                                                                    

+ 229
- 0
ai_manager.py View File

@@ -0,0 +1,229 @@
1
+def printplaying(skater,deck):
2
+    splaying_layers = "S: "
3
+    playing_layers = "D: "
4
+    tplaying_layers = "T: "
5
+    for x in range(9999):
6
+        if skater.isPlayingAction(x):
7
+        #if trucks.isPlayingAction(x):
8
+        #if skater.isPlayingAction(x):                        
9
+            splaying_layers += str(x)
10
+            splaying_layers += " "        
11
+        if deck.isPlayingAction(x):
12
+        #if trucks.isPlayingAction(x):
13
+        #if skater.isPlayingAction(x):                        
14
+            playing_layers += str(x)
15
+            playing_layers += " "
16
+          
17
+    print(splaying_layers, playing_layers)
18
+
19
+
20
+
21
+
22
+def main():
23
+
24
+    frame_rate = 60    #Set this to the framerate of your game.
25
+    optimization = 1    #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
26
+    #recording_cutoff = 6974#7300 #3600   #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
27
+    
28
+    recorder_state = 1   #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
29
+    allow_playback_break = True   #Allow the player to resume playing from the position in the recording.
30
+
31
+    from bge import logic
32
+    import aiRecord
33
+    import aiSortData
34
+    import npcChangeAnim
35
+    from mathutils import Vector
36
+    import math
37
+    
38
+
39
+    cont = logic.getCurrentController()
40
+    own = cont.owner
41
+    scene = logic.getCurrentScene()
42
+    dict = logic.globalDict
43
+    own['valueIndex'] = own['valueIndex'] + 20
44
+    #dict['recorder_on'] = recorder_on
45
+    npc_index = own['npc_index']
46
+    skater = dict['spawned_npcs'][npc_index]
47
+    recorder_on = dict.get('recorder_on')
48
+    own['recorder_on'] = recorder_on
49
+    #print("recorder on: ", recorder_on) 
50
+    own["playback"] = True
51
+    recording_cutoff = own['replay_length']
52
+    idle_timer = own['idle_timer']
53
+    npc_playback = own['npc_playback']
54
+    if 'data_loaded' not in own:
55
+        own['data_loaded'] = 1
56
+        aiRecord.loadData(cont, own)
57
+    if npc_playback == True:
58
+        cube = own
59
+        aiRecord.loadData(cont, own)   
60
+        #own['move'] = False          
61
+        #....................
62
+
63
+        valueIndex = own['valueIndex']
64
+        n = (valueIndex / recording_cutoff) * 1000
65
+        n = int(round(n))
66
+        #print(own['valueIndex'])
67
+        if own['objIndex'] < (recording_cutoff-3):
68
+            own['objIndex'] = own['objIndex'] + 2
69
+        else:
70
+            own['objIndex'] = 4   
71
+            print('replay end') 
72
+#            try:
73
+#                tActu = cont.actuators['npcSteering']
74
+#                cont.deactivate(tActu)
75
+
76
+#                
77
+#            except:
78
+#                print('no target to delete')    
79
+            npcChangeAnim.main(cont)
80
+            #own['npc_replay_name'] = '30secA.dat'
81
+            own['inited'] = False
82
+            own['rotate_in'] = True
83
+            own['move_to'] = True
84
+            own['rotate_out'] = True 
85
+            aiRecord.loadData(cont, own)
86
+    else:
87
+        if idle_timer < 5:
88
+            idle_timer += 1
89
+            #print('idling', idle_timer)
90
+        else:
91
+            idle_timer = 0
92
+            own['npc_rotate'] = True 
93
+#    if own['npc_rotate'] == True:
94
+#        xyz = own.localOrientation.to_euler()
95
+#        rotz = math.degrees(xyz[2])
96
+#        print (rotz, own['rpStartZ'], '---rotations')
97
+#        num = rotz - own['rpStartZ']
98
+#        amt = .05
99
+#        amt2 = 2
100
+#        if abs(num) < amt2:
101
+#            own['npc_playback'] = True
102
+#            own['npc_rotate'] = False
103
+#            print('----starting replay', num)
104
+#        elif rotz > own['rpStartZ']:
105
+#            own.applyRotation([0,0,-amt], True)
106
+#        elif rotz < own['rpStartZ']:
107
+#            own.applyRotation([0,0,amt], True)                 
108
+            
109
+    if own['move'] == True:
110
+        speed = .15
111
+        target = own['rpStartLoc']
112
+        my_vector = Vector([target[0], target[1], target[2]])
113
+        length = (own.worldPosition - my_vector).length
114
+        obj = own['target_object_name']
115
+        vect = own.getVectTo(obj)   
116
+        if length < .1:
117
+            own['move'] = False
118
+            obj = own['target_object_name']
119
+    own['idle_timer'] = idle_timer   
120
+    
121
+    try:
122
+        obj = own['target_object_name']
123
+        #print(obj.worldPosition)
124
+    except:
125
+        pass    
126
+    
127
+    
128
+    #11111111
129
+    if own['rotate_in'] == False and own['move_to'] == False and own['rotate_out'] == False:
130
+        own['npc_playback'] = True
131
+        #obj = own['target_object_name']
132
+        #obj.endObject()
133
+        #print('ending target')    
134
+    if own['rotate_in'] == True:
135
+        tActu = cont.actuators['npcTracking']
136
+        tActu.object = own['target_object_name']
137
+        try:
138
+            own['rotate_in_timer'] = own['rotate_in_timer'] + 1
139
+        except:
140
+            own['rotate_in_timer'] = 0
141
+        if own['rotate_in_timer'] < 120:    
142
+            cont.activate(tActu)
143
+            skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)  
144
+        else:
145
+            cont.deactivate(tActu) 
146
+            own['rotate_in'] = False
147
+            own['rotate_in_timer'] = 0
148
+            skater.stopAction(2)
149
+
150
+    elif own['move_to'] == True:
151
+        target = own['rpStartLoc']
152
+        #print(target, 'target', own.worldPosition, '++++++')
153
+        my_vector = Vector([target[0], target[1], target[2]])
154
+        length = (own.worldPosition - my_vector).length
155
+        sActu = cont.actuators['npcSteering']
156
+        sActu.target = own['target_object_name']
157
+        #length = round(length, 7)
158
+        if length > .1:
159
+            #print(length, 'length < .1')
160
+            #pass
161
+            cont.activate(sActu)
162
+            skater.playAction('reg_nwalk', 0,35, layer=2, play_mode=1, speed=.5)
163
+        else:
164
+            cont.deactivate(sActu)
165
+            own['move_to'] = False
166
+            print(length, 'length met')
167
+            skater.stopAction(2)
168
+
169
+    elif own['rotate_out'] == True:    
170
+        #own['rpStartZ'] = 180
171
+        #print(own['rpStartZ'], 'start')
172
+        xyz = own.localOrientation.to_euler()
173
+        #print(xyz[2], 'non euler')
174
+        rotz = math.degrees(xyz[2])
175
+        xyz[2] = xyz[2] + 1.57
176
+        rotz_b = rotz + 180
177
+        if rotz_b > 360:
178
+            rotz_b -= 360
179
+        srotz_b = own['rpStartZ'] + 180
180
+        if srotz_b > 360:
181
+            srotz_b -= 360
182
+        #print (rotz_b, srotz_b, '---rotations')        
183
+        #print (rotz, own['rpStartZ'], '---rotations')
184
+        num = rotz - (own['rpStartZ'])
185
+        amt = .03
186
+        amt2 = 1
187
+        
188
+        
189
+        local = own.worldOrientation.inverted() * ( own['target_object_name'].worldPosition - own.worldPosition) 
190
+
191
+        if local.x >0:
192
+            #target is in front
193
+            #print('in front')
194
+            pass
195
+        else:
196
+            #target is behind
197
+            #print('behind')
198
+            pass
199
+        if local.y > 0:
200
+                 #object on right
201
+            #print('on right')
202
+            rot = 'right'
203
+        else:
204
+                 #object is on left 
205
+            #print('on left')
206
+            rot = 'left'       
207
+        
208
+        
209
+        
210
+        skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)
211
+        if abs(num) < amt2:
212
+            own['npc_playback'] = True
213
+            own['npc_rotate'] = False
214
+            print('----starting replay', num)
215
+            own['rotate_out'] = False
216
+            obj = own['target_object_name']
217
+            obj.endObject()
218
+            print('ending target') 
219
+            skater.stopAction(2)            
220
+        #elif rotz > own['rpStartZ']:
221
+        elif rot == 'right':    
222
+            own.applyRotation([0,0,amt], True)
223
+            own.worldPosition = own['rpStartLoc']
224
+        #elif rotz < own['rpStartZ']:
225
+        elif rot == 'left':    
226
+            own.applyRotation([0,0,-amt], True) 
227
+            own.worldPosition = own['rpStartLoc']                
228
+    #print(own['rotate_in'], own['move_to'], own['rotate_out'])                          
229
+main()

+ 318
- 0
bike.py View File

@@ -0,0 +1,318 @@
1
+
2
+
3
+import bge
4
+from mathutils import Vector
5
+
6
+dict = bge.logic.globalDict
7
+scene = bge.logic.getCurrentScene()
8
+skater = scene.objects["Char4"]
9
+TURN_SENS = .04
10
+TURNAMT = .03
11
+ACCEL_AMT = .05
12
+
13
+def get_physics_action(cont, own):
14
+    #print(dict['lLR'])
15
+    action = 'None'
16
+    
17
+    lLR = dict['lLR']
18
+    lUD = dict['lUD']
19
+    rLR = dict['rLR']
20
+    rUD = dict['rUD']
21
+    lTrig = dict['lTrig']
22
+    rTrig = dict['rTrig']
23
+    aBut = dict['aBut']
24
+    bBut = dict['bBut']
25
+    xBut = dict['xBut']
26
+    yBut = dict['yBut']
27
+    lBump = dict['lBump']
28
+    rBump = dict['rBump']
29
+    bkBut = dict['bkBut']
30
+    stBut = dict['stBut']
31
+    xbBut = dict['xbBut']
32
+    ltsBut = dict['ltsBut']
33
+    rtsBut = dict['rtsBut']
34
+    ldPad = dict['ldPad']
35
+    rdPad = dict['rdPad']
36
+    udPad = dict['udPad']
37
+    ddPad = dict['ddPad']    
38
+    
39
+    q1oncd = own["Q1oncd"]
40
+    q2oncd = own["Q2oncd"]
41
+    q3oncd = own["Q3oncd"]
42
+    q4oncd = own["Q4oncd"]
43
+    q5oncd = own["Q5oncd"]
44
+    q6oncd = own["Q6oncd"]
45
+    q7oncd = own["Q7oncd"]
46
+    q8oncd = own["Q8oncd"]
47
+    q1oncdl = own["Q1oncdl"]
48
+    q2oncdl = own["Q2oncdl"]
49
+    q3oncdl = own["Q3oncdl"]
50
+    q4oncdl = own["Q4oncdl"]
51
+    q5oncdl = own["Q5oncdl"]
52
+    q6oncdl = own["Q6oncdl"]
53
+    q7oncdl = own["Q7oncdl"]
54
+    q8oncdl = own["Q8oncdl"]
55
+
56
+    q1on = 0
57
+    q2on = 0
58
+    q3on = 0
59
+    q4on = 0
60
+    q5on = 0
61
+    q6on = 0
62
+    q7on = 0
63
+    q8on = 0
64
+    lq1on = 0
65
+    lq2on = 0
66
+    lq3on = 0
67
+    lq4on = 0
68
+    lq5on = 0
69
+    lq6on = 0
70
+    lq7on = 0
71
+    lq8on = 0
72
+    
73
+    countdown = 20    
74
+    
75
+    
76
+    ##################
77
+    ###realcontrols###
78
+    ##################
79
+    #       q1
80
+    #    q8    q2
81
+    # q7          q3
82
+    #    q6    q4
83
+    #       q5
84
+    ##################    
85
+    
86
+    if lUD > .04 and lLR < -0.04 :
87
+        lq6on = 1
88
+        q6oncdl = countdown
89
+        own["Q6oncdl"] = q6oncdl
90
+        #print("lq6on")
91
+    elif q6oncdl > 0:
92
+        lq6on = 0
93
+        q6oncdl = q6oncdl - 1
94
+        own["Q6oncdl"] = q6oncdl
95
+    #lq8
96
+    if lUD < -.04 and lLR < -0.04 :
97
+        lq8on = 1
98
+        q8oncdl = countdown
99
+        own["Q8oncdl"] = q8oncdl
100
+        #print("lq8on")
101
+    elif q8oncdl > 0:
102
+        lq8on = 0
103
+        q8oncdl = q8oncdl - 1
104
+        own["Q8oncdl"] = q8oncdl
105
+    #lq2
106
+    if lUD < -.04 and lLR > 0.04 :
107
+        lq2on = 1
108
+        q2oncdl = countdown
109
+        own["Q2oncdl"] = q2oncdl
110
+        #print("lq2on")
111
+    elif q2oncdl > 0:
112
+        lq2on = 0
113
+        q2oncdl = q2oncdl - 1
114
+        own["Q2oncdl"] = q2oncdl
115
+    #q4
116
+    if lUD > 0.04 and lLR > 0.04 :
117
+        lq4on = 1
118
+        q4oncdl = countdown
119
+        own["Q4oncdl"] = q4oncdl
120
+        #print("lq4on")
121
+    elif q4oncdl > 0:
122
+        lq4on = 0
123
+        q4oncdl = q4oncdl - 1
124
+        own["Q4oncdl"] = q4oncdl  
125
+    #q5
126
+    if lUD > .070 and lq4on == 0 and lq6on == 0:
127
+        lq5on = 1
128
+        q5oncdl = countdown
129
+        own["Q5oncdl"] = q5oncdl
130
+        #print("lq5on")
131
+    elif q5oncdl > 0:
132
+        lq5on = 0
133
+        q5oncdl = q5oncdl - 1
134
+        own["Q5oncdl"] = q5oncdl   
135
+    #q1    
136
+    if lUD < -0.070 and lq8on !=1 and lq2on != 1:
137
+        lq1on = 1
138
+        q1oncdl = countdown
139
+        own["Q1oncdl"] = q1oncdl
140
+        #print("lq1on")              
141
+    elif q1oncdl > 0:
142
+        lq1on = 0
143
+        q1oncdl = q1oncdl - 1
144
+        own["Q1oncdl"] = q1oncdl   
145
+    #q7
146
+    if lLR < -0.070 and lq8on != 1 and lq6on != 1:
147
+        lq7on = 1
148
+        q7oncdl = countdown
149
+        own["Q7oncdl"] = q7oncdl
150
+        #print("lq7on")       
151
+    elif q7oncdl > 0:
152
+        lq7on = 0
153
+        q7oncdl = q7oncdl - 1
154
+        own["Q7oncdl"] = q7oncdl  
155
+    #q3    
156
+    if lLR > 0.070 and lq2on !=1 and lq4on != 1:
157
+        lq3on = 1
158
+        q3oncdl = countdown
159
+        own["Q3oncdl"] = q3oncdl
160
+        #print("lq3on") 
161
+    elif q3oncdl > 0:
162
+        lq3on = 0
163
+        q3oncdl = q3oncdl - 1
164
+        own["Q3oncdl"] = q3oncdl       
165
+         
166
+    ################
167
+    #q6
168
+    if rUD > .04 and rLR < -0.04 :
169
+        q6on = 1
170
+        q6oncd = countdown
171
+        own["Q6oncd"] = q6oncd
172
+        #print("q6on")
173
+    elif q6oncd > 0:
174
+        q6on = 0
175
+        q6oncd = q6oncd - 1
176
+        own["Q6oncd"] = q6oncd
177
+        
178
+    #q8
179
+    if rUD < -.04 and rLR < -0.04 :
180
+        q8on = 1
181
+        q8oncd = countdown
182
+        own["Q8oncd"] = q8oncd
183
+        #print("q8on")
184
+    elif q8oncd > 0:
185
+        q8on = 0
186
+        q8oncd = q8oncd - 1
187
+        own["Q8oncd"] = q8oncd
188
+    #q2
189
+    if rUD < -.04 and rLR > 0.04 :
190
+        q2on = 1
191
+        q2oncd = countdown
192
+        own["Q2oncd"] = q2oncd
193
+        #print("q2on")
194
+    elif q2oncd > 0:
195
+        q2on = 0
196
+        q2oncd = q2oncd - 1
197
+        own["Q2oncd"] = q2oncd
198
+        
199
+    #q4
200
+    if rUD > 0.04 and rLR > 0.04 :
201
+        q4on = 1
202
+        q4oncd = countdown
203
+        own["Q4oncd"] = q4oncd
204
+        #print("q4on")
205
+    elif q4oncd > 0:
206
+        q4on = 0
207
+        q4oncd = q4oncd - 1
208
+        own["Q4oncd"] = q4oncd
209
+    #q5
210
+    if rUD > .070 or dict['kb_space'] == 2:
211
+        if q4on == 0 and q6on == 0:
212
+            q5on = 1
213
+            q5oncd = countdown
214
+            own["Q5oncd"] = q5oncd  
215
+    elif q5oncd > 0:
216
+        q5on = 0
217
+        q5oncd = q5oncd - 1
218
+        own["Q5oncd"] = q5oncd              
219
+
220
+    #q1    
221
+    if rUD < -0.070:
222
+        if q2on == 0 and q8on == 0:
223
+            #print("q1on")
224
+            q1on = 1
225
+            q1oncd = countdown
226
+            own["Q1oncd"] = q1oncd
227
+    elif q1oncd > 0:
228
+        q1on = 0
229
+        q1oncd = q1oncd - 1
230
+        own["Q1oncd"] = q1oncd            
231
+
232
+            
233
+      
234
+    #q7
235
+    if rLR < -0.070:
236
+        if q8on == 0 and q6on == 0:
237
+            q7on = 1
238
+            q7oncd = countdown
239
+            own["Q7oncd"] = q7oncd
240
+           
241
+    elif q7oncd > 0:
242
+        q7on = 0
243
+        q7oncd = q7oncd - 1
244
+        own["Q7oncd"] = q7oncd
245
+    #q3    
246
+    if rLR > 0.070:
247
+        if q4on == 0 and q2on == 0:
248
+            q3on = 1
249
+            q3oncd = countdown
250
+            own["Q3oncd"] = q3oncd
251
+    elif q3oncd > 0:
252
+        q3on = 0
253
+        q3oncd = q3oncd - 1
254
+        own["Q3oncd"] = q3oncd
255
+            
256
+     
257
+    
258
+    if dict['aBut'] == True:
259
+        action = 'forward'    
260
+    if dict['lLR'] > TURN_SENS:
261
+        action = 'turnR'
262
+    if dict['lLR'] < -TURN_SENS:
263
+        action = 'turnL'    
264
+    if q5oncd > 0 and q1oncd > 0 and q5oncd < q1oncd:
265
+        action = 'jump'           
266
+
267
+
268
+    return action
269
+
270
+def do_physics_action(cont, own, action):
271
+    if action == 'turnR':
272
+        own.applyRotation([0,0,-TURNAMT], True)
273
+    if action == 'turnL':
274
+        own.applyRotation([0,0,TURNAMT], True)
275
+    if action == 'forward':
276
+        own.linearVelocity.x = own.linearVelocity.x - ACCEL_AMT
277
+    
278
+    if action == 'jump':
279
+        own.applyForce([0,0,100], False)
280
+        print('jump')    
281
+    
282
+    gray = cont.sensors['r_Ground']
283
+    if gray.positive:
284
+        own.alignAxisToVect(Vector(gray.hitNormal)*1, 2, .25)
285
+    else:
286
+        own.alignAxisToVect(Vector([0,0,1]),2,.25)     
287
+    
288
+    own.linearVelocity.y = 0  
289
+    
290
+    if gray.positive:
291
+        own.linearVelocity.z = own.linearVelocity.z -.05    
292
+   
293
+def do_anims(cont, own):
294
+    
295
+    skater = scene.objects["Char4"]
296
+    skater.playAction("reg_bike.001", 20,20, layer=2, play_mode=1, speed=1)
297
+       
298
+        
299
+def main(cont):
300
+    own = cont.owner
301
+    try:
302
+        bike = scene.objects['player_bike']
303
+        #print('biking')
304
+        if dict['yBut'] == True and dict['last_yBut'] == False:
305
+            cont.activate(cont.actuators['walk'])
306
+            pbike = scene.addObject('prop_bike', own, 0)
307
+            pbike.localScale = [4.6, 4.6, 4.6]
308
+            pbike.localScale = [1, 1, 1] 
309
+            pbike.applyRotation([0,0,1.570796], False)
310
+            pbike.worldPosition.y = pbike.worldPosition.y - 1.       
311
+            bike.endObject()
312
+            skater.stopAction(9)
313
+        
314
+        action = get_physics_action(cont, own)
315
+        do_physics_action(cont, own, action)
316
+        do_anims(cont,own)
317
+    except:
318
+        pass    

+ 139
- 0
load_npc.py View File

@@ -0,0 +1,139 @@
1
+
2
+import bge
3
+from mathutils import Vector
4
+
5
+def rot_deck(cont):
6
+      
7
+    scene = bge.logic.getCurrentScene()
8
+    deck = scene.objects['npc_ed_deck']
9
+    #rot = [ 0.0, 0.0, -1.570796327]
10
+    print('rotating')
11
+    deck.alignAxisToVect(Vector([1,0,0]),2,.25) 
12
+    #rot = [ 0.0, 0.0, -0.10796327]
13
+    #deck.applyRotation(rot,True) 
14
+    #print('rotating')    
15
+    
16
+def collect_npc(cont):
17
+    #add ed
18
+    own = cont.owner
19
+    scene = bge.logic.getCurrentScene()
20
+    dict = bge.logic.globalDict
21
+    objList = scene.objects   
22
+    
23
+    try:
24
+        spawned_list = dict['spawned_npc_list']
25
+        to_spawn = dict['to_spawn']
26
+    except:
27
+        dict['spawned_npc_list'] = []  
28
+        dict['to_spawn'] = []  
29
+        to_spawn = [] 
30
+        own['npc_index'] = 0
31
+    
32
+    npc_index = 0
33
+    for x in objList:
34
+        
35
+        if 'npc_skater' in x:
36
+            
37
+            dict['to_spawn'].append(x)
38
+            print(x.name, 'added to list')
39
+            
40
+def spawn_npc(cont):
41
+    own = cont.owner
42
+    scene = bge.logic.getCurrentScene()
43
+    dict = bge.logic.globalDict
44
+    objList = scene.objects 
45
+    to_spawn = dict['to_spawn']
46
+    #print(to_spawn)
47
+    npc_index = own['npc_index']
48
+    
49
+    if to_spawn:
50
+        x = dict['to_spawn'][0]  
51
+        print(x) 
52
+        
53
+        x['rpStartLoc'] = [0.0,0.0,0.0] 
54
+        x['rpStartLoc_set'] = False
55
+        x['move'] = False  
56
+        x['npc_rotate'] = False 
57
+        x['rotate_in'] = False
58
+        x['move_to'] = False
59
+        x['rotate_out'] = False      
60
+
61
+        obj = scene.addObject('npc_ed_deck', own, 0)
62
+        obj.setParent(x, False, False)            
63
+        dict['spawned_npc_decks'].append(obj)
64
+        obj = scene.addObject('npc_ed_trucks', own, 0)
65
+        obj.setParent(x, False, False)            
66
+        dict['spawned_npc_trucks'].append(obj)
67
+        obj = scene.addObject('npc_ed_arm', own, 0)
68
+        obj.setParent(x, False, False)
69
+        dict['spawned_npcs'].append(obj)
70
+                
71
+        if npc_index == 0:        
72
+            shirt = obj.children["npc:Zshirtt1"]
73
+            shirt.color = [.9,.1,.1,1]
74
+        if npc_index == 1:        
75
+            shirt = obj.children["npc:Zshirtt1"]
76
+            shirt.color = [.1,.9,.1,1]
77
+        if npc_index == 2:        
78
+            shirt = obj.children["npc:Zshirtt1"]
79
+            shirt.color = [.1,.1,.9,1]                        
80
+        
81
+        
82
+        #rot = [ 0.0, 0.0, 1.570796327]
83
+        x['npc_index'] = npc_index
84
+        npc_index += 1
85
+        own['npc_index'] = npc_index
86
+        print('adding npc character: ', x.name, obj.name)
87
+        dict['to_spawn'].remove(x)
88
+        
89
+        shirt = scene.objects["npc:Zshirtt1"]
90
+        shirt.color = [255,0,0,1]
91
+    
92
+def main():  
93
+    cont = bge.logic.getCurrentController()
94
+    own = cont.owner
95
+    scene = bge.logic.getCurrentScene()
96
+    #actu = cont.actuators['start_level']
97
+    dict = bge.logic.globalDict
98
+    objList = scene.objects
99
+    mainDir = bge.logic.expandPath("//")
100
+    skater = 'ai_ed'
101
+    
102
+    fileName = mainDir + "npc_skaters/" + str(skater) + '.blend'    
103
+    
104
+    path = bge.logic.expandPath(fileName)
105
+    try:
106
+        bge.logic.LibLoad(path, 'Scene') 
107
+    except:
108
+        print('trying to load', fileName, 'twice')    
109
+    
110
+
111
+    # get object named MainCharacter
112
+    #armature = objList["npc_ed_arm"]
113
+    #deck = objList['npc_ed_deck']
114
+    #trucks = objList['npc_ed_trucks']
115
+
116
+    # combine child's shape with parent's
117
+    compound = False
118
+
119
+    # child is solid
120
+    ghost = False
121
+    
122
+    # rotate the game object 1.570796327 radians (90 degrees)
123
+    #rot = [ 0.0, 0.0, -1.570796327]
124
+    #deck.applyRotation(rot,False)     
125
+
126
+    # set parent
127
+    #for x in [armature, deck, trucks]:
128
+        #x.setParent( own, compound, ghost) 
129
+        #rot = [ 0.0, 0.0, -1.570796327]
130
+        #deck.applyRotation(rot,True)     
131
+            
132
+
133
+       
134
+    #rot = [ 0.0, 0.0, -1.570796327]
135
+    #deck.applyRotation(rot,True) 
136
+    print('loading ai') 
137
+
138
+main()
139
+        

+ 48
- 0
npcChangeAnim.py View File

@@ -0,0 +1,48 @@
1
+#npcChangeAnim
2
+
3
+import bge
4
+import random
5
+
6
+a_starts = ['20secA.dat', '20secE.dat', 'shopSaEa40a.dat', 'shopSaEb40a.dat', 'shopSaEb20a.dat', 'shopSaEa30a.dat']
7
+a_ends = ['20secA.dat', '20secE.dat', 'shopSaEa40a.dat', 'shopSbEa50a.dat', 'shopSbEa60a.dat', 'shopSaEa30a.dat']
8
+b_starts = ['shopSbEb40sec.dat', 'shopSbEa50a.dat', 'shopSbEa60a.dat', 'shopSbEb50a.dat']
9
+b_ends = ['shopSbEb40sec.dat', 'shopSaEb40a.dat', 'shopSaEb20a.dat', 'shopSbEb50a.dat']
10
+
11
+def main(cont):
12
+    own = cont.owner
13
+    own['npc_playback'] = False
14
+    
15
+    if own['npc_replay_name'] in a_ends:
16
+        num = len(a_starts) - 1
17
+        ran = random.randint(0,num)
18
+        own['npc_replay_name'] = a_starts[ran]
19
+    elif own['npc_replay_name'] in b_ends:
20
+        num = len(b_starts) - 1
21
+        ran = random.randint(0,num)
22
+        own['npc_replay_name'] = b_starts[ran]        
23
+    
24
+    if own['npc_replay_name'] == '20secA.dat':
25
+        own['replay_length'] = 2400
26
+    if own['npc_replay_name'] == '20secE.dat':
27
+        own['replay_length'] = 2400    
28
+    if own['npc_replay_name'] == 'shopSaEa40a.dat':
29
+        own['replay_length'] = 6500 
30
+    if own['npc_replay_name'] == 'shopSaEb40a.dat':
31
+        own['replay_length'] = 5500  
32
+    if own['npc_replay_name'] == 'shopSbEa50a.dat':
33
+        own['replay_length'] = 6500  
34
+    if own['npc_replay_name'] == 'shopSbEb40sec.dat':
35
+        own['replay_length'] = 6500 
36
+    if own['npc_replay_name'] == 'shopSaEb20a.dat':
37
+        own['replay_length'] = 2300     
38
+    if own['npc_replay_name'] == 'shopSbEa60a.dat':
39
+        own['replay_length'] = 7100 
40
+    if own['npc_replay_name'] == 'shopSaEa30a.dat':
41
+        own['replay_length'] = 3200 
42
+    if own['npc_replay_name'] == 'shopSbEb50a.dat':
43
+        own['replay_length'] = 6000                                             
44
+
45
+    print('Playing NPC-Replay:', own['npc_replay_name'])
46
+
47
+    
48
+    own['rpStartLoc_set'] = False  

Loading…
Cancel
Save