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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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. own['grindcement_vol'] = 0
  302. own['grindcement_pitch'] = 0
  303. own['grindrail_vol'] = 0
  304. own['grindrail_pitch'] = 0
  305. own['sroll_vol'] = 0
  306. own['sroll_pitch'] = 0
  307. try:
  308. vel = own['offboard_vel']
  309. vel = [velx, vel.y, vel.z]
  310. except:
  311. pass
  312. if STANCE == 0:
  313. #killact(3)
  314. #killact(4)
  315. killall()
  316. skater.stopAction(fliplay)
  317. deck.stopAction(deckon)
  318. trucks.stopAction(truckon)
  319. own['requestAction'] = 'reg_offboard'
  320. if STANCE == 1:
  321. killact(3)
  322. killact(4)
  323. killall()
  324. skater.stopAction(fliplay)
  325. deck.stopAction(deckon)
  326. trucks.stopAction(truckon)
  327. own['requestAction'] = 'fak_offboard'
  328. def jump():
  329. if xBut == True:
  330. if own['lastx'] == 0:
  331. killact(3)
  332. killact(4)
  333. killact(5)
  334. killact(6)
  335. killact(7)
  336. if STANCE == 0:
  337. own['requestAction'] ='reg_jump'
  338. if STANCE == 1:
  339. own['requestAction'] ='fak_jump'
  340. JUMPHEIGHT = 1100
  341. force = [ 0.0, 0.0, JUMPHEIGHT]
  342. # use local axis
  343. local = False
  344. # apply force
  345. own.applyForce(force, local)
  346. own['lastx'] = 1
  347. else:
  348. own['lastx'] = 0
  349. def dropin():
  350. if dropinCol.positive == True:
  351. pass
  352. def getonboard():
  353. getonboard = own['getonboard']
  354. fliplay2 = 50#8560
  355. if yBut == True:
  356. #camera.height = -.4
  357. #camera.min = 1.5
  358. #camera.max = 2 #2
  359. #camera.damping = .99
  360. #camera.axis = 0
  361. #cont.deactivate(cam.actuators['replayCam'])
  362. #cont.deactivate(cam.actuators['Camera'])
  363. #camera.height = 10 #-.5
  364. #print("high cam")
  365. #camera.min = .75
  366. #camera.max = 1.25
  367. #cont.activate(cam.actuators['Camera'])
  368. fliplay3 = fliplay2 + 1
  369. if dropinCol.positive == True:
  370. nearestObject = None
  371. grindEmpty = scene.objects['grindEmpty']
  372. grindDar = grindEmpty.sensors['grindDar2']
  373. minDist = None
  374. if grindDar.positive:
  375. detectedObjects = grindDar.hitObjectList
  376. dist = 0
  377. for obj in detectedObjects:
  378. dist = own.getDistanceTo(obj)
  379. if (minDist is None or dist < minDist):
  380. nearestObject = obj
  381. minDist = dist
  382. if nearestObject != None:
  383. print(nearestObject)
  384. obj = nearestObject
  385. player_e = own.worldOrientation.to_euler()
  386. player_pos = own.worldPosition
  387. player_rotz = math.degrees(player_e[2])
  388. grinder_e = obj.worldOrientation.to_euler()
  389. grinder_rotz = math.degrees(grinder_e[2])
  390. rot = player_rotz - grinder_rotz
  391. grinder_pos = obj.worldPosition
  392. worldVect = [1, 0, 0]
  393. vect = obj.getAxisVect(worldVect)
  394. go = obj.worldOrientation
  395. grinder_axis = [1,0,0]
  396. try:
  397. delta = player_pos - grinder_pos
  398. delta = delta.cross(vect)
  399. if delta[2] >= 0:
  400. grindside = "right"
  401. else:
  402. grindside = "left"
  403. deltamove = delta[2] * .1#.25
  404. if STANCE == 0:
  405. move = [-deltamove, 0, 0]
  406. else:
  407. move = [deltamove, 0, 0]
  408. #print("1deltamove", deltamove)
  409. own.applyMovement(move, True)
  410. except:
  411. #print("delta broke: ", player_pos, grinder_pos)
  412. pass
  413. if STANCE == 0:
  414. own['requestAction'] ='reg_dropin_pos'
  415. own['dropinTimer'] = 60
  416. if STANCE == 1:
  417. own['requestAction'] ='fak_dropin_pos'
  418. own['dropinTimer'] = 60
  419. if getonboard == 1:
  420. fliplay3 = 6000
  421. onboard_speed = .1
  422. own['getonboard'] = 0
  423. if (yBut == False and lasty == True) or yBut == True and dropinCol.positive:
  424. deckact = deck.actuators["Visibility"]
  425. trucksact = trucks.actuators["Visibility"]
  426. wheel1act = wheel1.actuators["Visibility"]
  427. wheel2act = wheel2.actuators["Visibility"]
  428. wheel3act = wheel3.actuators["Visibility"]
  429. wheel4act = wheel4.actuators["Visibility"]
  430. deckact.visibility = True
  431. trucksact.visibility = True
  432. wheel1act.visibility = True
  433. wheel2act.visibility = True
  434. wheel3act.visibility = True
  435. wheel4act.visibility = True
  436. cont.activate(deck.actuators['Visibility'])
  437. cont.activate(trucks.actuators['Visibility'])
  438. cont.activate(wheel1.actuators['Visibility'])
  439. cont.activate(wheel2.actuators['Visibility'])
  440. cont.activate(wheel3.actuators['Visibility'])
  441. cont.activate(wheel4.actuators['Visibility'])
  442. own['throw_deck'] = False
  443. throw_deck_empty = scene.objects["throw_deck_empty"]
  444. throw_deck_empty['kill_deck'] = 1
  445. if (yBut == False and lasty == True):
  446. own['getonboard'] = 1
  447. def nextframe():
  448. framenumber = own["framenum"]
  449. framenumber = framenumber + 1
  450. if framenumber == 900000:
  451. framenumber = 0
  452. own["framenum"] = framenumber
  453. own['last_walk_frame'] = framenumber
  454. def checkidle():
  455. idle = cont.sensors["idle"]
  456. #print(idle.positive)
  457. idle_frame = own["walk_idle_frame"]
  458. if idle.positive:
  459. own["walk_idle_frame"] = 0
  460. cont.deactivate(camobj.actuators['idle_camRight'])
  461. camera.height = .5
  462. else:
  463. if idle_frame == 0:
  464. own["walk_idle_frame"] = own["framenum"]
  465. diff = own["framenum"] - idle_frame
  466. if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
  467. #print("you are idle", diff)
  468. cont.activate(camobj.actuators['idle_camRight'])
  469. camera.height = .9
  470. camera.min = 2
  471. camera.max = 2.50
  472. own['walk_idling'] = 1
  473. else:
  474. own['walk_idling'] = 0
  475. def idle_anim():
  476. if own['walk_idling'] == 1 and own['sit'] == 0:
  477. walk_idle_frame = own['walk_idle_frame']
  478. #print("walk_idling")
  479. mod_num = (own["framenum"] - walk_idle_frame) % 240
  480. #print(walk_idle_frame, mod_num)
  481. #killact(3)
  482. idle_lay = 300
  483. if mod_num == 0:
  484. if own['idle_skipper'] > 0:
  485. own['idle_skipper'] -= 1
  486. ran_num = random.randint(1, 8)
  487. print(ran_num, "modding")
  488. if own['last_idle_num'] == ran_num:
  489. ran_num = 1
  490. if own['idle_skipper'] == 0:
  491. own['last_idle_num'] = ran_num
  492. if ran_num == 1 or ran_num > 7:
  493. killact(3)
  494. if STANCE == 0 and own['throw_deck'] == 0:
  495. own['requestAction'] = 'reg_idle1'
  496. elif STANCE == 0 and own['throw_deck'] == 1:
  497. own['requestAction'] = 'reg_idle1'
  498. elif STANCE == 1 and own['throw_deck'] == 0:
  499. own['requestAction'] = 'fak_idle1'
  500. elif STANCE == 1 and own['throw_deck'] == 1:
  501. own['requestAction'] = 'fak_idle1'
  502. elif ran_num == 2:
  503. killact(3)
  504. if STANCE == 0 and own['throw_deck'] == 0:
  505. own['requestAction'] = 'reg_idle2'
  506. elif STANCE == 0 and own['throw_deck'] == 1:
  507. own['requestAction'] = 'reg_idle2_nb'
  508. elif STANCE == 1 and own['throw_deck'] == 0:
  509. own['requestAction'] = 'fak_idle1'
  510. elif STANCE == 1 and own['throw_deck'] == 1:
  511. own['requestAction'] = 'fak_idle1'
  512. elif ran_num == 3:
  513. killact(3)
  514. if STANCE == 0 and own['throw_deck'] == 0:
  515. own['requestAction'] = 'reg_idle3'
  516. elif STANCE == 0 and own['throw_deck'] == 1:
  517. own['requestAction'] = 'reg_idle3'
  518. elif STANCE == 1 and own['throw_deck'] == 0:
  519. own['requestAction'] = 'fak_idle1'
  520. elif STANCE == 1 and own['throw_deck'] == 1:
  521. own['requestAction'] = 'fak_idle1'
  522. own['idle_skipper'] = 2
  523. elif ran_num == 4:
  524. killact(3)
  525. if STANCE == 0 and own['throw_deck'] == 0:
  526. own['requestAction'] = 'reg_idle4'
  527. elif STANCE == 0 and own['throw_deck'] == 1:
  528. own['requestAction'] = 'reg_idle4'
  529. elif STANCE == 1 and own['throw_deck'] == 0:
  530. own['requestAction'] = 'fak_idle4'
  531. elif STANCE == 1 and own['throw_deck'] == 1:
  532. own['requestAction'] = 'fak_idle4'
  533. elif ran_num == 5:
  534. killact(3)
  535. if STANCE == 0 and own['throw_deck'] == 0:
  536. own['requestAction'] = 'reg_idle5'
  537. elif STANCE == 0 and own['throw_deck'] == 1:
  538. own['requestAction'] = 'reg_idle5'
  539. elif STANCE == 1 and own['throw_deck'] == 0:
  540. own['requestAction'] = 'fak_idle5'
  541. elif STANCE == 1 and own['throw_deck'] == 1:
  542. own['requestAction'] = 'fak_idle5'
  543. elif ran_num == 6:
  544. killact(3)
  545. if STANCE == 0 and own['throw_deck'] == 0:
  546. own['requestAction'] = 'reg_idle6'
  547. elif STANCE == 0 and own['throw_deck'] == 1:
  548. own['requestAction'] = 'reg_idle6'
  549. #skater.playAction("reg_idle6", 1,120, layer=idle_lay, play_mode=0, speed=.5)
  550. elif STANCE == 1 and own['throw_deck'] == 0:
  551. own['requestAction'] = 'fak_idle6'
  552. elif STANCE == 1 and own['throw_deck'] == 1:
  553. own['requestAction'] = 'fak_idle6'
  554. elif ran_num == 7:
  555. killact(3)
  556. if STANCE == 0 and own['throw_deck'] == 0:
  557. own['requestAction'] = 'reg_idle7'
  558. elif STANCE == 0 and own['throw_deck'] == 1:
  559. own['requestAction'] = 'reg_idle7'
  560. elif STANCE == 1 and own['throw_deck'] == 0:
  561. own['requestAction'] = 'fak_idle6'
  562. elif STANCE == 1 and own['throw_deck'] == 1:
  563. own['requestAction'] = 'fak_idle6'
  564. def reset_pos():
  565. #reset
  566. if ddPad == 1:
  567. spawn_pos = own['spawn_pos']
  568. spawn_rot = own['spawn_rot']
  569. #spawnz = spawn_pos[2] + .1
  570. try:
  571. own.worldPosition = (spawn_pos[0], spawn_pos[1], spawnz)
  572. 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]]
  573. except:
  574. own.worldPosition = (0, 0, .1)
  575. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  576. if own["spawn_stance"] == 1:
  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. else:
  584. own.setLinearVelocity([-.1,0,0], 1)
  585. #cam.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .25))
  586. #lx = cam.localPosition[1]
  587. #lx = lx - 4
  588. #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]]
  589. #cam.localPosition[1] = lx
  590. if udPad == 1:
  591. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  592. 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]]
  593. stance = own["stance"]
  594. own["spawn_stance"] = stance
  595. def falldeck():
  596. #print("falldeck")
  597. throw_deck_empty = scene.objects["throw_deck_empty"]
  598. deckact = deck.actuators["Visibility"]
  599. trucksact = trucks.actuators["Visibility"]
  600. wheel1act = wheel1.actuators["Visibility"]
  601. wheel2act = wheel2.actuators["Visibility"]
  602. wheel3act = wheel3.actuators["Visibility"]
  603. wheel4act = wheel4.actuators["Visibility"]
  604. if own['throw_deck'] == False:
  605. own['throw_deck'] = True
  606. deckact.visibility = False
  607. trucksact.visibility = False
  608. wheel1act.visibility = False
  609. wheel2act.visibility = False
  610. wheel3act.visibility = False
  611. wheel4act.visibility = False
  612. act = throw_deck_empty.actuators['throw_dec_act']
  613. if STANCE == True:
  614. act.linearVelocity = [0.0, 1.0, 1.0]
  615. if STANCE == False:
  616. act.linearVelocity = [0.0, 1.0, -1.0]
  617. cont.activate(act)
  618. else:
  619. own['throw_deck'] = False
  620. deckact.visibility = True
  621. trucksact.visibility = True
  622. wheel1act.visibility = True
  623. wheel2act.visibility = True
  624. wheel3act.visibility = True
  625. wheel4act.visibility = True
  626. throw_deck_empty['kill_deck'] = 1
  627. #print("trying to kill deck")
  628. cont.activate(deck.actuators['Visibility'])
  629. cont.activate(trucks.actuators['Visibility'])
  630. cont.activate(wheel1.actuators['Visibility'])
  631. cont.activate(wheel2.actuators['Visibility'])
  632. cont.activate(wheel3.actuators['Visibility'])
  633. cont.activate(wheel4.actuators['Visibility'])
  634. def throwdeck(strength, ud):
  635. throw_deck_empty = scene.objects["throw_deck_empty"]
  636. deckact = deck.actuators["Visibility"]
  637. trucksact = trucks.actuators["Visibility"]
  638. wheel1act = wheel1.actuators["Visibility"]
  639. wheel2act = wheel2.actuators["Visibility"]
  640. wheel3act = wheel3.actuators["Visibility"]
  641. wheel4act = wheel4.actuators["Visibility"]
  642. if own['throw_deck'] == False:
  643. own['throw_deck'] = True
  644. deckact.visibility = False
  645. trucksact.visibility = False
  646. wheel1act.visibility = False
  647. wheel2act.visibility = False
  648. wheel3act.visibility = False
  649. wheel4act.visibility = False
  650. act = throw_deck_empty.actuators['throw_dec_act']
  651. hard = strength * .08
  652. if hard > 9:
  653. hard = 9
  654. ud = ud * 4
  655. own['bbut_timer'] = 0
  656. if STANCE == True:
  657. own['requestAction'] = 'fak_throw'
  658. act.linearVelocity = [0.0, ud, hard]
  659. if STANCE == False:
  660. own['requestAction'] = 'fak_throw'
  661. act.linearVelocity = [0.0, ud, -hard]
  662. cont.activate(act)
  663. else:
  664. own['throw_deck'] = False
  665. deckact.visibility = True
  666. trucksact.visibility = True
  667. wheel1act.visibility = True
  668. wheel2act.visibility = True
  669. wheel3act.visibility = True
  670. wheel4act.visibility = True
  671. throw_deck_empty['kill_deck'] = 1
  672. cont.activate(deck.actuators['Visibility'])
  673. cont.activate(trucks.actuators['Visibility'])
  674. cont.activate(wheel1.actuators['Visibility'])
  675. cont.activate(wheel2.actuators['Visibility'])
  676. cont.activate(wheel3.actuators['Visibility'])
  677. cont.activate(wheel4.actuators['Visibility'])
  678. def throwdeck_trigger():
  679. lastb = own['lastb']
  680. throw_deck_empty = scene.objects["throw_deck_empty"]
  681. if bBut == True:
  682. own['bbut_timer'] += 1
  683. ud = (rUD * 10) +1
  684. if bBut == False:
  685. throw_deck_empty['kill_deck'] = 0
  686. if bBut == False and own['lastb'] == True:
  687. strength = own['bbut_timer']
  688. ud = (rUD * 10) +1
  689. throwdeck(strength, ud)
  690. def fall():
  691. if own['fall'] == True:
  692. falldeck()
  693. if STANCE == 1:
  694. own['requestAction'] = 'fak_fall1'
  695. own.setLinearVelocity([3,2,0], True)
  696. else:
  697. own['requestAction'] = 'reg_fall1'
  698. own.setLinearVelocity([-3,-2,0], True)
  699. own['fall'] = False
  700. def sit():
  701. #turn off sit
  702. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  703. if own['sit'] == 1:
  704. killact(300)
  705. killact(299)
  706. own['sit'] = 0
  707. if aBut == False and lasta == True:
  708. try:
  709. if 'sit' in r_ground.hitObject:
  710. print("sit")
  711. own['sit'] = 1
  712. #killall()
  713. killact(3)
  714. if STANCE == 0:
  715. own['requestAction'] = 'reg_sit'
  716. # skater.playAction("reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  717. # deck.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  718. # trucks.playAction("a_reg_sit", 1,65, layer=300, play_mode=0, speed=1)
  719. elif STANCE == 1:
  720. own['requestAction'] = 'fak_sit'
  721. # skater.playAction("fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  722. # deck.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  723. # trucks.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
  724. except:
  725. pass
  726. if own['sit'] == 1:
  727. try:
  728. killact(3)
  729. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  730. if STANCE == 0:
  731. own.alignAxisToVect(-sit_vect, 0, .2)
  732. own['requestAction'] = 'reg_sit'
  733. # skater.playAction("reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  734. # deck.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  735. # trucks.playAction("a_reg_sit", 65,65, layer=299, play_mode=1, speed=1)
  736. elif STANCE == 1:
  737. own['requestAction'] = 'fak_sit'
  738. own.alignAxisToVect(sit_vect, 0, .2)
  739. # skater.playAction("fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  740. # deck.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  741. # trucks.playAction("a_fak_sit", 65,65, layer=299, play_mode=1, speed=1)
  742. except:
  743. pass
  744. def switchcam():
  745. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  746. if own['camera'] == 1:
  747. own['camera'] = 0
  748. else:
  749. own['camera'] = 1
  750. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  751. if own['camera'] == 2:
  752. own['camera'] = 0
  753. else:
  754. own['camera'] = 2
  755. #followcam
  756. def move_followcam():
  757. if own['camera'] == 2:
  758. #if rtsBut == False and own['lastrts'] == True:
  759. if own['lastbkBut'] == True and bkBut == False:
  760. print("activate move followcam")
  761. if own['move_followcam'] == False:
  762. own['move_followcam'] = True
  763. else:
  764. own['move_followcam'] = False
  765. if own['move_followcam'] == True:
  766. #act = followcam.actuators[
  767. camspeed1 = .015
  768. camspeed2 = .055
  769. camrot1 = .005
  770. camrot2 = .02
  771. #up
  772. if lUD < -0.080:
  773. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  774. cont.activate(followcam.actuators["up"])
  775. print("fastup")
  776. else:
  777. cont.deactivate(followcam.actuators["up"])
  778. # #down
  779. if lUD > .080:
  780. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  781. cont.activate(followcam.actuators["down"])
  782. else:
  783. cont.deactivate(followcam.actuators["down"])
  784. # #left
  785. if lLR < -0.080:
  786. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  787. cont.activate(followcam.actuators["left"])
  788. else:
  789. cont.deactivate(followcam.actuators["left"])
  790. # #right
  791. if lLR > 0.080:
  792. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  793. cont.activate(followcam.actuators["right"])
  794. else:
  795. cont.deactivate(followcam.actuators["right"])
  796. #up
  797. if rUD < -0.080:
  798. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  799. cont.activate(followcam.actuators["rotup"])
  800. #print("uppppppppppppppppppppppppppp")
  801. else:
  802. cont.deactivate(followcam.actuators["rotup"])
  803. # #down
  804. if rUD > .080:
  805. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  806. cont.activate(followcam.actuators["rotdown"])
  807. else:
  808. cont.deactivate(followcam.actuators["rotdown"])
  809. # #left
  810. if rLR < -0.080:
  811. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  812. cont.activate(followcam.actuators["rotleft"])
  813. else:
  814. cont.deactivate(followcam.actuators["rotleft"])
  815. # #right
  816. if rLR > 0.080:
  817. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  818. cont.activate(followcam.actuators["rotright"])
  819. else:
  820. cont.deactivate(followcam.actuators["rotright"])
  821. #*********************************************
  822. if lUD > -0.080 and lUD < -0.030:
  823. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  824. cont.activate(followcam.actuators["up"])
  825. #print(lUD)
  826. else:
  827. cont.deactivate(followcam.actuators["up"])
  828. # #down
  829. if lUD < .080 and lUD > .03:
  830. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  831. cont.activate(followcam.actuators["down"])
  832. else:
  833. cont.deactivate(followcam.actuators["down"])
  834. # #left
  835. if lLR > -0.080 and lLR < -0.030:
  836. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  837. cont.activate(followcam.actuators["left"])
  838. else:
  839. cont.deactivate(followcam.actuators["left"])
  840. # #right
  841. if lLR < .080 and lLR > .03:
  842. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  843. cont.activate(followcam.actuators["right"])
  844. else:
  845. cont.deactivate(followcam.actuators["right"])
  846. #up
  847. if rUD > -0.080 and rUD < -0.030:
  848. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  849. cont.activate(followcam.actuators["rotup"])
  850. else:
  851. cont.deactivate(followcam.actuators["rotup"])
  852. # #down
  853. if rUD < .080 and rUD > .03:
  854. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  855. cont.activate(followcam.actuators["rotdown"])
  856. else:
  857. cont.deactivate(followcam.actuators["rotdown"])
  858. # #left
  859. if rLR > -0.080 and rLR < -0.030:
  860. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  861. cont.activate(followcam.actuators["rotleft"])
  862. else:
  863. cont.deactivate(followcam.actuators["rotleft"])
  864. # #right
  865. if rLR < .080 and rLR > .03:
  866. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  867. cont.activate(followcam.actuators["rotright"])
  868. else:
  869. cont.deactivate(followcam.actuators["rotright"])
  870. def move_flycam():
  871. if own['camera'] == 1:
  872. #if rtsBut == False and own['lastrts'] == True:
  873. if own['lastbkBut'] == True and bkBut == False:
  874. if own['move_freecam'] == False:
  875. own['move_freecam'] = True
  876. else:
  877. own['move_freecam'] = False
  878. if own['move_freecam'] == True:
  879. #act = freecam.actuators[
  880. camspeed1 = .015
  881. camspeed2 = .055
  882. camrot1 = .005
  883. camrot2 = .02
  884. #up
  885. if lUD < -0.080:
  886. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  887. cont.activate(freecam.actuators["up"])
  888. #print("fastup")
  889. else:
  890. cont.deactivate(freecam.actuators["up"])
  891. # #down
  892. if lUD > .080:
  893. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  894. cont.activate(freecam.actuators["down"])
  895. else:
  896. cont.deactivate(freecam.actuators["down"])
  897. # #left
  898. if lLR < -0.080:
  899. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  900. cont.activate(freecam.actuators["left"])
  901. else:
  902. cont.deactivate(freecam.actuators["left"])
  903. # #right
  904. if lLR > 0.080:
  905. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  906. cont.activate(freecam.actuators["right"])
  907. else:
  908. cont.deactivate(freecam.actuators["right"])
  909. #up
  910. if rUD < -0.080:
  911. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  912. cont.activate(freecam.actuators["rotup"])
  913. else:
  914. cont.deactivate(freecam.actuators["rotup"])
  915. # #down
  916. if rUD > .080:
  917. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  918. cont.activate(freecam.actuators["rotdown"])
  919. else:
  920. cont.deactivate(freecam.actuators["rotdown"])
  921. # #left
  922. if rLR < -0.080:
  923. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  924. cont.activate(freecam.actuators["rotleft"])
  925. else:
  926. cont.deactivate(freecam.actuators["rotleft"])
  927. # #right
  928. if rLR > 0.080:
  929. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  930. cont.activate(freecam.actuators["rotright"])
  931. else:
  932. cont.deactivate(freecam.actuators["rotright"])
  933. #*********************************************
  934. if lUD > -0.080 and lUD < -0.030:
  935. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  936. cont.activate(freecam.actuators["up"])
  937. #print(lUD)
  938. else:
  939. cont.deactivate(freecam.actuators["up"])
  940. # #down
  941. if lUD < .080 and lUD > .03:
  942. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  943. cont.activate(freecam.actuators["down"])
  944. else:
  945. cont.deactivate(freecam.actuators["down"])
  946. # #left
  947. if lLR > -0.080 and lLR < -0.030:
  948. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  949. cont.activate(freecam.actuators["left"])
  950. else:
  951. cont.deactivate(freecam.actuators["left"])
  952. # #right
  953. if lLR < .080 and lLR > .03:
  954. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  955. cont.activate(freecam.actuators["right"])
  956. else:
  957. cont.deactivate(freecam.actuators["right"])
  958. #up
  959. if rUD > -0.080 and rUD < -0.030:
  960. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  961. cont.activate(freecam.actuators["rotup"])
  962. else:
  963. cont.deactivate(freecam.actuators["rotup"])
  964. # #down
  965. if rUD < .080 and rUD > .03:
  966. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  967. cont.activate(freecam.actuators["rotdown"])
  968. else:
  969. cont.deactivate(freecam.actuators["rotdown"])
  970. # #left
  971. if rLR > -0.080 and rLR < -0.030:
  972. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  973. cont.activate(freecam.actuators["rotleft"])
  974. else:
  975. cont.deactivate(freecam.actuators["rotleft"])
  976. # #right
  977. if rLR < .080 and rLR > .03:
  978. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  979. cont.activate(freecam.actuators["rotright"])
  980. else:
  981. cont.deactivate(freecam.actuators["rotright"])
  982. if r_ground.triggered == False:
  983. cont.deactivate(own.actuators["walk_align"])
  984. else:
  985. cont.activate(own.actuators["walk_align"])
  986. #walking on stairs
  987. if r_ground.triggered:
  988. try:
  989. if 'stair' in r_ground.hitObject:
  990. own['stair_counter'] = 20
  991. force = [ 0.0, 0.0, -100]
  992. # use local axis
  993. local = True
  994. # apply force
  995. #own.applyForce(force, local)
  996. except:
  997. pass
  998. if own['stair_counter'] > 0:
  999. own['stair_counter'] -= 1
  1000. if yBut == True:
  1001. own['walk_idling'] = 0
  1002. own["walk_idle_frame"] = 0
  1003. #if own['requestAction'] == None:
  1004. # if own['throw_deck'] == False:
  1005. # if STANCE == 1:
  1006. # own['requestAction'] = reg_idle
  1007. # else:
  1008. # own['requestAction'] = fak_idle
  1009. # else:
  1010. # if STANCE == 1:
  1011. # own['requestAction'] = reg_idle_nb
  1012. # else:
  1013. # own['requestAction'] = fak_idle_nb
  1014. if deck.visible:
  1015. own['deckvis'] = 1
  1016. else:
  1017. own['deckvis'] = 0
  1018. if own['requestAction'] == 'empty' or own['requestAction'] == None:
  1019. if STANCE == 0:
  1020. own['requestAction'] = 'reg_idle1'
  1021. if STANCE == 1:
  1022. own['requestAction'] = 'fak_idle1'
  1023. onboard()
  1024. jump()
  1025. dropin()
  1026. throwdeck_trigger()
  1027. nextframe()
  1028. checkidle()
  1029. getonboard()
  1030. reset_pos()
  1031. switchcam()
  1032. move_flycam()
  1033. move_followcam()
  1034. fall()
  1035. idle_anim()
  1036. sit()
  1037. #cont.activate(cam.actuators['Camera'])
  1038. #printplaying()
  1039. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1040. own.actuators["sroll"].stopSound()
  1041. wheel1 = scene.objects["rollen.000"]
  1042. wheel2 = scene.objects["rollen.001"]
  1043. wheel3 = scene.objects["rollen.002"]
  1044. wheel4 = scene.objects["rollen.003"]
  1045. wheel1.stopAction(2)
  1046. wheel2.stopAction(2)
  1047. wheel3.stopAction(2)
  1048. wheel4.stopAction(2)
  1049. own['lasty'] = yBut
  1050. own['lastb'] = bBut
  1051. own['lasta'] = aBut
  1052. own['lastx'] = xBut
  1053. own['lastlts'] = ltsBut
  1054. own['lastrts'] = rtsBut
  1055. own['lastbkBut'] = bkBut
  1056. own['dropinCol'] = dropinCol
  1057. own['walk'] = 1