Jump to content
Korean Random
Sign in to follow this  
ahwa

World Of Warships Shells flying time

Recommended Posts

def firstOrderInterceptTime(shotSpeed, targetRelativePosition, targetRelativeVelocity):
    velocitySquared = targetRelativeVelocity.lengthSquared
    if velocitySquared < 0.001:
        return 0.0
    a = velocitySquared - shotSpeed * shotSpeed
    if abs(a) < 0.001:
        t = -targetRelativePosition.lengthSquared / (2.0 * targetRelativeVelocity.dot(targetRelativePosition))
        return max(t, 0.0)
    b = 2.0 * targetRelativeVelocity.dot(targetRelativePosition)
    c = targetRelativePosition.lengthSquared
    determinant = b * b - 4.0 * a * c
    if determinant > 0.0:
        t1 = (-b + math.sqrt(determinant)) / (2.0 * a)
        t2 = (-b - math.sqrt(determinant)) / (2.0 * a)
        if t1 > 0.0:
            if t2 > 0.0:
                return min(t1, t2)
            else:
                return t1
        else:
            return max(t2, 0.0)
    else:
        if determinant < 0.0:
            return 0.0
        return max(-b / (2.0 * a), 0.0)

Apply mechanically and modify to WOT

SpeedInfo = BigWorld.target.filter.speedInfo.value
speed = SpeedInfo[0]
fwdSpeedLimit, bckwdSpeedLimit = BigWorld.target.typeDescriptor.physics['speedLimits']
MAX_SPEED_MULTIPLIER = 1.5
fwdSpeedLimit *= MAX_SPEED_MULTIPLIER
bckwdSpeedLimit *= MAX_SPEED_MULTIPLIER
if speed > fwdSpeedLimit:
    speed = fwdSpeedLimit
elif speed < -bckwdSpeedLimit:
    speed = -bckwdSpeedLimit
TargetSpeed = abs(round(speed, 3))

try:
   Yaw = BigWorld.target.yaw
except:
   Yaw = 0.0

Dist = (BigWorld.player().getOwnVehiclePosition() - TargetPosition).length
ShotSpeed = BigWorld.player().vehicleTypeDescriptor.shot['speed']

ShotTime = FirstOrderInterceptTime(ShotSpeed, Dist, TargetSpeed, Yaw)

def FirstOrderInterceptTime(ShotSpeed, Dist, Speed, Yaw):
    Y = Dist
    if Speed < 0.001:
        return 0.0
    Yaw = Yaw + math.pi
    a = Speed - ShotSpeed * ShotSpeed
    if abs(a) < 0.001:
        t = -Y / (2.0 * Y * math.cos(Yaw))
        return max(t, 0.0)
    b = 2.0 * Y * math.cos(Yaw)
    c = Y ** 2
    determinant = b * b - 4.0 * a * c
    if determinant > 0.0:
        t1 = (-b + math.sqrt(determinant)) / (2.0 * a)
        t2 = (-b - math.sqrt(determinant)) / (2.0 * a)
        if t1 > 0.0:
            if t2 > 0.0:
                return min(t1, t2)
            else:
                return t1
        else:
            return max(t2, 0.0)
    else:
        if determinant < 0.0:
            return 0.0
        return max(-b / (2.0 * a), 0.0)

I do this wrong????

How do I Apply mechanically and modify

  • Upvote 1
  • Downvote 1

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...