Alchemy
Loading...
Searching...
No Matches

object_heading.h

Go to the documentation of this file.
1#include "script.h"
2#include "types.h"
3#include "field_obj.h"
4
5// Kalay and Venus Lighthouse's aerie: actors that look about.
6
7/// An object script call, each frame: when the actor's countdown (work) runs
8/// out, it turns by a random amount up to half a turn and waits a random 0 to
9/// 79 frames.
10static s32 Scene_LookAboutRandomly(struct ScriptInterpreter *interpreter) {
11 struct FieldActor *obj = (struct FieldActor *)interpreter;
12 s32 cnt = obj->work;
13 s32 loaded = (s16)obj->work;
14 s32 amount;
15
16 if (loaded == 0) {
17 obj->facing += (u32)(Engine_RandomNext() << 15) >> 16;
18 amount = (u32)(Engine_RandomNext() * 80) >> 16;
19 obj->work = amount;
20 if (amount == 0) {
21 goto done;
22 }
23 cnt = amount;
24 }
25 obj->work = cnt - 1;
26done:
27 return 1;
28}
s32 Engine_RandomNext()
Field objects and actors, and the scene transition styles.
static s32 Scene_LookAboutRandomly(struct ScriptInterpreter *interpreter)
An object script call, each frame: when the actor's countdown (work) runs out, it turns by a random a...
The field object script interpreter and the operands its commands read.
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
u16 facing
1/65536 turns
Definition field_obj.h:34
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
The prefix that command handlers read from a field object's 0x70-byte slot.
Definition script.h:16
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12