123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 |
- import bge
- import math
-
- def main():
- cont = bge.logic.getCurrentController()
- own = cont.owner
- player = cont.owner
- scene = bge.logic.getCurrentScene()
- #grindDar = cont.sensors['grindDar']
- grindEmpty = scene.objects['grindEmpty']
- grindDar = grindEmpty.sensors['grindDar2']
- rGround = cont.sensors['r_Ground']
- control_bottom = scene.objects['control_bottom']
- #grindCol_bottom
- grindTouch = control_bottom.sensors['grindCol_bottom']
- #grindTouch = cont.sensors['grindCol']
- invertCol = cont.sensors['invertCol']
- invertObjs = invertCol.hitObjectList
- invert_on = own['invert_on']
- detectedObjects = grindDar.hitObjectList
- lastObject = own['grindTrackObj']
- nearestObject = None
- minDist = None
- #act = cont.actuators["Target"]
- test = own["test"]
- grindold = own["grindOld"]
- lgobj = own["lGobj"]
- countdown = own['grindCountdown']
- #print(lgobj)
- ray = cont.sensors["GuardDuty"] # get the ray sensor attached to the controller named GuardDuty
- gt_cd = own["gt_cd"]
- pos = ray.hitPosition # get position where the game object hit by ray
- linVelocity = own.getLinearVelocity(False)
- linVelocity2 = own.getLinearVelocity(True)
- pos[2] = pos[2] + 1
- norm = ray.hitNormal
- STANCE = own["stance"]
- orientation = own.worldOrientation
- test = ray.hitObject
- xyz = own.worldOrientation.to_euler()
- rotz = math.degrees(xyz[2])
- roty = math.degrees(xyz[1])
- #print(roty)
- roty = abs(roty)
- sub = 0
- align_strength = .4
- align_strength2 = .3
- touched = grindTouch.triggered
- lgf = own['last_grind_frame']
- gsf = own['grind_start_frame']
- framenum = own['framenum']
- last_ground_frame = own['lF_ground_frame']
- frames_since_ground = framenum - last_ground_frame
- frames_since_grind = framenum - lgf
- frames_grinding = framenum - gsf
- #if framenum - lgf > 60:
- minus = framenum - gsf
- grindspeed_rail = .996 #multiplied by current speed
- grindspeed_cement = .995 #multiplied by current speed
- grindDar_timer = own["grindDar_timer"]
- last_grindDar = 0
- last_manual = own["manual"]
- joinit = 0
- #print(minus)
- # if grindold == True and minus > 20:
- # align_strength = .1
- # print("slow align")
-
- rot = own.getAxisVect( [0.0, 0.0, 1.0])
- dropin = own['dropinTimer']
- nearestObject = None
- last_hit = own['grindDar_hit']
- jump_timer = own['jump_timer']
- grind_jump = own['grind_jump']
- lastGround = own['lF_ground2']
- OG_PLAYER_POS = own.worldPosition
- grindvect = None
- grindyvect = None
- skipcol = 0
- skipconst = 0
- #print("--------frame: ", own['framenum'])
- #inertia = player.linearVelocity
- #print(rotz)
- try:
- no_grind_pull = own['no_grind_pull']
- except:
- own['no_grind_pull'] = 0
- no_grind_pull = 0
- #no grind
- no_grind = 0
- if jump_timer > 50:
- no_grind = 1
-
- #check manual
-
- manual = 0
- own["nogrindsound"] = 0
- #print(frames_since_ground)
- #print("grindold: ", grindold)
-
-
-
- #---------###########___###########-----------
- #start new #######
- ##----------##############----------############
-
- #grindvect func
- grindvect = None
- grindyvect = None
- lastobj = own["grindTouchobj"]
- grindpos = own["grindpos"]
- player_e = own.worldOrientation.to_euler()
- player_rotz = math.degrees(player_e[2])
- velxb = linVelocity2.x
- player_e = own.worldOrientation.to_euler()
-
- ogrot = own.orientation
- ogrot = player_e
-
- if (framenum - gsf) > 15:
- velx = linVelocity2.x
- vely = linVelocity2.y
- #print("limit speed")
- else:
- velx = linVelocity2.x
- vely = linVelocity2.y
- if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
- convely = own['pregrind_vely']
- else:
- convely = vely
- def grindvect(obj):
- STANCE = own['stance']
- if obj != None:
- grinder_e = obj.worldOrientation.to_euler()
- grinder_rotz = math.degrees(grinder_e[2])
- rot = player_rotz - grinder_rotz
- if rot >= 0 and rot < 45:
- grindvect = "pos"
- if rot >= 45 and rot < 90:
- grindvect = "pos"
- grindyvect = "pos"
- if rot >= 90 and rot < 135:
- grindvect = "neg"
- grindyvect = "neg"
- if rot >= 135 and rot < 180:
- grindvect = "neg"
- if rot >= 180 and rot < 225:
- grindvect = "neg"
- if rot >= 225 and rot < 270:
- grindvect = "neg"
- grindyvect = "pos"
- if rot >= 270 and rot < 315:
- grindvect = "pos"
- grindyvect = "neg"
- if rot >= 315: grindvect = "pos"
-
- if rot < 0 and rot >= -45:
- grindvect = "pos"
- if rot < -45 and rot >= -90:
- grindvect = "pos"
- grindyvect = "neg"
- if rot < -90 and rot >= -135:
- grindvect = "neg"
- grindyvect = "pos"
- if rot < -135 and rot >= -180:
- grindvect = "neg"
- if rot < -180 and rot >= -225:
- grindvect = "neg"
- if rot < -225 and rot >= -270:
- grindvect = "neg"
- grindyvect = "neg"
- if rot < -270 and rot >= -315:
- grindvect = "pos"
- grindyvect = "pos"
- if rot < -315:
- grindvect = "pos"
- #
- #print(grindvect, STANCE)
- rot = round((rot * .01), 1)
- rot *= 100
- #print(rot)
-
-
- if frames_grinding > 20:
- print("setting stance")
- if (rot == 90 or rot == -270) and STANCE == True:
- #print("90 fak stance")
- own['stance'] = 1
- STANCE = 1
- if (rot == 90 or rot == -270) and STANCE == False:
- #print("90 fak stance")
- own['stance'] = 1
- STANCE = 1
- if (rot == -90 or rot == 270) and STANCE == True:
- #print("-90 reg stance")
- own['stance'] = 0
- STANCE = 0
- if (rot == -90 or rot == 270) and STANCE == False:
- #print("-90 reg stance")
- own['stance'] = 0
- STANCE = 0
- #print("stance: ", STANCE)
- def grindrotvel(obj):
- skipconst = 1
- #print("set jumponinit")
- joinit = 0
- grinder_e = obj.worldOrientation.to_euler()
- grinder_rotz = math.degrees(grinder_e[2])
- grinder_vect = obj.getAxisVect( [1, 0, 0])
- grinder_vectz = obj.getAxisVect( [0, 0, 1])
- rot = player_rotz - grinder_rotz
- rayhit = ray.hitObject
- #print(round(rot,2), STANCE, " = rotation")
- own['grind_rot'] = rot
- vect = obj.getAxisVect( [1.0, 0.0, 0.0])
- xyzb = obj.worldOrientation.to_euler()
- rotzb = math.degrees(xyzb[2])
- grindpos = "None"
- align = "None"
- sub_converted = 0
- rotz = math.degrees(xyz[2])
- roty = math.degrees(xyz[1])
- bsrot = [ 0.0, 0.0, 1.570796327]
- negbsrot = [ 0.0, 0.0, -1.570796327]
- zvel = own.linearVelocity
- zvel = zvel.z * .95
- #print(rot, "rot")
- if grindold == 0:
- if rotz < 0:
- rotz = rotz + 360
- if rotzb < 0:
- rotzb = rotzb + 360
- if rotz > rotzb:
- sub_converted = rotz - rotzb
- if rotz < rotzb:
- sub_converted = rotzb - rotz
-
- #print("J grindvect: ", grindvect, "align: ", align)
- #z align
- #print("zalign")
- player.alignAxisToVect(grinder_vectz, 2, .25)
-
- if rot >= 0 and rot < 45:
- player.alignAxisToVect(grinder_vect, 0, align_strength)
- grindvect = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
-
- if rot >= 45 and rot < 90:
- #90 degrees CW about z-axis: (x, y, z) -> (y, -x, z)
- #90 degrees CCW about z-axis: (x, y, z) -> (-y, x, z)
- #grinder_vect2 =
- player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength)
- #print("1")
- grindvect = "pos"
- #player.applyRotation(bsrot, 1)
- align = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "pos"
- #print("bs1, don't switch")
- #print("boardslide")
-
- if rot >= 90 and rot < 135:
- #print(STANCE, "2")
- grinder_vect = grinder_vect * -1
- player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "neg"
- #print("2")
- #player.applyRotation(negbsrot, 1)
- align = "neg"
- grindyvect = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- #print("-bs2, don't switch?")
- #print("boardslide")
-
- if rot >= 135 and rot < 180:
- player.alignAxisToVect(-grinder_vect, 0, align_strength)
- grindvect = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- if rot >= 180 and rot < 225:
- player.alignAxisToVect(-grinder_vect, 0, align_strength)
- grindvect = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- if rot >= 225 and rot < 270:
- #print(STANCE, "3")
- #grinder_vect = grinder_vect * -1
- player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
- #print("3")
- grindvect = "neg"
- #player.applyRotation(bsrot, 1)
- align = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "pos"
- print("bs3")
- #print("boardslide")
-
- if rot >= 270 and rot < 315:
- #print(STANCE, "4")
- player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "pos"
- #player.applyRotation(negbsrot, 1)
- #print("4")
- align = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "neg"
- #print("-bs4")
- #print("boardslide")
-
- if rot >= 315:
- player.alignAxisToVect(grinder_vect, 0, align_strength)
- grindvect = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- #-------------------------------------------------------------
- if rot < 0 and rot >= -45:
- player.alignAxisToVect(grinder_vect, 0, align_strength)
- grindvect = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- if rot < -45 and rot >= -90:
- #print(STANCE, "5")
- grinder_vect = grinder_vect * -1
- player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "pos"
- #player.applyRotation(negbsrot, 1)
- #print("5")
- align = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- #print("-bs5")
- #print("boardslide")
-
- grindyvect = "neg"
- if rot < -90 and rot >= -135:
- #print(STANCE, "6")
- #grinder_vect = grinder_vect * -1
- player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "neg"
- #print("6")
- #player.applyRotation(bsrot, 1)
- align = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "pos"
- #print("bs6")
- #print("boardslide")
-
- if rot < -135 and rot >= -180:
- player.alignAxisToVect(-grinder_vect, 0, align_strength)
- grindvect = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- if rot < -180 and rot >= -225:
- player.alignAxisToVect(-grinder_vect, 0, align_strength)
- grindvect = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
- if rot < -225 and rot >= -270:
- #print(STANCE, "7")
- grinder_vect = grinder_vect * -1
- player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "neg"
- #player.applyRotation(negbsrot, 1)
- #print("7")
- align = "neg"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "neg"
- #print("-bs7")
- #print("boardslide")
- if rot < -270 and rot >= -315:
- #print(STANCE, "8")
- player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength)
- grindvect = "pos"
- #player.applyRotation(bsrot, 1)
- #print("8")
- align = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([0, convely, zvel], 1)
- grindpos = "reg_board"
- grindyvect = "pos"
- #print("bs8")
- #print("boardslide")
- if rot < -315:
- player.alignAxisToVect(grinder_vect, 0, align_strength)
- grindvect = "pos"
- #player.applyForce([0, 0, 0], True)
- player.setLinearVelocity([velxb, 0.0, zvel], 1)
- grindpos = "reg_5050"
-
- own['grindpos'] = grindpos
- own['grindvect'] = grindvect
- own['grindervect'] = grinder_vect
- try:
- own['grindyvect'] = grindyvect
-
- except:
- pass
-
- #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- def grind(obj):
- #if (ray.triggered and grindold == False) or (touched == True and own['lastTouched'] == False):
- #print("gt: ", gt_cd)
- try:
- grindyvect = own['grindyvect']
- except:
- grindyvect = 0
- grindvect = own['grindvect']
-
- if 'rail' in obj:
- own["grindSound"] = "rail"
- else:
- own["grindSound"] = "concrete"
- own['lGobj'] = obj
-
-
- #if 1 == 1:
- grinding = 1
-
- framenum = own['framenum']
- lastairframe = own['lF_air_frame']
- jumpside = 0
- if (framenum - lastairframe) < 10:
- #if lastGround == False:
- player_pos = own['jumpPos']
- #print("get side from jumpPos", framenum, lastairframe)
- jumpside = 1
- else:
- player_pos = OG_PLAYER_POS
- player_pos = own.worldPosition
- try:
- if 1 == 1:
-
- grinder_pos = obj.worldPosition
- #print("touchObj", obj)
- #vectTo = player.getVectTo(grinder_pos)
- worldVect = [1, 0, 0]
- vect = obj.getAxisVect(worldVect)
- go = obj.worldOrientation
- grinder_axis = [0,1,0]
- try:
- delta = player_pos - grinder_pos
- except:
- #print("delta broke: ", player_pos, grinder_pos)
- pass
- delta = delta.cross(vect)
- #print(own["grindpos"], touched, "eval broken!!?!", delta[2])
- if delta[2] >= 0:
- #print("right side", grindyvect, round(delta[2], 6))
- grindside = "right"
- else:
- #print("left side", grindyvect, round(delta[2], 6))
- grindside = "left"
- if (delta[2] > .00001 or delta[2] < -.00001) and (delta[2] < .8 or delta[2] < -.8):
- rotation = own.worldOrientation[2] - obj.worldOrientation[2]
- player_e = own.worldOrientation.to_euler()
- player_rotz = math.degrees(player_e[2])
- grinder_e = obj.worldOrientation.to_euler()
- grinder_rotz = math.degrees(grinder_e[2])
- #print("rotation =", player_rotz - grinder_rotz)
- #print( "rotating - grindvect: ", grindvect)
- deltamove = delta[2] * .3#.25
- #5050
- #print(own["grindpos"], jumpside)
- #print("delta move")
- if own["grindpos"] == "reg_5050":
- #print("missing delta")
- if (jumpside == 1 or jumpside == 0) and grindvect == "pos":
- move = [0, deltamove, 0]
- #print("1deltamove", deltamove)
- own.applyMovement(move, True)
- if (jumpside == 1 or jumpside == 0) and grindvect == "neg":
- move = [0, -deltamove, 0]
- #print("2deltamove -", deltamove)
- own.applyMovement(move, True)
- #board
- #print("turnud: ", own["turnud"], "grindyvect: ", grindyvect)
- if own["grindpos"] == "reg_board":
- if grindvect == "neg":
- if (jumpside == 1 or jumpside == 0) and grindyvect == "pos":
- move = [-deltamove, 0, 0]
- #print("3deltamove", deltamove)
- own.applyMovement(move, True)
- if (jumpside == 1 or jumpside == 0) and grindyvect == "neg":
- move = [deltamove, 0, 0]
- #print("4deltamove -", deltamove)
- own.applyMovement(move, True)
- if grindvect == "pos":
- if (jumpside == 1 or jumpside == 0) and grindyvect == "pos":
- move = [deltamove, 0, 0]
- #print("5deltamove", deltamove)
- own.applyMovement(move, True)
- if (jumpside == 1 or jumpside == 0) and grindyvect == "neg":
- move = [-deltamove, 0, 0]
- #print("6deltamove -", deltamove)
- own.applyMovement(move, True)
- own['grindside'] = grindside
- except:
- pass
- #speed limit
- velo = own.getLinearVelocity(True)
- touchobj = obj
- if touchobj != None and gt_cd == 0:
- if 'rail' in touchobj:
- newvelx = velo.x * grindspeed_rail
- newvely = velo.y * grindspeed_rail
- #print("grindspeed limit rail")
- else:
- newvelx = velo.x * grindspeed_cement
- newvely = velo.y * grindspeed_cement
- #print("grindspeed limit cement")
- #print("setting newvely =", newvely)
- player.setLinearVelocity([newvelx, newvely, velo.z], 1)
- #print("grindspeedlimit")
- player_rot = own.worldOrientation[2]
- grinder_rot = touchobj.worldOrientation[2]
- player_rot = own.getAxisVect( [0.0, 0.0, 1.0])
- xyz3 = own.worldOrientation.to_euler()
- player_rot = math.degrees(xyz3[2])
- xyz4 = touchobj.worldOrientation.to_euler()
- grinder_rot = math.degrees(xyz4[2])
- if player_rot < 0:
- player_rot = abs(player_rot) + 180
- if grinder_rot < 0:
- grinder_rot = abs(grinder_rot) + 180
- subtraction = player_rot - grinder_rot
-
- def invertpos(detectedObjects):
- minDist = None
- nearestObject = None
- for obj in detectedObjects:
- dist = own.getDistanceTo(obj)
- if (minDist is None or dist < minDist):
- nearestObject = obj
- minDist = dist
- if nearestObject != None:
- vect = nearestObject.getAxisVect( [1.0, 0.0, 0.0])
- #own.alignAxisToVect(vect, 0, 0)
- own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
- #own.setLinearVelocity([0, 0.0, 0], 1)
- own.linearVelocity.x = 0
- own.linearVelocity.y = 0
- print("setting invertpos")
-
-
-
- if grindDar.positive == False and grindTouch.positive and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and own['air_mover'] == False:
- print("touching, no dar")
- #print(grindold, "grindold")
- if grindDar.positive:
- detectedObjects = grindDar.hitObjectList
- dist = 0
- for obj in detectedObjects:
- dist = own.getDistanceTo(obj)
- if (minDist is None or dist < minDist):
- nearestObject = obj
- minDist = dist
- #print(dist, nearestObject, "grindDar")
-
- #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- #init grind
-
- if invert_on:
- invertpos(detectedObjects)
- #print('invertOn')
-
- grind_dist = .8#.6
- if dist < grind_dist and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0:
- print("new grind trigger")
- npos = nearestObject.worldPosition
-
-
- #grind
- #print(dist)
- if dist < grind_dist and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and own['airup'] == 0 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 55 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0:
- #print("grind")
- hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
- if grindold == 0:
- if grindTouch.positive:
- #print("set grind pos")
- nearpos = nearestObject.worldPosition
- if hitNormal != None:
- own.alignAxisToVect(hitNormal, 2, .05)
- print("align")
- own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
-
- grindold = True
- own['grindold_timer'] = 0
- own["grindHit"] = True
- #print("grinding")
- grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
- #print(grind_height_dif)
- worldPos = own.worldPosition
- if grind_height_dif > -.05:#02:
- #print("############################upping z")
- #own.worldPosition = [worldPos.x, worldPos.y, worldPos.z + .1]
-
- grindvect(nearestObject)
- grindrotvel(nearestObject)
- grind(nearestObject)
-
-
- else:
- #grindold = False
- own['grindold_timer'] += 1
- own["grindHit"] = False
-
-
- if own['grindold_timer'] > 5:
- grindold = False
- own['grind_start_frame'] = framenum
- own["grindSound"] = None
-
-
- #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
-
- #if you are touching grinder and last_manual is off keep manual off
- if (own['fak_nmanual'] == 1 or own['reg_nmanual'] == 1 or own['fak_manual'] == 1 or own['reg_manual'] == 1) and lastGround == True and grindold == False:
- manual = 1
- if last_manual == 0 and grindTouch.triggered == True:
- manual = 0
- own["nogrindsound"] = 1
- grindhit = own["grindHit"]
-
- if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
- convely = own['pregrind_vely']
- else:
- convely = vely
-
- off = 0
-
- if touched == True:
- own["grindTouchobj"] = grindTouch.hitObject
- else:
- own["grindTouchobj"] = None
-
- if ray.triggered and dropin == 0:
- lgobj = ray.hitObject
- own['lGobj'] = lgobj
- obj = ray.hitObject
- #prop = obj.get("property", None)
- linVelocity3 = own.getLinearVelocity(True)
- grindpos2 = own["grindpos"]
- regboard = "reg_board"
- fakboard = "fak_board"
- if obj is not None:
- if 'rail' in ray.hitObject:
- own["grindSound"] = "rail"
- else:
- own["grindSound"] = "concrete"
- own['lGobj'] = lgobj
- else:
- lgobj = "empty"
- own['lGobj'] = lgobj
- def timer():
- countdown = own["grindCountdown"]
- if touched == 1:
- countdown = 20
- else:
- countdown = countdown - 1
- own['grindCountdown'] = countdown
- def aligntimer():
- if own['grindOld'] == 0 and ray.triggered == 1:
- own['aligntimer'] = 20
- if own['grindOld'] == 1 and ray.triggered == 1:
- own['aligntimer'] = own['aligntimer'] - 1
- if own['grindOld'] == 0 and ray.triggered == 0:
- own['aligntimer'] = 0
-
- def invertpos():
- minDist = None
- nearestObject = None
- for obj in invertObjs:
- dist = own.getDistanceTo(obj)
- if (minDist is None or dist < minDist):
- nearestObject = obj
- minDist = dist
- vect = nearestObject.getAxisVect( [1.0, 0.0, 0.0])
- #own.alignAxisToVect(vect, 0, 0)
- own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
- #own.setLinearVelocity([0, 0.0, 0], 1)
-
- def set_pregrind_vel():
- if grindDar.triggered == False and ray.triggered == False:
- #print("set pregrind vel")
- own['pregrind_velx'] = linVelocity2.x
- own['pregrind_vely'] = linVelocity2.y
- own['pregrind_velz'] = linVelocity2.z
-
- def stop_bounce():
- if grindTouch.triggered and no_grind == 0 and grind_jump == 0 and jump_timer < 30:
- linVelocity4 = own.getLinearVelocity(True)
- #print(linVelocity4.z)
- if linVelocity4.z > 0:
- own.setLinearVelocity([linVelocity4.x, linVelocity4.y, 0], 1)
-
- # last_posz = own['last_z']
- # posz = own.worldPosition.z
- # obj = None
- # if ray.triggered:
- # obj = ray.hitObject
- # if grindTouch.triggered:
- # obj = grindTouch.hitObject
- # #if last_posz < posz and grindold == True and obj != None:
- # gsf = own['grind_start_frame']
- # frame = own['framenum']
- # sub = frame - gsf
- # linVelocity4 = own.getLinearVelocity(True)
- # avelx = linVelocity4.x
- # avely = linVelocity4.y
- # avelz = linVelocity4.z
- # num = -.2
- # num2 = -.1
- # if avelz > 0:
- # avelz = 0
- # avelz = avelz + num
- #
- # #if obj != None and sub > 30 and jump_timer < 10:
- # #own.setLinearVelocity([avelx, avely, num2], 1)
- # if sub < 3:
- # pass
- # #own.setLinearVelocity([avelx, avely, avelz], 1)
-
-
- if jump_timer < 30 :
- own['grind_jump'] = 0
- if grindold == False and ray.triggered:
- own['grind_start_frame'] = own['framenum']
-
- if grindDar_timer > 0:
- grindDar_timer -= 1
- if grindDar_timer > 0 and ray.triggered == False and touched == True and own['footplant_on'] == False and manual == 0:
- #print("timer but ground")
- obj = grindTouch.hitObject
- own.worlPosition = obj.worldPosition
- if ray.triggered == False:
- own["nogrindsound"] = 1
- timer()
- aligntimer()
- stop_bounce()
-
- own['grindOld'] = grindold
- own['test'] = test
- own['grindTrackObj'] = nearestObject
- own['grindDar_hit'] = grindDar.positive
- own['lastTouched'] = touched
- own['grindTouch'] = grindTouch.triggered
- own["grindDar_timer"] = grindDar_timer
- own["last_grindDar"] = last_grindDar
- linVelocity3 = own.getLinearVelocity(True)
- #print(linVelocity3.z)
- set_pregrind_vel()
- own['last_z'] = own.worldPosition.z
- own["manual"] = manual
-
-
-
- main()
|