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

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