Scripts Expand Overworld Sprites - haven1433/HexManiacAdvance GitHub Wiki

Return to List of Utilities and Scripts

Overworld Sprites

In the vanilla games, which Overworld Sprite gets assigned to which Overworld Object is decided by a 1-byte value in the Overworld Sprite. By default, the table is allowed to be up to 240 elements long, because the last 16 values are 'reserved' for dynamic sprites. Basically, if you set an object's graphics to be 240, it'll read from variable gfx0 (0x4010), and then use the sprite from the table based on that value. A graphics value of 241 will read from gfx1 (0x4011), 242 will read from gfx2 (0x4012), etc.

Expansion

Running this script expands the capabilities of this built-in system in 3 ways:

  • If the matching gfx variable is set to 0, the game will instead load a sprite from graphics.overworld.sprites in the normal way. This lets you put 255 sprites in the original table. (After applying this script, switching maps will reset the gfx variables to 0 to facilitate this.)
  • If the matching gfx variable is greater than 10000, the game will load a pokemon icon. An additional table called graphics.overworld.pokemon is added to facilitate this.
  • If the matching gfx variable is greater than 20000, the game will load an Overworld Sprite from a new graphics.overworld.sprites20k table. This table can have any number of overworld sprites in it.

Examples:

graphics index gfx variable gfx value result
46 N/A N/A graphics.overworld.sprites/46
246 gfx6 0 graphics.overworld.sprites/246
246 gfx6 19 graphics.overworld.sprites/19
249 gfx9 10019 graphics.overworld.pokemon/19 (Ratatta)
250 gfxA 20019 graphics.overworld.sprites20k/19
254 gfxE 0 graphics.overworld.sprites/254

Setting the graphics variable for the OW object.

The best way to set the gfx variables is in a Map Header Transition script. See Viridian City for an example (the old man that needs his coffee).

map header panel

script