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

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