Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To revise top missile/munition speed for disco #39

Open
dd84ai opened this issue Oct 9, 2024 · 0 comments
Open

To revise top missile/munition speed for disco #39

dd84ai opened this issue Oct 9, 2024 · 0 comments
Labels
wontfix This will not be worked on

Comments

@dd84ai
Copy link
Member

dd84ai commented Oct 9, 2024

Aingar, King of FLServer — Today at 1:11 PM
@darkwind the Dark Duck Since we introduced 'top speed' mechanic for missiles, you may want to revise those stats in DarkStat.

[Munition] ini block can contain an optional top_speed = float variable. It caps out the speed that a missile can reach.

This obviously changes the calculations for the max range, so you'll need to adjust those. That said, from what I can tell you simply pick muzzle_velocity, multiply by lifetime and end it there, ignoring the missile's motor.

This is the cpp code I use to calculate a missile's actual range including the top speed limit and it's motor:

string GetRangeAtSpeed(const Archetype::MotorData* motor, Archetype::Munition* munition, float muzzleVelocity, float shipVelocity)
{
    map<uint, float>::iterator topSpeedIter = munitionTopSpeedMap.find(munition->iArchID);

    float startSpeed = muzzleVelocity + shipVelocity;

    float baseDistance = munition->fLifeTime * startSpeed;

    float motorLifetime = min(motor->motorLifetime, munition->fLifeTime - motor->motorDelay);
    if (topSpeedIter != munitionTopSpeedMap.end())
    {
        motorLifetime = min(motorLifetime, max(0.0f, topSpeedIter->second - startSpeed) / motor->motorAcceleration);
    }

    float motorAcceleration = motor->motorAcceleration * motorLifetime;

    float motorDistance = motorAcceleration * motorLifetime * 0.5f;

    float timeMaxSpeed = max(0.0f, munition->fLifeTime - motor->motorDelay - motorLifetime);
    float maxspeedDistance = motorAcceleration * timeMaxSpeed;
    
    float totalDistance = baseDistance + motorDistance + maxspeedDistance;

    char buf[10];
    sprintf(buf, "%0.0fm", totalDistance);
    return string(buf);
}
@dd84ai dd84ai moved this to Todo in @dd84ai's Dark Tools Oct 22, 2024
@dd84ai dd84ai added the wontfix This will not be worked on label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant