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

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