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. truckon = 450
  27. deckon = 460
  28. lLR = dict['lLR']
  29. lUD = dict['lUD']
  30. rLR = dict['rLR']
  31. rUD = dict['rUD']
  32. lTrig = dict['lTrig']
  33. rTrig = dict['rTrig']
  34. aBut = dict['aBut']
  35. bBut = dict['bBut']
  36. xBut = dict['xBut']
  37. yBut = dict['yBut']
  38. lBump = dict['lBump']
  39. rBump = dict['rBump']
  40. bkBut = dict['bkBut']
  41. stBut = dict['stBut']
  42. xbBut = dict['xbBut']
  43. ltsBut = dict['ltsBut']
  44. rtsBut = dict['rtsBut']
  45. ldPad = dict['ldPad']
  46. rdPad = dict['rdPad']
  47. udPad = dict['udPad']
  48. ddPad = dict['ddPad']
  49. #user
  50. sens = .04
  51. fliplay = 30
  52. dropinCol = own.sensors['dropinCol']
  53. cube = scene.objects['control_cube.002']
  54. skater = scene.objects["Char4"]
  55. deck = scene.objects["deck"]
  56. trucks = scene.objects["trucks"]
  57. camobj2 = scene.objects['camobj']
  58. throw_deck_empty = scene.objects["throw_deck_empty"]
  59. wheel1 = scene.objects["rollen.000"]
  60. wheel2 = scene.objects["rollen.001"]
  61. wheel3 = scene.objects["rollen.002"]
  62. wheel4 = scene.objects["rollen.003"]
  63. camobj = scene.objects["Camera.003"]
  64. camera = cont.actuators["Camera"]
  65. replayCam = cont.actuators["replayCam"]
  66. timer = own['dropinTimer']
  67. cam = scene.objects["Camera.003"]
  68. freecam = scene.objects["freecam"]
  69. followcam = scene.objects["followcam"]
  70. control_bottom = scene.objects['control_bottom']
  71. cb = control_bottom.sensors['grindCol_bottom']
  72. cb_td = control_bottom.sensors['td_bottom']
  73. noidle = 0
  74. #if skater.isPlayingAction(460):
  75. # noidle = 1
  76. walk_inc = own['walk_inc']
  77. if own['stair_counter'] != 0:
  78. walk_inc = own['walk_inc'] *10
  79. if own["stance"] == None:
  80. own["stance"] = True
  81. STANCE = own["stance"]
  82. def killact(layer):
  83. if skater.isPlayingAction(layer):
  84. skater.stopAction(layer)
  85. if deck.isPlayingAction(layer):
  86. deck.stopAction(layer)
  87. if trucks.isPlayingAction(layer):
  88. trucks.stopAction(layer)
  89. def killall():
  90. for x in range(5000):
  91. skater.stopAction(x)
  92. deck.stopAction(x)
  93. trucks.stopAction(x)
  94. def trucksisplaying():
  95. for x in range(5000):
  96. if deck.isPlayingAction(x):
  97. print("deck is playing:", x)
  98. def printplaying():
  99. splaying_layers = "S: "
  100. playing_layers = "D: "
  101. tplaying_layers = "T: "
  102. for x in range(9900):
  103. if skater.isPlayingAction(x):
  104. #if trucks.isPlayingAction(x):
  105. #if skater.isPlayingAction(x):
  106. splaying_layers += str(x)
  107. splaying_layers += " "
  108. if deck.isPlayingAction(x):
  109. #if trucks.isPlayingAction(x):
  110. #if skater.isPlayingAction(x):
  111. playing_layers += str(x)
  112. playing_layers += " "
  113. if trucks.isPlayingAction(x):
  114. #if trucks.isPlayingAction(x):
  115. #if skater.isPlayingAction(x):
  116. tplaying_layers += str(x)
  117. tplaying_layers += " "
  118. print(splaying_layers, playing_layers, tplaying_layers)
  119. #printplaying()
  120. ##
  121. if r_ground.positive and xBut == False and lastx == False:
  122. killact(10)
  123. #killact(11)
  124. killact(12)
  125. killact(13)
  126. ######################################
  127. #idle
  128. 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:
  129. own['requestAction'] = 'reg_idle'
  130. if own['throw_deck'] == True:
  131. own['requestAction'] = 'reg_idle_nb'
  132. 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:
  133. own['requestAction'] = 'fak_idle'
  134. if own['throw_deck'] == True:
  135. own['requestAction'] = 'fak_idle_nb'
  136. if lUD < -sens:
  137. lup = 1
  138. else:
  139. lup = 0
  140. if lUD > sens:
  141. ldown = 1
  142. else:
  143. ldown = 0
  144. if lLR < -sens:
  145. lLeft = 1
  146. else:
  147. lLeft = 0
  148. if lLR > sens:
  149. lRight = 1
  150. else:
  151. lRight = 0
  152. #turning
  153. turning = False
  154. if r_ground.positive:
  155. num = .5
  156. tilt = .015
  157. if STANCE == 1:
  158. num *= -1
  159. tilt *= -1
  160. if lRight == 1 or dict['kb_ra'] == 2:
  161. #cont.activate(own.actuators['right'])
  162. own.linearVelocity.y = num
  163. if own['stair_counter'] > 0:
  164. if STANCE == 0:
  165. own.applyRotation([0,0,.05], True)
  166. else:
  167. own.applyRotation([0,0,-.05], True)
  168. else:
  169. own.applyRotation([-tilt, 0, 0], True)
  170. turning = True
  171. else:
  172. #cont.deactivate(own.actuators['right'])
  173. pass
  174. if lLeft == 1 or dict['kb_la'] == 2:
  175. #cont.activate(own.actuators['left'])
  176. own.linearVelocity.y = -num
  177. if own['stair_counter'] > 0:
  178. if STANCE == 0:
  179. own.applyRotation([0,0,.05], True)
  180. else:
  181. own.applyRotation([0,0,-.05], True)
  182. else:
  183. own.applyRotation([tilt, 0, 0], True)
  184. turning = True
  185. else:
  186. #cont.deactivate(own.actuators['left'])
  187. pass
  188. #in air
  189. #if (lup == 1 or dict['kb_ua'] != 0) and r_ground.positive == False:
  190. if r_ground.positive == False:
  191. airrot = .05
  192. if lLeft == 1 or dict['kb_la'] == 2:
  193. if stance == 0:
  194. own.applyRotation([0,0,airrot], True)
  195. if stance == 1:
  196. own.applyRotation([0,0,airrot], True)
  197. if lRight == 1 or dict['kb_ra'] == 2:
  198. if stance == 0:
  199. own.applyRotation([0,0,-airrot], True)
  200. if stance == 1:
  201. own.applyRotation([0,0,-airrot], True)
  202. own['lF_air_frame'] = own['framenum']
  203. #walking
  204. #new walking
  205. vel = own.getLinearVelocity(True)
  206. if own['walk_timer'] < 50:
  207. velx = vel.x * .95
  208. own.setLinearVelocity([velx, 0, vel.z], True)
  209. #print('y is zero')
  210. else:
  211. pass
  212. #own.setLinearVelocity([0, 0, vel.z], True)
  213. wf = 1
  214. if own['last_walk_frame'] - own['last_roll_frame'] > 55:
  215. wf = 0
  216. 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:
  217. own['walking'] = "regular"
  218. walking = "regular"
  219. 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:
  220. own['walking'] = "fast"
  221. walking = "fast"
  222. else:
  223. own['walking'] = None
  224. walking = None
  225. if walking == "regular":
  226. #if linvel.x < own['walk_targ_speed']:
  227. #cont.deactivate(own.actuators['forward2'])
  228. #cont.deactivate(own.actuators['backward2'])
  229. if stance == 1:
  230. if linvel.x < own['walk_targ_speed']:
  231. own.linearVelocity.x = linvel.x + walk_inc
  232. else:
  233. own.linearVelocity.x = own['walk_targ_speed']
  234. #cont.activate(own.actuators['forward'])
  235. else:
  236. if linvel.x > -own['walk_targ_speed']:
  237. own.linearVelocity.x = linvel.x - walk_inc
  238. else:
  239. own.linearVelocity.x = -own['walk_targ_speed']
  240. #cont.activate(own.actuators['backward'])
  241. if walking == "fast":
  242. #cont.deactivate(own.actuators['forward'])
  243. #cont.deactivate(own.actuators['backward'])
  244. if stance == 1:
  245. if linvel.x < own['walk_fast_targ_speed']:
  246. own.linearVelocity.x = linvel.x + walk_inc
  247. else:
  248. own.linearVelocity.x = own['walk_fast_targ_speed']
  249. else:
  250. if linvel.x > -own['walk_fast_targ_speed']:
  251. own.linearVelocity.x = linvel.x - walk_inc
  252. else:
  253. own.linearVelocity.x = -own['walk_fast_targ_speed']
  254. if walking == None and r_ground.positive and own['walk_jump_timer'] == 0:
  255. #cont.deactivate(own.actuators['forward2'])
  256. #cont.deactivate(own.actuators['backward2'])
  257. #cont.deactivate(own.actuators['forward'])
  258. #cont.deactivate(own.actuators['backward'])
  259. if own['walk_timer'] < 50 and turning == False:
  260. velx = vel.x * .95
  261. own.setLinearVelocity([velx, 0, vel.z], True)
  262. #print('minusvel', velx)
  263. else:
  264. #pass
  265. print('minusvel')
  266. if own.linearVelocity.x > .1 or own.linearVelocity.x < -.1:
  267. own.linearVelocity.x *= .01
  268. else:
  269. own.linearVelocity.x = 0
  270. if turning == False:
  271. if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
  272. own.linearVelocity.y *= .01
  273. else:
  274. own.linearVelocity.y = 0
  275. #own.setLinearVelocity([0, 0, vel.z], True)
  276. #old walking
  277. 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):
  278. own.actuators["walkondirt"].volume = .2
  279. own.actuators["walkondirt"].pitch = 1
  280. cont.activate(own.actuators["walkondirt"])
  281. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  282. #without deck
  283. if own['throw_deck'] == True:
  284. own['requestAction'] = 'reg_walk_nb'
  285. else:
  286. own['requestAction'] = 'reg_walk'
  287. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  288. #without deck
  289. if own['throw_deck'] == True:
  290. own['requestAction'] = 'fak_walk_nb'
  291. else:
  292. own['requestAction'] = 'fak_walk'
  293. 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):
  294. own.actuators["walkondirt"].volume = .2
  295. own.actuators["walkondirt"].pitch = 1.3
  296. cont.activate(own.actuators["walkondirt"])
  297. print('fastwalk')
  298. if stance == 0 and skater.isPlayingAction(fliplay) == False:
  299. if own['throw_deck'] == True:
  300. own['requestAction'] = 'reg_walkFast_nb'
  301. else:
  302. own['requestAction'] = 'reg_walkFast'
  303. if stance == 1 and skater.isPlayingAction(fliplay) == False:
  304. if own['throw_deck'] == True:
  305. own['requestAction'] = 'fak_walkFast_nb'
  306. else:
  307. own['requestAction'] = 'fak_walkFast'
  308. else:
  309. vel = own.getLinearVelocity(True)
  310. cont.deactivate(own.actuators["walkondirt"])
  311. #---------------
  312. if rLR > .05:
  313. cont.activate(camobj.actuators['camRight'])
  314. else:
  315. cont.deactivate(camobj.actuators['camRight'])
  316. if rLR < -.05:
  317. cont.activate(camobj.actuators['camLeft'])
  318. else:
  319. cont.deactivate(camobj.actuators['camLeft'])
  320. if rUD > .05:
  321. cont.activate(camobj.actuators['camDown'])
  322. else:
  323. cont.deactivate(camobj.actuators['camDown'])
  324. if rUD < -.05:
  325. cont.activate(camobj.actuators['camUp'])
  326. else:
  327. cont.deactivate(camobj.actuators['camUp'])
  328. #----------------
  329. camera.height = .01 #.9
  330. camera.min = 1.75
  331. camera.max = 2.25
  332. lasty = own['lasty']
  333. def onboard():
  334. if own['walk'] == 0:
  335. print("start walking")
  336. own['walk_idling'] = 0
  337. if own['framenum'] > 100 and own['fall'] == False:
  338. cont.activate(own.actuators['pop'])
  339. own['getoffboard'] = False
  340. own["walk_idle_frame"] = own["framenum"]
  341. own['grindcement_vol'] = 0
  342. own['grindcement_pitch'] = 0
  343. own['grindrail_vol'] = 0
  344. own['grindrail_pitch'] = 0
  345. own['sroll_vol'] = 0
  346. own['sroll_pitch'] = 0
  347. #camobj.worldPosition.z += 4
  348. try:
  349. vel = own['offboard_vel']
  350. vel = [velx, vel.y, vel.z]
  351. except:
  352. pass
  353. if STANCE == 0:
  354. own['requestAction'] = 'reg_offboard'
  355. if STANCE == 1:
  356. own['requestAction'] = 'fak_offboard'
  357. def jump():
  358. #limit fall speed
  359. if linvel.z < -10:
  360. own.linearVelocity.z = -10
  361. if xBut == True or dict['kb_space'] == 1:
  362. if own['lastx'] == 0:
  363. #killact(3)
  364. #killact(4)
  365. #killact(5)
  366. #killact(6)
  367. #killact(7)
  368. if STANCE == 0:
  369. own['requestAction'] ='reg_jump'
  370. print('jump')
  371. if STANCE == 1:
  372. own['requestAction'] ='fak_jump'
  373. print('jump')
  374. JUMPHEIGHT = 1100
  375. force = [ 0.0, 0.0, JUMPHEIGHT]
  376. # use local axis
  377. local = False
  378. # apply force -- limit jump speed
  379. if linvel.z < 10:
  380. #own.applyForce(force, local)
  381. own.linearVelocity.z += 5
  382. own.linearVelocity.x = linvel.x
  383. own.linearVelocity.y = linvel.y
  384. own['walk_jump_timer'] = 20
  385. own['lastx'] = 1
  386. else:
  387. own['lastx'] = 0
  388. def dropin():
  389. if dropinCol.positive == True:
  390. pass
  391. def getonboard(dict):
  392. #print(dict['kb_q'])
  393. getonboard = own['getonboard']
  394. fliplay2 = 50#8560
  395. if ((yBut == True and dict['last_yBut'] == False) or dict['kb_q'] == 2):# and (cont.sensors["vehicleNear"].positive == False and own['throw_deck'] == False):
  396. fliplay3 = fliplay2 + 1
  397. if dropinCol.positive == True:
  398. nearestObject = None
  399. grindEmpty = scene.objects['grindEmpty']
  400. grindDar = grindEmpty.sensors['grindDar2']
  401. minDist = None
  402. if grindDar.positive:
  403. detectedObjects = grindDar.hitObjectList
  404. dist = 0
  405. for obj in detectedObjects:
  406. dist = own.getDistanceTo(obj)
  407. if (minDist is None or dist < minDist):
  408. nearestObject = obj
  409. minDist = dist
  410. if nearestObject != None:
  411. print(nearestObject)
  412. obj = nearestObject
  413. player_e = own.worldOrientation.to_euler()
  414. player_pos = own.worldPosition
  415. player_rotz = math.degrees(player_e[2])
  416. grinder_e = obj.worldOrientation.to_euler()
  417. grinder_rotz = math.degrees(grinder_e[2])
  418. rot = player_rotz - grinder_rotz
  419. grinder_pos = obj.worldPosition
  420. worldVect = [1, 0, 0]
  421. vect = obj.getAxisVect(worldVect)
  422. go = obj.worldOrientation
  423. grinder_axis = [1,0,0]
  424. try:
  425. delta = player_pos - grinder_pos
  426. delta = delta.cross(vect)
  427. if delta[2] >= 0:
  428. grindside = "right"
  429. else:
  430. grindside = "left"
  431. deltamove = delta[2] * .1#.25
  432. if STANCE == 0:
  433. move = [-deltamove, 0, 0]
  434. else:
  435. move = [deltamove, 0, 0]
  436. own.applyMovement(move, True)
  437. except:
  438. pass
  439. if STANCE == 0:
  440. own['requestAction'] ='reg_dropin_pos'
  441. own['dropinTimer'] = 60
  442. if STANCE == 1:
  443. own['requestAction'] ='fak_dropin_pos'
  444. own['dropinTimer'] = 60
  445. if getonboard == 1:
  446. fliplay3 = 6000
  447. onboard_speed = .1
  448. own['getonboard'] = 0
  449. own['walk_idling'] = 0
  450. if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 2) and dropinCol.positive:
  451. deckact = deck.actuators["Visibility"]
  452. trucksact = trucks.actuators["Visibility"]
  453. wheel1act = wheel1.actuators["Visibility"]
  454. wheel2act = wheel2.actuators["Visibility"]
  455. wheel3act = wheel3.actuators["Visibility"]
  456. wheel4act = wheel4.actuators["Visibility"]
  457. deckact.visibility = True
  458. trucksact.visibility = True
  459. wheel1act.visibility = True
  460. wheel2act.visibility = True
  461. wheel3act.visibility = True
  462. wheel4act.visibility = True
  463. cont.activate(deck.actuators['Visibility'])
  464. cont.activate(trucks.actuators['Visibility'])
  465. cont.activate(wheel1.actuators['Visibility'])
  466. cont.activate(wheel2.actuators['Visibility'])
  467. cont.activate(wheel3.actuators['Visibility'])
  468. cont.activate(wheel4.actuators['Visibility'])
  469. own['throw_deck'] = False
  470. throw_deck_empty = scene.objects["throw_deck_empty"]
  471. throw_deck_empty['kill_deck'] = 1
  472. if ((yBut == False and lasty == True) or dict['kb_q'] == 3):# and cont.sensors["vehicleNear"].positive == False:
  473. own['getonboard'] = 1
  474. own['walk_idling'] = 0
  475. def nextframe():
  476. framenumber = own["framenum"]
  477. framenumber = framenumber + 1
  478. if framenumber == 900000:
  479. framenumber = 0
  480. own["framenum"] = framenumber
  481. own['last_walk_frame'] = framenumber
  482. def checkidle():
  483. idle = cont.sensors["idle"]
  484. idle_frame = own["walk_idle_frame"]
  485. if idle.positive:
  486. own["walk_idle_frame"] = 0
  487. cont.deactivate(camobj.actuators['idle_camRight'])
  488. camera.height = .5
  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