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

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