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 53KB

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