Shuvit game release repo.
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

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