Hero#

Inherits: sprite

Contains functions and variables related to the playable hero character.

Access with Hero->.

Variables#

int

HitDir

int

SwordJinx

int

ItemJinx

int

HP

int

MP

int

MaxHP

int

MaxMP

int

Action

int

TileMod

int

HeldItem

bool[]

Item

int[]

Steps

int

Step

int

ShoveOffset

int

Drunk

int

HealthBeep

bool

Invisible

bool

NoStepForward

bool

CollDetection

int[]

Defense

untyped[]

HitBy

const int

LadderX

const int

LadderY

int

InvFrames

bool

InvFlicker

int

HurtSound

int

ItemB

int

ItemA

int

ItemX

int

ItemY

int

Eaten

bool

Grabbed

int

Stun

int

BunnyClk

int

Pushing

int

ScriptCSet

bool

Diagonal

bool

BigHitbox

bool

Climbing

int

JumpCount

const int

PitPullDir

int

PitPullTimer

bool

ClockActive

int

ClockTimer

const bool

IsWarping

int

RespawnX

int

RespawnY

int

RespawnDMap

int

RespawnScreen

const int

SwitchTimer

const int

SwitchMaxTimer

int

Immortal

const bool

Standing

int

CoyoteTime

lweapon

LiftedWeapon

int

LiftTimer

int

LiftMaxTimer

int

LiftHeight

int

HammerState

bool[]

LiftFlags

int

ShieldJinx

int

FlickerColor

int

FlickerTransparencyPasses

const int

FlashingCSet

const int

Sliding

const int

IceCombo

int

ScriptIceCombo

int

IceVx

int

IceVy

int

IceEntryFrames

int

IceEntryMaxFrames

bool

InputStart

bool

InputMap

bool

InputUp

bool

InputDown

bool

InputLeft

bool

InputRight

bool

InputA

bool

InputB

bool

InputL

bool

InputR

bool

InputEx1

bool

InputEx2

bool

InputEx3

bool

InputEx4

bool

PressStart

bool

PressUp

bool

PressDown

bool

PressLeft

bool

PressRight

bool

PressA

bool

PressB

bool

PressL

bool

PressR

bool

PressEx1

bool

PressEx2

bool

PressEx3

bool

PressEx4

int

InputMouseX

int

InputMouseY

int

InputMouseZ

int

InputMouseB

bool

InputAxisUp

bool

InputAxisDown

bool

InputAxisLeft

bool

InputAxisRight

bool

PressAxisUp

bool

PressAxisDown

bool

PressAxisLeft

bool

PressAxisRight

bool

PressMap

const int

TotalDYOffset

int

Equipment

Functions#

void

Warp(int DMap, int screen)

void

WarpEx(int[] ptr)

void

Explode(int arg1)

void

PitWarp(int arg1, int arg2)

void

SelectAWeapon(int dir)

void

SelectBWeapon(int dir)

void

SelectXWeapon(int dir)

void

SelectYWeapon(int dir)

bool

SwitchCombo(int pos, int effect)

void

Kill(bool bypass_revive = false)

bool

MoveXY(int dx, int dy, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

bool

CanMoveXY(int dx, int dy, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

bool

MoveAtAngle(int degrees, int pixels, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

bool

CanMoveAtAngle(int degrees, int pxamnt, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

bool

Move(int dir, int pixels, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

bool

CanMove(int dir, int pxamnt, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true)

lweapon

ReleaseLiftWeapon()

void

LiftWeapon(lweapon arg1, int arg2, int arg3)

bool

isFlickerFrame()

void

Warp(int arg1)

void

SetItemA(int arg1)

void

SetItemB(int arg1)

void

SetItemSlot(int itm_id, int button, int force)

int

GetOriginalTile(int arg1, int arg2)

int

GetOriginalFlip(int arg1, int arg2)

Enumerations#

enum HeroSliding: ๐Ÿ”— Source

HeroSliding SLD_NONE = 0

HeroSliding SLD_ICE = 1

sliding on the ground, on ice

HeroSliding SLD_AIR = 2

sliding in the air (momentum from ice)

HeroSliding SLD_MAX = 3


Variable descriptions#

int HitDir ๐Ÿ”— Source


int SwordJinx ๐Ÿ”— Source


int ItemJinx ๐Ÿ”— Source


int HP ๐Ÿ”— Source


int MP ๐Ÿ”— Source


int MaxHP ๐Ÿ”— Source


int MaxMP ๐Ÿ”— Source


int Action ๐Ÿ”— Source


int TileMod ๐Ÿ”— Source

The current *total* Hero Tile Modifier.


int HeldItem ๐Ÿ”— Source


bool[] Item ๐Ÿ”— Source

Reading from, or writing to this array no longer causes lag.


int[] Steps ๐Ÿ”— Source

The number of pixels that the Hero moves in a frame, based on present coordinates. The movement is taken from X and Y:

x_move_in_pixels = Hero->Steps[Hero->X&7];
y_move_in_pixels = Hero->Steps[Hero->Y&7];

The default values are: { 1, 1, 2, 1, 1, 2, 1, 1 }

You can double the speed by doubling these values.

NOTE: This only affects 4-way movement, and has no effect if the quest rule New Hero Movement is enabled.


int Step ๐Ÿ”— Source

The rate the Hero moves at. This is similar to npc::Step: a step of 100 moves the Hero 1 pixel per frame. The default step rate is 150, which moves the Hero 1.5 pixels per frame.

NOTE: This affects BOTH 4-way and 8-way movement, but ONLY if the quest rule New Hero Movement is enabled.


int ShoveOffset ๐Ÿ”— Source

The offset from corners that the Heroโ€™s movement will โ€˜shoveโ€™ them around. Ranges from 0-16

NOTE: Only applies if Newer Hero Movement Quest Rule is enabled.


int Drunk ๐Ÿ”— Source


int HealthBeep ๐Ÿ”— Source

The timer for the health beep sound, if it is not constant.

Setting this to -2 suspends system control over stopping the sound, and setting this to -4 suspends system control over both stopping, and starting it.

The normal operating range used by the system is 70 to -1, where -1 wraps around to zero internally.


bool Invisible ๐Ÿ”— Source


bool NoStepForward ๐Ÿ”— Source

If set true, the Hero will not take two steps into NES dungeon rooms.

This value is reset to false every time that the hero sprite is initialised, so should be written ideally in the hero init script.

!! Future versions may change when this is cleared.


bool CollDetection ๐Ÿ”— Source


int[] Defense ๐Ÿ”— Source

Unused at this time.


untyped[] HitBy ๐Ÿ”— Source

Stores the ID/UIDs of objects that hurt the Link this frame.


const int LadderX ๐Ÿ”— Source


const int LadderY ๐Ÿ”— Source


int InvFrames ๐Ÿ”— Source

This returns how long Link will remain invincible, 0 if not invincible. Can be set.


bool InvFlicker ๐Ÿ”— Source

If set false, Link will neither flash, nor flicker when invincible.


int HurtSound ๐Ÿ”— Source

The sound that plays when Link is injured. By default this is 16, but you may change it at any time.


int ItemB ๐Ÿ”— Source

Contains the item IDs of what is currently equiped to Linkโ€™s B button.


int ItemA ๐Ÿ”— Source

Contains the item IDs of what is currently equiped to Linkโ€™s A button.


int ItemX ๐Ÿ”— Source

Contains the item IDs of what is currently equiped to Linkโ€™s X (Ex1) button.


int ItemY ๐Ÿ”— Source

Contains the item IDs of what is currently equiped to Linkโ€™s Y (Ex2) button.


int Eaten ๐Ÿ”— Source

Returns 0 if the Hero is not eaten, otherwise it returns the duration of them being eaten.


bool Grabbed ๐Ÿ”— Source

Returns if the Hero is grabbed (i.e. by wallmaster)


int Stun ๐Ÿ”— Source

Returns the number of frames for which Link will; remain stunned.

Writing to this causes Link to be stunned for โ€˜nโ€™ frames.

This decrements once per frame.


int BunnyClk ๐Ÿ”— Source

Returns the number of frames for which the Hero will be a Bunny.

If -1, the effect will be removed by the engine if the current

dmap does not have the bunny flag, or the Hero possesses a pearl item.

-2 through -99 reserved for potential future engine use If <-100, the effect will last until script-modified

If >0, will tick down each frame


int Pushing ๐Ÿ”— Source

Returns the number of frames that Link has been pushing against a solid object.


int ScriptCSet ๐Ÿ”— Source


bool Diagonal ๐Ÿ”— Source

This corresponds to whether โ€˜Diagonal Movementโ€™ is enabled, or not.


bool BigHitbox ๐Ÿ”— Source

This corresponds to whether โ€˜Big Hitboxโ€™ is enabled, or not.


bool Climbing ๐Ÿ”— Source

Returns as โ€˜trueโ€™ when the hero is climbing a sideview ladder

Setting to โ€˜falseโ€™ will let go of the ladder, and setting โ€˜trueโ€™ will grab the ladder

While โ€˜trueโ€™, gravity does not affect the hero


int JumpCount ๐Ÿ”— Source

Returns the number of times the hero has jumped in mid-air since last landing.

If this is positive, it will be reset to 0 the next frame the hero is on the ground.

Used by Rocโ€™s Feather items to determine how many extra jumps the hero has left


const int PitPullDir ๐Ÿ”— Source

Returns the direction that the Hero is being pulled in by a pit


int PitPullTimer ๐Ÿ”— Source

A timer related to pits pulling the hero

The pit will only pull the hero on frames where โ€˜PitPullTimer % PitSensitivity == 0โ€™

The Pit Sensitivity is an attribyte on the pit combo


bool ClockActive ๐Ÿ”— Source

Returns true if a stopwatch/clock is active.

Writing to this acts like picking up a stopwatch/clock item, and sets the duration of its effect based on ClockTimer. If ClockTimer is 0, the effect.

Lasts until the Hero changes screens.


int ClockTimer ๐Ÿ”— Source

Returns the current ticks of a stopwatch/clock item countdown timer.

Writing to this while ClockActive is true sets or changes the duration of the clock effect; if no stopwatch/clock is active, it pre-sets the value so that you may start a timed effect by setting ClockActive to true.


const bool IsWarping ๐Ÿ”— Source

Returns true if the Hero is currently being warped

Note that as scripts generally do not run in warps, this may not ever return true during a given warp, depending on the warp type, QRs, script type, etc.


int RespawnX ๐Ÿ”— Source

The X-coordinate at which the Hero will respawn upon drowning or such.

The engine may overwrite this value upon changing screens or standing on safe ground.


int RespawnY ๐Ÿ”— Source

The Y-coordinate at which the Hero will respawn upon drowning or such.

The engine may overwrite this value upon changing screens or standing on safe ground.


int RespawnDMap ๐Ÿ”— Source

The DMap at which the Hero will respawn upon drowning or such.

The engine may overwrite this value upon changing screens or standing on safe ground.


int RespawnScreen ๐Ÿ”— Source

The screen at which the Hero will respawn upon drowning or such.

The engine may overwrite this value upon changing screens or standing on safe ground.


const int SwitchTimer ๐Ÿ”— Source

The timer for the switchhook effect. If > 0, a switch effect is active.

The Hero will swap positions with the target when this is equal to Hero->SwitchMaxTimer / 2, and the animation completes when this reaches 0.


const int SwitchMaxTimer ๐Ÿ”— Source

The starting (max) value of the switch timer.


int Immortal ๐Ÿ”— Source

If non-zero, the Hero will not die, even if their HP drops to 0.

This will prevent effects such as bottled fairies from being triggered.

If greater than 0, decrements by 1 each frame.

If it becomes 0 while the Hero has 0 hp, it will act as though their HP just dropped to 0 that frame, and normal effects such as fairies will trigger.


const bool Standing ๐Ÿ”— Source

Returns true if the hero is โ€˜standingโ€™, as is used to check if they are capable of jumping. Automatically accounts for sideview.


int CoyoteTime ๐Ÿ”— Source

The number of frames the hero has been off the ground. Range 0-65535.

0 while standing. When not standing, ticks up by 1 each frame.

When jumping, is immediately set to 65535.

If this value is < 65535 and < a featherโ€™s โ€œCoyote Timeโ€ attribute, the feather will be able to jump despite being in the air.

Setting this to 65535 will disable coyote jumps, though this will be set to 0 upon landing on the ground again.


lweapon LiftedWeapon ๐Ÿ”— Source


int LiftTimer ๐Ÿ”— Source


int LiftMaxTimer ๐Ÿ”— Source


int LiftHeight ๐Ÿ”— Source


int HammerState ๐Ÿ”— Source

Returns a value representing the current hammer swing. - 0 = not swinging hammer - 1 = hammer above head - 2 = hammer at angle - 3 = hammer hit the ground


bool[] LiftFlags ๐Ÿ”— Source


int ShieldJinx ๐Ÿ”— Source

The time, in frames, that the shield is disabled. Negative values disable indefinitely.


int FlickerColor ๐Ÿ”— Source

This sets what color Link is drawn when flickering.

If -1, will use the default from Init Data.

If the quest rule โ€˜Invincible Hero Flickersโ€™ is unchecked, this is unused.


int FlickerTransparencyPasses ๐Ÿ”— Source

This sets how many times the transparency effect is applied to Linkโ€™s flicker effect.

If -1, will use the default from Init Data. If 0, will use a solid color.

If the quest rule โ€˜Invincible Hero Flickersโ€™ is unchecked, this is unused.


const int FlashingCSet ๐Ÿ”— Source

This returns Linkโ€™s current displayed cset when taking damage or invincible. If not in one of these states, will return his normal cset.

If called before Waitdraw() / Hero update, results may be off by a frame.

If the quest rule โ€˜Invincible Hero Flickersโ€™ is checked, this is unused.


const int Sliding ๐Ÿ”— Source

Valid values: HeroSliding (SLD_).


const int IceCombo ๐Ÿ”— Source

The icy combo the Hero is sliding on.


int ScriptIceCombo ๐Ÿ”— Source

Read-write. If nonzero, this combo is used instead of the IceCombo (can be used to force the Hero to slide).

If the specified combo is not an Icy Floor combo that affects the Hero, no sliding will occur.


int IceVx ๐Ÿ”— Source

The Heroโ€™s ice velocity (in pixels per frame). Has no effect unless the Hero is Sliding. If the Hero is not Sliding, the engine will clear these to 0.


int IceVy ๐Ÿ”— Source

The Heroโ€™s ice velocity (in pixels per frame). Has no effect unless the Hero is Sliding. If the Hero is not Sliding, the engine will clear these to 0.


int IceEntryFrames ๐Ÿ”— Source

Read/write, 0-255, has no effect unless the Hero is Sliding.

Used to grant the Hero some leeway when first entering the ice.

On entering the ice, these are set to the same value, and โ€˜IceEntryFramesโ€™ then ticks down each frame to 0. Instantly goes to 0 if the Hero is still.

Based on the ratio between these values, the Heroโ€™s deceleration will be somewhere between the IceComboโ€™s deceleration and half of the Heroโ€™s step speed.


int IceEntryMaxFrames ๐Ÿ”— Source

Read/write, 0-255, has no effect unless the Hero is Sliding.

Used to grant the Hero some leeway when first entering the ice.

On entering the ice, these are set to the same value, and โ€˜IceEntryFramesโ€™ then ticks down each frame to 0. Instantly goes to 0 if the Hero is still.

Based on the ratio between these values, the Heroโ€™s deceleration will be somewhere between the IceComboโ€™s deceleration and half of the Heroโ€™s step speed.


bool InputStart ๐Ÿ”— Source


bool InputMap ๐Ÿ”— Source


bool InputUp ๐Ÿ”— Source


bool InputDown ๐Ÿ”— Source


bool InputLeft ๐Ÿ”— Source


bool InputRight ๐Ÿ”— Source


bool InputA ๐Ÿ”— Source


bool InputB ๐Ÿ”— Source


bool InputL ๐Ÿ”— Source


bool InputR ๐Ÿ”— Source


bool InputEx1 ๐Ÿ”— Source


bool InputEx2 ๐Ÿ”— Source


bool InputEx3 ๐Ÿ”— Source


bool InputEx4 ๐Ÿ”— Source


bool PressStart ๐Ÿ”— Source


bool PressUp ๐Ÿ”— Source


bool PressDown ๐Ÿ”— Source


bool PressLeft ๐Ÿ”— Source


bool PressRight ๐Ÿ”— Source


bool PressA ๐Ÿ”— Source


bool PressB ๐Ÿ”— Source


bool PressL ๐Ÿ”— Source


bool PressR ๐Ÿ”— Source


bool PressEx1 ๐Ÿ”— Source


bool PressEx2 ๐Ÿ”— Source


bool PressEx3 ๐Ÿ”— Source


bool PressEx4 ๐Ÿ”— Source


int InputMouseX ๐Ÿ”— Source


int InputMouseY ๐Ÿ”— Source


int InputMouseZ ๐Ÿ”— Source


int InputMouseB ๐Ÿ”— Source


bool InputAxisUp ๐Ÿ”— Source


bool InputAxisDown ๐Ÿ”— Source


bool InputAxisLeft ๐Ÿ”— Source


bool InputAxisRight ๐Ÿ”— Source


bool PressAxisUp ๐Ÿ”— Source


bool PressAxisDown ๐Ÿ”— Source


bool PressAxisLeft ๐Ÿ”— Source


bool PressAxisRight ๐Ÿ”— Source


bool PressMap ๐Ÿ”— Source


const int TotalDYOffset ๐Ÿ”— Source


int Equipment ๐Ÿ”— Source

Link->Equipment is now read-write, and needs testing.


Function descriptions#

void Warp(int DMap, int screen) ๐Ÿ”— Source

Warps link to the given screen in the given DMap, just like if heโ€™d triggered an โ€˜Insta-Warpโ€™-type warp.

Uses warp return square A, unless compat rule Old 'Hero->Warp' Return Square is on, in which case it uses the warp return square of the current screenโ€™s Sidewarp A.


void WarpEx(int[] ptr) ๐Ÿ”— Source


void Explode(int arg1) ๐Ÿ”— Source


void PitWarp(int arg1, int arg2) ๐Ÿ”— Source


void SelectAWeapon(int dir) ๐Ÿ”— Source

Changes the A button item (respectively), in the same manner the engine subscreen cursor moves. DIR_RIGHT/DIR_LEFT are equivalent to how quickswap cycles.

Does nothing if the QR allowing items to be set for that button is not enabled.


void SelectBWeapon(int dir) ๐Ÿ”— Source

Changes the B button item (respectively), in the same manner the engine subscreen cursor moves. DIR_RIGHT/DIR_LEFT are equivalent to how quickswap cycles.


void SelectXWeapon(int dir) ๐Ÿ”— Source

Changes the X button item (respectively), in the same manner the engine subscreen cursor moves. DIR_RIGHT/DIR_LEFT are equivalent to how quickswap cycles.

Does nothing if the QR allowing items to be set for that button is not enabled.


void SelectYWeapon(int dir) ๐Ÿ”— Source

Changes the Y button item (respectively), in the same manner the engine subscreen cursor moves. DIR_RIGHT/DIR_LEFT are equivalent to how quickswap cycles.

Does nothing if the QR allowing items to be set for that button is not enabled.


bool SwitchCombo(int pos, int effect) ๐Ÿ”— Source

Switch the Hero with the given combo position. Returns true if successful.

Valid values for effect: SwitchEffect (SW_EFF_).


void Kill(bool bypass_revive = false) ๐Ÿ”— Source

Kills the Hero. Their HP will be set to 0, and โ€˜Immortalโ€™ will be bypassed.

If โ€˜bypass_reviveโ€™ is true, bottles will not be checked for revival items, and the normal single frame delay before death that is used for script-revival will also be skipped.

Otherwise, revival processes will occur as normal.


bool MoveXY(int dx, int dy, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Attempts to move the Hero by โ€˜dx, dyโ€™; obeying solidity.

is_knockback should be true if this movement is the result of some scripted form of knockback.

This currently has no effect for the Heroโ€ฆ It may in the future?

โ€˜ignore_sideviewโ€™: if this is false, and the current screen is sideview gravity, โ€˜dyโ€™ will be ignored (unless the Hero is โ€˜Climbingโ€™, has walk-through-walls enabled, or is sideview swimming)

corner_shove: if this is true, and the movement is not diagonal (i.e. one of dx or dy is 0), then if the movement pushes the Hero into the corner of a solid, the Hero will automatically be shoved โ€˜aroundโ€™ the corner. (Same as how engine movement does it)

Returns true if the full distance was moved, false otherwise.


bool CanMoveXY(int dx, int dy, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Same as MoveXY(), but does not move the Hero- instead, just returns true/false based on what MoveXY() would return.


bool MoveAtAngle(int degrees, int pixels, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Like MoveXY(), but for a pixels movement in the degrees angle.


bool CanMoveAtAngle(int degrees, int pxamnt, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Like MoveAtAngle(), but does not move the Hero - instead, just returns true/false based on what MoveAtAngle() would return.


bool Move(int dir, int pixels, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Like MoveXY(), but for a pixels movement in the dir direction.


bool CanMove(int dir, int pxamnt, bool is_knockback = false, bool ignore_sideview = false, bool corner_shove = true) ๐Ÿ”— Source

Like Move(), but does not move the Hero - instead, just returns true/false based on what Move() would return.


lweapon ReleaseLiftWeapon() ๐Ÿ”— Source


void LiftWeapon(lweapon arg1, int arg2, int arg3) ๐Ÿ”— Source


bool isFlickerFrame() ๐Ÿ”— Source

This returns true if the Hero is currently in a flicker frame (either invisible or color masked).

If called before Waitdraw() / Hero update, results may be off by a frame.

If the quest rule โ€˜Invincible Hero Flickersโ€™ is unchecked, this is unused.


void Warp(int arg1) ๐Ÿ”— Source


void SetItemA(int arg1) ๐Ÿ”— Source


void SetItemB(int arg1) ๐Ÿ”— Source


void SetItemSlot(int itm_id, int button, int force) ๐Ÿ”— Source

This allows you to set Linkโ€™s button items without binary operation with options for forcing them.

Use the constants ITM_REQUIRE_ and ITM_SLOT_ from <std> when passing values into this function.


int GetOriginalTile(int arg1, int arg2) ๐Ÿ”— Source


int GetOriginalFlip(int arg1, int arg2) ๐Ÿ”— Source