Scripts

From The Elite Wiki
Revision as of 17:27, 18 July 2021 by en>BurnsBA (add references, Wyst3r's recommended video on AI)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Goldeneye makes use of scripts to control high level behaviour in the various stages. These can easily be viewed in the function explorer pages or less easily using the setup editor. Be aware that both have some interpretation inaccuracies. The scripts come in two types, level scripts and character scripts. All scripts have unique names made up of 4 hexadecimal characters.

Although the scripts describe a large part of the logic of a level, there is of course a large amount of standard guard logic relating to routing, shooting, etc. which is down in the raw assembly code. And there are types of objects which are specific to one level, i.e. the table and chairs in the exhaust room on Aztec which are actually a special kind of door. Of course the commands themselves are defined in the assembly, and often include subtleties which aren't captured in a simple name. Some of these are described in detail on pages here.

In a cycle, subsequent commands are run until an 03 or yield statement is reached. The next cycle will continue after that yield.

The purpose of the scripts was ultimately to keep the size of the ROM low, as expressing the same logic in raw assembly for each level would take up a lot more space. [1].

Level scripts

Level scripts, denoted by codes 10XX, are not attached to a specific character in the level. They always run each game frame in the order that they are listed. This is markedly different from the character scripts, which often run only after a specific delay, i.e. of 0.30s (rounded up into game frames).

The majority of objectives are triggered by setting flags in the level scripts, though objectives can be set up separately, i.e. the destruction objectives on Runway. They will also usually control all spawning, for instance on Streets and Surface 1, but there are odd exceptions where these are done by specific characters.

Exiting the level is always triggered by a level script. With the game tick, this is before the mission timer is incremented, which is exploited in the Pause trick on Cradle and Train.

Fake characters

The cradle scripts complicate the picture slightly, since the 1003 script assigns itself the 0409 script. A fuller understanding of the code here explains this situation: For each level script in the setup, a "fake character" is assigned. These characters are very incomplete i.e. they don't have a location or a model or the like, but they do provide a "surface" to run the scripts from. In this case the "1003 script character" is reassigned with the 0409 script. This allows them to separate the logic when Trev is at various different locations into separate scripts, without having them all running at once (which would happen if they were all 10XX scripts). However it breaks the general distinction of 04XX scripts being attached to a full character, and so being able to run commands like "walk to this specific pad".

Character scripts

Character, or guard, scripts are only called by characters (Guards and NPCs) in the level. Each script can be run by many characters simultaneously, with each tracking their state (position in the script, current timer, etc.) separately. These scripts have access to a wider set of commands which can effect the attached guard i.e. making them attack or run to a specific pad.

After the level end is triggered by a level script on the final frame, the character scripts still run one last time on all versions. This can include character scripts setting flags which complete objectives. On NTSC-U this allows the Time not saved glitch on facility, frigate, train and control. [2]

Delays

Depending on the character's current action, there is a different delay between two cycles of character scripts. Each game tick, the frame width (in native ticks) is subtracted from the remaining delay. If this is less than 0 then the script is executed, and the delay will be set again later in the character update.

Note that this table is incomplete.

NTSC delays
Action Delay time Logic
Moving or shooting 0
Facing Bond (e.g. Val) 0
Idle (no animation) 0.25-0.32s Random
Surrendering 0.25-0.32s Random


This delay is set late in the character's update routine, in particular after the character has updated their animation. An example of the effect of this is that following a trev shot, Trev will not greet Bond on the same frame that he finishes his death animation. Going through his update on this frame he'll

  1. Run his script, and the 2F command will say that he's still animating
  2. Finish his injury animation, and become idle
  3. Set his script delay based on being idle, so for 0.25 - 0.32s

When he next runs his script, at least 0.25s later, he'll greet Bond and start his timer. Hence some randomness (on top of the selected injury animation), and any further delay from lag, is unavoidable.

Associated phenomena

This delay is quite a core feature of Goldeneye's scripts, and makes its presence known a lot in speedrunning. It is the cause of (list inexhaustive):

  • Randomness in the console door lure at the start of Facility
  • Nat's variable eyesight in Archives
  • The truly random delay before Val sees you on Streets SA / 00A and Statue
  • More randomness in the speed of Frigate hostages
  • Random success/failure when looking up very early to trigger Nat to open the door out of the 1st area in Control
  • Trev's random response time at the start of Caverns


In general the small randomness in the idle delay leads to a random 0-0.32s delay before idle characters respond to some event. Any levels which involve NPC interactions will be effected by it. TASes on some levels such as Facility have to perform heavy RNG manipulation throughout the run to align delays favourably.

External Links

References

  1. rwhitegoose. "Talking Goldeneye with Dr. Doak". Retrieved July 16, 2021.
  2. Whiteted. "the-elite forum Goldeneye facts post on time not saved glitch". Retrieved July 16, 2021.