1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099 |
- #shuvit.org
- #walk.py
-
- import bge
- import GameLogic
- import ctypes
- import random
- import math
-
- scene = bge.logic.getCurrentScene()
- objList = scene.objects
-
- cont = GameLogic.getCurrentController()
- obj = bge.logic.getCurrentScene().objects
- char = bge.constraints.getCharacter
- own = cont.owner
- stance = own['stance']
- STANCE = own['stance']
- r_ground = cont.sensors["r_Ground"]
- linvel = own.getLinearVelocity(True)
- lasta = own['lasta']
- lastx = own['lastx']
- last_sit = own['sit']
- dict = bge.logic.globalDict
-
- try:
- own['walk_timer'] = own['walk_timer'] +1
- except:
- own['walk_timer'] = 1
-
- truckon = 450
- deckon = 460
-
- lLR = dict['lLR']
- lUD = dict['lUD']
- rLR = dict['rLR']
- rUD = dict['rUD']
- lTrig = dict['lTrig']
- rTrig = dict['rTrig']
- aBut = dict['aBut']
- bBut = dict['bBut']
- xBut = dict['xBut']
- yBut = dict['yBut']
- lBump = dict['lBump']
- rBump = dict['rBump']
- bkBut = dict['bkBut']
- stBut = dict['stBut']
- xbBut = dict['xbBut']
- ltsBut = dict['ltsBut']
- rtsBut = dict['rtsBut']
- ldPad = dict['ldPad']
- rdPad = dict['rdPad']
- udPad = dict['udPad']
- ddPad = dict['ddPad']
-
- #user
- sens = .04
- fliplay = 30
- dropinCol = own.sensors['dropinCol']
-
- skater = scene.objects["Char4"]
- deck = scene.objects["deck"]
- trucks = scene.objects["trucks"]
-
- throw_deck_empty = scene.objects["throw_deck_empty"]
- wheel1 = scene.objects["rollen.000"]
- wheel2 = scene.objects["rollen.001"]
- wheel3 = scene.objects["rollen.002"]
- wheel4 = scene.objects["rollen.003"]
- camobj = scene.objects["Camera.003"]
- camera = cont.actuators["Camera"]
- replayCam = cont.actuators["replayCam"]
- timer = own['dropinTimer']
- cam = scene.objects["Camera.003"]
- freecam = scene.objects["freecam"]
- followcam = scene.objects["followcam"]
-
- control_bottom = scene.objects['control_bottom']
- cb = control_bottom.sensors['grindCol_bottom']
- cb_td = control_bottom.sensors['td_bottom']
-
- noidle = 0
-
- if skater.isPlayingAction(460):
- noidle = 1
-
- if own["stance"] == None:
- own["stance"] = True
- STANCE = own["stance"]
- def killact(layer):
- if skater.isPlayingAction(layer):
- skater.stopAction(layer)
- if deck.isPlayingAction(layer):
- deck.stopAction(layer)
- if trucks.isPlayingAction(layer):
- trucks.stopAction(layer)
- def killall():
- for x in range(5000):
- skater.stopAction(x)
- deck.stopAction(x)
- trucks.stopAction(x)
- def trucksisplaying():
- for x in range(5000):
- if deck.isPlayingAction(x):
- print("deck is playing:", x)
-
- def printplaying():
- splaying_layers = "S: "
- playing_layers = "D: "
- tplaying_layers = "T: "
- for x in range(9900):
- if skater.isPlayingAction(x):
- #if trucks.isPlayingAction(x):
- #if skater.isPlayingAction(x):
- splaying_layers += str(x)
- splaying_layers += " "
- if deck.isPlayingAction(x):
- #if trucks.isPlayingAction(x):
- #if skater.isPlayingAction(x):
- playing_layers += str(x)
- playing_layers += " "
- if trucks.isPlayingAction(x):
- #if trucks.isPlayingAction(x):
- #if skater.isPlayingAction(x):
- tplaying_layers += str(x)
- tplaying_layers += " "
- print(splaying_layers, playing_layers, tplaying_layers)
- #printplaying()
- ##
- if r_ground.positive and xBut == False and lastx == False:
- killact(10)
- #killact(11)
- killact(12)
- killact(13)
- ######################################
-
- #idle
- if stance == 0 and skater.isPlayingAction(fliplay) == False and yBut == False and r_ground.triggered and xBut == False and noidle == 0 and own['walk_idling'] == 0 and own['sit'] == 0 and own['dropinTimer'] == 0 and own['lasty'] == False:
- own['requestAction'] = 'reg_idle'
- if own['throw_deck'] == True:
- own['requestAction'] = 'reg_idle_nb'
-
- if stance == 1 and skater.isPlayingAction(fliplay) == False and yBut == False and r_ground.triggered and xBut == False and noidle == 0 and own['walk_idling'] == 0 and own['sit'] == 0 and own['dropinTimer'] == 0 and own['lasty'] == False:
- own['requestAction'] = 'fak_idle'
- if own['throw_deck'] == True:
- own['requestAction'] = 'fak_idle_nb'
-
- if lUD < -sens:
- lup = 1
- else:
- lup = 0
- if lUD > sens:
- ldown = 1
- else:
- ldown = 0
- if lLR < -sens:
- lLeft = 1
- else:
- lLeft = 0
- if lLR > sens:
- lRight = 1
- else:
- lRight = 0
-
- #walking
-
- #new walking
- vel = own.getLinearVelocity(True)
- if own['walk_timer'] < 50:
- velx = vel.x * .95
- own.setLinearVelocity([velx, 0, vel.z], True)
- else:
- own.setLinearVelocity([0, 0, vel.z], True)
-
- wf = 1
- if own['last_walk_frame'] - own['last_roll_frame'] > 55:
- wf = 0
-
- if ((lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0)) and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] == 0:
- own['walking'] = "regular"
- walking = "regular"
-
- elif ((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] != 2:
- own['walking'] = "fast"
- walking = "fast"
- else:
- own['walking'] = None
- walking = None
-
- if walking == "regular":
- cont.deactivate(own.actuators['forward2'])
- cont.deactivate(own.actuators['backward2'])
- if stance == 0:
- cont.activate(own.actuators['forward'])
- else:
- cont.activate(own.actuators['backward'])
- if walking == "fast":
- cont.deactivate(own.actuators['forward'])
- cont.deactivate(own.actuators['backward'])
- if stance == 0:
- cont.activate(own.actuators['forward2'])
- else:
- cont.activate(own.actuators['backward2'])
-
- if walking == None:
- cont.deactivate(own.actuators['forward2'])
- cont.deactivate(own.actuators['backward2'])
- cont.deactivate(own.actuators['forward'])
- cont.deactivate(own.actuators['backward'])
- if own['walk_timer'] < 50:
- velx = vel.x * .95
- own.setLinearVelocity([velx, 0, vel.z], True)
- else:
- own.setLinearVelocity([0, 0, vel.z], True)
-
- #old walking
- if (lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
- own.actuators["walkondirt"].volume = .2
- own.actuators["walkondirt"].pitch = 1
- cont.activate(own.actuators["walkondirt"])
-
- if stance == 0 and skater.isPlayingAction(fliplay) == False:
- #without deck
- if own['throw_deck'] == True:
- own['requestAction'] = 'reg_walk_nb'
- else:
- own['requestAction'] = 'reg_walk'
-
- if stance == 1 and skater.isPlayingAction(fliplay) == False:
- #without deck
- if own['throw_deck'] == True:
- own['requestAction'] = 'fak_walk_nb'
- else:
- own['requestAction'] = 'fak_walk'
-
- elif ((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
- own.actuators["walkondirt"].volume = .2
- own.actuators["walkondirt"].pitch = 1.3
- cont.activate(own.actuators["walkondirt"])
- if stance == 0 and skater.isPlayingAction(fliplay) == False:
- if own['throw_deck'] == True:
- own['requestAction'] = 'reg_walkFast_nb'
- else:
- own['requestAction'] = 'reg_walkFast'
-
- if stance == 1 and skater.isPlayingAction(fliplay) == False:
- if own['throw_deck'] == True:
- own['requestAction'] = 'fak_walkFast_nb'
- else:
- own['requestAction'] = 'fak_walkFast'
- else:
- vel = own.getLinearVelocity(True)
- cont.deactivate(own.actuators["walkondirt"])
-
- #turning
- if lRight == 1 or dict['kb_ra'] == 2:
- cont.activate(own.actuators['right'])
- else:
- cont.deactivate(own.actuators['right'])
-
- if lLeft == 1 or dict['kb_la'] == 2:
- cont.activate(own.actuators['left'])
- else:
- cont.deactivate(own.actuators['left'])
-
- #in air
- if (lup == 1 or dict['kb_ua'] != 0) and r_ground.positive == False:
- if stance == 0:
- cont.deactivate(own.actuators['forward'])
- cont.deactivate(own.actuators['forward2'])
- killact(4)
- killact(5)
- killact(6)
- killact(7)
- velx = linvel.x - 1
- own.setLinearVelocity([-1.5, linvel.y, linvel.z], 1)
- if stance == 1:
- cont.deactivate(own.actuators['backward'])
- cont.deactivate(own.actuators['backward2'])
- killact(4)
- killact(5)
- killact(6)
- killact(7)
- velx = linvel.x + 1
- own.setLinearVelocity([1.5, linvel.y, linvel.z], 1)
- own['lF_air_frame'] = own['framenum']
- #---------------
- if rLR > .05:
- cont.activate(camobj.actuators['camRight'])
- else:
- cont.deactivate(camobj.actuators['camRight'])
- if rLR < -.05:
- cont.activate(camobj.actuators['camLeft'])
- else:
- cont.deactivate(camobj.actuators['camLeft'])
- if rUD > .05:
- cont.activate(camobj.actuators['camDown'])
- else:
- cont.deactivate(camobj.actuators['camDown'])
- if rUD < -.05:
- cont.activate(camobj.actuators['camUp'])
- else:
- cont.deactivate(camobj.actuators['camUp'])
-
- #----------------
- camera.height = .9 #-.4
- camera.min = 1.5
- camera.max = 2
- lasty = own['lasty']
-
- def onboard():
- if own['walk'] == 0:
- print("start walking")
- own['walk_idling'] = 0
- if own['framenum'] > 100 and own['fall'] == False:
- cont.activate(own.actuators['pop'])
- own['getoffboard'] = False
- fliplay = 301
- fliplay2 = 302
- fliplay3 = 303
- own['grindcement_vol'] = 0
- own['grindcement_pitch'] = 0
- own['grindrail_vol'] = 0
- own['grindrail_pitch'] = 0
- own['sroll_vol'] = 0
- own['sroll_pitch'] = 0
- try:
- vel = own['offboard_vel']
- vel = [velx, vel.y, vel.z]
- except:
- pass
-
- if STANCE == 0:
- skater.stopAction(fliplay)
- deck.stopAction(deckon)
- trucks.stopAction(truckon)
- own['requestAction'] = 'reg_offboard'
-
- if STANCE == 1:
- skater.stopAction(fliplay)
- deck.stopAction(deckon)
- trucks.stopAction(truckon)
- own['requestAction'] = 'fak_offboard'
- def jump():
- #limit fall speed
- if linvel.z < -10:
- own.linearVelocity.z = -10
- if xBut == True or dict['kb_space'] == 1:
- if own['lastx'] == 0:
- killact(3)
- killact(4)
- killact(5)
- killact(6)
- killact(7)
- if STANCE == 0:
- own['requestAction'] ='reg_jump'
- print('jump')
- if STANCE == 1:
- own['requestAction'] ='fak_jump'
- print('jump')
- JUMPHEIGHT = 1100
- force = [ 0.0, 0.0, JUMPHEIGHT]
- # use local axis
- local = False
- # apply force -- limit jump speed
- if linvel.z < 10:
- own.applyForce(force, local)
- own['lastx'] = 1
- else:
- own['lastx'] = 0
- def dropin():
- if dropinCol.positive == True:
- pass
-
- def getonboard():
- #print(dict['kb_q'])
- getonboard = own['getonboard']
- fliplay2 = 50#8560
- if yBut == True or dict['kb_q'] == 2:
- fliplay3 = fliplay2 + 1
- if dropinCol.positive == True:
- nearestObject = None
- grindEmpty = scene.objects['grindEmpty']
- grindDar = grindEmpty.sensors['grindDar2']
- minDist = None
- if grindDar.positive:
- detectedObjects = grindDar.hitObjectList
- dist = 0
- for obj in detectedObjects:
- dist = own.getDistanceTo(obj)
- if (minDist is None or dist < minDist):
- nearestObject = obj
- minDist = dist
- if nearestObject != None:
- print(nearestObject)
- obj = nearestObject
- player_e = own.worldOrientation.to_euler()
- player_pos = own.worldPosition
- player_rotz = math.degrees(player_e[2])
- grinder_e = obj.worldOrientation.to_euler()
- grinder_rotz = math.degrees(grinder_e[2])
- rot = player_rotz - grinder_rotz
- grinder_pos = obj.worldPosition
- worldVect = [1, 0, 0]
- vect = obj.getAxisVect(worldVect)
- go = obj.worldOrientation
- grinder_axis = [1,0,0]
- try:
- delta = player_pos - grinder_pos
-
- delta = delta.cross(vect)
- if delta[2] >= 0:
- grindside = "right"
- else:
- grindside = "left"
- deltamove = delta[2] * .1#.25
- if STANCE == 0:
- move = [-deltamove, 0, 0]
- else:
- move = [deltamove, 0, 0]
- own.applyMovement(move, True)
- except:
- pass
-
- if STANCE == 0:
- own['requestAction'] ='reg_dropin_pos'
- own['dropinTimer'] = 60
-
- if STANCE == 1:
- own['requestAction'] ='fak_dropin_pos'
- own['dropinTimer'] = 60
-
- if getonboard == 1:
- fliplay3 = 6000
- onboard_speed = .1
- own['getonboard'] = 0
- own['walk_idling'] = 0
- if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 2) and dropinCol.positive:
- deckact = deck.actuators["Visibility"]
- trucksact = trucks.actuators["Visibility"]
- wheel1act = wheel1.actuators["Visibility"]
- wheel2act = wheel2.actuators["Visibility"]
- wheel3act = wheel3.actuators["Visibility"]
- wheel4act = wheel4.actuators["Visibility"]
- deckact.visibility = True
- trucksact.visibility = True
- wheel1act.visibility = True
- wheel2act.visibility = True
- wheel3act.visibility = True
- wheel4act.visibility = True
- cont.activate(deck.actuators['Visibility'])
- cont.activate(trucks.actuators['Visibility'])
- cont.activate(wheel1.actuators['Visibility'])
- cont.activate(wheel2.actuators['Visibility'])
- cont.activate(wheel3.actuators['Visibility'])
- cont.activate(wheel4.actuators['Visibility'])
- own['throw_deck'] = False
- throw_deck_empty = scene.objects["throw_deck_empty"]
- throw_deck_empty['kill_deck'] = 1
- if (yBut == False and lasty == True) or dict['kb_q'] == 3:
- own['getonboard'] = 1
- own['walk_idling'] = 0
-
- def nextframe():
- framenumber = own["framenum"]
- framenumber = framenumber + 1
- if framenumber == 900000:
- framenumber = 0
- own["framenum"] = framenumber
- own['last_walk_frame'] = framenumber
-
- def checkidle():
- idle = cont.sensors["idle"]
- idle_frame = own["walk_idle_frame"]
- if idle.positive:
- own["walk_idle_frame"] = 0
- cont.deactivate(camobj.actuators['idle_camRight'])
- camera.height = .5
- else:
- if idle_frame == 0:
- own["walk_idle_frame"] = own["framenum"]
- diff = own["framenum"] - idle_frame
-
- if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
- cont.activate(camobj.actuators['idle_camRight'])
- camera.height = .9
- camera.min = 2
- camera.max = 2.50
- own['walk_idling'] = 1
- else:
- own['walk_idling'] = 0
-
- def idle_anim():
- if own['walk_idling'] == 1 and own['sit'] == 0:
- walk_idle_frame = own['walk_idle_frame']
- mod_num = (own["framenum"] - walk_idle_frame) % 240
- idle_lay = 300
- if mod_num == 0:
- if own['idle_skipper'] > 0:
- own['idle_skipper'] -= 1
- ran_num = random.randint(1, 8)
- if own['last_idle_num'] == ran_num:
- ran_num = 1
- if own['idle_skipper'] == 0:
- own['last_idle_num'] = ran_num
- if ran_num == 1 or ran_num > 7:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle1'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle1'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle1'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle1'
-
- elif ran_num == 2:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle2'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle2_nb'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle1'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle1'
- elif ran_num == 3:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle3'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle3'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle1'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle1'
- own['idle_skipper'] = 2
- elif ran_num == 4:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle4'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle4'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle4'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle4'
- elif ran_num == 5:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle5'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle5'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle5'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle5'
- elif ran_num == 6:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle6'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle6'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle6'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle6'
- elif ran_num == 7:
- killact(3)
- if STANCE == 0 and own['throw_deck'] == 0:
- own['requestAction'] = 'reg_idle7'
- elif STANCE == 0 and own['throw_deck'] == 1:
- own['requestAction'] = 'reg_idle7'
- elif STANCE == 1 and own['throw_deck'] == 0:
- own['requestAction'] = 'fak_idle6'
- elif STANCE == 1 and own['throw_deck'] == 1:
- own['requestAction'] = 'fak_idle6'
-
- def reset_pos():
- #reset
- if ddPad == 1:
- spawn_pos = own['spawn_pos']
- spawn_rot = own['spawn_rot']
- spawn_cam_pos = own['spawn_cam_pos']
- spawn_cam_rot = own['spawn_cam_rot']
- try:
- own.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
- own.worldOrientation = [[spawn_rot[0][0],spawn_rot[0][1],spawn_rot[0][2]], [spawn_rot[1][0],spawn_rot[1][1],spawn_rot[1][2]], [0.0, 0.0, 1.0]]
- cam.worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
- cam.worldOrientation = [[spawn_cam_rot[0][0],spawn_cam_rot[0][1],spawn_cam_rot[0][2]], [spawn_cam_rot[1][0],spawn_cam_rot[1][1],spawn_cam_rot[1][2]], [0.0, 0.0, 1.0]]
- except:
- own.worldPosition = (0, 0, .1)
- own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
- own['stance'] = own['spawn_stance']
- if own["spawn_stance"] == 1:
- own.setLinearVelocity([.1,0,0], 1)
- else:
- own.setLinearVelocity([-.1,0,0], 1)
-
- if udPad == 1:
- own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
- own['spawn_rot'] = [[own.worldOrientation[0][0],own.worldOrientation[0][1],own.worldOrientation[0][2]], [own.worldOrientation[1][0],own.worldOrientation[1][1],own.worldOrientation[1][2]], own.worldOrientation[2][2]]
- own['spawn_cam_pos'] = [cam.worldPosition[0], cam.worldPosition[1], cam.worldPosition[2]]
- own['spawn_cam_rot'] = [[cam.worldOrientation[0][0],cam.worldOrientation[0][1],cam.worldOrientation[0][2]], [cam.worldOrientation[1][0],cam.worldOrientation[1][1],cam.worldOrientation[1][2]], cam.worldOrientation[2][2]]
- stance = own["stance"]
- own["spawn_stance"] = stance
- def falldeck():
- throw_deck_empty = scene.objects["throw_deck_empty"]
- deckact = deck.actuators["Visibility"]
- trucksact = trucks.actuators["Visibility"]
- wheel1act = wheel1.actuators["Visibility"]
- wheel2act = wheel2.actuators["Visibility"]
- wheel3act = wheel3.actuators["Visibility"]
- wheel4act = wheel4.actuators["Visibility"]
-
- if own['throw_deck'] == False:
- own['throw_deck'] = True
- deckact.visibility = False
- trucksact.visibility = False
- wheel1act.visibility = False
- wheel2act.visibility = False
- wheel3act.visibility = False
- wheel4act.visibility = False
- act = throw_deck_empty.actuators['throw_dec_act']
- if STANCE == True:
- act.linearVelocity = [0.0, 1.0, 1.0]
- if STANCE == False:
- act.linearVelocity = [0.0, 1.0, -1.0]
- cont.activate(act)
- else:
- own['throw_deck'] = False
- deckact.visibility = True
- trucksact.visibility = True
- wheel1act.visibility = True
- wheel2act.visibility = True
- wheel3act.visibility = True
- wheel4act.visibility = True
- throw_deck_empty['kill_deck'] = 1
- cont.activate(deck.actuators['Visibility'])
- cont.activate(trucks.actuators['Visibility'])
- cont.activate(wheel1.actuators['Visibility'])
- cont.activate(wheel2.actuators['Visibility'])
- cont.activate(wheel3.actuators['Visibility'])
- cont.activate(wheel4.actuators['Visibility'])
-
- def throwdeck(strength, ud):
- throw_deck_empty = scene.objects["throw_deck_empty"]
- deckact = deck.actuators["Visibility"]
- trucksact = trucks.actuators["Visibility"]
- wheel1act = wheel1.actuators["Visibility"]
- wheel2act = wheel2.actuators["Visibility"]
- wheel3act = wheel3.actuators["Visibility"]
- wheel4act = wheel4.actuators["Visibility"]
-
- if own['throw_deck'] == False:
- own['throw_deck'] = True
- deckact.visibility = False
- trucksact.visibility = False
- wheel1act.visibility = False
- wheel2act.visibility = False
- wheel3act.visibility = False
- wheel4act.visibility = False
- act = throw_deck_empty.actuators['throw_dec_act']
- hard = strength * .08
- if hard > 9:
- hard = 9
- if hard < 1:
- hard = 1
- ud = ud * 4
- own['bbut_timer'] = 0
- if STANCE == True:
- own['requestAction'] = 'fak_throw'
- act.linearVelocity = [0.0, ud, hard]
- if STANCE == False:
- own['requestAction'] = 'fak_throw'
- act.linearVelocity = [0.0, ud, -hard]
- cont.activate(act)
- else:
- own['throw_deck'] = False
- deckact.visibility = True
- trucksact.visibility = True
- wheel1act.visibility = True
- wheel2act.visibility = True
- wheel3act.visibility = True
- wheel4act.visibility = True
- throw_deck_empty['kill_deck'] = 1
- cont.activate(deck.actuators['Visibility'])
- cont.activate(trucks.actuators['Visibility'])
- cont.activate(wheel1.actuators['Visibility'])
- cont.activate(wheel2.actuators['Visibility'])
- cont.activate(wheel3.actuators['Visibility'])
- cont.activate(wheel4.actuators['Visibility'])
- def throwdeck_trigger():
- lastb = own['lastb']
- throw_deck_empty = scene.objects["throw_deck_empty"]
- if bBut == True:
- own['bbut_timer'] += 1
- ud = (rUD * 10) +1
- if bBut == False:
- throw_deck_empty['kill_deck'] = 0
- if bBut == False and own['lastb'] == True:
- strength = own['bbut_timer']
- ud = (rUD * 10) +1
- throwdeck(strength, ud)
-
- def focus_deck():
- since_air = own['framenum'] - own['lF_air_frame']
- if cb_td.positive and since_air < 10:
- object = 'focus_deckA'
- object2 = 'focus_deckB'
- other = throw_deck_empty
- throw_deck = scene.objects["throw_deck"]
- throw_deck.endObject()
- scene.addObject(object, other, 0)
- scene.addObject(object2, other, 0)
-
- if own['throw_deck'] == True:
- if dict['ldPad'] == False and dict['last_ldPad'] == True:
- object = 'focus_deckA'
- object2 = 'focus_deckB'
- other = throw_deck_empty
- scene.addObject(object, other, 0)
- scene.addObject(object2, other, 0)
-
- def fall():
- if own['fall'] == True:
- falldeck()
- if STANCE == 1:
- own['requestAction'] = 'fak_air-walk_air'
- own.setLinearVelocity([3,2,0], True)
- else:
- own['requestAction'] = 'reg_air-walk_air'
- own.setLinearVelocity([-3,-2,0], True)
- own['fall'] = False
-
- def sit():
- #turn off sit
- if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
- if own['sit'] == 1:
- killact(300)
- killact(299)
- own['sit'] = 0
-
- if aBut == False and lasta == True:
- try:
- if 'sit' in r_ground.hitObject:
- print("sit")
- own['sit'] = 1
- killact(3)
- if STANCE == 0:
- own['requestAction'] = 'reg_sit'
- elif STANCE == 1:
- own['requestAction'] = 'fak_sit'
- except:
- pass
- if own['sit'] == 1:
- try:
- killact(3)
- sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
- if STANCE == 0:
- own.alignAxisToVect(-sit_vect, 0, .2)
- own['requestAction'] = 'reg_sit'
-
- elif STANCE == 1:
- own['requestAction'] = 'fak_sit'
- own.alignAxisToVect(sit_vect, 0, .2)
- except:
- pass
-
- def switchcam():
- if ltsBut == False and own['lastlts'] == True and rtsBut == False:
- if own['camera'] == 1:
- own['camera'] = 0
- else:
- own['camera'] = 1
- if rtsBut == False and own['lastrts'] == True and ltsBut == False:
- if own['camera'] == 2:
- own['camera'] = 0
- else:
- own['camera'] = 2
- #followcam
- def move_followcam():
- if own['camera'] == 2:
- if own['lastbkBut'] == True and bkBut == False:
- print("activate move followcam")
- if own['move_followcam'] == False:
- own['move_followcam'] = True
- else:
- own['move_followcam'] = False
- if own['move_followcam'] == True:
- camspeed1 = .015
- camspeed2 = .055
- camrot1 = .005
- camrot2 = .02
- #up
- if lUD < -0.080:
- followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
- cont.activate(followcam.actuators["up"])
- print("fastup")
- else:
- cont.deactivate(followcam.actuators["up"])
- # #down
- if lUD > .080:
- followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
- cont.activate(followcam.actuators["down"])
- else:
- cont.deactivate(followcam.actuators["down"])
- # #left
- if lLR < -0.080:
- followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
- cont.activate(followcam.actuators["left"])
- else:
- cont.deactivate(followcam.actuators["left"])
- # #right
- if lLR > 0.080:
- followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
- cont.activate(followcam.actuators["right"])
- else:
- cont.deactivate(followcam.actuators["right"])
- #up
- if rUD < -0.080:
- followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
- cont.activate(followcam.actuators["rotup"])
- else:
- cont.deactivate(followcam.actuators["rotup"])
- # #down
- if rUD > .080:
- followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
- cont.activate(followcam.actuators["rotdown"])
- else:
- cont.deactivate(followcam.actuators["rotdown"])
- # #left
- if rLR < -0.080:
- followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
- cont.activate(followcam.actuators["rotleft"])
- else:
- cont.deactivate(followcam.actuators["rotleft"])
- # #right
- if rLR > 0.080:
- followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
- cont.activate(followcam.actuators["rotright"])
- else:
- cont.deactivate(followcam.actuators["rotright"])
-
- #*********************************************
-
- if lUD > -0.080 and lUD < -0.030:
- followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
- cont.activate(followcam.actuators["up"])
- else:
- cont.deactivate(followcam.actuators["up"])
- # #down
- if lUD < .080 and lUD > .03:
- followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
- cont.activate(followcam.actuators["down"])
- else:
- cont.deactivate(followcam.actuators["down"])
- # #left
- if lLR > -0.080 and lLR < -0.030:
- followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
- cont.activate(followcam.actuators["left"])
- else:
- cont.deactivate(followcam.actuators["left"])
- # #right
- if lLR < .080 and lLR > .03:
- followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
- cont.activate(followcam.actuators["right"])
- else:
- cont.deactivate(followcam.actuators["right"])
- #up
- if rUD > -0.080 and rUD < -0.030:
- followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
- cont.activate(followcam.actuators["rotup"])
- else:
- cont.deactivate(followcam.actuators["rotup"])
- # #down
- if rUD < .080 and rUD > .03:
- followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
- cont.activate(followcam.actuators["rotdown"])
- else:
- cont.deactivate(followcam.actuators["rotdown"])
- # #left
- if rLR > -0.080 and rLR < -0.030:
- followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
- cont.activate(followcam.actuators["rotleft"])
- else:
- cont.deactivate(followcam.actuators["rotleft"])
- # #right
- if rLR < .080 and rLR > .03:
- followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
- cont.activate(followcam.actuators["rotright"])
- else:
- cont.deactivate(followcam.actuators["rotright"])
- def move_flycam():
- if own['camera'] == 1:
- if own['lastbkBut'] == True and bkBut == False:
- if own['move_freecam'] == False:
- own['move_freecam'] = True
- else:
- own['move_freecam'] = False
- if own['move_freecam'] == True:
- camspeed1 = .015
- camspeed2 = .055
- camrot1 = .005
- camrot2 = .02
- #up
- if lUD < -0.080:
- freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
- cont.activate(freecam.actuators["up"])
- else:
- cont.deactivate(freecam.actuators["up"])
- # #down
- if lUD > .080:
- freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
- cont.activate(freecam.actuators["down"])
- else:
- cont.deactivate(freecam.actuators["down"])
- # #left
- if lLR < -0.080:
- freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
- cont.activate(freecam.actuators["left"])
- else:
- cont.deactivate(freecam.actuators["left"])
- # #right
- if lLR > 0.080:
- freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
- cont.activate(freecam.actuators["right"])
- else:
- cont.deactivate(freecam.actuators["right"])
- #up
- if rUD < -0.080:
- freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
- cont.activate(freecam.actuators["rotup"])
- else:
- cont.deactivate(freecam.actuators["rotup"])
- # #down
- if rUD > .080:
- freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
- cont.activate(freecam.actuators["rotdown"])
- else:
- cont.deactivate(freecam.actuators["rotdown"])
- # #left
- if rLR < -0.080:
- freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
- cont.activate(freecam.actuators["rotleft"])
- else:
- cont.deactivate(freecam.actuators["rotleft"])
- # #right
- if rLR > 0.080:
- freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
- cont.activate(freecam.actuators["rotright"])
- else:
- cont.deactivate(freecam.actuators["rotright"])
-
- #*********************************************
-
- if lUD > -0.080 and lUD < -0.030:
- freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
- cont.activate(freecam.actuators["up"])
- #print(lUD)
- else:
- cont.deactivate(freecam.actuators["up"])
- # #down
- if lUD < .080 and lUD > .03:
- freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
- cont.activate(freecam.actuators["down"])
- else:
- cont.deactivate(freecam.actuators["down"])
- # #left
- if lLR > -0.080 and lLR < -0.030:
- freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
- cont.activate(freecam.actuators["left"])
- else:
- cont.deactivate(freecam.actuators["left"])
- # #right
- if lLR < .080 and lLR > .03:
- freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
- cont.activate(freecam.actuators["right"])
- else:
- cont.deactivate(freecam.actuators["right"])
- #up
- if rUD > -0.080 and rUD < -0.030:
- freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
- cont.activate(freecam.actuators["rotup"])
- else:
- cont.deactivate(freecam.actuators["rotup"])
- # #down
- if rUD < .080 and rUD > .03:
- freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
- cont.activate(freecam.actuators["rotdown"])
- else:
- cont.deactivate(freecam.actuators["rotdown"])
- # #left
- if rLR > -0.080 and rLR < -0.030:
- freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
- cont.activate(freecam.actuators["rotleft"])
- else:
- cont.deactivate(freecam.actuators["rotleft"])
- # #right
- if rLR < .080 and rLR > .03:
- freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
- cont.activate(freecam.actuators["rotright"])
- else:
- cont.deactivate(freecam.actuators["rotright"])
- if r_ground.triggered == False:
- cont.deactivate(own.actuators["walk_align"])
- else:
- cont.activate(own.actuators["walk_align"])
-
- #walking on stairs
- if r_ground.triggered:
- try:
- if 'stair' in r_ground.hitObject:
- own['stair_counter'] = 20
- except:
- pass
- if own['stair_counter'] > 0:
- own['stair_counter'] -= 1
-
- if yBut == True:
- own['walk_idling'] = 0
- own["walk_idle_frame"] = 0
-
-
-
- if own['stair_counter'] > 5 and r_ground.triggered == False:
- own.applyForce([0,0,-200], True)
-
- if deck.visible:
- own['deckvis'] = 1
- else:
- own['deckvis'] = 0
-
- if own['requestAction'] == 'empty' or own['requestAction'] == None:
- if STANCE == 0:
- own['requestAction'] = 'reg_idle1'
- if STANCE == 1:
- own['requestAction'] = 'fak_idle1'
-
- def onground():
- if r_ground.positive:
- own['lF_ground_frame'] = own['framenum']
- if 'grind' in r_ground.hitObject:
- if own['framenum'] - own['last_fall_frame'] < 90:
- own.applyForce([0,100,0], True)
- #print('moving away from rail')
-
- else:
- #print('in air')
- if own['framenum'] - own['lF_ground_frame'] > 10:
- if STANCE == 0:
- own['requestAction'] = 'reg_walk_air'
- else:
- own['requestAction'] = 'fak_walk_air'
- #if control bottom is touching ground object, turn ground on
- if cb.positive:
- if own['framenum'] - own['last_fall_frame'] < 90:
- own['lF_ground_frame'] = own['framenum']
-
-
- onboard()
- jump()
- dropin()
- throwdeck_trigger()
-
- nextframe()
- checkidle()
- getonboard()
- reset_pos()
- switchcam()
- move_flycam()
- move_followcam()
- fall()
- idle_anim()
- sit()
- onground()
- focus_deck()
- #printplaying()
-
- own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
- own.actuators["sroll"].stopSound()
- wheel1 = scene.objects["rollen.000"]
- wheel2 = scene.objects["rollen.001"]
- wheel3 = scene.objects["rollen.002"]
- wheel4 = scene.objects["rollen.003"]
- wheel1.stopAction(2)
- wheel2.stopAction(2)
- wheel3.stopAction(2)
- wheel4.stopAction(2)
- own['lasty'] = yBut
- own['lastb'] = bBut
- own['lasta'] = aBut
- own['lastx'] = xBut
- own['lastlts'] = ltsBut
- own['lastrts'] = rtsBut
- own['lastbkBut'] = bkBut
- own['dropinCol'] = dropinCol
- own['walk'] = 1
-
|