Exemple #1
0
def ChaseBallBias(s):

    s.tL, s.tV, s.taV, s.dT = s.ptL, s.ptV, s.ptaV, s.pdT

    dt = s.bfd / 5300
    tPath = PhysicsLib.predictPath(s.ptL, s.ptV, s.ptaV, dt + 1 / 60, 60)
    tState = tPath.ballstates[min(tPath.numstates - 1, 0)]
    s.tL = a3(tState.Location)
    s.tV = a3(tState.Velocity)
    s.pfL, s.pfV = PhysicsLib.CarStep(s.pfL, s.pfV, dt)
    s.dT += dt

    s.fx, s.fy, s.fz = local(s.tL, s.pfL, s.pR)
    s.fd, s.fa, s.fi = spherical(s.fx, s.fy, s.fz)
    s.fd2 = dist2d([s.fx, s.fy])
    s.fgd2 = dist2d(s.pfL, s.tL)

    s.tx, s.ty, s.tz = local(s.tL, s.pL, s.pR)
    s.td, s.ta, s.ti = spherical(s.tx, s.ty, s.tz)
    s.td2 = dist2d([s.tx, s.ty])
    s.r = s.pR[2] / U180
    s.tLb = s.tL

    Cl = Ph.Collision_Model(s.pfL)
    if s.aerialing and not Cl.hasCollided:
        n1 = normalize(s.tL - s.pL)
        v1 = s.pV
        b1 = v1 - np.dot(v1, n1) * n1
        d = s.bd
        v = max(s.pvd * .5 + .5 * dist3d(s.pfV), 200)
        t = d / v
        s.tLb = s.tL - b1 * t

    s.ax, s.ay, s.az = local(s.tLb, s.pL, s.pR)
    s.d, s.a, s.i = spherical(s.ax, s.ay, s.az)
    s.d2 = dist2d([s.ax, s.ay])

    s.tLs = s.tL

    if s.pL[2] > 20 and s.poG and (s.tL[2] < s.az or s.az > 450 + s.pB * 9):
        s.tLs[2] = 50

    s.sx, s.sy, s.sz = local(s.tLs, s.pL, s.pR)
    s.sd, s.sa, s.si = spherical(s.sx, s.sy + 50, s.sz)
    s.sd2 = dist2d([s.ax, s.ay])

    if not s.offense:
        s.goal = set_dist(s.tL, s.ogoal, -999)

    if max(abs(s.fz), abs(s.bz)
           ) > 130 or s.odT + dist3d(s.otL, s.ofL) / 5300 < s.pdT + 1 or 1:
        Bias(s, 93)
    else:
        aimBias(s, s.goal)

    s.txv, s.tyv, s.tzv = s.bxv, s.byv, s.bzv
    s.xv, s.yv, s.zv = s.pxv - s.txv, s.pyv - s.tyv, s.pzv - s.tzv
    s.vd, s.va, s.vi = spherical(s.xv, s.yv, s.zv)
    s.vd2 = dist2d([s.xv, s.yv])
Exemple #2
0
def ChaseBallBias(s):

    s.tL, s.tV, s.taV, s.dT = s.ptL, s.ptV, s.ptaV, s.pdT

    dt = s.bfd / 8300
    tPath = PhysicsLib.predictPath(s.ptL, s.ptV, s.ptaV, dt + 1 / 60, 60)
    tState = tPath.ballstates[min(tPath.numstates - 1, 0)]
    s.tL = a3(tState.Location)
    s.tV = a3(tState.Velocity)
    s.pfL, s.pfV = PhysicsLib.CarStep(s.pfL, s.pfV, dt)
    s.dT += dt

    if s.tL[1] * s.color < -Ph.wy - 80:
        s.tL[1] = -Ph.wy * s.color - 80

    s.fx, s.fy, s.fz = local(s.tL, s.pfL, s.pR)
    s.fd, s.fa, s.fi = spherical(s.fx, s.fy, s.fz)
    s.fd2 = dist2d([s.fx, s.fy])
    s.fgd2 = dist2d(s.pfL, s.tL)

    s.tLb2 = s.tLb
    s.r = s.pR[2] / U180

    s.Cl = Ph.Collision_Model(s.pfL)
    if s.Cl.hasCollided:
        # landing on any surface
        # lt = Ph.local_space(s.tLb2, s.Cl.Location, s.Cl.Rotation)
        # lp = Ph.local_space(s.pL, s.Cl.Location, s.Cl.Rotation)
        # lt[2] = (93 + lp[2]) / 2
        # s.tLb2 = Ph.global_space(lt, s.Cl.Location, s.Cl.Rotation)
        # sUP = Ph.global_space(UP, 0, s.Cl.Rotation)
        # sRI = Ph.global_space(RI, 0, s.Cl.Rotation)
        # pUP = world(UP, 0, s.pR)
        # s.r = math.atan2(np.dot(sRI, pUP), np.dot(sUP, pUP)) / PI
        pass
    elif s.aerialing:
        n1 = normalize(s.tL - s.pL)
        v1 = s.pV
        b1 = v1 - np.dot(v1, n1) * n1
        d = (s.bd * 5 + .5 * dist3d(s.pL, s.tL))
        v = max(s.pvd * .5 + .5 * dist3d(s.pfV), 200)
        t = d / v
        s.tLb2 = s.tLb - b1 * t
    else:
        s.tLb2 = (s.pV + s.tLb2) / 2

    s.x, s.y, s.z = local(s.tLb2, s.pL, s.pR)
    s.d, s.a, s.i = spherical(s.x, s.y, s.z)
    s.d2 = dist2d([s.x, s.y])

    s.dspeed = 2310
    s.forwards = 1

    goal = s.goal if not s.behind else set_dist(s.tL, s.ogoal, -999)

    s.tLs = aimBias(s, goal) if s.pL[2] < 50 or not s.poG else s.tLb

    if s.pL[2] > 20 and s.poG and (s.tL[2] < s.z or s.z > 450 + s.pB * 9):
        s.tLs[2] = 50

    s.sx, s.sy, s.sz = local(s.tLs, s.pL, s.pR)
    s.sd, s.sa, s.si = spherical(s.sx, s.sy + 50, s.sz)

    s.txv, s.tyv, s.tzv = s.bxv, s.byv, s.bzv
    s.xv, s.yv, s.zv = s.pxv - s.txv, s.pyv - s.tyv, s.pzv - s.tzv
    s.vd, s.va, s.vi = spherical(s.xv, s.yv, s.zv)
    s.vd2 = dist2d([s.xv, s.yv])

    s.shoot = True