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

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