Alchemy
Loading...
Searching...
No Matches

step.c File Reference

Field requests and each step of the leader: exits, encounters, damage. More...

Go to the source code of this file.

Data Structures

struct  StepOwner
 A party member's battle unit, seen as the HP and poison a step reads. More...

Enumerations

enum  StepTileEvent {
  STEP_EVENT_FIRST = 1 , STEP_EVENT_LAST = 239 , STEP_TERRAIN_FIRST = 240 , STEP_TERRAIN_LAST = 241 ,
  STEP_EVENT_HAZARD = 250 , STEP_WARP_FIRST = 252 , STEP_WARP_LAST = 254
}
 The collision codes of map cells that mean something when stepped on. More...

Functions

void Field_ClearRequests (void)
 Clears the field's twelve pending requests (see struct FieldWork).
s32 Field_CountRequests (void)
 Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-zero while any request is pending.
s32 Field_GetCollisionAheadOfLeader (void)
 Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on the world map), or 0 without a leader.
void Field_CheckExitRegions (s32 positionX, s32 positionY, s32 positionZ)
 Takes the exit of the first of the scene's exit regions that contains the position (x, y, z) and whose condition holds: records the region's exit value for Field_RunScene, plays the exit sound and starts leaving the scene.
void Field_ProcessStep (s32 layer, s32 x, s32 y, s32 z)
 Handles one step of the party leader onto the cell at (x, y, z) of map layer: records step events and push tiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.
void BattleParty_ApplyDrain (s32 amount, s32 unused)
 Gives each character in the party amount PP (PP regenerates as the party walks).
void BattleParty_ApplyHealthDelta (s32 amount, s32 percent)
 Changes each party member's HP by amount, or by that percentage of maximum HP when percent is set.
s32 BattleParty_ApplyStatusDamage (void)
 Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a tenth (at least 1).
void WorldMap_BeginEvent (void)
 Starts an event or menu on the world map: ends any colour ratio transition in progress, pauses camera movement and freezes the perspective view as a still picture.
void WorldMap_EndEvent (void)
 Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the camera's movement state back to 0.

Detailed Description

Field requests and each step of the leader: exits, encounters, damage.

Part of object.c, the field object, compiled only through it.

Definition in file step.c.

Enumeration Type Documentation

◆ StepTileEvent

The collision codes of map cells that mean something when stepped on.

Enumerator
STEP_EVENT_FIRST 

1 to 239: the scene's step events

STEP_EVENT_LAST 
STEP_TERRAIN_FIRST 

240 and 241: ground with its own encounters

STEP_TERRAIN_LAST 
STEP_EVENT_HAZARD 

ground that hurts the party over time

STEP_WARP_FIRST 

252 to 254: ledges and climbing spots the leader pushes against (Field_RunPushTileEvent)

STEP_WARP_LAST 

Definition at line 19 of file step.c.

Function Documentation

◆ Field_ClearRequests()

void Field_ClearRequests ( void )

Clears the field's twelve pending requests (see struct FieldWork).

Called by Field_RunScene while it sets a scene up.

Definition at line 33 of file step.c.

Referenced by Field_ClearRequests(), and Field_RunScene().

◆ Field_CountRequests()

s32 Field_CountRequests ( void )

Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-zero while any request is pending.

Field_RunScene tests it to stop walking and to leave its request loop.

Definition at line 56 of file step.c.

Referenced by Field_CountRequests(), and Field_RunScene().

◆ Field_GetCollisionAheadOfLeader()

s32 Field_GetCollisionAheadOfLeader ( void )

Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on the world map), or 0 without a leader.

Called from items.c, where using an item looks at what the leader faces.

Definition at line 69 of file step.c.

Referenced by BattleFx_FindMatchingEvent(), Field_FindItemEvent(), and Field_GetCollisionAheadOfLeader().

◆ Field_CheckExitRegions()

void Field_CheckExitRegions ( s32 positionX,
s32 positionY,
s32 positionZ )

Takes the exit of the first of the scene's exit regions that contains the position (x, y, z) and whose condition holds: records the region's exit value for Field_RunScene, plays the exit sound and starts leaving the scene.

Called by Field_ProcessStep when the leader steps on a cell with a non-zero collision code. Sets work->exit and stops the leader.

Definition at line 135 of file step.c.

Referenced by Field_CheckExitRegions(), and Field_ProcessStep().

◆ Field_ProcessStep()

void Field_ProcessStep ( s32 layer,
s32 x,
s32 y,
s32 z )

Handles one step of the party leader onto the cell at (x, y, z) of map layer: records step events and push tiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.

When this hurts the party, the leader flinches and characters who fall are listed in the field work.

Called by Field_RunScene each frame while the party walks (in debug mode, flag 0x163 skips it). Sets work->action, input, battle, command and event (-1 when someone fell), work->currentTile and previousTile, walkingDistance, fallenOwners and survivorCount, and gGameState's hazard and Avoid counts.

Definition at line 193 of file step.c.

Referenced by Field_ProcessStep(), and Field_RunScene().

◆ BattleParty_ApplyDrain()

void BattleParty_ApplyDrain ( s32 amount,
s32 unused )

Gives each character in the party amount PP (PP regenerates as the party walks).

Called by Field_ProcessStep as the party walks, by Field_SearchTile for a Psynergy stone (999, all PP), and by the Vale home scene through BattleParty_ApplyDrainFar.

Definition at line 362 of file step.c.

Referenced by BattleParty_ApplyDrain(), Event_UsePsynergyStone(), Field_ProcessStep(), and Field_SearchTile().

◆ BattleParty_ApplyHealthDelta()

void BattleParty_ApplyHealthDelta ( s32 amount,
s32 percent )

Changes each party member's HP by amount, or by that percentage of maximum HP when percent is set.

A percentage that truncates to zero falls back to the positive magnitude of amount. Damage flashes and plays an impact sound; healing plays the recovery sound.

Called by Field_ProcessStep for hazardous ground.

Definition at line 376 of file step.c.

Referenced by BattleParty_ApplyHealthDelta(), and Field_ProcessStep().

◆ BattleParty_ApplyStatusDamage()

s32 BattleParty_ApplyStatusDamage ( void )

Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a tenth (at least 1).

Returns 0 when nobody was hurt, else the worst status found (1 poison, 2 venom), after a flash.

Called by Field_ProcessStep at each tick of the distance walked.

Definition at line 416 of file step.c.

Referenced by BattleParty_ApplyStatusDamage(), and Field_ProcessStep().

◆ WorldMap_BeginEvent()

void WorldMap_BeginEvent ( void )

Starts an event or menu on the world map: ends any colour ratio transition in progress, pauses camera movement and freezes the perspective view as a still picture.

Elsewhere it does nothing.

Called by Field_RunScene around the handling of most requests, by the Djinni effect and by the world map scene; each call is paired with WorldMap_EndEvent. Changes the display transition state in heap slot 31 (0x1F, HEAP_SLOT_TRANSITION) only when it is running.

Definition at line 464 of file step.c.

Referenced by Djinn_JoinParty(), Event_MeetFlint(), Event_SearchShipwreck(), Event_StopLeavingShip(), Event_UseBlackOrb(), Field_RunScene(), WorldMap_BeginEvent(), WorldMap_BoardBunzasWagon(), WorldMap_DepartWithTravelers(), WorldMap_RunBlackOrbScene(), WorldMap_ShowDjinnTutorial(), and WorldMap_ShowEndingScene().

◆ WorldMap_EndEvent()

void WorldMap_EndEvent ( void )

Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the camera's movement state back to 0.

Definition at line 484 of file step.c.

Referenced by Djinn_JoinParty(), Event_MeetFlint(), Event_SearchShipwreck(), Event_StopLeavingShip(), Event_UseBlackOrb(), Field_RunScene(), WorldMap_DepartWithTravelers(), WorldMap_EndEvent(), WorldMap_RunBlackOrbScene(), and WorldMap_ShowDjinnTutorial().