diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2022-12-12 23:23:14 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-12 21:23:14 -0500 |
| commit | c420885513db9c170dff67f81c849a58b67a0ae1 (patch) | |
| tree | 68a209a35e6aec926367a5791a90a86b14bf028a /src/code | |
| parent | 83163f4d4bb4217f0d973328afe92e7f50d01396 (diff) | |
`z_actor` documentation pass (#1445)
* Actor_Offer* and Actor_SetClosestSecretDistance
* color filter stuff
* KillAll
* format
* comment
* Update src/code/z_actor.c
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* review
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* format
* COLORFILTER_INTENSITY_FLAG
* Remove -
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* yeet COLORFILTER_GET_XLUFLAG
* bug
* frug
* Undo Actor_KillAllFromUnloadedRooms
* update Actor_OfferGetItem comment
* Update Actor_OfferGetItem description
* diving
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_actor.c | 73 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 6 | ||||
| -rw-r--r-- | src/code/z_scene.c | 2 |
3 files changed, 55 insertions, 26 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 8197e5f18..6f6bd2972 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1570,7 +1570,30 @@ u32 Actor_HasParent(Actor* actor, PlayState* play) { } } -s32 func_8002F434(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { +/** + * 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. + * + * 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_OfferGetItem(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_12 | PLAYER_STATE1_13 | PLAYER_STATE1_14 | @@ -1596,12 +1619,12 @@ s32 func_8002F434(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 return false; } -void func_8002F554(Actor* actor, PlayState* play, s32 getItemId) { - func_8002F434(actor, play, getItemId, 50.0f, 10.0f); +s32 Actor_OfferGetItemNearby(Actor* actor, PlayState* play, s32 getItemId) { + return Actor_OfferGetItem(actor, play, getItemId, 50.0f, 10.0f); } -void func_8002F580(Actor* actor, PlayState* play) { - func_8002F554(actor, play, GI_NONE); +s32 Actor_OfferCarry(Actor* actor, PlayState* play) { + return Actor_OfferGetItemNearby(actor, play, GI_NONE); } u32 Actor_HasNoParent(Actor* actor, PlayState* play) { @@ -1627,11 +1650,11 @@ void func_8002F5C4(Actor* actorA, Actor* actorB, PlayState* play) { actorA->parent = NULL; } -void func_8002F5F0(Actor* actor, PlayState* play) { +void Actor_SetClosestSecretDistance(Actor* actor, PlayState* play) { Player* player = GET_PLAYER(play); - if (actor->xyzDistToPlayerSq < player->unk_6A4) { - player->unk_6A4 = actor->xyzDistToPlayerSq; + if (actor->xyzDistToPlayerSq < player->closestSecretDistSq) { + player->closestSecretDistSq = actor->xyzDistToPlayerSq; } } @@ -2218,25 +2241,25 @@ void Actor_Draw(PlayState* play, Actor* actor) { if (actor->colorFilterTimer != 0) { Color_RGBA8 color = { 0, 0, 0, 255 }; - if (actor->colorFilterParams & 0x8000) { - color.r = color.g = color.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; - } else if (actor->colorFilterParams & 0x4000) { - color.r = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + if (actor->colorFilterParams & COLORFILTER_COLORFLAG_GRAY) { + color.r = color.g = color.b = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; + } else if (actor->colorFilterParams & COLORFILTER_COLORFLAG_RED) { + color.r = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; } else { - color.b = ((actor->colorFilterParams & 0x1F00) >> 5) | 7; + color.b = COLORFILTER_GET_COLORINTENSITY(actor->colorFilterParams) | 7; } - if (actor->colorFilterParams & 0x2000) { - func_80026860(play, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + if (actor->colorFilterParams & COLORFILTER_BUFFLAG_XLU) { + func_80026860(play, &color, actor->colorFilterTimer, COLORFILTER_GET_DURATION(actor->colorFilterParams)); } else { - func_80026400(play, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_80026400(play, &color, 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_80026A6C(play); } else { func_80026608(play); @@ -2500,7 +2523,10 @@ void func_800315AC(PlayState* play, ActorContext* actorCtx) { CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6563); } -void func_80031A28(PlayState* play, ActorContext* actorCtx) { +/** + * Kill every actor which depends on an object that is not loaded. + */ +void Actor_KillAllWithMissingObject(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -2530,6 +2556,9 @@ void Actor_FreezeAllEnemies(PlayState* play, ActorContext* actorCtx, s32 duratio } } +/** + * Kill actors on room change and update flags accordingly + */ void func_80031B14(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; @@ -3633,12 +3662,12 @@ void func_8003424C(PlayState* play, Vec3f* arg1) { CollisionCheck_SpawnShieldParticlesMetal(play, arg1); } -void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 xluFlag, s16 duration) { - if ((colorFlag == 0x8000) && !(colorIntensityMax & 0x8000)) { +void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 bufFlag, s16 duration) { + if ((colorFlag == COLORFILTER_COLORFLAG_GRAY) && !(colorIntensityMax & COLORFILTER_INTENSITY_FLAG)) { Audio_PlayActorSfx2(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; } @@ -4061,7 +4090,7 @@ s32 func_80035124(Actor* actor, PlayState* play) { ret = 1; } else { actor->shape.rot.x = actor->shape.rot.z = 0; - func_8002F580(actor, play); + Actor_OfferCarry(actor, play); } break; case 1: diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 9a6ee6e09..f1ad80087 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -351,7 +351,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { } if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { - func_8002F554(&this->actor, play, getItemId); + Actor_OfferGetItemNearby(&this->actor, play, getItemId); } EnItem00_SetupAction(this, EnItem00_Collected); @@ -498,7 +498,7 @@ void EnItem00_Collected(EnItem00* this, PlayState* play) { if (this->getItemId != GI_NONE) { if (!Actor_HasParent(&this->actor, play)) { - func_8002F434(&this->actor, play, this->getItemId, 50.0f, 80.0f); + Actor_OfferGetItem(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->despawnTimer++; } else { this->getItemId = GI_NONE; @@ -696,7 +696,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { params = &this->actor.params; if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { - func_8002F554(&this->actor, play, getItemId); + Actor_OfferGetItemNearby(&this->actor, play, getItemId); } switch (*params) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 8dde9ac0c..0deabe136 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -269,7 +269,7 @@ void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { status2++; } play->objectCtx.num = i; - func_80031A28(play, &play->actorCtx); + Actor_KillAllWithMissingObject(play, &play->actorCtx); continue; } |
