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

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