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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  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["b_deck"]
  58. trucks = scene.objects["b_trucks"]
  59. camobj2 = scene.objects['camobj']
  60. throw_deck_empty = scene.objects["throw_deck_empty"]
  61. wheel1 = scene.objects["wheel1"]
  62. wheel2 = scene.objects["wheel2"]
  63. wheel3 = scene.objects["wheel3"]
  64. wheel4 = scene.objects["wheel4"]
  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'] = 6
  385. own['lastx'] = 1
  386. else:
  387. own['lastx'] = 0
  388. def getonboard(dict, cont):
  389. grindDar = cont.sensors['grindDar2']
  390. getonboard = own['getonboard']
  391. fliplay2 = 50#8560
  392. if ((yBut == True and dict['last_yBut'] == False) or dict['kb_q'] == 2):# and (cont.sensors["vehicleNear"].positive == False and own['throw_deck'] == False):
  393. fliplay3 = fliplay2 + 1
  394. dar = 0
  395. if grindDar.hitObjectList != None:
  396. for x in grindDar.hitObjectList:
  397. to_grinder = (x.worldPosition - own.worldPosition).length
  398. #if 'coping' in x and to_grinder < .36:
  399. if 'coping' in x:
  400. dar = 1
  401. if dropinCol.positive == True or dar == 1:
  402. nearestObject = None
  403. grindEmpty = scene.objects['grindEmpty']
  404. grindDar = grindEmpty.sensors['grindDar2']
  405. minDist = None
  406. if grindDar.positive:
  407. detectedObjects = grindDar.hitObjectList
  408. dist = 0
  409. for obj in detectedObjects:
  410. dist = own.getDistanceTo(obj)
  411. if (minDist is None or dist < minDist):
  412. nearestObject = obj
  413. minDist = dist
  414. # if nearestObject != None:
  415. # #print(nearestObject)
  416. # obj = nearestObject
  417. # player_e = own.worldOrientation.to_euler()
  418. # player_pos = own.worldPosition
  419. # player_rotz = math.degrees(player_e[2])
  420. # grinder_e = obj.worldOrientation.to_euler()
  421. # grinder_rotz = math.degrees(grinder_e[2])
  422. # rot = player_rotz - grinder_rotz
  423. # grinder_pos = obj.worldPosition
  424. # worldVect = [1, 0, 0]
  425. # vect = obj.getAxisVect(worldVect)
  426. # go = obj.worldOrientation
  427. # grinder_axis = [1,0,0]
  428. # try:
  429. # delta = player_pos - grinder_pos
  430. # delta = delta.cross(vect)
  431. # if delta[2] >= 0:
  432. # grindside = "right"
  433. # else:
  434. # grindside = "left"
  435. # deltamove = delta[2] * .1#.25
  436. # if STANCE == 0:
  437. # move = [-deltamove, 0, 0]
  438. # else:
  439. # move = [deltamove, 0, 0]
  440. # own.applyMovement(move, True)
  441. # except:
  442. # pass
  443. print('dropin')
  444. if STANCE == 0:
  445. own['requestAction'] ='reg_dropin_pos'
  446. own['dropinTimer'] = 60
  447. if STANCE == 1:
  448. own['requestAction'] ='fak_dropin_pos'
  449. own['dropinTimer'] = 60
  450. if getonboard == 1:
  451. fliplay3 = 6000
  452. onboard_speed = .1
  453. own['getonboard'] = 0
  454. own['walk_idling'] = 0
  455. if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 3) and dropinCol.positive:
  456. print('getting on board')
  457. deckact = deck.actuators["Visibility"]
  458. trucksact = trucks.actuators["Visibility"]
  459. wheel1act = wheel1.actuators["Visibility"]
  460. wheel2act = wheel2.actuators["Visibility"]
  461. wheel3act = wheel3.actuators["Visibility"]
  462. wheel4act = wheel4.actuators["Visibility"]
  463. deckact.visibility = True
  464. trucksact.visibility = True
  465. wheel1act.visibility = True
  466. wheel2act.visibility = True
  467. wheel3act.visibility = True
  468. wheel4act.visibility = True
  469. cont.activate(deck.actuators['Visibility'])
  470. cont.activate(trucks.actuators['Visibility'])
  471. cont.activate(wheel1.actuators['Visibility'])
  472. cont.activate(wheel2.actuators['Visibility'])
  473. cont.activate(wheel3.actuators['Visibility'])
  474. cont.activate(wheel4.actuators['Visibility'])
  475. own['throw_deck'] = False
  476. throw_deck_empty = scene.objects["throw_deck_empty"]
  477. throw_deck_empty['kill_deck'] = 1
  478. if ((yBut == False and lasty == True) or dict['kb_q'] == 3):# and cont.sensors["vehicleNear"].positive == False:
  479. print('secondary get on board')
  480. own['getonboard'] = 1
  481. own['walk_idling'] = 0
  482. deckact = deck.actuators["Visibility"]
  483. trucksact = trucks.actuators["Visibility"]
  484. wheel1act = wheel1.actuators["Visibility"]
  485. wheel2act = wheel2.actuators["Visibility"]
  486. wheel3act = wheel3.actuators["Visibility"]
  487. wheel4act = wheel4.actuators["Visibility"]
  488. deckact.visibility = True
  489. trucksact.visibility = True
  490. wheel1act.visibility = True
  491. wheel2act.visibility = True
  492. wheel3act.visibility = True
  493. wheel4act.visibility = True
  494. cont.activate(deck.actuators['Visibility'])
  495. cont.activate(trucks.actuators['Visibility'])
  496. cont.activate(wheel1.actuators['Visibility'])
  497. cont.activate(wheel2.actuators['Visibility'])
  498. cont.activate(wheel3.actuators['Visibility'])
  499. cont.activate(wheel4.actuators['Visibility'])
  500. own['throw_deck'] = False
  501. throw_deck_empty = scene.objects["throw_deck_empty"]
  502. throw_deck_empty['kill_deck'] = 1
  503. def nextframe():
  504. framenumber = own["framenum"]
  505. framenumber = framenumber + 1
  506. if framenumber == 900000:
  507. framenumber = 0
  508. own["framenum"] = framenumber
  509. own['last_walk_frame'] = framenumber
  510. def checkidle():
  511. idle = cont.sensors["idle"]
  512. idle_frame = own["walk_idle_frame"]
  513. if idle.positive:
  514. own["walk_idle_frame"] = 0
  515. cont.deactivate(camobj.actuators['idle_camRight'])
  516. #camera.height = .5
  517. camera.height = dict['cam_idle_height']
  518. else:
  519. if idle_frame == 0:
  520. own["walk_idle_frame"] = own["framenum"]
  521. diff = own["framenum"] - idle_frame
  522. if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
  523. cont.activate(camobj.actuators['idle_camRight'])
  524. #camera.height = .9
  525. #camera.min = 2
  526. #camera.max = 2.50
  527. own['walk_idling'] = 1
  528. else:
  529. own['walk_idling'] = 0
  530. def idle_anim():
  531. if own['walk_idling'] == 1 and own['sit'] == 0:
  532. walk_idle_frame = own['walk_idle_frame']
  533. mod_num = (own["framenum"] - walk_idle_frame) % 240
  534. idle_lay = 300
  535. if mod_num == 0:
  536. if own['idle_skipper'] > 0:
  537. own['idle_skipper'] -= 1
  538. ran_num = random.randint(1, 8)
  539. if own['last_idle_num'] == ran_num:
  540. ran_num = 1
  541. if own['idle_skipper'] == 0:
  542. own['last_idle_num'] = ran_num
  543. if ran_num == 1 or ran_num > 7:
  544. killact(3)
  545. if STANCE == 0 and own['throw_deck'] == 0:
  546. own['requestAction'] = 'reg_idle1'
  547. elif STANCE == 0 and own['throw_deck'] == 1:
  548. own['requestAction'] = 'reg_idle1'
  549. elif STANCE == 1 and own['throw_deck'] == 0:
  550. own['requestAction'] = 'fak_idle1'
  551. elif STANCE == 1 and own['throw_deck'] == 1:
  552. own['requestAction'] = 'fak_idle1'
  553. elif ran_num == 2:
  554. killact(3)
  555. if STANCE == 0 and own['throw_deck'] == 0:
  556. own['requestAction'] = 'reg_idle2'
  557. elif STANCE == 0 and own['throw_deck'] == 1:
  558. own['requestAction'] = 'reg_idle2_nb'
  559. elif STANCE == 1 and own['throw_deck'] == 0:
  560. own['requestAction'] = 'fak_idle1'
  561. elif STANCE == 1 and own['throw_deck'] == 1:
  562. own['requestAction'] = 'fak_idle1'
  563. elif ran_num == 3:
  564. killact(3)
  565. if STANCE == 0 and own['throw_deck'] == 0:
  566. own['requestAction'] = 'reg_idle3'
  567. elif STANCE == 0 and own['throw_deck'] == 1:
  568. own['requestAction'] = 'reg_idle3'
  569. elif STANCE == 1 and own['throw_deck'] == 0:
  570. own['requestAction'] = 'fak_idle1'
  571. elif STANCE == 1 and own['throw_deck'] == 1:
  572. own['requestAction'] = 'fak_idle1'
  573. own['idle_skipper'] = 2
  574. elif ran_num == 4:
  575. killact(3)
  576. if STANCE == 0 and own['throw_deck'] == 0:
  577. own['requestAction'] = 'reg_idle4'
  578. elif STANCE == 0 and own['throw_deck'] == 1:
  579. own['requestAction'] = 'reg_idle4'
  580. elif STANCE == 1 and own['throw_deck'] == 0:
  581. own['requestAction'] = 'fak_idle4'
  582. elif STANCE == 1 and own['throw_deck'] == 1:
  583. own['requestAction'] = 'fak_idle4'
  584. elif ran_num == 5:
  585. killact(3)
  586. if STANCE == 0 and own['throw_deck'] == 0:
  587. own['requestAction'] = 'reg_idle5'
  588. elif STANCE == 0 and own['throw_deck'] == 1:
  589. own['requestAction'] = 'reg_idle5'
  590. elif STANCE == 1 and own['throw_deck'] == 0:
  591. own['requestAction'] = 'fak_idle5'
  592. elif STANCE == 1 and own['throw_deck'] == 1:
  593. own['requestAction'] = 'fak_idle5'
  594. elif ran_num == 6:
  595. killact(3)
  596. if STANCE == 0 and own['throw_deck'] == 0:
  597. own['requestAction'] = 'reg_idle6'
  598. elif STANCE == 0 and own['throw_deck'] == 1:
  599. own['requestAction'] = 'reg_idle6'
  600. elif STANCE == 1 and own['throw_deck'] == 0:
  601. own['requestAction'] = 'fak_idle6'
  602. elif STANCE == 1 and own['throw_deck'] == 1:
  603. own['requestAction'] = 'fak_idle6'
  604. elif ran_num == 7:
  605. killact(3)
  606. if STANCE == 0 and own['throw_deck'] == 0:
  607. own['requestAction'] = 'reg_idle7'
  608. elif STANCE == 0 and own['throw_deck'] == 1:
  609. own['requestAction'] = 'reg_idle7'
  610. elif STANCE == 1 and own['throw_deck'] == 0:
  611. own['requestAction'] = 'fak_idle6'
  612. elif STANCE == 1 and own['throw_deck'] == 1:
  613. own['requestAction'] = 'fak_idle6'
  614. def reset_pos():
  615. #reset
  616. if ddPad == 1:
  617. spawn_pos = own['spawn_pos']
  618. spawn_rot = own['spawn_rot']
  619. spawn_cam_pos = own['spawn_cam_pos']
  620. spawn_cam_rot = own['spawn_cam_rot']
  621. try:
  622. own.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
  623. 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]]
  624. cam.worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
  625. 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]]
  626. except:
  627. own.worldPosition = (5, 2, .1)
  628. own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
  629. own['stance'] = own['spawn_stance']
  630. if own["spawn_stance"] == 1:
  631. own.setLinearVelocity([.1,0,0], 1)
  632. else:
  633. own.setLinearVelocity([-.1,0,0], 1)
  634. if udPad == 1:
  635. own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]]
  636. 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]]
  637. own['spawn_cam_pos'] = [cam.worldPosition[0], cam.worldPosition[1], cam.worldPosition[2]]
  638. 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]]
  639. stance = own["stance"]
  640. own["spawn_stance"] = stance
  641. def falldeck():
  642. throw_deck_empty = scene.objects["throw_deck_empty"]
  643. throw_deck_empty.worldPosition.y += .5
  644. throw_deck_empty.worldPosition.x += .5
  645. deckact = deck.actuators["Visibility"]
  646. trucksact = trucks.actuators["Visibility"]
  647. wheel1act = wheel1.actuators["Visibility"]
  648. wheel2act = wheel2.actuators["Visibility"]
  649. wheel3act = wheel3.actuators["Visibility"]
  650. wheel4act = wheel4.actuators["Visibility"]
  651. print('doing falldeck')
  652. if own['throw_deck'] == False:
  653. own['throw_deck'] = True
  654. deckact.visibility = False
  655. trucksact.visibility = False
  656. wheel1act.visibility = False
  657. wheel2act.visibility = False
  658. wheel3act.visibility = False
  659. wheel4act.visibility = False
  660. act = throw_deck_empty.actuators['throw_dec_act']
  661. if STANCE == True:
  662. act.linearVelocity = [0.0, 1.0, 1.0]
  663. if STANCE == False:
  664. act.linearVelocity = [0.0, 1.0, -1.0]
  665. cont.activate(act)
  666. print('running falldeck()')
  667. else:
  668. own['throw_deck'] = False
  669. deckact.visibility = True
  670. trucksact.visibility = True
  671. wheel1act.visibility = True
  672. wheel2act.visibility = True
  673. wheel3act.visibility = True
  674. wheel4act.visibility = True
  675. throw_deck_empty['kill_deck'] = 1
  676. cont.activate(deck.actuators['Visibility'])
  677. cont.activate(trucks.actuators['Visibility'])
  678. cont.activate(wheel1.actuators['Visibility'])
  679. cont.activate(wheel2.actuators['Visibility'])
  680. cont.activate(wheel3.actuators['Visibility'])
  681. cont.activate(wheel4.actuators['Visibility'])
  682. def throwdeck(strength, ud):
  683. throw_deck_empty = scene.objects["throw_deck_empty"]
  684. deckact = deck.actuators["Visibility"]
  685. trucksact = trucks.actuators["Visibility"]
  686. wheel1act = wheel1.actuators["Visibility"]
  687. wheel2act = wheel2.actuators["Visibility"]
  688. wheel3act = wheel3.actuators["Visibility"]
  689. wheel4act = wheel4.actuators["Visibility"]
  690. if own['throw_deck'] == False:
  691. own['throw_deck'] = True
  692. deckact.visibility = False
  693. trucksact.visibility = False
  694. wheel1act.visibility = False
  695. wheel2act.visibility = False
  696. wheel3act.visibility = False
  697. wheel4act.visibility = False
  698. act = throw_deck_empty.actuators['throw_dec_act']
  699. hard = strength * .08
  700. if hard > 9:
  701. hard = 9
  702. if hard < 1:
  703. hard = 1
  704. ud = ud * 4
  705. own['bbut_timer'] = 0
  706. if STANCE == True:
  707. own['requestAction'] = 'fak_throw'
  708. act.linearVelocity = [0.0, ud, hard]
  709. if STANCE == False:
  710. own['requestAction'] = 'fak_throw'
  711. act.linearVelocity = [0.0, ud, -hard]
  712. cont.activate(act)
  713. else:
  714. own['throw_deck'] = False
  715. deckact.visibility = True
  716. trucksact.visibility = True
  717. wheel1act.visibility = True
  718. wheel2act.visibility = True
  719. wheel3act.visibility = True
  720. wheel4act.visibility = True
  721. throw_deck_empty['kill_deck'] = 1
  722. cont.activate(deck.actuators['Visibility'])
  723. cont.activate(trucks.actuators['Visibility'])
  724. cont.activate(wheel1.actuators['Visibility'])
  725. cont.activate(wheel2.actuators['Visibility'])
  726. cont.activate(wheel3.actuators['Visibility'])
  727. cont.activate(wheel4.actuators['Visibility'])
  728. def throwdeck_trigger():
  729. lastb = own['lastb']
  730. throw_deck_empty = scene.objects["throw_deck_empty"]
  731. if bBut == True:
  732. own['bbut_timer'] += 1
  733. ud = (rUD * 10) +1
  734. if bBut == False:
  735. throw_deck_empty['kill_deck'] = 0
  736. if bBut == False and own['lastb'] == True:
  737. strength = own['bbut_timer']
  738. ud = (rUD * 10) +1
  739. throwdeck(strength, ud)
  740. def focus_deck():
  741. since_air = own['framenum'] - own['lF_air_frame']
  742. if cb_td.positive and since_air < 10:
  743. object = 'focus_deckA'
  744. object2 = 'focus_deckB'
  745. other = throw_deck_empty
  746. throw_deck = scene.objects["throw_deck"]
  747. throw_deck.endObject()
  748. scene.addObject(object, other, 0)
  749. scene.addObject(object2, other, 0)
  750. if own['throw_deck'] == True:
  751. if dict['ldPad'] == False and dict['last_ldPad'] == True:
  752. object = 'focus_deckA'
  753. object2 = 'focus_deckB'
  754. other = throw_deck_empty
  755. scene.addObject(object, other, 0)
  756. scene.addObject(object2, other, 0)
  757. def fall():
  758. if own['fall'] == True:
  759. falldeck()
  760. if STANCE == 1:
  761. own['requestAction'] = 'fak_air-walk_air'
  762. #own.setLinearVelocity([3,2,0], True)
  763. else:
  764. own['requestAction'] = 'reg_air-walk_air'
  765. #own.setLinearVelocity([-3,-2,0], True)
  766. own['fall'] = False
  767. own.worldPosition.z += .3
  768. print('falling from walk.py')
  769. def sit():
  770. #turn off sit
  771. if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
  772. if own['sit'] == 1:
  773. killact(300)
  774. killact(299)
  775. own['sit'] = 0
  776. if aBut == True and lasta == False:
  777. try:
  778. if 'sit' in r_ground.hitObject:
  779. #print("sit")
  780. own['sit'] = 1
  781. killact(3)
  782. if STANCE == 0:
  783. own['requestAction'] = 'reg_sit'
  784. elif STANCE == 1:
  785. own['requestAction'] = 'fak_sit'
  786. except:
  787. pass
  788. if own['sit'] == 1:
  789. try:
  790. killact(3)
  791. sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
  792. if STANCE == 0:
  793. own.alignAxisToVect(-sit_vect, 0, .2)
  794. own['requestAction'] = 'reg_sit'
  795. elif STANCE == 1:
  796. own['requestAction'] = 'fak_sit'
  797. own.alignAxisToVect(sit_vect, 0, .2)
  798. except:
  799. pass
  800. def switchcam():
  801. if ltsBut == False and own['lastlts'] == True and rtsBut == False:
  802. if own['camera'] == 1:
  803. own['camera'] = 0
  804. else:
  805. own['camera'] = 1
  806. if rtsBut == False and own['lastrts'] == True and ltsBut == False:
  807. if own['camera'] == 2:
  808. own['camera'] = 0
  809. else:
  810. own['camera'] = 2
  811. #followcam
  812. def move_followcam():
  813. if own['camera'] == 2:
  814. if own['lastbkBut'] == True and bkBut == False:
  815. #print("activate move followcam")
  816. if own['move_followcam'] == False:
  817. own['move_followcam'] = True
  818. else:
  819. own['move_followcam'] = False
  820. if own['move_followcam'] == True:
  821. camspeed1 = .015
  822. camspeed2 = .055
  823. camrot1 = .005
  824. camrot2 = .02
  825. #up
  826. if lUD < -0.080:
  827. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  828. cont.activate(followcam.actuators["up"])
  829. #print("fastup")
  830. else:
  831. cont.deactivate(followcam.actuators["up"])
  832. # #down
  833. if lUD > .080:
  834. followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  835. cont.activate(followcam.actuators["down"])
  836. else:
  837. cont.deactivate(followcam.actuators["down"])
  838. # #left
  839. #if lLR < -0.080:
  840. if lLR > 0.080:
  841. followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  842. cont.activate(followcam.actuators["left"])
  843. else:
  844. cont.deactivate(followcam.actuators["left"])
  845. # #right
  846. #if lLR > 0.080:
  847. if lLR < -0.080:
  848. followcam.actuators["right"].dLoc = [camspeed2, 0, 0]
  849. cont.activate(followcam.actuators["right"])
  850. else:
  851. cont.deactivate(followcam.actuators["right"])
  852. #up
  853. if rUD < -0.080:
  854. followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
  855. cont.activate(followcam.actuators["rotup"])
  856. else:
  857. cont.deactivate(followcam.actuators["rotup"])
  858. # #down
  859. if rUD > .080:
  860. followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]
  861. cont.activate(followcam.actuators["rotdown"])
  862. else:
  863. cont.deactivate(followcam.actuators["rotdown"])
  864. # #left
  865. if rLR < -0.080:
  866. followcam.actuators["rotleft"].dRot = [0, 0, camrot2]
  867. cont.activate(followcam.actuators["rotleft"])
  868. else:
  869. cont.deactivate(followcam.actuators["rotleft"])
  870. # #right
  871. if rLR > 0.080:
  872. followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
  873. cont.activate(followcam.actuators["rotright"])
  874. else:
  875. cont.deactivate(followcam.actuators["rotright"])
  876. #*********************************************
  877. if lUD > -0.080 and lUD < -0.030:
  878. followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  879. cont.activate(followcam.actuators["up"])
  880. else:
  881. cont.deactivate(followcam.actuators["up"])
  882. # #down
  883. if lUD < .080 and lUD > .03:
  884. followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  885. cont.activate(followcam.actuators["down"])
  886. else:
  887. cont.deactivate(followcam.actuators["down"])
  888. # #left
  889. if lLR > -0.080 and lLR < -0.030:
  890. followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  891. cont.activate(followcam.actuators["left"])
  892. else:
  893. cont.deactivate(followcam.actuators["left"])
  894. # #right
  895. if lLR < .080 and lLR > .03:
  896. followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
  897. cont.activate(followcam.actuators["right"])
  898. else:
  899. cont.deactivate(followcam.actuators["right"])
  900. #up
  901. if rUD > -0.080 and rUD < -0.030:
  902. followcam.actuators["rotup"].dRot = [camrot1, 0, 0]
  903. cont.activate(followcam.actuators["rotup"])
  904. else:
  905. cont.deactivate(followcam.actuators["rotup"])
  906. # #down
  907. if rUD < .080 and rUD > .03:
  908. followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  909. cont.activate(followcam.actuators["rotdown"])
  910. else:
  911. cont.deactivate(followcam.actuators["rotdown"])
  912. # #left
  913. if rLR > -0.080 and rLR < -0.030:
  914. followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
  915. cont.activate(followcam.actuators["rotleft"])
  916. else:
  917. cont.deactivate(followcam.actuators["rotleft"])
  918. # #right
  919. if rLR < .080 and rLR > .03:
  920. followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
  921. cont.activate(followcam.actuators["rotright"])
  922. else:
  923. cont.deactivate(followcam.actuators["rotright"])
  924. def move_flycam():
  925. if own['camera'] == 1:
  926. if own['lastbkBut'] == True and bkBut == False:
  927. if own['move_freecam'] == False:
  928. own['move_freecam'] = True
  929. else:
  930. own['move_freecam'] = False
  931. if own['move_freecam'] == True:
  932. camspeed1 = .015
  933. camspeed2 = .055
  934. camrot1 = .005
  935. camrot2 = .02
  936. #up
  937. if lUD < -0.080:
  938. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
  939. cont.activate(freecam.actuators["up"])
  940. else:
  941. cont.deactivate(freecam.actuators["up"])
  942. # #down
  943. if lUD > .080:
  944. freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
  945. cont.activate(freecam.actuators["down"])
  946. else:
  947. cont.deactivate(freecam.actuators["down"])
  948. # #left
  949. if lLR < -0.080:
  950. freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]
  951. cont.activate(freecam.actuators["left"])
  952. else:
  953. cont.deactivate(freecam.actuators["left"])
  954. # #right
  955. if lLR > 0.080:
  956. freecam.actuators["right"].dLoc = [camspeed2, 0, 0]
  957. cont.activate(freecam.actuators["right"])
  958. else:
  959. cont.deactivate(freecam.actuators["right"])
  960. #up
  961. if rUD < -0.080:
  962. freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
  963. cont.activate(freecam.actuators["rotup"])
  964. else:
  965. cont.deactivate(freecam.actuators["rotup"])
  966. # #down
  967. if rUD > .080:
  968. freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]
  969. cont.activate(freecam.actuators["rotdown"])
  970. else:
  971. cont.deactivate(freecam.actuators["rotdown"])
  972. # #left
  973. if rLR < -0.080:
  974. freecam.actuators["rotleft"].dRot = [0, 0, camrot2]
  975. cont.activate(freecam.actuators["rotleft"])
  976. else:
  977. cont.deactivate(freecam.actuators["rotleft"])
  978. # #right
  979. if rLR > 0.080:
  980. freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
  981. cont.activate(freecam.actuators["rotright"])
  982. else:
  983. cont.deactivate(freecam.actuators["rotright"])
  984. #*********************************************
  985. if lUD > -0.080 and lUD < -0.030:
  986. freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
  987. cont.activate(freecam.actuators["up"])
  988. #print(lUD)
  989. else:
  990. cont.deactivate(freecam.actuators["up"])
  991. # #down
  992. if lUD < .080 and lUD > .03:
  993. freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]
  994. cont.activate(freecam.actuators["down"])
  995. else:
  996. cont.deactivate(freecam.actuators["down"])
  997. # #left
  998. if lLR > -0.080 and lLR < -0.030:
  999. freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]
  1000. cont.activate(freecam.actuators["left"])
  1001. else:
  1002. cont.deactivate(freecam.actuators["left"])
  1003. # #right
  1004. if lLR < .080 and lLR > .03:
  1005. freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
  1006. cont.activate(freecam.actuators["right"])
  1007. else:
  1008. cont.deactivate(freecam.actuators["right"])
  1009. #up
  1010. if rUD > -0.080 and rUD < -0.030:
  1011. freecam.actuators["rotup"].dRot = [camrot1, 0, 0]
  1012. cont.activate(freecam.actuators["rotup"])
  1013. else:
  1014. cont.deactivate(freecam.actuators["rotup"])
  1015. # #down
  1016. if rUD < .080 and rUD > .03:
  1017. freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]
  1018. cont.activate(freecam.actuators["rotdown"])
  1019. else:
  1020. cont.deactivate(freecam.actuators["rotdown"])
  1021. # #left
  1022. if rLR > -0.080 and rLR < -0.030:
  1023. freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
  1024. cont.activate(freecam.actuators["rotleft"])
  1025. else:
  1026. cont.deactivate(freecam.actuators["rotleft"])
  1027. # #right
  1028. if rLR < .080 and rLR > .03:
  1029. freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
  1030. cont.activate(freecam.actuators["rotright"])
  1031. else:
  1032. cont.deactivate(freecam.actuators["rotright"])
  1033. if r_ground.triggered == False:
  1034. cont.deactivate(own.actuators["walk_align"])
  1035. else:
  1036. cont.activate(own.actuators["walk_align"])
  1037. #walking on stairs
  1038. if r_ground.triggered:
  1039. try:
  1040. if 'stair' in r_ground.hitObject:
  1041. own['stair_counter'] = 20
  1042. except:
  1043. pass
  1044. if own['stair_counter'] > 0:
  1045. own.linearVelocity.z += .1
  1046. own['stair_counter'] -= 1
  1047. if yBut == True:
  1048. own['walk_idling'] = 0
  1049. own["walk_idle_frame"] = 0
  1050. if own['stair_counter'] > 5 and r_ground.triggered == False:
  1051. own.applyForce([0,0,-200], True)
  1052. if deck.visible:
  1053. own['deckvis'] = 1
  1054. else:
  1055. own['deckvis'] = 0
  1056. if own['requestAction'] == 'empty' or own['requestAction'] == None:
  1057. if STANCE == 0:
  1058. own['requestAction'] = 'reg_idle1'
  1059. if STANCE == 1:
  1060. own['requestAction'] = 'fak_idle1'
  1061. def onground():
  1062. if r_ground.positive:
  1063. own['lF_ground_frame'] = own['framenum']
  1064. if 'grind' in r_ground.hitObject:
  1065. if own['framenum'] - own['last_fall_frame'] < 90:
  1066. #own.applyForce([0,100,0], True)
  1067. pass
  1068. #print('moving away from rail')
  1069. yvel = own.linearVelocity.y
  1070. yvel = yvel *.1
  1071. if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01 and own['stair_counter'] == 0:
  1072. if STANCE == 0:
  1073. own.applyRotation([0,0,-yvel], True)
  1074. else:
  1075. own.applyRotation([0,0,yvel], True)
  1076. else:
  1077. own.linearVelocity.y = 0
  1078. else:
  1079. #print('in air')
  1080. if own['framenum'] - own['lF_ground_frame'] > 10:
  1081. if STANCE == 0:
  1082. own['requestAction'] = 'reg_walk_air'
  1083. else:
  1084. own['requestAction'] = 'fak_walk_air'
  1085. #if control bottom is touching ground object, turn ground on
  1086. if cb.positive:
  1087. if own['framenum'] - own['last_fall_frame'] < 90:
  1088. own['lF_ground_frame'] = own['framenum']
  1089. def get_in_car():
  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. if vehicleNear.positive and 'car' in vehicleNear.hitObject:
  1096. obj = vehicleNear.hitObject
  1097. if yBut == True:
  1098. obj['driving'] = True
  1099. own['driving'] = True
  1100. cube.suspendDynamics(True)
  1101. cube.worldPosition = obj.worldPosition
  1102. cube.worldOrientation = obj.worldOrientation
  1103. rot = [ 0.0, 0.0, 1.570796327]
  1104. cube.applyRotation(rot,False)
  1105. compound = False
  1106. # child is solid
  1107. ghost = True
  1108. # set parent
  1109. cube.setParent( obj, compound, ghost)
  1110. #cam.target = obj
  1111. #cam.state = 2
  1112. cont.actuators['Camera'].object = obj
  1113. cont.actuators['Camera'].height = 3
  1114. cont.actuators['Camera'].min = 6
  1115. cont.actuators['Camera'].max = 10
  1116. own.state = 2
  1117. #print('near car')
  1118. if dict['last_driving'] == True:
  1119. cont.actuators['Camera'].object = scene.objects['camCube']
  1120. cont.activate(cont.actuators['walk'])
  1121. if own['driving'] == False:
  1122. #cont.actuators['Camera'].object = scene.objects['camCube']
  1123. #cont.activate(cont.actuators['walk'])
  1124. dict['last_driving'] = False
  1125. def get_on_bike(dict, own):
  1126. #bikeCol = cont.sensors['bikeCol']
  1127. vehicleNear = cont.sensors["vehicleNear"]
  1128. #print('vh', vehicleNear.positive)
  1129. scene = bge.logic.getCurrentScene()
  1130. #cam = scene.active_camera
  1131. #dict = bge.logic.globalDict
  1132. try:
  1133. if vehicleNear.positive and 'bike' in vehicleNear.hitObject:
  1134. if yBut == True and dict['last_yBut'] == False and own['throw_deck'] == True:
  1135. vehicleNear.hitObject.endObject()
  1136. dict['bike'] = True
  1137. cont.activate(own.actuators['bike_state'])
  1138. object = "player_bike"
  1139. # instantly add bullet
  1140. newbike = scene.addObject(object, own, 0)
  1141. #bike.localScale = 4.6
  1142. newbike.setParent(cube, False, False)
  1143. #rot = [ 0.0, 0.0, 1.570796327]
  1144. #bike.applyRotation(rot,False)
  1145. except:
  1146. pass
  1147. if dict['driving_reset'] == True:
  1148. scene.resume()
  1149. cube.suspendDynamics(False)
  1150. cont.actuators['Camera'].object = camobj2
  1151. cont.activate(own.actuators['walk'])
  1152. #dict['driving_reset'] = False
  1153. #print('reseting driving')
  1154. if own['walk_jump_timer'] != 0:
  1155. own['walk_jump_timer'] = own['walk_jump_timer'] - 1
  1156. wts = own['walk_targ_speed'] +1
  1157. if own['requestAction'] == 'reg_walkFast' and own.linearVelocity.x > (wts * -1):
  1158. own['requestAction'] = 'reg_walk'
  1159. if own['requestAction'] == 'fak_walkFast' and own.linearVelocity.x < wts:
  1160. own['requestAction'] = 'fak_walk'
  1161. if own['requestAction'] == 'reg_walkFast_nb' and own.linearVelocity.x > (wts * -1):
  1162. own['requestAction'] = 'reg_walk_nb'
  1163. if own['requestAction'] == 'fak_walkFast_nb' and own.linearVelocity.x < wts:
  1164. own['requestAction'] = 'fak_walk_nb'
  1165. if r_ground.triggered:
  1166. #force2 = [0.0, 0, dict['antibounce']]
  1167. #own.applyForce(force2, True)
  1168. gdist = ((own.worldPosition.z - r_ground.hitPosition[2]))
  1169. #print(gdist)
  1170. if gdist < .28 and gdist > .1:
  1171. #move = 2.875 - gdist
  1172. move = (.28 - gdist)*.5
  1173. #move = (own.worldPosition.z + gdist)
  1174. if move > 0:
  1175. own.worldPosition.z = own.worldPosition.z + move
  1176. else:
  1177. own.worldPosition.z = own.worldPosition.z - move
  1178. own.linearVelocity.z = 0
  1179. onboard()
  1180. jump()
  1181. #dropin()
  1182. throwdeck_trigger()
  1183. nextframe()
  1184. checkidle()
  1185. getonboard(dict, cont)
  1186. reset_pos()
  1187. switchcam()
  1188. move_flycam()
  1189. move_followcam()
  1190. fall()
  1191. idle_anim()
  1192. sit()
  1193. onground()
  1194. focus_deck()
  1195. get_in_car()
  1196. get_on_bike(dict, own)
  1197. #printplaying()
  1198. own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
  1199. own.actuators["sroll"].stopSound()
  1200. wheel1 = scene.objects["wheel1"]
  1201. wheel2 = scene.objects["wheel2"]
  1202. wheel3 = scene.objects["wheel3"]
  1203. wheel4 = scene.objects["wheel4"]
  1204. wheel1.stopAction(2)
  1205. wheel2.stopAction(2)
  1206. wheel3.stopAction(2)
  1207. wheel4.stopAction(2)
  1208. own['lasty'] = yBut
  1209. own['lastb'] = bBut
  1210. own['lasta'] = aBut
  1211. own['lastx'] = xBut
  1212. own['lastlts'] = ltsBut
  1213. own['lastrts'] = rtsBut
  1214. own['lastbkBut'] = bkBut
  1215. own['dropinCol'] = dropinCol
  1216. own['walk'] = 1
  1217. dict['walk'] = 1