Plotlite.hsd

From OHRRPGCE-Wiki
Jump to navigationJump to search


Obsolete.png
This article (or part thereof) is obsolete. It may have made sense in the past, but it does not make sense now. It is kept here only for historic curiosity and/or posterity.

This file has not been updated to to match the latest version of plotscr.hsd

This is an alternative HSD file for use with OHRRPGCE, and is invented by User:Zzo38, who agrees to post in public domain if possible.

This file is imported instead of plotscr.hsd; you should not import both files. HSpeak will automatically include plotscr.hsd; you should pass the -b commandline argument to HSpeak to prevent this. (Note that if plotscr.hsd isn't included then you will need to explicitly include scancode.hsi.) Also, it is intended to be imported using shell scripts rather than through CUSTOM, and not using the "export .hsi" option. It is meant to work with numeric scripts, attacks, menus, etc rather than the named ones. You can use HAMARC to delete the COMMANDS.BIN, SCRIPTS.TXT, and SCRIPTS.BIN lumps from the compiled .HSP file, since those lumps are unnecessary and take up extra space; HAMARC is also used to splice the compiled scripts into the .RPG file.

This file uses shorter names for most functions, as well as sometimes multiples each with different defaults, and will result in smaller compiled files. There are also a few predefined scripts:

  • GENSET: Set a general bitset, using the GB: constants. (For example GENSET(GB:CATERPILLAR) enables caterpillar mode.)
  • GENCLEAR: Clear a general bitset, using the GB: constants.
  • ILAST: Get the index of the last inventory slot.
  • EQDEL: Clears an equipment slot, without affecting the contents of the inventory. (UNEQUIP is a built-in which is similar but adds the removed item to the inventory.)
  • EQSET: Set the contents of an equipment slot, without affecting the contents of the inventory. (If the item to set in the slot is NOITEM then it acts the same as EQDEL.) (DOEQUIP is a built-in which is similar but takes it out of the inventory, and puts into the inventory the item that used to be equipped, if any.)
  • STRSAVE: Allocates a hidden slice to save a string and returns the ID number for restoring it with.
  • STRLOAD: Given the string number to write into, and the ID number returned by STRSAVE, reload the saved string. After doing this, the saved ID number is no longer valid.

Note: When downloading this file it is necessary to delete the <pre> tag and stuff above it, as well as the final </pre> tag.

# PLOTLITE.HSD

# Use same capitalisation as HSpeak does, pad to length 3
PLOTSCRVERSION("3P ","3P ")

DEFINEFUNCTION(
  0,NOOP,0 # no operation
  1,WAIT,1,1 # wait specified number of ticks
  2,AWAIT,0 # wait for everything to stop moving
  3,HWAIT,1,0 # wait for hero to stop moving
  4,NWAIT,1,0 # wait for NPC to stop moving
  5,NPCMOVE-OFF,0 # stop NPC movement
  6,CONTROL-OFF,0 # turn off default controls except textboses
  7,NPCMOVE-ON,0 # undo NPCMOVE-OFF
  8,CONTROL-ON,0 # undo CONTROL-OFF
  9,KEYWAIT,1,99 # wait for a key and return the scancode
  10,HWALK,3,0,2,1 # Cause hero to walk (who,dir,count)
  11,TEXTBOX,1,1 # Display a text box (script continues)
  12,TSET?,1,0 # Check if a tag is set
  13,TSET,2,0,1 # Set a tag
  13,TCLEAR,2,0,0 # Clear a tag
  15,ENTER,1,0 # Activate a door
  16,BATTLE,1,0 # Call a battle formation; return true if you win
  17,IINC,2,0,1 # Increase quantity of item in inventory
  18,IDEC,2,0,1 # Decrease quantity of item in inventory
  19,LEADER,0 # Current leader ID
  20,MINC,1,1 # Increase money
  21,MDEC,1,1 # Decrease money
  22,MDEC?,1,1 # If you can afford it, decrease money and return true
  23,UNEQUIP,2,0,1 # Unequip slot (who,slot)
  24,DOEQUIP,3,0,1,0 # Equip slot (who,slot,item)
  27,OVERLAY-OFF,0 # Turn off overlay, making them normal tiles instead
  28,MUSIC,1,0 # Play music
  29,MUSIC-STOP,0 # Stop music
  30,KEYCODE,1,0 # Tell you the state of a key
  32,BACKDROP,1,0 # Show a .MXS picture instead of the map
  33,BACKDROP-OFF,0 # Turn off the BACKDROP
  34,DISMOUNT,0 # Dismount the active vehicle
  40,PAN,3,0,1,2 # Pan the camera (dir,dist,speed)
  41,CFOCUS,3,0,0,2 # Cause camera to move to a point (x,y,speed)
  42,CWAIT,0 # Wait until camera is finished moving
  43,HEROX,1,0 # Hero X coordinate (who)
  44,HEROY,1,0 # Hero Y coordinate (who)
  45,NPCX,1,0 # NPC X coordinate (who)
  46,NPCY,1,0 # NPC Y coordinate (who)
  49,WALL-OFF,0 # Let hero walk through walls
  51,WALL-ON,0 # Prevents hero from walking through walls
  52,NWALK,3,0,2,1 # Cause NPC to walk (who,dir,count)
  53,HFACE,2,0,2 # Set hero facing (who,dir)
  54,NFACE,2,0,2 # Set NPC facing (who,dir)
  59,BOXWAIT,0 # Wait until no textboxes are open
  60,EQSLOT?,2,0,0 # Where it can be equipped (who,item)
  61,TELEPORT,3,0,0,0 # Teleport to (map,x,y)
  62,BATTLE-OFF,0 # Turn off foemap battles
  63,BATTLE-ON,0 # Turn on foemap battles
  64,HSGET,3,0,0,0 # Get current hero stat (who,stat)
  64,HSMGET,3,0,0,1 # Get maximum hero stat (who,stat)
  64,HSBGET,3,0,0,2 # Get base hero stat (who,stat)
  64,LEVELGET,3,0,12,0 # Get hero level (who)
  65,OVERLAY-ON,0 # Turn back on overlay disabled by OVERLAY-OFF
  66,HADD,1,0 # Add a hero to the party
  67,HDEL,1,0 # Delete a hero from the party
  68,HOUT,1,0 # Swap out a hero
  69,HIN,1,0 # Swap in a party
  70,PARTY?,0 # Number of free slots in active party
  71,HLOCK,1,0 # Lock a hero
  72,HUNLOCK,1,0 # Unlock a hero
  73,QUIT,0 # Quit; return to title screen if not bypassed in gen
  74,ONDEATH,1,0 # Set script to run when all heros is dead
  75,FADEOUT,3,0,0,0 # Fade out screen (r,g,b) (range 0-63)
  76,FADEIN,0 # Fade in the screen
  77,SHOWNUM,1,0 # Display a number in the bottom-left corner
  78,NPCPUT,3,0,0,0 # Write to NPC registers (who,which,data)
  79,SHOWOFF,0 # Turn off SHOWNUM
  80,MAP,0 # Current map ID
  81,HSPEED,2,0,4 # Set speed of hero movement (who,speed)
  82,INVENTORY?,1,0 # How many you have in the inventory
  83,HSPUT,4,0,0,0,0 # Put current hero stat (who,stat,value)
  83,HSMPUT,4,0,0,0,1 # Put maximum hero stat (who,stat,value)
  83,HSBPUT,4,0,0,0,2 # Put base hero stat (who,stat,value)
  84,TBA-OFF,0 # Turn off manual control of text box advancing
  85,TBA-ON,0 # Resume manual control of text box advancing
  86,TBA,0 # Advance the text box
  87,HPLACE,3,0,0,0 # Place hero (who,x,y)
  88,NPLACE,3,0,0,0 # Place NPC (who,x,y)
  89,HSWAP,2,0,0 # Swap two hero slots
  90,HFIND,1,0 # Find slot number of hero (who)
  91,EQGET,2,0,1 # Look at equipment (who,slot)
  96,HZPUT,2,0,0 # Set hero jump height (who,height)
  97,TILEGET,3,0,0,0 # Get tile at (x,y,layer)
  98,TILEPUT,4,0,0,0,0 # Put tile at (x,y,value,layer)
  99,WALLGET,2,0,0 # Get passability at (x,y)
  100,WALLPUT,3,0,0,0 # Put passability at (x,y,value)
  101,NDGET,1,0 # Get NPC direction
  102,HDGET,1,0 # Get PC direction
  108,RANDOMIZE,1,0 # Random seed
  110,HPICPUT,3,0,0,1
  111,HPALPUT,3,0,0,1
  112,HPICGET,2,0,1
  113,HPALGET,2,0,1
  114,VALUE,1,0 # Read script global by index
  115,SET,2,0,0 # Write script global by index (var,value)
  116,WALKING?,1,0 # Check if hero is walking (who)
  118,FOLLOW-OFF,0 # Turn off automatic caterpillar movement
  119,FOLLOW-ON,0 # Turn on automatic caterpillar movement
  120,NPC,2,0,0 # Get a reference to a NPC (id,num)
  121,NPCAT,3,0,0,0 # Get NPC at (x,y,which if multiples)
  121,NPCATCOUNT,3,0,0,-1 # How many NPCs at (x,y)
  122,NPCIDGET,1,0
  123,NPCCOUNT,1,0 # How many of specified NPC is on map (id)
  124,NPCIDPUT,2,0,0 # Set ID of an NPC (who,id)
  125,NPCNEW,4,0,0,0,2
  126,NPCDEL,1,0 # Delete a NPC
  127,SPTEACH,2,0,0 # Teach a spell if learnable by item (who,attack+1)
  128,SPFORGET,2,0,0 # Hero forgets a spell (who,attack+1)
  129,SPGET,3,0,0,0 # Read spell slot (who,list,slot)
  130,SPPUT,4,0,0,0,0 # Write spell slot (who,list,slot,attack+1)
  131,SPKNOWN?,2,0,0 # Check if spell known (who,attack+1)
  132,SPLEARN?,3,0,0,0 # Check if spell learnable by item (who,attack+1)
  133,SLOTHID,1,0 # Get hero ID by slot
  134,RANKHID,1,0 # Get hero ID by marching order
  135,PUTHEROP,3,0,0,0
  136,PUTNPCP,3,0,0,0
  137,CAMSETP,2,0,0
  138,HEROPX,1,0
  139,HEROPY,1,0
  140,NPCPX,1,0
  141,NPCPY,1,0
  142,CAMPX,0
  143,CAMPY,0
  144,TILESET,2,-1,-1
  145,ASKHERO,0 # Ask which hero you want, returns -1 if canceled
  146,NAMEHERO,1,0 # Ask the name of the hero
  147,GENGET,1,0 # Read general data
  148,GENPUT,2,0,0 # Write to general data
  150,STATUSSCREEN,1,0 # Status screen for specified hero
  151,MINIMAP,0 # Show entire map in small view
  152,SPELLS,1,0 # Spells menu for specified hero
  153,ITEMS,0 # Display inventory menu
  154,EQUIP,1,-1 # Display equipment menu (who)
  157,ORDER,0 # Display order menu
  158,TEAM,0 # Display team menu
  159,MOUSEON,0 # Enable mouse functions
  160,MOUSEX,0
  161,MOUSEY,0
  162,BUTTON?,0 # Check if mouse button is pushed
  163,MWARP,2,160,100 # Set position of mouse pointer
  164,MOUSE-LIMIT,4,-1,-1,-1,-1
  166,SAVE,1,0 # Save game in specified slot
  167,SAVELAST,0
  170,ASKSAVE,1,0 # Ask which slot to save (doesn't actually save)
  171,SAVED?,1,1 # Tells if a save game exists
  172,SAVEGET,3,1,-1,-1
  173,SAVEPUT,3,1,0,16383
  174,RESTORE,1,1 # Restore a save game
  175,DELSAVE,1,1 # Delete a save game
  176,CALL,-1 # Call a script dynamically (script,args...)
  178,MAPGET,1,0
  179,MAPPUT,2,0,0
  180,MAPWIDTH,1,-1 # Get width of map
  181,MAPHEIGHT,1,-1 # Get height of map
  182,NPCGET,2,0,0
  183,LEVELPUT,3,0,0,1 # Set hero level (who,level)
  183,LEVELPUTNF,3,0,0,0 # As above but remember spells if level down
  184,XPADD,2,-1,1 # Add experience to hero (who,amount)
  185,LEVELUP?,1,0 # Check if specified hero levelled up
  187,VOLGET,0 # Get current volume
  188,VOLPUT,1,128 # Set current volume
  193,NPCEXGET,2,0,1 # Get NPC extra data 0-2 (who,ext)
  194,NPCEXPUT,3,0,1,0 # Put NPC extra data 0-2 (who,ext,value)
  197,SOUND,3,1,0,0 # Play sound (id,loop,preempt)
  198,SOUND-PAUSE,1,1 # Pause sound (id)
  199,SOUND-STOP,1,1 # Stop and rewind sound (id)
  200,RTCH,0 # Real-time-clock hours
  201,RTCM,0 # Real-time-clock minutes
  202,RTCS,0 # Real-time-clock seconds
  203,SONG,0 # Current song playing
  204,STRHERO,2,0,0 # Hero name (str,who)
  205,HRENAME,2,0,0 # Change name of hero by script (str,who)
  206,STRITEM,2,0,0 # Name of item (str,item)
  207,STRMAP,2,0,0 # Name of map (str,map)
  210,SHOWSTR,1,0 # Show string in bottom-left (str)
  211,STRCLEAR,1,0 # Clear a string
  212,STRAPP,2,0,0 # Append character to string (str,char)
  213,STRAPPN,2,0,0 # Append number to string (str,num)
  214,STRCOPY,2,0,0 # Copy string (dest,src)
  215,STRCAT,2,0,0 # Concatenate string (dest,src)
  216,STRLEN,1,0 # Length of string (str)
  217,STRDEL,2,0,1 # Delete character from string (str,pos)
  218,STRPUT,3,0,1,0 # Set character in string (str,pos,char)
  219,STRGET,2,0,1 # Get character from string (str,pos)
  220,STRMOVE,3,0,0,0 # Set string position on screen (str,x,y)
  221,STRSHOW,3,0,0,1 # Make string visible (str)
  221,STRHIDE,3,0,0,0 # Make string invisible (str)
  221,STRFLAT,3,0,1,1 # Make string flat (no outline) (str)
  221,STROUTLINE,3,0,1,0 # Make string with outline (str)
  222,STRSHOWN?,2,0,0 # Check if string is visible (str)
  222,STRFLAT?,2,0,1 # Check if string is flat (str)
  223,STRCOLOR,3,0,15,0 # Set color of string (str,fg,bg)
  226,RTCDAY,0 # Real-time-clock days
  227,RTCMO,0 # Real-time-clock months
  228,RTCY,0 # Real-time-clock years (Anno Domini)
  229,STREQ?,2,1,0 # Check if two strings match (str1,str2)
  230,EGET,2,0,0 # Enemy get (id,which)
  231,EPUT,3,0,0,0 # Enemy put (id,which,value)
  232,TRACE,1,0 # Write string to debug file
  233,STRSONG,2,0,0 # Get name of song (str,song)
  235,KEY?,2,0,0 # Is the key pushed now or previous tick? (key,stick)
  236,SOUND?,1,0 # Tell you if the sound is playing
  238,STRLOOK,3,0,0,1 # Search in the string (str1,str2,start)
  239,STRTRIM,3,0,-1,1 # Trim string (str,start,length)
  241,STREXP,1,0 # Expand a string like a textbox does
  242,JBUTTON?,2,0,0 # Tell you if joystick button pushed (button,stick)
  243,JAXIS,3,0,100,0 # Joystick axis (axis,mult,stick)
  244,SCANWAIT,1,0 # Wait for a key by scancode
  249,GOLD,0
  250,SETGOLD,1,0
  251,setstringfromtable,2,0,0
  252,appendstringfromtable,2,0,0
  256,AUTOMUSIC-OFF,0 # Disable auto changing music when moving to a map
  257,AUTOMUSIC-ON,0 # Undo AUTOMUSIC-OFF
  258,HBLOCKED?,2,0,0 # Check if hero is blocked (who,dir)
  259,NBLOCKED?,2,0,0 # Check if NPC is blocked (who,dir)
  260,TIMER,6,0,-1,-1,-1,-1,-1 # Set timer (id,count,speed,trig,str,flag)
  260,TIMERNORM,6,0,-1,-1,-1,-1,0 # Set a normal timer
  260,TIMERCRIT,6,0,-1,-1,-1,-1,3 # Set a critical timer
  260,TIMERCRITM,6,0,-1,-1,-1,-1,7 # Set a critical timer (incl. menu)
  260,TIMERBAT,6,0,-1,-1,-1,-1,2 # Set a battle-inclusive timer
  260,TIMERBATM,6,0,-1,-1,-1,-1,6 # Set a battle-inclusive timer (menu)
  262,TIMER?,1,0 # Check timer count; false if expired
  265,RGB,3,0,0,0 # Make RGB value (r,g,b)
  269,XPGET,1,0 # Total experience of hero (who)
  270,XPTO,1,0 # Experience to reach level from lv.0 (level)
  271,XPNEXT,1,0 # How much experience needed for next level (who)
  272,XPPUTF,3,0,0,1 # Set experience, allow forgetting (who,value)
  272,XPPUTR,3,0,0,0 # Set experience, remembering spells (who,value)
  274,MENU,2,0,0 # Show menu (id)
  274,MENUDUP,2,0,1 # Show another copy even if the menu is already open
  275,MENUGET,2,0,0
  276,MENUPUT,3,0,0,0
  277,MIGET,2,0,0 # Menu item get
  278,MIPUT,3,0,0,0 # Menu item put
  279,MNEW,0 # Make up a new blank menu
  280,MDEL,1,0 # Delete a menu created with MNEW
  281,MTOP?,0 # Handle to top menu; false if no menu is open
  282,MFRONT,1,0 # Move to front
  283,MADD,1,0 # Add menu item (menuh)
  284,MIDEL,1,0 # Delete menu item (itemh)
  286,MITEXT,2,0,0 # Set menu caption (itemh,str)
  287,SSGET,2,0,0 # Get Vancian MP (who,row)
  288,SSPUT,3,0,0,0 # Set Vancian MP (who,row,value)
  289,MBOT?,0
  290,MBELOW?,1,0 # Get menu below this one (false if none)
  291,MABOVE?,1,0 # Get menu above this one (false if none)
  292,MSITEM,3,0,0,0 # Menu item by slot (menuh,slot,visibleonly)
  293,MIPREV?,2,0,1 # Get previous menu item (false if none)
  294,MINEXT?,2,0,1 # Get next menu item (false if none)
  295,MCURSOR,1,-1 # Where is the cursor (menuh)
  296,MISELECT,1,0 # Move menu cursor (itemh)
  297,MILOC,1,0 # Get menu that an item belongs to (itemh)
  302,MOPEN?,1,0 # Check if menu handle is valid
  303,MISLOT,1,0
  304,ATTACK,3,0,0,-1 # Execute OOB attack (attack,target,user)
  308,FADD,5,0,0,85,95,-1
  309,FFIND,3,0,0,0
  310,FDEL,2,0,0
  314,FBGSET,4,0,0,1,0
  315,FBGGET,1,0
  316,FLAST,0 # Last formation fought
  317,FRANDOM,1,0 # Pick a random formation from a set
  320,CURBOX,0 # Current textbox number (NOITEM if none)
  322,SPNEW0,2,0,-1 # Create a PT0 sprite slice (picture,palette)
  324,SLPOS,3,0,0,0 # Set position of slice (slice,x,y)
  327,SPCHANGE0,3,0,0,-1 # Change sprite into PT0 (slice,picture,pal)
  328,SPFSET,2,0,0 # Sprite frame number (slice,frame)
  329,SPNEW4,2,0,-1
  330,SPCHANGE4,3,0,0,-1
  331,SPNEW5,2,0,-1
  332,SPCHANGE5,3,0,0,-1
  333,SPNEW1,2,0,-1
  334,SPCHANGE1,3,0,0,-1
  335,SPNEW2,2,0,-1
  336,SPCHANGE2,3,0,0,-1
  337,SPNEW3,2,0,-1
  338,SPCHANGE3,3,0,0,-1
  339,SPNEW6,2,0,-1
  340,SPCHANGE6,3,0,0,-1
  341,SPNEW7,2,0,-1
  342,SPCHANGE7,3,0,0,-1
  343,SPNEW8,2,0,-1
  344,SPCHANGE8,3,0,0,-1
  345,SPCLONE,2,0,0 # Create a new slice with the same sprite (slice)
  346,SPFGET,1,0 # Get sprite frame (slice)
  348,SLXGET,1,0 # Get slice X position (slice)
  349,SLYGET,1,0
  350,SLXPUT,2,0,0 # Put slice X position (slice,value)
  351,SLYPUT,2,0,0 # Put slice Y position (slice,value)
  352,SLWGET,1,0
  353,SLHGET,1,0
  360,DEFCON,0 # Default container for created sprites
  361,SLFREE,1,0 # Delete a slice (slice)
  362,SLFIRST,1,0 # First child slice (slice)
  363,SLNEXT,1,0 # Next sibling slice (slice)
  364,SLNEWCON,2,0,0 # New container slice (width,height)
  365,SLINSET,2,0,0
  366,SLIN?,2,0,0
  367,SLXSCR,1,0
  368,SLYSCR,1,0
  370,SLNEWRECT,3,0,0,-1 # New rectangular slice (width,height,style)
  372,SLWPUT,2,0,0 # Put slice width (slice,value)
  373,SLHPUT,2,0,0 # Put slice height (slice,value)
  374,SLSTGET,1,0 # Get rect style (slice)
  375,SLSTPUT,2,0,0 # Put rect style (slice,style)
  382,SLTRANS?,1,0 # Get translucency of rect slice (slice)
  383,SLSOLID,2,0,0 # Set rect translucency to solid (slice)
  383,SLFUZZY,2,0,1 # Set rect translucency to fuzzy (slice)
  383,SLHOLLOW,2,0,2 # Set rect translucency to hollow (slice)
  384,SLAT?,3,0,0,0 # Check if slice hits point (slice,x,y)
  385,SLHIT?,2,0,0 # Check if two slices collide (slice1,slice2)
  386,SLCIN?,2,0,0 # Check if slice2 is positioned inside slice1
  387,SLCLAMP,2,0,0 # Clamp slice1's position to be inside slice2
  400,SLFILL,2,0,1 # Make slice fill parent (slice)
  400,SLNOFILL,2,0,0 # Turn off slice fill parent (slice)
  401,SLFILL?,1,0 # Check if slice is filling parent
  402,SLFRONT,1,0 # Move slice to front
  403,SLBACK,1,0 # Move slice to back
  405,SLYSORT,1,0 # Sort children of slice by Y coordinates
  406,SLOPUT,2,0,0 # Set priority of slice; deferred until SLSORT
  407,SLSORT,2,0,1 # Sort children as defined by SLOPUT and reset values
  407,SLSORTNW,2,0,0 # As SLSORT but SLOPUT values aren't reset
  409,SLOGET,1,0 # Read back value set by SLOPUT
  410,SLEXGET,2,0,0 # Read extra 0-2 data from a slice (slice,ext)
  411,SLEXPUT,3,0,0,0 # Write extra data to a slice (slice,ext,value)
  412,SPTYPE,1,0
  413,SPID,1,0
  414,SPPGET,1,0
  415,TPAUSE,0 # Pause all timers
  416,TRESUME,0 # Resume timers paused by TPAUSE
  417,SLSHOW,2,0,1 # Make a slice visible (slice)
  417,SLHIDE,2,0,0 # Make a slice invisible (slice)
  418,SLSHOWN?,1,0 # Query visibility of slice (slice)
  419,SLEX,2,0,0
  420,SLEY,2,0,0
  421,SLNEWTEXT,0 # Make a new text slice
  422,SLPUTTEXT,2,0,0 # Set text of slice (slice,str)
  423,SLTCGET,1,0 # Get text color (slice)
  424,SLTCPUT,2,0,0 # Put text color (slice,color)
  425,SLWRAP?,1,0 # Query text wrapping (slice)
  426,SLWRAP,2,0,1 # Set slice to wrap text (slice)
  426,SLNOWRAP,2,0,0 # Set slice to don't wrap text (slice)
  428,SLBGGET,1,0 # Get background color of text slice (slice)
  429,SLBGPUT,2,0,0 # Put background color of text slice (slice)
  430,SLOL?,1,0 # Check if text has outline (slice)
  431,SLOLSET,2,0,1 # Turn on text outline (slice)
  431,SLOLCLEAR,2,0,0 # Turn off text outline (slice)
  432,MIACT,1,0 # Activate menu item (itemh)
  435,SLLOC,1,0 # Parent of a slice (slice)
  436,SLCOUNT,1,0 # Number of children of a slice (slice)
  437,SLLOOK,2,0,0 # Find slice by lookup code (code,slice)
  438,RESTART,0 # Restart the entire game
  439,SLVALID?,1,0
  440,IGET,1,0 # Read inventory item (invslot)
  441,IPUT,2,0,0 # Set inventory item (invslot,item)
  442,IGETCOUNT,1,0 # Read inventory count (invslot)
  443,IPUTCOUNT,2,0,0 # Set inventory count (invslot,count)
  445,SPELLUP,2,0,1 # Update spells learned by level (who,forget)
  446,SLBELOW,2,0,0
  447,SLABOVE,2,0,0
  451,SLCLIP,2,0,1 # Make slice to clip children
  451,SLNOCLIP,2,0,0 # Make slice to don't clip children
  452,SLCLIP?,1,0
  453,SLNEWGRID,4,0,0,1,1 # Make a grid slice (width,height,rows,cols)
  455,SLGCPUT,2,0,1 # Put grid columns (slice,value)
  456,SLGCGET,1,0 # Get grid columns (slice)
  457,SLGRPUT,2,0,1 # Put grid rows (slice,value)
  458,SLGRGET,1,0 # Get grid rows (slice)
  461,SLLOAD,1,0 # Load a slice collection (id)
  464,SLCODEGET,1,0
  465,SLCODEPUT,2,0,0 # Set a slice's lookup code (slice,data)
  468,STRATT,2,0,0 # Name of attack (str,attack+1)
  470,TALLOC,1,16 # Set number of timers
  480,ZSET?,3,0,0,0 # Check if tile has zone (zone,x,y)
  481,ZSET,4,0,0,0,1 # Add zone to tile (zone,x,y)
  481,ZCLEAR,4,0,0,0,0 # Remove zone from tile (zone,x,y)
  483,ZCOUNT,1,0 # How many tiles in a zone (zone)
  487,STRZONE,2,0,0 # Get zone name (str,zone)
  488,ZXGET,2,0,0
  489,ZXPUT,3,0,0,0
  490,USEITEM,1,0 # Activate effect of item (item)
  491,USESLOT,1,0 # Use item of inventory (invslot)
  492,CLICKED?,1,0
  493,SPNEWMXS,1,0 # Make a backdrop slice (id)
  494,SPCHANGEMXS,2,0,-1 # Change into a backdrop slice (slice,id)
  495,SPTRANS?,1,0 # Check if sprite is transparent (slice)
  496,SPTRANS,2,0,1 # Make sprite transparent (slice)
  496,SPOPAQUE,2,0,0 # Make sprite opaque (slice)
  497,HERPUT,3,-1,0,100 # Set base hero element resist (who,elem,percent)
  498,HERGET,2,-1,0 # Get base hero element resist (who,elem)
  499,HERTGET,2,-1,0 # Get calculated hero element resist (who,elem)
  516,CHECKPT,0 # In autotest mode, write out checkpoint data
  519,SLHERO,1,0 # Slice representing hero walkabout
  520,SLNPC,1,0 # Slice representing NPC walkabout
  521,DXGET,1,0 # Get X coordinate of a door
  522,DYGET,1,0 # Get Y coordinate of a door
  523,DDIDGET,1,0 # Get destination door ID of a door
  524,DMAPGET,1,0 # Get destination map ID of a door
  525,DOOR?,1,0 # Check if a door exists
  530,STRSLICE,2,0,0 # Load slice text into a string (str,slice)
  531,INPUT,1,0 # Read typed text into a string (str)
  532,INPUT-ON,1,1 # Allow INPUT working
  532,INPUT-OFF,1,0 # Turn off INPUT
  533,INPUT-ON?,0 # Check if text input is turned on
  544,HZGET,1,0 # Get hero Z coordinate (who)
  545,HSCGET,1,0 # Read stat cap (stat)
  546,HSCPUT,2,0,0 # Write stat cap (stat,value)
  547,IMSGET,1,0 # Get maximum stack size of an item (item)
  548,NZGET,1,0 # Read NPC Z (npc)
  549,NZPUT,2,0,0 # Write NPC Z (npc,value)
  550,DOORAT,2,0,0 # Door at tile (x,y) (NOITEM if there is no door)
  551,DOORS-OFF,0 # Cause doors to stop working
  552,DOORS-ON,0 # Cause doors to work normally
)

DEFINETRIGGER(
  0,SCRIPT
)

DEFINECONSTANT(

# General data constants
  0,GEN:MAXMAP
  1,GEN:TITLE
  2,GEN:TITLEMUS
  3,GEN:VICTMUS
  4,GEN:BATMUS
  26,GEN:PT0
  27,GEN:PT1
  28,GEN:PT2
  29,GEN:PT3
  30,GEN:PT4
  31,GEN:PT5
  32,GEN:PT6
  33,GEN:MAXTILE
  34,GEN:MAXATTACK
  35,GEN:MAXHERO
  36,GEN:MAXENEMY
  37,GEN:MAXFORM
  38,GEN:MAXPAL
  39,GEN:MAXSAY
  41,GEN:START
  42,GEN:QUIT
  43,GEN:MAXSCRIPT
  44,GEN:SUSPEND
  45,GEN:CAMERA
  46,GEN:CAMERA1
  47,GEN:CAMERA2
  48,GEN:CAMERA3
  49,GEN:CAMERA4
  50,GEN:SCRBACK
  51,GEN:DAYS
  52,GEN:HOURS
  53,GEN:MINUTES
  54,GEN:SECONDS
  55,GEN:MAXVEH
  57,GEN:RESTORE
  58,GEN:TBB
  59,GEN:DISSOLVE
  60,GEN:JOY
  61,GEN:PIND
  62,GEN:SIND
  63,GEN:DAMAGECAP
  64,GEN:MIND
  65,GEN:CAP-HP
  66,GEN:CAP-MP
  67,GEN:CAP-ATK
  68,GEN:CAP-AIM
  69,GEN:CAP-DEF
  70,GEN:CAP-DOG
  71,GEN:CAP-MAG
  72,GEN:CAP-WIL
  73,GEN:CAP-SPD
  74,GEN:CAP-CTR
  75,GEN:CAP-FOCUS
  76,GEN:CAP-HITS
  77,GEN:MAXSFX
  80,GEN:MAXMENU
  82,GEN:MAXITEM
  83,GEN:PT7
  84,GEN:PT8
  85,GEN:INVSLOT
  86,GEN:ERROR
  87,GEN:LEVELCAP
  88,GEN:EQMERGE
  89,GEN:ELEMENTS
  90,GEN:URESXP
  91,GEN:LRESXP
  92,GEN:PASSWORD
  95,GEN:COMPAT
  96,GEN:MONEY
  97,GEN:MAXSHOP
  100,GEN:MXSCOUNT
  101,GEN:BITS1
  102,GEN:STARTX
  103,GEN:STARTY
  104,GEN:STARTMAP
  171,GEN:DEATHSFX
  172,GEN:MAXSONG
  173,GEN:SFX-ACCEPT
  174,GEN:SFX-CANCEL
  175,GEN:SFX-CHOOSE
  176,GEN:SFX-LETTER
  177,GEN:BITS2
  178,GEN:BITS3
  179,GEN:SFX-LEARN
  180,GEN:SFX-NOLEARN
  181,GEN:SFX-BUY
  182,GEN:SFX-HIRE
  183,GEN:SFX-SELL
  184,GEN:SFX-POOR
  185,GEN:SFX-NOSELL
  186,GEN:DAMTICKS
  187,GEN:DAMRISE
  188,GEN:HWEAK
  189,GEN:EWEAK
  190,GEN:AUTOSORT
  191,GEN:LEVELMAX
  192,GEN:BATTLEMODE
  193,GEN:STACK

# General bitset constants
  0,GB:MENUPAUSE
  1,GB:CATERPILLAR
  2,GB:NORESTHP
  3,GB:NORESTMP
  4,GB:NORESURRECT
  5,GB:HEROSWAP
  6,GB:NOREADY
  7,GB:NOHPBAR
  8,GB:NODEBUG
  9,GB:LEVELBUG
  10,GB:DTRIGGER
  11,GB:NOTITLE
  12,GB:NOLOAD
  13,GB:BPAUSE
  14,GB:NOBCURSOR
  15,GB:DISPASS
  16,GB:PUSHBUG
  17,GB:NORUN
  18,GB:NOSCRIPTSAVE
  19,GB:DEADXP
  20,GB:LOCK
  21,GB:CAPPAUSE
  22,GB:FIXEDREADY
  23,GB:ANIMWAIT
  24,GB:SCANCODE
  25,GB:OLDRESIST
  26,GB:IMMUNE
  27,GB:RESLICE
  28,GB:HARMALL
  29,GB:NOHITS
  30,GB:NOXPDIV
  31,GB:NORESETOOB
  32,GB:MORETAGS

# Autosort modes
  0,AS:TYPE
  1,AS:USABLE
  2,AS:ALPHA
  3,AS:ID
  4,AS:COMPACT

# Error suppression levels
  2,ERR:ALL
  3,ERR:SOME
  4,ERR:REL
  5,ERR:OLD
  6,ERR:HIDE

# Map data constants
  0,MAP:TILESET
  1,MAP:MUSIC
  2,MAP:MINI
  3,MAP:SAVE
  4,MAP:NAMEDISP
  5,MAP:EDGEMODE
  6,MAP:EDGE
  7,MAP:AUTORUN
  8,MAP:ARG
  9,MAP:HDAMAGE
  10,MAP:HFLASH
  11,MAP:FOOT
  12,MAP:AFTERBATTLE
  13,MAP:ONBATTLE
  14,MAP:ONSTEP
  15,MAP:ONKEY
  16,MAP:ZORDER
  17,MAP:NPERSIST
  18,MAP:TPERSIST
  19,MAP:LAYER
  20,MAP:SAVX
  21,MAP:SAVY
  25,MAP:NPCCOUNT
  31,MAP:WALKLAYER
  32,MAP:MZONE
  33,MAP:AZONE

# Menu data constants
  12,MENU:STYLE
  13,MENU:COLOR
  14,MENU:ROWS
  15,MENU:BITS
  16,MENU:XOFF
  17,MENU:YOFF
  18,MENU:XANC
  19,MENU:YANC
  20,MENU:ALIGN
  24,MENU:ONCLOSE

# Menu item data constants
  0,MI:PARENT
  21,MI:SORT
  22,MI:TYPE
  23,MI:SUBTYPE
  24,MI:TAG1
  25,MI:TAG2
  26,MI:STAG
  27,MI:TTAG
  28,MI:BITS
  29,MI:EXT0
  30,MI:EXT1
  31,MI:EXT2

# NPC data constants
  0,NPC:PICTURE
  1,NPC:PALETTE
  2,NPC:MOVE
  3,NPC:SPEED
  4,NPC:TEXT
  5,NPC:FACE
  6,NPC:ITEM
  7,NPC:PUSH
  8,NPC:ACTMODE
  9,NPC:TAG1
  10,NPC:TAG2
  11,NPC:ONETIME
  12,NPC:SCRIPT
  13,NPC:ARG
  14,NPC:VEH
  15,NPC:MZONE
  16,NPC:AZONE

# Menu types
  0,MT:LABEL
  1,MT:BUILTIN
  2,MT:MENU
  3,MT:TEXTBOX
  4,MT:SCRIPT

# Battle stats
  0,HP
  1,MP
  2,STRENGTH
  3,ACCURACY
  4,DEFENSE
  5,DODGE
  6,MAGIC
  7,WILL
  8,SPEED
  9,COUNTER
  10,FOCUS
  11,HITS

# Directions
  0,NORTH
  1,EAST
  2,SOUTH
  3,WEST

# Built-in slice codes
  -100000,SL:ROOT
  -100001,SL:TBTEXT
  -100002,SL:TBPIC
  -100003,SL:TBC0
  -100004,SL:TBC1
  -100016,SL:TBBOX
  -100017,SL:TBPBOX
  -100018,SL:TBCBOX
  -100019,SL:TBR
  -100005,SL:SCRIPTL
  -100006,SL:BOXL
  -100007,SL:STRL
  -100008,SL:MAP
  -100009,SL:OH
  -100010,SL:WALK
  -100011,SL:HERO
  -100012,SL:NPC
  -100013,SL:SPRITE
  -100014,SL:SHADOW
  -100015,SL:MXS
  -101000,SL:ML0
  -101001,SL:ML1
  -101002,SL:ML2
  -101003,SL:ML3
  -101004,SL:ML4
  -101005,SL:ML5
  -101006,SL:ML6
  -101007,SL:ML7

# Miscellaneous constants
  -1,NOITEM

)

define operator,begin
20 ^   exponent
30,mod,modulus
30 /   divide
30 *   multiply
40 --  subtract
40 +   add
50 ==  equal
50 <>  notequal
50 <<  lessthan
50 >>  greaterthan
50 <   lessthan
50 >   greaterthan
50 <=  lessthanorequalto
50 >=  greaterthanorequalto
60,xor,xor
60,and,and
60,or, or
65 &&  logand
70 ||  logor
70 ^^  logxor
80 :=  setvariable
80 +=  increment
80 -=  decrement
80 $+  concatenatestrings
80 $=  copystring
end

SCRIPT,GENSET,HSD:X( # Turn on a general bitset (which)
  IF(HSD:X<<16)THEN(
    GENPUT(GEN:BITS1,(GENGET(GEN:BITS1),OR,(2^HSD:X)))
    EXITSCRIPT
  )
  IF(HSD:X<<32)THEN(
    GENPUT(GEN:BITS2,(GENGET(GEN:BITS2),OR,(2^(HSD:X--32))))
    EXITSCRIPT
  )
  IF(HSD:X<<48)THEN(
    GENPUT(GEN:BITS3,(GENGET(GEN:BITS3),OR,(2^(HSD:X--48))))
    EXITSCRIPT
  )
)

SCRIPT,GENCLEAR,HSD:X( # Turn off a general bitset (which)
  GENPUT(GEN:BITS1,(GENGET(GEN:BITS1),XOR,65535))
  GENPUT(GEN:BITS2,(GENGET(GEN:BITS2),XOR,65535))
  GENPUT(GEN:BITS3,(GENGET(GEN:BITS3),XOR,65535))
  GENSET(HSD:X)
  GENPUT(GEN:BITS1,(GENGET(GEN:BITS1),XOR,65535))
  GENPUT(GEN:BITS2,(GENGET(GEN:BITS2),XOR,65535))
  GENPUT(GEN:BITS3,(GENGET(GEN:BITS3),XOR,65535))
)

SCRIPT,ILAST( # Last inventory slot number
  IF(GENGET(GEN:INVSLOT))THEN(
    RETURN((((GENGET(GEN:INVSLOT)+3)/3)*3)--1)
  )ELSE(
    RETURN(599)
  )
)

# Very klugy implementations follow. It would be more sensible to
# implement DOEQUIP and UNEQUIP in terms of EQSET and EQDEL rather
# than the other way around. However, it doesn't work that way.

SCRIPT,EQDEL,HSD:X,HSD:Y( # Delete equipment in slot (who,slot)
  VARIABLE(HSD:A,HSD:B,HSD:C,HSD:D)
  HSD:A:=EQGET(HSD:X,HSD:Y)
  IF(HSD:A==NOITEM)THEN(EXITSCRIPT)
  # Find the slot containing the item to remove
  FOR(HSD:B,0,ILAST)DO(
    IF(IGET(HSD:B)==HSD:A)THEN(
      # We already have this item
      # Save the amount and temporarily remove it
      HSD:C:=IGETCOUNT(HSD:B)
      IPUTCOUNT(HSD:B,0)
      # Remember if there are further inventory slots with the same item
      HSD:D:=INVENTORY?(HSD:A)
      # Unequip the item; adds it to your inventory
      UNEQUIP(HSD:X,HSD:Y)
      # Discard the item if it has been added due to unequipping
      IF(INVENTORY?(HSD:A)>>HSD:D)THEN(IDEC(HSD:A))
      # Put it back in
      IPUT(HSD:B,HSD:A)
      IPUTCOUNT(HSD:B,HSD:C)
      # Finished
      EXITSCRIPT
    )
  )
  # We don't already have such an item in the inventory
  # Temporarily use the first slot
  HSD:A:=IGET(0)
  HSD:B:=IGETCOUNT(0)
  # Clear it to make room for the item
  IPUTCOUNT(0,0)
  # Unequip it; if the item is added to inventory, it is added to slot 0
  UNEQUIP(HSD:X,HSD:Y)
  # Restore the inventory slot 0
  IPUT(0,HSD:A)
  IPUTCOUNT(0,HSD:B)
)

SCRIPT,EQSET,HSD:X,HSD:Y,HSD:Z( # Set equipment in slot (who,slot,item)
  VARIABLE(HSD:A,HSD:B)
  # First remove the item in the reasonable way
  EQDEL(HSD:X,HSD:Y)
  # Skip the rest if nothing is to be added to the equipment slot
  IF(HSD:Z==NOITEM)THEN(EXITSCRIPT)
  # Find the slot containing such an item, if any
  FOR(HSD:B,0,ILAST)DO(
    IF(IGET(HSD:B)==HSD:Z)THEN(
      # Remember it
      HSD:A:=IGETCOUNT(HSD:B)
      # Do equip
      DOEQUIP(HSD:X,HSD:Y,HSD:Z)
      # Put back the item in the inventory
      IPUT(HSD:B,HSD:Z)
      IPUTCOUNT(HSD:B,HSD:A)
      # Finished
      EXITSCRIPT
    )
  )
  # There wasn't any, so it is safe to just DOEQUIP
  DOEQUIP(HSD:X,HSD:Y,HSD:Z)
)

SCRIPT,STRSAVE,HSD:X( # Temporary save a string (str)
  VARIABLE(HSD:A)
  HSD:A:=SLNEWTEXT
  SLPUTTEXT(HSD:A,HSD:X)
  SLHIDE(HSD:A)
  RETURN(HSD:A)
)

SCRIPT,STRLOAD,HSD:X,HSD:Y( # Restore a saved string (str,saved)
  STRSLICE(HSD:X,HSD:Y)
  SLFREE(HSD:Y)
)