mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 22:44:30 +00:00
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
This commit is contained in:
parent
c11ce9c994
commit
3d1ee33d7b
74 changed files with 297 additions and 266 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,10 +204,10 @@ void EnAObj_WaitTalk(EnAObj* this, PlayState* play) {
|
|||
relYawTowardsPlayer = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y;
|
||||
if (ABS(relYawTowardsPlayer) < 0x2800 ||
|
||||
(this->dyna.actor.params == A_OBJ_SIGNPOST_ARROW && ABS(relYawTowardsPlayer) > 0x5800)) {
|
||||
if (Actor_ProcessTalkRequest(&this->dyna.actor, play)) {
|
||||
if (Actor_TalkOfferAccepted(&this->dyna.actor, play)) {
|
||||
EnAObj_SetupAction(this, EnAObj_WaitFinishedTalking);
|
||||
} else {
|
||||
func_8002F2F4(&this->dyna.actor, play);
|
||||
Actor_OfferTalkNearColChkInfoCylinder(&this->dyna.actor, play);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue