Alchemy
Loading...
Searching...
No Matches

vault_nearby.h

Go to the documentation of this file.
1/// @file
2/// Vault, before and after the thieves are caught: the two villagers who walk
3/// about together (actors 14 and 15).
4#include "types.h"
5#include "field_obj.h"
6
7// The update hook of actors 14 and 15. Their timer holds two bits: bit 0
8// picks the partner (set for actor 14, whose partner is 15; clear for 15) and
9// bit 1 is set while the party talks to them. A villager stops when close to
10// and facing its partner, and otherwise when the leader is within 18 pixels in
11// front of it. While the window work's word at 376 or the render mode is set
12// the range is 26 pixels, and a villager being talked to stops whichever way
13// it faces.
14//
15// UB: update hooks return void. In tbs-en vault_revisit, plain
16// void differs in 13 bytes of the 152-byte function. Keep the unused
17// native result in matching builds.
18#ifdef UBFIX
19static void Vault_UpdateWalkingVillager(union FieldObject *fieldObject) {
20#else
21static s32 Vault_UpdateWalkingVillager(union FieldObject *fieldObject) {
22#endif
23 struct FieldActor *self = (struct FieldActor *)fieldObject;
24 u8 **globals = gWindowWork;
25 u8 *scene = globals[0];
26 u8 *workspace = globals[12];
27 s16 *flags = &self->timer;
28 s32 force = 0;
29 s32 range = 18;
30 struct FieldActor *partner;
31 struct FieldActor *player;
32
33 if ((*flags & 1) != 0) {
34 partner = Object_GetById(15);
35 } else {
36 partner = Object_GetById(14);
37 }
38 if (Vault_StopIfFacingNear(self, partner, 32, 0) != 0) {
39#ifdef UBFIX
40 return;
41#else
42 return 0;
43#endif
44 }
45
47
48 if (*(s16 *)(workspace + 376) != 0 || scene[RENDER_MODE_OFFSET] != 0) {
49 range = 26;
50 if ((*flags & 2) != 0) {
51 force = 1;
52 }
53 }
54
55 Vault_StopIfFacingNear(self, player, range, force);
56#ifdef UBFIX
57 return;
58#else
59 return 0;
60#endif
61}
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
Field objects and actors, and the scene transition styles.
@ ACTOR_PARTY_LEADER
s32 Vault_StopIfFacingNear(struct FieldActor *actor, struct FieldActor *target, s32 range, s32 force)
Stops the actor (paused, mode 1) when the target is nearer than range pixels and lies ahead of it,...
Definition vault_range.h:11
u8 gWindowWork[]
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s16 timer
The parameter its action script reads (a follow distance or an angle to face), the player's frames to...
Definition field_obj.h:109
#define RENDER_MODE_OFFSET
Definition tbs_edition.h:50
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed short s16
Definition types.h:12
unsigned char u8
Definition types.h:11
An object on the field, read as an actor or as an effect.
static s32 Vault_UpdateWalkingVillager(union FieldObject *fieldObject)