Alchemy
Loading...
Searching...
No Matches

growth.c

Go to the documentation of this file.
1/// @file
2/// Growth.
3/// Part of psynergy_effects.c, compiled only through it.
4
6
7#define GROWTH_PARTICLE_MAX 24 ///< particles round the target
8#define GROWTH_PARTICLE_OBJECT 284 ///< particle object
9#define GROWTH_FALL_OBJECT 217 ///< falling object
10#define GROWTH_FALL_LAST 4 ///< five falling objects, 0 to 4
11
12/// A point Growth works out round the effect's position.
14 s32 values[3]; ///< x, y, z
15};
16
17/// A particle sprite's attributes.
21 u8 flip : 1;
26 union {
27 struct {
28 u16 shape : 10;
29 u16 unused : 6;
30 } bits;
31 struct {
32 u8 lo;
33 u8 highLow : 4;
34 u8 palette : 4;
35 } bytes;
37};
38
39/// A particle's sprite, seen as its two parts' attributes, which Growth copies
40/// from the first to the second.
44};
45
46/// Particles round the target, which takes the sprite priority of the ground
47/// under it.
48///
49/// Abilities: Growth (field kind 12), cast on a target.
51 struct FieldActor *target;
52
53 target = ((struct BattleFxScene *)gEffectWork)->child;
54 if (target != NULL) {
57 target->collisionFlags = 0;
59 target->priorityFlags |= ACTOR_PRIORITY_UNDERFOOT;
60 WaitFrames(10);
62 WaitFrames(40);
64 }
65}
66
67/// The particles, then five falling objects 4 to 10 pixels round the effect's
68/// position.
69///
70/// Abilities: Growth (field kind 12), cast with no target.
72 struct BattleFxScene *work = gEffectWork;
73 struct BurstParticleVector pos;
74 struct BurstParticleVector *p;
75 s32 remainingObjects;
76
79 p = &pos;
80 remainingObjects = GROWTH_FALL_LAST;
81 do {
82 struct FieldActor *particle;
83 s32 radius;
84
85 p->values[0] = work->x;
86 p->values[2] = work->z;
87 radius = (Random16() * 6) + 0x40000;
89 p->values[1] = work->y;
90 particle = (struct FieldActor *)Object_Spawn(
91 GROWTH_FALL_OBJECT, p->values[0], p->values[1], p->values[2]);
92 if (particle != 0) {
95 particle->motionFlags = ACTOR_FALLS;
96 }
97 WaitFrames(((Random16() * 2) >> 16) + 2);
98 remainingObjects--;
99 } while (remainingObjects >= 0);
100 WaitFrames(30);
102}
103
104/// Sends 24 particles, one every 2 frames, from in front of the caster to
105/// points round the effect's position. They start 10 pixels up facing south,
106/// 24 pixels up facing north, and 10 pixels up and 10 ahead otherwise.
108 struct BattleFxScene *work;
109 struct FieldActor *caster;
110 s32 pos[3];
111 s32 particleIndex;
112
114 caster = work->mainObject;
116
117 for (particleIndex = 0; particleIndex < GROWTH_PARTICLE_MAX;
118 particleIndex++) {
119 struct FieldActor *particle;
120 struct BurstParticleVisual *visual;
121 struct BurstParticleVisual *child;
122 s32 radius;
123
124 if (work->angle == 0x4000) {
125 SET_VECTOR(pos, caster->x.fixed, caster->y.fixed + 0xa0000,
126 caster->z.fixed);
127 } else if (work->angle == 0xc000) {
128 SET_VECTOR(pos, caster->x.fixed, caster->y.fixed + 0x180000,
129 caster->z.fixed);
130 } else {
131 SET_VECTOR(pos, caster->x.fixed, caster->y.fixed + 0xa0000,
132 caster->z.fixed);
133 Vector_AddPolarOffset(0xa0000, work->angle, pos);
134 }
135
136 // Copy the flip, shape and palette to the child sprite.
137 particle = (struct FieldActor *)Object_Spawn(GROWTH_PARTICLE_OBJECT, pos[0],
138 pos[1], pos[2]);
139 visual = &((struct BurstParticleVisualGroup *)particle->sprite)->primary;
140 child = &((struct BurstParticleVisualGroup *)particle->sprite)->child;
141 child->flip = visual->flip;
142 child->flagsAHigh = visual->flagsAHigh;
143 child->flagsBHigh = visual->flagsBHigh;
144 child->attributes.bits.shape = visual->attributes.bits.shape;
145 child->attributes.bytes.palette = visual->attributes.bytes.palette;
146
147 if (particle != 0) {
148 particle->scaleY = 0xb333; // 0.7
149 particle->scaleX = 0xb333;
150 particle->acceleration = 0x18000;
151 particle->speed = 0x18000;
152 particle->motionFlags = 0;
153 Animation_ApplyChildValuesFar((struct DispatchObject *)particle, 11);
158 1);
159
160 // Destination: 4 to 10 pixels from the effect's position.
161 SET_VECTOR(pos, work->x, work->y, work->z);
162 if (work->angle == 0xc000)
163 Vector_AddPolarOffset(0xe0000, work->angle, pos);
164 radius = Random16() * 6 + 0x40000;
165 Vector_AddPolarOffset(radius, Random16(), pos);
166 Object_SetMoveTargetFar((struct ObjectRuntime *)particle, pos[0], pos[1],
167 pos[2]);
168 }
170 WaitFrames(2);
171 }
172 WaitFrames(8);
173}
174
175#undef GROWTH_PARTICLE_MAX
176#undef GROWTH_PARTICLE_OBJECT
177#undef GROWTH_FALL_OBJECT
178#undef GROWTH_FALL_LAST
void ObjectDispatch_SetSingleChildFlagsFar(struct DispatchObject *obj, u32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_InitializeFar(struct DispatchObject *obj, const s32 *script)
void Object_SetMoveTargetFar(struct ObjectRuntime *object, s32 x, s32 y, s32 z)
void Animation_ApplyChildValuesFar(struct DispatchObject *obj, u32 val)
void AudioCommand_PlayFar(s32 id)
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
Definition field_obj.h:155
@ ACTOR_FALLS
falls by its gravity and bounces
Definition field_obj.h:161
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
const s32 gBattleFx_BurstParticleObjectScript[]
Word +4 is gBattleFx_HeavyImpactScript.
Definition fxdata.c:476
const s32 gBattleFx_CommonParticleScript[]
[0] only frees the actor, +1 waits for it to arrive and frees it; +3 is gBattleFx_SourceHoldScript,...
Definition fxdata.c:444
void * gEffectWork
Slot 56: points to a scene-specific structure.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
Definition macros.h:12
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
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
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
#define GROWTH_FALL_OBJECT
falling object
Definition growth.c:9
#define GROWTH_PARTICLE_OBJECT
particle object
Definition growth.c:8
void BattleEffect_SpawnBurstParticleField(void)
Sends 24 particles, one every 2 frames, from in front of the caster to points round the effect's posi...
Definition growth.c:107
#define GROWTH_FALL_LAST
five falling objects, 0 to 4
Definition growth.c:10
void FieldFx_RunGrowthOnTarget(s32 unused)
Particles round the target, which takes the sprite priority of the ground under it.
Definition growth.c:50
#define GROWTH_PARTICLE_MAX
particles round the target
Definition growth.c:7
void FieldFx_RunGrowth(void)
The particles, then five falling objects 4 to 10 pixels round the effect's position.
Definition growth.c:71
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_RECOVERY
Definition songs.h:119
#define SE_131
Definition songs.h:124
#define SE_HEAVY_IMPACT
Definition songs.h:127
#define NULL
Definition bilibin.h:6
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 * child
the target's object, or NULL
Definition fx_scene.h:37
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 point Growth works out round the effect's position.
Definition growth.c:13
s32 values[3]
x, y, z
Definition growth.c:14
A particle's sprite, seen as its two parts' attributes, which Growth copies from the first to the sec...
Definition growth.c:41
struct BurstParticleVisual child
Definition growth.c:43
struct BurstParticleVisual primary
Definition growth.c:42
A particle sprite's attributes.
Definition growth.c:18
union BurstParticleVisual::@126276175202327065265047147273232301312011235242 attributes
A field object as the object dispatcher's far calls take it.
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s32 speed
speed limit, 16.16 fixed-point pixels per frame
Definition field_obj.h:55
u16 radius
Collision radius in pixels: 16, or half the sprite metadata's boxY, when created; the overlap checks ...
Definition field_obj.h:43
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
Definition field_obj.h:83
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
Definition field_obj.h:58
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition field_obj.h:39
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition field_obj.h:40
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
Definition field_obj.h:91
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
signed int s32
Definition types.h:14
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
struct BurstParticleVisual::@126276175202327065265047147273232301312011235242::@317272372153265270346004241356334055115007313341 bits
struct BurstParticleVisual::@126276175202327065265047147273232301312011235242::@305217217245255163100005303332215165247335037335 bytes
s32 fixed
16.16 fixed-point pixels