123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- import bge
- import actionsFSMlist
-
- dict = bge.logic.globalDict
- zero_blend = False
-
- def actionPlayer(ac):
- scene = bge.logic.getCurrentScene()
- skater = dict['p1']
- deck = dict['p1d']
- a = getattr(actionsFSMlist.reg_walk, 'name')
- name = getattr(ac, 'name')
- dname = getattr(ac, 'dname')
- start = getattr(ac, 'start')
- end = getattr(ac, 'end')
- dstart = getattr(ac, 'dstart')
- dend = getattr(ac, 'dend')
- layer = getattr(ac, 'layer')
- mode = getattr(ac, 'mode')
- speed = getattr(ac, 'speed')
- blendin = getattr(ac, 'blendin')
- #--------------------------------
- if zero_blend:
- blendin = 0
- print('zeroing blend')
- skater.playAction(name, start,end, layer=layer, play_mode=mode, speed=speed, blendin=blendin)
- deck.playAction(dname, dstart,dend, layer=layer, play_mode=mode, speed=speed, blendin=blendin)
- print('playing', name, get_frame(ac))
-
- def get_frame(ac):
- skater = dict['p1']
- layer = getattr(ac, 'layer')
- print('getting frame', skater.getActionFrame(layer))
- return skater.getActionFrame(layer)
-
- def set_frame(ac, frame):
- skater = dict['p1']
- deck = dict['p1d']
- layer = getattr(ac, 'layer')
- skater.setActionFrame(frame, layer)
- deck.setActionFrame(frame, layer)
- print('setting frame', frame)
-
- def check_exit(aState, rA, timer, ac):
- exits = getattr(ac, 'exits')
- force = getattr(ac, 'force_exit')
- fe = getattr(ac, 'fef')
- if rA in exits:
- return rA
- else:
- return aState
-
- if force != None and fe >= timer:
- print('doing exit timer')
- return force
-
- def state_timer(own):
- if own['aState'] == own['l_aState']:
- own['stateTimer'] += 1
- else:
- own['stateTimer'] = 0
-
- def check_land(rA, aState, own):
-
- #check if manualling
- if rA in actionsFSMlist.reg_manuallist or rA in actionsFSMlist.reg_grindlist:
- aState = rA
- own['stateTimer'] = 0
- own['aState'] = rA
- #otherwise, force land, offboard or fliptrick
- elif 'land' in rA or 'onboard' in rA or 'offboard' in rA or rA in actionsFSMlist.reg_fliplist:
- print('landing________________________', rA)
- aState = rA
- own['stateTimer'] = 0
- own['aState'] = rA
- return aState
-
- def main(cont):
- own = cont.owner
- dict = bge.logic.globalDict
-
- #initial state
- if 'aState' not in own:
- own['aState'] = 'reg_idle'
- own['l_aState'] = None
- own['stateTimer'] = 0
-
-
- aState = own['aState']
- rA = own['requestAction']
- timer = own['stateTimer']
- newState = own['aState']
- aState = check_land(rA, aState, own)
- newState = aState
- og_state = own['aState']
- print(aState, 'cur aState')
-
- if own['l_aState'] in actionsFSMlist.reg_fliplist:
- zero_blend = True
-
- #-----------------------
- check_state = 'reg_idle'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_idle2'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_idle3'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_idle4'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_idle5'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_jump'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_walk_air'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if aState != rA:
- newState = getattr(action, 'exits')[0]
-
- check_state = 'reg_walk_air_out'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- print(own['stateTimer'], getattr(action, 'fef'))
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_sit'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- #if own['stateTimer'] < 19:
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- actionPlayer(getattr(actionsFSMlist, 'intro'))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, actionsFSMlist.reg_sit)
-
- #-----------------------
- check_state = 'reg_walk'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['l_aState'] == 'reg_walkFast':
- frame = get_frame(actionsFSMlist.reg_walkFast)
- actionPlayer(action)
- set_frame(actionsFSMlist.reg_walk, frame)
- else:
- frame = actionPlayer(action)
-
- newState = check_exit(aState, rA, timer, action)
-
- #-----------------------
- check_state = 'reg_walkFast'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- newState = check_exit(aState, rA, timer, actionsFSMlist.reg_walkFast)
-
- if own['l_aState'] == 'reg_walk':
- frame = get_frame(actionsFSMlist.reg_walk)
- actionPlayer(action)
- set_frame(actionsFSMlist.reg_walkFast, frame)
-
- else:
- actionPlayer(action)
- #print(frame)
-
- check_state = 'reg_onboard'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- print('checking onbaord state')
- #if own['stateTimer'] > 10:
- #newState = check_exit(aState, rA, timer, actionsFSMlist.reg_onboard)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_offboard'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > 20:
- newState = check_exit(aState, rA, timer, actionsFSMlist.reg_offboard)
-
- check_state = 'reg_roll'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_turnLeft'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_turnRight'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_opos'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_nopos'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_pump'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_pump_left'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_pump_right'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
-
- check_state = 'reg_push'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > 70:
- newState = 'reg_roll'
-
- check_state = 'reg_push_goof'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > 70:
- newState = 'reg_roll'
-
- check_state = 'reg_powerslide'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- # if own['stateTimer'] < 20:
- # actionPlayer(actionsFSMlist.reg_powerslide_in)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, actionsFSMlist.reg_powerslide)
-
- check_state = 'reg_fs_powerslide'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- # if own['stateTimer'] < 20:
- # actionPlayer(actionsFSMlist.reg_fs_powerslide_in)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, actionsFSMlist.reg_fs_powerslide)
-
- check_state = 'reg_manual'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_nmanual'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_land'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_landL'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_landLb'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_landR'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_landRb'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_air'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_air_nose'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_air_tail'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_ollie'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_kickflip'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_heelflip'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_shuvit'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_shuvit360'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_fsshuvit'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_fsshuvit360'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- if own['stateTimer'] > getattr(action, 'fef'):
- newState = getattr(action, 'force_exit')
-
- check_state = 'reg_5050'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_bsboard'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_fsboard'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_tailg'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_tailgr'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_tailgl'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_noseg'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_nosegr'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_nosegl'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_tailslide'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_noseslide'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
-
-
-
-
-
- check_state = 'frontside_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'backside_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'frontside_nose_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'backside_nose_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'frontside_tail_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'backside_tail_grab'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_ollie_north'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
- check_state = 'reg_ollie_south'
- if aState == check_state:
- action = getattr(actionsFSMlist, check_state)
- if own['stateTimer'] < getattr(action, 'intro_frames'):
- intro = getattr(action, 'intro')
- actionPlayer(getattr(actionsFSMlist, intro))
- else:
- actionPlayer(action)
- newState = check_exit(aState, rA, timer, action)
-
-
-
-
-
-
-
-
-
-
-
-
-
- #-----------------------
- #own['aState'] = aState
- if newState != '':
- own['aState'] = newState
- #print(own['l_aState'], '----l_aState', own['aState'])
- own['l_aState'] = og_state
- #own['l_aState'] = newState
- print(own['l_aState'], '----l_aState', own['aState'], 'rA', rA)
- state_timer(own)
|