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

walk.py 53KB

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