summaryrefslogtreecommitdiff
path: root/mm/2s2h/Rando/ActorBehavior/EnGk.cpp
blob: b1df69895e3749cb8e27497c13534398ec5b14a0 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "ActorBehavior.h"
#include <libultraship/bridge/consolevariablebridge.h>

extern "C" {
#include "variables.h"
#include "overlays/actors/ovl_En_Gk/z_en_gk.h"

void Player_StartTalking(PlayState* play, Actor* actor);
}

void Rando::ActorBehavior::InitEnGKBehavior() {
    COND_VB_SHOULD(VB_GIVE_ITEM_FROM_OFFER, IS_RANDO, {
        GetItemId* item = va_arg(args, GetItemId*);
        Actor* actor = va_arg(args, Actor*);
        Player* player = GET_PLAYER(gPlayState);

        switch (actor->id) {
            case ACTOR_EN_GK:
                // In either case here, WEEKEVENTREG_RECEIVED_GORON_RACE_BOTTLE will be set and trigger the rando
                // check to be queued.

                // If they have an empty bottle, force item to gold dust refill and let vanilla item get continue
                if (Inventory_HasEmptyBottle()) {
                    *item = GI_GOLD_DUST_2;
                    return;
                }

                // Otherwise bypass item get entirely
                *should = false;
                actor->parent = &player->actor;
                player->talkActor = actor;
                player->talkActorDistance = actor->xzDistToPlayer;
                player->exchangeItemAction = PLAYER_IA_MINUS1;
                Player_StartTalking(gPlayState, actor);
                break;
        }
    });

    COND_VB_SHOULD(VB_GIVE_ITEM_FROM_GK_LULLABY, IS_RANDO, {
        // Override vanilla cutscene skip item grant behavior to use rando queue instead
        *should = false;
    });

    COND_VB_SHOULD(VB_START_CUTSCENE, IS_RANDO, {
        s16* csId = va_arg(args, s16*);
        Actor* actor = va_arg(args, Actor*);

        if (*csId != 9 || actor == NULL || actor->id != ACTOR_EN_GK) {
            return;
        }

        *should = false;

        SET_WEEKEVENTREG(WEEKEVENTREG_24_80); // Ensure Goron Elder check is available
        if (!RANDO_SAVE_CHECKS[RC_GORON_SHRINE_FULL_LULLABY].cycleObtained) {
            RANDO_SAVE_CHECKS[RC_GORON_SHRINE_FULL_LULLABY].eligible = true;
        }
    });

    // Played Full Lullaby for Baby Goron
    COND_HOOK(OnSceneFlagSet, IS_RANDO, [](s16 sceneId, FlagType flagType, u32 flag) {
        if (sceneId == SCENE_16GORON_HOUSE && flagType == FLAG_CYCL_SCENE_SWITCH && flag == 20) {
            SET_WEEKEVENTREG(WEEKEVENTREG_24_80); // Ensure Goron Elder check is available
        }
    });
}