diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2023-11-20 03:11:59 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-19 11:11:59 -0500 |
| commit | 3d1ee33d7b7799cd84c3bbe1fc8d4f69ec3f58d9 (patch) | |
| tree | 21178a693db198c0ca04a3fe3d0061c3c6915de5 /src/code/z_actor.c | |
| parent | c11ce9c99473be1ff1eba565e7eae920612586c3 (diff) | |
Document Actor "OfferTalk" (#1567)
* OfferTalk
* rm comment
* exch to offer in comment
* reword again
* Partial PR Review
* Actor_AcknowledgeTalking
* Actor_TalkOfferAccepted
* PR Review
* rm part of comment
* rm comment
Diffstat (limited to 'src/code/z_actor.c')
| -rw-r--r-- | src/code/z_actor.c | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index bbbb22c36..e55fc95b0 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1549,22 +1549,39 @@ s32 func_8002F0C8(Actor* actor, Player* player, s32 flag) { return false; } -u32 Actor_ProcessTalkRequest(Actor* actor, PlayState* play) { - if (actor->flags & ACTOR_FLAG_8) { - actor->flags &= ~ACTOR_FLAG_8; +/** + * When a given talk offer is accepted, Player will set `ACTOR_FLAG_TALK` for that actor. + * This function serves to acknowledge that the offer was accepted by Player, and notifies the actor + * that it should proceed with its own internal processes for handling dialogue. + * + * @return true if the talk offer was accepted, false otherwise + */ +s32 Actor_TalkOfferAccepted(Actor* actor, PlayState* play) { + if (actor->flags & ACTOR_FLAG_TALK) { + actor->flags &= ~ACTOR_FLAG_TALK; return true; } return false; } -s32 func_8002F1C4(Actor* actor, PlayState* play, f32 arg2, f32 arg3, u32 exchangeItemId) { +/** + * This function covers offering the ability to talk with the player. + * Passing an exchangeItemId (see `ExchangeItemID`) allows the player to also use the item to initiate the + * conversation. + * + * This function carries a talk exchange offer to the player actor if context allows it (e.g. the player is in range + * and not busy with certain things). + * + * @return true If the player actor is capable of accepting the offer. + */ +s32 Actor_OfferTalkExchange(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, u32 exchangeItemId) { Player* player = GET_PLAYER(play); - if ((player->actor.flags & ACTOR_FLAG_8) || ((exchangeItemId != EXCH_ITEM_NONE) && Player_InCsMode(play)) || + if ((player->actor.flags & ACTOR_FLAG_TALK) || ((exchangeItemId != EXCH_ITEM_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && - ((arg3 < fabsf(actor->yDistToPlayer)) || (player->targetActorDistance < actor->xzDistToPlayer) || - (arg2 < actor->xzDistToPlayer)))) { + ((yRange < fabsf(actor->yDistToPlayer)) || (player->targetActorDistance < actor->xzDistToPlayer) || + (xzRange < actor->xzDistToPlayer)))) { return false; } @@ -1575,18 +1592,28 @@ s32 func_8002F1C4(Actor* actor, PlayState* play, f32 arg2, f32 arg3, u32 exchang return true; } -s32 func_8002F298(Actor* actor, PlayState* play, f32 arg2, u32 exchangeItemId) { - return func_8002F1C4(actor, play, arg2, arg2, exchangeItemId); +/** + * Offers a talk exchange request within an equilateral cylinder with the radius specified. + */ +s32 Actor_OfferTalkExchangeEquiCylinder(Actor* actor, PlayState* play, f32 radius, u32 exchangeItemId) { + return Actor_OfferTalkExchange(actor, play, radius, radius, exchangeItemId); } -s32 func_8002F2CC(Actor* actor, PlayState* play, f32 arg2) { - return func_8002F298(actor, play, arg2, EXCH_ITEM_NONE); +/** + * Offers a talk request within an equilateral cylinder with the radius specified. + */ +s32 Actor_OfferTalk(Actor* actor, PlayState* play, f32 radius) { + return Actor_OfferTalkExchangeEquiCylinder(actor, play, radius, EXCH_ITEM_NONE); } -s32 func_8002F2F4(Actor* actor, PlayState* play) { - f32 var1 = 50.0f + actor->colChkInfo.cylRadius; +/** + * Offers a talk request within an equilateral cylinder whose radius is determined by the actor's collision check + * cylinder's radius. + */ +s32 Actor_OfferTalkNearColChkInfoCylinder(Actor* actor, PlayState* play) { + f32 cylRadius = 50.0f + actor->colChkInfo.cylRadius; - return func_8002F2CC(actor, play, var1); + return Actor_OfferTalk(actor, play, cylRadius); } u32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { @@ -3776,7 +3803,7 @@ s32 Npc_UpdateTalking(PlayState* play, Actor* actor, s16* talkState, f32 interac s16 x; s16 y; - if (Actor_ProcessTalkRequest(actor, play)) { + if (Actor_TalkOfferAccepted(actor, play)) { *talkState = NPC_TALK_STATE_TALKING; return true; } @@ -3792,7 +3819,7 @@ s32 Npc_UpdateTalking(PlayState* play, Actor* actor, s16* talkState, f32 interac return false; } - if (!func_8002F2CC(actor, play, interactRange)) { + if (!Actor_OfferTalk(actor, play, interactRange)) { return false; } @@ -5674,7 +5701,7 @@ s32 func_80037D98(PlayState* play, Actor* actor, s16 arg2, s32* arg3) { s16 sp2A; s16 abs_var; - if (Actor_ProcessTalkRequest(actor, play)) { + if (Actor_TalkOfferAccepted(actor, play)) { *arg3 = 1; return true; } @@ -5704,11 +5731,11 @@ s32 func_80037D98(PlayState* play, Actor* actor, s16 arg2, s32* arg3) { } if (actor->xyzDistToPlayerSq <= SQ(80.0f)) { - if (func_8002F2CC(actor, play, 80.0f)) { + if (Actor_OfferTalk(actor, play, 80.0f)) { actor->textId = func_80037C30(play, arg2); } } else { - if (func_8002F2F4(actor, play)) { + if (Actor_OfferTalkNearColChkInfoCylinder(actor, play)) { actor->textId = func_80037C30(play, arg2); } } |
