Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

walk.py 54KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. #os = 'Windows'
  2. #from sys import platform
  3. #if platform != "win32":
  4. #os = 'Linux'
  5. def onWindows():
  6. return os == 'Windows'
  7. import bge
  8. import GameLogic
  9. import ctypes
  10. #import bpy
  11. import random
  12. #build global dict (move this to separate script that runs once)
  13. scene = bge.logic.getCurrentScene()
  14. objList = scene.objects
  15. #reduction = 400000
  16. #axisTh = 0.03
  17. ############
  18. ##vibration#
  19. ############
  20. ## Define necessary structures
  21. #class XINPUT_VIBRATION(ctypes.Structure):
  22. # _fields_ = [("wLeftMotorSpeed", ctypes.c_ushort), ("wRightMotorSpeed", ctypes.c_ushort)]
  23. #xinput = ctypes.windll.xinput1_3 # Load Xinput.dll
  24. ## Set up function argument types and return type
  25. #XInputSetState = xinput.XInputSetState
  26. #XInputSetState.argtypes = [ctypes.c_uint, ctypes.POINTER(XINPUT_VIBRATION)]
  27. #XInputSetState.restype = ctypes.c_uint
  28. ## Now we're ready to call it. Set left motor to 100%, right motor to 50%
  29. ## for controller 0
  30. ##vibration = XINPUT_VIBRATION(65535, 32768)
  31. ##XInputSetState(0, ctypes.byref(vibration))
  32. ## You can also create a helper function like this:
  33. #def set_vibration(controller, left_motor, right_motor):
  34. # vibration = XINPUT_VIBRATION(int(left_motor * 65535), int(right_motor * 65535))
  35. # XInputSetState(controller, ctypes.byref(vibration))
  36. ## ... and use it like so
  37. ##set_vibration(0, 0.2, 0.2)
  38. ################
  39. ##end vibration#
  40. ################
  41. cont = GameLogic.getCurrentController()
  42. obj = bge.logic.getCurrentScene().objects
  43. char = bge.constraints.getCharacter
  44. own = cont.owner
  45. stance = own['stance']
  46. STANCE = own['stance']
  47. r_ground = cont.sensors["r_Ground"]
  48. #Sensor logic bricks connected to the python Controller
  49. #aXis = cont.sensors["sControla.001"]
  50. #bUtt = cont.sensors["sControlb.001"]
  51. linvel = own.getLinearVelocity(True)
  52. lasta = own['lasta']
  53. lastx = own['lastx']
  54. last_sit = own['sit']
  55. dict = bge.logic.globalDict
  56. try:
  57. own['walk_timer'] = own['walk_timer'] +1
  58. except:
  59. own['walk_timer'] = 1
  60. truckon = 30
  61. deckon = 30
  62. #onW = onWindows()
  63. # windows stuff
  64. #lar_lts = 0
  65. #uad_lts = 1
  66. #lt = 4 if onW else 2
  67. #lar_rts = 2 if onW else 3
  68. #uad_rts = 3 if onW else 4
  69. #rt = 5
  70. #a_but = 0 if onW else 0
  71. #b_but = 1 if onW else 1
  72. #x_but = 2 if onW else 2
  73. #y_but = 3 if onW else 3
  74. #l_bump = 9 if onW else 4
  75. #r_bump = 10 if onW else 5
  76. #bk_but = 4 if onW else 6
  77. #st_but = 6 if onW else 7
  78. #xb_but = 5 if onW else 8
  79. #lts_pr = 7 if onW else 9
  80. #rts_pr = 8 if onW else 10
  81. #l_dp = 13 if onW else 11
  82. #r_dp = 14 if onW else 12
  83. #u_dp = 11 if onW else 13
  84. #d_dp = 12 if onW else 14
  85. lLR = dict['lLR']
  86. lUD = dict['lUD']
  87. rLR = dict['rLR']
  88. rUD = dict['rUD']
  89. lTrig = dict['lTrig']
  90. rTrig = dict['rTrig']
  91. aBut = dict['aBut']
  92. bBut = dict['bBut']
  93. xBut = dict['xBut']
  94. yBut = dict['yBut']
  95. lBump = dict['lBump']
  96. rBump = dict['rBump']
  97. bkBut = dict['bkBut']
  98. stBut = dict['stBut']
  99. xbBut = dict['xbBut']
  100. ltsBut = dict['ltsBut']
  101. rtsBut = dict['rtsBut']
  102. ldPad = dict['ldPad']
  103. rdPad = dict['rdPad']
  104. udPad = dict['udPad']
  105. ddPad = dict['ddPad']
  106. #user
  107. sens = .04
  108. fliplay = 30
  109. dropinCol = own.sensors['dropinCol']
  110. #no input
  111. #def cutOff():
  112. #
  113. # if (abs(lLR) < axisTh
  114. # and abs(lUD) < axisTh
  115. # and abs(rLR) < axisTh
  116. # and abs(rUD) < axisTh
  117. # and aBut == False):
  118. #
  119. # return True
  120. skater = scene.objects["Char4"]
  121. deck = scene.objects["deck"]
  122. trucks = scene.objects["trucks"]
  123. throw_deck_empty = scene.objects["throw_deck_empty"]
  124. wheel1 = scene.objects["rollen.000"]
  125. wheel2 = scene.objects["rollen.001"]
  126. wheel3 = scene.objects["rollen.002"]
  127. wheel4 = scene.objects["rollen.003"]
  128. camobj = scene.objects["Camera.003"]
  129. camera = cont.actuators["Camera"]
  130. replayCam = cont.actuators["replayCam"]
  131. timer = own['dropinTimer']
  132. cam = scene.objects["Camera.003"]
  133. freecam = scene.objects["freecam"]
  134. followcam = scene.objects["followcam"]
  135. noidle = 0
  136. playing_deck = deck.isPlayingAction(deckon)
  137. playing_trucks = trucks.isPlayingAction(truckon)
  138. if playing_deck == 1 or playing_trucks == 1:
  139. noidle = 1
  140. if own["stance"] == None:
  141. own["stance"] = True
  142. STANCE = own["stance"]
  143. def killact(layer):
  144. if skater.isPlayingAction(layer):
  145. skater.stopAction(layer)
  146. if deck.isPlayingAction(layer):
  147. deck.stopAction(layer)
  148. if trucks.isPlayingAction(layer):
  149. trucks.stopAction(layer)
  150. def killall():
  151. for x in range(5000):
  152. skater.stopAction(x)
  153. deck.stopAction(x)
  154. trucks.stopAction(x)
  155. def trucksisplaying():
  156. for x in range(5000):
  157. if deck.isPlayingAction(x):
  158. print("deck is playing:", x)
  159. #trucksisplaying()
  160. def printplaying():
  161. splaying_layers = "S: "
  162. playing_layers = "D: "
  163. tplaying_layers = "T: "
  164. for x in range(9900):
  165. if skater.isPlayingAction(x):
  166. #if trucks.isPlayingAction(x):
  167. #if skater.isPlayingAction(x):
  168. splaying_layers += str(x)
  169. splaying_layers += " "
  170. if deck.isPlayingAction(x):
  171. #if trucks.isPlayingAction(x):
  172. #if skater.isPlayingAction(x):
  173. playing_layers += str(x)
  174. playing_layers += " "
  175. if trucks.isPlayingAction(x):
  176. #if trucks.isPlayingAction(x):
  177. #if skater.isPlayingAction(x):
  178. tplaying_layers += str(x)
  179. tplaying_layers += " "
  180. print(splaying_layers, playing_layers, tplaying_layers)
  181. #printplaying()
  182. ##
  183. if r_ground.positive and xBut == False and lastx == False:
  184. killact(10)
  185. #killact(11)
  186. killact(12)
  187. killact(13)
  188. ######################################
  189. #walk out
  190. #print(own['walk_timer'])
  191. #if own['walk_timer'] < 5:
  192. #
  193. # if stance == 0 and skater.isPlayingAction(fliplay) == False:
  194. #
  195. # if own['throw_deck'] == True:
  196. # print("walk out1")
  197. # skater.playAction("reg_nwalk_nb.001", 15,35, layer=29, play_mode=0, speed=.5)
  198. # else:
  199. # print("walk out2")
  200. # skater.playAction("walk.000", 15,35, layer=29, play_mode=0, speed=.5)
  201. # deck.playAction("a_reg_walk", 0,35, layer=17, play_mode=0)
  202. # trucks.playAction("a_reg_walk", 0,35, layer=17, play_mode=0)
  203. #idle
  204. 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:
  205. own['requestAction'] = 'reg_idle'
  206. if own['throw_deck'] == True:
  207. own['requestAction'] = 'reg_idle_nb'
  208. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  209. else:
  210. #cont.activate(skater.actuators['aRest'])
  211. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  212. deck.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  213. trucks.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  214. 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:
  215. own['requestAction'] = 'fak_idle'
  216. if own['throw_deck'] == True:
  217. own['requestAction'] = 'fak_idle_nb'
  218. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  219. else:
  220. #cont.activate(skater.actuators['aRest'])
  221. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  222. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  223. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  224. if lUD < -sens:
  225. lup = 1
  226. else:
  227. lup = 0
  228. if lUD > sens:
  229. ldown = 1
  230. else:
  231. ldown = 0
  232. #walking
  233. #new walking
  234. #if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  235. vel = own.getLinearVelocity(True)
  236. if own['walk_timer'] < 50:
  237. velx = vel.x * .95
  238. own.setLinearVelocity([velx, 0, vel.z], True)
  239. else:
  240. own.setLinearVelocity([0, 0, vel.z], True)
  241. #print("set 0 vel")
  242. if (lup == 1 and aBut == 0 and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  243. own['walking'] = "regular"
  244. walking = "regular"
  245. elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  246. own['walking'] = "fast"
  247. walking = "fast"
  248. else:
  249. own['walking'] = None
  250. walking = None
  251. #print(own['walk_timer'])
  252. if walking == "regular":
  253. cont.deactivate(own.actuators['forward2'])
  254. cont.deactivate(own.actuators['backward2'])
  255. if stance == 0:
  256. cont.activate(own.actuators['forward'])
  257. else:
  258. cont.activate(own.actuators['backward'])
  259. if walking == "fast":
  260. cont.deactivate(own.actuators['forward'])
  261. cont.deactivate(own.actuators['backward'])
  262. if stance == 0:
  263. cont.activate(own.actuators['forward2'])
  264. else:
  265. cont.activate(own.actuators['backward2'])
  266. if walking == None:
  267. cont.deactivate(own.actuators['forward2'])
  268. cont.deactivate(own.actuators['backward2'])
  269. cont.deactivate(own.actuators['forward'])
  270. cont.deactivate(own.actuators['backward'])
  271. if own['walk_timer'] < 50:
  272. velx = vel.x * .95
  273. own.setLinearVelocity([velx, 0, vel.z], True)
  274. else:
  275. own.setLinearVelocity([0, 0, vel.z], True)
  276. #print("set 0 vel")
  277. #old walking
  278. if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  279. own.actuators["walkondirt"].volume = .2
  280. own.actuators["walkondirt"].pitch = 1
  281. cont.activate(own.actuators["walkondirt"])
  282. if lasta == 1:
  283. #cont.deactivate(own.actuators['forward2'])
  284. #cont.deactivate(own.actuators['backward2'])
  285. killact(6)
  286. killact(7)
  287. killact(8)
  288. killact(9)
  289. killact(17)
  290. killact(18)
  291. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  292. #cont.activate(own.actuators['forward'])
  293. #cont.activate(skater.actuators['aWalk'])
  294. #cont.activate(deck.actuators['a_reg_walk'])
  295. #cont.activate(deck.actuators['a_reg_walk'])
  296. #without deck
  297. if own['throw_deck'] == True:
  298. own['requestAction'] = 'reg_walk_nb'
  299. #skater.playAction("reg_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=.5)
  300. else:
  301. own['requestAction'] = 'reg_walk'
  302. # skater.playAction("reg_nwalk", 0,35, layer=24, play_mode=1, speed=.5)
  303. # deck.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
  304. # trucks.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
  305. killact(25)
  306. killact(305)
  307. killact(306)
  308. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  309. #cont.activate(own.actuators['backward'])
  310. #cont.activate(skater.actuators['aWalk_fak'])
  311. #cont.activate(deck.actuators['a_fak_walk'])
  312. #cont.activate(trucks.actuators['a_fak_walk'])
  313. #without deck
  314. if own['throw_deck'] == True:
  315. own['requestAction'] = 'fak_walk_nb'
  316. #skater.playAction("fak_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=.5)
  317. else:
  318. own['requestAction'] = 'fak_walk'
  319. # skater.playAction("fak_nwalk", 0,35, layer=25, play_mode=1, speed=.5)
  320. # deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)
  321. # trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)
  322. elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  323. own.actuators["walkondirt"].volume = .2
  324. own.actuators["walkondirt"].pitch = 1.3
  325. cont.activate(own.actuators["walkondirt"])
  326. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  327. #cont.activate(own.actuators['forward2'])
  328. #cont.activate(skater.actuators['aWalk'])
  329. if own['throw_deck'] == True:
  330. own['requestAction'] = 'reg_walkFast_nb'
  331. skater.playAction("reg_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=1)
  332. else:
  333. own['requestAction'] = 'reg_walkFast'
  334. # skater.playAction("reg_nwalk", 0,35, layer=25, play_mode=1, speed=1)
  335. #
  336. # deck.playAction("a_reg_nwalk", 0,35, layer=305, play_mode=1, speed=1)
  337. # trucks.playAction("a_reg_nwalk", 0,35, layer=306, play_mode=1, speed=1)
  338. else:
  339. killact(25)
  340. killact(305)
  341. killact(306)
  342. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  343. #cont.activate(own.actuators['backward2'])
  344. #cont.activate(skater.actuators['aWalk_fak'])
  345. if own['throw_deck'] == True:
  346. own['requestAction'] = 'fak_walkFast_nb'
  347. skater.playAction("fak_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=1)
  348. else:
  349. own['requestAction'] = 'fak_walkFast'
  350. # skater.playAction("fak_nwalk", 0,35, layer=24, play_mode=1, speed=1)
  351. # deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)
  352. # trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)
  353. else:
  354. vel = own.getLinearVelocity(True)
  355. cont.deactivate(own.actuators["walkondirt"])
  356. if stance == 0:
  357. #cont.deactivate(own.actuators['forward'])
  358. #cont.deactivate(own.actuators['forward2'])
  359. cont.deactivate(skater.actuators['aWalk'])
  360. cont.deactivate(deck.actuators['a_reg_walk'])
  361. cont.deactivate(trucks.actuators['a_reg_walk'])
  362. killact(4)
  363. killact(5)
  364. killact(6)
  365. killact(7)
  366. killact(15)
  367. killact(16)
  368. killact(17)
  369. killact(18)
  370. killact(24)
  371. killact(25)
  372. killact(305)
  373. killact(306)
  374. # if own['walk_timer'] < 50:
  375. # velx = vel.x * .95
  376. # #own.setLinearVelocity([velx, 0, vel.z], True)
  377. #
  378. # else:
  379. # if r_ground.triggered:
  380. # own.setLinearVelocity([0, 0, vel.z], True)
  381. # #velz = vel.z
  382. # #print(velz)
  383. # #own.localLinearVelocity[0, 0, velz]
  384. if stance == 1:
  385. #cont.deactivate(own.actuators['backward'])
  386. #cont.deactivate(own.actuators['backward2'])
  387. cont.deactivate(skater.actuators['aWalk_fak'])
  388. cont.deactivate(deck.actuators['a_fak_walk'])
  389. cont.deactivate(trucks.actuators['a_fak_walk'])
  390. killact(4)
  391. killact(5)
  392. killact(6)
  393. killact(7)
  394. killact(15)
  395. killact(16)
  396. killact(17)
  397. killact(18)
  398. killact(24)
  399. killact(25)
  400. killact(305)
  401. killact(306)
  402. # if own['walk_timer'] < 50:
  403. # velx = vel.x * .95
  404. # #own.setLinearVelocity([velx, 0, vel.z], True)
  405. # else:
  406. # own.setLinearVelocity([0, 0, vel.z], True)
  407. #in air
  408. if lup == 1 and r_ground.positive == False:
  409. if stance == 0:
  410. cont.deactivate(own.actuators['forward'])
  411. cont.deactivate(own.actuators['forward2'])
  412. cont.deactivate(skater.actuators['aWalk'])
  413. killact(4)
  414. killact(5)
  415. killact(6)
  416. killact(7)
  417. velx = linvel.x - 1
  418. own.setLinearVelocity([-1.5, linvel.y, linvel.z], 1)
  419. #cont.activate(own.actuators['forward2'])
  420. if stance == 1:
  421. cont.deactivate(own.actuators['backward'])
  422. cont.deactivate(own.actuators['backward2'])
  423. cont.deactivate(skater.actuators['aWalk_fak'])
  424. killact(4)
  425. killact(5)
  426. killact(6)
  427. killact(7)
  428. velx = linvel.x + 1
  429. own.setLinearVelocity([1.5, linvel.y, linvel.z], 1)
  430. #cont.activate(own.actuators['backward2'])
  431. #---------------
  432. if rLR > .05:
  433. cont.activate(camobj.actuators['camRight'])
  434. else:
  435. cont.deactivate(camobj.actuators['camRight'])
  436. if rLR < -.05:
  437. cont.activate(camobj.actuators['camLeft'])
  438. else:
  439. cont.deactivate(camobj.actuators['camLeft'])
  440. if rUD > .05:
  441. cont.activate(camobj.actuators['camDown'])
  442. else:
  443. cont.deactivate(camobj.actuators['camDown'])
  444. if rUD < -.05:
  445. cont.activate(camobj.actuators['camUp'])
  446. else:
  447. cont.deactivate(camobj.actuators['camUp'])
  448. #----------------
  449. camera.height = .9 #-.4
  450. camera.min = 1.5
  451. camera.max = 2
  452. #camera.object = "Char4:Mhair01"
  453. #camera.damping = 0
  454. #camera.axis = 4
  455. lasty = own['lasty']
  456. #if yBut == False and lasty == True:
  457. # if own['walk'] == 1:
  458. # killact(fliplay)
  459. #killall()
  460. #camera.damping = 0
  461. #camera.axis = 4
  462. #print(stance)
  463. def onboard():
  464. # pass
  465. if own['walk'] == 0:
  466. print("start walking")
  467. if own['framenum'] > 100 and own['fall'] == False:
  468. #pass
  469. cont.activate(own.actuators['pop'])
  470. own['getoffboard'] = False
  471. #set_vibration(0, 0.0, 0.0)
  472. fliplay = 301
  473. fliplay2 = 302
  474. fliplay3 = 303
  475. try:
  476. vel = own['offboard_vel']
  477. #velx = vel.x *2
  478. vel = [velx, vel.y, vel.z]
  479. #vel = vel * 4
  480. #vel = [-100, 0, 0]
  481. #print(vel)
  482. #own.localLinearVelocity = vel
  483. #JUMPHEIGHT = 1100
  484. #force = [600, 0.0, 10]
  485. # use local axis
  486. #local = True
  487. # apply force
  488. #own.applyForce(force, local)
  489. except:
  490. pass
  491. if STANCE == 0:
  492. #killact(3)
  493. #killact(4)
  494. killall()
  495. skater.stopAction(fliplay)
  496. deck.stopAction(deckon)
  497. trucks.stopAction(truckon)
  498. # skater.playAction("nreg_offboard", 1,30, layer=fliplay, priority=0, play_mode=0, speed=1.5)
  499. # deck.playAction("a_reg_offboard", 1,30, layer=deckon, priority=0, play_mode=0, speed=1.5)
  500. # trucks.playAction("c_reg_offboard", 1,30, layer=truckon, priority=0, play_mode=0, speed=1.5)
  501. skater.playAction("reg_noffboard", 0,26, layer=fliplay, priority=0, play_mode=0, speed=.5)
  502. deck.playAction("a_reg_noffboard", 0,26, layer=deckon, priority=0, play_mode=0, speed=.5)
  503. trucks.playAction("a_reg_noffboard", 0,26, layer=truckon, priority=0, play_mode=0, speed=.5)
  504. if STANCE == 1:
  505. killact(3)
  506. killact(4)
  507. killall()
  508. skater.stopAction(fliplay)
  509. deck.stopAction(deckon)
  510. trucks.stopAction(truckon)
  511. skater.playAction("nfak_offboard", 1,30, layer=fliplay, priority=0, play_mode=0, speed=1.5)
  512. deck.playAction("a_fak_offboard", 1,30, layer=deckon, priority=0, play_mode=0, speed=1.5)
  513. trucks.playAction("a_fak_offboard", 1,30, layer=truckon, priority=0, play_mode=0, speed=1.5)
  514. def jump():
  515. if xBut == True:
  516. if own['lastx'] == 0:
  517. killact(3)
  518. killact(4)
  519. killact(5)
  520. killact(6)
  521. killact(7)
  522. #why does this layer have to be so high?
  523. if STANCE == 0:
  524. own['requestAction'] ='reg_jump'
  525. # skater.playAction("reg_jump", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
  526. # deck.playAction("a_reg_jump2", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
  527. # trucks.playAction("a_reg_jump2", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
  528. if STANCE == 1:
  529. own['requestAction'] ='fak_jump'
  530. #skater.playAction("fak_jump", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
  531. #deck.playAction("a_reg_jump", 1,30, layer=11, play_mode=0, speed=.5)
  532. #trucks.playAction("a_reg_jump", 1,30, layer=12, priority=0, play_mode=0, speed=1)
  533. JUMPHEIGHT = 1100
  534. force = [ 0.0, 0.0, JUMPHEIGHT]
  535. # use local axis
  536. local = False
  537. # apply force
  538. own.applyForce(force, local)
  539. own['lastx'] = 1
  540. else:
  541. own['lastx'] = 0
  542. def dropin():
  543. if dropinCol.positive == True:
  544. #print("DROPIN")
  545. pass
  546. def getonboard():
  547. getonboard = own['getonboard']
  548. fliplay2 = 50#8560
  549. if yBut == True:
  550. #camera.height = -.4
  551. #camera.min = 1.5
  552. #camera.max = 2 #2
  553. #camera.damping = .99
  554. #camera.axis = 0
  555. #cont.deactivate(cam.actuators['replayCam'])
  556. #cont.deactivate(cam.actuators['Camera'])
  557. #camera.height = 10 #-.5
  558. #print("high cam")
  559. #camera.min = .75
  560. #camera.max = 1.25
  561. #cont.activate(cam.actuators['Camera'])
  562. deckact = deck.actuators["Visibility"]
  563. trucksact = trucks.actuators["Visibility"]
  564. wheel1act = wheel1.actuators["Visibility"]
  565. wheel2act = wheel2.actuators["Visibility"]
  566. wheel3act = wheel3.actuators["Visibility"]
  567. wheel4act = wheel4.actuators["Visibility"]
  568. deckact.visibility = True
  569. trucksact.visibility = True
  570. wheel1act.visibility = True
  571. wheel2act.visibility = True
  572. wheel3act.visibility = True
  573. wheel4act.visibility = True
  574. cont.activate(deck.actuators['Visibility'])
  575. cont.activate(trucks.actuators['Visibility'])
  576. cont.activate(wheel1.actuators['Visibility'])
  577. cont.activate(wheel2.actuators['Visibility'])
  578. cont.activate(wheel3.actuators['Visibility'])
  579. cont.activate(wheel4.actuators['Visibility'])
  580. own['throw_deck'] = False
  581. throw_deck_empty = scene.objects["throw_deck_empty"]
  582. throw_deck_empty['kill_deck'] = 1
  583. fliplay3 = fliplay2 + 1
  584. if STANCE == 0 and dropinCol.positive == True:
  585. cont.deactivate(skater.actuators['aRest'])
  586. cont.deactivate(skater.actuators['aRest_fak'])
  587. killact(4)
  588. killact(5)
  589. killact(6)
  590. killact(7)
  591. skater.playAction("nreg_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  592. deck.playAction("a_reg_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  593. trucks.playAction("a_reg_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  594. if lasty == False:
  595. skater.playAction("nreg_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  596. deck.playAction("a_reg_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  597. trucks.playAction("a_reg_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  598. if STANCE == 1 and dropinCol.positive == True:
  599. cont.deactivate(skater.actuators['aRest'])
  600. cont.deactivate(skater.actuators['aRest_fak'])
  601. killact(4)
  602. killact(5)
  603. killact(6)
  604. killact(7)
  605. skater.playAction("nfak_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  606. deck.playAction("a_fak_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  607. trucks.playAction("a_fak_dropin", 50,60, layer=fliplay2, priority=0, play_mode=1, speed=.5)
  608. if lasty == False:
  609. skater.playAction("nfak_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  610. deck.playAction("a_fak_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  611. trucks.playAction("a_fak_dropin", 30,50, layer=fliplay3, priority=0, play_mode=0, speed=.75)
  612. if getonboard == 1:
  613. fliplay3 = 6000
  614. onboard_speed = .1
  615. # if STANCE == 1:
  616. # skater.playAction("nfak_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  617. # deck.playAction("a_fak_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  618. # trucks.playAction("a_fak_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  619. # if STANCE == 0:
  620. # skater.playAction("nreg_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  621. # deck.playAction("a_reg_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  622. # trucks.playAction("a_reg_dropin", 60,80, layer=fliplay3, priority=0, play_mode=0, speed=onboard_speed)
  623. own['getonboard'] = 0
  624. if yBut == False and lasty == True:
  625. own['getonboard'] = 1
  626. #camera.height = -.5
  627. #camera.min = .75
  628. #camera.max = 1.25
  629. def nextframe():
  630. framenumber = own["framenum"]
  631. framenumber = framenumber + 1
  632. if framenumber == 900000:
  633. framenumber = 0
  634. own["framenum"] = framenumber
  635. own['last_walk_frame'] = framenumber
  636. def checkidle():
  637. idle = cont.sensors["idle"]
  638. #print(idle.positive)
  639. idle_frame = own["walk_idle_frame"]
  640. if idle.positive:
  641. own["walk_idle_frame"] = 0
  642. cont.deactivate(camobj.actuators['idle_camRight'])
  643. camera.height = .5
  644. else:
  645. if idle_frame == 0:
  646. own["walk_idle_frame"] = own["framenum"]
  647. diff = own["framenum"] - idle_frame
  648. if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
  649. #print("you are idle", diff)
  650. cont.activate(camobj.actuators['idle_camRight'])
  651. camera.height = .9
  652. camera.min = 2
  653. camera.max = 2.50
  654. own['walk_idling'] = 1
  655. else:
  656. own['walk_idling'] = 0
  657. def idle_anim():
  658. if own['walk_idling'] == 1 and own['sit'] == 0:
  659. walk_idle_frame = own['walk_idle_frame']
  660. #print("walk_idling")
  661. mod_num = (own["framenum"] - walk_idle_frame) % 240
  662. #print(walk_idle_frame, mod_num)
  663. #killact(3)
  664. if mod_num == 0:
  665. if own['idle_skipper'] > 0:
  666. own['idle_skipper'] -= 1
  667. ran_num = random.randint(1, 8)
  668. #print(ran_num, "modding")
  669. if own['last_idle_num'] == ran_num:
  670. ran_num = 1
  671. if own['idle_skipper'] == 0:
  672. own['last_idle_num'] = ran_num
  673. if ran_num == 1 or ran_num > 7:
  674. killact(3)
  675. if STANCE == 0 and own['throw_deck'] == 0:
  676. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  677. deck.playAction("a_reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  678. trucks.playAction("a_reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  679. elif STANCE == 0 and own['throw_deck'] == 1:
  680. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  681. elif STANCE == 1 and own['throw_deck'] == 0:
  682. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  683. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  684. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  685. elif STANCE == 1 and own['throw_deck'] == 1:
  686. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  687. elif ran_num == 2:
  688. killact(3)
  689. if STANCE == 0 and own['throw_deck'] == 0:
  690. skater.playAction("reg_idle2_", 1,120, layer=3, play_mode=0, speed=.5)
  691. deck.playAction("a_reg_idle2", 1,120, layer=3, play_mode=0, speed=.5)
  692. trucks.playAction("a_reg_idle2", 1,120, layer=3, play_mode=0, speed=.5)
  693. elif STANCE == 0 and own['throw_deck'] == 1:
  694. skater.playAction("reg_idle2_nb", 1,120, layer=3, play_mode=0, speed=.5)
  695. elif STANCE == 1 and own['throw_deck'] == 0:
  696. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  697. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  698. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  699. elif STANCE == 1 and own['throw_deck'] == 1:
  700. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  701. elif ran_num == 3:
  702. killact(3)
  703. if STANCE == 0 and own['throw_deck'] == 0:
  704. skater.playAction("reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  705. deck.playAction("a_reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  706. trucks.playAction("a_reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  707. elif STANCE == 0 and own['throw_deck'] == 1:
  708. skater.playAction("reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  709. elif STANCE == 1 and own['throw_deck'] == 0:
  710. skater.playAction("fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  711. deck.playAction("a_fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  712. trucks.playAction("a_fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  713. elif STANCE == 1 and own['throw_deck'] == 1:
  714. skater.playAction("fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  715. own['idle_skipper'] = 2
  716. elif ran_num == 4:
  717. killact(3)
  718. if STANCE == 0 and own['throw_deck'] == 0:
  719. skater.playAction("reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  720. deck.playAction("a_reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  721. trucks.playAction("a_reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  722. elif STANCE == 0 and own['throw_deck'] == 1:
  723. skater.playAction("reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  724. elif STANCE == 1 and own['throw_deck'] == 0:
  725. skater.playAction("fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  726. deck.playAction("a_fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  727. trucks.playAction("a_fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  728. elif STANCE == 1 and own['throw_deck'] == 1:
  729. skater.playAction("fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  730. elif ran_num == 5:
  731. killact(3)
  732. if STANCE == 0 and own['throw_deck'] == 0:
  733. skater.playAction("reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  734. deck.playAction("a_reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  735. trucks.playAction("a_reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  736. elif STANCE == 0 and own['throw_deck'] == 1:
  737. skater.playAction("reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  738. elif STANCE == 1 and own['throw_deck'] == 0:
  739. skater.playAction("fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  740. deck.playAction("a_fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  741. trucks.playAction("a_fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  742. elif STANCE == 1 and own['throw_deck'] == 1:
  743. skater.playAction("fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  744. elif ran_num == 6:
  745. killact(3)
  746. if STANCE == 0 and own['throw_deck'] == 0:
  747. skater.playAction("reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  748. deck.playAction("a_reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  749. trucks.playAction("a_reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  750. elif STANCE == 0 and own['throw_deck'] == 1:
  751. skater.playAction("reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  752. elif STANCE == 1 and own['throw_deck'] == 0:
  753. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  754. deck.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  755. trucks.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  756. elif STANCE == 1 and own['throw_deck'] == 1:
  757. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  758. elif ran_num == 7:
  759. killact(3)
  760. if STANCE == 0 and own['throw_deck'] == 0:
  761. skater.playAction("reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  762. deck.playAction("a_reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  763. trucks.playAction("a_reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  764. elif STANCE == 0 and own['throw_deck'] == 1:
  765. skater.playAction("reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  766. elif STANCE == 1 and own['throw_deck'] == 0:
  767. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  768. deck.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  769. trucks.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  770. elif STANCE == 1 and own['throw_deck'] == 1:
  771. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  772. def reset_pos():
  773. #reset
  774. if ddPad == 1:
  775. spawn_pos = own['spawn_pos']
  776. spawn_rot = own['spawn_rot']
  777. #spawnz = spawn_pos[2] + .1
  778. try:
  779. own.worldPosition = (spawn_pos[0], spawn_pos[1], spawnz)
  780. 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]]
  781. except:
  782. own.worldPosition = (0, 0, .1)
  783. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  784. if own["spawn_stance"] == 1:
  785. own.setLinearVelocity([.1,0,0], 1)
  786. #cam.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .25))
  787. #lx = cam.localPosition[1]
  788. #lx = lx - 4
  789. #cam.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]]
  790. #cam.localPosition[1] = lx
  791. else:
  792. own.setLinearVelocity([-.1,0,0], 1)
  793. #cam.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .25))
  794. #lx = cam.localPosition[1]
  795. #lx = lx - 4
  796. #cam.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]]
  797. #cam.localPosition[1] = lx
  798. if udPad == 1:
  799. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  800. 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]]
  801. stance = own["stance"]
  802. own["spawn_stance"] = stance
  803. def falldeck():
  804. #print("falldeck")
  805. throw_deck_empty = scene.objects["throw_deck_empty"]
  806. deckact = deck.actuators["Visibility"]
  807. trucksact = trucks.actuators["Visibility"]
  808. wheel1act = wheel1.actuators["Visibility"]
  809. wheel2act = wheel2.actuators["Visibility"]
  810. wheel3act = wheel3.actuators["Visibility"]
  811. wheel4act = wheel4.actuators["Visibility"]
  812. if own['throw_deck'] == False:
  813. own['throw_deck'] = True
  814. deckact.visibility = False
  815. trucksact.visibility = False
  816. wheel1act.visibility = False
  817. wheel2act.visibility = False
  818. wheel3act.visibility = False
  819. wheel4act.visibility = False
  820. act = throw_deck_empty.actuators['throw_dec_act']
  821. if STANCE == True:
  822. #skater.playAction("fak_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  823. act.linearVelocity = [0.0, 1.0, 1.0]
  824. if STANCE == False:
  825. #skater.playAction("reg_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  826. act.linearVelocity = [0.0, 1.0, -1.0]
  827. cont.activate(act)
  828. else:
  829. own['throw_deck'] = False
  830. deckact.visibility = True
  831. trucksact.visibility = True
  832. wheel1act.visibility = True
  833. wheel2act.visibility = True
  834. wheel3act.visibility = True
  835. wheel4act.visibility = True
  836. throw_deck_empty['kill_deck'] = 1
  837. #print("trying to kill deck")
  838. cont.activate(deck.actuators['Visibility'])
  839. cont.activate(trucks.actuators['Visibility'])
  840. cont.activate(wheel1.actuators['Visibility'])
  841. cont.activate(wheel2.actuators['Visibility'])
  842. cont.activate(wheel3.actuators['Visibility'])
  843. cont.activate(wheel4.actuators['Visibility'])
  844. def throwdeck():
  845. throw_deck_empty = scene.objects["throw_deck_empty"]
  846. deckact = deck.actuators["Visibility"]
  847. trucksact = trucks.actuators["Visibility"]
  848. wheel1act = wheel1.actuators["Visibility"]
  849. wheel2act = wheel2.actuators["Visibility"]
  850. wheel3act = wheel3.actuators["Visibility"]
  851. wheel4act = wheel4.actuators["Visibility"]
  852. if own['throw_deck'] == False:
  853. own['throw_deck'] = True
  854. deckact.visibility = False
  855. trucksact.visibility = False
  856. wheel1act.visibility = False
  857. wheel2act.visibility = False
  858. wheel3act.visibility = False
  859. wheel4act.visibility = False
  860. act = throw_deck_empty.actuators['throw_dec_act']
  861. if STANCE == True:
  862. skater.playAction("fak_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  863. act.linearVelocity = [0.0, 5.0, 5.0]
  864. if STANCE == False:
  865. skater.playAction("reg_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  866. act.linearVelocity = [0.0, 5.0, -5.0]
  867. cont.activate(act)
  868. else:
  869. own['throw_deck'] = False
  870. deckact.visibility = True
  871. trucksact.visibility = True
  872. wheel1act.visibility = True
  873. wheel2act.visibility = True
  874. wheel3act.visibility = True
  875. wheel4act.visibility = True
  876. throw_deck_empty['kill_deck'] = 1
  877. #print("trying to kill deck")
  878. cont.activate(deck.actuators['Visibility'])
  879. cont.activate(trucks.actuators['Visibility'])
  880. cont.activate(wheel1.actuators['Visibility'])
  881. cont.activate(wheel2.actuators['Visibility'])
  882. cont.activate(wheel3.actuators['Visibility'])
  883. cont.activate(wheel4.actuators['Visibility'])
  884. def throwdeck_trigger():
  885. lastb = own['lastb']
  886. throw_deck_empty = scene.objects["throw_deck_empty"]
  887. if bBut == False:
  888. throw_deck_empty['kill_deck'] = 0
  889. if bBut == False and own['lastb'] == True:
  890. #print("throw deck")
  891. throwdeck()
  892. def fall():
  893. if own['fall'] == True:
  894. falldeck()
  895. if STANCE == 1:
  896. own.setLinearVelocity([3,2,0], True)
  897. else:
  898. own.setLinearVelocity([-3,-2,0], True)
  899. own['fall'] = False
  900. def sit():
  901. #turn off sit
  902. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  903. if own['sit'] == 1:
  904. killact(300)
  905. killact(299)
  906. own['sit'] = 0
  907. if aBut == False and lasta == True:
  908. #print(lasta)
  909. try:
  910. #print(r_ground.hitObject)
  911. if 'sit' in r_ground.hitObject:
  912. print("sit")
  913. own['sit'] = 1
  914. #killall()
  915. killact(3)
  916. if STANCE == 0:
  917. skater.playAction("reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  918. deck.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  919. trucks.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  920. elif STANCE == 1:
  921. skater.playAction("fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  922. deck.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  923. trucks.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  924. #if own['sit'] == 1 and last_sit == 0:
  925. except:
  926. #print("sit broke")
  927. pass
  928. if own['sit'] == 1:
  929. try:
  930. killact(3)
  931. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  932. if STANCE == 0:
  933. own.alignAxisToVect(-sit_vect, 0, .2)
  934. skater.playAction("reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  935. deck.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  936. trucks.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  937. elif STANCE == 1:
  938. own.alignAxisToVect(sit_vect, 0, .2)
  939. skater.playAction("fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  940. deck.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  941. trucks.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  942. except:
  943. pass
  944. def switchcam():
  945. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  946. if own['camera'] == 1:
  947. own['camera'] = 0
  948. else:
  949. own['camera'] = 1
  950. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  951. if own['camera'] == 2:
  952. own['camera'] = 0
  953. else:
  954. own['camera'] = 2
  955. #followcam
  956. def move_followcam():
  957. if own['camera'] == 2:
  958. #if rtsBut == False and own['lastrts'] == True:
  959. if own['lastbkBut'] == True and bkBut == False:
  960. print("activate move followcam")
  961. if own['move_followcam'] == False:
  962. own['move_followcam'] = True
  963. else:
  964. own['move_followcam'] = False
  965. if own['move_followcam'] == True:
  966. #act = followcam.actuators[
  967. camspeed1 = .015
  968. camspeed2 = .055
  969. camrot1 = .005
  970. camrot2 = .02
  971. #up
  972. if lUD < -0.080:
  973. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  974. cont.activate(followcam.actuators["up"])
  975. print("fastup")
  976. else:
  977. cont.deactivate(followcam.actuators["up"])
  978. # #down
  979. if lUD > .080:
  980. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  981. cont.activate(followcam.actuators["down"])
  982. else:
  983. cont.deactivate(followcam.actuators["down"])
  984. # #left
  985. if lLR < -0.080:
  986. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  987. cont.activate(followcam.actuators["left"])
  988. else:
  989. cont.deactivate(followcam.actuators["left"])
  990. # #right
  991. if lLR > 0.080:
  992. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  993. cont.activate(followcam.actuators["right"])
  994. else:
  995. cont.deactivate(followcam.actuators["right"])
  996. #up
  997. if rUD < -0.080:
  998. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  999. cont.activate(followcam.actuators["rotup"])
  1000. #print("uppppppppppppppppppppppppppp")
  1001. else:
  1002. cont.deactivate(followcam.actuators["rotup"])
  1003. # #down
  1004. if rUD > .080:
  1005. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  1006. cont.activate(followcam.actuators["rotdown"])
  1007. else:
  1008. cont.deactivate(followcam.actuators["rotdown"])
  1009. # #left
  1010. if rLR < -0.080:
  1011. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  1012. cont.activate(followcam.actuators["rotleft"])
  1013. else:
  1014. cont.deactivate(followcam.actuators["rotleft"])
  1015. # #right
  1016. if rLR > 0.080:
  1017. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  1018. cont.activate(followcam.actuators["rotright"])
  1019. else:
  1020. cont.deactivate(followcam.actuators["rotright"])
  1021. #*********************************************
  1022. if lUD > -0.080 and lUD < -0.030:
  1023. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  1024. cont.activate(followcam.actuators["up"])
  1025. #print(lUD)
  1026. else:
  1027. cont.deactivate(followcam.actuators["up"])
  1028. # #down
  1029. if lUD < .080 and lUD > .03:
  1030. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  1031. cont.activate(followcam.actuators["down"])
  1032. else:
  1033. cont.deactivate(followcam.actuators["down"])
  1034. # #left
  1035. if lLR > -0.080 and lLR < -0.030:
  1036. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  1037. cont.activate(followcam.actuators["left"])
  1038. else:
  1039. cont.deactivate(followcam.actuators["left"])
  1040. # #right
  1041. if lLR < .080 and lLR > .03:
  1042. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  1043. cont.activate(followcam.actuators["right"])
  1044. else:
  1045. cont.deactivate(followcam.actuators["right"])
  1046. #up
  1047. if rUD > -0.080 and rUD < -0.030:
  1048. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  1049. cont.activate(followcam.actuators["rotup"])
  1050. else:
  1051. cont.deactivate(followcam.actuators["rotup"])
  1052. # #down
  1053. if rUD < .080 and rUD > .03:
  1054. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  1055. cont.activate(followcam.actuators["rotdown"])
  1056. else:
  1057. cont.deactivate(followcam.actuators["rotdown"])
  1058. # #left
  1059. if rLR > -0.080 and rLR < -0.030:
  1060. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1061. cont.activate(followcam.actuators["rotleft"])
  1062. else:
  1063. cont.deactivate(followcam.actuators["rotleft"])
  1064. # #right
  1065. if rLR < .080 and rLR > .03:
  1066. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1067. cont.activate(followcam.actuators["rotright"])
  1068. else:
  1069. cont.deactivate(followcam.actuators["rotright"])
  1070. def move_flycam():
  1071. if own['camera'] == 1:
  1072. #if rtsBut == False and own['lastrts'] == True:
  1073. if own['lastbkBut'] == True and bkBut == False:
  1074. if own['move_freecam'] == False:
  1075. own['move_freecam'] = True
  1076. else:
  1077. own['move_freecam'] = False
  1078. if own['move_freecam'] == True:
  1079. #act = freecam.actuators[
  1080. camspeed1 = .015
  1081. camspeed2 = .055
  1082. camrot1 = .005
  1083. camrot2 = .02
  1084. #up
  1085. if lUD < -0.080:
  1086. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  1087. cont.activate(freecam.actuators["up"])
  1088. #print("fastup")
  1089. else:
  1090. cont.deactivate(freecam.actuators["up"])
  1091. # #down
  1092. if lUD > .080:
  1093. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  1094. cont.activate(freecam.actuators["down"])
  1095. else:
  1096. cont.deactivate(freecam.actuators["down"])
  1097. # #left
  1098. if lLR < -0.080:
  1099. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  1100. cont.activate(freecam.actuators["left"])
  1101. else:
  1102. cont.deactivate(freecam.actuators["left"])
  1103. # #right
  1104. if lLR > 0.080:
  1105. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  1106. cont.activate(freecam.actuators["right"])
  1107. else:
  1108. cont.deactivate(freecam.actuators["right"])
  1109. #up
  1110. if rUD < -0.080:
  1111. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  1112. cont.activate(freecam.actuators["rotup"])
  1113. else:
  1114. cont.deactivate(freecam.actuators["rotup"])
  1115. # #down
  1116. if rUD > .080:
  1117. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  1118. cont.activate(freecam.actuators["rotdown"])
  1119. else:
  1120. cont.deactivate(freecam.actuators["rotdown"])
  1121. # #left
  1122. if rLR < -0.080:
  1123. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  1124. cont.activate(freecam.actuators["rotleft"])
  1125. else:
  1126. cont.deactivate(freecam.actuators["rotleft"])
  1127. # #right
  1128. if rLR > 0.080:
  1129. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  1130. cont.activate(freecam.actuators["rotright"])
  1131. else:
  1132. cont.deactivate(freecam.actuators["rotright"])
  1133. #*********************************************
  1134. if lUD > -0.080 and lUD < -0.030:
  1135. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  1136. cont.activate(freecam.actuators["up"])
  1137. #print(lUD)
  1138. else:
  1139. cont.deactivate(freecam.actuators["up"])
  1140. # #down
  1141. if lUD < .080 and lUD > .03:
  1142. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  1143. cont.activate(freecam.actuators["down"])
  1144. else:
  1145. cont.deactivate(freecam.actuators["down"])
  1146. # #left
  1147. if lLR > -0.080 and lLR < -0.030:
  1148. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  1149. cont.activate(freecam.actuators["left"])
  1150. else:
  1151. cont.deactivate(freecam.actuators["left"])
  1152. # #right
  1153. if lLR < .080 and lLR > .03:
  1154. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  1155. cont.activate(freecam.actuators["right"])
  1156. else:
  1157. cont.deactivate(freecam.actuators["right"])
  1158. #up
  1159. if rUD > -0.080 and rUD < -0.030:
  1160. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  1161. cont.activate(freecam.actuators["rotup"])
  1162. else:
  1163. cont.deactivate(freecam.actuators["rotup"])
  1164. # #down
  1165. if rUD < .080 and rUD > .03:
  1166. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  1167. cont.activate(freecam.actuators["rotdown"])
  1168. else:
  1169. cont.deactivate(freecam.actuators["rotdown"])
  1170. # #left
  1171. if rLR > -0.080 and rLR < -0.030:
  1172. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1173. cont.activate(freecam.actuators["rotleft"])
  1174. else:
  1175. cont.deactivate(freecam.actuators["rotleft"])
  1176. # #right
  1177. if rLR < .080 and rLR > .03:
  1178. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1179. cont.activate(freecam.actuators["rotright"])
  1180. else:
  1181. cont.deactivate(freecam.actuators["rotright"])
  1182. if r_ground.triggered == False:
  1183. cont.deactivate(own.actuators["walk_align"])
  1184. else:
  1185. cont.activate(own.actuators["walk_align"])
  1186. if r_ground.triggered:
  1187. #print("on stair")
  1188. try:
  1189. if 'stair' in r_ground.hitObject:
  1190. own['stair_counter'] = 20
  1191. force = [ 0.0, 0.0, -100]
  1192. # use local axis
  1193. local = True
  1194. # apply force
  1195. #own.applyForce(force, local)
  1196. except:
  1197. pass
  1198. if own['stair_counter'] > 0:
  1199. own['stair_counter'] -= 1
  1200. if yBut == True:
  1201. own['walk_idling'] = 0
  1202. own["walk_idle_frame"] = 0
  1203. onboard()
  1204. jump()
  1205. dropin()
  1206. throwdeck_trigger()
  1207. nextframe()
  1208. checkidle()
  1209. getonboard()
  1210. reset_pos()
  1211. switchcam()
  1212. move_flycam()
  1213. move_followcam()
  1214. fall()
  1215. idle_anim()
  1216. sit()
  1217. #cont.activate(cam.actuators['Camera'])
  1218. #printplaying()
  1219. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1220. own.actuators["sroll"].stopSound()
  1221. wheel1 = scene.objects["rollen.000"]
  1222. wheel2 = scene.objects["rollen.001"]
  1223. wheel3 = scene.objects["rollen.002"]
  1224. wheel4 = scene.objects["rollen.003"]
  1225. wheel1.stopAction(2)
  1226. wheel2.stopAction(2)
  1227. wheel3.stopAction(2)
  1228. wheel4.stopAction(2)
  1229. own['lasty'] = yBut
  1230. own['lastb'] = bBut
  1231. own['lasta'] = aBut
  1232. own['lastx'] = xBut
  1233. own['lastlts'] = ltsBut
  1234. own['lastrts'] = rtsBut
  1235. own['lastbkBut'] = bkBut
  1236. own['dropinCol'] = dropinCol
  1237. own['walk'] = 1