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

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