Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
script.c
Go to the documentation of this file.
1/* The helpers of the stages' scripts and the script commands' table */
2
3#include "field/field_mode.h"
4
5/* Stops the scripts' timer */
9
10/* The actor of a character (Actor.key1), or NULL */
12 return TASK_REGISTRY.funcs.find(FIELD_TASK_ACTOR, character, -1);
13}
14
15/* A script's wait: counts time down, then moves the script on */
17 if (time != 0 && FIELDSTG_scriptTimer.active == 0) {
20 }
22 if (FIELDSTG_scriptTimer.time <= 0) {
25 (*pc)++;
26 }
27}
28
29/* A script's wait for the animation of the actor id to end */
31 Actor *actor = FIELDSTG_findActor(id);
32
33 if (actor->isAnimDone(actor) != 0) {
34 (*pc)++;
35 }
36}
37
38/* A script's wait for the actor id to reach its goal */
40 Actor *actor = FIELDSTG_findActor(id);
41
42 if (actor->isWalking(actor) == 0) {
43 (*pc)++;
44 }
45}
46
47/* Turns a map position into a screen one */
49 Vec2 scroll;
51
52 layer->getScroll(layer, &scroll);
53 pos->x -= scroll.x;
54 pos->y -= scroll.y;
55}
56
57/* A script helper: clears the script flag of character 1, or else of
58 character 2 */
60 Actor *actor = FIELDSTG_findActor(1);
61
62 if (actor == NULL) {
63 actor = FIELDSTG_findActor(2);
64 }
65 actor->scriptFlag = 0;
66}
67
68/* The script command id of FIELDSTG_scriptCommands, or NULL */
70 ScriptCommand *cmd;
71
72 for (cmd = FIELDSTG_scriptCommands; cmd->id != 0; cmd++) {
73 if (cmd->id == id) {
74 return cmd;
75 }
76 }
77 return NULL;
78}
79
80/* Creates the task of script command id, or returns 0 */
83 s32 ret = 0;
84
85 if (cmd != NULL) {
86 ret = cmd->create(id);
87 }
88 return ret;
89}
90
91/* Hands the task of script command id a command and its argument, through
92 the command's handle */
93void FIELDSTG_handleScriptCommand(s32 task, s32 id, s32 command, s32 arg) {
95
96 if (cmd != NULL && cmd->handle != NULL) {
97 cmd->handle(task, command, arg);
98 }
99}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
FIELDSTG.PRO: the field mode, where the player walks around the map.
ScriptCommand FIELDSTG_scriptCommands[]
The script commands (FIELDSTG_findScriptCommand), up to the first id 0.
Definition fieldstg.c:3590
ScriptTimer FIELDSTG_scriptTimer
Definition fieldstg.c:3580
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
TaskRegistry TASK_REGISTRY
Definition registry.c:122
void FIELDSTG_resetScriptTimer(void)
Stops the scripts' timer.
Definition script.c:6
void FIELDSTG_waitScriptTime(s32 time, s32 *pc)
A script's wait: counts time down, then moves the script on.
Definition script.c:16
void FIELDSTG_handleScriptCommand(s32 task, s32 id, s32 command, s32 arg)
Hands the task of script command id a command and its argument, through the command's handle.
Definition script.c:93
void FIELDSTG_toScreenPos(Vec2 *pos)
Turns a map position into a screen one.
Definition script.c:48
ScriptCommand * FIELDSTG_findScriptCommand(s32 id)
The script command id of FIELDSTG_scriptCommands, or NULL.
Definition script.c:69
void FIELDSTG_waitWalkDone(s32 id, s32 *pc)
A script's wait for the actor id to reach its goal.
Definition script.c:39
void FIELDSTG_clearScriptFlag(void)
A script helper: clears the script flag of character 1, or else of character 2.
Definition script.c:59
s32 FIELDSTG_createScriptCommand(s32 id)
Creates the task of script command id, or returns 0.
Definition script.c:81
Actor * FIELDSTG_findActor(s32 character)
The actor of a character (Actor.key1), or NULL.
Definition script.c:11
void FIELDSTG_waitAnimDone(s32 id, s32 *pc)
A script's wait for the animation of the actor id to end.
Definition script.c:30
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
s32(* isAnimDone)(struct Actor *)
Definition field_map.h:389
s32(* isWalking)(struct Actor *)
Definition field_map.h:391
s32 scriptFlag
cleared by FIELDSTG_clearScriptFlag; nothing in FIELDSTG or the stages reads it
Definition field_map.h:377
s32(* getFrameTime)(void)
Definition gfx.h:32
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
GfxFuncs funcs
Definition gfx.h:77
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
void(* getScroll)()
Definition gfx.h:148
An entry of the script command table FIELDSTG_scriptCommands (ids from 0x320)
Definition field_mode.h:300
s32(* create)(s32 id)
creates the command's task; FIELDSTG's own return nothing or a Lift, so the table casts them
Definition field_mode.h:302
void(* handle)()
(task, command, arg): each command's task has its own type
Definition field_mode.h:304
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353