diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-03-09 14:35:23 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-09 12:35:23 -0500 |
| commit | c833969ea79ba31c3103e25e94ef88098c0287de (patch) | |
| tree | bc60d4135593ee06a17dff9972ef80b794c89982 /src/code | |
| parent | 496b4928ea8bdf310949a88bbe221d91c2d3ebff (diff) | |
`z_actor` documentation pass (#1154)
* ActorContext_unk_1F4
* a
* ACTOR_FLAG_IGNORE_QUAKE
* ACTOR_FLAG_TALK_REQUESTED and ACTOR_FLAG_CANT_LOCK_ON
* actorCtx->unkC => ctorCtx->halfDaysBit
* HALFDAYBIT defines
* actor.halfDaysBits
* format
* Actor_InitHalfDaysBit
* Name actor-killing functions
* cleanup variables.h a bit
* DAWN
* bss
* Actor_RequestRumble and Actor_GetArrowDmgFlags
* name vars of func_800BC620
* format
* fix missing PLAYER_IA
* Actor_OfferGetItem
* Actor_SetClosestSecretDistance
* freezeCategoryPlayerFlags1
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* DROPFLAG_
* a
* COLORFILTER
* format
* sCategoryFreezeMasks
* Actor_OfferCarry
* review
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* change hex to dec
* COLORFILTER_INTENSITY_FLAG
* format
* review
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
* shiftedHalfDaysBit
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
* cleanup
* Undo Actor_RequestRumble
* Undo ACTOR_FLAG_IGNORE_QUAKE
* format
* Remove COLORFILTER_GET_BUFFLAG
* Undo Actor_KillAllFromUnloadedRooms
* format
* Update Actor_OfferGetItem comment
* Update Actor_OfferGetItem description
* diving
* bss
* namefixer
* format
* speed
* review
---------
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_actor.c | 467 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 15 | ||||
| -rw-r--r-- | src/code/z_scene.c | 4 | ||||
| -rw-r--r-- | src/code/z_sub_s.c | 2 |
4 files changed, 269 insertions, 219 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d00061bf5..72d330f59 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -32,7 +32,7 @@ extern Mtx D_801ED8E0; // 1 func extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor // Internal forward declarations -void func_800BA8B8(PlayState* play, ActorContext* actorCtx); +void Actor_KillAllOnHalfDayChange(PlayState* play, ActorContext* actorCtx); Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play); Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play); void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player); @@ -129,9 +129,9 @@ void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play) { } void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play) { - static Color_RGBA8 color = { 255, 255, 255, 255 }; + static Color_RGBA8 sColor = { 255, 255, 255, 255 }; - ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &color); + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &sColor); } void ActorShadow_DrawHorse(Actor* actor, Lights* lights, PlayState* play) { @@ -195,7 +195,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { if (distToFloor < 200.0f) { MtxF sp13C; MtxF spFC; - CollisionPoly* spF8; + CollisionPoly* poly; s32 bgId; f32 floorHeight[2]; Light* firstLight = &mapper->l.l[0]; @@ -224,7 +224,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) { feetPosPtr->y += 50.0f; - *floorHeightPtr = Play_GetFloorSurfaceImpl(play, &sp13C, &spF8, &bgId, feetPosPtr); + *floorHeightPtr = Play_GetFloorSurfaceImpl(play, &sp13C, &poly, &bgId, feetPosPtr); feetPosPtr->y -= 50.0f; distToFloor = feetPosPtr->y - *floorHeightPtr; @@ -235,7 +235,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { actor->shape.feetFloorFlags |= spB8; if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) { - if (func_800C9C24(&play->colCtx, spF8, bgId, 1) != 0) { + if (func_800C9C24(&play->colCtx, poly, bgId, 1)) { SkinMatrix_MtxFCopy(&sp13C, &spFC); SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y); EffFootmark_Add(play, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f), @@ -560,7 +560,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) { } actor = targetCtx->unk_94; - if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_8000000)) { + if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_CANT_LOCK_ON)) { TatlColor* color = &sTatlColorList[actor->category]; POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); @@ -907,39 +907,41 @@ s32 func_800B6434(PlayState* play, TitleCardContext* titleCtx) { return true; } +// ActorContext_1F4 Init void func_800B6468(PlayState* play) { - play->actorCtx.unk1F5 = 0; + play->actorCtx.unk_1F4.timer = 0; } +// ActorContext_1F4 Update void func_800B6474(PlayState* play) { - if (play->actorCtx.unk1F5 != 0) { - play->actorCtx.unk1F5--; - } + DECR(play->actorCtx.unk_1F4.timer); } -s32 func_800B648C(PlayState* play, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) { - if ((play->actorCtx.unk1F5 != 0) && (arg3 < play->actorCtx.unk1F8)) { +// ActorContext_1F4 setter something +s32 func_800B648C(PlayState* play, s32 arg1, s32 timer, f32 arg3, Vec3f* arg4) { + if ((play->actorCtx.unk_1F4.timer != 0) && (arg3 < play->actorCtx.unk_1F4.unk_04)) { return false; } - play->actorCtx.unk1F4 = arg1; - play->actorCtx.unk1F5 = arg2; - play->actorCtx.unk1F8 = arg3; - Math_Vec3f_Copy(&play->actorCtx.unk1FC, arg4); + play->actorCtx.unk_1F4.unk_00 = arg1; + play->actorCtx.unk_1F4.timer = timer; + play->actorCtx.unk_1F4.unk_04 = arg3; + Math_Vec3f_Copy(&play->actorCtx.unk_1F4.unk_08, arg4); return true; } +// ActorContext_1F4 getter something f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3) { f32 temp_f8; - if ((play->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) { + if ((play->actorCtx.unk_1F4.timer == 0) || (arg1 == 0.0f)) { return -1.0f; } - temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk1FC, arg2) / arg1; - *arg3 = play->actorCtx.unk1F4; - return play->actorCtx.unk1F8 - temp_f8; + temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk_1F4.unk_08, arg2) / arg1; + *arg3 = play->actorCtx.unk_1F4.unk_00; + return play->actorCtx.unk_1F4.unk_04 - temp_f8; } /** @@ -1010,7 +1012,7 @@ void* func_800B6608(PlayState* play, s16 id) { * Retrieves the first pointer stored with the id `id`. * If there's no pointer stored with that id, NULL is returned. * - * Used only by EnLiftNuts. + * Used only by EnGamelupy. */ void* func_800B6680(PlayState* play, s16 id) { ActorContext_unk_20C* entry = play->actorCtx.unk_20C; @@ -1101,17 +1103,17 @@ void Actor_Destroy(Actor* actor, PlayState* play) { } } -f32 actorMovementScale = 1.0f; +f32 sActorMovementScale = 1.0f; void Actor_SetMovementScale(s32 scale) { - actorMovementScale = scale * 0.5f; + sActorMovementScale = scale * 0.5f; } /** * Update actor position using velocity and any push from z_collision_check. */ void Actor_UpdatePos(Actor* actor) { - f32 speedRate = actorMovementScale; + f32 speedRate = sActorMovementScale; actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x; actor->world.pos.y += (actor->velocity.y * speedRate) + actor->colChkInfo.displacement.y; @@ -1302,12 +1304,16 @@ f32 Player_GetHeight(Player* player) { default: case PLAYER_FORM_FIERCE_DEITY: return extraHeight + 124.0f; + case PLAYER_FORM_GORON: return extraHeight + ((player->stateFlags3 & PLAYER_STATE3_1000) ? 34.0f : 80.0f); + case PLAYER_FORM_ZORA: return extraHeight + 68.0f; + case PLAYER_FORM_DEKU: return extraHeight + 36.0f; + case PLAYER_FORM_HUMAN: return extraHeight + 44.0f; } @@ -1785,7 +1791,7 @@ f32 func_800B82EC(Actor* actor, Player* player, s16 angle) { s16 yaw = ABS_ALT(temp_v0); if (player->targetedActor != NULL) { - if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_8000000))) { + if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_CANT_LOCK_ON))) { return FLT_MAX; } @@ -1813,7 +1819,7 @@ s32 func_800B83BC(Actor* actor, f32 arg1) { } s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { - if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_8000000)) { + if ((actor->update == NULL) || !(actor->flags & ACTOR_FLAG_1) || (actor->flags & ACTOR_FLAG_CANT_LOCK_ON)) { return true; } @@ -1835,24 +1841,34 @@ s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { } s16 D_801AED48[] = { - 0x101, 0x141, 0x111, 0x151, 0x105, 0x145, 0x115, 0x155, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY3_NIGHT | HALFDAYBIT_DAY4_NIGHT, + HALFDAYBIT_DAY0_NIGHT | HALFDAYBIT_DAY1_NIGHT | HALFDAYBIT_DAY2_NIGHT | HALFDAYBIT_DAY3_NIGHT | + HALFDAYBIT_DAY4_NIGHT, }; s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) { - if (actor->flags & ACTOR_FLAG_100) { - actor->flags &= ~ACTOR_FLAG_100; + if (actor->flags & ACTOR_FLAG_TALK_REQUESTED) { + actor->flags &= ~ACTOR_FLAG_TALK_REQUESTED; return true; } return false; } -// Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp +// Actor_OfferTalk / Actor_OfferGetItemExchange? Seems to be called with PLAYER_IA_MINUS1 if the same actor used +// Actor_OfferGetItem. // This function is also used to toggle the "Speak" action on the A button s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, PlayerItemAction exchangeItemId) { Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_100) || ((exchangeItemId > PLAYER_IA_NONE) && Player_InCsMode(play)) || + if ((player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) || + ((exchangeItemId > PLAYER_IA_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || (actor->xzDistToPlayer > player->talkActorDistance) || (xzRange < actor->xzDistToPlayer)))) { @@ -1883,7 +1899,7 @@ s32 func_800B863C(Actor* actor, PlayState* play) { s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - actor->flags &= ~ACTOR_FLAG_100; + actor->flags &= ~ACTOR_FLAG_TALK_REQUESTED; return true; } @@ -1900,7 +1916,7 @@ s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) { talkActor = player->talkActor; - if ((player->actor.flags & ACTOR_FLAG_100) && (talkActor != NULL)) { + if ((player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) && (talkActor != NULL)) { player->talkActor = actor2; player->targetedActor = actor2; return true; @@ -1987,13 +2003,29 @@ s32 Actor_HasParent(Actor* actor, PlayState* play) { } /** - * Allows to pick up an item (GetItem or GI), lift an actor or catch various actors in bottles - * within the specified range. + * This function covers various interactions with the player actor, using Get Item IDs (see `GetItemID` enum). + * It is typically used to give items to the player, but also has other purposes. + * + * This function carries a get item request to the player actor if context allows it (e.g. the player is in range and + * not busy with certain things). The player actor performs the requested action itself. * - * GI_NONE is usually used as a special case to lift an actor - * GI_MAX is usually used to catch an actor in a bottle + * The following description of what the `getItemId` values can do is provided here for completeness, but these + * behaviors are entirely out of the scope of this function. All behavior is defined by the player actor. + * + * - Positive values (`GI_NONE < getItemId < GI_MAX`): + * Give an item to the player. The player may not get it immediately (for example if diving), but is expected to + * in the near future. + * - Negative values (`-GI_MAX < getItemId < GI_NONE`): + * Used by treasure chests to indicate the chest can be opened (by pressing A). + * The item gotten corresponds to the positive Get Item ID `abs(getItemId)`. + * - `GI_NONE`: + * Allows the player to pick up the actor (by pressing A), to carry it around. + * - `GI_MAX`: + * Allows the player to catch specific actors in a bottle. + * + * @return true If the player actor is capable of accepting the offer. */ -s32 Actor_PickUp(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange, f32 yRange) { +s32 Actor_OfferGetItem(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & @@ -2027,16 +2059,16 @@ s32 Actor_PickUp(Actor* actor, PlayState* play, GetItemId getItemId, f32 xzRange return false; } -s32 Actor_PickUpNearby(Actor* actor, PlayState* play, GetItemId getItemId) { - return Actor_PickUp(actor, play, getItemId, 50.0f, 10.0f); +s32 Actor_OfferGetItemNearby(Actor* actor, PlayState* play, GetItemId getItemId) { + return Actor_OfferGetItem(actor, play, getItemId, 50.0f, 10.0f); } -s32 Actor_LiftActor(Actor* actor, PlayState* play) { - return Actor_PickUpNearby(actor, play, GI_NONE); +s32 Actor_OfferCarry(Actor* actor, PlayState* play) { + return Actor_OfferGetItemNearby(actor, play, GI_NONE); } -s32 Actor_PickUpFar(Actor* actor, PlayState* play, GetItemId getItemId) { - return Actor_PickUp(actor, play, getItemId, 9999.9f, 9999.9f); +s32 Actor_OfferGetItemFar(Actor* actor, PlayState* play, GetItemId getItemId) { + return Actor_OfferGetItem(actor, play, getItemId, 9999.9f, 9999.9f); } s32 Actor_HasNoParent(Actor* actor, PlayState* play) { @@ -2066,7 +2098,7 @@ void func_800B8C20(Actor* actorA, Actor* actorB, PlayState* play) { * Sets closest secret distance to the distance to the actor. Calling this function on `actor` is the way to make it a * 'secret' for that update cycle, i.e. something that the controller will rumble for. */ -void func_800B8C50(Actor* actor, PlayState* play) { +void Actor_SetClosestSecretDistance(Actor* actor, PlayState* play) { Player* player = GET_PLAYER(play); if (actor->xyzDistToPlayerSq < player->closestSecretDistSq) { @@ -2230,14 +2262,14 @@ void Actor_DeactivateLens(PlayState* play) { } } -void func_800B9120(ActorContext* actorCtx) { - s32 phi_v0 = CURRENT_DAY * 2; +void Actor_InitHalfDaysBit(ActorContext* actorCtx) { + s32 halfDayCount = CURRENT_DAY * 2; - if (gSaveContext.save.time < CLOCK_TIME(6, 0) || gSaveContext.save.time > CLOCK_TIME(18, 0)) { - phi_v0++; + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) || (gSaveContext.save.time > CLOCK_TIME(18, 0))) { + halfDayCount++; } - actorCtx->unkC = 0x200 >> phi_v0; + actorCtx->halfDaysBit = HALFDAYBIT_DAY0_DAWN >> halfDayCount; } void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry) { @@ -2276,7 +2308,7 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto Actor_SpawnEntry(actorCtx, actorEntry, play); Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, play); - func_800B9120(actorCtx); + Actor_InitHalfDaysBit(actorCtx); Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); func_800B722C(&play->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); } @@ -2288,24 +2320,27 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) { if (play->numSetupActors > 0) { ActorEntry* actorEntry = play->setupActorList; - s32 temp_fp = actorCtx->unkC; - s32 temp_s1; - s32 phi_v0; + s32 prevHalfDaysBitValue = actorCtx->halfDaysBit; + s32 shiftedHalfDaysBit; + s32 actorEntryHalfDayBit; s32 i; - func_800B9120(actorCtx); - func_800BA8B8(play, &play->actorCtx); + Actor_InitHalfDaysBit(actorCtx); + Actor_KillAllOnHalfDayChange(play, &play->actorCtx); - temp_s1 = (actorCtx->unkC * 2) & 0x2FF; + // Shift to previous halfDay bit, but ignoring DAY0_NIGHT. + // In other words, if the current halfDay is DAY1_DAY then this logic is ignored and this variable is zero + shiftedHalfDaysBit = (actorCtx->halfDaysBit << 1) & (HALFDAYBIT_ALL & ~HALFDAYBIT_DAY0_NIGHT); for (i = 0; i < play->numSetupActors; i++) { - phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); - if (phi_v0 == 0) { - phi_v0 = 0x3FF; + actorEntryHalfDayBit = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F); + if (actorEntryHalfDayBit == 0) { + actorEntryHalfDayBit = HALFDAYBIT_ALL; } - if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) && - (!CHECK_EVENTINF(EVENTINF_17) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { + if (!(actorEntryHalfDayBit & prevHalfDaysBitValue) && (actorEntryHalfDayBit & actorCtx->halfDaysBit) && + (!CHECK_EVENTINF(EVENTINF_17) || !(actorEntryHalfDayBit & shiftedHalfDaysBit) || + !(actorEntry->id & 0x800))) { Actor_SpawnEntry(&play->actorCtx, actorEntry, play); } actorEntry++; @@ -2319,9 +2354,9 @@ void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) { typedef struct { /* 0x00 */ PlayState* play; /* 0x04 */ Actor* actor; - /* 0x08 */ u32 unk_08; - /* 0x0C */ u32 unkC; - /* 0x10 */ Actor* unk10; + /* 0x08 */ u32 requiredActorFlag; + /* 0x0C */ u32 canFreezeCategory; + /* 0x10 */ Actor* talkActor; /* 0x14 */ Player* player; /* 0x18 */ u32 unk_18; // Bitmask of actor flags. The actor will only have main called if it has at least 1 // flag set that matches this bitmask @@ -2356,53 +2391,51 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { } else { if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_Kill(actor); + } else if (((params->requiredActorFlag) && !(actor->flags & params->requiredActorFlag)) || + ((((!params->requiredActorFlag) != 0)) && + (!(actor->flags & ACTOR_FLAG_100000) || + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && + params->canFreezeCategory && (actor != params->talkActor) && + ((actor != params->player->heldActor)) && (actor->parent != ¶ms->player->actor))) { + CollisionCheck_ResetDamage(&actor->colChkInfo); } else { - if (((params->unk_08) && !(actor->flags & params->unk_08)) || - ((((!params->unk_08) != 0)) && - (!(actor->flags & ACTOR_FLAG_100000) || - ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && - (params->unkC != 0) && (actor != params->unk10) && ((actor != params->player->heldActor)) && - (actor->parent != ¶ms->player->actor))) { - CollisionCheck_ResetDamage(&actor->colChkInfo); - } else { - Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); - actor->xzDistToPlayer = Actor_WorldDistXZToActor(actor, ¶ms->player->actor); - actor->playerHeightRel = Actor_HeightDiff(actor, ¶ms->player->actor); - actor->xyzDistToPlayerSq = SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel); + Math_Vec3f_Copy(&actor->prevPos, &actor->world.pos); + actor->xzDistToPlayer = Actor_WorldDistXZToActor(actor, ¶ms->player->actor); + actor->playerHeightRel = Actor_HeightDiff(actor, ¶ms->player->actor); + actor->xyzDistToPlayerSq = SQ(actor->xzDistToPlayer) + SQ(actor->playerHeightRel); - actor->yawTowardsPlayer = Actor_WorldYawTowardActor(actor, ¶ms->player->actor); - actor->flags &= ~ACTOR_FLAG_1000000; + actor->yawTowardsPlayer = Actor_WorldYawTowardActor(actor, ¶ms->player->actor); + actor->flags &= ~ACTOR_FLAG_1000000; - if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { - if (actor == params->player->targetedActor) { - actor->isTargeted = true; - } else { - actor->isTargeted = false; - } - - if ((actor->targetPriority != 0) && (params->player->targetedActor == NULL)) { - actor->targetPriority = 0; - } + if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { + if (actor == params->player->targetedActor) { + actor->isTargeted = true; + } else { + actor->isTargeted = false; + } - Actor_SetObjectDependency(play, actor); + if ((actor->targetPriority != 0) && (params->player->targetedActor == NULL)) { + actor->targetPriority = 0; + } - if (actor->colorFilterTimer != 0) { - actor->colorFilterTimer--; - } + Actor_SetObjectDependency(play, actor); - actor->update(actor, play); - BgCheck_ResetFlagsIfLoadedActor(play, &play->colCtx.dyna, actor); + if (actor->colorFilterTimer != 0) { + actor->colorFilterTimer--; } - CollisionCheck_ResetDamage(&actor->colChkInfo); + actor->update(actor, play); + BgCheck_ResetFlagsIfLoadedActor(play, &play->colCtx.dyna, actor); } + + CollisionCheck_ResetDamage(&actor->colChkInfo); } nextActor = actor->next; } return nextActor; } -u32 D_801AED58[ACTORCAT_MAX] = { +u32 sCategoryFreezeMasks[ACTORCAT_MAX] = { /* ACTORCAT_SWITCH */ PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, /* ACTORCAT_BG */ @@ -2437,7 +2470,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { s32 i; Actor* actor; Player* player = GET_PLAYER(play); - u32* tmp; + u32* categoryFreezeMaskP; s32 cat; Actor* next; ActorListEntry* entry; @@ -2458,22 +2491,23 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { actorCtx->unk2--; } - tmp = D_801AED58; + categoryFreezeMaskP = sCategoryFreezeMasks; if (player->stateFlags2 & PLAYER_STATE2_8000000) { - params.unk_08 = 0x2000000; + params.requiredActorFlag = ACTOR_FLAG_2000000; } else { - params.unk_08 = 0; + params.requiredActorFlag = 0; } if ((player->stateFlags1 & PLAYER_STATE1_40) && ((player->actor.textId & 0xFF00) != 0x1900)) { - params.unk10 = player->talkActor; + params.talkActor = player->talkActor; } else { - params.unk10 = NULL; + params.talkActor = NULL; } - for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); entry++, tmp++, i++) { - params.unkC = *tmp & player->stateFlags1; + for (i = 0, entry = actorCtx->actorLists; i < ARRAY_COUNT(actorCtx->actorLists); + entry++, categoryFreezeMaskP++, i++) { + params.canFreezeCategory = *categoryFreezeMaskP & player->stateFlags1; params.actor = entry->first; while (params.actor != NULL) { @@ -2559,31 +2593,33 @@ void Actor_Draw(PlayState* play, Actor* actor) { gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); if (actor->colorFilterTimer != 0) { - s32 temp_v0_2 = actor->colorFilterParams & 0xC000; + s32 colorFlag = COLORFILTER_GET_COLORFLAG(actor->colorFilterParams); Color_RGBA8 actorDefaultHitColor = { 0, 0, 0, 255 }; - if (temp_v0_2 == 0x8000) { + if (colorFlag == COLORFILTER_COLORFLAG_GRAY) { actorDefaultHitColor.r = actorDefaultHitColor.g = actorDefaultHitColor.b = - ((actor->colorFilterParams & 0x1F00) >> 5) | 7; - } else if (temp_v0_2 == 0x4000) { - actorDefaultHitColor.r = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; - } else if (temp_v0_2 == 0xC000) { + COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; + } else if (colorFlag == COLORFILTER_COLORFLAG_RED) { + actorDefaultHitColor.r = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; + } else if (colorFlag == COLORFILTER_COLORFLAG_NONE) { actorDefaultHitColor.b = actorDefaultHitColor.g = actorDefaultHitColor.r = 0; } else { - actorDefaultHitColor.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + actorDefaultHitColor.b = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; } - if (actor->colorFilterParams & 0x2000) { - func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + if (actor->colorFilterParams & COLORFILTER_BUFFLAG_XLU) { + func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, + COLORFILTER_GET_DURATION(actor->colorFilterParams)); } else { - func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, + COLORFILTER_GET_DURATION(actor->colorFilterParams)); } } actor->draw(actor, play); if (actor->colorFilterTimer != 0) { - if (actor->colorFilterParams & 0x2000) { + if (actor->colorFilterParams & COLORFILTER_BUFFLAG_XLU) { func_800AE8EC(play); } else { func_800AE5A0(play); @@ -2897,9 +2933,9 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { } /** - * Kills every actor which its object is not loaded + * Kill every actor which depends on an object that is not loaded. */ -void func_800BA6FC(PlayState* play, ActorContext* actorCtx) { +void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -2949,15 +2985,19 @@ void func_800BA798(PlayState* play, ActorContext* actorCtx) { play->msgCtx.unk_12030 = 0; } -void func_800BA8B8(PlayState* play, ActorContext* actorCtx) { +/** + * Kill every actor which does not have the current halfDayBit enabled + */ +void Actor_KillAllOnHalfDayChange(PlayState* play, ActorContext* actorCtx) { s32 i; for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { Actor* actor = actorCtx->actorLists[i].first; while (actor != NULL) { - if (!(actor->unk20 & actorCtx->unkC)) { + if (!(actor->halfDaysBits & actorCtx->halfDaysBit)) { func_80123590(play, actor); + if (!actor->isDrawn) { actor = Actor_Delete(actorCtx, actor, play); } else { @@ -3085,8 +3125,8 @@ void Actor_FreeOverlay(ActorOverlay* entry) { Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { - return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, 0x3FF, - NULL); + return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, + HALFDAYBIT_ALL, NULL); } ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { @@ -3130,7 +3170,7 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) { } Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s16 index, f32 x, f32 y, f32 z, s16 rotX, - s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) { + s16 rotY, s16 rotZ, s32 params, u32 cutscene, u32 halfDaysBits, Actor* parent) { s32 pad; Actor* actor; ActorInit* actorInit; @@ -3202,10 +3242,10 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 actor->cutscene = -1; } - if (arg11 != 0) { - actor->unk20 = arg11; + if (halfDaysBits != 0) { + actor->halfDaysBits = halfDaysBits; } else { - actor->unk20 = 0x3FF; + actor->halfDaysBits = HALFDAYBIT_ALL; } Actor_AddToCategory(actorCtx, actor, actorInit->type); @@ -3223,7 +3263,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) { return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, - parent->unk20, parent); + parent->halfDaysBits, parent); } void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { @@ -3239,13 +3279,13 @@ void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { (transitionActorList->sides[1].room >= 0 && (play->roomCtx.curRoom.num == transitionActorList->sides[1].room || play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) { - s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f); + s16 rotY = DEG_TO_BINANG((transitionActorList->rotY >> 7) & 0x1FF); if (Actor_SpawnAsChildAndCutscene(actorCtx, play, transitionActorList->id & 0x1FFF, transitionActorList->pos.x, transitionActorList->pos.y, transitionActorList->pos.z, 0, rotY, 0, (i << 0xA) + (transitionActorList->params & 0x3FF), - transitionActorList->rotY & 0x7F, 0x3FF, 0) != NULL) { + transitionActorList->rotY & 0x7F, HALFDAYBIT_ALL, 0) != NULL) { transitionActorList->id = -transitionActorList->id; } numTransitionActors = play->doorCtx.numTransitionActors; @@ -3260,19 +3300,19 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayStat s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF; if (!(actorEntry->id & 0x8000)) { - rotY *= 0x10000 / 360.0f; + rotY = DEG_TO_BINANG(rotY); } else if (rotY > 180) { rotY -= 360; } if (!(actorEntry->id & 0x4000)) { - rotX *= 0x10000 / 360.0f; + rotX = DEG_TO_BINANG(rotX); } else if (rotX > 180) { rotX -= 360; } if (!(actorEntry->id & 0x2000)) { - rotZ *= 0x10000 / 360.0f; + rotZ = DEG_TO_BINANG(rotZ); } else if (rotZ > 180) { rotZ -= 360; } @@ -3497,16 +3537,16 @@ s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { return arg0[0]; } -void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList) { - EnPart* part; - Actor* spawnedPart; - MtxF* currentMatrix; - +void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 partParams, Gfx** dList) { if (*dList != NULL) { - currentMatrix = Matrix_GetCurrent(); + EnPart* part; + Actor* spawnedPart; + MtxF* currentMatrix = Matrix_GetCurrent(); + spawnedPart = Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, currentMatrix->mf[3][0], - currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); + currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, partParams); + if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; @@ -3575,21 +3615,29 @@ void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 act } // Damage flags for EnArrow -s32 D_801AEDB0[] = { - 0x800, 0x20, 0x20, 0x800, 0x1000, 0x2000, 0x1, 0x10000, 0x1, +u32 sArrowDmgFlags[] = { + DMG_FIRE_ARROW, // ENARROW_0 + DMG_NORMAL_ARROW, // ENARROW_1 + DMG_NORMAL_ARROW, // ENARROW_2 + DMG_FIRE_ARROW, // ENARROW_3 + DMG_ICE_ARROW, // ENARROW_4 + DMG_LIGHT_ARROW, // ENARROW_5 + DMG_DEKU_NUT, // ENARROW_6 + DMG_DEKU_BUBBLE, // ENARROW_7 + DMG_DEKU_NUT, // ENARROW_8 }; -s32 func_800BC188(s32 index) { - if ((index < 0) || (index >= ARRAY_COUNT(D_801AEDB0))) { +u32 Actor_GetArrowDmgFlags(s32 params) { + if ((params < 0) || (params >= ARRAY_COUNT(sArrowDmgFlags))) { return 0; } - return D_801AEDB0[index]; + return sArrowDmgFlags[params]; } -s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { - if ((arg3 > 0.0f) && (Actor_WorldDistXYZToActor(arg1, actor) < ((arg3 * 2.5f) + arg2))) { - s16 temp_v1 = BINANG_SUB(Actor_WorldYawTowardActor(arg1, actor), arg1->world.rot.y); +s32 func_800BC1B4(Actor* actor, Actor* projectile, f32 distance, f32 speed) { + if ((speed > 0.0f) && (Actor_WorldDistXYZToActor(projectile, actor) < ((speed * 2.5f) + distance))) { + s16 temp_v1 = BINANG_SUB(Actor_WorldYawTowardActor(projectile, actor), projectile->world.rot.y); if (ABS_ALT(temp_v1) < 0x1400) { return true; @@ -3599,36 +3647,36 @@ s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) { return false; } -Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) { +Actor* func_800BC270(PlayState* play, Actor* actor, f32 distance, u32 dmgFlags) { Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; while (itemAction != NULL) { - if (((itemAction->id == ACTOR_ARMS_HOOK) && (arg3 & 0x80)) || - ((itemAction->id == ACTOR_EN_BOOM) && (arg3 & 0x10)) || - ((itemAction->id == ACTOR_EN_ARROW) && (func_800BC188(itemAction->params) & arg3))) { - f32 speedXZ; + if (((itemAction->id == ACTOR_ARMS_HOOK) && (dmgFlags & DMG_HOOKSHOT)) || + ((itemAction->id == ACTOR_EN_BOOM) && (dmgFlags & DMG_ZORA_BOOMERANG)) || + ((itemAction->id == ACTOR_EN_ARROW) && (Actor_GetArrowDmgFlags(itemAction->params) & dmgFlags))) { + f32 speed; if ((itemAction->speed <= 0.0f) && (GET_PLAYER(play)->unk_D57 != 0)) { if (itemAction->id == ACTOR_ARMS_HOOK) { - speedXZ = 20.0f; + speed = 20.0f; } else if (itemAction->id == ACTOR_EN_BOOM) { - speedXZ = 12.0f; + speed = 12.0f; } else { - s32 temp_v0_3 = func_800BC188(itemAction->params); + u32 arrowDmgFlags = Actor_GetArrowDmgFlags(itemAction->params); - if (temp_v0_3 == 1) { - speedXZ = 80.0f; - } else if (temp_v0_3 == 0x10000) { - speedXZ = 60.0f; + if (arrowDmgFlags == DMG_DEKU_NUT) { + speed = 80.0f; + } else if (arrowDmgFlags == DMG_DEKU_BUBBLE) { + speed = 60.0f; } else { - speedXZ = 150.0f; + speed = 150.0f; } } } else { - speedXZ = itemAction->speed; + speed = itemAction->speed; } - if (func_800BC1B4(actor, itemAction, arg2, speedXZ)) { + if (func_800BC1B4(actor, itemAction, distance, speed)) { break; } } @@ -3639,13 +3687,13 @@ Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) { return itemAction; } -Actor* func_800BC444(PlayState* play, Actor* actor, f32 arg2) { +Actor* func_800BC444(PlayState* play, Actor* actor, f32 distance) { Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; while (explosive != NULL) { if (((explosive->id == ACTOR_EN_BOM) || (explosive->id == ACTOR_EN_BOM_CHU) || (explosive->id == ACTOR_EN_BOMBF))) { - if (func_800BC1B4(actor, explosive, arg2, explosive->speed)) { + if (func_800BC1B4(actor, explosive, distance, explosive->speed)) { break; } } @@ -3714,29 +3762,30 @@ s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { return false; } -void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { - MtxF sp58; - f32 sp54; - Vec3f sp48; - CollisionPoly* sp44; +void func_800BC620(Vec3f* pos, Vec3f* scale, u8 alpha, PlayState* play) { + MtxF mf; + f32 yIntersect; + Vec3f adjustedPos; + CollisionPoly* poly; OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha); - sp48.x = arg0->x; - sp48.y = arg0->y + 1.0f; - sp48.z = arg0->z; + adjustedPos.x = pos->x; + adjustedPos.y = pos->y + 1.0f; + adjustedPos.z = pos->z; - sp54 = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp44, &sp48); - if (sp44 != NULL) { - func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); - Matrix_Put(&sp58); + yIntersect = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &poly, &adjustedPos); + if (poly != NULL) { + func_800C0094(poly, pos->x, yIntersect, pos->z, &mf); + Matrix_Put(&mf); } else { - Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); } - Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); + + Matrix_Scale(scale->x, 1.0f, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); @@ -3841,12 +3890,12 @@ void Actor_SpawnShieldParticlesMetal(PlayState* play, Vec3f* pos) { CollisionCheck_SpawnShieldParticlesMetal(play, pos); } -void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration) { - if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { +void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 bufFlag, u16 duration) { + if ((colorFlag == COLORFILTER_COLORFLAG_GRAY) && !(colorIntensityMax & COLORFILTER_INTENSITY_FLAG)) { Actor_PlaySfx(actor, NA_SE_EN_LIGHT_ARROW_HIT); } - actor->colorFilterParams = colorFlag | xluFlag | ((colorIntensityMax & 0xF8) << 5) | duration; + actor->colorFilterParams = colorFlag | bufFlag | ((colorIntensityMax & 0xF8) << 5) | duration; actor->colorFilterTimer = duration; } @@ -4151,7 +4200,7 @@ void Npc_TrackPointWithLimits(Actor* actor, NpcInteractInfo* interactInfo, s16 m } temp = CLAMP(pitchTowardsTarget, minHeadPitch, (s16)(u16)maxHeadPitch); - Math_SmoothStepToS(&interactInfo->headRot.x, temp, 6, 0x7D0, 1); + Math_SmoothStepToS(&interactInfo->headRot.x, temp, 6, 2000, 1); torsoPitch = pitchTowardsTarget - interactInfo->headRot.x; @@ -4452,15 +4501,15 @@ void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo) { ColliderInfo* acHitInfo = colInfo->acHitInfo; if (acHitInfo == NULL) { - actor->dropFlag = 0; - } else if (acHitInfo->toucher.dmgFlags & 0x800) { // DMG_FIRE_ARROW - actor->dropFlag = 1; - } else if (acHitInfo->toucher.dmgFlags & 0x1000) { // DMG_ICE_ARROW - actor->dropFlag = 2; - } else if (acHitInfo->toucher.dmgFlags & 0x2000) { // DMG_LIGHT_ARROW - actor->dropFlag = 0x20; + actor->dropFlag = DROPFLAG_NONE; + } else if (acHitInfo->toucher.dmgFlags & DMG_FIRE_ARROW) { + actor->dropFlag = DROPFLAG_1; + } else if (acHitInfo->toucher.dmgFlags & DMG_ICE_ARROW) { + actor->dropFlag = DROPFLAG_2; + } else if (acHitInfo->toucher.dmgFlags & DMG_LIGHT_ARROW) { + actor->dropFlag = DROPFLAG_20; } else { - actor->dropFlag = 0; + actor->dropFlag = DROPFLAG_NONE; } } @@ -4470,23 +4519,23 @@ void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { ColliderInfo* acHitInfo; s32 flag; - actor->dropFlag = 0; + actor->dropFlag = DROPFLAG_NONE; for (i = jntSphere->count - 1; i >= 0; i--) { jntElement = &jntSphere->elements[i]; acHitInfo = jntElement->info.acHitInfo; if (acHitInfo == NULL) { - flag = 0; + flag = DROPFLAG_NONE; } else { s32 dmgFlags = acHitInfo->toucher.dmgFlags; - if (dmgFlags & 0x800) { - flag = 1; - } else if (dmgFlags & 0x1000) { - flag = 2; + if (dmgFlags & DMG_FIRE_ARROW) { + flag = DROPFLAG_1; + } else if (dmgFlags & DMG_ICE_ARROW) { + flag = DROPFLAG_2; } else { - flag = (dmgFlags & 0x2000) ? 0x20 : 0; + flag = (dmgFlags & DMG_LIGHT_ARROW) ? DROPFLAG_20 : DROPFLAG_NONE; } } @@ -4494,19 +4543,19 @@ void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSphere) { } } -void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { +void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* dst, s32 arg3) { f32 xDiff = arg1->x - arg0->x; f32 zDiff = arg1->z - arg0->z; f32 yDiff = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y); - arg2->y = Math_Atan2S_XY(zDiff, xDiff); - arg2->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); + dst->y = Math_Atan2S_XY(zDiff, xDiff); + dst->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); } void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { - f32 sp44; - f32 sp40; - f32 sp3C; + f32 floorPolyNormalX; + f32 floorPolyNormalY; + f32 floorPolyNormalZ; f32 sp38; f32 sp34; f32 sp30; @@ -4516,17 +4565,17 @@ void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { if (actor->floorPoly != NULL) { CollisionPoly* floorPoly = actor->floorPoly; - sp44 = COLPOLY_GET_NORMAL(floorPoly->normal.x); - sp40 = COLPOLY_GET_NORMAL(floorPoly->normal.y); - sp3C = COLPOLY_GET_NORMAL(floorPoly->normal.z); + floorPolyNormalX = COLPOLY_GET_NORMAL(floorPoly->normal.x); + floorPolyNormalY = COLPOLY_GET_NORMAL(floorPoly->normal.y); + floorPolyNormalZ = COLPOLY_GET_NORMAL(floorPoly->normal.z); sp38 = Math_SinS(angle); sp34 = Math_CosS(angle); - arg2->x = (s16)-Math_Atan2S((-(sp44 * sp38) - (sp3C * sp34)) * sp40, 1.0f); + arg2->x = (s16)-Math_Atan2S((-(floorPolyNormalX * sp38) - (floorPolyNormalZ * sp34)) * floorPolyNormalY, 1.0f); sp2C = Math_SinS(angle - 0x3FF7); sp30 = Math_CosS(angle - 0x3FF7); - arg2->z = (s16)-Math_Atan2S((-(sp44 * sp2C) - (sp3C * sp30)) * sp40, 1.0f); + arg2->z = (s16)-Math_Atan2S((-(floorPolyNormalX * sp2C) - (floorPolyNormalZ * sp30)) * floorPolyNormalY, 1.0f); } } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 4423a184d..3d78f00df 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -299,7 +299,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { } if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 50.0f, 20.0f); } this->actionFunc = func_800A6A40; @@ -456,7 +456,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { if (this->getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, this->getItemId, 50.0f, 80.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk152++; } else { this->getItemId = GI_NONE; @@ -646,7 +646,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { if (getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { - Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f); + Actor_OfferGetItem(&this->actor, play, getItemId, 50.0f, 20.0f); } } @@ -1128,16 +1128,17 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP if (fromActor != NULL) { dropFlag = fromActor->dropFlag; - if (dropFlag != 0) { - if (fromActor->dropFlag & 1) { + + if (dropFlag != DROPFLAG_NONE) { + if (fromActor->dropFlag & DROPFLAG_1) { params = 0x10; dropId = ITEM00_ARROWS_30; dropQuantity = 1; - } else if (fromActor->dropFlag & 2) { + } else if (fromActor->dropFlag & DROPFLAG_2) { params = 0x10; dropId = ITEM00_RECOVERY_HEART; dropQuantity = 1; - } else if (fromActor->dropFlag & 0x20) { + } else if (fromActor->dropFlag & DROPFLAG_20) { dropId = ITEM00_RUPEE_PURPLE; dropQuantity = 1; } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 5be9dca41..1f431d0e4 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -171,7 +171,7 @@ void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) { play->numSetupActors = cmd->actorList.num; play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); - play->actorCtx.unkC = 0; + play->actorCtx.halfDaysBit = 0; } // SceneTableEntry Header Command 0x02: List of camera data for actor cutscenes @@ -277,7 +277,7 @@ void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) { } play->objectCtx.num = i; - func_800BA6FC(play, &play->actorCtx); + Actor_KillAllWithMissingObject(play, &play->actorCtx); continue; } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index e4138269f..6650f41a7 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -828,7 +828,7 @@ s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 it case 1: yRange = fabsf(actor->playerHeightRel) + 1.0f; xzRange = actor->xzDistToPlayer + 1.0f; - ret = Actor_PickUp(actor, play, itemId, xzRange, yRange); + ret = Actor_OfferGetItem(actor, play, itemId, xzRange, yRange); break; case 2: |
