30 while (event->control != -1) {
31 s32 eventFacing =
event->trigger & 0xf000;
32 s16 requiresFacing =
event->trigger & 0x0800;
33 s32 eventTarget =
event->trigger & 0xff;
35 if ((event->control & 0x0f) == 4 &&
37 (requiresFacing == 0 ||
38 (
u16)(eventFacing - facing + 0x17ff) <= 0x2ffe)) {
39 u32 flags =
event->control;
40 s32 eventItem = ((
const u8 *)&event->control)[1];
42 if (item == 0 || eventItem == item) {
43 if ((flags & 0x10) != 0) {
44 if (eventTarget == actorAhead)
46 }
else if (eventTarget == tileAhead) {
73 s32 mostMatchingSlots;
79 itemId = packedItem & 0x3ff;
80 actor = (packedItem >> 10) & 0xf;
85 mostMatchingSlots = 0;
90 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
93 for (inventorySlot = 0; inventorySlot < 15; inventorySlot++) {
94 if ((unit->
inventory[inventorySlot] & 0x1ff) == itemId)
98 if (mostMatchingSlots < matchingSlots) {
99 mostMatchingSlots = matchingSlots;
105 for (inventorySlot = 0; inventorySlot < 15; inventorySlot++) {
106 if ((unit->
inventory[inventorySlot] & 0x1ff) == itemId)
111 if (mostMatchingSlots == 0) {
118 if (event != 0 && event->
value != 0) {
124 if (!(event->
trigger & 0x400)) {
216 *(
s32 *)target = actorAhead;
222 while (event->control != -1) {
223 s32 eventFacing =
event->trigger & 0xf000;
224 s16 requiresFacing =
event->trigger & 0x0800;
225 s32 eventTarget =
event->trigger & 0xff;
229 (requiresFacing == 0 ||
230 (
u16)(eventFacing - facing + 0x17ff) <= 0x2ffe) &&
232 (anyPhase || (event->control & 0x7000000f) == eventFlags)) {
234 if ((event->control & 0x80) != 0)
235 return (
void *)event;
236 if ((event->control & 0x10) != 0) {
237 if (eventTarget == actorAhead)
238 return (
void *)event;
239 }
else if (eventTarget == tileAhead) {
240 return (
void *)event;
261 abilityId = packed & 0x3FF;
262 userId = ((
u32)packed >> 10) & 0xF;
void Event_SetMessageId(s32 message)
The event command "set message": the number of the event's next message, written to work->message.
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
struct BattleUnit * UnitGetFar(u32 owner)
struct ItemDefinition * Item_GetDirectFar(s32 item)
s32 GameFlag_TestFar(s32 flag)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
s32 GameFlag_SetBitFar(s32 flag)
s32 Inventory_RemoveFar(s32 owner, s32 slot)
s32 Party_CountActiveOwnersFar(void)
void GameFlag_ClearBitFar(s32 flag)
void UiText_ShowPositionedMessageAndWaitFar(s32 no, s32 flags)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiWork_FinalizePendingCoreFar(void)
#define FLAG_RETREAT_BLOCKED
Retreat is blocked, from Psynergy or an item.
#define FLAG_NOTHING_HAPPENS
Set before an action on the field; still set afterwards, nothing came of it and the game says so.
#define FLAG_ITEM_USE
the Psynergy comes from an item
#define FLAG_ITEM_USED_UP
the item just used is removed afterwards
struct GameState gGameState
void * BattleFx_FindMatchingEvent(s32 eventFlags, s32 group, void *target)
Returns the scene's Psynergy event (kind 5) for Psynergy of the given group that applies to what the ...
s32(*) BattleItemCallback(s32 item, s32 actor, s32 slot)
An item's own field routine, which the scene's item event may name.
s32 Field_FindItemEvent(s32 item)
Returns the scene's item event (kind 4) for item that applies to what the leader faces,...
s32 Field_RunPsynergyEvents(s32 packed)
Runs the scene's events for Psynergy without paying its PP or showing its usual effect (phases 3 and ...
s32 Field_UseItem(s32 packedItem, s32 slot)
Uses an item on the field.
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
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,...
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...
void FieldEvent_RunTypeHandler(void)
The extra handler of Reveal, Cloak and Avoid: what each does when it ends.
s32 Field_RunEventAction(const void *event, s32 param, s32 target)
Runs the event tied to an effect: a result below 0x10000 is a message, shown at target; a larger one ...
void BattleFx_Run(void)
Casts the current Psynergy effect with no target: runs the body of its kind (scene->fieldKind).
s32 Menu_AskYesNo(s32 atBottom)
Asks yes or no at the top of the screen, or at the bottom with atBottom set.
void FieldEvent_End(void)
Ends an event: stops the debug fast-forward callback, gives the camera back to the leader and refresh...
void FieldEvent_Begin(void)
The event command "begin event": closes any timed notice, stops the leader, resets the message and ti...
void FieldEvent_ShowMessageAndWait(s32 actor, s32 flags)
The event command "show message": opens the current message at actor (UiText_OpenMessageAtObject) and...
void BattleFx_SetupObjectPair(s32 userId, s32 targetId)
Records the caster and the target of an effect.
void EffectRuntime_StopCurrentObject(void)
Stops the caster's per-frame hook and restores its colours.
void BattleEffect_CleanupSceneObjects(void)
Ends a Psynergy effect: frees the effect slots still in use and, unless another effect is being resol...
void BattleFx_LoadActionEffectResources(s32 abilityId, s32 mode)
Prepares the work of the Psynergy effect for ability (heap slot 56) and loads its spark tiles.
What every part of object.c shares: its includes and the macros and types more than one part uses.
#define EXIT_RETREAT
the exit Retreat takes
#define PSYNERGY_EV_ANY
any phase
#define PSYNERGY_EV(phase)
The flags of a Psynergy event (kind 5) in the given phase.
struct EventWork * gEventWork
s32 Field_GetCollisionAheadOfLeader(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on ...
u8 type0c
The field Psynergy the ability works as, 1 (Move) to 16 (Avoid); 0 for none.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
s8 resolvingAction
set while Psynergy takes effect
const struct SceneEvent * events
the scene's event table
s16 retreatEntrance
where Retreat goes; the group's first entrance
s16 retreatScene
where Retreat goes; the group's first entrance
u8 activeOwners[8]
the party in order
s32 selectedActor
the leader: its unit and its actor
u16 actionId
the ability used, or taught as Psynergy
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
s16 trigger
What the event answers: an actor id, a tile's collision code, a marker id or a raised value.
u32 value
A message below 0x10000, else an event function; for an exit, the exit kind its scene's exit table ma...