13 s32 listedKind = *rangeEntry;
15 while (listedKind != -1) {
17 if (kind == listedKind) {
22 listedKind = *rangeEntry;
53 for (actorIndex = 0; actorIndex <=
OBJ_LAST; actorIndex++) {
63 if (candidate->
y - source->
y >= 0) {
64 if (candidate->
y - source->
y >= 48 << 16)
66 }
else if (source->
y - candidate->
y >= 48 << 16) {
71 dx = (candidate->
x - source->
x) / 0x10000;
72 dy = (candidate->
y - source->
y) / 0x10000;
73 dz = (candidate->
z - source->
z) / 0x10000;
78 squaredDistance = squaredX + squaredY + squaredZ;
81 distance = distance * 10 / 13;
82 if (distance >= nearestDistance)
91 if (angleDifference < -0x2fff)
93 if (angleDifference > 0x2fff)
97 nearestActor = actorIndex;
98 nearestDistance = distance;
132 facingQuadrant = (source->
angle + 0x2000) & 0xc000;
133 for (actorIndex = 0; actorIndex <=
OBJ_LAST; actorIndex++) {
134 if (actorIndex ==
id)
143 heightLimit = 8 << 16;
145 heightLimit = 48 << 16;
147 heightLimit = 64 << 16;
149 heightLimit = 16 << 16;
152 s32 dy = candidate->
y - source->
y;
154 if (dy > heightLimit)
156 }
else if (source->
y - candidate->
y > heightLimit) {
162 dx = candidate->
x - source->
x;
167 dz = candidate->
z - source->
z;
172 distance =
Iwram_Sqrt(dx * dx + pixelZ * pixelZ);
174 distance = distance * 2 / 3;
175 if (distance >= nearestDistance)
181 coneHalfAngle = 0x1800;
183 coneHalfAngle = 0x1000;
185 coneHalfAngle = 0x2000;
188 s32 angleDifference = (
s16)(
angle - facingQuadrant);
189 if (angleDifference < 0)
190 angleDifference = -angleDifference;
191 if (angleDifference >= coneHalfAngle)
195 nearestActor = actorIndex;
196 nearestDistance = distance;
213 if (targetActor != 0) {
236 sprite =
object->records;
237 replacement = palette - 1;
241 partCount = sprite->
count;
242 if (partCount != 0) {
244 remainingParts = partCount;
246 entry = *entrySlot++;
247 if (entry != 0 && entry->
script != 0 &&
249 entry->
param = replacement;
251 }
while (remainingParts != 0);
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
@ SPRITE_COLOR_HIDDEN
solid colour 0, transparent
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void AudioCommand_PlayFar(s32 id)
struct EffectObj * BattleFx_StartRandomParticleEmitter(s32 actor, s32 item)
Shows the picture of item (0 for none) at the centre of the cell 16 pixels in front of character acto...
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
volatile u32 gFrameCount
Frames WaitFrames has finished.
const u8 gAnimation_ChildPaletteCycle[8]
The palette cycle of Animation_ChildPaletteCycle ((gFrameCount >> 1) & 7).
const s16 gBattleFx_TargetRangeByMode[25]
{field Psynergy kind, range in pixels}, ended by -1; a kind not listed reaches 16 pixels.
s32 Field_RunPsynergyEvents(s32 packed)
Runs the scene's events for Psynergy without paying its PP or showing its usual effect (phases 3 and ...
static s32 Iwram_Sqrt(s32 value)
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
s32 Field_FindNearbyPsynergyTarget(s32 id, s32 kind)
Returns the actor nearest in front of actor id that a field Psynergy of the given kind can reach,...
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
s32 Field_FindNearbyTalkTarget(s32 id)
Returns the actor nearest to actor id that it could talk to, or -1: within 48 pixels of height and 32...
s32 Field_GetPsynergyTargetRange(s32 kind)
Returns how far, in pixels, a field Psynergy of the given kind reaches: gBattleFx_TargetRangeByMode p...
void Animation_ApplyChildPalette(struct MotionObject *object, s32 palette)
Gives every part of a motion object's sprite (but those at palette 15) palette - 1,...
s32 BattleFx_PlayCueAndStartEmitterOnTarget(s32 actor, s32 target, s32 itemId)
If actor target exists, plays SE_124, gives it animation 4 and, 12 frames later, shows itemId in fron...
What every part of object.c shares: its includes and the macros and types more than one part uses.
#define ACT_PACKED
use it without paying PP
struct EventWork * gEventWork
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 * script
the running script; null when stopped (ANIM_CMD_END)
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
u8 dirty
nonzero redraws its pixels into VRAM when next drawn
Full event work allocated by Field_RunScene (heap slot 27).
s16 revealActive
nonzero while Reveal is active
u16 busy
Set while a raised or touch event runs; FieldEvent_Begin then resets the effect counter.
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
u8 recordStorageKind
bits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 z
16.16 fixed-point pixels
u8 collisionFlags
FieldActor.collisionFlags: bit 0 solid, bit 1 the player pushes it, bits 2 to 4 for talk and Psynergy...
s32 x
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
#define OBJ_LAST
the last actor slot searched