summaryrefslogtreecommitdiff
path: root/mm/2s2h/Rando/ActorBehavior/ItemGetBehavior.cpp
blob: 3a6a16f577eef338bc903ee7944df218a830a037 (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
#include "ActorBehavior.h"

extern "C" {
#include "overlays/actors/ovl_En_Dno/z_en_dno.h"
#include "overlays/actors/ovl_Obj_Bean/z_obj_bean.h"
void func_809388A8(ObjBean* objBean, PlayState* play);
void func_80A730A0(EnDno* enDno, PlayState* play);
}

#define PLAYER_IN_GET_ITEM_STATE(player) ((player->stateFlags1 & PLAYER_STATE1_400) || player->actor.freezeTimer)

void Rando::ActorBehavior::InitItemGetBehavior() {
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_OBJ_BEAN, IS_RANDO, [](Actor* actor, bool* should) {
        ObjBean* objBean = (ObjBean*)actor;
        // Bean is in moving state, and player is in Get Item state
        Player* player = GET_PLAYER(gPlayState);
        if (objBean->actionFunc == func_809388A8 && PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });

    // Deku Butler
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_EN_DNO, IS_RANDO, [](Actor* actor, bool* should) {
        EnDno* enDno = (EnDno*)actor;
        // Deku Butler is in race state, and player is in Get Item state
        Player* player = GET_PLAYER(gPlayState);
        if (enDno->actionFunc == func_80A730A0 && PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });

    // Deku Butler race moving platform
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_OBJ_DANPEILIFT, IS_RANDO, [](Actor* actor, bool* should) {
        Player* player = GET_PLAYER(gPlayState);
        if (PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });

    // Deku Butler race door
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_BG_CRACE_MOVEBG, IS_RANDO, [](Actor* actor, bool* should) {
        Player* player = GET_PLAYER(gPlayState);
        if (PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });

    // Deku Scrub Playground platform
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_OBJ_LUPYGAMELIFT, IS_RANDO, [](Actor* actor, bool* should) {
        Player* player = GET_PLAYER(gPlayState);
        if (PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });

    // Deku Palace moving platform
    COND_ID_HOOK(ShouldActorUpdate, ACTOR_OBJ_RAILLIFT, IS_RANDO, [](Actor* actor, bool* should) {
        Player* player = GET_PLAYER(gPlayState);
        if (PLAYER_IN_GET_ITEM_STATE(player)) {
            *should = false;
        }
    });
}