Shuvit game master repo. http://shuvit.org
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

walk.py 53KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  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. 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'] = 6
  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. if 'coping' in x:
  400. dar = 1
  401. if dropinCol.positive == True or dar == 1:
  402. nearestObject = None
  403. grindEmpty = scene.objects['grindEmpty']
  404. grindDar = grindEmpty.sensors['grindDar2']
  405. minDist = None
  406. if grindDar.positive:
  407. detectedObjects = grindDar.hitObjectList
  408. dist = 0
  409. for obj in detectedObjects:
  410. dist = own.getDistanceTo(obj)
  411. if (minDist is None or dist < minDist):
  412. nearestObject = obj
  413. minDist = dist
  414. # if nearestObject != None:
  415. # #print(nearestObject)
  416. # obj = nearestObject
  417. # player_e = own.worldOrientation.to_euler()
  418. # player_pos = own.worldPosition
  419. # player_rotz = math.degrees(player_e[2])
  420. # grinder_e = obj.worldOrientation.to_euler()
  421. # grinder_rotz = math.degrees(grinder_e[2])
  422. # rot = player_rotz - grinder_rotz
  423. # grinder_pos = obj.worldPosition
  424. # worldVect = [1, 0, 0]
  425. # vect = obj.getAxisVect(worldVect)
  426. # go = obj.worldOrientation
  427. # grinder_axis = [1,0,0]
  428. # try:
  429. # delta = player_pos - grinder_pos
  430. # delta = delta.cross(vect)
  431. # if delta[2] >= 0:
  432. # grindside = "right"
  433. # else:
  434. # grindside = "left"
  435. # deltamove = delta[2] * .1#.25
  436. # if STANCE == 0:
  437. # move = [-deltamove, 0, 0]
  438. # else:
  439. # move = [deltamove, 0, 0]
  440. # own.applyMovement(move, True)
  441. # except:
  442. # pass
  443. print('dropin')
  444. if STANCE == 0:
  445. own['requestAction'] ='reg_dropin_pos'
  446. own['dropinTimer'] = 60
  447. if STANCE == 1:
  448. own['requestAction'] ='fak_dropin_pos'
  449. own['dropinTimer'] = 60
  450. if getonboard == 1:
  451. fliplay3 = 6000
  452. onboard_speed = .1
  453. own['getonboard'] = 0
  454. own['walk_idling'] = 0
  455. if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 2) and dropinCol.positive:
  456. deckact = deck.actuators["Visibility"]
  457. trucksact = trucks.actuators["Visibility"]
  458. wheel1act = wheel1.actuators["Visibility"]
  459. wheel2act = wheel2.actuators["Visibility"]
  460. wheel3act = wheel3.actuators["Visibility"]
  461. wheel4act = wheel4.actuators["Visibility"]
  462. deckact.visibility = True
  463. trucksact.visibility = True
  464. wheel1act.visibility = True
  465. wheel2act.visibility = True
  466. wheel3act.visibility = True
  467. wheel4act.visibility = True
  468. cont.activate(deck.actuators['Visibility'])
  469. cont.activate(trucks.actuators['Visibility'])
  470. cont.activate(wheel1.actuators['Visibility'])
  471. cont.activate(wheel2.actuators['Visibility'])
  472. cont.activate(wheel3.actuators['Visibility'])
  473. cont.activate(wheel4.actuators['Visibility'])
  474. own['throw_deck'] = False
  475. throw_deck_empty = scene.objects["throw_deck_empty"]
  476. throw_deck_empty['kill_deck'] = 1
  477. if ((yBut == False and lasty == True) or dict['kb_q'] == 3):# and cont.sensors["vehicleNear"].positive == False:
  478. own['getonboard'] = 1
  479. own['walk_idling'] = 0
  480. def nextframe():
  481. framenumber = own["framenum"]
  482. framenumber = framenumber + 1
  483. if framenumber == 900000:
  484. framenumber = 0
  485. own["framenum"] = framenumber
  486. own['last_walk_frame'] = framenumber
  487. def checkidle():
  488. idle = cont.sensors["idle"]
  489. idle_frame = own["walk_idle_frame"]
  490. if idle.positive:
  491. own["walk_idle_frame"] = 0
  492. cont.deactivate(camobj.actuators['idle_camRight'])
  493. #camera.height = .5
  494. camera.height = dict['cam_idle_height']
  495. else:
  496. if idle_frame == 0:
  497. own["walk_idle_frame"] = own["framenum"]
  498. diff = own["framenum"] - idle_frame
  499. if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
  500. cont.activate(camobj.actuators['idle_camRight'])
  501. #camera.height = .9
  502. #camera.min = 2
  503. #camera.max = 2.50
  504. own['walk_idling'] = 1
  505. else:
  506. own['walk_idling'] = 0
  507. def idle_anim():
  508. if own['walk_idling'] == 1 and own['sit'] == 0:
  509. walk_idle_frame = own['walk_idle_frame']
  510. mod_num = (own["framenum"] - walk_idle_frame) % 240
  511. idle_lay = 300
  512. if mod_num == 0:
  513. if own['idle_skipper'] > 0:
  514. own['idle_skipper'] -= 1
  515. ran_num = random.randint(1, 8)
  516. if own['last_idle_num'] == ran_num:
  517. ran_num = 1
  518. if own['idle_skipper'] == 0:
  519. own['last_idle_num'] = ran_num
  520. if ran_num == 1 or ran_num > 7:
  521. killact(3)
  522. if STANCE == 0 and own['throw_deck'] == 0:
  523. own['requestAction'] = 'reg_idle1'
  524. elif STANCE == 0 and own['throw_deck'] == 1:
  525. own['requestAction'] = 'reg_idle1'
  526. elif STANCE == 1 and own['throw_deck'] == 0:
  527. own['requestAction'] = 'fak_idle1'
  528. elif STANCE == 1 and own['throw_deck'] == 1:
  529. own['requestAction'] = 'fak_idle1'
  530. elif ran_num == 2:
  531. killact(3)
  532. if STANCE == 0 and own['throw_deck'] == 0:
  533. own['requestAction'] = 'reg_idle2'
  534. elif STANCE == 0 and own['throw_deck'] == 1:
  535. own['requestAction'] = 'reg_idle2_nb'
  536. elif STANCE == 1 and own['throw_deck'] == 0:
  537. own['requestAction'] = 'fak_idle1'
  538. elif STANCE == 1 and own['throw_deck'] == 1:
  539. own['requestAction'] = 'fak_idle1'
  540. elif ran_num == 3:
  541. killact(3)
  542. if STANCE == 0 and own['throw_deck'] == 0:
  543. own['requestAction'] = 'reg_idle3'
  544. elif STANCE == 0 and own['throw_deck'] == 1:
  545. own['requestAction'] = 'reg_idle3'
  546. elif STANCE == 1 and own['throw_deck'] == 0:
  547. own['requestAction'] = 'fak_idle1'
  548. elif STANCE == 1 and own['throw_deck'] == 1:
  549. own['requestAction'] = 'fak_idle1'
  550. own['idle_skipper'] = 2
  551. elif ran_num == 4:
  552. killact(3)
  553. if STANCE == 0 and own['throw_deck'] == 0:
  554. own['requestAction'] = 'reg_idle4'
  555. elif STANCE == 0 and own['throw_deck'] == 1:
  556. own['requestAction'] = 'reg_idle4'
  557. elif STANCE == 1 and own['throw_deck'] == 0:
  558. own['requestAction'] = 'fak_idle4'
  559. elif STANCE == 1 and own['throw_deck'] == 1:
  560. own['requestAction'] = 'fak_idle4'
  561. elif ran_num == 5:
  562. killact(3)
  563. if STANCE == 0 and own['throw_deck'] == 0:
  564. own['requestAction'] = 'reg_idle5'
  565. elif STANCE == 0 and own['throw_deck'] == 1:
  566. own['requestAction'] = 'reg_idle5'
  567. elif STANCE == 1 and own['throw_deck'] == 0:
  568. own['requestAction'] = 'fak_idle5'
  569. elif STANCE == 1 and own['throw_deck'] == 1:
  570. own['requestAction'] = 'fak_idle5'
  571. elif ran_num == 6:
  572. killact(3)
  573. if STANCE == 0 and own['throw_deck'] == 0:
  574. own['requestAction'] = 'reg_idle6'
  575. elif STANCE == 0 and own['throw_deck'] == 1:
  576. own['requestAction'] = 'reg_idle6'
  577. elif STANCE == 1 and own['throw_deck'] == 0:
  578. own['requestAction'] = 'fak_idle6'
  579. elif STANCE == 1 and own['throw_deck'] == 1:
  580. own['requestAction'] = 'fak_idle6'
  581. elif ran_num == 7:
  582. killact(3)
  583. if STANCE == 0 and own['throw_deck'] == 0:
  584. own['requestAction'] = 'reg_idle7'
  585. elif STANCE == 0 and own['throw_deck'] == 1:
  586. own['requestAction'] = 'reg_idle7'
  587. elif STANCE == 1 and own['throw_deck'] == 0:
  588. own['requestAction'] = 'fak_idle6'
  589. elif STANCE == 1 and own['throw_deck'] == 1:
  590. own['requestAction'] = 'fak_idle6'
  591. def reset_pos():
  592. #reset
  593. if ddPad == 1:
  594. spawn_pos = own['spawn_pos']
  595. spawn_rot = own['spawn_rot']
  596. spawn_cam_pos = own['spawn_cam_pos']
  597. spawn_cam_rot = own['spawn_cam_rot']
  598. try:
  599. own.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
  600. 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]]
  601. cam.worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
  602. 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]]
  603. except:
  604. own.worldPosition = (5, 2, .1)
  605. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  606. own['stance'] = own['spawn_stance']
  607. if own["spawn_stance"] == 1:
  608. own.setLinearVelocity([.1,0,0], 1)
  609. else:
  610. own.setLinearVelocity([-.1,0,0], 1)
  611. if udPad == 1:
  612. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  613. 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]]
  614. own['spawn_cam_pos'] = [cam.worldPosition[0], cam.worldPosition[1], cam.worldPosition[2]]
  615. 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]]
  616. stance = own["stance"]
  617. own["spawn_stance"] = stance
  618. def falldeck():
  619. throw_deck_empty = scene.objects["throw_deck_empty"]
  620. throw_deck_empty.worldPosition.y += .5
  621. throw_deck_empty.worldPosition.x += .5
  622. deckact = deck.actuators["Visibility"]
  623. trucksact = trucks.actuators["Visibility"]
  624. wheel1act = wheel1.actuators["Visibility"]
  625. wheel2act = wheel2.actuators["Visibility"]
  626. wheel3act = wheel3.actuators["Visibility"]
  627. wheel4act = wheel4.actuators["Visibility"]
  628. print('doing falldeck')
  629. if own['throw_deck'] == False:
  630. own['throw_deck'] = True
  631. deckact.visibility = False
  632. trucksact.visibility = False
  633. wheel1act.visibility = False
  634. wheel2act.visibility = False
  635. wheel3act.visibility = False
  636. wheel4act.visibility = False
  637. act = throw_deck_empty.actuators['throw_dec_act']
  638. if STANCE == True:
  639. act.linearVelocity = [0.0, 1.0, 1.0]
  640. if STANCE == False:
  641. act.linearVelocity = [0.0, 1.0, -1.0]
  642. cont.activate(act)
  643. print('running falldeck()')
  644. else:
  645. own['throw_deck'] = False
  646. deckact.visibility = True
  647. trucksact.visibility = True
  648. wheel1act.visibility = True
  649. wheel2act.visibility = True
  650. wheel3act.visibility = True
  651. wheel4act.visibility = True
  652. throw_deck_empty['kill_deck'] = 1
  653. cont.activate(deck.actuators['Visibility'])
  654. cont.activate(trucks.actuators['Visibility'])
  655. cont.activate(wheel1.actuators['Visibility'])
  656. cont.activate(wheel2.actuators['Visibility'])
  657. cont.activate(wheel3.actuators['Visibility'])
  658. cont.activate(wheel4.actuators['Visibility'])
  659. def throwdeck(strength, ud):
  660. throw_deck_empty = scene.objects["throw_deck_empty"]
  661. deckact = deck.actuators["Visibility"]
  662. trucksact = trucks.actuators["Visibility"]
  663. wheel1act = wheel1.actuators["Visibility"]
  664. wheel2act = wheel2.actuators["Visibility"]
  665. wheel3act = wheel3.actuators["Visibility"]
  666. wheel4act = wheel4.actuators["Visibility"]
  667. if own['throw_deck'] == False:
  668. own['throw_deck'] = True
  669. deckact.visibility = False
  670. trucksact.visibility = False
  671. wheel1act.visibility = False
  672. wheel2act.visibility = False
  673. wheel3act.visibility = False
  674. wheel4act.visibility = False
  675. act = throw_deck_empty.actuators['throw_dec_act']
  676. hard = strength * .08
  677. if hard > 9:
  678. hard = 9
  679. if hard < 1:
  680. hard = 1
  681. ud = ud * 4
  682. own['bbut_timer'] = 0
  683. if STANCE == True:
  684. own['requestAction'] = 'fak_throw'
  685. act.linearVelocity = [0.0, ud, hard]
  686. if STANCE == False:
  687. own['requestAction'] = 'fak_throw'
  688. act.linearVelocity = [0.0, ud, -hard]
  689. cont.activate(act)
  690. else:
  691. own['throw_deck'] = False
  692. deckact.visibility = True
  693. trucksact.visibility = True
  694. wheel1act.visibility = True
  695. wheel2act.visibility = True
  696. wheel3act.visibility = True
  697. wheel4act.visibility = True
  698. throw_deck_empty['kill_deck'] = 1
  699. cont.activate(deck.actuators['Visibility'])
  700. cont.activate(trucks.actuators['Visibility'])
  701. cont.activate(wheel1.actuators['Visibility'])
  702. cont.activate(wheel2.actuators['Visibility'])
  703. cont.activate(wheel3.actuators['Visibility'])
  704. cont.activate(wheel4.actuators['Visibility'])
  705. def throwdeck_trigger():
  706. lastb = own['lastb']
  707. throw_deck_empty = scene.objects["throw_deck_empty"]
  708. if bBut == True:
  709. own['bbut_timer'] += 1
  710. ud = (rUD * 10) +1
  711. if bBut == False:
  712. throw_deck_empty['kill_deck'] = 0
  713. if bBut == False and own['lastb'] == True:
  714. strength = own['bbut_timer']
  715. ud = (rUD * 10) +1
  716. throwdeck(strength, ud)
  717. def focus_deck():
  718. since_air = own['framenum'] - own['lF_air_frame']
  719. if cb_td.positive and since_air < 10:
  720. object = 'focus_deckA'
  721. object2 = 'focus_deckB'
  722. other = throw_deck_empty
  723. throw_deck = scene.objects["throw_deck"]
  724. throw_deck.endObject()
  725. scene.addObject(object, other, 0)
  726. scene.addObject(object2, other, 0)
  727. if own['throw_deck'] == True:
  728. if dict['ldPad'] == False and dict['last_ldPad'] == True:
  729. object = 'focus_deckA'
  730. object2 = 'focus_deckB'
  731. other = throw_deck_empty
  732. scene.addObject(object, other, 0)
  733. scene.addObject(object2, other, 0)
  734. def fall():
  735. if own['fall'] == True:
  736. falldeck()
  737. if STANCE == 1:
  738. own['requestAction'] = 'fak_air-walk_air'
  739. #own.setLinearVelocity([3,2,0], True)
  740. else:
  741. own['requestAction'] = 'reg_air-walk_air'
  742. #own.setLinearVelocity([-3,-2,0], True)
  743. own['fall'] = False
  744. own.worldPosition.z += .3
  745. print('falling from walk.py')
  746. def sit():
  747. #turn off sit
  748. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  749. if own['sit'] == 1:
  750. killact(300)
  751. killact(299)
  752. own['sit'] = 0
  753. if aBut == True and lasta == False:
  754. try:
  755. if 'sit' in r_ground.hitObject:
  756. #print("sit")
  757. own['sit'] = 1
  758. killact(3)
  759. if STANCE == 0:
  760. own['requestAction'] = 'reg_sit'
  761. elif STANCE == 1:
  762. own['requestAction'] = 'fak_sit'
  763. except:
  764. pass
  765. if own['sit'] == 1:
  766. try:
  767. killact(3)
  768. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  769. if STANCE == 0:
  770. own.alignAxisToVect(-sit_vect, 0, .2)
  771. own['requestAction'] = 'reg_sit'
  772. elif STANCE == 1:
  773. own['requestAction'] = 'fak_sit'
  774. own.alignAxisToVect(sit_vect, 0, .2)
  775. except:
  776. pass
  777. def switchcam():
  778. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  779. if own['camera'] == 1:
  780. own['camera'] = 0
  781. else:
  782. own['camera'] = 1
  783. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  784. if own['camera'] == 2:
  785. own['camera'] = 0
  786. else:
  787. own['camera'] = 2
  788. #followcam
  789. def move_followcam():
  790. if own['camera'] == 2:
  791. if own['lastbkBut'] == True and bkBut == False:
  792. #print("activate move followcam")
  793. if own['move_followcam'] == False:
  794. own['move_followcam'] = True
  795. else:
  796. own['move_followcam'] = False
  797. if own['move_followcam'] == True:
  798. camspeed1 = .015
  799. camspeed2 = .055
  800. camrot1 = .005
  801. camrot2 = .02
  802. #up
  803. if lUD < -0.080:
  804. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  805. cont.activate(followcam.actuators["up"])
  806. #print("fastup")
  807. else:
  808. cont.deactivate(followcam.actuators["up"])
  809. # #down
  810. if lUD > .080:
  811. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  812. cont.activate(followcam.actuators["down"])
  813. else:
  814. cont.deactivate(followcam.actuators["down"])
  815. # #left
  816. #if lLR < -0.080:
  817. if lLR > 0.080:
  818. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  819. cont.activate(followcam.actuators["left"])
  820. else:
  821. cont.deactivate(followcam.actuators["left"])
  822. # #right
  823. #if lLR > 0.080:
  824. if lLR < -0.080:
  825. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  826. cont.activate(followcam.actuators["right"])
  827. else:
  828. cont.deactivate(followcam.actuators["right"])
  829. #up
  830. if rUD < -0.080:
  831. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  832. cont.activate(followcam.actuators["rotup"])
  833. else:
  834. cont.deactivate(followcam.actuators["rotup"])
  835. # #down
  836. if rUD > .080:
  837. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  838. cont.activate(followcam.actuators["rotdown"])
  839. else:
  840. cont.deactivate(followcam.actuators["rotdown"])
  841. # #left
  842. if rLR < -0.080:
  843. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  844. cont.activate(followcam.actuators["rotleft"])
  845. else:
  846. cont.deactivate(followcam.actuators["rotleft"])
  847. # #right
  848. if rLR > 0.080:
  849. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  850. cont.activate(followcam.actuators["rotright"])
  851. else:
  852. cont.deactivate(followcam.actuators["rotright"])
  853. #*********************************************
  854. if lUD > -0.080 and lUD < -0.030:
  855. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  856. cont.activate(followcam.actuators["up"])
  857. else:
  858. cont.deactivate(followcam.actuators["up"])
  859. # #down
  860. if lUD < .080 and lUD > .03:
  861. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  862. cont.activate(followcam.actuators["down"])
  863. else:
  864. cont.deactivate(followcam.actuators["down"])
  865. # #left
  866. if lLR > -0.080 and lLR < -0.030:
  867. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  868. cont.activate(followcam.actuators["left"])
  869. else:
  870. cont.deactivate(followcam.actuators["left"])
  871. # #right
  872. if lLR < .080 and lLR > .03:
  873. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  874. cont.activate(followcam.actuators["right"])
  875. else:
  876. cont.deactivate(followcam.actuators["right"])
  877. #up
  878. if rUD > -0.080 and rUD < -0.030:
  879. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  880. cont.activate(followcam.actuators["rotup"])
  881. else:
  882. cont.deactivate(followcam.actuators["rotup"])
  883. # #down
  884. if rUD < .080 and rUD > .03:
  885. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  886. cont.activate(followcam.actuators["rotdown"])
  887. else:
  888. cont.deactivate(followcam.actuators["rotdown"])
  889. # #left
  890. if rLR > -0.080 and rLR < -0.030:
  891. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  892. cont.activate(followcam.actuators["rotleft"])
  893. else:
  894. cont.deactivate(followcam.actuators["rotleft"])
  895. # #right
  896. if rLR < .080 and rLR > .03:
  897. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  898. cont.activate(followcam.actuators["rotright"])
  899. else:
  900. cont.deactivate(followcam.actuators["rotright"])
  901. def move_flycam():
  902. if own['camera'] == 1:
  903. if own['lastbkBut'] == True and bkBut == False:
  904. if own['move_freecam'] == False:
  905. own['move_freecam'] = True
  906. else:
  907. own['move_freecam'] = False
  908. if own['move_freecam'] == True:
  909. camspeed1 = .015
  910. camspeed2 = .055
  911. camrot1 = .005
  912. camrot2 = .02
  913. #up
  914. if lUD < -0.080:
  915. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  916. cont.activate(freecam.actuators["up"])
  917. else:
  918. cont.deactivate(freecam.actuators["up"])
  919. # #down
  920. if lUD > .080:
  921. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  922. cont.activate(freecam.actuators["down"])
  923. else:
  924. cont.deactivate(freecam.actuators["down"])
  925. # #left
  926. if lLR < -0.080:
  927. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  928. cont.activate(freecam.actuators["left"])
  929. else:
  930. cont.deactivate(freecam.actuators["left"])
  931. # #right
  932. if lLR > 0.080:
  933. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  934. cont.activate(freecam.actuators["right"])
  935. else:
  936. cont.deactivate(freecam.actuators["right"])
  937. #up
  938. if rUD < -0.080:
  939. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  940. cont.activate(freecam.actuators["rotup"])
  941. else:
  942. cont.deactivate(freecam.actuators["rotup"])
  943. # #down
  944. if rUD > .080:
  945. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  946. cont.activate(freecam.actuators["rotdown"])
  947. else:
  948. cont.deactivate(freecam.actuators["rotdown"])
  949. # #left
  950. if rLR < -0.080:
  951. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  952. cont.activate(freecam.actuators["rotleft"])
  953. else:
  954. cont.deactivate(freecam.actuators["rotleft"])
  955. # #right
  956. if rLR > 0.080:
  957. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  958. cont.activate(freecam.actuators["rotright"])
  959. else:
  960. cont.deactivate(freecam.actuators["rotright"])
  961. #*********************************************
  962. if lUD > -0.080 and lUD < -0.030:
  963. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  964. cont.activate(freecam.actuators["up"])
  965. #print(lUD)
  966. else:
  967. cont.deactivate(freecam.actuators["up"])
  968. # #down
  969. if lUD < .080 and lUD > .03:
  970. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  971. cont.activate(freecam.actuators["down"])
  972. else:
  973. cont.deactivate(freecam.actuators["down"])
  974. # #left
  975. if lLR > -0.080 and lLR < -0.030:
  976. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  977. cont.activate(freecam.actuators["left"])
  978. else:
  979. cont.deactivate(freecam.actuators["left"])
  980. # #right
  981. if lLR < .080 and lLR > .03:
  982. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  983. cont.activate(freecam.actuators["right"])
  984. else:
  985. cont.deactivate(freecam.actuators["right"])
  986. #up
  987. if rUD > -0.080 and rUD < -0.030:
  988. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  989. cont.activate(freecam.actuators["rotup"])
  990. else:
  991. cont.deactivate(freecam.actuators["rotup"])
  992. # #down
  993. if rUD < .080 and rUD > .03:
  994. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  995. cont.activate(freecam.actuators["rotdown"])
  996. else:
  997. cont.deactivate(freecam.actuators["rotdown"])
  998. # #left
  999. if rLR > -0.080 and rLR < -0.030:
  1000. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1001. cont.activate(freecam.actuators["rotleft"])
  1002. else:
  1003. cont.deactivate(freecam.actuators["rotleft"])
  1004. # #right
  1005. if rLR < .080 and rLR > .03:
  1006. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1007. cont.activate(freecam.actuators["rotright"])
  1008. else:
  1009. cont.deactivate(freecam.actuators["rotright"])
  1010. if r_ground.triggered == False:
  1011. cont.deactivate(own.actuators["walk_align"])
  1012. else:
  1013. cont.activate(own.actuators["walk_align"])
  1014. #walking on stairs
  1015. if r_ground.triggered:
  1016. try:
  1017. if 'stair' in r_ground.hitObject:
  1018. own['stair_counter'] = 20
  1019. except:
  1020. pass
  1021. if own['stair_counter'] > 0:
  1022. own.linearVelocity.z += .1
  1023. own['stair_counter'] -= 1
  1024. if yBut == True:
  1025. own['walk_idling'] = 0
  1026. own["walk_idle_frame"] = 0
  1027. if own['stair_counter'] > 5 and r_ground.triggered == False:
  1028. own.applyForce([0,0,-200], True)
  1029. if deck.visible:
  1030. own['deckvis'] = 1
  1031. else:
  1032. own['deckvis'] = 0
  1033. if own['requestAction'] == 'empty' or own['requestAction'] == None:
  1034. if STANCE == 0:
  1035. own['requestAction'] = 'reg_idle1'
  1036. if STANCE == 1:
  1037. own['requestAction'] = 'fak_idle1'
  1038. def onground():
  1039. if r_ground.positive:
  1040. own['lF_ground_frame'] = own['framenum']
  1041. if 'grind' in r_ground.hitObject:
  1042. if own['framenum'] - own['last_fall_frame'] < 90:
  1043. #own.applyForce([0,100,0], True)
  1044. pass
  1045. #print('moving away from rail')
  1046. yvel = own.linearVelocity.y
  1047. yvel = yvel *.1
  1048. if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01 and own['stair_counter'] == 0:
  1049. if STANCE == 0:
  1050. own.applyRotation([0,0,-yvel], True)
  1051. else:
  1052. own.applyRotation([0,0,yvel], True)
  1053. else:
  1054. own.linearVelocity.y = 0
  1055. else:
  1056. #print('in air')
  1057. if own['framenum'] - own['lF_ground_frame'] > 10:
  1058. if STANCE == 0:
  1059. own['requestAction'] = 'reg_walk_air'
  1060. else:
  1061. own['requestAction'] = 'fak_walk_air'
  1062. #if control bottom is touching ground object, turn ground on
  1063. if cb.positive:
  1064. if own['framenum'] - own['last_fall_frame'] < 90:
  1065. own['lF_ground_frame'] = own['framenum']
  1066. def get_in_car():
  1067. vehicleNear = cont.sensors["vehicleNear"]
  1068. #print('vh', vehicleNear.positive)
  1069. scene = bge.logic.getCurrentScene()
  1070. cam = scene.active_camera
  1071. #dict = bge.logic.globalDict
  1072. if vehicleNear.positive and 'car' in vehicleNear.hitObject:
  1073. obj = vehicleNear.hitObject
  1074. if yBut == True:
  1075. obj['driving'] = True
  1076. own['driving'] = True
  1077. cube.suspendDynamics(True)
  1078. cube.worldPosition = obj.worldPosition
  1079. cube.worldOrientation = obj.worldOrientation
  1080. rot = [ 0.0, 0.0, 1.570796327]
  1081. cube.applyRotation(rot,False)
  1082. compound = False
  1083. # child is solid
  1084. ghost = True
  1085. # set parent
  1086. cube.setParent( obj, compound, ghost)
  1087. #cam.target = obj
  1088. #cam.state = 2
  1089. cont.actuators['Camera'].object = obj
  1090. cont.actuators['Camera'].height = 3
  1091. cont.actuators['Camera'].min = 6
  1092. cont.actuators['Camera'].max = 10
  1093. own.state = 2
  1094. #print('near car')
  1095. if dict['last_driving'] == True:
  1096. cont.actuators['Camera'].object = scene.objects['camCube']
  1097. cont.activate(cont.actuators['walk'])
  1098. if own['driving'] == False:
  1099. #cont.actuators['Camera'].object = scene.objects['camCube']
  1100. #cont.activate(cont.actuators['walk'])
  1101. dict['last_driving'] = False
  1102. def get_on_bike(dict, own):
  1103. #bikeCol = cont.sensors['bikeCol']
  1104. vehicleNear = cont.sensors["vehicleNear"]
  1105. #print('vh', vehicleNear.positive)
  1106. scene = bge.logic.getCurrentScene()
  1107. #cam = scene.active_camera
  1108. #dict = bge.logic.globalDict
  1109. try:
  1110. if vehicleNear.positive and 'bike' in vehicleNear.hitObject:
  1111. if yBut == True and dict['last_yBut'] == False and own['throw_deck'] == True:
  1112. vehicleNear.hitObject.endObject()
  1113. dict['bike'] = True
  1114. cont.activate(own.actuators['bike_state'])
  1115. object = "player_bike"
  1116. # instantly add bullet
  1117. newbike = scene.addObject(object, own, 0)
  1118. #bike.localScale = 4.6
  1119. newbike.setParent(cube, False, False)
  1120. #rot = [ 0.0, 0.0, 1.570796327]
  1121. #bike.applyRotation(rot,False)
  1122. except:
  1123. pass
  1124. if dict['driving_reset'] == True:
  1125. scene.resume()
  1126. cube.suspendDynamics(False)
  1127. cont.actuators['Camera'].object = camobj2
  1128. cont.activate(own.actuators['walk'])
  1129. #dict['driving_reset'] = False
  1130. #print('reseting driving')
  1131. if own['walk_jump_timer'] != 0:
  1132. own['walk_jump_timer'] = own['walk_jump_timer'] - 1
  1133. wts = own['walk_targ_speed'] +1
  1134. if own['requestAction'] == 'reg_walkFast' and own.linearVelocity.x > (wts * -1):
  1135. own['requestAction'] = 'reg_walk'
  1136. if own['requestAction'] == 'fak_walkFast' and own.linearVelocity.x < wts:
  1137. own['requestAction'] = 'fak_walk'
  1138. if own['requestAction'] == 'reg_walkFast_nb' and own.linearVelocity.x > (wts * -1):
  1139. own['requestAction'] = 'reg_walk_nb'
  1140. if own['requestAction'] == 'fak_walkFast_nb' and own.linearVelocity.x < wts:
  1141. own['requestAction'] = 'fak_walk_nb'
  1142. if r_ground.triggered:
  1143. #force2 = [0.0, 0, dict['antibounce']]
  1144. #own.applyForce(force2, True)
  1145. gdist = ((own.worldPosition.z - r_ground.hitPosition[2]))
  1146. #print(gdist)
  1147. if gdist < .28 and gdist > .1:
  1148. #move = 2.875 - gdist
  1149. move = (.28 - gdist)*.5
  1150. #move = (own.worldPosition.z + gdist)
  1151. if move > 0:
  1152. own.worldPosition.z = own.worldPosition.z + move
  1153. else:
  1154. own.worldPosition.z = own.worldPosition.z - move
  1155. own.linearVelocity.z = 0
  1156. onboard()
  1157. jump()
  1158. #dropin()
  1159. throwdeck_trigger()
  1160. nextframe()
  1161. checkidle()
  1162. getonboard(dict, cont)
  1163. reset_pos()
  1164. switchcam()
  1165. move_flycam()
  1166. move_followcam()
  1167. fall()
  1168. idle_anim()
  1169. sit()
  1170. onground()
  1171. focus_deck()
  1172. get_in_car()
  1173. get_on_bike(dict, own)
  1174. #printplaying()
  1175. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1176. own.actuators["sroll"].stopSound()
  1177. wheel1 = scene.objects["wheel1"]
  1178. wheel2 = scene.objects["wheel2"]
  1179. wheel3 = scene.objects["wheel3"]
  1180. wheel4 = scene.objects["wheel4"]
  1181. wheel1.stopAction(2)
  1182. wheel2.stopAction(2)
  1183. wheel3.stopAction(2)
  1184. wheel4.stopAction(2)
  1185. own['lasty'] = yBut
  1186. own['lastb'] = bBut
  1187. own['lasta'] = aBut
  1188. own['lastx'] = xBut
  1189. own['lastlts'] = ltsBut
  1190. own['lastrts'] = rtsBut
  1191. own['lastbkBut'] = bkBut
  1192. own['dropinCol'] = dropinCol
  1193. own['walk'] = 1
  1194. dict['walk'] = 1