Skip to content
tustin2121 edited this page Aug 15, 2022 · 1 revision

Welcome to my scratch space.

ScriptContext1 =>

  • Context status
    • Set to 0 when
      • Set when a new script is set up to run in it. This also enables context 2.
      • Script is "set up", which means the union room is waiting for it to tear down
    • Set to 1 when
      • Context is "stopped"
      • Script context 2 cannot be run?
    • Set to 2 when
      • Context is re-inited to empty.
      • Also set when the script in context 1 runs out.
      • Script context 2 cannot be run?
  • It looks like ScriptContext2 is enabled and disabled based also on whether this context is enabled.
    • It might just be using that variable to stop execution in the overworld, and it has nothing to do with the script context?
  • Runs the following items: (via ScriptContext1_SetupScript)
    • Map header scripts from MAP_SCRIPT_ON_FRAME_TABLE
    • EventScript_StartTrainerApproach when trainer battles are being initiated from trainer eyeline in the overworld
    • In the decoration code...
      • To dip into script language then dip back to native code a lot...
    • In the overworld...
      • To run any interaction scripts.
      • To run dive and emerge scripts.
      • To run sign post scripts
      • To run some walking/metatile scripts, like falling down a hole or warping to the next battle pyramid floor.
      • To run on-step scripts, ie:
        • Overworld poison
        • Egg hatching
        • Story-related Match Call scripts
        • The regice puzzle
        • Abnormal weather cleanup
        • SS Tidal arrival script
      • To run the overworld HM / secret power scripts
      • To run EventScript_SelectWithoutRegisteredItem
      • To run berry / watering related event scripts
      • To run interact and menu scripts in the cable club
      • To turn off the bedroom PCs
      • To run the safari zone stopping scripts
        • (except if you're out of balls mid-battle, presumably because that is run mid-battle and context 1 might be busy?)
      • To run secret base scripts (see also decorating)
      • To run EventScript_RepelWoreOff

ScriptContext2 =>

  • ScriptContext2_RunNewScript runs the script immediately and until the script ends or waits
    • ScriptContext2_RunScript runs script context 1???
  • sScriptContext2Enabled is unrelated, see below
  • Runs the following items: (via ScriptContext2_RunNewScript)
    • Most Map header scripts
      • Also specifically scripts from MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE
    • In the overworld...
      • Coordinate event ("trigger") scripts
    • Mystery Event Scripts
    • EventScript_ResetAllMapFlags during New Game initialization
    • EventScript_WhiteOut during white out
    • EventScript_ResetMrBriney during teleporting
    • SafariZone_EventScript_OutOfBallsMidBattle during the safari zone

sScriptContext2Enabled =>

  • When true:
    • Time-based events do not run in the overworld.
    • Player input is ignored in the overworld.
    • Something about key intercepts in Link mode?
    • Objects are frozen in the union room
    • Summary: It seems the only thing it does is lock player controls in the overworld.
  • Set to true when:
    • Any time Script Context 1 is set up with a new script, and any time it is running a script.
      • It is also redundantly set to true in many places after ScriptContext1_SetupScript is called
    • At the start if any battle
    • The cable car cutscene
    • At the start of wireless trades, contests, trades, cutscenes, minigames.
      • Also showing berry crush and contest rankings / results
    • When an egg is about to start hatching.
    • Before any warp via a warp tile.
      • Also possibly redundantly in the Do*Warp() functions.
    • Before pushing boulders or stepping on mats which control avatar movement.
    • When starting / stopping surfing.
    • In many of the field callbacks, include ContinueScript and returning to field with things open.
    • In every field callback which does an animation.
    • At the start of match calls.
    • When opening menus such as:
      • The start menu
      • The party menu to choose contest pokemon
      • The storage system
      • The shop menu

Notes:

  • The following are misnamed:
    • sScriptContext2Enabled => sLockFieldControls
    • ScriptContext2_Enable => LockPlayerFieldControls
    • ScriptContext2_Disable => UnlockPlayerFieldControls
    • ScriptContext2_IsEnabled => ArePlayerFieldControlsLocked
    • ScriptContext2_RunScript => ScriptContext1_RunScript
      • context 2 is entirely unrelated, and it runs commands in context 1
    • EnableBothScriptContexts => ScriptContext1_Enable

Clone this wiki locally