summaryrefslogtreecommitdiff
path: root/src/code/code_800E8EA0.c
blob: ca2e9e841f96c32c3f8699db9fec9517508d6c64 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "global.h"

void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId) {
    func_80151938(globalCtx, textId);
    actor->textId = textId;
}

s32 nop_800E8ED0(UNK_TYPE4 param_1) {
    return 0;
}

void nop_800E8EE0(UNK_TYPE4 param_1) {
}

s32 nop_800E8EEC(UNK_TYPE4 param_1) {
    return 0;
}

void nop_800E8EFC(UNK_TYPE4 param_1) {
}

s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2) {
    Math_SmoothStepToS(&param_1->y, 0, 6, 6200, 100);
    Math_SmoothStepToS(&param_1->x, 0, 6, 6200, 100);
    Math_SmoothStepToS(&param_2->y, 0, 6, 6200, 100);
    Math_SmoothStepToS(&param_2->x, 0, 6, 6200, 100);
    return 1;
}

s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4) {
    s16 targetPitch;
    s16 targetYaw;
    s16 yawDiffFromTarget;

    targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, param_2);
    targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, param_2) - actor->world.rot.y;

    Math_SmoothStepToS(&param_3->x, targetPitch, 6, 2000, 1);
    param_3->x = CLAMP(param_3->x, -6000, 6000);

    yawDiffFromTarget = Math_SmoothStepToS(&param_3->y, targetYaw, 6, 2000, 1);
    param_3->y = CLAMP(param_3->y, -8000, 8000);

    if (yawDiffFromTarget != 0) {
        if (ABS_ALT(param_3->y) < 8000) {
            return 0;
        }
    }

    Math_SmoothStepToS(&param_4->y, targetYaw - param_3->y, 4, 2000, 1);
    param_4->y = CLAMP(param_4->y, -12000, 12000);

    return 1;
}

s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5) {
    Player* player = PLAYER;
    s16 sVar3;
    Vec3f local_14;
    s16 sVar3A;

    actor->focus.pos = actor->world.pos;
    actor->focus.pos.y += param_5;

    if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) {
        sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y;
        sVar3A = ABS_ALT(sVar3);
        if (sVar3A >= 0x4300) {
            func_800E8F08(param_3, param_4);
            return 0;
        }
    }

    if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) {
        local_14 = globalCtx->view.eye;
    } else {
        local_14 = player->actor.focus.pos;
    }

    func_800E8FA4(actor, &local_14, param_3, param_4);

    return 1;
}

s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) {
    Player* player = PLAYER;
    s16 sVar3;
    Vec3f local_14;
    s16 sVar3A;

    actor->focus.pos = param_5;

    if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) {
        sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y;
        sVar3A = ABS_ALT(sVar3);
        if (sVar3A >= 0x4300) {
            func_800E8F08(param_3, param_4);
            return 0;
        }
    }

    if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) {
        local_14 = globalCtx->view.eye;
    } else {
        local_14 = player->actor.focus.pos;
    }

    func_800E8FA4(actor, &local_14, param_3, param_4);

    return 1;
}