summaryrefslogtreecommitdiff
path: root/src/f_op/f_op_actor.cpp
blob: 306afb480bc6b41be40b619339964c2602ab1c9b (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/**
 * f_op_actor.cpp
 * Actor base process class
 */

#include "f_op/f_op_actor.h"
#include "d/a/d_a_alink.h"
#include "d/com/d_com_inf_actor.h"
#include "d/com/d_com_static.h"
#include "d/d_demo.h"
#include "d/s/d_s_play.h"
#include "f_op/f_op_actor_tag.h"
#include "f_op/f_op_draw_tag.h"
#include "f_pc/f_pc_manager.h"

/* 80018B64-80018BD0 0134A4 006C+00 0/0 7/7 562/562 .text            __ct__10fopAc_ac_cFv */
fopAc_ac_c::fopAc_ac_c() {}

/* 80018C8C-80018CE0 0135CC 0054+00 0/0 5/5 270/270 .text            __dt__10fopAc_ac_cFv */
fopAc_ac_c::~fopAc_ac_c() {}

/* ############################################################################################## */
/* 80450CB8-80450CBC 0001B8 0004+00 2/2 0/0 0/0 .sbss            g_fopAc_type */
static int g_fopAc_type;

/* 80018CE0-80018D0C 013620 002C+00 0/0 12/12 391/391 .text            fopAc_IsActor__FPv */
s32 fopAc_IsActor(void* i_this) {
    return fpcM_IsJustType(g_fopAc_type, ((fopAc_ac_c*)i_this)->actor_type);
}

/* ############################################################################################## */
/* 80450CBC-80450CC0 0001BC 0004+00 2/2 1/1 0/0 .sbss            stopStatus__10fopAc_ac_c */
u32 fopAc_ac_c::stopStatus;

/* 80018D0C-80018DD8 01364C 00CC+00 1/0 0/0 0/0 .text            fopAc_Draw__FPv */
static int fopAc_Draw(void* i_this) {
    fopAc_ac_c* a_this = (fopAc_ac_c*)i_this;

    int ret = 1;
    if (!dComIfGp_isPauseFlag()) {
        if ((dComIfGp_event_moveApproval(a_this) == 2 ||
             (!fopAcM_checkStatus(a_this, fopAc_ac_c::stopStatus) &&
              (!fopAcM_checkStatus(a_this, fopAcStts_CULL_e) || !fopAcM_cullingCheck(a_this)))) &&
            !fopAcM_checkStatus(a_this, 0x21000000))
        {
            fopAcM_OffCondition(a_this, fopAcCnd_NODRAW_e);
            ret = fpcLf_DrawMethod((leafdraw_method_class*)a_this->sub_method, a_this);
        } else {
            fopAcM_OnCondition(a_this, fopAcCnd_NODRAW_e);
        }

        fopAcM_OffStatus(a_this, fopAcStts_NODRAW_e);
    }

    return ret;
}

/* 80018DD8-80018F78 013718 01A0+00 1/0 0/0 0/0 .text            fopAc_Execute__FPv */
static int fopAc_Execute(void* i_this) {
    fopAc_ac_c* a_this = (fopAc_ac_c*)i_this;

    int ret = 1;
    if (!dComIfGp_isPauseFlag() && dScnPly_c::isPause()) {
        if (!dComIfA_PauseCheck()) {
            daSus_c::check(a_this);
            a_this->eventInfo.beforeProc();
            s32 move = dComIfGp_event_moveApproval(i_this);
            fopAcM_OffStatus(a_this, 0x40000000);

            if (!fopAcM_checkStatus(a_this, 0x20000000) &&
                (move == 2 ||
                 (move != 0 && !fopAcM_checkStatus(a_this, fopAc_ac_c::stopStatus) &&
                  (!fopAcM_checkStatus(a_this, fopAcStts_NOEXEC_e) || !fopAcM_CheckCondition(a_this, 4)))))
            {
                fopAcM_OffCondition(a_this, fopAcCnd_NOEXEC_e);
                a_this->old = a_this->current;
                ret = fpcMtd_Execute((process_method_class*)a_this->sub_method, a_this);
            } else {
                a_this->eventInfo.suspendProc(a_this);
                fopAcM_OnCondition(a_this, fopAcCnd_NOEXEC_e);
            }

            if (fopAcM_checkStatus(a_this, 0x20) &&
                a_this->home.pos.y - a_this->current.pos.y > 5000.0f)
            {
                fopAcM_delete(a_this);
            }

            if (a_this->current.pos.y < -1e31f) {
                a_this->current.pos.y = -1e31f;
            }

            dKy_depth_dist_set(a_this);
        }
    }

    return ret;
}

/* 80018F78-80018FCC 0138B8 0054+00 1/0 0/0 0/0 .text            fopAc_IsDelete__FPv */
static int fopAc_IsDelete(void* i_this) {
    fopAc_ac_c* a_this = (fopAc_ac_c*)i_this;

    int isDelete = fpcMtd_IsDelete((process_method_class*)a_this->sub_method, a_this);
    if (isDelete == true) {
        fopDwTg_DrawQTo(&a_this->draw_tag);
    }

    return isDelete;
}

/* 80018FCC-8001904C 01390C 0080+00 1/0 0/0 0/0 .text            fopAc_Delete__FPv */
static int fopAc_Delete(void* i_this) {
    fopAc_ac_c* a_this = (fopAc_ac_c*)i_this;

    int deleted = fpcMtd_Delete((process_method_class*)a_this->sub_method, a_this);
    if (deleted == true) {
        fopAcTg_ActorQTo(&a_this->actor_tag);
        fopDwTg_DrawQTo(&a_this->draw_tag);
        fopAcM_DeleteHeap(a_this);

        dDemo_actor_c* demoAc = dDemo_c::getActor(a_this->demoActorID);
        if (demoAc != NULL) {
            demoAc->setActor(NULL);
        }
    }

    return deleted;
}

/* 8001904C-800193FC 01398C 03B0+00 1/0 0/0 0/0 .text            fopAc_Create__FPv */
static int fopAc_Create(void* i_this) {
    fopAc_ac_c* a_this = (fopAc_ac_c*)i_this;

    if (fpcM_IsFirstCreating(i_this)) {
        actor_process_profile_definition* profile =
            (actor_process_profile_definition*)fpcM_GetProfile(i_this);
        a_this->actor_type = fpcBs_MakeOfType(&g_fopAc_type);
        a_this->sub_method = (profile_method_class*)profile->sub_method;

        fopAcTg_Init(&a_this->actor_tag, a_this);
        fopAcTg_ToActorQ(&a_this->actor_tag);
        fopDwTg_Init(&a_this->draw_tag, a_this);

        a_this->actor_status = profile->status;
        a_this->group = profile->mActorType;
        a_this->cullType = profile->cullType;

        fopAcM_prm_class* append = fopAcM_GetAppend(a_this);
        if (append != NULL) {
            fopAcM_SetParam(a_this, append->mParameter);
            a_this->home.pos = append->mPos;
            a_this->home.angle = append->mAngle;
            a_this->shape_angle = append->mAngle;
            a_this->parentActorID = append->mParentPId;
            a_this->subtype = append->mSubtype;
            a_this->scale.set(append->mScale[0] * 0.1f, append->mScale[1] * 0.1f,
                              append->mScale[2] * 0.1f);
            a_this->setID = append->mEnemyNo;
            a_this->home.roomNo = append->mRoomNo;
        }

        a_this->old = a_this->home;
        a_this->current = a_this->home;
        a_this->eyePos = a_this->home.pos;
        a_this->maxFallSpeed = -100.0f;
        a_this->attention_info.distances[fopAc_attn_LOCK_e] = 1;
        a_this->attention_info.distances[fopAc_attn_TALK_e] = 2;
        a_this->attention_info.distances[fopAc_attn_BATTLE_e] = 3;
        a_this->attention_info.distances[fopAc_attn_SPEAK_e] = 5;
        a_this->attention_info.distances[fopAc_attn_CARRY_e] = 6;
        a_this->attention_info.distances[fopAc_attn_ETC_e] = 14;
        a_this->attention_info.distances[fopAc_attn_DOOR_e] = 15;
        a_this->attention_info.distances[fopAc_attn_JUEL_e] = 15;
        a_this->attention_info.distances[fopAc_attn_CHECK_e] = 51;
        a_this->attention_info.position = a_this->home.pos;
        a_this->attention_info.field_0xa = 30;
        dKy_tevstr_init(&a_this->tevStr, a_this->home.roomNo, -1);

        int roomNo = dComIfGp_roomControl_getStayNo();
        if (roomNo >= 0) {
            dComIfGp_roomControl_getStatusRoomDt(roomNo)->mRoomDt.getFileListInfo();
        }

        dStage_FileList_dt_c* filelist = NULL;
        if (a_this->home.roomNo >= 0) {
            filelist =
                dComIfGp_roomControl_getStatusRoomDt(a_this->home.roomNo)->mRoomDt.getFileListInfo();
        }

        if (filelist != NULL) {
            if (!dStage_FileList_dt_GetEnemyAppear1Flag(filelist)) {
                u32 sw = dStage_FileList_dt_GetBitSw(filelist);
                if (sw != 0xFF && dComIfGs_isSwitch(sw, a_this->home.roomNo) &&
                    profile->mActorType == fopAc_ENEMY_e)
                {
                    return cPhs_ERROR_e;
                }
            } else {
                u32 sw = dStage_FileList_dt_GetBitSw(filelist);
                if (sw != 0xFF && !dComIfGs_isSwitch(sw, a_this->home.roomNo) &&
                    profile->mActorType == fopAc_ENEMY_e)
                {
                    return cPhs_ERROR_e;
                }
            }
        }
    }

    int ret = fpcMtd_Create((process_method_class*)a_this->sub_method, a_this);
    if (ret == cPhs_COMPLEATE_e) {
        s32 priority = fpcLf_GetPriority(a_this);
        fopDwTg_ToDrawQ(&a_this->draw_tag, priority);
    } else if (ret == cPhs_ERROR_e) {
        fopAcM_OnCondition(a_this, 0x10);
    }

    return ret;
}

/* 800193FC-80019404 013D3C 0008+00 0/0 1/0 0/0 .text getFileListInfo__15dStage_roomDt_cCFv */
dStage_FileList_dt_c* dStage_roomDt_c::getFileListInfo() const {
    return mFileListInfo;
}

/* 80019404-800194FC 013D44 00F8+00 0/0 0/0 2/2 .text            initBallModel__13fopEn_enemy_cFv */
bool fopEn_enemy_c::initBallModel() {
    void* objRes = dComIfG_getObjectRes("Alink", daAlink_c::getBallModelIdx());
    mBallModel = mDoExt_J3DModel__create((J3DModelData*)objRes, 0x80000, 0x11000284);

    if (!mBallModel) {
        return false;
    } else {
        mBallModel->setBaseScale(cXyz::Zero);

        mBtk = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes("Alink", daAlink_c::getBallBtkIdx());
        mBtk->searchUpdateMaterialID(mBallModel->getModelData());

        mBrk = (J3DAnmTevRegKey*)dComIfG_getObjectRes("Alink", daAlink_c::getBallBrkIdx());
        mBrk->searchUpdateMaterialID(mBallModel->getModelData());
    }

    return true;
}
/* 800194FC-80019520 013E3C 0024+00 2/2 0/0 2/2 .text checkBallModelDraw__13fopEn_enemy_cFv */
bool fopEn_enemy_c::checkBallModelDraw() {
    return (mFlags & 1) && !(mFlags & 0x32);
}

/* 80019520-800196A0 013E60 0180+00 0/0 0/0 2/2 .text
 * setBallModelEffect__13fopEn_enemy_cFP12dKy_tevstr_c          */
void fopEn_enemy_c::setBallModelEffect(dKy_tevstr_c* i_tevstr) {
    if (mBallModel) {
        field_0x590 += 1.0f;

        if (field_0x590 >= mBtk->getFrameMax()) {
            field_0x590 -= mBtk->getFrameMax();
        }

        if (checkBallModelDraw()) {
            Vec* base_scale = mBallModel->getBaseScale();
            cLib_chaseF(&base_scale->x, 1.0f, 0.1f);
            f32 result = base_scale->x;
            base_scale->z = result;
            base_scale->y = result;

            mEffectID1 = dComIfGp_particle_set(mEffectID1, 0x86C8, &mDownPos, i_tevstr);
            mEffectID2 = dComIfGp_particle_set(mEffectID2, 0x86C9, &mDownPos, i_tevstr);
        }
    }
}

/* 800196A0-800197BC 013FE0 011C+00 0/0 0/0 2/2 .text
 * drawBallModel__13fopEn_enemy_cFP12dKy_tevstr_c               */
void fopEn_enemy_c::drawBallModel(dKy_tevstr_c* i_tevstr) {
    f32 scale_target;

    if (mBallModel) {
        Vec* base_scale = mBallModel->getBaseScale();

        if (checkBallModelDraw()) {
            scale_target = 1.0f;
        } else {
            scale_target = 0.0f;
        }

        cLib_chaseF(&base_scale->x, scale_target, 0.05f);

        base_scale->y = base_scale->x;
        base_scale->z = base_scale->x;

        mBallModel->setBaseScale(*base_scale);

        if (base_scale->x > 0.01f) {
            mDoMtx_trans(mBallModel->getBaseTRMtx(), mDownPos.x, mDownPos.y, mDownPos.z);
            dKy_getEnvlight()->setLightTevColorType_MAJI(mBallModel, i_tevstr);

            mBtk->setFrame(field_0x590);
            mBallModel->getModelData()->entryTexMtxAnimator(mBtk);

            mBrk->setFrame(field_0x590);
            mBallModel->getModelData()->entryTevRegAnimator(mBrk);

            mDoExt_modelUpdateDL(mBallModel);
        }
    }
}

/* ############################################################################################## */
/* 803A35B0-803A35D0 -00001 0020+00 0/0 3/0 756/0 .data            g_fopAc_Method */
extern actor_method_class g_fopAc_Method = {
    (process_method_func)fopAc_Create,  (process_method_func)fopAc_Delete,
    (process_method_func)fopAc_Execute, (process_method_func)fopAc_IsDelete,
    (process_method_func)fopAc_Draw,
};

/* ############################################################################################## */
/* 80450CC0-80450CC8 0001C0 0004+04 0/0 9/9 0/0 .sbss
 * sInstance__35JASGlobalInstance<14JAUSectionHeap>             */
extern u8 data_80450CC0[4 + 4 /* padding */];
u8 data_80450CC0[4 + 4 /* padding */];