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

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