ShootersForever.com Forum Index

GoldenEye 007 Nintendo 64 Community, GoldenEye X, Nintendo 64 Games Discussion
GoldenEye Cheats, GoldenEye X Codes, Tips, Help, Nintendo 64 Gaming Community


How do you calculate how long it takes to open/close a door?

 
Post new topic   Reply to topic    ShootersForever.com Forum Index -> Q-Lab Hacking Department
View previous topic :: View next topic  
tolos
Agent
Agent


Joined: 17 Jan 2021
Posts: 6

 PostPosted: Tue Jul 20, 2021 7:21 pm    Post subject: How do you calculate how long it takes to open/close a door? Reply with quote Back to top

Assume I load up Depot. I find a door, Preset 272A, #0002.

I'm looking at an Object Type of "01 Door" in the Object Editor. Object # 2.

On the right, I see what appear to be six relevant text boxes:

Distance Travels
0xE666

Walkthru Distance
0xCCCC

Acceleration
0xA

Rate
0xA

Max Speed
0x1EB

Time Open (ms)
0x384

The IRL time to open the depot roller door is ~3.0 seconds (NTSC on N64 hardware). How do I calculate 3 seconds from those numbers above?
 
View user's profile Send private message
Lazlo52
Secret Agent
Secret Agent


Joined: 18 Nov 2017
Posts: 331
Location: N.J.

 PostPosted: Thu Jul 22, 2021 12:45 pm    Post subject: Reply with quote Back to top

l'm not too keen on the specifics of doors because l've always copy-pasted from other doors, but here's what l understand...

Distance Travels is how much the door will travel, where zero is closed and the provided value is fully open. Walkthru Distance is the point at which you can walk through the door (this is how vertical doors work).

Acceleration affects how long it takes for the door to reach full speed. I don't know what Rate does or how Acceleration is scaled, so check some existing doors for examples. It might actually be acceleration, then deceleration.

Max Speed is how fast the door will ultimately move, of course.

Time Open is how long the door will stay open until it automatically closes. It says (ms), but this is false, it's 60 cycles (frames) per second. 0x384 is 900, which is perfectly aligned with 15 seconds, and the Depot doors indeed stay open for 15 seconds.


So, for the purpose of determining how 3 seconds lines up with the door opening, I'd say it's a combination of Distance Travels, Acceleration, Rate, and Max Speed.
_________________
Quote:
22 not happening nerds. forget about it. 23 til the day i die.
 
View user's profile Send private message
Trevor
007
007


Joined: 15 Jan 2010
Posts: 926
Location: UK, Friockheim OS:Win11-Dev PerfectGold:Latest

 PostPosted: Fri Jul 23, 2021 3:16 am    Post subject: Reply with quote Back to top

Quote:
Time Open is how long the door will stay open until it automatically closes. It says (ms), but this is false, it's 60 cycles (frames) per second. 0x384 is 900, which is perfectly aligned with 15 seconds, and the Depot doors indeed stay open for 15 seconds.


This actually perfectly explains the time difference you are seeing since PAL is 50, so 900/50 = 18 secs

Trev
_________________
 
View user's profile Send private message
tolos
Agent
Agent


Joined: 17 Jan 2021
Posts: 6

 PostPosted: Sat Jul 24, 2021 3:17 pm    Post subject: Reply with quote Back to top

Alright, here's a summary of my findings. Thanks to trevor, ryan, carnviorous, whiteted along the way.

The original question I posted about was, given a set of configuration parameters, how do you tell how long it will take for a door to go from closed to open?

Basically the answer is to do the same thing the game does, and simulate the door opening by stepping it along one frame at a time. Once you know the number of frames you can convert from framerate to realtime.

This was part of a larger question which I wrote a C# program for, to collect some door information for every level in the game, across NTSC and PAL. If you care, the project is on github, https://github.com/burnsba/GoldeneyeDoorCalc .

The ApplySpeed function below simulates what happens in the game. The CalcOpen method resets the door state then calls ApplySpeed until the door is considered open, or too many iterations pass (some of the automatically collected "door" objects this program was written for were not actually doors). Once that's done, the door's OpenFrames property will contain the number of frames it took to open.

Relevant code from the door class:

Code:

public double DistanceDone { get; set; } = 0.0;
public double MaxDistance { get; set; } = 0.0;
public double Speed { get; set; } = 0.0;
public double Acceleration { get; set; } = 0.0;
public double Deceleration { get; set; } = 0.0;
public double MaxSpeed { get; set; } = 0.0;
public int OpenFrames { get; set; } = 0;
public bool OpenDone { get; set; } = false;
public int ToMaxSpeedFrames { get; set; } = 0;
public bool ToMaxSpeedDone { get; set; } = false;
public int StartDecelFrame = 0;

// ...

public void ApplySpeed()
{
    var localSpeed = Speed;

    var limit = localSpeed * localSpeed * 0.5 / Deceleration;
    var distRemaining = MaxDistance - DistanceDone;

    if (distRemaining > 0.0)
    {
        if (localSpeed > 0.0 && distRemaining <= limit)
        {
            if (StartDecelFrame == 0)
            {
                StartDecelFrame = OpenFrames;
            }

            // Slow down for end
            localSpeed -= Deceleration;

            if (localSpeed < Deceleration)
            {
                localSpeed = Deceleration;
            }
        }
        else if (localSpeed < MaxSpeed)
        {
            // Accelerate
            if (localSpeed < 0.0)
            {
                localSpeed += Deceleration;
            }
            else
            {
                localSpeed += Acceleration;
            }

            if (localSpeed >= MaxSpeed)
            {
                localSpeed = MaxSpeed;
                ToMaxSpeedDone = true;
            }

            if (!ToMaxSpeedDone)
            {
                ToMaxSpeedFrames++;
            }
        }

        if (localSpeed >= distRemaining)
        {
            DistanceDone = MaxDistance;
            OpenDone = true;
        }

        DistanceDone += localSpeed;

        if (!OpenDone)
        {
            OpenFrames++;
        }
    }
    else
    {
        if (localSpeed < 0.0 && -distRemaining <= limit)
        {
            localSpeed += Deceleration;

            if (localSpeed > -Deceleration)
            {
                localSpeed = -Deceleration;
            }
        }
        else if (localSpeed > -MaxSpeed)
        {
            if (localSpeed > 0.0)
            {
                localSpeed -= Deceleration;
            }
            else
            {
                localSpeed -= Acceleration;
            }

            if (localSpeed < -MaxSpeed)
            {
                localSpeed = -MaxSpeed;
            }
        }

        if (localSpeed <= distRemaining)
        {
            DistanceDone = MaxDistance;
            //break;
        }

        DistanceDone += localSpeed;
    }

    Speed = localSpeed;
}

public void CalcOpen()
{
    Speed = 0;
    DistanceDone = 0;
    OpenFrames = 0;
    ToMaxSpeedFrames = 0;

    OpenDone = false;
    ToMaxSpeedDone = false;
    PositionCalcValid = null;

    for (var i = 0; i < MaxOpenCalcIterations; i++)
    {
        ApplySpeed();
        if (OpenDone && ToMaxSpeedDone)
        {
            PositionCalcValid = true;
            break;
        }
    }

    if (PositionCalcValid != true)
    {
        PositionCalcValid = false;
    }
}
 
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ShootersForever.com Forum Index -> Q-Lab Hacking Department All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Cobalt 2.0 BB theme/template by Jakob Persson.
Copyright © 2002-2004 Jakob Persson


Powered by BB © 01, 02 BB Group

 


Please Visit My Other Sites: GoldenEyeForever.com | GrandTheftAutoForever.com

Got kids? Check out my Dora The Explorer site with games and coloring pages!

Our forums feature Nintendo 64 games, GoldenEye 007 N64 New Maps and Missions, GoldenEye Cheats, N64 Emulator, Gameshark, GoldenEye Multiplayer and more!

[ Privacy Policy ]