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.

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