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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. #shuvit.org
  2. #walk.py
  3. import bge
  4. import GameLogic
  5. import ctypes
  6. #import bpy
  7. import random
  8. import math
  9. #build global dict (move this to separate script that runs once)
  10. scene = bge.logic.getCurrentScene()
  11. objList = scene.objects
  12. cont = GameLogic.getCurrentController()
  13. obj = bge.logic.getCurrentScene().objects
  14. char = bge.constraints.getCharacter
  15. own = cont.owner
  16. stance = own['stance']
  17. STANCE = own['stance']
  18. r_ground = cont.sensors["r_Ground"]
  19. linvel = own.getLinearVelocity(True)
  20. lasta = own['lasta']
  21. lastx = own['lastx']
  22. last_sit = own['sit']
  23. dict = bge.logic.globalDict
  24. try:
  25. own['walk_timer'] = own['walk_timer'] +1
  26. except:
  27. own['walk_timer'] = 1
  28. truckon = 450
  29. deckon = 460
  30. lLR = dict['lLR']
  31. lUD = dict['lUD']
  32. rLR = dict['rLR']
  33. rUD = dict['rUD']
  34. lTrig = dict['lTrig']
  35. rTrig = dict['rTrig']
  36. aBut = dict['aBut']
  37. bBut = dict['bBut']
  38. xBut = dict['xBut']
  39. yBut = dict['yBut']
  40. lBump = dict['lBump']
  41. rBump = dict['rBump']
  42. bkBut = dict['bkBut']
  43. stBut = dict['stBut']
  44. xbBut = dict['xbBut']
  45. ltsBut = dict['ltsBut']
  46. rtsBut = dict['rtsBut']
  47. ldPad = dict['ldPad']
  48. rdPad = dict['rdPad']
  49. udPad = dict['udPad']
  50. ddPad = dict['ddPad']
  51. #user
  52. sens = .04
  53. fliplay = 30
  54. dropinCol = own.sensors['dropinCol']
  55. skater = scene.objects["Char4"]
  56. deck = scene.objects["deck"]
  57. trucks = scene.objects["trucks"]
  58. throw_deck_empty = scene.objects["throw_deck_empty"]
  59. wheel1 = scene.objects["rollen.000"]
  60. wheel2 = scene.objects["rollen.001"]
  61. wheel3 = scene.objects["rollen.002"]
  62. wheel4 = scene.objects["rollen.003"]
  63. camobj = scene.objects["Camera.003"]
  64. camera = cont.actuators["Camera"]
  65. replayCam = cont.actuators["replayCam"]
  66. timer = own['dropinTimer']
  67. cam = scene.objects["Camera.003"]
  68. freecam = scene.objects["freecam"]
  69. followcam = scene.objects["followcam"]
  70. control_bottom = scene.objects['control_bottom']
  71. cb = control_bottom.sensors['grindCol_bottom']
  72. cb_td = control_bottom.sensors['td_bottom']
  73. noidle = 0
  74. if skater.isPlayingAction(460):
  75. noidle = 1
  76. if own["stance"] == None:
  77. own["stance"] = True
  78. STANCE = own["stance"]
  79. def killact(layer):
  80. if skater.isPlayingAction(layer):
  81. skater.stopAction(layer)
  82. if deck.isPlayingAction(layer):
  83. deck.stopAction(layer)
  84. if trucks.isPlayingAction(layer):
  85. trucks.stopAction(layer)
  86. def killall():
  87. for x in range(5000):
  88. skater.stopAction(x)
  89. deck.stopAction(x)
  90. trucks.stopAction(x)
  91. def trucksisplaying():
  92. for x in range(5000):
  93. if deck.isPlayingAction(x):
  94. print("deck is playing:", x)
  95. def printplaying():
  96. splaying_layers = "S: "
  97. playing_layers = "D: "
  98. tplaying_layers = "T: "
  99. for x in range(9900):
  100. if skater.isPlayingAction(x):
  101. #if trucks.isPlayingAction(x):
  102. #if skater.isPlayingAction(x):
  103. splaying_layers += str(x)
  104. splaying_layers += " "
  105. if deck.isPlayingAction(x):
  106. #if trucks.isPlayingAction(x):
  107. #if skater.isPlayingAction(x):
  108. playing_layers += str(x)
  109. playing_layers += " "
  110. if trucks.isPlayingAction(x):
  111. #if trucks.isPlayingAction(x):
  112. #if skater.isPlayingAction(x):
  113. tplaying_layers += str(x)
  114. tplaying_layers += " "
  115. print(splaying_layers, playing_layers, tplaying_layers)
  116. #printplaying()
  117. ##
  118. if r_ground.positive and xBut == False and lastx == False:
  119. killact(10)
  120. #killact(11)
  121. killact(12)
  122. killact(13)
  123. ######################################
  124. #idle
  125. 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:
  126. own['requestAction'] = 'reg_idle'
  127. if own['throw_deck'] == True:
  128. own['requestAction'] = 'reg_idle_nb'
  129. 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:
  130. own['requestAction'] = 'fak_idle'
  131. if own['throw_deck'] == True:
  132. own['requestAction'] = 'fak_idle_nb'
  133. if lUD < -sens:
  134. lup = 1
  135. else:
  136. lup = 0
  137. if lUD > sens:
  138. ldown = 1
  139. else:
  140. ldown = 0
  141. if lLR < -sens:
  142. lLeft = 1
  143. else:
  144. lLeft = 0
  145. if lLR > sens:
  146. lRight = 1
  147. else:
  148. lRight = 0
  149. #walking
  150. #new walking
  151. vel = own.getLinearVelocity(True)
  152. if own['walk_timer'] < 50:
  153. velx = vel.x * .95
  154. own.setLinearVelocity([velx, 0, vel.z], True)
  155. else:
  156. own.setLinearVelocity([0, 0, vel.z], True)
  157. #print("set 0 vel")
  158. wf = 1
  159. if own['last_walk_frame'] - own['last_roll_frame'] > 55:
  160. wf = 0
  161. if ((lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0)) and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] == 0:
  162. own['walking'] = "regular"
  163. walking = "regular"
  164. elif ((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] != 2:
  165. own['walking'] = "fast"
  166. walking = "fast"
  167. else:
  168. own['walking'] = None
  169. walking = None
  170. #print(own['walk_timer'])
  171. if walking == "regular":
  172. cont.deactivate(own.actuators['forward2'])
  173. cont.deactivate(own.actuators['backward2'])
  174. if stance == 0:
  175. cont.activate(own.actuators['forward'])
  176. else:
  177. cont.activate(own.actuators['backward'])
  178. if walking == "fast":
  179. cont.deactivate(own.actuators['forward'])
  180. cont.deactivate(own.actuators['backward'])
  181. if stance == 0:
  182. cont.activate(own.actuators['forward2'])
  183. else:
  184. cont.activate(own.actuators['backward2'])
  185. if walking == None:
  186. cont.deactivate(own.actuators['forward2'])
  187. cont.deactivate(own.actuators['backward2'])
  188. cont.deactivate(own.actuators['forward'])
  189. cont.deactivate(own.actuators['backward'])
  190. if own['walk_timer'] < 50:
  191. velx = vel.x * .95
  192. own.setLinearVelocity([velx, 0, vel.z], True)
  193. else:
  194. own.setLinearVelocity([0, 0, vel.z], True)
  195. #print("set 0 vel")
  196. #old walking
  197. if (lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  198. own.actuators["walkondirt"].volume = .2
  199. own.actuators["walkondirt"].pitch = 1
  200. cont.activate(own.actuators["walkondirt"])
  201. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  202. #without deck
  203. if own['throw_deck'] == True:
  204. own['requestAction'] = 'reg_walk_nb'
  205. else:
  206. own['requestAction'] = 'reg_walk'
  207. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  208. #without deck
  209. if own['throw_deck'] == True:
  210. own['requestAction'] = 'fak_walk_nb'
  211. else:
  212. own['requestAction'] = 'fak_walk'
  213. elif ((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
  214. own.actuators["walkondirt"].volume = .2
  215. own.actuators["walkondirt"].pitch = 1.3
  216. cont.activate(own.actuators["walkondirt"])
  217. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  218. if own['throw_deck'] == True:
  219. own['requestAction'] = 'reg_walkFast_nb'
  220. skater.playAction("reg_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=1)
  221. else:
  222. own['requestAction'] = 'reg_walkFast'
  223. else:
  224. killact(25)
  225. killact(305)
  226. killact(306)
  227. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  228. if own['throw_deck'] == True:
  229. own['requestAction'] = 'fak_walkFast_nb'
  230. skater.playAction("fak_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=1)
  231. else:
  232. own['requestAction'] = 'fak_walkFast'
  233. else:
  234. vel = own.getLinearVelocity(True)
  235. cont.deactivate(own.actuators["walkondirt"])
  236. #turning
  237. if lRight == 1 or dict['kb_ra'] == 2:
  238. cont.activate(own.actuators['right'])
  239. else:
  240. cont.deactivate(own.actuators['right'])
  241. if lLeft == 1 or dict['kb_la'] == 2:
  242. cont.activate(own.actuators['left'])
  243. else:
  244. cont.deactivate(own.actuators['left'])
  245. #in air
  246. if (lup == 1 or dict['kb_ua'] != 0) and r_ground.positive == False:
  247. if stance == 0:
  248. cont.deactivate(own.actuators['forward'])
  249. cont.deactivate(own.actuators['forward2'])
  250. killact(4)
  251. killact(5)
  252. killact(6)
  253. killact(7)
  254. velx = linvel.x - 1
  255. own.setLinearVelocity([-1.5, linvel.y, linvel.z], 1)
  256. if stance == 1:
  257. cont.deactivate(own.actuators['backward'])
  258. cont.deactivate(own.actuators['backward2'])
  259. killact(4)
  260. killact(5)
  261. killact(6)
  262. killact(7)
  263. velx = linvel.x + 1
  264. own.setLinearVelocity([1.5, linvel.y, linvel.z], 1)
  265. own['lF_air_frame'] = own['framenum']
  266. #---------------
  267. if rLR > .05:
  268. cont.activate(camobj.actuators['camRight'])
  269. else:
  270. cont.deactivate(camobj.actuators['camRight'])
  271. if rLR < -.05:
  272. cont.activate(camobj.actuators['camLeft'])
  273. else:
  274. cont.deactivate(camobj.actuators['camLeft'])
  275. if rUD > .05:
  276. cont.activate(camobj.actuators['camDown'])
  277. else:
  278. cont.deactivate(camobj.actuators['camDown'])
  279. if rUD < -.05:
  280. cont.activate(camobj.actuators['camUp'])
  281. else:
  282. cont.deactivate(camobj.actuators['camUp'])
  283. #----------------
  284. camera.height = .9 #-.4
  285. camera.min = 1.5
  286. camera.max = 2
  287. lasty = own['lasty']
  288. def onboard():
  289. if own['walk'] == 0:
  290. print("start walking")
  291. if own['framenum'] > 100 and own['fall'] == False:
  292. #pass
  293. cont.activate(own.actuators['pop'])
  294. own['getoffboard'] = False
  295. fliplay = 301
  296. fliplay2 = 302
  297. fliplay3 = 303
  298. own['grindcement_vol'] = 0
  299. own['grindcement_pitch'] = 0
  300. own['grindrail_vol'] = 0
  301. own['grindrail_pitch'] = 0
  302. own['sroll_vol'] = 0
  303. own['sroll_pitch'] = 0
  304. try:
  305. vel = own['offboard_vel']
  306. vel = [velx, vel.y, vel.z]
  307. except:
  308. pass
  309. if STANCE == 0:
  310. skater.stopAction(fliplay)
  311. deck.stopAction(deckon)
  312. trucks.stopAction(truckon)
  313. own['requestAction'] = 'reg_offboard'
  314. if STANCE == 1:
  315. skater.stopAction(fliplay)
  316. deck.stopAction(deckon)
  317. trucks.stopAction(truckon)
  318. own['requestAction'] = 'fak_offboard'
  319. def jump():
  320. if xBut == True or dict['kb_space'] == 1:
  321. #if xBut == True:
  322. if own['lastx'] == 0:
  323. killact(3)
  324. killact(4)
  325. killact(5)
  326. killact(6)
  327. killact(7)
  328. if STANCE == 0:
  329. own['requestAction'] ='reg_jump'
  330. print('jump')
  331. if STANCE == 1:
  332. own['requestAction'] ='fak_jump'
  333. print('jump')
  334. JUMPHEIGHT = 1100
  335. force = [ 0.0, 0.0, JUMPHEIGHT]
  336. # use local axis
  337. local = False
  338. # apply force
  339. own.applyForce(force, local)
  340. own['lastx'] = 1
  341. else:
  342. own['lastx'] = 0
  343. def dropin():
  344. if dropinCol.positive == True:
  345. pass
  346. def getonboard():
  347. #print(dict['kb_q'])
  348. getonboard = own['getonboard']
  349. fliplay2 = 50#8560
  350. if yBut == True or dict['kb_q'] == 2:
  351. fliplay3 = fliplay2 + 1
  352. if dropinCol.positive == True:
  353. nearestObject = None
  354. grindEmpty = scene.objects['grindEmpty']
  355. grindDar = grindEmpty.sensors['grindDar2']
  356. minDist = None
  357. if grindDar.positive:
  358. detectedObjects = grindDar.hitObjectList
  359. dist = 0
  360. for obj in detectedObjects:
  361. dist = own.getDistanceTo(obj)
  362. if (minDist is None or dist < minDist):
  363. nearestObject = obj
  364. minDist = dist
  365. if nearestObject != None:
  366. print(nearestObject)
  367. obj = nearestObject
  368. player_e = own.worldOrientation.to_euler()
  369. player_pos = own.worldPosition
  370. player_rotz = math.degrees(player_e[2])
  371. grinder_e = obj.worldOrientation.to_euler()
  372. grinder_rotz = math.degrees(grinder_e[2])
  373. rot = player_rotz - grinder_rotz
  374. grinder_pos = obj.worldPosition
  375. worldVect = [1, 0, 0]
  376. vect = obj.getAxisVect(worldVect)
  377. go = obj.worldOrientation
  378. grinder_axis = [1,0,0]
  379. try:
  380. delta = player_pos - grinder_pos
  381. delta = delta.cross(vect)
  382. if delta[2] >= 0:
  383. grindside = "right"
  384. else:
  385. grindside = "left"
  386. deltamove = delta[2] * .1#.25
  387. if STANCE == 0:
  388. move = [-deltamove, 0, 0]
  389. else:
  390. move = [deltamove, 0, 0]
  391. own.applyMovement(move, True)
  392. except:
  393. pass
  394. if STANCE == 0:
  395. own['requestAction'] ='reg_dropin_pos'
  396. own['dropinTimer'] = 60
  397. if STANCE == 1:
  398. own['requestAction'] ='fak_dropin_pos'
  399. own['dropinTimer'] = 60
  400. if getonboard == 1:
  401. fliplay3 = 6000
  402. onboard_speed = .1
  403. own['getonboard'] = 0
  404. if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 2) and dropinCol.positive:
  405. deckact = deck.actuators["Visibility"]
  406. trucksact = trucks.actuators["Visibility"]
  407. wheel1act = wheel1.actuators["Visibility"]
  408. wheel2act = wheel2.actuators["Visibility"]
  409. wheel3act = wheel3.actuators["Visibility"]
  410. wheel4act = wheel4.actuators["Visibility"]
  411. deckact.visibility = True
  412. trucksact.visibility = True
  413. wheel1act.visibility = True
  414. wheel2act.visibility = True
  415. wheel3act.visibility = True
  416. wheel4act.visibility = True
  417. cont.activate(deck.actuators['Visibility'])
  418. cont.activate(trucks.actuators['Visibility'])
  419. cont.activate(wheel1.actuators['Visibility'])
  420. cont.activate(wheel2.actuators['Visibility'])
  421. cont.activate(wheel3.actuators['Visibility'])
  422. cont.activate(wheel4.actuators['Visibility'])
  423. own['throw_deck'] = False
  424. throw_deck_empty = scene.objects["throw_deck_empty"]
  425. throw_deck_empty['kill_deck'] = 1
  426. if (yBut == False and lasty == True) or dict['kb_q'] == 3:
  427. own['getonboard'] = 1
  428. def nextframe():
  429. framenumber = own["framenum"]
  430. framenumber = framenumber + 1
  431. if framenumber == 900000:
  432. framenumber = 0
  433. own["framenum"] = framenumber
  434. own['last_walk_frame'] = framenumber
  435. def checkidle():
  436. idle = cont.sensors["idle"]
  437. #print(idle.positive)
  438. idle_frame = own["walk_idle_frame"]
  439. if idle.positive:
  440. own["walk_idle_frame"] = 0
  441. cont.deactivate(camobj.actuators['idle_camRight'])
  442. camera.height = .5
  443. else:
  444. if idle_frame == 0:
  445. own["walk_idle_frame"] = own["framenum"]
  446. diff = own["framenum"] - idle_frame
  447. if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
  448. cont.activate(camobj.actuators['idle_camRight'])
  449. camera.height = .9
  450. camera.min = 2
  451. camera.max = 2.50
  452. own['walk_idling'] = 1
  453. else:
  454. own['walk_idling'] = 0
  455. def idle_anim():
  456. if own['walk_idling'] == 1 and own['sit'] == 0:
  457. walk_idle_frame = own['walk_idle_frame']
  458. mod_num = (own["framenum"] - walk_idle_frame) % 240
  459. idle_lay = 300
  460. if mod_num == 0:
  461. if own['idle_skipper'] > 0:
  462. own['idle_skipper'] -= 1
  463. ran_num = random.randint(1, 8)
  464. if own['last_idle_num'] == ran_num:
  465. ran_num = 1
  466. if own['idle_skipper'] == 0:
  467. own['last_idle_num'] = ran_num
  468. if ran_num == 1 or ran_num > 7:
  469. killact(3)
  470. if STANCE == 0 and own['throw_deck'] == 0:
  471. own['requestAction'] = 'reg_idle1'
  472. elif STANCE == 0 and own['throw_deck'] == 1:
  473. own['requestAction'] = 'reg_idle1'
  474. elif STANCE == 1 and own['throw_deck'] == 0:
  475. own['requestAction'] = 'fak_idle1'
  476. elif STANCE == 1 and own['throw_deck'] == 1:
  477. own['requestAction'] = 'fak_idle1'
  478. elif ran_num == 2:
  479. killact(3)
  480. if STANCE == 0 and own['throw_deck'] == 0:
  481. own['requestAction'] = 'reg_idle2'
  482. elif STANCE == 0 and own['throw_deck'] == 1:
  483. own['requestAction'] = 'reg_idle2_nb'
  484. elif STANCE == 1 and own['throw_deck'] == 0:
  485. own['requestAction'] = 'fak_idle1'
  486. elif STANCE == 1 and own['throw_deck'] == 1:
  487. own['requestAction'] = 'fak_idle1'
  488. elif ran_num == 3:
  489. killact(3)
  490. if STANCE == 0 and own['throw_deck'] == 0:
  491. own['requestAction'] = 'reg_idle3'
  492. elif STANCE == 0 and own['throw_deck'] == 1:
  493. own['requestAction'] = 'reg_idle3'
  494. elif STANCE == 1 and own['throw_deck'] == 0:
  495. own['requestAction'] = 'fak_idle1'
  496. elif STANCE == 1 and own['throw_deck'] == 1:
  497. own['requestAction'] = 'fak_idle1'
  498. own['idle_skipper'] = 2
  499. elif ran_num == 4:
  500. killact(3)
  501. if STANCE == 0 and own['throw_deck'] == 0:
  502. own['requestAction'] = 'reg_idle4'
  503. elif STANCE == 0 and own['throw_deck'] == 1:
  504. own['requestAction'] = 'reg_idle4'
  505. elif STANCE == 1 and own['throw_deck'] == 0:
  506. own['requestAction'] = 'fak_idle4'
  507. elif STANCE == 1 and own['throw_deck'] == 1:
  508. own['requestAction'] = 'fak_idle4'
  509. elif ran_num == 5:
  510. killact(3)
  511. if STANCE == 0 and own['throw_deck'] == 0:
  512. own['requestAction'] = 'reg_idle5'
  513. elif STANCE == 0 and own['throw_deck'] == 1:
  514. own['requestAction'] = 'reg_idle5'
  515. elif STANCE == 1 and own['throw_deck'] == 0:
  516. own['requestAction'] = 'fak_idle5'
  517. elif STANCE == 1 and own['throw_deck'] == 1:
  518. own['requestAction'] = 'fak_idle5'
  519. elif ran_num == 6:
  520. killact(3)
  521. if STANCE == 0 and own['throw_deck'] == 0:
  522. own['requestAction'] = 'reg_idle6'
  523. elif STANCE == 0 and own['throw_deck'] == 1:
  524. own['requestAction'] = 'reg_idle6'
  525. elif STANCE == 1 and own['throw_deck'] == 0:
  526. own['requestAction'] = 'fak_idle6'
  527. elif STANCE == 1 and own['throw_deck'] == 1:
  528. own['requestAction'] = 'fak_idle6'
  529. elif ran_num == 7:
  530. killact(3)
  531. if STANCE == 0 and own['throw_deck'] == 0:
  532. own['requestAction'] = 'reg_idle7'
  533. elif STANCE == 0 and own['throw_deck'] == 1:
  534. own['requestAction'] = 'reg_idle7'
  535. elif STANCE == 1 and own['throw_deck'] == 0:
  536. own['requestAction'] = 'fak_idle6'
  537. elif STANCE == 1 and own['throw_deck'] == 1:
  538. own['requestAction'] = 'fak_idle6'
  539. def reset_pos():
  540. #reset
  541. if ddPad == 1:
  542. spawn_pos = own['spawn_pos']
  543. spawn_rot = own['spawn_rot']
  544. spawn_cam_pos = own['spawn_cam_pos']
  545. spawn_cam_rot = own['spawn_cam_rot']
  546. try:
  547. own.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
  548. 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]]
  549. cam.worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
  550. cam.worldOrientation = [[spawn_cam_rot[0][0],spawn_cam_rot[0][1],spawn_cam_rot[0][2]], [spawn_cam_rot[1][0],spawn_cam_rot[1][1],spawn_cam_rot[1][2]], [0.0, 0.0, 1.0]]
  551. except:
  552. own.worldPosition = (0, 0, .1)
  553. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  554. own['stance'] = own['spawn_stance']
  555. if own["spawn_stance"] == 1:
  556. own.setLinearVelocity([.1,0,0], 1)
  557. else:
  558. own.setLinearVelocity([-.1,0,0], 1)
  559. if udPad == 1:
  560. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  561. 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]]
  562. own['spawn_cam_pos'] = [cam.worldPosition[0], cam.worldPosition[1], cam.worldPosition[2]]
  563. own['spawn_cam_rot'] = [[cam.worldOrientation[0][0],cam.worldOrientation[0][1],cam.worldOrientation[0][2]], [cam.worldOrientation[1][0],cam.worldOrientation[1][1],cam.worldOrientation[1][2]], cam.worldOrientation[2][2]]
  564. stance = own["stance"]
  565. own["spawn_stance"] = stance
  566. def falldeck():
  567. throw_deck_empty = scene.objects["throw_deck_empty"]
  568. deckact = deck.actuators["Visibility"]
  569. trucksact = trucks.actuators["Visibility"]
  570. wheel1act = wheel1.actuators["Visibility"]
  571. wheel2act = wheel2.actuators["Visibility"]
  572. wheel3act = wheel3.actuators["Visibility"]
  573. wheel4act = wheel4.actuators["Visibility"]
  574. if own['throw_deck'] == False:
  575. own['throw_deck'] = True
  576. deckact.visibility = False
  577. trucksact.visibility = False
  578. wheel1act.visibility = False
  579. wheel2act.visibility = False
  580. wheel3act.visibility = False
  581. wheel4act.visibility = False
  582. act = throw_deck_empty.actuators['throw_dec_act']
  583. if STANCE == True:
  584. act.linearVelocity = [0.0, 1.0, 1.0]
  585. if STANCE == False:
  586. act.linearVelocity = [0.0, 1.0, -1.0]
  587. cont.activate(act)
  588. else:
  589. own['throw_deck'] = False
  590. deckact.visibility = True
  591. trucksact.visibility = True
  592. wheel1act.visibility = True
  593. wheel2act.visibility = True
  594. wheel3act.visibility = True
  595. wheel4act.visibility = True
  596. throw_deck_empty['kill_deck'] = 1
  597. cont.activate(deck.actuators['Visibility'])
  598. cont.activate(trucks.actuators['Visibility'])
  599. cont.activate(wheel1.actuators['Visibility'])
  600. cont.activate(wheel2.actuators['Visibility'])
  601. cont.activate(wheel3.actuators['Visibility'])
  602. cont.activate(wheel4.actuators['Visibility'])
  603. def throwdeck(strength, ud):
  604. throw_deck_empty = scene.objects["throw_deck_empty"]
  605. deckact = deck.actuators["Visibility"]
  606. trucksact = trucks.actuators["Visibility"]
  607. wheel1act = wheel1.actuators["Visibility"]
  608. wheel2act = wheel2.actuators["Visibility"]
  609. wheel3act = wheel3.actuators["Visibility"]
  610. wheel4act = wheel4.actuators["Visibility"]
  611. if own['throw_deck'] == False:
  612. own['throw_deck'] = True
  613. deckact.visibility = False
  614. trucksact.visibility = False
  615. wheel1act.visibility = False
  616. wheel2act.visibility = False
  617. wheel3act.visibility = False
  618. wheel4act.visibility = False
  619. act = throw_deck_empty.actuators['throw_dec_act']
  620. hard = strength * .08
  621. if hard > 9:
  622. hard = 9
  623. if hard < 1:
  624. hard = 1
  625. ud = ud * 4
  626. own['bbut_timer'] = 0
  627. if STANCE == True:
  628. own['requestAction'] = 'fak_throw'
  629. act.linearVelocity = [0.0, ud, hard]
  630. if STANCE == False:
  631. own['requestAction'] = 'fak_throw'
  632. act.linearVelocity = [0.0, ud, -hard]
  633. cont.activate(act)
  634. else:
  635. own['throw_deck'] = False
  636. deckact.visibility = True
  637. trucksact.visibility = True
  638. wheel1act.visibility = True
  639. wheel2act.visibility = True
  640. wheel3act.visibility = True
  641. wheel4act.visibility = True
  642. throw_deck_empty['kill_deck'] = 1
  643. cont.activate(deck.actuators['Visibility'])
  644. cont.activate(trucks.actuators['Visibility'])
  645. cont.activate(wheel1.actuators['Visibility'])
  646. cont.activate(wheel2.actuators['Visibility'])
  647. cont.activate(wheel3.actuators['Visibility'])
  648. cont.activate(wheel4.actuators['Visibility'])
  649. def throwdeck_trigger():
  650. lastb = own['lastb']
  651. throw_deck_empty = scene.objects["throw_deck_empty"]
  652. if bBut == True:
  653. own['bbut_timer'] += 1
  654. ud = (rUD * 10) +1
  655. if bBut == False:
  656. throw_deck_empty['kill_deck'] = 0
  657. if bBut == False and own['lastb'] == True:
  658. strength = own['bbut_timer']
  659. ud = (rUD * 10) +1
  660. throwdeck(strength, ud)
  661. def focus_deck():
  662. since_air = own['framenum'] - own['lF_air_frame']
  663. if cb_td.positive and since_air < 10:
  664. object = 'focus_deckA'
  665. object2 = 'focus_deckB'
  666. other = throw_deck_empty
  667. throw_deck = scene.objects["throw_deck"]
  668. throw_deck.endObject()
  669. scene.addObject(object, other, 0)
  670. scene.addObject(object2, other, 0)
  671. if own['throw_deck'] == True:
  672. if dict['ldPad'] == False and dict['last_ldPad'] == True:
  673. object = 'focus_deckA'
  674. object2 = 'focus_deckB'
  675. other = throw_deck_empty
  676. scene.addObject(object, other, 0)
  677. scene.addObject(object2, other, 0)
  678. def fall():
  679. if own['fall'] == True:
  680. falldeck()
  681. if STANCE == 1:
  682. own['requestAction'] = 'fak_air-walk_air'
  683. own.setLinearVelocity([3,2,0], True)
  684. else:
  685. own['requestAction'] = 'reg_air-walk_air'
  686. own.setLinearVelocity([-3,-2,0], True)
  687. own['fall'] = False
  688. def sit():
  689. #turn off sit
  690. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  691. if own['sit'] == 1:
  692. killact(300)
  693. killact(299)
  694. own['sit'] = 0
  695. if aBut == False and lasta == True:
  696. try:
  697. if 'sit' in r_ground.hitObject:
  698. print("sit")
  699. own['sit'] = 1
  700. #killall()
  701. killact(3)
  702. if STANCE == 0:
  703. own['requestAction'] = 'reg_sit'
  704. elif STANCE == 1:
  705. own['requestAction'] = 'fak_sit'
  706. except:
  707. pass
  708. if own['sit'] == 1:
  709. try:
  710. killact(3)
  711. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  712. if STANCE == 0:
  713. own.alignAxisToVect(-sit_vect, 0, .2)
  714. own['requestAction'] = 'reg_sit'
  715. elif STANCE == 1:
  716. own['requestAction'] = 'fak_sit'
  717. own.alignAxisToVect(sit_vect, 0, .2)
  718. except:
  719. pass
  720. def switchcam():
  721. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  722. if own['camera'] == 1:
  723. own['camera'] = 0
  724. else:
  725. own['camera'] = 1
  726. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  727. if own['camera'] == 2:
  728. own['camera'] = 0
  729. else:
  730. own['camera'] = 2
  731. #followcam
  732. def move_followcam():
  733. if own['camera'] == 2:
  734. if own['lastbkBut'] == True and bkBut == False:
  735. print("activate move followcam")
  736. if own['move_followcam'] == False:
  737. own['move_followcam'] = True
  738. else:
  739. own['move_followcam'] = False
  740. if own['move_followcam'] == True:
  741. camspeed1 = .015
  742. camspeed2 = .055
  743. camrot1 = .005
  744. camrot2 = .02
  745. #up
  746. if lUD < -0.080:
  747. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  748. cont.activate(followcam.actuators["up"])
  749. print("fastup")
  750. else:
  751. cont.deactivate(followcam.actuators["up"])
  752. # #down
  753. if lUD > .080:
  754. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  755. cont.activate(followcam.actuators["down"])
  756. else:
  757. cont.deactivate(followcam.actuators["down"])
  758. # #left
  759. if lLR < -0.080:
  760. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  761. cont.activate(followcam.actuators["left"])
  762. else:
  763. cont.deactivate(followcam.actuators["left"])
  764. # #right
  765. if lLR > 0.080:
  766. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  767. cont.activate(followcam.actuators["right"])
  768. else:
  769. cont.deactivate(followcam.actuators["right"])
  770. #up
  771. if rUD < -0.080:
  772. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  773. cont.activate(followcam.actuators["rotup"])
  774. else:
  775. cont.deactivate(followcam.actuators["rotup"])
  776. # #down
  777. if rUD > .080:
  778. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  779. cont.activate(followcam.actuators["rotdown"])
  780. else:
  781. cont.deactivate(followcam.actuators["rotdown"])
  782. # #left
  783. if rLR < -0.080:
  784. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  785. cont.activate(followcam.actuators["rotleft"])
  786. else:
  787. cont.deactivate(followcam.actuators["rotleft"])
  788. # #right
  789. if rLR > 0.080:
  790. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  791. cont.activate(followcam.actuators["rotright"])
  792. else:
  793. cont.deactivate(followcam.actuators["rotright"])
  794. #*********************************************
  795. if lUD > -0.080 and lUD < -0.030:
  796. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  797. cont.activate(followcam.actuators["up"])
  798. else:
  799. cont.deactivate(followcam.actuators["up"])
  800. # #down
  801. if lUD < .080 and lUD > .03:
  802. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  803. cont.activate(followcam.actuators["down"])
  804. else:
  805. cont.deactivate(followcam.actuators["down"])
  806. # #left
  807. if lLR > -0.080 and lLR < -0.030:
  808. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  809. cont.activate(followcam.actuators["left"])
  810. else:
  811. cont.deactivate(followcam.actuators["left"])
  812. # #right
  813. if lLR < .080 and lLR > .03:
  814. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  815. cont.activate(followcam.actuators["right"])
  816. else:
  817. cont.deactivate(followcam.actuators["right"])
  818. #up
  819. if rUD > -0.080 and rUD < -0.030:
  820. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  821. cont.activate(followcam.actuators["rotup"])
  822. else:
  823. cont.deactivate(followcam.actuators["rotup"])
  824. # #down
  825. if rUD < .080 and rUD > .03:
  826. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  827. cont.activate(followcam.actuators["rotdown"])
  828. else:
  829. cont.deactivate(followcam.actuators["rotdown"])
  830. # #left
  831. if rLR > -0.080 and rLR < -0.030:
  832. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  833. cont.activate(followcam.actuators["rotleft"])
  834. else:
  835. cont.deactivate(followcam.actuators["rotleft"])
  836. # #right
  837. if rLR < .080 and rLR > .03:
  838. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  839. cont.activate(followcam.actuators["rotright"])
  840. else:
  841. cont.deactivate(followcam.actuators["rotright"])
  842. def move_flycam():
  843. if own['camera'] == 1:
  844. if own['lastbkBut'] == True and bkBut == False:
  845. if own['move_freecam'] == False:
  846. own['move_freecam'] = True
  847. else:
  848. own['move_freecam'] = False
  849. if own['move_freecam'] == True:
  850. camspeed1 = .015
  851. camspeed2 = .055
  852. camrot1 = .005
  853. camrot2 = .02
  854. #up
  855. if lUD < -0.080:
  856. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  857. cont.activate(freecam.actuators["up"])
  858. else:
  859. cont.deactivate(freecam.actuators["up"])
  860. # #down
  861. if lUD > .080:
  862. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  863. cont.activate(freecam.actuators["down"])
  864. else:
  865. cont.deactivate(freecam.actuators["down"])
  866. # #left
  867. if lLR < -0.080:
  868. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  869. cont.activate(freecam.actuators["left"])
  870. else:
  871. cont.deactivate(freecam.actuators["left"])
  872. # #right
  873. if lLR > 0.080:
  874. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  875. cont.activate(freecam.actuators["right"])
  876. else:
  877. cont.deactivate(freecam.actuators["right"])
  878. #up
  879. if rUD < -0.080:
  880. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  881. cont.activate(freecam.actuators["rotup"])
  882. else:
  883. cont.deactivate(freecam.actuators["rotup"])
  884. # #down
  885. if rUD > .080:
  886. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  887. cont.activate(freecam.actuators["rotdown"])
  888. else:
  889. cont.deactivate(freecam.actuators["rotdown"])
  890. # #left
  891. if rLR < -0.080:
  892. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  893. cont.activate(freecam.actuators["rotleft"])
  894. else:
  895. cont.deactivate(freecam.actuators["rotleft"])
  896. # #right
  897. if rLR > 0.080:
  898. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  899. cont.activate(freecam.actuators["rotright"])
  900. else:
  901. cont.deactivate(freecam.actuators["rotright"])
  902. #*********************************************
  903. if lUD > -0.080 and lUD < -0.030:
  904. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  905. cont.activate(freecam.actuators["up"])
  906. #print(lUD)
  907. else:
  908. cont.deactivate(freecam.actuators["up"])
  909. # #down
  910. if lUD < .080 and lUD > .03:
  911. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  912. cont.activate(freecam.actuators["down"])
  913. else:
  914. cont.deactivate(freecam.actuators["down"])
  915. # #left
  916. if lLR > -0.080 and lLR < -0.030:
  917. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  918. cont.activate(freecam.actuators["left"])
  919. else:
  920. cont.deactivate(freecam.actuators["left"])
  921. # #right
  922. if lLR < .080 and lLR > .03:
  923. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  924. cont.activate(freecam.actuators["right"])
  925. else:
  926. cont.deactivate(freecam.actuators["right"])
  927. #up
  928. if rUD > -0.080 and rUD < -0.030:
  929. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  930. cont.activate(freecam.actuators["rotup"])
  931. else:
  932. cont.deactivate(freecam.actuators["rotup"])
  933. # #down
  934. if rUD < .080 and rUD > .03:
  935. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  936. cont.activate(freecam.actuators["rotdown"])
  937. else:
  938. cont.deactivate(freecam.actuators["rotdown"])
  939. # #left
  940. if rLR > -0.080 and rLR < -0.030:
  941. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  942. cont.activate(freecam.actuators["rotleft"])
  943. else:
  944. cont.deactivate(freecam.actuators["rotleft"])
  945. # #right
  946. if rLR < .080 and rLR > .03:
  947. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  948. cont.activate(freecam.actuators["rotright"])
  949. else:
  950. cont.deactivate(freecam.actuators["rotright"])
  951. if r_ground.triggered == False:
  952. cont.deactivate(own.actuators["walk_align"])
  953. else:
  954. cont.activate(own.actuators["walk_align"])
  955. #walking on stairs
  956. if r_ground.triggered:
  957. try:
  958. if 'stair' in r_ground.hitObject:
  959. own['stair_counter'] = 20
  960. except:
  961. pass
  962. if own['stair_counter'] > 0:
  963. own['stair_counter'] -= 1
  964. if yBut == True:
  965. own['walk_idling'] = 0
  966. own["walk_idle_frame"] = 0
  967. if own['stair_counter'] > 5 and r_ground.triggered == False:
  968. own.applyForce([0,0,-200], True)
  969. if deck.visible:
  970. own['deckvis'] = 1
  971. else:
  972. own['deckvis'] = 0
  973. if own['requestAction'] == 'empty' or own['requestAction'] == None:
  974. if STANCE == 0:
  975. own['requestAction'] = 'reg_idle1'
  976. if STANCE == 1:
  977. own['requestAction'] = 'fak_idle1'
  978. def onground():
  979. if r_ground.positive:
  980. own['lF_ground_frame'] = own['framenum']
  981. if 'grind' in r_ground.hitObject:
  982. if own['framenum'] - own['last_fall_frame'] < 90:
  983. own.applyForce([0,100,0], True)
  984. #print('moving away from rail')
  985. else:
  986. #print('in air')
  987. if own['framenum'] - own['lF_ground_frame'] > 10:
  988. if STANCE == 0:
  989. own['requestAction'] = 'reg_walk_air'
  990. else:
  991. own['requestAction'] = 'fak_walk_air'
  992. #if control bottom is touching ground object, turn ground on
  993. if cb.positive:
  994. #if own['framenum'] - own['lF_ground_frame'] > 30:
  995. if own['framenum'] - own['last_fall_frame'] < 90:
  996. own['lF_ground_frame'] = own['framenum']
  997. onboard()
  998. jump()
  999. dropin()
  1000. throwdeck_trigger()
  1001. nextframe()
  1002. checkidle()
  1003. getonboard()
  1004. reset_pos()
  1005. switchcam()
  1006. move_flycam()
  1007. move_followcam()
  1008. fall()
  1009. idle_anim()
  1010. sit()
  1011. onground()
  1012. focus_deck()
  1013. #printplaying()
  1014. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1015. own.actuators["sroll"].stopSound()
  1016. wheel1 = scene.objects["rollen.000"]
  1017. wheel2 = scene.objects["rollen.001"]
  1018. wheel3 = scene.objects["rollen.002"]
  1019. wheel4 = scene.objects["rollen.003"]
  1020. wheel1.stopAction(2)
  1021. wheel2.stopAction(2)
  1022. wheel3.stopAction(2)
  1023. wheel4.stopAction(2)
  1024. own['lasty'] = yBut
  1025. own['lastb'] = bBut
  1026. own['lasta'] = aBut
  1027. own['lastx'] = xBut
  1028. own['lastlts'] = ltsBut
  1029. own['lastrts'] = rtsBut
  1030. own['lastbkBut'] = bkBut
  1031. own['dropinCol'] = dropinCol
  1032. own['walk'] = 1