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 44KB

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