Alchemy
Loading...
Searching...
No Matches

step.c

Go to the documentation of this file.
1/// @file
2/// Field requests and each step of the leader: exits, encounters, damage.
3/// Part of object.c, the field object, compiled only through it.
4
6
7// The fields of struct BattleUnit that Field_ProcessStep reads (see its tag).
8#ifndef UBFIX
9/// A party member's battle unit, seen as the HP and poison a step reads.
10struct StepOwner {
15};
16#endif
17
18/// The collision codes of map cells that mean something when stepped on.
20 STEP_EVENT_FIRST = 1, ///< 1 to 239: the scene's step events
22 STEP_TERRAIN_FIRST = 240, ///< 240 and 241: ground with its own encounters
24 STEP_EVENT_HAZARD = 250, ///< ground that hurts the party over time
25 STEP_WARP_FIRST = 252, ///< 252 to 254: ledges and climbing spots the
26 ///< leader pushes against (Field_RunPushTileEvent)
28};
29
30/// Clears the field's twelve pending requests (see struct FieldWork).
31///
32/// Called by Field_RunScene while it sets a scene up.
34 s16 noRequest;
35 struct FieldWork *work;
36 noRequest = 0;
37 work = (struct FieldWork *)gEventWork;
38 work->action = noRequest;
39 work->input = 0;
40 work->exit = 0;
41 work->menu = 0;
42 work->examine = 0;
43 work->start = 0;
44 work->descriptor = 0;
45 work->tile = 0;
46 work->battle = 0;
47 work->command = 0;
48 work->item = 0;
49 work->event = 0;
50}
51
52/// Returns the sum of the field's twelve pending requests (counting the actor
53/// event request twice): non-zero while any request is pending.
54///
55/// Field_RunScene tests it to stop walking and to leave its request loop.
57 struct FieldWork *work = (struct FieldWork *)gEventWork;
58
59 return work->action + work->input + work->exit + work->menu + work->examine +
60 work->start + (s16)work->descriptor + work->tile +
61 (s16)work->descriptor + work->battle + work->command + work->item +
62 work->event;
63}
64
65/// Returns the collision code of the map cell 16 pixels ahead of the party
66/// leader (a world map block on the world map), or 0 without a leader.
67///
68/// Called from items.c, where using an item looks at what the leader faces.
70 struct FieldWork *work;
71 struct ObjectRuntime *leader;
72 struct MapState *map;
73 union PolarOffsetPosition position;
74 u8 *tile;
75 s32 fixedX;
76 s32 fixedZ;
77
79 leader = (struct ObjectRuntime *)work->actors[gGameState.selectedActor];
80
81 map = WORK_SLOT(8);
82
83 if (leader == 0)
84 return 0;
85
86 position.vector.x = leader->x;
87 position.vector.y = leader->y;
88 position.vector.z = leader->z;
89 Vector_AddPolarOffset(0x100000, leader->angle, position.coordinates);
90
91 if (work->mode == MODE_WORLD_MAP) {
92 // World map blocks are 32 pixels square, 32 to a row.
93 u32 tileX;
94 u32 tileY;
95
96 // Rounding toward zero, as a signed division by 0x200000 would.
97 fixedX = position.vector.x;
98 if (fixedX < 0)
99 fixedX += 0x1fffff;
100 tileX = (fixedX >> 21) & 31;
101
102 fixedZ = position.vector.z;
103 if (fixedZ < 0)
104 fixedZ += 0x1fffff;
105 tileY = (fixedZ >> 21) & 31;
106
107 tile = (u8 *)gMapBlocks + ((tileX + (tileY << 5)) << 2);
108 } else {
109 // Map cells are 16 pixels square, 128 to a row.
110 tile = (u8 *)map->layers[0].cells;
111
112 fixedX = position.vector.x;
113 if (fixedX < 0)
114 fixedX += 0xfffff;
115 {
116 u32 tileX = fixedX >> 20;
117
118 fixedZ = position.vector.z;
119 if (fixedZ < 0)
120 fixedZ += 0xfffff;
121
122 tile = (u8 *)((u32)tile + ((tileX + ((fixedZ >> 20) << 7)) << 2));
123 }
124 }
125
126 return tile[2];
127}
128
129/// Takes the exit of the first of the scene's exit regions that contains the
130/// position (x, y, z) and whose condition holds: records the region's exit
131/// value for Field_RunScene, plays the exit sound and starts leaving the scene.
132///
133/// Called by Field_ProcessStep when the leader steps on a cell with a non-zero
134/// collision code. Sets work->exit and stops the leader.
135void Field_CheckExitRegions(s32 positionX, s32 positionY, s32 positionZ) {
136 // A do/while or while scan changes register allocation (51 text bytes in
137 // tbs-en); keep the sentinel backedge until that form matches.
138 s32 exitValue;
139 struct FieldWork *work;
140 s32 fixedZ;
141 s32 fixedY;
142 s32 fixedX;
143 s16 condition;
144 s16 minZ;
145 s16 maxY;
146 s16 minY;
147 s32 maxZ;
148 s16 maxX;
149 s16 minX;
150 const struct SceneRegion *region;
151
152 fixedX = positionX;
153 fixedY = positionY;
154 fixedZ = positionZ;
155 region = gOverlayArea.regions();
156 if (region != 0 && (work = (struct FieldWork *)gEventWork,
157 minX = region->minX, minX != -1)) {
158 loop:
159 minY = region->minY;
160 minZ = region->minZ;
161 maxX = region->maxX;
162 maxY = region->maxY;
163 maxZ = region->maxZ;
164 condition = region->condition;
165 exitValue = region->value;
167 fixedY >= REGION_FIXED(minY) && fixedY < REGION_FIXED(maxY) &&
168 fixedX >= REGION_FIXED(minX) && fixedX < REGION_FIXED(maxX) &&
169 fixedZ >= REGION_FIXED(minZ) && fixedZ < REGION_FIXED(maxZ)) {
170 work->exit = exitValue;
173 return;
174 }
175 work = (struct FieldWork *)gEventWork;
176 region++;
177 minX = region->minX;
178 if (minX != -1)
179 goto loop;
180 }
181}
182
183/// Handles one step of the party leader onto the cell at (x, y, z) of map
184/// layer: records step events and push tiles, takes exits, and while walking
185/// advances the encounter counter, regenerates PP, hurts the party with poison
186/// and hazardous ground, and wears Avoid off. When this hurts the party, the
187/// leader flinches and characters who fall are listed in the field work.
188///
189/// Called by Field_RunScene each frame while the party walks (in debug mode,
190/// flag 0x163 skips it). Sets work->action, input, battle, command and event
191/// (-1 when someone fell), work->currentTile and previousTile, walkingDistance,
192/// fallenOwners and survivorCount, and gGameState's hazard and Avoid counts.
193void Field_ProcessStep(s32 layer, s32 x, s32 y, s32 z) {
194 /* FAKEMATCH(wrapper): the party read through struct StepOwner, whose alias
195 * set keeps the load order and the 44-byte frame; as struct BattleUnit, 2
196 * of 472 instructions differ in tbs-en. */
197 struct FieldWork *work = WORK_SLOT(HEAP_SLOT_EVENT);
198 struct MapState *map = WORK_SLOT(8);
199 s32 leaderId = gGameState.selectedActor;
200 struct ObjectRuntime *leader = (struct ObjectRuntime *)work->actors[leaderId];
201 s16 previousHp[8];
202 struct MapCell *tile;
203#ifdef UBFIX
204 // The defined form reads the struct BattleUnit UnitGetFar returns, rather
205 // than through the unrelated struct StepOwner; it compiles to the same size
206 // with a different register allocation (see the tag above).
207 struct BattleUnit *unitVitals;
208#else
209 struct StepOwner *unitVitals;
210#endif
211 u32 partyCount;
212 s32 partyHurt;
213 u32 i;
214 u32 event;
215 s32 encounterSpeed;
216 s32 stepDistance;
217 s32 amount;
218 s32 accumulatedDistance;
219 s32 fullEncounterRate;
220
221 partyHurt = 0;
222 if (work == NULL)
223 return;
224
225 // Note each character's HP, to see who falls.
226 partyCount = Party_CountActiveOwnersFar();
227 for (i = 0; i < partyCount; i++)
228 previousHp[i] = UnitGetFar(gGameState.activeOwners[i])->hp;
229
230 if (work->mode == MODE_WORLD_MAP) {
231 tile = &((struct MapCell *)Ram_MapBlocks)[((x / 0x200000) & 31) +
232 (((z / 0x200000) & 31) << 5)];
233 } else {
234 if ((u32)layer <= 2)
235 tile = map->layers[layer].cells;
236 else
237 tile = (struct MapCell *)gMapCellBuffer;
238 tile = &tile[(x / 0x100000) + ((z / 0x100000) << 7)];
239 }
240 event = tile->collisionCode;
241 work->previousTile = work->currentTile;
242 work->currentTile = tile;
243 // Exit regions are checked on any marked cell; the code then picks the
244 // request it raises.
245 if (event != 0)
246 Field_CheckExitRegions(x, y, z);
247 if (event >= STEP_EVENT_FIRST && event <= STEP_EVENT_LAST)
248 work->action = event;
249 if (event >= STEP_WARP_FIRST && event <= STEP_WARP_LAST)
250 work->input = event;
251
252 // Only while walking (not climbing) towards a target.
253 if (gGameState.movementMode == 0 && leader != NULL &&
254 leader->targetX != ACTOR_NO_TARGET) {
255 // Encounters: the zone comes from the world map terrain, or from the
256 // ground the leader stands on. FLAG_LURE_CAP doubles the speed the roll
257 // counts.
258 encounterSpeed = leader->speedLimit;
260 encounterSpeed <<= 1;
261 if (work->mode == MODE_WORLD_MAP) {
262 fullEncounterRate = 1;
263 work->battle = Encounter_RollWorldMap((s32)&leader->x, encounterSpeed);
264 } else if (event == STEP_TERRAIN_FIRST || event == STEP_TERRAIN_LAST) {
265 fullEncounterRate =
266 work->encounterGroups[event - (STEP_TERRAIN_FIRST - 1)];
267 work->battle = Encounter_RollTerrain(event - (STEP_TERRAIN_FIRST - 1),
268 encounterSpeed);
269 } else {
270 fullEncounterRate = work->encounterGroups[0];
271 work->battle = Encounter_RollTerrain(0, encounterSpeed);
272 }
273
274 // Every 0x10000 of distance walked (counted at half speed on ground whose
275 // encounter zone is 0; fullEncounterRate holds that zone, 1 on the world
276 // map), the party regains PP, Djinn recover, and poison hurts.
277 stepDistance = Iwram_MulQ16(work->walkingDistanceScale, leader->speedLimit);
278 if (!fullEncounterRate)
279 stepDistance /= 2;
280 accumulatedDistance = work->walkingDistance + stepDistance;
281 work->walkingDistance = accumulatedDistance;
282 if (accumulatedDistance > 0xffff) {
283 amount = accumulatedDistance / 0x10000;
284 work->walkingDistance = accumulatedDistance & 0xffff;
285 BattleParty_ApplyDrain(amount, 0);
289 partyHurt = BattleParty_ApplyStatusDamage();
290 }
291
292 // Hazardous ground: entering it starts the count half way.
293 if (gGameState.hazardMode == 0 && event == STEP_EVENT_HAZARD) {
295 gGameState.hazardSteps += leader->speedLimit / 0x10000;
296 else
298 }
299
300 // Avoid wears off with distance, outside scenes of variant 2.
303 if (gGameState.avoidDistance <= 0) {
305 // Raise Avoid as a Psynergy request that pays no PP (ACT_PACKED |
306 // ABILITY_AVOID); Avoid's end handler says it wore off.
307 if (work->command == 0)
308 work->command = 0x2096;
309 }
310 }
311 }
312
313 // In hazard mode 1 the count rises each step. Half way, object 209 is
314 // attached to the leader until removed (0x101, at sprite priority 1); at
315 // the limit it is removed (0x100) and the party takes the hazard's damage.
316 if (gGameState.hazardMode == 1) {
319 BattleFx_ConfigureLinkedObject(leaderId, 0x101);
321 BattleFx_ConfigureLinkedObject(leaderId, 0x100);
322 }
324 // hazardDamage: bits 7 to 0 the amount, bit 8 a percentage of maximum HP.
325 amount = gGameState.hazardDamage;
327 BattleParty_ApplyHealthDelta(-(amount & 255), amount & 0x100);
328 partyHurt++;
329 }
330
331 // The leader flinches (velocityY) and shows a one-off object 209 (0x102);
332 // each character whose HP reached 0 on this step is listed, loses its
333 // poison and raises event -1, which Field_RunScene handles.
334 if (partyHurt) {
335 work->fallenCount = 0;
336 work->survivorCount = 0;
337 leader->velocityY = 0x40000;
338 BattleFx_ConfigureLinkedObject(leaderId, 0x102);
339 for (i = 0; i < partyCount; i++) {
340#ifdef UBFIX
341 unitVitals = UnitGetFar(gGameState.activeOwners[i]);
342#else
343 unitVitals = (struct StepOwner *)UnitGetFar(gGameState.activeOwners[i]);
344#endif
345 if (unitVitals->hp > 0) {
346 work->survivorCount++;
347 } else if (previousHp[i] != 0) {
349 work->event = -1;
350 unitVitals->poison = 0;
351 }
352 }
353 }
354}
355
356/// Gives each character in the party amount PP (PP regenerates as the party
357/// walks).
358///
359/// Called by Field_ProcessStep as the party walks, by Field_SearchTile for a
360/// Psynergy stone (999, all PP), and by the Vale home scene through
361/// BattleParty_ApplyDrainFar.
362void BattleParty_ApplyDrain(s32 amount, s32 unused) {
363 s32 partyCount = Party_CountActiveOwnersFar();
364 s32 partyIndex;
365
366 for (partyIndex = 0; partyIndex < partyCount; partyIndex++)
367 Unit_AddPpFar(gGameState.activeOwners[partyIndex], amount);
368}
369
370/// Changes each party member's HP by amount, or by that percentage of maximum
371/// HP when percent is set. A percentage that truncates to zero falls back to
372/// the positive magnitude of amount. Damage flashes and plays an impact sound;
373/// healing plays the recovery sound.
374///
375/// Called by Field_ProcessStep for hazardous ground.
376void BattleParty_ApplyHealthDelta(s32 amount, s32 percent) {
377 s32 partyCount;
378 s32 partyIndex;
379 s32 hpDelta;
380 struct BattleUnit *unit;
381
382 // Damage of more than 10 plays the heavier impact sound.
383 if (amount < 0) {
386 if (amount < -10)
388 else
390 } else {
392 }
393
394 partyCount = Party_CountActiveOwnersFar();
395 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
396 unit = UnitGetFar(gGameState.activeOwners[partyIndex]);
397 if (!percent) {
398 hpDelta = amount;
399 } else {
400 hpDelta = unit->maxHp * amount / 100;
401 if (hpDelta == 0) {
402 hpDelta = amount;
403 if (hpDelta < 0)
404 hpDelta = -hpDelta;
405 }
406 }
407 Unit_AddHpFar(gGameState.activeOwners[partyIndex], hpDelta);
408 }
409}
410
411/// Hurts each poisoned character in the party: poison takes a twentieth of
412/// their maximum HP and venom a tenth (at least 1). Returns 0 when nobody was
413/// hurt, else the worst status found (1 poison, 2 venom), after a flash.
414///
415/// Called by Field_ProcessStep at each tick of the distance walked.
417 s32 worstPoison = 0;
418 s32 partyCount = Party_CountActiveOwnersFar();
419 s32 partyIndex;
420
421 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
422 struct BattleUnit *unit = UnitGetFar(gGameState.activeOwners[partyIndex]);
423 s32 hpDelta;
424
425 switch (unit->poison) {
426 case 1:
427 hpDelta = -((unit->maxHp + 10) / 20);
428 if (hpDelta == 0)
429 hpDelta = -1;
430 if (worstPoison <= 0)
431 worstPoison = 1;
432 break;
433 case 2:
434 hpDelta = -((unit->maxHp + 5) / 10);
435 if (hpDelta == 0)
436 hpDelta = -1;
437 if (worstPoison <= 1)
438 worstPoison = 2;
439 break;
440 default:
441 hpDelta = 0;
442 break;
443 }
444 Unit_AddHpFar(gGameState.activeOwners[partyIndex], hpDelta);
445 }
446
447 if (worstPoison != 0) {
451 }
452
453 return worstPoison;
454}
455
456/// Starts an event or menu on the world map: ends any colour ratio transition
457/// in progress, pauses camera movement and freezes the perspective view as a
458/// still picture. Elsewhere it does nothing.
459///
460/// Called by Field_RunScene around the handling of most requests, by the
461/// Djinni effect and by the world map scene; each call is paired with
462/// WorldMap_EndEvent. Changes the display transition state in
463/// heap slot 31 (0x1F, HEAP_SLOT_TRANSITION) only when it is running.
465 struct FieldWork *work;
466 struct DisplayTransitionState *transition;
467
468 work = Runtime_AllocateBlock(HEAP_SLOT_EVENT, sizeof(*work));
469 if (work->mode == MODE_WORLD_MAP) {
470 transition = Runtime_AllocateBlock(0x1F, 0x540);
471 if ((transition != NULL) && (transition->step != 0)) {
472 transition->start = 0;
473 transition->end = 0;
474 transition->duration = 1;
475 transition->step = 0;
476 }
477 work->camera->movementState = 1;
479 }
480}
481
482/// Ends what WorldMap_BeginEvent started: on the world map, reloads
483/// the area's graphics and sets the camera's movement state back to 0.
485 struct FieldWork *work;
486
487 work = Runtime_AllocateBlock(HEAP_SLOT_EVENT, sizeof(*work));
488 if (work->mode == MODE_WORLD_MAP) {
490 work->camera->movementState = 0;
491 }
492}
void BattleFx_StartBufferInterpolation(s32 frames)
Starts moving the shown colours to the target colours over frames frames: sets work->duration,...
Definition color.c:431
void BattleFx_ApplyColorToSourceBuffer(s32 mode, s32 half)
Sets the colours the buffer shows now (see BattleFx_BuildBuffer).
Definition color.c:409
s32 DjinnRecovery_TickFar(void)
void WorldMap_BeginStillViewFar(void)
void Map_LoadAreaGraphicsFar(void)
struct BattleUnit * UnitGetFar(u32 owner)
s16 Unit_AddPpFar(s32 owner, s32 delta)
s32 GameFlag_TestFar(s32 flag)
s32 Unit_AddHpFar(s32 owner, s32 delta)
s32 Party_CountActiveOwnersFar(void)
void AudioCommand_PlayFar(s32 id)
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
Definition field_obj.h:145
struct SceneEntries gOverlayArea
#define FLAG_LURE_CAP
Set while the Lure Cap is worn: random encounters come twice as fast.
Definition flags.h:65
struct GameState gGameState
struct EffectStep gMapCellBuffer[]
Map cells; battle effects reuse this as a particle array.
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
Definition heap.c:80
@ HEAP_SLOT_EVENT
Definition heap_state.h:40
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
Definition heap_state.h:14
#define Iwram_MulQ16(left, right)
Definition iwram_call.h:127
u32 gMapBlocks[]
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
Definition math.c:23
s32 Encounter_RollWorldMap(s32 pos, s32 steps)
Rolls a random battle on the world map, taking the zone from the tile at pos.
Definition encounter.c:236
s32 Encounter_RollTerrain(u32 terrain, s32 steps)
Rolls a random battle on the encounter zone of the ground underfoot.
Definition encounter.c:226
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
Definition events.c:65
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
Definition events.c:67
void Event_ClearInvalidPackedValues(void)
Clears each button shortcut whose Psynergy can no longer be cast: zeroes gGameState....
Definition events.c:203
void BattleFx_ConfigureLinkedObject(s32 actor, s32 flags)
The event command "actor set attached effect": with mode (the low 2 bits) 0 removes the object attach...
Definition view.c:211
What every part of object.c shares: its includes and the macros and types more than one part uses.
#define REGION_FIXED(value)
A scene region's bounds, in pixels, as 16.16 fixed point.
#define Ram_MapBlocks
Definition ram_buffer.h:12
#define SE_RECOVERY
Definition songs.h:119
#define SE_133
Definition songs.h:126
#define SE_139
Definition songs.h:132
#define SE_MAP_EXIT
Definition songs.h:116
#define SE_HEAVY_IMPACT
Definition songs.h:127
struct EventWork * gEventWork
#define NULL
Definition bilibin.h:6
StepTileEvent
The collision codes of map cells that mean something when stepped on.
Definition step.c:19
@ STEP_EVENT_FIRST
1 to 239: the scene's step events
Definition step.c:20
@ STEP_TERRAIN_FIRST
240 and 241: ground with its own encounters
Definition step.c:22
@ STEP_EVENT_HAZARD
ground that hurts the party over time
Definition step.c:24
@ STEP_WARP_LAST
Definition step.c:27
@ STEP_TERRAIN_LAST
Definition step.c:23
@ STEP_WARP_FIRST
252 to 254: ledges and climbing spots the leader pushes against (Field_RunPushTileEvent)
Definition step.c:25
@ STEP_EVENT_LAST
Definition step.c:21
void WorldMap_EndEvent(void)
Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the cam...
Definition step.c:484
void BattleParty_ApplyDrain(s32 amount, s32 unused)
Gives each character in the party amount PP (PP regenerates as the party walks).
Definition step.c:362
s32 BattleParty_ApplyStatusDamage(void)
Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a ...
Definition step.c:416
void WorldMap_BeginEvent(void)
Starts an event or menu on the world map: ends any colour ratio transition in progress,...
Definition step.c:464
void Field_ClearRequests(void)
Clears the field's twelve pending requests (see struct FieldWork).
Definition step.c:33
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...
Definition step.c:193
s32 Field_GetCollisionAheadOfLeader(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on ...
Definition step.c:69
s32 Field_CountRequests(void)
Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-...
Definition step.c:56
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,...
Definition step.c:135
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.
Definition step.c:376
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s8 poison
1 poisoned, 2 deadly poison
s16 hp
current HP, 0 when downed
s16 maxHp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
The display transition state (heap block 31): two pages of window edges for every line,...
s8 end
the value's last step; 64 hides BG1 to BG3 and sprites
s8 start
the value's first step
s8 duration
frames; 0 when the value is not moving
s32 y
16.16 fixed-point pixels
Definition battle.h:75
s32 z
16.16 fixed-point pixels
Definition battle.h:76
s32 x
16.16 fixed-point pixels
Definition battle.h:74
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
u16 descriptor
an actor's event, as actor | 0x1000
s16 input
a tile code (252 to 254) for Field_RunPushTileEvent
s16 event
A raised event for Scene_RunRaisedEvent, or -1 when characters fell to poison or hazard damage,...
s16 command
a field Psynergy to use, as owner << 10 | Psynergy
s16 tile
a tile's collision code, for Field_SearchTile
struct MapCell * previousTile
the cell before it
u8 encounterGroups[8]
encounter zone for each kind of ground
s16 start
the Start button: open the pause menu
s16 fallenOwners[9]
the characters who fell, from the active party
s16 battle
the enemy group of a random encounter
s16 survivorCount
0 when the whole party fell
s32 walkingDistanceScale
scales movement for PP and status updates
struct ObjectRuntime * camera
the object the map view follows
s16 menu
open the main menu
s16 mode
MODE_WORLD_MAP (3) on the world map.
s16 examine
the A button: examine what is ahead
struct MapCell * currentTile
the cell the leader last stepped onto
s16 item
an item to use, packed as Field_UseItem reads it
s16 action
The twelve requests: each nonzero value asks the field loop for one thing; Field_ClearRequests clears...
struct FieldActor * actors[66]
The actors by id: 0 to 7 the party's characters, 8 on the placed actors.
s16 fallenCount
the characters who fell this step
s32 walkingDistance
accumulated 16.16 distance awaiting an update
s16 hazardLimit
Hazardous ground (the Lamakan Desert's heat): every hazardLimit steps the party takes hazardDamage (b...
Definition game_state.h:96
s32 avoidDistance
distance left of Avoid, 16.16 pixels; 0 when off
Definition game_state.h:110
s16 hazardSteps
reset on entering a new scene group
Definition game_state.h:99
s16 hazardDamage
Definition game_state.h:98
s16 sceneVariant
the current scene's variant from its record
Definition game_state.h:107
u8 activeOwners[8]
the party in order
Definition game_state.h:60
u8 movementMode
1 while the leader is climbing, 0 otherwise
Definition game_state.h:57
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
s16 hazardMode
0 counts on hazard cells only; 1 counts every step
Definition game_state.h:97
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
Definition map.h:13
u8 collisionCode
The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_...
Definition map.h:18
struct MapCell * cells
the layer's first cell (MapLayerScroll's cells)
Definition map.h:26
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
Definition map.h:49
struct MapLayer layers[4]
Each layer's cells, at MapScrollWork's layers[i].cells; readers mask the layer with 3,...
Definition map.h:63
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
u16 angle
1/65536 turns
s32 velocityY
16.16 fixed-point pixels per frame
u8 movementState
nonzero skips its script and motion (paused)
s32 z
16.16 fixed-point pixels
s32 targetX
16.16 fixed-point pixels; 0x80000000 when unset
s32 x
16.16 fixed-point pixels
s32 speedLimit
16.16 fixed-point pixels per frame
s32 y
16.16 fixed-point pixels
const struct SceneRegion *(*) regions(void)
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
s16 value
the exit kind, stored in FieldWork's exit
s16 minZ
pixels, inclusive; minX -1 ends the table
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear
s16 maxZ
pixels, exclusive
A party member's battle unit, seen as the HP and poison a step reads.
Definition step.c:10
s16 hp
Definition step.c:12
u8 unitFieldsBeforeHp[0x38]
Definition step.c:11
u8 poison
Definition step.c:14
u8 unitFieldsBeforePoison[0x131 - 0x3a]
Definition step.c:13
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned char u8
Definition types.h:11
The polar-offset routine walks three array elements.
struct EffectVector vector
#define MODE_WORLD_MAP
the world map
Definition object.h:78