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

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