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

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