14 object->effect.x +=
object->effect.velocity.x;
15 object->effect.y +=
object->effect.velocity.y;
16 object->effect.z +=
object->effect.velocity.z;
17 object->effect.scaleX +=
object->effect.scaleRateX;
18 object->effect.scaleY +=
object->effect.scaleRateY;
19 object->effect.sprite->rotation +=
object->effect.spin;
38 s32 velocityX,
s32 velocityY,
55#define EFFECT_SPAWN(name, create, set_mode, set_script) \
56 void name(s32 x, s32 y, s32 z, s32 velocityX, s32 velocityY, s32 velocityZ, \
57 u32 flags, const struct EffectOptions *options) { \
58 struct FieldActor *party = Actor_Get(ACTOR_PARTY_LEADER); \
59 struct FieldEffect *effect; \
60 struct AnimationObject *sprite; \
63 if ((flags & EFFECT_USE_TYPE) != 0 && options != 0) \
64 effect = (struct FieldEffect *)create(options->type, x, y, z); \
66 effect = (struct FieldEffect *)create(EFFECT_DEFAULT_TYPE, x, y, z); \
70 sprite = effect->sprite; \
71 set_mode((struct FieldActor *)effect, (flags + 1) & EFFECT_SCRIPT_MASK); \
72 set_script((void *)effect, gEffectScripts[flags & EFFECT_SCRIPT_MASK]); \
73 effect->motionFlags = 0; \
75 effect->update = BattleFx_UpdateObjectMotionScaleAndLinkedAngle; \
76 Effect_InitializeMotion(effect, sprite, party, velocityX, velocityY, \
79 if ((flags & EFFECT_OPTION_MASK) == 0 || options == 0) \
81 if ((flags & EFFECT_USE_PALETTE) != 0) \
82 ObjectGroup_SetChildValue((struct FieldActor *)effect, \
84 if ((flags & EFFECT_USE_PRIORITY) != 0) { \
85 effect->priorityFlags &= ~ACTOR_PRIORITY_AUTOMATIC; \
86 sprite->image.priority = options->priority; \
88 if ((flags & EFFECT_USE_START_SCALE) != 0) { \
89 effect->scaleX = options->startScaleX; \
90 effect->scaleY = options->startScaleY; \
92 if ((flags & EFFECT_SCALE_TO_TARGET) != 0) { \
93 script = gEffectScripts[flags & EFFECT_SCRIPT_MASK]; \
94 if ((flags & EFFECT_USE_START_SCALE) != 0) { \
95 effect->scaleRateX = (options->targetScaleX - effect->scaleX) / \
96 script[EFFECT_SCRIPT_REPEAT_COUNT]; \
97 effect->scaleRateY = (options->targetScaleY - effect->scaleY) / \
98 script[EFFECT_SCRIPT_REPEAT_COUNT]; \
100 effect->scaleRateX = (options->targetScaleX - Q16_ONE) / \
101 script[EFFECT_SCRIPT_REPEAT_COUNT]; \
102 effect->scaleRateY = (options->targetScaleY - Q16_ONE) / \
103 script[EFFECT_SCRIPT_REPEAT_COUNT]; \
106 if ((flags & EFFECT_USE_SCRIPT) != 0) { \
107 set_mode((struct FieldActor *)effect, 1); \
108 set_script((void *)effect, options->script); \
110 if ((flags & EFFECT_USE_ROTATION) != 0) \
111 sprite->rotation = options->rotation; \
112 if ((flags & EFFECT_USE_SPIN) != 0) \
113 effect->spin = options->spin; \
114 if ((flags & EFFECT_USE_UPDATE) != 0) \
115 effect->update = options->update; \
118#ifdef EFFECT_SPAWN_RESIDENT
const s32 * gEffectScripts[]
struct ObjectRuntime * Object_CreateFar(s32 id, s32 x, s32 y, s32 z)
Far call to FieldObject_Create.
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_InitializeFar(struct DispatchObject *obj, const s32 *script)
Field effects, their scripts and the flags that spawn them.
void Effect_SpawnResident(s32 x, s32 y, s32 z, s32 velocityX, s32 velocityY, s32 velocityZ, u32 flags, const struct EffectOptions *options)
void Object_SetMode(struct FieldActor *object, s32 animation)
static struct FieldActor * Object_Create(s32 type, s32 fixed_x, s32 fixed_y, s32 fixed_z)
static void Object_SetScript(struct FieldActor *object, const s32 *script)
The scene table formats: entrances, exits, placements and events, and the macros that write them.
16.16 fixed-point constants, sine and cosine, and the library division.
The object dispatcher's forward declaration.
@ EFFECT_SCRIPT_REPEAT_COUNT
#define EFFECT_SPAWN(name, create, set_mode, set_script)
static void Effect_InitializeMotion(struct FieldEffect *effect, struct AnimationObject *sprite, struct FieldActor *leader, s32 velocityX, s32 velocityY, s32 velocityZ)
Starts with linear motion and the leader's draw order; options can override it.
void BattleFx_UpdateObjectMotionScaleAndLinkedAngle(union FieldObject *object)
Integrates linear motion, scale changes and rotation once per effect frame.
#define offsetof(type, member)
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart image
u16 priority
2 when created
A field actor: a person or thing on the field with a position, motion toward a target,...
A field effect: a small object on the field that moves at its velocity and grows and spins at its rat...
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 scaleRateX
Added to scaleX each frame by the update hooks, in 16.16 fixed point a frame; zeroed by the spawner.
s32 scaleRateY
as scaleRateX, for scaleY
u16 spin
Added to the sprite's rotation each frame by the update hooks, in 1/65536 turns per frame; Imil's ris...
The integer types, TRUE, UNUSED and the fixed-address macros.
An object on the field, read as an actor or as an effect.