summaryrefslogtreecommitdiff
path: root/mm/2s2h/Rando/ActorBehavior/EnSyatekiMan.cpp
blob: d106ddc2ced89bf956a96af7755304634935d2b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ActorBehavior.h"
#include <libultraship/bridge/consolevariablebridge.h>

extern "C" {
#include "variables.h"
void Player_StartTalking(PlayState* play, Actor* actor);
}

// This is the same block found for non-scripted actors in OfferGetItem.cpp
void talkToShootingGalleryNpc(Player* player, Actor* actor) {
    player->talkActor = actor;
    player->talkActorDistance = actor->xzDistToPlayer;
    player->exchangeItemAction = PLAYER_IA_MINUS1;
    Player_StartTalking(gPlayState, actor);
}

void Rando::ActorBehavior::InitEnSyatekiManBehavior() {
    COND_VB_SHOULD(VB_GIVE_ITEM_FROM_OFFER, IS_RANDO, {
        GetItemId* item = va_arg(args, GetItemId*);
        Actor* actor = va_arg(args, Actor*);
        // Only hijack the quivers and Heart Pieces; let the rupee rewards remain as normal
        if (actor->id == ACTOR_EN_SYATEKI_MAN && *item > GI_RUPEE_HUGE) {
            Player* player = GET_PLAYER(gPlayState);
            if (gPlayState->sceneId == SCENE_SYATEKI_MIZU) { // Town Shooting Gallery
                if (CURRENT_DAY == 3) {
                    // On the third day, there is additional dialog after the reward
                    talkToShootingGalleryNpc(player, actor);
                    actor->flags |= ACTOR_FLAG_TALK;
                } else {
                    /*
                     * On the other two days, there is no dialog after the reward. The simplest thing to make the NPC
                     * behave is to add an extra textbox. 0x3F8 is "Usually this place is packed..."
                     */
                    Message_StartTextbox(gPlayState, 0x3F8, actor);
                }
            } else if (gPlayState->sceneId == SCENE_SYATEKI_MORI) { // Swamp Shooting Gallery
                talkToShootingGalleryNpc(player, actor);
            }
            actor->parent = &player->actor;
            *should = false;
        }
    });
}