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

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