Shuvit game release repo.
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

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