Alchemy
Loading...
Searching...
No Matches

field_effect.h

Go to the documentation of this file.
1#ifndef ALCHEMY_FIELD_EFFECT_H
2#define ALCHEMY_FIELD_EFFECT_H
3
4/// @file
5/// Field effects, their scripts and the flags that spawn them.
6
7#include "edition.h"
8#include "field_event.h"
9#include "vector3.h"
10
11/// A field effect: a small object on the field that moves at its velocity and
12/// grows and spins at its rates, run by its script and update hook.
14 /// FieldActor's script pointer, cursor and facing; not named by this view.
16 s32 x; ///< 16.16 fixed-point pixels
17 s32 y; ///< 16.16 fixed-point pixels
18 s32 z; ///< 16.16 fixed-point pixels
19 u8 unk14[4]; ///< FieldActor's terrainHeight; not named by this view
20 s32 scaleX; ///< 16.16 fixed point, 0x10000 full size
21 s32 scaleY; ///< 16.16 fixed point, 0x10000 full size
22 u8 unk20[3]; ///< FieldActor's radius and terrainId; not named by this view
23 /// ActorPriorityFlag bits: the spawner clears ACTOR_PRIORITY_AUTOMATIC when
24 /// EFFECT_USE_PRIORITY sets the sprite's priority.
26 /// FieldActor's velocityX to velocityZ; effects move by velocity instead.
27 u8 unk24[0x0c];
28 /// Added to scaleX each frame by the update hooks, in 16.16 fixed point a
29 /// frame; zeroed by the spawner.
31 s32 scaleRateY; ///< as scaleRateX, for scaleY
32 u8 unk38[0x0c]; ///< FieldActor's targetX to targetZ; not named by this view
33 /// Added to x, y and z each frame by the update hooks, in 16.16 fixed-point
34 /// pixels per frame; FieldActor's bounce, gravity and riseBaseY.
36 struct AnimationObject *sprite; ///< the sprite spin turns
37 u8 unk54; ///< FieldActor's spriteStorageKind; not named by this view
38 u8 motionFlags; ///< ActorMotionFlag bits; zeroed by the spawner
39 u8 unk56[3]; ///< FieldActor's unk56; not named by this view
40 u8 collisionFlags; ///< FieldActor's collisionFlags; not named by this view
41 /// FieldActor's steeringFlags to riseEnabled; not named by this view.
42 u8 unk5a[0x0a];
43 /// Added to the sprite's rotation each frame by the update hooks, in
44 /// 1/65536 turns per frame; Imil's rising effects keep a drift here instead.
46 u8 unk66[2]; ///< FieldActor's work; not named by this view
47 /// Frames until a scene's update hook releases the effect: 20 for Altin
48 /// Peak's spray, 60 for Imil's rising effects.
50 /// Called each frame while the effect is live: the spawner sets
51 /// BattleFx_UpdateObjectMotionScaleAndLinkedAngle, or options.update.
52 void (*update)(union FieldObject *object);
53};
54
55STATIC_ASSERT(offsetof(struct FieldEffect, scaleRateX) == 0x30);
56STATIC_ASSERT(offsetof(struct FieldEffect, velocity) == 0x44);
57STATIC_ASSERT(offsetof(struct FieldEffect, sprite) == 0x50);
58STATIC_ASSERT(offsetof(struct FieldEffect, spin) == 0x64);
59STATIC_ASSERT(offsetof(struct FieldEffect, countdown) == 0x68);
60STATIC_ASSERT(offsetof(struct FieldEffect, update) == 0x6c);
61
62/// An object on the field, read as an actor or as an effect.
66};
67
68#define SCRIPT_WAIT(frames) 0, (frames)
69#define SCRIPT_SET_POSITION(x, y, z) 2, (x), (y), (z)
70#define SCRIPT_REPEAT(count, label) 12, (count), (label)
71#define SCRIPT_DELETE 27
72
74 /// Picks one of gEffectScripts; the object's mode is this plus 1.
76 EFFECT_USE_PALETTE = 0x10000, ///< options.palette, as its group child value
77 EFFECT_USE_PRIORITY = 0x20000, ///< options.priority, as the sprite's priority
78 /// Grows from the start scale, or full size, to the target scale over the
79 /// script's repeat count.
81 EFFECT_USE_START_SCALE = 0x80000, ///< options.startScaleX and startScaleY
82 EFFECT_USE_TYPE = 0x100000, ///< options.type, else object type 222
83 EFFECT_USE_SCRIPT = 0x200000, ///< options.script, run in mode 1
84 EFFECT_USE_ROTATION = 0x400000, ///< options.rotation, as the sprite's
85 EFFECT_USE_SPIN = 0x800000, ///< options.spin
86 EFFECT_USE_UPDATE = 0x1000000 ///< options.update
87};
88
89/// The options of a spawned field effect, each used when its EFFECT_USE_ flag
90/// (or EFFECT_SCALE_TO_TARGET) is set.
92 s32 priority; ///< the sprite's priority
93 s32 palette; ///< passed to ObjectGroup_SetChildValue
94 s32 startScaleX; ///< 16.16 fixed point, 0x10000 full size
95 s32 startScaleY; ///< 16.16 fixed point, 0x10000 full size
96 s32 targetScaleX; ///< 16.16 fixed point, 0x10000 full size
97 s32 targetScaleY; ///< 16.16 fixed point, 0x10000 full size
98 s16 type; ///< the object type to create; 222 without the flag
99 const s32 *script; ///< the object script, run in mode 1
100 u16 rotation; ///< 1/65536 turns
101 u16 spin; ///< 1/65536 turns per frame
102 void (*update)(union FieldObject *object); ///< replaces the update hook
103};
104
105STATIC_ASSERT(offsetof(struct EffectOptions, type) == 0x18);
106STATIC_ASSERT(offsetof(struct EffectOptions, update) == 0x24);
107
108void Effect_SpawnResident(s32 x, s32 y, s32 z, s32 velocityX, s32 velocityY,
109 s32 velocityZ, u32 flags,
110 const struct EffectOptions *options);
111
112#endif
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
EffectSpawnFlags
@ EFFECT_USE_PALETTE
options.palette, as its group child value
@ EFFECT_SCRIPT_MASK
Picks one of gEffectScripts; the object's mode is this plus 1.
@ EFFECT_USE_UPDATE
options.update
@ EFFECT_USE_START_SCALE
options.startScaleX and startScaleY
@ EFFECT_USE_ROTATION
options.rotation, as the sprite's
@ EFFECT_SCALE_TO_TARGET
Grows from the start scale, or full size, to the target scale over the script's repeat count.
@ EFFECT_USE_SPIN
options.spin
@ EFFECT_USE_TYPE
options.type, else object type 222
@ EFFECT_USE_PRIORITY
options.priority, as the sprite's priority
@ EFFECT_USE_SCRIPT
options.script, run in mode 1
void Effect_SpawnResident(s32 x, s32 y, s32 z, s32 velocityX, s32 velocityY, s32 velocityZ, u32 flags, const struct EffectOptions *options)
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
The options of a spawned field effect, each used when its EFFECT_USE_ flag (or EFFECT_SCALE_TO_TARGET...
s16 type
the object type to create; 222 without the flag
s32 targetScaleY
16.16 fixed point, 0x10000 full size
s32 targetScaleX
16.16 fixed point, 0x10000 full size
s32 palette
passed to ObjectGroup_SetChildValue
s32 startScaleY
16.16 fixed point, 0x10000 full size
s32 priority
the sprite's priority
u16 rotation
1/65536 turns
u16 spin
1/65536 turns per frame
const s32 * script
the object script, run in mode 1
s32 startScaleX
16.16 fixed point, 0x10000 full size
void(*) update(union FieldObject *object)
replaces the update hook
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
A field effect: a small object on the field that moves at its velocity and grows and spins at its rat...
void(*) update(union FieldObject *object)
Called each frame while the effect is live: the spawner sets BattleFx_UpdateObjectMotionScaleAndLinke...
u8 unk66[2]
FieldActor's work; not named by this view.
struct Vector3 velocity
Added to x, y and z each frame by the update hooks, in 16.16 fixed-point pixels per frame; FieldActor...
s32 z
16.16 fixed-point pixels
struct AnimationObject * sprite
the sprite spin turns
u8 priorityFlags
ActorPriorityFlag bits: the spawner clears ACTOR_PRIORITY_AUTOMATIC when EFFECT_USE_PRIORITY sets the...
u8 unk14[4]
FieldActor's terrainHeight; not named by this view.
u8 unk54
FieldActor's spriteStorageKind; not named by this view.
s32 scaleRateX
Added to scaleX each frame by the update hooks, in 16.16 fixed point a frame; zeroed by the spawner.
u8 unk38[0x0c]
FieldActor's targetX to targetZ; not named by this view.
u8 unk00[8]
FieldActor's script pointer, cursor and facing; not named by this view.
u8 unk24[0x0c]
FieldActor's velocityX to velocityZ; effects move by velocity instead.
u8 motionFlags
ActorMotionFlag bits; zeroed by the spawner.
s32 scaleY
16.16 fixed point, 0x10000 full size
s32 scaleX
16.16 fixed point, 0x10000 full size
u8 unk20[3]
FieldActor's radius and terrainId; not named by this view.
s32 y
16.16 fixed-point pixels
u8 collisionFlags
FieldActor's collisionFlags; not named by this view.
s32 x
16.16 fixed-point pixels
s32 scaleRateY
as scaleRateX, for scaleY
u8 unk5a[0x0a]
FieldActor's steeringFlags to riseEnabled; not named by this view.
s32 countdown
Frames until a scene's update hook releases the effect: 20 for Altin Peak's spray,...
u8 unk56[3]
FieldActor's unk56; not named by this view.
u16 spin
Added to the sprite's rotation each frame by the update hooks, in 1/65536 turns per frame; Imil's ris...
Three coordinates, x, y and z: a position, a velocity or a direction.
Definition vector3.h:11
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
An object on the field, read as an actor or as an effect.
struct FieldActor actor
struct FieldEffect effect
Vector3, a three-coordinate vector.