Shuvit game release repo.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

walk.py 54KB

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