|
@@ -6,767 +6,800 @@ import sound_man
|
6
|
6
|
State = type("State", (object,), {})
|
7
|
7
|
#====================================
|
8
|
8
|
class State(object):
|
9
|
|
- def __init__(self, FSM):
|
10
|
|
- self.FSM = FSM
|
11
|
|
- self.timer = 0
|
12
|
|
- self.startTime = 0
|
13
|
|
- def Enter(self):
|
14
|
|
- self.timer = 0
|
15
|
|
- self.startTime = 0
|
16
|
|
- def Execute(self):
|
17
|
|
- print('Executing')
|
18
|
|
- def Exit(self):
|
19
|
|
- print('Exiting')
|
|
9
|
+ def __init__(self, FSM):
|
|
10
|
+ self.FSM = FSM
|
|
11
|
+ self.timer = 0
|
|
12
|
+ self.startTime = 0
|
|
13
|
+ def Enter(self):
|
|
14
|
+ self.timer = 0
|
|
15
|
+ self.startTime = 0
|
|
16
|
+ def Execute(self):
|
|
17
|
+ print('Executing')
|
|
18
|
+ def Exit(self):
|
|
19
|
+ print('Exiting')
|
20
|
20
|
|
21
|
21
|
#====================================
|
22
|
|
-
|
|
22
|
+
|
23
|
23
|
class Example(State):
|
24
|
|
- def __init__(self,FSM):
|
25
|
|
- super(Example, self).__init__(FSM)
|
26
|
|
-
|
27
|
|
- def Enter(self):
|
28
|
|
- self.FSM.stateLife = 1
|
29
|
|
- super(Example, self).Enter()
|
30
|
|
-
|
31
|
|
- def Execute(self):
|
32
|
|
- self.FSM.stateLife += 1
|
33
|
|
- #self.FSM.ToTransition('toExample')
|
34
|
|
-
|
35
|
|
- def Exit(self):
|
36
|
|
- pass
|
|
24
|
+ def __init__(self,FSM):
|
|
25
|
+ super(Example, self).__init__(FSM)
|
|
26
|
+
|
|
27
|
+ def Enter(self):
|
|
28
|
+ self.FSM.stateLife = 1
|
|
29
|
+ super(Example, self).Enter()
|
|
30
|
+
|
|
31
|
+ def Execute(self):
|
|
32
|
+ self.FSM.stateLife += 1
|
|
33
|
+ #self.FSM.ToTransition('toExample')
|
|
34
|
+
|
|
35
|
+ def Exit(self):
|
|
36
|
+ pass
|
37
|
37
|
|
38
|
38
|
#====================================
|
39
|
39
|
|
40
|
40
|
class Startup(State):
|
41
|
|
- def __init__(self,FSM):
|
42
|
|
- super(Startup, self).__init__(FSM)
|
43
|
|
-
|
44
|
|
- def Enter(self):
|
45
|
|
- self.FSM.stateLife = 1
|
46
|
|
- super(Startup, self).Enter()
|
47
|
|
-
|
48
|
|
- def Execute(self):
|
49
|
|
- self.FSM.stateLife += 1
|
50
|
|
-
|
51
|
|
- if self.FSM.stateLife == 5:
|
52
|
|
- self.FSM.ToTransition('toWalk')
|
53
|
|
- print('player FSM')
|
54
|
|
-
|
55
|
|
- def Exit(self):
|
56
|
|
- pass
|
|
41
|
+ def __init__(self,FSM):
|
|
42
|
+ super(Startup, self).__init__(FSM)
|
|
43
|
+
|
|
44
|
+ def Enter(self):
|
|
45
|
+ self.FSM.stateLife = 1
|
|
46
|
+ super(Startup, self).Enter()
|
|
47
|
+
|
|
48
|
+ def Execute(self):
|
|
49
|
+ self.FSM.stateLife += 1
|
|
50
|
+
|
|
51
|
+ if self.FSM.stateLife == 5:
|
|
52
|
+ self.FSM.ToTransition('toWalk')
|
|
53
|
+ print('player FSM')
|
|
54
|
+
|
|
55
|
+ def Exit(self):
|
|
56
|
+ pass
|
57
|
57
|
|
58
|
58
|
#====================================
|
59
|
|
-
|
|
59
|
+
|
60
|
60
|
class Walk(State):
|
61
|
|
- def __init__(self,FSM):
|
62
|
|
- super(Walk, self).__init__(FSM)
|
63
|
|
-
|
64
|
|
- def Enter(self):
|
65
|
|
- self.FSM.stateLife = 1
|
66
|
|
- o = self.FSM.owner.obj
|
67
|
|
- c = self.FSM.owner
|
68
|
|
- o['getoffboard'] = False
|
69
|
|
- o['getonboard'] = False
|
70
|
|
-
|
71
|
|
- if c.arm == None:
|
72
|
|
-
|
73
|
|
- c.arm = o.childrenRecursive['Char4']
|
74
|
|
- c.deck_arm = o.childrenRecursive['deck_arm']
|
75
|
|
- self.walk_weight = 1
|
76
|
|
- self.run_weight = 1
|
77
|
|
- self.run_speed = 0.0
|
78
|
|
- self.turn_weight = 0
|
79
|
|
- self.FSM.owner.walking = True
|
80
|
|
- dict['walking'] = True
|
81
|
|
- dict['walk'] = 1
|
82
|
|
- print('fsm enter walk')
|
83
|
|
-
|
84
|
|
- super(Walk, self).Enter()
|
85
|
|
-
|
86
|
|
- def Execute(self):
|
87
|
|
- self.FSM.stateLife += 1
|
88
|
|
- o = self.FSM.owner.obj
|
89
|
|
- c = self.FSM.owner
|
90
|
|
- #print(o.worldPosition.z)
|
91
|
|
- #print(o['getonboard'], 'dict onboard')
|
92
|
|
- #print(dict['walk'], 'fsm walk walk')
|
93
|
|
- # if self.FSM.stateLife == 2:
|
94
|
|
- # if o['stance']:
|
95
|
|
- # o.applyRotation([0,0,3.14], True)
|
96
|
|
- # o['stance'] = False
|
97
|
|
- # o['requestAction'] = 'fak_offboard'
|
98
|
|
- # print('request fak offboard')
|
99
|
|
- # else:
|
100
|
|
- # o['requestAction'] = 'reg_offboard'
|
101
|
|
- # print('request reg offboard')
|
102
|
|
- # if self.FSM.stateLife > 5:
|
103
|
|
- # o['requestAction'] = 'reg_idle'
|
104
|
|
- c.align_walk_z()
|
105
|
|
- ground_rays = c.get_ground_ray()
|
106
|
|
- #77777777777777777777777777777777777777777777777777777777777777777777777777777777777
|
107
|
|
- c.get_hang_align_ray()
|
108
|
|
- c.move_walk_cam()
|
109
|
|
- c.check_reset_point()
|
110
|
|
- c.check_throw()
|
111
|
|
-
|
112
|
|
- if ground_rays[0][0] != None:
|
113
|
|
- dist = c.get_ground_dist(ground_rays)
|
114
|
|
- if dist > .7:
|
115
|
|
- self.FSM.ToTransition('toWalkAir')
|
116
|
|
- #print('---falling')
|
117
|
|
- else:
|
118
|
|
- c.set_walk_z(dist)
|
119
|
|
- #print(dist, 'setting height')
|
120
|
|
-
|
121
|
|
- if self.FSM.stateLife > 4:
|
122
|
|
- self.check_onboard()
|
123
|
|
- self.check_jump()
|
124
|
|
-
|
125
|
|
- moving = c.walk_movement()
|
126
|
|
-
|
127
|
|
- self.get_walk_weight()
|
128
|
|
- self.idle_blend()
|
129
|
|
- else:
|
130
|
|
- dict['walk'] = 1
|
131
|
|
-
|
132
|
|
-
|
133
|
|
- def check_onboard(self):
|
134
|
|
-
|
135
|
|
- o = self.FSM.owner.obj
|
136
|
|
- #print(o['getonboard'], 'getonboard')
|
137
|
|
-
|
138
|
|
-
|
139
|
|
- if dict['walk'] == 0:
|
140
|
|
- o['getonboard'] = True
|
141
|
|
- #self.FSM.ToTransition('toRoll')
|
142
|
|
- self.FSM.ToTransition('toWalkOnboard')
|
143
|
|
- #print('onboard', dict['walk'], o['getonboard'])
|
144
|
|
- if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
145
|
|
-
|
146
|
|
-
|
147
|
|
- dropin = self.check_dropin()
|
148
|
|
- print('-----dropin', dropin)
|
149
|
|
- if dropin == None:
|
150
|
|
- o['getonboard'] = True
|
151
|
|
-
|
152
|
|
- self.FSM.ToTransition('toWalkOnboard')
|
153
|
|
- else:
|
154
|
|
- self.FSM.owner.dropin_obj = dropin
|
155
|
|
- self.FSM.ToTransition('toDropin')
|
156
|
|
-
|
157
|
|
-
|
158
|
|
-
|
159
|
|
- def check_dropin(self):
|
160
|
|
- dr = None
|
161
|
|
- ground_rays = self.FSM.owner.get_dropin_rays()
|
162
|
|
- for x in ground_rays:
|
163
|
|
- if x[0] != None:
|
164
|
|
- #print(x[0], '---checked')
|
165
|
|
- if 'coping' in x[0]:
|
166
|
|
- print('dropin collided')
|
167
|
|
- dr = x
|
168
|
|
- return dr
|
169
|
|
-
|
170
|
|
- def check_jump(self):
|
171
|
|
- if dict['xBut'] == True or dict['kb_space'] == 1:
|
172
|
|
- if dict['last_xBut'] == 0:
|
173
|
|
- self.FSM.ToTransition('toWalkJump')
|
174
|
|
-
|
175
|
|
-
|
176
|
|
- def idle_blend(self):
|
177
|
|
- arm = self.FSM.owner.arm
|
178
|
|
- deck = self.FSM.owner.deck_arm
|
179
|
|
- arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=10)
|
180
|
|
- deck.playAction('b_reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=10)
|
181
|
|
- if self.FSM.stateLife > 20:
|
182
|
|
- frame = arm.getActionFrame(2) + .5 * self.run_speed
|
183
|
|
- if frame > 30:
|
184
|
|
- frame = 0
|
185
|
|
- arm.stopAction(2)
|
186
|
|
- deck.stopAction(2)
|
187
|
|
- arm.playAction('reg_nwalk3', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
|
188
|
|
- deck.playAction('b_reg_walk', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
|
189
|
|
- #b_reg_walk
|
190
|
|
- arm.setActionFrame(frame, 2)
|
191
|
|
- deck.setActionFrame(frame, 2)
|
192
|
|
- #print(self.walk_weight, frame)
|
193
|
|
-
|
194
|
|
-
|
195
|
|
-
|
196
|
|
- frame = arm.getActionFrame(3) + .5 * self.run_speed
|
197
|
|
- if frame > 30:
|
198
|
|
- frame = 0
|
199
|
|
- arm.stopAction(3)
|
200
|
|
- deck.stopAction(3)
|
201
|
|
- arm.playAction('reg_run.003', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
|
202
|
|
- deck.playAction('b_reg_run', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
|
203
|
|
-
|
204
|
|
- arm.setActionFrame(frame, 3)
|
205
|
|
- deck.setActionFrame(frame, 3)
|
206
|
|
- #print(frame, 'frame')
|
207
|
|
- #print(self.run_weight, frame)
|
208
|
|
-
|
209
|
|
- # if self.turn_weight > 0:
|
210
|
|
- # tw = abs(self.turn_weight - 1)
|
211
|
|
- # #tw = self.turn_weight
|
212
|
|
- # arm.stopAction(4)
|
213
|
|
- # arm.playAction('bwalk_right', 1,60, layer=4, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=tw)
|
214
|
|
- # elif self.turn_weight < 0:
|
215
|
|
- # tw = abs(abs(self.turn_weight) - 1)
|
216
|
|
- # #tw = self.turn_weight
|
217
|
|
- # arm.stopAction(4)
|
218
|
|
- # arm.playAction('bwalk_left', 1,60, layer=4, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=tw)
|
219
|
|
- #print('walk_weight', self.walk_weight)
|
220
|
|
- if self.walk_weight < .8:
|
221
|
|
- if frame > 15:
|
222
|
|
- if self.FSM.owner.step == False:
|
223
|
|
- self.FSM.owner.step = True
|
224
|
|
-
|
225
|
|
- if frame < 23:
|
226
|
|
- print('step left')
|
227
|
|
- dict['camera']['sndmgr'].queue_sound(['s_l_1', self.FSM.owner.obj, dict['camera']])
|
228
|
|
- else:
|
229
|
|
- if self.FSM.owner.step == True:
|
230
|
|
- self.FSM.owner.step = False
|
231
|
|
- if frame < 8:
|
232
|
|
- dict['camera']['sndmgr'].queue_sound(['s_r_1', self.FSM.owner.obj, dict['camera']])
|
233
|
|
- print('step right')
|
234
|
|
-
|
235
|
|
- # if frame > 15 and self.FSM.owner.step:
|
236
|
|
- # self.FSM.owner.step = True
|
237
|
|
- # print('step left')
|
238
|
|
- # if frame < 15 and not self.FSM.owner.step:
|
239
|
|
- # self.FSM.owner.step = False
|
240
|
|
- # print('step right')
|
241
|
|
- #print('frame', frame)
|
242
|
|
-
|
243
|
|
- def get_walk_weight(self):
|
244
|
|
- #print(self.FSM.owner.linearVelocity.y)
|
245
|
|
-
|
246
|
|
-
|
247
|
|
- o = self.FSM.owner.obj
|
248
|
|
- w = abs(o.linearVelocity.x)
|
249
|
|
- #wt = 3.5
|
250
|
|
- #yt = 8
|
251
|
|
- wt = 1.7
|
252
|
|
- yt = 3
|
253
|
|
- out2 = 0
|
254
|
|
- if w < wt:
|
255
|
|
- out = w / wt
|
256
|
|
- else:
|
257
|
|
- out = 1
|
258
|
|
- #print('running', w)
|
259
|
|
- out2 = w / yt
|
260
|
|
- out = abs(1 - out)
|
261
|
|
- out2 = abs(1 - out2)
|
262
|
|
- tgww = round(out, 3)
|
263
|
|
- tgrw = round(out2, 3)
|
264
|
|
- incer = .05
|
265
|
|
- if self.walk_weight < tgww:
|
266
|
|
- self.walk_weight += incer
|
267
|
|
- if self.walk_weight > tgww:
|
268
|
|
- self.walk_weight -= incer
|
269
|
|
- if self.run_weight <= tgrw:
|
270
|
|
- self.run_weight += incer
|
271
|
|
- if self.run_weight > tgrw:
|
272
|
|
- self.run_weight -= incer
|
273
|
|
- if self.walk_weight <= 0:
|
274
|
|
- self.walk_weight = 0
|
275
|
|
- if self.walk_weight > .95:
|
276
|
|
- self.walk_weight = 1
|
277
|
|
- if self.run_weight <= 0:
|
278
|
|
- self.run_weight = 0
|
279
|
|
- if self.run_weight > .95:
|
280
|
|
- self.run_weight = 1
|
281
|
|
-
|
282
|
|
-
|
283
|
|
- if dict['kb_lsh'] == 2 or dict['aBut'] == 1:
|
284
|
|
- self.run_speed = 1.3
|
285
|
|
- else:
|
286
|
|
- self.run_speed = .8
|
287
|
|
- #print(self.run_speed, '---', self.walk_weight, 'walk weight', self.run_weight, 'run weight')
|
288
|
|
-
|
289
|
|
- def Exit(self):
|
290
|
|
- self.FSM.owner.arm.stopAction(0)
|
291
|
|
- self.FSM.owner.arm.stopAction(1)
|
292
|
|
- self.FSM.owner.arm.stopAction(2)
|
293
|
|
- self.FSM.owner.arm.stopAction(3)
|
294
|
|
- self.FSM.owner.deck_arm.stopAction(0)
|
295
|
|
- self.FSM.owner.deck_arm.stopAction(1)
|
296
|
|
- self.FSM.owner.deck_arm.stopAction(2)
|
297
|
|
- self.FSM.owner.deck_arm.stopAction(3)
|
298
|
|
- dict['walk'] = 0
|
|
61
|
+ def __init__(self,FSM):
|
|
62
|
+ super(Walk, self).__init__(FSM)
|
|
63
|
+
|
|
64
|
+ def Enter(self):
|
|
65
|
+ self.FSM.stateLife = 1
|
|
66
|
+ o = self.FSM.owner.obj
|
|
67
|
+ c = self.FSM.owner
|
|
68
|
+ o['getoffboard'] = False
|
|
69
|
+ o['getonboard'] = False
|
|
70
|
+
|
|
71
|
+ if c.arm == None:
|
|
72
|
+
|
|
73
|
+ c.arm = o.childrenRecursive['Char4']
|
|
74
|
+ c.deck_arm = o.childrenRecursive['deck_arm']
|
|
75
|
+ self.walk_weight = 1
|
|
76
|
+ self.run_weight = 1
|
|
77
|
+ self.run_speed = 0.0
|
|
78
|
+ self.turn_weight = 0
|
|
79
|
+ self.FSM.owner.walking = True
|
|
80
|
+ dict['walking'] = True
|
|
81
|
+ dict['walk'] = 1
|
|
82
|
+ print('fsm enter walk')
|
|
83
|
+
|
|
84
|
+ super(Walk, self).Enter()
|
|
85
|
+
|
|
86
|
+ def Execute(self):
|
|
87
|
+ self.FSM.stateLife += 1
|
|
88
|
+ o = self.FSM.owner.obj
|
|
89
|
+ c = self.FSM.owner
|
|
90
|
+ #print(o.worldPosition.z)
|
|
91
|
+ #print(o['getonboard'], 'dict onboard')
|
|
92
|
+ #print(dict['walk'], 'fsm walk walk')
|
|
93
|
+ # if self.FSM.stateLife == 2:
|
|
94
|
+ # if o['stance']:
|
|
95
|
+ # o.applyRotation([0,0,3.14], True)
|
|
96
|
+ # o['stance'] = False
|
|
97
|
+ # o['requestAction'] = 'fak_offboard'
|
|
98
|
+ # print('request fak offboard')
|
|
99
|
+ # else:
|
|
100
|
+ # o['requestAction'] = 'reg_offboard'
|
|
101
|
+ # print('request reg offboard')
|
|
102
|
+ # if self.FSM.stateLife > 5:
|
|
103
|
+ # o['requestAction'] = 'reg_idle'
|
|
104
|
+ c.align_walk_z()
|
|
105
|
+ ground_rays = c.get_ground_ray()
|
|
106
|
+ #77777777777777777777777777777777777777777777777777777777777777777777777777777777777
|
|
107
|
+ c.get_hang_align_ray()
|
|
108
|
+ c.move_walk_cam()
|
|
109
|
+ c.check_reset_point()
|
|
110
|
+ c.check_throw()
|
|
111
|
+ c.check_pause()
|
|
112
|
+ c.check_idle(False)
|
|
113
|
+ c.idle_anim()
|
|
114
|
+
|
|
115
|
+ if ground_rays[0][0] != None:
|
|
116
|
+ dist = c.get_ground_dist(ground_rays)
|
|
117
|
+ if dist > .7:
|
|
118
|
+ self.FSM.ToTransition('toWalkAir')
|
|
119
|
+ #print('---falling')
|
|
120
|
+ else:
|
|
121
|
+ c.set_walk_z(dist)
|
|
122
|
+ #print(dist, 'setting height')
|
|
123
|
+
|
|
124
|
+ if self.FSM.stateLife > 4:
|
|
125
|
+ self.check_onboard()
|
|
126
|
+ self.check_jump()
|
|
127
|
+
|
|
128
|
+ moving = c.walk_movement()
|
|
129
|
+
|
|
130
|
+ self.get_walk_weight()
|
|
131
|
+ self.idle_blend()
|
|
132
|
+ else:
|
|
133
|
+ dict['walk'] = 1
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+ def check_onboard(self):
|
|
137
|
+
|
|
138
|
+ o = self.FSM.owner.obj
|
|
139
|
+ #print(o['getonboard'], 'getonboard')
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ if dict['walk'] == 0:
|
|
143
|
+ o['getonboard'] = True
|
|
144
|
+ #self.FSM.ToTransition('toRoll')
|
|
145
|
+ self.FSM.ToTransition('toWalkOnboard')
|
|
146
|
+ #print('onboard', dict['walk'], o['getonboard'])
|
|
147
|
+ if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+ dropin = self.check_dropin()
|
|
151
|
+ print('-----dropin', dropin)
|
|
152
|
+ if dropin == None:
|
|
153
|
+ o['getonboard'] = True
|
|
154
|
+
|
|
155
|
+ self.FSM.ToTransition('toWalkOnboard')
|
|
156
|
+ else:
|
|
157
|
+ self.FSM.owner.dropin_obj = dropin
|
|
158
|
+ self.FSM.ToTransition('toDropin')
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+ def check_dropin(self):
|
|
163
|
+ dr = None
|
|
164
|
+ ground_rays = self.FSM.owner.get_dropin_rays()
|
|
165
|
+ for x in ground_rays:
|
|
166
|
+ if x[0] != None:
|
|
167
|
+ #print(x[0], '---checked')
|
|
168
|
+ if 'coping' in x[0]:
|
|
169
|
+ print('dropin collided')
|
|
170
|
+ dr = x
|
|
171
|
+ return dr
|
|
172
|
+
|
|
173
|
+ def check_jump(self):
|
|
174
|
+ if dict['xBut'] == True or dict['kb_space'] == 1:
|
|
175
|
+ if dict['last_xBut'] == 0:
|
|
176
|
+ self.FSM.ToTransition('toWalkJump')
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+ def idle_blend(self):
|
|
180
|
+ arm = self.FSM.owner.arm
|
|
181
|
+ deck = self.FSM.owner.deck_arm
|
|
182
|
+ arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=.5, blendin=10)
|
|
183
|
+ deck.playAction('b_reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=10)
|
|
184
|
+ if self.FSM.stateLife > 20:
|
|
185
|
+ frame = arm.getActionFrame(2) + .5 * self.run_speed
|
|
186
|
+ if frame > 30:
|
|
187
|
+ frame = 0
|
|
188
|
+ arm.stopAction(2)
|
|
189
|
+ deck.stopAction(2)
|
|
190
|
+ arm.playAction('reg_nwalk3', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
|
|
191
|
+ deck.playAction('b_reg_walk', 0,30, layer=2, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.walk_weight)
|
|
192
|
+ #b_reg_walk
|
|
193
|
+ arm.setActionFrame(frame, 2)
|
|
194
|
+ deck.setActionFrame(frame, 2)
|
|
195
|
+ #print(self.walk_weight, frame)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+ frame = arm.getActionFrame(3) + .5 * self.run_speed
|
|
200
|
+ if frame > 30:
|
|
201
|
+ frame = 0
|
|
202
|
+ arm.stopAction(3)
|
|
203
|
+ deck.stopAction(3)
|
|
204
|
+ arm.playAction('reg_run.003', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
|
|
205
|
+ deck.playAction('b_reg_run', 0,30, layer=3, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=self.run_weight)
|
|
206
|
+
|
|
207
|
+ arm.setActionFrame(frame, 3)
|
|
208
|
+ deck.setActionFrame(frame, 3)
|
|
209
|
+ #print(frame, 'frame')
|
|
210
|
+ #print(self.run_weight, frame)
|
|
211
|
+
|
|
212
|
+ # if self.turn_weight > 0:
|
|
213
|
+ # tw = abs(self.turn_weight - 1)
|
|
214
|
+ # #tw = self.turn_weight
|
|
215
|
+ # arm.stopAction(4)
|
|
216
|
+ # arm.playAction('bwalk_right', 1,60, layer=4, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=tw)
|
|
217
|
+ # elif self.turn_weight < 0:
|
|
218
|
+ # tw = abs(abs(self.turn_weight) - 1)
|
|
219
|
+ # #tw = self.turn_weight
|
|
220
|
+ # arm.stopAction(4)
|
|
221
|
+ # arm.playAction('bwalk_left', 1,60, layer=4, play_mode=1, speed=self.run_speed, blendin=0, layer_weight=tw)
|
|
222
|
+ #print('walk_weight', self.walk_weight)
|
|
223
|
+ if self.walk_weight < .8:
|
|
224
|
+ if frame > 15:
|
|
225
|
+ if self.FSM.owner.step == False:
|
|
226
|
+ self.FSM.owner.step = True
|
|
227
|
+
|
|
228
|
+ if frame < 23:
|
|
229
|
+ #print('step left')
|
|
230
|
+ dict['camera']['sndmgr'].queue_sound(['s_l_1', self.FSM.owner.obj, dict['camera']])
|
|
231
|
+ else:
|
|
232
|
+ if self.FSM.owner.step == True:
|
|
233
|
+ self.FSM.owner.step = False
|
|
234
|
+ if frame < 8:
|
|
235
|
+ dict['camera']['sndmgr'].queue_sound(['s_r_1', self.FSM.owner.obj, dict['camera']])
|
|
236
|
+ #print('step right')
|
|
237
|
+
|
|
238
|
+ # if frame > 15 and self.FSM.owner.step:
|
|
239
|
+ # self.FSM.owner.step = True
|
|
240
|
+ # print('step left')
|
|
241
|
+ # if frame < 15 and not self.FSM.owner.step:
|
|
242
|
+ # self.FSM.owner.step = False
|
|
243
|
+ # print('step right')
|
|
244
|
+ #print('frame', frame)
|
|
245
|
+
|
|
246
|
+ def get_walk_weight(self):
|
|
247
|
+ #print(self.FSM.owner.linearVelocity.y)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+ o = self.FSM.owner.obj
|
|
251
|
+ w = abs(o.linearVelocity.x)
|
|
252
|
+ #wt = 3.5
|
|
253
|
+ #yt = 8
|
|
254
|
+ wt = 1.7
|
|
255
|
+ yt = 3
|
|
256
|
+ out2 = 0
|
|
257
|
+ if w < wt:
|
|
258
|
+ out = w / wt
|
|
259
|
+ else:
|
|
260
|
+ out = 1
|
|
261
|
+ #print('running', w)
|
|
262
|
+ out2 = w / yt
|
|
263
|
+ out = abs(1 - out)
|
|
264
|
+ out2 = abs(1 - out2)
|
|
265
|
+ tgww = round(out, 3)
|
|
266
|
+ tgrw = round(out2, 3)
|
|
267
|
+ incer = .05
|
|
268
|
+ if self.walk_weight < tgww:
|
|
269
|
+ self.walk_weight += incer
|
|
270
|
+ if self.walk_weight > tgww:
|
|
271
|
+ self.walk_weight -= incer
|
|
272
|
+ if self.run_weight <= tgrw:
|
|
273
|
+ self.run_weight += incer
|
|
274
|
+ if self.run_weight > tgrw:
|
|
275
|
+ self.run_weight -= incer
|
|
276
|
+ if self.walk_weight <= 0:
|
|
277
|
+ self.walk_weight = 0
|
|
278
|
+ if self.walk_weight > .95:
|
|
279
|
+ self.walk_weight = 1
|
|
280
|
+ if self.run_weight <= 0:
|
|
281
|
+ self.run_weight = 0
|
|
282
|
+ if self.run_weight > .95:
|
|
283
|
+ self.run_weight = 1
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+ if dict['kb_lsh'] == 2 or dict['aBut'] == 1:
|
|
287
|
+ self.run_speed = 1.3
|
|
288
|
+ else:
|
|
289
|
+ self.run_speed = .8
|
|
290
|
+ #print(self.run_speed, '---', self.walk_weight, 'walk weight', self.run_weight, 'run weight')
|
|
291
|
+
|
|
292
|
+ def Exit(self):
|
|
293
|
+ self.FSM.owner.arm.stopAction(0)
|
|
294
|
+ self.FSM.owner.arm.stopAction(1)
|
|
295
|
+ self.FSM.owner.arm.stopAction(2)
|
|
296
|
+ self.FSM.owner.arm.stopAction(3)
|
|
297
|
+ self.FSM.owner.deck_arm.stopAction(0)
|
|
298
|
+ self.FSM.owner.deck_arm.stopAction(1)
|
|
299
|
+ self.FSM.owner.deck_arm.stopAction(2)
|
|
300
|
+ self.FSM.owner.deck_arm.stopAction(3)
|
|
301
|
+ dict['walk'] = 0
|
299
|
302
|
|
300
|
303
|
|
301
|
304
|
#====================================
|
302
|
|
-
|
|
305
|
+
|
303
|
306
|
class WalkAir(State):
|
304
|
|
- def __init__(self,FSM):
|
305
|
|
- super(WalkAir, self).__init__(FSM)
|
306
|
|
-
|
307
|
|
- def Enter(self):
|
308
|
|
- self.FSM.stateLife = 1
|
309
|
|
- super(WalkAir, self).Enter()
|
310
|
|
-
|
311
|
|
- def Execute(self):
|
312
|
|
- self.FSM.stateLife += 1
|
313
|
|
- self.FSM.owner.check_reset_point()
|
314
|
|
- arm = self.FSM.owner.arm
|
315
|
|
- deck_arm = self.FSM.owner.deck_arm
|
316
|
|
- #arm.playAction('a_jump_t', 23, 23, layer=3, play_mode=1, speed=1, blendin=5)
|
317
|
|
- arm.playAction('c_jump_up', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
|
318
|
|
- deck_arm.playAction('b_walk_jump', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
|
319
|
|
-
|
320
|
|
- if self.FSM.owner.obj.linearVelocity.z < -10:
|
321
|
|
- self.FSM.owner.obj.linearVelocity.z = -10
|
322
|
|
- moving = self.FSM.owner.walk_movement()
|
323
|
|
- ground_rays = self.FSM.owner.get_ground_ray()
|
324
|
|
-
|
325
|
|
- self.FSM.owner.check_throw()
|
326
|
|
- self.check_onboard()
|
327
|
|
- self.FSM.owner.align_walk_z()
|
328
|
|
- if ground_rays[0][0] != None:
|
329
|
|
- dist = self.FSM.owner.get_ground_dist(ground_rays)
|
330
|
|
- if dist < .4:
|
331
|
|
- self.FSM.ToTransition('toWalkLand')
|
332
|
|
-
|
333
|
|
-
|
334
|
|
-
|
335
|
|
- if dist > .5 and self.FSM.owner.obj.worldPosition.z < self.FSM.owner.last_pos.z:
|
336
|
|
- hang_ray = self.FSM.owner.get_hang_ray()
|
337
|
|
- hang_align_ray = self.FSM.owner.get_hang_align_ray()
|
338
|
|
-
|
339
|
|
- if hang_ray[0] != None and hang_align_ray[0] != None and self.FSM.prevState != 'WalkHang' and dict['lUD'] < .04:
|
340
|
|
- hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
|
341
|
|
- if hr_dist < .1:
|
342
|
|
- self.FSM.owner.obj.linearVelocity = [0,0,0]
|
343
|
|
- self.FSM.owner.obj.worldPosition.z = hang_ray[1].z - 1
|
344
|
|
- self.FSM.ToTransition('toWalkHang')
|
345
|
|
-
|
346
|
|
- def check_onboard(self):
|
347
|
|
- o = self.FSM.owner.obj
|
348
|
|
- # if dict['walk'] == 0:
|
349
|
|
- # o['getonboard'] = True
|
350
|
|
- # self.FSM.ToTransition('toWalkOnboard')
|
351
|
|
- if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
352
|
|
- o['getonboard'] = True
|
353
|
|
- #self.FSM.ToTransition('toWalkOnboard')
|
354
|
|
- self.FSM.ToTransition('toAirOnboard')
|
355
|
|
-
|
356
|
|
- def Exit(self):
|
357
|
|
- self.FSM.owner.arm.stopAction(0)
|
358
|
|
- self.FSM.owner.arm.stopAction(1)
|
359
|
|
- self.FSM.owner.arm.stopAction(2)
|
360
|
|
- self.FSM.owner.arm.stopAction(3)
|
361
|
|
- self.FSM.owner.deck_arm.stopAction(0)
|
362
|
|
- self.FSM.owner.deck_arm.stopAction(1)
|
363
|
|
- self.FSM.owner.deck_arm.stopAction(2)
|
364
|
|
- self.FSM.owner.deck_arm.stopAction(3)
|
|
307
|
+ def __init__(self,FSM):
|
|
308
|
+ super(WalkAir, self).__init__(FSM)
|
|
309
|
+
|
|
310
|
+ def Enter(self):
|
|
311
|
+ self.FSM.stateLife = 1
|
|
312
|
+ super(WalkAir, self).Enter()
|
|
313
|
+
|
|
314
|
+ def Execute(self):
|
|
315
|
+ self.FSM.stateLife += 1
|
|
316
|
+ self.FSM.owner.check_reset_point()
|
|
317
|
+ arm = self.FSM.owner.arm
|
|
318
|
+ deck_arm = self.FSM.owner.deck_arm
|
|
319
|
+ #arm.playAction('a_jump_t', 23, 23, layer=3, play_mode=1, speed=1, blendin=5)
|
|
320
|
+ arm.playAction('c_jump_up', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
|
|
321
|
+ deck_arm.playAction('b_walk_jump', 23, 23, layer=3, play_mode=1, speed=1, blendin=15)
|
|
322
|
+
|
|
323
|
+ if self.FSM.owner.obj.linearVelocity.z < -10:
|
|
324
|
+ self.FSM.owner.obj.linearVelocity.z = -10
|
|
325
|
+ moving = self.FSM.owner.walk_movement()
|
|
326
|
+ ground_rays = self.FSM.owner.get_ground_ray()
|
|
327
|
+
|
|
328
|
+ self.FSM.owner.check_throw()
|
|
329
|
+ self.check_onboard()
|
|
330
|
+ self.FSM.owner.align_walk_z()
|
|
331
|
+ self.FSM.owner.check_pause()
|
|
332
|
+ if ground_rays[0][0] != None:
|
|
333
|
+ dist = self.FSM.owner.get_ground_dist(ground_rays)
|
|
334
|
+ if dist < .4:
|
|
335
|
+ self.FSM.ToTransition('toWalkLand')
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+ if dist > .5 and self.FSM.owner.obj.worldPosition.z < self.FSM.owner.last_pos.z:
|
|
340
|
+ hang_ray = self.FSM.owner.get_hang_ray()
|
|
341
|
+ hang_align_ray = self.FSM.owner.get_hang_align_ray()
|
|
342
|
+
|
|
343
|
+ if hang_ray[0] != None and hang_align_ray[0] != None and self.FSM.prevState != 'WalkHang' and dict['lUD'] < .04:
|
|
344
|
+ hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
|
|
345
|
+ if hr_dist < .1:
|
|
346
|
+ self.FSM.owner.obj.linearVelocity = [0,0,0]
|
|
347
|
+ self.FSM.owner.obj.worldPosition.z = hang_ray[1].z - 1
|
|
348
|
+ self.FSM.ToTransition('toWalkHang')
|
|
349
|
+
|
|
350
|
+ def check_onboard(self):
|
|
351
|
+ o = self.FSM.owner.obj
|
|
352
|
+ # if dict['walk'] == 0:
|
|
353
|
+ # o['getonboard'] = True
|
|
354
|
+ # self.FSM.ToTransition('toWalkOnboard')
|
|
355
|
+ if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
|
356
|
+ o['getonboard'] = True
|
|
357
|
+ #self.FSM.ToTransition('toWalkOnboard')
|
|
358
|
+ self.FSM.ToTransition('toAirOnboard')
|
|
359
|
+
|
|
360
|
+ def Exit(self):
|
|
361
|
+ self.FSM.owner.arm.stopAction(0)
|
|
362
|
+ self.FSM.owner.arm.stopAction(1)
|
|
363
|
+ self.FSM.owner.arm.stopAction(2)
|
|
364
|
+ self.FSM.owner.arm.stopAction(3)
|
|
365
|
+ self.FSM.owner.deck_arm.stopAction(0)
|
|
366
|
+ self.FSM.owner.deck_arm.stopAction(1)
|
|
367
|
+ self.FSM.owner.deck_arm.stopAction(2)
|
|
368
|
+ self.FSM.owner.deck_arm.stopAction(3)
|
365
|
369
|
|
366
|
370
|
#====================================
|
367
|
|
-
|
|
371
|
+
|
368
|
372
|
class WalkJump(State):
|
369
|
|
- def __init__(self,FSM):
|
370
|
|
- super(WalkJump, self).__init__(FSM)
|
371
|
|
-
|
372
|
|
- def Enter(self):
|
373
|
|
- self.FSM.stateLife = 1
|
374
|
|
- dict['camera']['sndmgr'].queue_sound(['walk_grunt', self.FSM.owner.obj, dict['camera']])
|
375
|
|
- arm = self.FSM.owner.arm
|
376
|
|
- deck = self.FSM.owner.deck_arm
|
377
|
|
- #arm.playAction('a_jump_t', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
378
|
|
- arm.playAction('c_jump_up', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
379
|
|
- deck.playAction('b_walk_jump', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
380
|
|
-
|
381
|
|
-
|
382
|
|
- super(WalkJump, self).Enter()
|
383
|
|
-
|
384
|
|
- def Execute(self):
|
385
|
|
- self.FSM.stateLife += 1
|
386
|
|
- arm = self.FSM.owner.arm
|
387
|
|
- o = self.FSM.owner.obj
|
388
|
|
-
|
389
|
|
- moving = self.FSM.owner.walk_movement()
|
390
|
|
- self.check_onboard()
|
391
|
|
- if self.FSM.stateLife == 10:
|
392
|
|
- force = [ 0.0, 0.0, dict['walk_jump_force']]
|
393
|
|
- if o.linearVelocity.z < 10:
|
394
|
|
- o.applyForce(force, True)
|
395
|
|
-
|
396
|
|
- if self.FSM.stateLife > 27:
|
397
|
|
- self.FSM.ToTransition('toWalkAir')
|
398
|
|
-
|
399
|
|
- def check_onboard(self):
|
400
|
|
- o = self.FSM.owner.obj
|
401
|
|
- # if dict['walk'] == 0:
|
402
|
|
- # o['getonboard'] = True
|
403
|
|
- # self.FSM.ToTransition('toWalkOnboard')
|
404
|
|
- if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
405
|
|
- o['getonboard'] = True
|
406
|
|
- self.FSM.ToTransition('toAirOnboard')
|
407
|
|
-
|
408
|
|
- def Exit(self):
|
409
|
|
- pass
|
|
373
|
+ def __init__(self,FSM):
|
|
374
|
+ super(WalkJump, self).__init__(FSM)
|
|
375
|
+
|
|
376
|
+ def Enter(self):
|
|
377
|
+ self.FSM.stateLife = 1
|
|
378
|
+ dict['camera']['sndmgr'].queue_sound(['walk_grunt', self.FSM.owner.obj, dict['camera']])
|
|
379
|
+ arm = self.FSM.owner.arm
|
|
380
|
+ deck = self.FSM.owner.deck_arm
|
|
381
|
+ #arm.playAction('a_jump_t', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
|
382
|
+ arm.playAction('c_jump_up', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
|
383
|
+ deck.playAction('b_walk_jump', 1, 23, layer=3, play_mode=0, speed=1, blendin=5)
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+ super(WalkJump, self).Enter()
|
|
387
|
+
|
|
388
|
+ def Execute(self):
|
|
389
|
+ self.FSM.stateLife += 1
|
|
390
|
+ arm = self.FSM.owner.arm
|
|
391
|
+ o = self.FSM.owner.obj
|
|
392
|
+
|
|
393
|
+ moving = self.FSM.owner.walk_movement()
|
|
394
|
+ self.check_onboard()
|
|
395
|
+ self.FSM.owner.check_pause()
|
|
396
|
+ if self.FSM.stateLife == 10:
|
|
397
|
+ force = [ 0.0, 0.0, dict['walk_jump_force']]
|
|
398
|
+ if o.linearVelocity.z < 10:
|
|
399
|
+ o.applyForce(force, True)
|
|
400
|
+
|
|
401
|
+ if self.FSM.stateLife > 27:
|
|
402
|
+ self.FSM.ToTransition('toWalkAir')
|
|
403
|
+
|
|
404
|
+ def check_onboard(self):
|
|
405
|
+ o = self.FSM.owner.obj
|
|
406
|
+ # if dict['walk'] == 0:
|
|
407
|
+ # o['getonboard'] = True
|
|
408
|
+ # self.FSM.ToTransition('toWalkOnboard')
|
|
409
|
+ if dict['yBut'] == 1 and dict['last_yBut'] == 0:
|
|
410
|
+ o['getonboard'] = True
|
|
411
|
+ self.FSM.ToTransition('toAirOnboard')
|
|
412
|
+
|
|
413
|
+ def Exit(self):
|
|
414
|
+ pass
|
410
|
415
|
|
411
|
416
|
#====================================
|
412
|
|
-
|
|
417
|
+
|
413
|
418
|
class WalkLand(State):
|
414
|
|
- def __init__(self,FSM):
|
415
|
|
- super(WalkLand, self).__init__(FSM)
|
416
|
|
-
|
417
|
|
- def Enter(self):
|
418
|
|
- self.FSM.stateLife = 1
|
419
|
|
- #self.FSM.owner.arm.playAction('a_jump_t', 23, 50, layer=5, play_mode=0, speed=1, blendin=5)
|
420
|
|
- self.FSM.owner.arm.playAction('c_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
421
|
|
- self.FSM.owner.deck_arm.playAction('b_walk_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
422
|
|
- dict['camera']['sndmgr'].queue_sound(['walk_land', self.FSM.owner.obj, dict['camera']])
|
423
|
|
- #c_land
|
424
|
|
- super(WalkLand, self).Enter()
|
425
|
|
-
|
426
|
|
- def Execute(self):
|
427
|
|
- self.FSM.stateLife += 1
|
428
|
|
- self.FSM.owner.obj.linearVelocity.x *= .8
|
429
|
|
- self.FSM.owner.obj.linearVelocity.y *= .8
|
430
|
|
- # arm = self.FSM.owner.arm
|
431
|
|
-
|
432
|
|
- # print('af', arm.getActionFrame(5))
|
433
|
|
- # if arm.getActionFrame(5) > 30:
|
434
|
|
- # print('stopping land')
|
435
|
|
- # arm.stopAction(5)
|
436
|
|
- # arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=2)
|
437
|
|
- if self.FSM.stateLife > 30:
|
438
|
|
- self.FSM.ToTransition('toWalk')
|
439
|
|
-
|
440
|
|
- ground_rays = self.FSM.owner.get_ground_ray()
|
441
|
|
- if ground_rays[0][0] != None:
|
442
|
|
- dist = self.FSM.owner.get_ground_dist(ground_rays)
|
443
|
|
- self.FSM.owner.set_walk_z(dist)
|
444
|
|
-
|
445
|
|
- def Exit(self):
|
446
|
|
- pass
|
|
419
|
+ def __init__(self,FSM):
|
|
420
|
+ super(WalkLand, self).__init__(FSM)
|
|
421
|
+
|
|
422
|
+ def Enter(self):
|
|
423
|
+ self.FSM.stateLife = 1
|
|
424
|
+ #self.FSM.owner.arm.playAction('a_jump_t', 23, 50, layer=5, play_mode=0, speed=1, blendin=5)
|
|
425
|
+ self.FSM.owner.arm.playAction('c_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
|
426
|
+ self.FSM.owner.deck_arm.playAction('b_walk_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
|
427
|
+ dict['camera']['sndmgr'].queue_sound(['walk_land', self.FSM.owner.obj, dict['camera']])
|
|
428
|
+ #c_land
|
|
429
|
+ super(WalkLand, self).Enter()
|
|
430
|
+
|
|
431
|
+ def Execute(self):
|
|
432
|
+ self.FSM.stateLife += 1
|
|
433
|
+ self.FSM.owner.obj.linearVelocity.x *= .8
|
|
434
|
+ self.FSM.owner.obj.linearVelocity.y *= .8
|
|
435
|
+ # arm = self.FSM.owner.arm
|
|
436
|
+
|
|
437
|
+ # print('af', arm.getActionFrame(5))
|
|
438
|
+ # if arm.getActionFrame(5) > 30:
|
|
439
|
+ # print('stopping land')
|
|
440
|
+ # arm.stopAction(5)
|
|
441
|
+ # arm.playAction('reg_idle1', 1,120, layer=1, play_mode=1, speed=1, blendin=2)
|
|
442
|
+ if self.FSM.stateLife > 30:
|
|
443
|
+ self.FSM.ToTransition('toWalk')
|
|
444
|
+
|
|
445
|
+ self.FSM.owner.check_pause()
|
|
446
|
+ ground_rays = self.FSM.owner.get_ground_ray()
|
|
447
|
+ if ground_rays[0][0] != None:
|
|
448
|
+ dist = self.FSM.owner.get_ground_dist(ground_rays)
|
|
449
|
+ self.FSM.owner.set_walk_z(dist)
|
|
450
|
+
|
|
451
|
+ def Exit(self):
|
|
452
|
+ pass
|
447
|
453
|
|
448
|
454
|
#====================================
|
449
|
|
-
|
|
455
|
+
|
450
|
456
|
class WalkHang(State):
|
451
|
|
- def __init__(self,FSM):
|
452
|
|
- super(WalkHang, self).__init__(FSM)
|
453
|
|
-
|
454
|
|
- def Enter(self):
|
455
|
|
- self.FSM.stateLife = 1
|
456
|
|
- self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
|
457
|
|
- self.moveable = False
|
458
|
|
- dict['camera']['sndmgr'].queue_sound(['walk_hang', self.FSM.owner.obj, dict['camera']])
|
459
|
|
- self.FSM.owner.drop_deck()
|
460
|
|
- #self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
|
461
|
|
- super(WalkHang, self).Enter()
|
462
|
|
-
|
463
|
|
- def Execute(self):
|
464
|
|
- self.FSM.stateLife += 1
|
465
|
|
- self.FSM.owner.obj.linearVelocity = [0,0,0]
|
466
|
|
- #self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
|
467
|
|
- self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
|
468
|
|
- if dict['lUD'] > .04:
|
469
|
|
- self.FSM.ToTransition('toWalkAir')
|
470
|
|
-
|
471
|
|
-
|
472
|
|
- self.FSM.owner.move_walk_cam()
|
473
|
|
- if self.FSM.stateLife > 25:
|
474
|
|
- self.moveable = True
|
475
|
|
- if self.moveable:
|
476
|
|
- if dict['lUD'] < -.04:
|
477
|
|
- self.FSM.ToTransition('toWalkClimb')
|
478
|
|
- self.FSM.owner.hang_move()
|
479
|
|
- ground_rays = self.FSM.owner.get_ground_ray()
|
480
|
|
- if ground_rays[0][0] != None:
|
481
|
|
- dist = self.FSM.owner.get_ground_dist(ground_rays)
|
482
|
|
- if dist < .4:
|
483
|
|
- self.FSM.ToTransition('toWalkLand')
|
484
|
|
-
|
485
|
|
- hang_ray = self.FSM.owner.get_hang_ray()
|
486
|
|
- hang_align_ray = self.FSM.owner.get_hang_align_ray()
|
487
|
|
- #print(hang_align_ray, 'hang_align_ray')
|
488
|
|
- #self.FSM.owner.hang_move()
|
489
|
|
-
|
490
|
|
-
|
491
|
|
-
|
492
|
|
- if hang_ray[0] != None:
|
493
|
|
- hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
|
494
|
|
- #print(hr_dist, 'hang dist')
|
495
|
|
- if hr_dist < .5:
|
496
|
|
- self.FSM.owner.obj.linearVelocity = [0,0,0]
|
497
|
|
- self.FSM.owner.obj.worldPosition.z = hang_ray[1].z - 1
|
498
|
|
- if hang_align_ray[0] != None:
|
499
|
|
- #print(hang_align_ray[0])
|
500
|
|
- v = hang_align_ray[2]
|
501
|
|
- self.FSM.owner.obj.alignAxisToVect(v, 0, .5)
|
502
|
|
- else:
|
503
|
|
- self.FSM.ToTransition('toWalkAir')
|
504
|
|
- if hang_align_ray[0] == None:
|
505
|
|
- self.FSM.ToTransition('toWalkAir')
|
506
|
|
-
|
507
|
|
- self.FSM.owner.align_walk_z()
|
508
|
|
- def Exit(self):
|
509
|
|
- pass
|
|
457
|
+ def __init__(self,FSM):
|
|
458
|
+ super(WalkHang, self).__init__(FSM)
|
|
459
|
+
|
|
460
|
+ def Enter(self):
|
|
461
|
+ self.FSM.stateLife = 1
|
|
462
|
+ self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
|
|
463
|
+ self.moveable = False
|
|
464
|
+ dict['camera']['sndmgr'].queue_sound(['walk_hang', self.FSM.owner.obj, dict['camera']])
|
|
465
|
+ self.FSM.owner.drop_deck()
|
|
466
|
+ #self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
|
|
467
|
+ super(WalkHang, self).Enter()
|
|
468
|
+
|
|
469
|
+ def Execute(self):
|
|
470
|
+ self.FSM.stateLife += 1
|
|
471
|
+ self.FSM.owner.obj.linearVelocity = [0,0,0]
|
|
472
|
+ #self.FSM.owner.arm.playAction('c_braced_hang', 0, 36, layer=2, play_mode=0, speed=1, blendin=10)
|
|
473
|
+ self.FSM.owner.arm.playAction('c_braced_hang', 36, 50, layer=1, play_mode=1, speed=1, blendin=10)
|
|
474
|
+ if dict['lUD'] > .04:
|
|
475
|
+ self.FSM.ToTransition('toWalkAir')
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+ self.FSM.owner.move_walk_cam()
|
|
479
|
+ self.FSM.owner.check_pause()
|
|
480
|
+ if self.FSM.stateLife > 25:
|
|
481
|
+ self.moveable = True
|
|
482
|
+ if self.moveable:
|
|
483
|
+ if dict['lUD'] < -.04:
|
|
484
|
+ self.FSM.ToTransition('toWalkClimb')
|
|
485
|
+ self.FSM.owner.hang_move()
|
|
486
|
+ ground_rays = self.FSM.owner.get_ground_ray()
|
|
487
|
+ if ground_rays[0][0] != None:
|
|
488
|
+ dist = self.FSM.owner.get_ground_dist(ground_rays)
|
|
489
|
+ if dist < .4:
|
|
490
|
+ self.FSM.ToTransition('toWalkLand')
|
|
491
|
+
|
|
492
|
+ hang_ray = self.FSM.owner.get_hang_ray()
|
|
493
|
+ hang_align_ray = self.FSM.owner.get_hang_align_ray()
|
|
494
|
+ #print(hang_align_ray, 'hang_align_ray')
|
|
495
|
+ #self.FSM.owner.hang_move()
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+ if hang_ray[0] != None:
|
|
500
|
+ hr_dist = self.FSM.owner.get_hang_dist(hang_ray)
|
|
501
|
+ #print(hr_dist, 'hang dist')
|
|
502
|
+ if hr_dist < .5:
|
|
503
|
+ self.FSM.owner.obj.linearVelocity = [0,0,0]
|
|
504
|
+ self.FSM.owner.obj.worldPosition.z = hang_ray[1].z - 1
|
|
505
|
+ if hang_align_ray[0] != None:
|
|
506
|
+ #print(hang_align_ray[0])
|
|
507
|
+ v = hang_align_ray[2]
|
|
508
|
+ self.FSM.owner.obj.alignAxisToVect(v, 0, .5)
|
|
509
|
+ else:
|
|
510
|
+ self.FSM.ToTransition('toWalkAir')
|
|
511
|
+ if hang_align_ray[0] == None:
|
|
512
|
+ self.FSM.ToTransition('toWalkAir')
|
|
513
|
+
|
|
514
|
+ self.FSM.owner.align_walk_z()
|
|
515
|
+ def Exit(self):
|
|
516
|
+ pass
|
510
|
517
|
|
511
|
518
|
#====================================
|
512
|
|
-
|
|
519
|
+
|
513
|
520
|
class WalkClimb(State):
|
514
|
|
- def __init__(self,FSM):
|
515
|
|
- super(WalkClimb, self).__init__(FSM)
|
516
|
|
-
|
517
|
|
- def Enter(self):
|
518
|
|
- self.FSM.stateLife = 1
|
519
|
|
- self.FSM.owner.arm.playAction('c_wallclimb', 1, 50, layer=3, play_mode=0, speed=1, blendin=10)
|
520
|
|
- dict['camera']['sndmgr'].queue_sound(['walk_climb', self.FSM.owner.obj, dict['camera']])
|
521
|
|
- super(WalkClimb, self).Enter()
|
522
|
|
-
|
523
|
|
- def Execute(self):
|
524
|
|
- self.FSM.stateLife += 1
|
525
|
|
- #self.FSM.ToTransition('toLand')
|
526
|
|
-
|
527
|
|
- if self.FSM.stateLife > 25:
|
528
|
|
- self.FSM.owner.obj.applyForce([-300, 0, 80], True)
|
529
|
|
- else:
|
530
|
|
- self.FSM.owner.obj.applyForce([-20, 0, 80], True)
|
531
|
|
- if self.FSM.stateLife > 35:
|
532
|
|
- self.FSM.ToTransition('toWalkLand')
|
533
|
|
-
|
534
|
|
- def Exit(self):
|
535
|
|
- pass
|
|
521
|
+ def __init__(self,FSM):
|
|
522
|
+ super(WalkClimb, self).__init__(FSM)
|
|
523
|
+
|
|
524
|
+ def Enter(self):
|
|
525
|
+ self.FSM.stateLife = 1
|
|
526
|
+ self.FSM.owner.arm.playAction('c_wallclimb', 1, 50, layer=3, play_mode=0, speed=1, blendin=10)
|
|
527
|
+ dict['camera']['sndmgr'].queue_sound(['walk_climb', self.FSM.owner.obj, dict['camera']])
|
|
528
|
+ super(WalkClimb, self).Enter()
|
|
529
|
+
|
|
530
|
+ def Execute(self):
|
|
531
|
+ self.FSM.stateLife += 1
|
|
532
|
+ #self.FSM.ToTransition('toLand')
|
|
533
|
+ self.FSM.owner.check_pause()
|
|
534
|
+ if self.FSM.stateLife > 25:
|
|
535
|
+ self.FSM.owner.obj.applyForce([-300, 0, 80], True)
|
|
536
|
+ else:
|
|
537
|
+ self.FSM.owner.obj.applyForce([-20, 0, 80], True)
|
|
538
|
+ if self.FSM.stateLife > 35:
|
|
539
|
+ self.FSM.ToTransition('toWalkLand')
|
|
540
|
+
|
|
541
|
+ def Exit(self):
|
|
542
|
+ pass
|
536
|
543
|
|
537
|
544
|
#====================================
|
538
|
|
-
|
|
545
|
+
|
539
|
546
|
class WalkHurdle(State):
|
540
|
|
- def __init__(self,FSM):
|
541
|
|
- super(WalkHurdle, self).__init__(FSM)
|
542
|
|
-
|
543
|
|
- def Enter(self):
|
544
|
|
- self.FSM.stateLife = 1
|
545
|
|
- super(WalkHurdle, self).Enter()
|
546
|
|
-
|
547
|
|
- def Execute(self):
|
548
|
|
- self.FSM.stateLife += 1
|
549
|
|
- #self.FSM.ToTransition('toLand')
|
550
|
|
-
|
551
|
|
- def Exit(self):
|
552
|
|
- pass
|
|
547
|
+ def __init__(self,FSM):
|
|
548
|
+ super(WalkHurdle, self).__init__(FSM)
|
|
549
|
+
|
|
550
|
+ def Enter(self):
|
|
551
|
+ self.FSM.stateLife = 1
|
|
552
|
+ super(WalkHurdle, self).Enter()
|
|
553
|
+
|
|
554
|
+ def Execute(self):
|
|
555
|
+ self.FSM.stateLife += 1
|
|
556
|
+ #self.FSM.ToTransition('toLand')
|
|
557
|
+
|
|
558
|
+ def Exit(self):
|
|
559
|
+ pass
|
553
|
560
|
|
554
|
561
|
|
555
|
562
|
#====================================
|
556
|
563
|
|
557
|
|
-
|
|
564
|
+
|
558
|
565
|
class WalkOnboard(State):
|
559
|
|
- def __init__(self,FSM):
|
560
|
|
- super(WalkOnboard, self).__init__(FSM)
|
561
|
|
-
|
562
|
|
- def Enter(self):
|
563
|
|
- self.FSM.stateLife = 1
|
564
|
|
- self.FSM.owner.walking = False
|
565
|
|
- self.FSM.owner.obj['getonboard'] = False
|
566
|
|
- if self.FSM.owner.throw_deck != None:
|
567
|
|
- self.FSM.owner.throw_deck.endObject()
|
568
|
|
- self.FSM.owner.throw_deck = None
|
569
|
|
- self.FSM.owner.show_deck()
|
570
|
|
- dict['walking'] = False
|
571
|
|
- self.FSM.owner.obj['walking'] = False
|
572
|
|
- self.FSM.owner.obj['requestAction'] = 'reg_onboard'
|
573
|
|
- self.FSM.owner.obj['getoffboard'] == False
|
574
|
|
- self.FSM.owner.obj.applyForce([-300, 0, 0], True)
|
575
|
|
- print('walkonboard entered')
|
576
|
|
- super(WalkOnboard, self).Enter()
|
577
|
|
-
|
578
|
|
- def Execute(self):
|
579
|
|
- self.FSM.stateLife += 1
|
580
|
|
- self.FSM.ToTransition('toRoll')
|
581
|
|
-
|
582
|
|
- def Exit(self):
|
583
|
|
- pass
|
|
566
|
+ def __init__(self,FSM):
|
|
567
|
+ super(WalkOnboard, self).__init__(FSM)
|
|
568
|
+
|
|
569
|
+ def Enter(self):
|
|
570
|
+ self.FSM.stateLife = 1
|
|
571
|
+ self.FSM.owner.walking = False
|
|
572
|
+ self.FSM.owner.obj['getonboard'] = False
|
|
573
|
+ if self.FSM.owner.throw_deck != None:
|
|
574
|
+ self.FSM.owner.throw_deck.endObject()
|
|
575
|
+ self.FSM.owner.throw_deck = None
|
|
576
|
+ self.FSM.owner.show_deck()
|
|
577
|
+ dict['walking'] = False
|
|
578
|
+ self.FSM.owner.obj['walking'] = False
|
|
579
|
+ self.FSM.owner.obj['requestAction'] = 'reg_onboard'
|
|
580
|
+ self.FSM.owner.obj['getoffboard'] == False
|
|
581
|
+ self.FSM.owner.obj.applyForce([-300, 0, 0], True)
|
|
582
|
+ print('walkonboard entered')
|
|
583
|
+ super(WalkOnboard, self).Enter()
|
|
584
|
+
|
|
585
|
+ def Execute(self):
|
|
586
|
+ self.FSM.stateLife += 1
|
|
587
|
+ self.FSM.ToTransition('toRoll')
|
|
588
|
+
|
|
589
|
+ def Exit(self):
|
|
590
|
+ pass
|
584
|
591
|
|
585
|
592
|
#====================================
|
586
|
593
|
|
587
|
594
|
|
588
|
|
-
|
|
595
|
+
|
589
|
596
|
class AirOnboard(State):
|
590
|
|
- def __init__(self,FSM):
|
591
|
|
- super(AirOnboard, self).__init__(FSM)
|
592
|
|
-
|
593
|
|
- def Enter(self):
|
594
|
|
- self.FSM.stateLife = 1
|
595
|
|
- self.FSM.owner.walking = False
|
596
|
|
- self.FSM.owner.obj['getonboard'] = False
|
597
|
|
- if self.FSM.owner.throw_deck != None:
|
598
|
|
- self.FSM.owner.throw_deck.endObject()
|
599
|
|
- self.FSM.owner.throw_deck = None
|
600
|
|
- self.FSM.owner.show_deck()
|
601
|
|
- dict['walking'] = False
|
602
|
|
- self.FSM.owner.obj['walking'] = False
|
603
|
|
- #self.FSM.owner.obj['requestAction'] = 'reg_onboard'
|
604
|
|
-
|
605
|
|
- self.FSM.owner.arm.playAction('c_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
606
|
|
- self.FSM.owner.deck_arm.playAction('b_walk_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
607
|
|
-
|
608
|
|
- self.FSM.owner.obj['getoffboard'] == False
|
609
|
|
- self.FSM.owner.obj.applyForce([-300, 0, 0], True)
|
610
|
|
- print('air entered')
|
611
|
|
- super(AirOnboard, self).Enter()
|
612
|
|
-
|
613
|
|
- def Execute(self):
|
614
|
|
- self.FSM.stateLife += 1
|
615
|
|
- print('@@@@@@@@@@@@@@@@@@@@@@@@@@@air ob')
|
616
|
|
- self.FSM.ToTransition('toRoll')
|
617
|
|
-
|
618
|
|
- def Exit(self):
|
619
|
|
- pass
|
|
597
|
+ def __init__(self,FSM):
|
|
598
|
+ super(AirOnboard, self).__init__(FSM)
|
|
599
|
+
|
|
600
|
+ def Enter(self):
|
|
601
|
+ self.FSM.stateLife = 1
|
|
602
|
+ self.FSM.owner.walking = False
|
|
603
|
+ self.FSM.owner.obj['getonboard'] = False
|
|
604
|
+ if self.FSM.owner.throw_deck != None:
|
|
605
|
+ self.FSM.owner.throw_deck.endObject()
|
|
606
|
+ self.FSM.owner.throw_deck = None
|
|
607
|
+ self.FSM.owner.show_deck()
|
|
608
|
+ dict['walking'] = False
|
|
609
|
+ self.FSM.owner.obj['walking'] = False
|
|
610
|
+ #self.FSM.owner.obj['requestAction'] = 'reg_onboard'
|
|
611
|
+
|
|
612
|
+ self.FSM.owner.arm.playAction('c_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
|
613
|
+ self.FSM.owner.deck_arm.playAction('b_walk_land', 0, 50, layer=1, play_mode=0, speed=1, blendin=5)
|
|
614
|
+
|
|
615
|
+ self.FSM.owner.obj['getoffboard'] == False
|
|
616
|
+ self.FSM.owner.obj.applyForce([-300, 0, 0], True)
|
|
617
|
+ print('air entered')
|
|
618
|
+ super(AirOnboard, self).Enter()
|
|
619
|
+
|
|
620
|
+ def Execute(self):
|
|
621
|
+ self.FSM.stateLife += 1
|
|
622
|
+ self.FSM.ToTransition('toRoll')
|
|
623
|
+
|
|
624
|
+ def Exit(self):
|
|
625
|
+ pass
|
620
|
626
|
|
621
|
627
|
#====================================
|
622
|
|
-
|
|
628
|
+
|
623
|
629
|
class Roll(State):
|
624
|
|
- def __init__(self,FSM):
|
625
|
|
- super(Roll, self).__init__(FSM)
|
626
|
|
-
|
627
|
|
- def Enter(self):
|
628
|
|
- self.FSM.stateLife = 1
|
629
|
|
- # self.FSM.owner.obj['getoffboard'] == False
|
630
|
|
- # dict['walk'] = 0
|
631
|
|
- print('roll entered')
|
632
|
|
- super(Roll, self).Enter()
|
633
|
|
-
|
634
|
|
- def Execute(self):
|
635
|
|
- self.FSM.stateLife += 1
|
636
|
|
- if dict['walk'] == 1 or self.FSM.owner.obj['getoffboard'] == True:
|
637
|
|
- dict['walk'] = 1
|
638
|
|
- self.FSM.owner.obj['getoffboard'] = True
|
639
|
|
- #self.FSM.ToTransition('toWalk')
|
640
|
|
- self.FSM.ToTransition('toOffboard')
|
641
|
|
- print('fsm to walk', dict['walk'], self.FSM.owner.obj['getoffboard'])
|
642
|
|
- if self.FSM.owner.obj['fall'] == True:
|
643
|
|
- self.FSM.ToTransition('toRagdoll')
|
644
|
|
- #print('rolling')
|
645
|
|
- #self.FSM.ToTransition('toLand')
|
646
|
|
-
|
647
|
|
- def Exit(self):
|
648
|
|
- pass
|
|
630
|
+ def __init__(self,FSM):
|
|
631
|
+ super(Roll, self).__init__(FSM)
|
|
632
|
+
|
|
633
|
+ def Enter(self):
|
|
634
|
+ self.FSM.stateLife = 1
|
|
635
|
+ # self.FSM.owner.obj['getoffboard'] == False
|
|
636
|
+ # dict['walk'] = 0
|
|
637
|
+ print('roll entered')
|
|
638
|
+ super(Roll, self).Enter()
|
|
639
|
+
|
|
640
|
+ def Execute(self):
|
|
641
|
+ self.FSM.stateLife += 1
|
|
642
|
+ if dict['walk'] == 1 or self.FSM.owner.obj['getoffboard'] == True:
|
|
643
|
+ dict['walk'] = 1
|
|
644
|
+ self.FSM.owner.obj['getoffboard'] = True
|
|
645
|
+ #self.FSM.ToTransition('toWalk')
|
|
646
|
+ self.FSM.ToTransition('toOffboard')
|
|
647
|
+ #print('fsm to walk', dict['walk'], self.FSM.owner.obj['getoffboard'])
|
|
648
|
+ if self.FSM.owner.obj['fall'] == True:
|
|
649
|
+ self.FSM.ToTransition('toRagdoll')
|
|
650
|
+ #print('rolling')
|
|
651
|
+ #self.FSM.ToTransition('toLand')
|
|
652
|
+
|
|
653
|
+ def Exit(self):
|
|
654
|
+ pass
|
649
|
655
|
|
650
|
656
|
#====================================
|
651
|
657
|
|
652
|
658
|
class Offboard(State):
|
653
|
|
- def __init__(self,FSM):
|
654
|
|
- super(Offboard, self).__init__(FSM)
|
655
|
|
-
|
656
|
|
- def Enter(self):
|
657
|
|
- self.FSM.stateLife = 1
|
658
|
|
-
|
659
|
|
- o = self.FSM.owner.obj
|
660
|
|
- if o['stance']:
|
661
|
|
- o.applyRotation([0,0,3.14], True)
|
662
|
|
- o['stance'] = False
|
663
|
|
- self.FSM.owner.arm.playAction('fak_noffboard', 0,24, layer=2, play_mode=0, speed=1, blendin=0)
|
664
|
|
- self.FSM.owner.deck_arm.playAction('b_reg_offboard', 0,30, layer=2, play_mode=0, speed=1, blendin=0)
|
665
|
|
- else:
|
666
|
|
- self.FSM.owner.arm.playAction('reg_noffboard', 0,40, layer=2, play_mode=0, speed=1, blendin=0)
|
667
|
|
- self.FSM.owner.deck_arm.playAction('b_reg_offboard', 0,40, layer=2, play_mode=0, speed=1, blendin=0)
|
668
|
|
- print('fsm getting off board')
|
669
|
|
- super(Offboard, self).Enter()
|
670
|
|
-
|
671
|
|
- def Execute(self):
|
672
|
|
- self.FSM.stateLife += 1
|
673
|
|
-
|
674
|
|
- self.FSM.ToTransition('toWalk')
|
675
|
|
-
|
676
|
|
- def Exit(self):
|
677
|
|
- pass
|
|
659
|
+ def __init__(self,FSM):
|
|
660
|
+ super(Offboard, self).__init__(FSM)
|
|
661
|
+
|
|
662
|
+ def Enter(self):
|
|
663
|
+ self.FSM.stateLife = 1
|
|
664
|
+
|
|
665
|
+ o = self.FSM.owner.obj
|
|
666
|
+ if o['stance']:
|
|
667
|
+ o.applyRotation([0,0,3.14], True)
|
|
668
|
+ o['stance'] = False
|
|
669
|
+ self.FSM.owner.arm.playAction('fak_noffboard', 0,24, layer=2, play_mode=0, speed=1, blendin=0)
|
|
670
|
+ self.FSM.owner.deck_arm.playAction('b_reg_offboard', 0,30, layer=2, play_mode=0, speed=1, blendin=0)
|
|
671
|
+ else:
|
|
672
|
+ self.FSM.owner.arm.playAction('reg_noffboard', 0,40, layer=2, play_mode=0, speed=1, blendin=0)
|
|
673
|
+ self.FSM.owner.deck_arm.playAction('b_reg_offboard', 0,40, layer=2, play_mode=0, speed=1, blendin=0)
|
|
674
|
+ print('fsm getting off board')
|
|
675
|
+ super(Offboard, self).Enter()
|
|
676
|
+
|
|
677
|
+ def Execute(self):
|
|
678
|
+ self.FSM.stateLife += 1
|
|
679
|
+
|
|
680
|
+ self.FSM.ToTransition('toWalk')
|
|
681
|
+
|
|
682
|
+ def Exit(self):
|
|
683
|
+ pass
|
678
|
684
|
#====================================
|
679
|
685
|
|
680
|
686
|
class Ragdoll(State):
|
681
|
|
- def __init__(self,FSM):
|
682
|
|
- super(Ragdoll, self).__init__(FSM)
|
683
|
|
-
|
684
|
|
- def Enter(self):
|
685
|
|
- self.FSM.stateLife = 1
|
686
|
|
- self.FSM.owner.obj['ragdoll_active'] = True
|
687
|
|
- self.FSM.owner.drop_deck()
|
688
|
|
- print('ragdoll_player_fsm entered')
|
689
|
|
- super(Ragdoll, self).Enter()
|
690
|
|
-
|
691
|
|
- def Execute(self):
|
692
|
|
- self.FSM.stateLife += 1
|
693
|
|
- print('ragdolling')
|
694
|
|
- if dict['yBut'] == 1:
|
695
|
|
- self.FSM.owner.obj['fall'] = False
|
696
|
|
- self.FSM.owner.cont.activate(self.FSM.owner.cont.actuators['walk'])
|
697
|
|
- #self.FSM.ToTransition('toWalk')
|
698
|
|
- self.FSM.ToTransition('toOffboard')
|
699
|
|
- self.FSM.owner.move_walk_cam()
|
700
|
|
- def Exit(self):
|
701
|
|
- print('ragdoll_player_fsm exited')
|
702
|
|
- self.FSM.owner.obj['ragdoll_active'] = False
|
703
|
|
- #pass
|
|
687
|
+ def __init__(self,FSM):
|
|
688
|
+ super(Ragdoll, self).__init__(FSM)
|
|
689
|
+
|
|
690
|
+ def Enter(self):
|
|
691
|
+ self.FSM.stateLife = 1
|
|
692
|
+ self.FSM.owner.obj['ragdoll_active'] = True
|
|
693
|
+ self.FSM.owner.drop_deck()
|
|
694
|
+ print('ragdoll_player_fsm entered')
|
|
695
|
+ super(Ragdoll, self).Enter()
|
|
696
|
+
|
|
697
|
+ def Execute(self):
|
|
698
|
+ self.FSM.stateLife += 1
|
|
699
|
+ #print('ragdolling')
|
|
700
|
+ if dict['yBut'] == 1:
|
|
701
|
+ self.FSM.owner.obj['fall'] = False
|
|
702
|
+ self.FSM.owner.cont.activate(self.FSM.owner.cont.actuators['walk'])
|
|
703
|
+ #self.FSM.ToTransition('toWalk')
|
|
704
|
+ self.FSM.ToTransition('toOffboard')
|
|
705
|
+ self.FSM.owner.move_walk_cam()
|
|
706
|
+ self.FSM.owner.check_pause()
|
|
707
|
+ def Exit(self):
|
|
708
|
+ print('ragdoll_player_fsm exited')
|
|
709
|
+ self.FSM.owner.obj['ragdoll_active'] = False
|
|
710
|
+ #pass
|
704
|
711
|
|
705
|
712
|
#====================================
|
706
|
|
-
|
|
713
|
+
|
707
|
714
|
class Dropin(State):
|
708
|
|
- def __init__(self,FSM):
|
709
|
|
- super(Dropin, self).__init__(FSM)
|
710
|
|
-
|
711
|
|
- def Enter(self):
|
712
|
|
- self.FSM.stateLife = 1
|
713
|
|
- if self.FSM.owner.throw_deck != None:
|
714
|
|
- self.FSM.owner.throw_deck.endObject()
|
715
|
|
- self.FSM.owner.throw_deck = None
|
716
|
|
- self.FSM.owner.show_deck()
|
717
|
|
- self.FSM.owner.arm.playAction('reg_dropin3', 30, 50, layer=2, play_mode=0, speed=1, blendin=5)
|
718
|
|
- self.FSM.owner.deck_arm.playAction('b_reg_dropin', 30, 50, layer=2, play_mode=0, speed=1, blendin=5)
|
719
|
|
- self.out_triggered = False
|
720
|
|
- # #player armature action name, start, end frames
|
721
|
|
- # 'reg_dropin3', 30, 50,
|
722
|
|
- # #deck action name, start, end frames
|
723
|
|
- # 'b_reg_dropin', 30, 50,
|
724
|
|
- # #layer, speed, mode (0 = play, 1 = loop), blendin
|
725
|
|
- # 1, .5, 0, 15,
|
726
|
|
- # #intro, length
|
727
|
|
-
|
728
|
|
- super(Dropin, self).Enter()
|
729
|
|
-
|
730
|
|
- def Execute(self):
|
731
|
|
- self.FSM.stateLife += 1
|
732
|
|
- print('dropin')
|
733
|
|
- eu = self.FSM.owner.get_vert_rot(self.FSM.owner.obj, self.FSM.owner.dropin_obj[0])
|
734
|
|
- #print(eu, 'eu')
|
735
|
|
-
|
736
|
|
- self.FSM.owner.arm.playAction('reg_dropin3', 50, 50, layer=1, play_mode=1, speed=1, blendin=5)
|
737
|
|
- self.FSM.owner.deck_arm.playAction('b_reg_dropin', 50, 50, layer=1, play_mode=1, speed=1, blendin=5)
|
738
|
|
-
|
739
|
|
- if dict['last_yBut'] == True and dict['yBut'] == False:
|
740
|
|
- self.out_triggered = True
|
741
|
|
-
|
742
|
|
- if self.out_triggered:
|
743
|
|
- self.FSM.owner.arm.playAction('reg_dropin3', 60, 80, layer=2, play_mode=0, speed=1, blendin=5)
|
744
|
|
- self.FSM.owner.deck_arm.playAction('b_reg_dropin', 60, 80, layer=2, play_mode=0, speed=1, blendin=5)
|
745
|
|
- self.FSM.owner.obj.applyForce([-15, 0, 0], True)
|
746
|
|
- self.FSM.owner.obj.applyRotation([0, -.01, 0], True)
|
747
|
|
-
|
748
|
|
- else:
|
749
|
|
- self.FSM.owner.move_to_te()
|
750
|
|
-
|
751
|
|
- if self.FSM.owner.arm.getActionFrame(2)> 78:
|
752
|
|
-
|
753
|
|
- self.FSM.ToTransition('toRoll')
|
754
|
|
-
|
755
|
|
- self.FSM.owner.move_walk_cam()
|
756
|
|
-
|
757
|
|
-
|
758
|
|
-
|
759
|
|
-
|
760
|
|
-
|
761
|
|
- def Exit(self):
|
762
|
|
- self.FSM.owner.obj['getonboard'] = True
|
763
|
|
- self.FSM.owner.walking = False
|
764
|
|
- #self.FSM.owner.obj['getonboard'] = False
|
765
|
|
- dict['walking'] = False
|
766
|
|
- self.FSM.owner.obj['walking'] = False
|
767
|
|
- self.FSM.owner.obj['requestAction'] = 'reg_air'
|
768
|
|
- self.FSM.owner.obj['getoffboard'] == False
|
|
715
|
+ def __init__(self,FSM):
|
|
716
|
+ super(Dropin, self).__init__(FSM)
|
|
717
|
+
|
|
718
|
+ def Enter(self):
|
|
719
|
+ self.FSM.stateLife = 1
|
|
720
|
+ if self.FSM.owner.throw_deck != None:
|
|
721
|
+ self.FSM.owner.throw_deck.endObject()
|
|
722
|
+ self.FSM.owner.throw_deck = None
|
|
723
|
+ self.FSM.owner.show_deck()
|
|
724
|
+ self.FSM.owner.arm.playAction('reg_dropin3', 30, 50, layer=2, play_mode=0, speed=1, blendin=5)
|
|
725
|
+ self.FSM.owner.deck_arm.playAction('b_reg_dropin', 30, 50, layer=2, play_mode=0, speed=1, blendin=5)
|
|
726
|
+ self.out_triggered = False
|
|
727
|
+ # #player armature action name, start, end frames
|
|
728
|
+ # 'reg_dropin3', 30, 50,
|
|
729
|
+ # #deck action name, start, end frames
|
|
730
|
+ # 'b_reg_dropin', 30, 50,
|
|
731
|
+ # #layer, speed, mode (0 = play, 1 = loop), blendin
|
|
732
|
+ # 1, .5, 0, 15,
|
|
733
|
+ # #intro, length
|
|
734
|
+
|
|
735
|
+ super(Dropin, self).Enter()
|
|
736
|
+
|
|
737
|
+ def Execute(self):
|
|
738
|
+ self.FSM.stateLife += 1
|
|
739
|
+ #print('dropin')
|
|
740
|
+ eu = self.FSM.owner.get_vert_rot(self.FSM.owner.obj, self.FSM.owner.dropin_obj[0])
|
|
741
|
+ #print(eu, 'eu')
|
|
742
|
+
|
|
743
|
+ self.FSM.owner.arm.playAction('reg_dropin3', 50, 50, layer=1, play_mode=1, speed=1, blendin=5)
|
|
744
|
+ self.FSM.owner.deck_arm.playAction('b_reg_dropin', 50, 50, layer=1, play_mode=1, speed=1, blendin=5)
|
|
745
|
+
|
|
746
|
+ if dict['last_yBut'] == True and dict['yBut'] == False:
|
|
747
|
+ self.out_triggered = True
|
|
748
|
+
|
|
749
|
+ if self.out_triggered:
|
|
750
|
+ self.FSM.owner.arm.playAction('reg_dropin3', 60, 80, layer=2, play_mode=0, speed=1, blendin=5)
|
|
751
|
+ self.FSM.owner.deck_arm.playAction('b_reg_dropin', 60, 80, layer=2, play_mode=0, speed=1, blendin=5)
|
|
752
|
+ self.FSM.owner.obj.applyForce([-15, 0, 0], True)
|
|
753
|
+ self.FSM.owner.obj.applyRotation([0, -.01, 0], True)
|
|
754
|
+
|
|
755
|
+ else:
|
|
756
|
+ self.FSM.owner.move_to_te()
|
|
757
|
+
|
|
758
|
+ if self.FSM.owner.arm.getActionFrame(2)> 78:
|
|
759
|
+
|
|
760
|
+ self.FSM.ToTransition('toRoll')
|
|
761
|
+
|
|
762
|
+ self.FSM.owner.move_walk_cam()
|
|
763
|
+ self.FSM.owner.check_pause()
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+ def Exit(self):
|
|
770
|
+ self.FSM.owner.obj['getonboard'] = True
|
|
771
|
+ self.FSM.owner.walking = False
|
|
772
|
+ #self.FSM.owner.obj['getonboard'] = False
|
|
773
|
+ dict['walking'] = False
|
|
774
|
+ self.FSM.owner.obj['walking'] = False
|
|
775
|
+ self.FSM.owner.obj['requestAction'] = 'reg_air'
|
|
776
|
+ self.FSM.owner.obj['getoffboard'] == False
|
769
|
777
|
|
770
|
778
|
|
771
|
779
|
|
772
|
780
|
#====================================
|
|
781
|
+
|
|
782
|
+#====================================
|
|
783
|
+
|
|
784
|
+class Pause(State):
|
|
785
|
+ def __init__(self,FSM):
|
|
786
|
+ super(Pause, self).__init__(FSM)
|
|
787
|
+
|
|
788
|
+ def Enter(self):
|
|
789
|
+ self.FSM.stateLife = 1
|
|
790
|
+ super(Pause, self).Enter()
|
|
791
|
+
|
|
792
|
+ def Execute(self):
|
|
793
|
+ self.FSM.stateLife += 1
|
|
794
|
+ #print('******paused')
|
|
795
|
+ self.FSM.owner.obj['walk'] = True
|
|
796
|
+ if dict['npause'] == False:
|
|
797
|
+ n = self.FSM.prevState.__class__.__name__
|
|
798
|
+ n = 'to' + n
|
|
799
|
+ #self.FSM.ToTransition('toWalk')
|
|
800
|
+ self.FSM.ToTransition(n)
|
|
801
|
+
|
|
802
|
+ def Exit(self):
|
|
803
|
+ pass
|
|
804
|
+
|
|
805
|
+#====================================
|