Skip to content

World Processing Cycle

Pazaz edited this page May 18, 2024 · 39 revisions

Each section is listed in order.

Some unknowns...

  • run energy recovery processing details: where does it live in player processing
  • longqueue processing details: where to execute accelerated scripts/discard scripts
  • how they cancel logout e.g. a trigger called "logout" that runs when the player requests to logout
  • how they cancel movement e.g. a trigger called "movecheck" that runs pre-movement

World processing

  • world queue
  • NPC spawn scripts
  • NPC hunt

Client input

  • read packets
    • may resume suspended script (pausebutton, countdialog)
  • calculate pathfinding request (if not using clientside pathfinding)

note: pathfinding calculates once at the end to save processing time! do not do it for every move packet
note: if using clientside pathfinding, the server still has to validate the input (like every other packet should)

NPC processing

  • if not busy:
    • resume suspended script
    • stat regen
    • timer
    • queue
    • movement
    • modes

note: npc stat regen is done at the engine level here, not like player stat regen
note: null mode will set to default mode (config) this tick, which will run starting next tick

Controller processing

  • timer
  • queue

note: controllers do not exist in these early years. Included for completeness.

Player processing

  • resume suspended script if it was delayed
  • primary queue: normal, strong (late 2004+), soft (osrs?)
    • if strong is in the queue at all, close interface
    • running strong closes interface
    • do not run script if busy (delayed || modal)
  • weak queue
  • timers
  • soft timers
  • engine queue
    • levelup trigger, queued after gaining a level
    • area trigger, not in 2004
  • loc/obj interactions
  • movement (the pathfinding request)
  • player/npc interactions
  • close interface if attempting to logout

note: closing interfaces clears weak queue
note: player stat regen is a soft timer
note: player run energy recovery is at the engine level (not controlled in runescript)
note: weak queues were introduced september 2004, and strong came separately after that
note: while movecheck is just a theory, we are able to override freezes with other effects which proves there can only be 1 registered trigger

Player logout

  • remove player if they have nothing in their queue

Zone processing

  • Loc/obj despawn/respawn
  • Compute shared event buffers

Client output

  • map update (load new zones)
  • player info
  • npc info
  • zone updates
  • inv changes
  • stat changes
  • flush packets