65 firstZoneOnGround = 0;
67 while (rule->
scene != -1) {
68 if (rule->
scene == scene &&
82 for (i = 0; i <= 6; i++) {
83 *groundZones++ = zone;
87 if (firstZoneOnGround != 0) {
109 while (rule->
kind != -1) {
110 if (rule->
kind == kind &&
191 if (total < work->encounterThreshold)
286 for (; rule->
id != -1; rule++) {
288 if (rule->
id != scene)
297 if (rule->
id != group)
331 while (rule->
id != -1) {
333 if (rule->
id == scene) {
340 if (rule->
id == group) {
362 while (rule[0] != -1) {
363 if (rule[0] == scene && (rule[1] == -1 || rule[1] ==
entrance)) {
385 s32 entry = *table++;
390 if (entry != 0 && entry != target) {
392 if (entry & 0x80000000) {
393 backdrop = entry & 0xFFFF;
396 }
while (entry != 0 && entry != target);
407 switch (behavior - 1) {
440 u16 key = (zone << 4) + slot;
457 music = value & 0xfff;
s32 gBattle_BackdropScenes[]
u16 gEncounter_EnemyGroupTable[]
const s16 gParty_PairResolveRules[]
const u16 gEncounter_BattleMusic[35]
Battle music: each song as 0x8000 | song, followed by the encounters that use it as (zone << 4) + slo...
s32 GetWorldMapTerrainBehaviorFar(struct WorldPosition *position, s32 *terrain_kind)
struct BattleUnit * UnitGetFar(u32 owner)
s32 GameFlag_TestFar(s32 flag)
u32 Party_GetAverageLevelFar(void)
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
#define FLAG_NO_ENCOUNTERS
No random encounters while set (Encounter_SelectEnemyGroup), unless flag 0x15f is set; debug entrance...
struct GameState gGameState
static s32 Iwram_RatioMulQ14(s32 divisor, s32 value)
All calls go through this layer.
#define Iwram_MulQ16(left, right)
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Battle_SelectTerrainBackdrop(s32 behavior)
Chooses the battle backdrop for a world map terrain behavior (1 to 7; any other gives Sol Sanctum's) ...
void Scene_ResolveInteractionResult(void)
Chooses the current scene's field music (gGameState.cue) from the first rule matching the scene or it...
s32 Encounter_ResolveWorldMapZoneAndBackdrop(void *pos)
Returns the world map encounter zone for the terrain at pos (0 for none), and chooses the battle back...
u16 Encounter_GetEnemyGroupAtSlot(s32 zone, s32 slot)
Returns the enemy group in slot (0 to 7) of zone; 14 halfwords make a zone.
const struct SceneAreaNameRule gScene_AreaNameRules[]
s32 Encounter_SelectEnemyGroup(s32 zone, s32 steps)
Advances the encounter counter for zone and returns the enemy group to fight, or 0 for no battle.
s16 Event_GetSpecialValue(void)
Returns the battle backdrop chosen for the current scene.
s32 Encounter_RollWorldMap(s32 pos, s32 steps)
Rolls a random battle on the world map, taking the zone from the tile at pos.
void BattleFx_SelectBattleCue(s32 zone, s32 slot)
Chooses the battle music for slot of zone (gGameState.sceneCue).
void Encounter_SelectSceneZones(s32 useRules)
Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEve...
s32 Encounter_RollTerrain(u32 terrain, s32 steps)
Rolls a random battle on the encounter zone of the ground underfoot.
void Battle_SelectSceneBackdrop(void)
Chooses the battle backdrop for the current scene.
s16 Encounter_GetDjinnEnemyGroup(s32 djinni)
Returns the enemy group of Djinni battle djinni, which the table gives as a zone and slot.
const struct BattleLocationRule gBattle_LocationRules[]
const struct SceneInteractionEntry gScene_InteractionRuleTable[]
void Scene_SetDefeatReturnPoint(void)
Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance),...
s32 Scene_GetAreaNameIndex(s32 scene, s32 entrance)
Returns the place name of scene and entrance, from the first rule matching the scene or its group; 0 ...
What every part of object.c shares: its includes and the macros and types more than one part uses.
char ResourceId_ForestBackdrop
char ResourceId_SolSanctumBackdrop
char ResourceId_SnowfieldBackdrop
char ResourceId_BeachBackdrop
char ResourceId_DesertBackdrop
char ResourceId_GrasslandBackdrop
s32 BattleFx_GetResourceGroup(s32 scene)
Returns the group scene belongs to.
struct EventWork * gEventWork
A field scene's encounter zones (gBattle_LocationRules, location_rules.s), ended by scene -1.
s16 firstZone
the first of up to seven consecutive zones
s16 entrance
-1 for any entrance
s16 firstZoneOnGround
the first zone is for ground 0, not 1
s16 flag
-1, or a flag that turns the rule off once set
u32 experience
a character's experience points
An encounter zone, a row of encounter.tsv: its rate, the level it is made for, and the enemy groups t...
u8 weights[ENCOUNTER_GROUP_COUNT]
each group's relative chance
u16 enemies[ENCOUNTER_GROUP_COUNT]
the enemy groups that can appear
u16 rate
the base encounter rate
u16 level
the party level the zone is made for
Full event work allocated by Field_RunScene (heap slot 27).
u8 encounterGroups[8]
encounter zone for each kind of ground
s32 encounterBias
randomized distance adjustment between battles
s32 encounterThreshold
encounter steps before a battle; 0x100000
s16 cloaked
1 under Cloak, which prevents battles
s16 special
the battle backdrop chosen for the scene or terrain
s16 sceneGroup
the current scene's group; a new group resets its flags
s16 sceneCue
the battle music chosen for the encounter
s32 avoidDistance
distance left of Avoid, 16.16 pixels; 0 when off
s32 encounterSteps
the encounter count, reset with a new group
s16 savedScene
where a defeat returns to without a defeat point
s16 cue
the current scene's field music
s16 savedEntrance
where a defeat returns to without a defeat point
A rule naming the place a scene is in (gScene_AreaNameRules, scene_rules.s), ended by id -1.
s16 entrance
-1 for any entrance
s32 areaNameIndex
the place name
s16 id
a scene, or a scene group
u16 useSceneId
1 when id is a scene, 0 when it is a group
A rule choosing a scene's field music (gScene_InteractionRuleTable, scene_rules.s),...
s16 flag
-1, or a flag that must be set
u16 idIsScene
1 when id is a scene, 0 when it is a group
s16 id
a scene, or a scene group
s16 entrance
-1 for any entrance
The world map's encounter zone for each kind of terrain (gWorldMap_EncounterRules,...
s16 flag
-1, or a flag that turns the rule off once set
s16 kind
the terrain kind of the map block
s16 behavior
the terrain's behavior, or -1 for any
const u16 gEncounter_AreaEntryTable[160]
The encounter of each Djinni battle (Encounter_GetDjinnEnemyGroup): {zone, slot}.
const s16 gWorldMap_EncounterRules[132]
The world map's encounter zones (struct TerrainRule): {terrain kind, terrain behavior (-1 for any),...