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

walk.py 54KB

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