Alchemy
Loading...
Searching...
No Matches

catch.c

Go to the documentation of this file.
1/// @file
2/// Catch.
3/// Part of psynergy_effects.c, compiled only through it.
4
6
7/// Abilities: Catch (field kind 13), cast on a target.
8///
9/// Called by BattleFx_DispatchRequestKind; the target is ignored.
11
12/// Carries object 215 from 16 pixels above the caster to the goal in 10 steps,
13/// growing from a quarter to full size, presses down 20 pixels moving child to
14/// (-9, -9), rises 19.5 pixels and shrinks back.
15///
16/// Abilities: Catch (field kind 13).
17///
18/// The goal is 32 pixels in front of the caster with scene->enabled, otherwise
19/// the effect's position, 32 pixels up in both cases. Called by BattleFx_Run
20/// and FieldFx_RunCatchOnTarget. Moves the effect scene's child to (-9, -9)
21/// when there is one, and releases object 215 at the end.
22void FieldFx_RunCatch(void) {
23 struct BattleFxScene *scene = gEffectWork;
24 struct MotionObject *actor = scene->mainObject;
25 struct MotionObject *child = scene->child;
26 struct MotionObject *object;
27 struct FixedPointPosition spawn;
28 struct FixedPointPosition origin;
29 struct FixedPointPosition target;
30 s32 step;
31 s32 i;
32 s32 steps = 11;
33
34 origin.x = actor->x;
35 origin.y = actor->y + (16 << 16);
36 origin.z = actor->z;
37 if (scene->enabled) {
38 target.x = actor->x;
39 target.y = actor->y + (32 << 16);
40 target.z = actor->z;
41 Vector_AddPolarOffset(32 << 16, scene->angle, &target.x);
42 } else {
43 target.x = scene->x;
44 target.y = scene->y + (32 << 16);
45 target.z = scene->z;
46 }
47 spawn.x = scene->x;
48 spawn.y = scene->y + (32 << 16);
49 spawn.z = scene->z;
50 object = (struct MotionObject *)Object_Spawn(215, spawn.x, spawn.y, spawn.z);
51 if (object == 0)
52 return;
55 object->angle = actor->angle;
56 object->speedLimit = 0x14ccc;
57 object->motionFlags = 0;
60
61 // Reach out to the goal: steps 0 to 10 of an 11-step loop, a tenth of the
62 // way each frame.
63 step = 0;
64 do {
65 s32 scale;
66
67 SET_POSITION(object, origin.x + (target.x - origin.x) * step / 10,
68 origin.y + (target.y - origin.y) * step / 10,
69 origin.z + (target.z - origin.z) * step / 10);
70 scale = BattleFx_Interpolate(0x10000, 0x4000, step);
71 object->scaleX = scale;
72 object->scaleY = scale;
73 WaitFrames(1);
74 step++;
75 } while (step < steps);
76 WaitFrames(10);
78 WaitFrames(15);
79
80 // Press down 2 pixels a frame for 10 frames.
81 for (i = 0; i < 10; i++) {
82 object->y -= 2 << 16;
83 WaitFrames(1);
84 }
87 // XXX: why the caught object goes to (-9, -9) pixels, just off the map's
88 // corner; the scene code that reads it after Catch would settle it.
89 if (child != 0)
91 -(9 << 16), child->y, -(9 << 16));
92 WaitFrames(20);
93
94 // Rise 1.5 pixels a frame for 13 frames.
95 for (i = 0; i < 13; i++) {
96 object->y += 0x18000;
97 WaitFrames(1);
98 }
99 WaitFrames(10);
101
102 // Shrink back to the caster.
103 step = 0;
104 do {
105 s32 scale;
106
107 SET_POSITION(object, target.x + (origin.x - target.x) * step / 10,
108 target.y + (origin.y - target.y) * step / 10,
109 target.z + (origin.z - target.z) * step / 10);
110 scale = BattleFx_Interpolate(0x4000, 0x10000, step);
111 object->scaleX = scale;
112 object->scaleY = scale;
113 WaitFrames(1);
114 step++;
115 } while (step < steps);
118}
void FieldFx_RunCatch(void)
Carries object 215 from 16 pixels above the caster to the goal in 10 steps, growing from a quarter to...
Definition catch.c:22
void FieldFx_RunCatchOnTarget(s32 unused)
Abilities: Catch (field kind 13), cast on a target.
Definition catch.c:10
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
void Object_SetPositionAndResetMotionFar(struct ObjectRuntime *obj, s32 x, s32 y, s32 z)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void Animation_ApplyChildValuesFar(struct DispatchObject *obj, u32 val)
void AudioCommand_PlayFar(s32 id)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
static __inline__ s32 BattleFx_Interpolate(s32 to, s32 from, s32 step)
Definition fx_scene.h:90
void * gEffectWork
Slot 56: points to a scene-specific structure.
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
Definition macros.h:16
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
Definition math.c:23
struct ObjectRuntime * Object_Spawn(s32 kind, s32 x, s32 y, s32 z)
Creates an object for an effect, at the caster's ground height, with sprite priority 0 and animation ...
Definition dispatch.c:371
void BattleEffect_InitializeSharedScene(void)
Saves the palettes for the effect (once, unless an effect is already shown) and fades them toward one...
Definition setup.c:236
void BattleFx_PrepareBufferInterpolation(void)
Fades the palettes back from an effect's colours to the saved ones (or to palette 0x10001 while an ef...
Definition setup.c:275
What every part of psynergy_effects.c shares: its includes and the macros and types more than one par...
#define SE_132
Definition songs.h:125
#define SE_MENU_ERROR
Definition songs.h:107
#define SE_ITEM_BREAK
Definition songs.h:131
The work of a Psynergy effect scene: its caster and target, where it takes place, the map state it re...
Definition fx_scene.h:31
s32 y
16.16 fixed-point pixels
Definition fx_scene.h:34
s32 angle
1/65536 turns
Definition fx_scene.h:32
void * mainObject
the caster's object
Definition fx_scene.h:36
void * child
the target's object, or NULL
Definition fx_scene.h:37
s8 enabled
Set at the start: Force then aims in front of the caster; cleared once the target has been dispatched...
Definition fx_scene.h:44
s32 x
16.16 fixed-point pixels
Definition fx_scene.h:33
s32 z
16.16 fixed-point pixels
Definition fx_scene.h:35
A field object as the object dispatcher's far calls take it.
A position in three coordinates, each in 16.16 fixed point.
s32 z
16.16 fixed point
s32 x
16.16 fixed point
s32 y
16.16 fixed point
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
s32 z
16.16 fixed-point pixels
Definition motobj.h:25
s32 y
16.16 fixed-point pixels
Definition motobj.h:24
u16 angle
1/65536 turns
Definition motobj.h:22
s32 x
16.16 fixed-point pixels
Definition motobj.h:23
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
signed int s32
Definition types.h:14