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