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

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