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

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