Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

walk.py 47KB

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