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

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