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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  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. #cont.activate(skater.actuators['aRest'])
  212. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  213. deck.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  214. trucks.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  215. 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:
  216. own['requestAction'] = 'fak_idle'
  217. if own['throw_deck'] == True:
  218. own['requestAction'] = 'fak_idle_nb'
  219. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  220. else:
  221. #cont.activate(skater.actuators['aRest'])
  222. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  223. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  224. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
  225. if lUD < -sens:
  226. lup = 1
  227. else:
  228. lup = 0
  229. if lUD > sens:
  230. ldown = 1
  231. else:
  232. ldown = 0
  233. #walking
  234. #new walking
  235. #if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  236. vel = own.getLinearVelocity(True)
  237. if own['walk_timer'] < 50:
  238. velx = vel.x * .95
  239. own.setLinearVelocity([velx, 0, vel.z], True)
  240. else:
  241. own.setLinearVelocity([0, 0, vel.z], True)
  242. #print("set 0 vel")
  243. if (lup == 1 and aBut == 0 and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  244. own['walking'] = "regular"
  245. walking = "regular"
  246. elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  247. own['walking'] = "fast"
  248. walking = "fast"
  249. else:
  250. own['walking'] = None
  251. walking = None
  252. #print(own['walk_timer'])
  253. if walking == "regular":
  254. cont.deactivate(own.actuators['forward2'])
  255. cont.deactivate(own.actuators['backward2'])
  256. if stance == 0:
  257. cont.activate(own.actuators['forward'])
  258. else:
  259. cont.activate(own.actuators['backward'])
  260. if walking == "fast":
  261. cont.deactivate(own.actuators['forward'])
  262. cont.deactivate(own.actuators['backward'])
  263. if stance == 0:
  264. cont.activate(own.actuators['forward2'])
  265. else:
  266. cont.activate(own.actuators['backward2'])
  267. if walking == None:
  268. cont.deactivate(own.actuators['forward2'])
  269. cont.deactivate(own.actuators['backward2'])
  270. cont.deactivate(own.actuators['forward'])
  271. cont.deactivate(own.actuators['backward'])
  272. if own['walk_timer'] < 50:
  273. velx = vel.x * .95
  274. own.setLinearVelocity([velx, 0, vel.z], True)
  275. else:
  276. own.setLinearVelocity([0, 0, vel.z], True)
  277. #print("set 0 vel")
  278. #old walking
  279. if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
  280. own.actuators["walkondirt"].volume = .2
  281. own.actuators["walkondirt"].pitch = 1
  282. cont.activate(own.actuators["walkondirt"])
  283. if lasta == 1:
  284. #cont.deactivate(own.actuators['forward2'])
  285. #cont.deactivate(own.actuators['backward2'])
  286. killact(6)
  287. killact(7)
  288. killact(8)
  289. killact(9)
  290. killact(17)
  291. killact(18)
  292. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  293. #cont.activate(own.actuators['forward'])
  294. #cont.activate(skater.actuators['aWalk'])
  295. #cont.activate(deck.actuators['a_reg_walk'])
  296. #cont.activate(deck.actuators['a_reg_walk'])
  297. #without deck
  298. if own['throw_deck'] == True:
  299. own['requestAction'] = 'reg_walk_nb'
  300. #skater.playAction("reg_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=.5)
  301. else:
  302. own['requestAction'] = 'reg_walk'
  303. # skater.playAction("reg_nwalk", 0,35, layer=24, play_mode=1, speed=.5)
  304. # deck.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
  305. # trucks.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
  306. killact(25)
  307. killact(305)
  308. killact(306)
  309. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  310. #cont.activate(own.actuators['backward'])
  311. #cont.activate(skater.actuators['aWalk_fak'])
  312. #cont.activate(deck.actuators['a_fak_walk'])
  313. #cont.activate(trucks.actuators['a_fak_walk'])
  314. #without deck
  315. if own['throw_deck'] == True:
  316. own['requestAction'] = 'fak_walk_nb'
  317. #skater.playAction("fak_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=.5)
  318. else:
  319. own['requestAction'] = 'fak_walk'
  320. # skater.playAction("fak_nwalk", 0,35, layer=25, play_mode=1, speed=.5)
  321. # deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)
  322. # trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)
  323. elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  324. own.actuators["walkondirt"].volume = .2
  325. own.actuators["walkondirt"].pitch = 1.3
  326. cont.activate(own.actuators["walkondirt"])
  327. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  328. #cont.activate(own.actuators['forward2'])
  329. #cont.activate(skater.actuators['aWalk'])
  330. if own['throw_deck'] == True:
  331. own['requestAction'] = 'reg_walkFast_nb'
  332. skater.playAction("reg_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=1)
  333. else:
  334. own['requestAction'] = 'reg_walkFast'
  335. # skater.playAction("reg_nwalk", 0,35, layer=25, play_mode=1, speed=1)
  336. #
  337. # deck.playAction("a_reg_nwalk", 0,35, layer=305, play_mode=1, speed=1)
  338. # trucks.playAction("a_reg_nwalk", 0,35, layer=306, play_mode=1, speed=1)
  339. else:
  340. killact(25)
  341. killact(305)
  342. killact(306)
  343. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  344. #cont.activate(own.actuators['backward2'])
  345. #cont.activate(skater.actuators['aWalk_fak'])
  346. if own['throw_deck'] == True:
  347. own['requestAction'] = 'fak_walkFast_nb'
  348. skater.playAction("fak_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=1)
  349. else:
  350. own['requestAction'] = 'fak_walkFast'
  351. # skater.playAction("fak_nwalk", 0,35, layer=24, play_mode=1, speed=1)
  352. # deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)
  353. # trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)
  354. else:
  355. vel = own.getLinearVelocity(True)
  356. cont.deactivate(own.actuators["walkondirt"])
  357. if stance == 0:
  358. #cont.deactivate(own.actuators['forward'])
  359. #cont.deactivate(own.actuators['forward2'])
  360. cont.deactivate(skater.actuators['aWalk'])
  361. cont.deactivate(deck.actuators['a_reg_walk'])
  362. cont.deactivate(trucks.actuators['a_reg_walk'])
  363. killact(4)
  364. killact(5)
  365. killact(6)
  366. killact(7)
  367. killact(15)
  368. killact(16)
  369. killact(17)
  370. killact(18)
  371. killact(24)
  372. killact(25)
  373. killact(305)
  374. killact(306)
  375. # if own['walk_timer'] < 50:
  376. # velx = vel.x * .95
  377. # #own.setLinearVelocity([velx, 0, vel.z], True)
  378. #
  379. # else:
  380. # if r_ground.triggered:
  381. # own.setLinearVelocity([0, 0, vel.z], True)
  382. # #velz = vel.z
  383. # #print(velz)
  384. # #own.localLinearVelocity[0, 0, velz]
  385. if stance == 1:
  386. #cont.deactivate(own.actuators['backward'])
  387. #cont.deactivate(own.actuators['backward2'])
  388. cont.deactivate(skater.actuators['aWalk_fak'])
  389. cont.deactivate(deck.actuators['a_fak_walk'])
  390. cont.deactivate(trucks.actuators['a_fak_walk'])
  391. killact(4)
  392. killact(5)
  393. killact(6)
  394. killact(7)
  395. killact(15)
  396. killact(16)
  397. killact(17)
  398. killact(18)
  399. killact(24)
  400. killact(25)
  401. killact(305)
  402. killact(306)
  403. # if own['walk_timer'] < 50:
  404. # velx = vel.x * .95
  405. # #own.setLinearVelocity([velx, 0, vel.z], True)
  406. # else:
  407. # own.setLinearVelocity([0, 0, vel.z], True)
  408. #in air
  409. if lup == 1 and r_ground.positive == False:
  410. if stance == 0:
  411. cont.deactivate(own.actuators['forward'])
  412. cont.deactivate(own.actuators['forward2'])
  413. cont.deactivate(skater.actuators['aWalk'])
  414. killact(4)
  415. killact(5)
  416. killact(6)
  417. killact(7)
  418. velx = linvel.x - 1
  419. own.setLinearVelocity([-1.5, linvel.y, linvel.z], 1)
  420. #cont.activate(own.actuators['forward2'])
  421. if stance == 1:
  422. cont.deactivate(own.actuators['backward'])
  423. cont.deactivate(own.actuators['backward2'])
  424. cont.deactivate(skater.actuators['aWalk_fak'])
  425. killact(4)
  426. killact(5)
  427. killact(6)
  428. killact(7)
  429. velx = linvel.x + 1
  430. own.setLinearVelocity([1.5, linvel.y, linvel.z], 1)
  431. #cont.activate(own.actuators['backward2'])
  432. #---------------
  433. if rLR > .05:
  434. cont.activate(camobj.actuators['camRight'])
  435. else:
  436. cont.deactivate(camobj.actuators['camRight'])
  437. if rLR < -.05:
  438. cont.activate(camobj.actuators['camLeft'])
  439. else:
  440. cont.deactivate(camobj.actuators['camLeft'])
  441. if rUD > .05:
  442. cont.activate(camobj.actuators['camDown'])
  443. else:
  444. cont.deactivate(camobj.actuators['camDown'])
  445. if rUD < -.05:
  446. cont.activate(camobj.actuators['camUp'])
  447. else:
  448. cont.deactivate(camobj.actuators['camUp'])
  449. #----------------
  450. camera.height = .9 #-.4
  451. camera.min = 1.5
  452. camera.max = 2
  453. #camera.object = "Char4:Mhair01"
  454. #camera.damping = 0
  455. #camera.axis = 4
  456. lasty = own['lasty']
  457. #if yBut == False and lasty == True:
  458. # if own['walk'] == 1:
  459. # killact(fliplay)
  460. #killall()
  461. #camera.damping = 0
  462. #camera.axis = 4
  463. #print(stance)
  464. def onboard():
  465. # pass
  466. if own['walk'] == 0:
  467. print("start walking")
  468. if own['framenum'] > 100 and own['fall'] == False:
  469. #pass
  470. cont.activate(own.actuators['pop'])
  471. own['getoffboard'] = False
  472. #set_vibration(0, 0.0, 0.0)
  473. fliplay = 301
  474. fliplay2 = 302
  475. fliplay3 = 303
  476. try:
  477. vel = own['offboard_vel']
  478. #velx = vel.x *2
  479. vel = [velx, vel.y, vel.z]
  480. #vel = vel * 4
  481. #vel = [-100, 0, 0]
  482. #print(vel)
  483. #own.localLinearVelocity = vel
  484. #JUMPHEIGHT = 1100
  485. #force = [600, 0.0, 10]
  486. # use local axis
  487. #local = True
  488. # apply force
  489. #own.applyForce(force, local)
  490. except:
  491. pass
  492. if STANCE == 0:
  493. #killact(3)
  494. #killact(4)
  495. killall()
  496. skater.stopAction(fliplay)
  497. deck.stopAction(deckon)
  498. trucks.stopAction(truckon)
  499. # skater.playAction("nreg_offboard", 1,30, layer=fliplay, priority=0, play_mode=0, speed=1.5)
  500. # deck.playAction("a_reg_offboard", 1,30, layer=deckon, priority=0, play_mode=0, speed=1.5)
  501. # trucks.playAction("c_reg_offboard", 1,30, layer=truckon, priority=0, play_mode=0, speed=1.5)
  502. skater.playAction("reg_noffboard", 0,26, layer=fliplay, priority=0, play_mode=0, speed=.5)
  503. deck.playAction("a_reg_noffboard", 0,26, layer=deckon, priority=0, play_mode=0, speed=.5)
  504. trucks.playAction("a_reg_noffboard", 0,26, layer=truckon, priority=0, play_mode=0, speed=.5)
  505. if STANCE == 1:
  506. killact(3)
  507. killact(4)
  508. killall()
  509. skater.stopAction(fliplay)
  510. deck.stopAction(deckon)
  511. trucks.stopAction(truckon)
  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. if mod_num == 0:
  677. if own['idle_skipper'] > 0:
  678. own['idle_skipper'] -= 1
  679. ran_num = random.randint(1, 8)
  680. #print(ran_num, "modding")
  681. if own['last_idle_num'] == ran_num:
  682. ran_num = 1
  683. if own['idle_skipper'] == 0:
  684. own['last_idle_num'] = ran_num
  685. if ran_num == 1 or ran_num > 7:
  686. killact(3)
  687. if STANCE == 0 and own['throw_deck'] == 0:
  688. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  689. deck.playAction("a_reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  690. trucks.playAction("a_reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  691. elif STANCE == 0 and own['throw_deck'] == 1:
  692. skater.playAction("reg_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  693. elif STANCE == 1 and own['throw_deck'] == 0:
  694. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  695. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  696. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  697. elif STANCE == 1 and own['throw_deck'] == 1:
  698. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  699. elif ran_num == 2:
  700. killact(3)
  701. if STANCE == 0 and own['throw_deck'] == 0:
  702. skater.playAction("reg_idle2_", 1,120, layer=3, play_mode=0, speed=.5)
  703. deck.playAction("a_reg_idle2", 1,120, layer=3, play_mode=0, speed=.5)
  704. trucks.playAction("a_reg_idle2", 1,120, layer=3, play_mode=0, speed=.5)
  705. elif STANCE == 0 and own['throw_deck'] == 1:
  706. skater.playAction("reg_idle2_nb", 1,120, layer=3, play_mode=0, speed=.5)
  707. elif STANCE == 1 and own['throw_deck'] == 0:
  708. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  709. deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  710. trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  711. elif STANCE == 1 and own['throw_deck'] == 1:
  712. skater.playAction("fak_idle1", 1,120, layer=3, play_mode=0, speed=.5)
  713. elif ran_num == 3:
  714. killact(3)
  715. if STANCE == 0 and own['throw_deck'] == 0:
  716. skater.playAction("reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  717. deck.playAction("a_reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  718. trucks.playAction("a_reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  719. elif STANCE == 0 and own['throw_deck'] == 1:
  720. skater.playAction("reg_idle3", 1,240, layer=3, play_mode=0, speed=.5)
  721. elif STANCE == 1 and own['throw_deck'] == 0:
  722. skater.playAction("fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  723. deck.playAction("a_fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  724. trucks.playAction("a_fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  725. elif STANCE == 1 and own['throw_deck'] == 1:
  726. skater.playAction("fak_idle1", 1,240, layer=3, play_mode=0, speed=.5)
  727. own['idle_skipper'] = 2
  728. elif ran_num == 4:
  729. killact(3)
  730. if STANCE == 0 and own['throw_deck'] == 0:
  731. skater.playAction("reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  732. deck.playAction("a_reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  733. trucks.playAction("a_reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  734. elif STANCE == 0 and own['throw_deck'] == 1:
  735. skater.playAction("reg_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  736. elif STANCE == 1 and own['throw_deck'] == 0:
  737. skater.playAction("fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  738. deck.playAction("a_fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  739. trucks.playAction("a_fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  740. elif STANCE == 1 and own['throw_deck'] == 1:
  741. skater.playAction("fak_idle4", 1,120, layer=3, play_mode=0, speed=.5)
  742. elif ran_num == 5:
  743. killact(3)
  744. if STANCE == 0 and own['throw_deck'] == 0:
  745. skater.playAction("reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  746. deck.playAction("a_reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  747. trucks.playAction("a_reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  748. elif STANCE == 0 and own['throw_deck'] == 1:
  749. skater.playAction("reg_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  750. elif STANCE == 1 and own['throw_deck'] == 0:
  751. skater.playAction("fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  752. deck.playAction("a_fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  753. trucks.playAction("a_fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  754. elif STANCE == 1 and own['throw_deck'] == 1:
  755. skater.playAction("fak_idle5", 1,120, layer=3, play_mode=0, speed=.5)
  756. elif ran_num == 6:
  757. killact(3)
  758. if STANCE == 0 and own['throw_deck'] == 0:
  759. skater.playAction("reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  760. deck.playAction("a_reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  761. trucks.playAction("a_reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  762. elif STANCE == 0 and own['throw_deck'] == 1:
  763. skater.playAction("reg_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  764. elif STANCE == 1 and own['throw_deck'] == 0:
  765. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  766. deck.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  767. trucks.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  768. elif STANCE == 1 and own['throw_deck'] == 1:
  769. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  770. elif ran_num == 7:
  771. killact(3)
  772. if STANCE == 0 and own['throw_deck'] == 0:
  773. skater.playAction("reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  774. deck.playAction("a_reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  775. trucks.playAction("a_reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  776. elif STANCE == 0 and own['throw_deck'] == 1:
  777. skater.playAction("reg_idle7", 1,120, layer=3, play_mode=0, speed=.5)
  778. elif STANCE == 1 and own['throw_deck'] == 0:
  779. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  780. deck.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  781. trucks.playAction("a_fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  782. elif STANCE == 1 and own['throw_deck'] == 1:
  783. skater.playAction("fak_idle6", 1,120, layer=3, play_mode=0, speed=.5)
  784. def reset_pos():
  785. #reset
  786. if ddPad == 1:
  787. spawn_pos = own['spawn_pos']
  788. spawn_rot = own['spawn_rot']
  789. #spawnz = spawn_pos[2] + .1
  790. try:
  791. own.worldPosition = (spawn_pos[0], spawn_pos[1], spawnz)
  792. 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]]
  793. except:
  794. own.worldPosition = (0, 0, .1)
  795. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  796. if own["spawn_stance"] == 1:
  797. own.setLinearVelocity([.1,0,0], 1)
  798. #cam.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .25))
  799. #lx = cam.localPosition[1]
  800. #lx = lx - 4
  801. #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]]
  802. #cam.localPosition[1] = lx
  803. else:
  804. own.setLinearVelocity([-.1,0,0], 1)
  805. #cam.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .25))
  806. #lx = cam.localPosition[1]
  807. #lx = lx - 4
  808. #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]]
  809. #cam.localPosition[1] = lx
  810. if udPad == 1:
  811. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  812. 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]]
  813. stance = own["stance"]
  814. own["spawn_stance"] = stance
  815. def falldeck():
  816. #print("falldeck")
  817. throw_deck_empty = scene.objects["throw_deck_empty"]
  818. deckact = deck.actuators["Visibility"]
  819. trucksact = trucks.actuators["Visibility"]
  820. wheel1act = wheel1.actuators["Visibility"]
  821. wheel2act = wheel2.actuators["Visibility"]
  822. wheel3act = wheel3.actuators["Visibility"]
  823. wheel4act = wheel4.actuators["Visibility"]
  824. if own['throw_deck'] == False:
  825. own['throw_deck'] = True
  826. deckact.visibility = False
  827. trucksact.visibility = False
  828. wheel1act.visibility = False
  829. wheel2act.visibility = False
  830. wheel3act.visibility = False
  831. wheel4act.visibility = False
  832. act = throw_deck_empty.actuators['throw_dec_act']
  833. if STANCE == True:
  834. #skater.playAction("fak_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  835. act.linearVelocity = [0.0, 1.0, 1.0]
  836. if STANCE == False:
  837. #skater.playAction("reg_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  838. act.linearVelocity = [0.0, 1.0, -1.0]
  839. cont.activate(act)
  840. else:
  841. own['throw_deck'] = False
  842. deckact.visibility = True
  843. trucksact.visibility = True
  844. wheel1act.visibility = True
  845. wheel2act.visibility = True
  846. wheel3act.visibility = True
  847. wheel4act.visibility = True
  848. throw_deck_empty['kill_deck'] = 1
  849. #print("trying to kill deck")
  850. cont.activate(deck.actuators['Visibility'])
  851. cont.activate(trucks.actuators['Visibility'])
  852. cont.activate(wheel1.actuators['Visibility'])
  853. cont.activate(wheel2.actuators['Visibility'])
  854. cont.activate(wheel3.actuators['Visibility'])
  855. cont.activate(wheel4.actuators['Visibility'])
  856. def throwdeck():
  857. throw_deck_empty = scene.objects["throw_deck_empty"]
  858. deckact = deck.actuators["Visibility"]
  859. trucksact = trucks.actuators["Visibility"]
  860. wheel1act = wheel1.actuators["Visibility"]
  861. wheel2act = wheel2.actuators["Visibility"]
  862. wheel3act = wheel3.actuators["Visibility"]
  863. wheel4act = wheel4.actuators["Visibility"]
  864. if own['throw_deck'] == False:
  865. own['throw_deck'] = True
  866. deckact.visibility = False
  867. trucksact.visibility = False
  868. wheel1act.visibility = False
  869. wheel2act.visibility = False
  870. wheel3act.visibility = False
  871. wheel4act.visibility = False
  872. act = throw_deck_empty.actuators['throw_dec_act']
  873. if STANCE == True:
  874. skater.playAction("fak_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  875. act.linearVelocity = [0.0, 5.0, 5.0]
  876. if STANCE == False:
  877. skater.playAction("reg_throw", 10,30, layer=29, priority=0, play_mode=0, speed=.5)
  878. act.linearVelocity = [0.0, 5.0, -5.0]
  879. cont.activate(act)
  880. else:
  881. own['throw_deck'] = False
  882. deckact.visibility = True
  883. trucksact.visibility = True
  884. wheel1act.visibility = True
  885. wheel2act.visibility = True
  886. wheel3act.visibility = True
  887. wheel4act.visibility = True
  888. throw_deck_empty['kill_deck'] = 1
  889. #print("trying to kill deck")
  890. cont.activate(deck.actuators['Visibility'])
  891. cont.activate(trucks.actuators['Visibility'])
  892. cont.activate(wheel1.actuators['Visibility'])
  893. cont.activate(wheel2.actuators['Visibility'])
  894. cont.activate(wheel3.actuators['Visibility'])
  895. cont.activate(wheel4.actuators['Visibility'])
  896. def throwdeck_trigger():
  897. lastb = own['lastb']
  898. throw_deck_empty = scene.objects["throw_deck_empty"]
  899. if bBut == False:
  900. throw_deck_empty['kill_deck'] = 0
  901. if bBut == False and own['lastb'] == True:
  902. #print("throw deck")
  903. throwdeck()
  904. def fall():
  905. if own['fall'] == True:
  906. falldeck()
  907. if STANCE == 1:
  908. own.setLinearVelocity([3,2,0], True)
  909. else:
  910. own.setLinearVelocity([-3,-2,0], True)
  911. own['fall'] = False
  912. def sit():
  913. #turn off sit
  914. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  915. if own['sit'] == 1:
  916. killact(300)
  917. killact(299)
  918. own['sit'] = 0
  919. if aBut == False and lasta == True:
  920. #print(lasta)
  921. try:
  922. #print(r_ground.hitObject)
  923. if 'sit' in r_ground.hitObject:
  924. print("sit")
  925. own['sit'] = 1
  926. #killall()
  927. killact(3)
  928. if STANCE == 0:
  929. skater.playAction("reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  930. deck.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  931. trucks.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  932. elif STANCE == 1:
  933. skater.playAction("fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  934. deck.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  935. trucks.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  936. #if own['sit'] == 1 and last_sit == 0:
  937. except:
  938. #print("sit broke")
  939. pass
  940. if own['sit'] == 1:
  941. try:
  942. killact(3)
  943. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  944. if STANCE == 0:
  945. own.alignAxisToVect(-sit_vect, 0, .2)
  946. skater.playAction("reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  947. deck.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  948. trucks.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  949. elif STANCE == 1:
  950. own.alignAxisToVect(sit_vect, 0, .2)
  951. skater.playAction("fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  952. deck.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  953. trucks.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  954. except:
  955. pass
  956. def switchcam():
  957. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  958. if own['camera'] == 1:
  959. own['camera'] = 0
  960. else:
  961. own['camera'] = 1
  962. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  963. if own['camera'] == 2:
  964. own['camera'] = 0
  965. else:
  966. own['camera'] = 2
  967. #followcam
  968. def move_followcam():
  969. if own['camera'] == 2:
  970. #if rtsBut == False and own['lastrts'] == True:
  971. if own['lastbkBut'] == True and bkBut == False:
  972. print("activate move followcam")
  973. if own['move_followcam'] == False:
  974. own['move_followcam'] = True
  975. else:
  976. own['move_followcam'] = False
  977. if own['move_followcam'] == True:
  978. #act = followcam.actuators[
  979. camspeed1 = .015
  980. camspeed2 = .055
  981. camrot1 = .005
  982. camrot2 = .02
  983. #up
  984. if lUD < -0.080:
  985. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  986. cont.activate(followcam.actuators["up"])
  987. print("fastup")
  988. else:
  989. cont.deactivate(followcam.actuators["up"])
  990. # #down
  991. if lUD > .080:
  992. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  993. cont.activate(followcam.actuators["down"])
  994. else:
  995. cont.deactivate(followcam.actuators["down"])
  996. # #left
  997. if lLR < -0.080:
  998. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  999. cont.activate(followcam.actuators["left"])
  1000. else:
  1001. cont.deactivate(followcam.actuators["left"])
  1002. # #right
  1003. if lLR > 0.080:
  1004. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  1005. cont.activate(followcam.actuators["right"])
  1006. else:
  1007. cont.deactivate(followcam.actuators["right"])
  1008. #up
  1009. if rUD < -0.080:
  1010. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  1011. cont.activate(followcam.actuators["rotup"])
  1012. #print("uppppppppppppppppppppppppppp")
  1013. else:
  1014. cont.deactivate(followcam.actuators["rotup"])
  1015. # #down
  1016. if rUD > .080:
  1017. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  1018. cont.activate(followcam.actuators["rotdown"])
  1019. else:
  1020. cont.deactivate(followcam.actuators["rotdown"])
  1021. # #left
  1022. if rLR < -0.080:
  1023. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  1024. cont.activate(followcam.actuators["rotleft"])
  1025. else:
  1026. cont.deactivate(followcam.actuators["rotleft"])
  1027. # #right
  1028. if rLR > 0.080:
  1029. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  1030. cont.activate(followcam.actuators["rotright"])
  1031. else:
  1032. cont.deactivate(followcam.actuators["rotright"])
  1033. #*********************************************
  1034. if lUD > -0.080 and lUD < -0.030:
  1035. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  1036. cont.activate(followcam.actuators["up"])
  1037. #print(lUD)
  1038. else:
  1039. cont.deactivate(followcam.actuators["up"])
  1040. # #down
  1041. if lUD < .080 and lUD > .03:
  1042. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  1043. cont.activate(followcam.actuators["down"])
  1044. else:
  1045. cont.deactivate(followcam.actuators["down"])
  1046. # #left
  1047. if lLR > -0.080 and lLR < -0.030:
  1048. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  1049. cont.activate(followcam.actuators["left"])
  1050. else:
  1051. cont.deactivate(followcam.actuators["left"])
  1052. # #right
  1053. if lLR < .080 and lLR > .03:
  1054. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  1055. cont.activate(followcam.actuators["right"])
  1056. else:
  1057. cont.deactivate(followcam.actuators["right"])
  1058. #up
  1059. if rUD > -0.080 and rUD < -0.030:
  1060. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  1061. cont.activate(followcam.actuators["rotup"])
  1062. else:
  1063. cont.deactivate(followcam.actuators["rotup"])
  1064. # #down
  1065. if rUD < .080 and rUD > .03:
  1066. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  1067. cont.activate(followcam.actuators["rotdown"])
  1068. else:
  1069. cont.deactivate(followcam.actuators["rotdown"])
  1070. # #left
  1071. if rLR > -0.080 and rLR < -0.030:
  1072. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1073. cont.activate(followcam.actuators["rotleft"])
  1074. else:
  1075. cont.deactivate(followcam.actuators["rotleft"])
  1076. # #right
  1077. if rLR < .080 and rLR > .03:
  1078. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1079. cont.activate(followcam.actuators["rotright"])
  1080. else:
  1081. cont.deactivate(followcam.actuators["rotright"])
  1082. def move_flycam():
  1083. if own['camera'] == 1:
  1084. #if rtsBut == False and own['lastrts'] == True:
  1085. if own['lastbkBut'] == True and bkBut == False:
  1086. if own['move_freecam'] == False:
  1087. own['move_freecam'] = True
  1088. else:
  1089. own['move_freecam'] = False
  1090. if own['move_freecam'] == True:
  1091. #act = freecam.actuators[
  1092. camspeed1 = .015
  1093. camspeed2 = .055
  1094. camrot1 = .005
  1095. camrot2 = .02
  1096. #up
  1097. if lUD < -0.080:
  1098. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  1099. cont.activate(freecam.actuators["up"])
  1100. #print("fastup")
  1101. else:
  1102. cont.deactivate(freecam.actuators["up"])
  1103. # #down
  1104. if lUD > .080:
  1105. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  1106. cont.activate(freecam.actuators["down"])
  1107. else:
  1108. cont.deactivate(freecam.actuators["down"])
  1109. # #left
  1110. if lLR < -0.080:
  1111. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  1112. cont.activate(freecam.actuators["left"])
  1113. else:
  1114. cont.deactivate(freecam.actuators["left"])
  1115. # #right
  1116. if lLR > 0.080:
  1117. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  1118. cont.activate(freecam.actuators["right"])
  1119. else:
  1120. cont.deactivate(freecam.actuators["right"])
  1121. #up
  1122. if rUD < -0.080:
  1123. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  1124. cont.activate(freecam.actuators["rotup"])
  1125. else:
  1126. cont.deactivate(freecam.actuators["rotup"])
  1127. # #down
  1128. if rUD > .080:
  1129. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  1130. cont.activate(freecam.actuators["rotdown"])
  1131. else:
  1132. cont.deactivate(freecam.actuators["rotdown"])
  1133. # #left
  1134. if rLR < -0.080:
  1135. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  1136. cont.activate(freecam.actuators["rotleft"])
  1137. else:
  1138. cont.deactivate(freecam.actuators["rotleft"])
  1139. # #right
  1140. if rLR > 0.080:
  1141. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  1142. cont.activate(freecam.actuators["rotright"])
  1143. else:
  1144. cont.deactivate(freecam.actuators["rotright"])
  1145. #*********************************************
  1146. if lUD > -0.080 and lUD < -0.030:
  1147. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  1148. cont.activate(freecam.actuators["up"])
  1149. #print(lUD)
  1150. else:
  1151. cont.deactivate(freecam.actuators["up"])
  1152. # #down
  1153. if lUD < .080 and lUD > .03:
  1154. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  1155. cont.activate(freecam.actuators["down"])
  1156. else:
  1157. cont.deactivate(freecam.actuators["down"])
  1158. # #left
  1159. if lLR > -0.080 and lLR < -0.030:
  1160. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  1161. cont.activate(freecam.actuators["left"])
  1162. else:
  1163. cont.deactivate(freecam.actuators["left"])
  1164. # #right
  1165. if lLR < .080 and lLR > .03:
  1166. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  1167. cont.activate(freecam.actuators["right"])
  1168. else:
  1169. cont.deactivate(freecam.actuators["right"])
  1170. #up
  1171. if rUD > -0.080 and rUD < -0.030:
  1172. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  1173. cont.activate(freecam.actuators["rotup"])
  1174. else:
  1175. cont.deactivate(freecam.actuators["rotup"])
  1176. # #down
  1177. if rUD < .080 and rUD > .03:
  1178. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  1179. cont.activate(freecam.actuators["rotdown"])
  1180. else:
  1181. cont.deactivate(freecam.actuators["rotdown"])
  1182. # #left
  1183. if rLR > -0.080 and rLR < -0.030:
  1184. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1185. cont.activate(freecam.actuators["rotleft"])
  1186. else:
  1187. cont.deactivate(freecam.actuators["rotleft"])
  1188. # #right
  1189. if rLR < .080 and rLR > .03:
  1190. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1191. cont.activate(freecam.actuators["rotright"])
  1192. else:
  1193. cont.deactivate(freecam.actuators["rotright"])
  1194. if r_ground.triggered == False:
  1195. cont.deactivate(own.actuators["walk_align"])
  1196. else:
  1197. cont.activate(own.actuators["walk_align"])
  1198. if r_ground.triggered:
  1199. #print("on stair")
  1200. try:
  1201. if 'stair' in r_ground.hitObject:
  1202. own['stair_counter'] = 20
  1203. force = [ 0.0, 0.0, -100]
  1204. # use local axis
  1205. local = True
  1206. # apply force
  1207. #own.applyForce(force, local)
  1208. except:
  1209. pass
  1210. if own['stair_counter'] > 0:
  1211. own['stair_counter'] -= 1
  1212. if yBut == True:
  1213. own['walk_idling'] = 0
  1214. own["walk_idle_frame"] = 0
  1215. onboard()
  1216. jump()
  1217. dropin()
  1218. throwdeck_trigger()
  1219. nextframe()
  1220. checkidle()
  1221. getonboard()
  1222. reset_pos()
  1223. switchcam()
  1224. move_flycam()
  1225. move_followcam()
  1226. fall()
  1227. idle_anim()
  1228. sit()
  1229. #cont.activate(cam.actuators['Camera'])
  1230. #printplaying()
  1231. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1232. own.actuators["sroll"].stopSound()
  1233. wheel1 = scene.objects["rollen.000"]
  1234. wheel2 = scene.objects["rollen.001"]
  1235. wheel3 = scene.objects["rollen.002"]
  1236. wheel4 = scene.objects["rollen.003"]
  1237. wheel1.stopAction(2)
  1238. wheel2.stopAction(2)
  1239. wheel3.stopAction(2)
  1240. wheel4.stopAction(2)
  1241. own['lasty'] = yBut
  1242. own['lastb'] = bBut
  1243. own['lasta'] = aBut
  1244. own['lastx'] = xBut
  1245. own['lastlts'] = ltsBut
  1246. own['lastrts'] = rtsBut
  1247. own['lastbkBut'] = bkBut
  1248. own['dropinCol'] = dropinCol
  1249. own['walk'] = 1