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

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