Skip to content

Gameflow2

Adalid Claure edited this page Sep 17, 2025 · 1 revision

NPC Scripting Language Specification (Assembly/VPL Hybrid)

This scripting language defines low-level commands to control NPC behavior in a survival-horror strategy game. It is stack-based, flag-driven, and uses CLI-style flow control with jump labels. This language is primarily intended as an internal backend for a Visual Programming Language (VPL) interface and content authoring.


πŸ—‚οΈ Keyword Categories

πŸ”Έ Variable & Stack Management

  • PUSH β€” Push a value onto the stack (e.g., $CURRENT_LOCATION)
  • POP β€” Pop the top of the stack into a register or discard
  • SET β€” Assign a value to a register (e.g., SET $R0 1)
  • CLEAR β€” Clear/reset a register or flag
  • ADD β€” Add two values and store the result (e.g., ADD $R0 1 -> $R0)
  • INCR β€” Increment a value (syntactic sugar for ADD)

πŸ”Έ Flow Control

  • LABEL β€” Define a jump target (e.g., LABEL:retry)
  • JUMP β€” Unconditional jump to label (e.g., JUMP retry)
  • JUMP_IF β€” Jump to label if a flag/register is truthy (e.g., JUMP_IF $FLAG0 success)
  • JUMP_UNLESS β€” Jump to label unless a flag/register is truthy
  • JUMP_IF_NULL β€” Jump to label if a register is null or empty
  • GOTO β€” Move NPC to a location or point in the world

πŸ”Έ Method Invocation / Actions

  • CALL β€” Invoke a method on a system variable or item (e.g., CALL $EQUIPPED_ITEM "pull_pin")
  • EQUIP β€” Equip a specific item from inventory (e.g., EQUIP [Grenade])
  • DROP β€” Drop a held or equipped item
  • FIND β€” Search for an item in the environment (sets $FOUND, $FOUND_LOCATION)

πŸ”Έ Data Structures / Lists

  • DEFINE_LIST β€” Define a named list of strings (e.g., DEFINE_LIST $SEARCH_POINTS "Point1" "Bathroom")
  • GET_FROM_LIST β€” Get an entry at index from list (e.g., GET_FROM_LIST $SEARCH_POINTS $R0 -> $R1)
  • POP_FROM_LIST β€” Pop and retrieve the top of a list (LIFO-style)
  • LOAD_SEARCH_POINT β€” Retrieve a search point by index (optional legacy op)

πŸ’Ύ Register & Flag Conventions

  • $R0, $R1, ... β€” General-purpose registers
  • $FLAG0, $FLAG1 β€” Boolean flags
  • $FOUND β€” Boolean, set by FIND
  • $FOUND_LOCATION β€” Position set by successful FIND
  • $RET β€” Return label for simulated call-return flow

🧠 Example

PUSH $CURRENT_LOCATION
DEFINE_LIST $SEARCH_POINTS "Point1" "PointB" "Bathroom"
SET $R0 0
SET $RET end_search
JUMP search_loop

LABEL:search_loop
    GET_FROM_LIST $SEARCH_POINTS $R0 -> $R1
    JUMP_IF_NULL $R1 end_search

    GOTO $R1
    FIND [Grenade]
    JUMP_IF $FOUND found_grenade

    ADD $R0 1 -> $R0
    JUMP search_loop

LABEL:found_grenade
    GOTO $FOUND_LOCATION
    EQUIP [Grenade]
    CALL $EQUIPPED_ITEM "pull_pin"
    GOTO "Enemy Camp"
    CALL $EQUIPPED_ITEM "throw"
    DROP $EQUIPPED_ITEM
    POP -> $R1
    GOTO $R1

LABEL:end_search
    GOTO "Home"
0

Clone this wiki locally