2020-08-04 08:49:11 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-10-12 03:59:42 +02:00
|
|
|
s32 get_defeated(s32 mapID, s32 encounterID) {
|
|
|
|
EncounterStatus* currentEncounter = &gCurrentEncounter;
|
|
|
|
s32 encounterIdx = encounterID / 32;
|
|
|
|
s32 encounterShift = encounterID % 32;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-12 03:59:42 +02:00
|
|
|
return currentEncounter->defeatFlags[mapID][encounterIdx] & (1 << encounterShift);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_defeated(s32 mapID, s32 encounterID) {
|
2020-10-14 18:45:54 +02:00
|
|
|
EncounterStatus* currentEncounter = &gCurrentEncounter;
|
2020-10-12 20:46:04 +02:00
|
|
|
s32 encounterIdx = encounterID / 32;
|
2020-10-12 03:59:42 +02:00
|
|
|
s32 encounterShift;
|
2020-10-12 20:46:04 +02:00
|
|
|
s32 flag;
|
2020-10-14 18:45:54 +02:00
|
|
|
|
2020-10-12 20:46:04 +02:00
|
|
|
flag = encounterID % 32;
|
|
|
|
encounterShift = flag;
|
|
|
|
flag = currentEncounter->defeatFlags[mapID][encounterIdx];
|
|
|
|
currentEncounter->defeatFlags[mapID][encounterIdx] = flag | (1 << encounterShift);
|
2020-10-14 18:45:54 +02:00
|
|
|
|
2020-10-12 20:46:04 +02:00
|
|
|
// TODO: The below should work but has regalloc issues:
|
|
|
|
/*EncounterStatus *currentEncounter = &gCurrentEncounter;
|
|
|
|
s32 encounterIdx = encounterID / 32;
|
|
|
|
s32 encounterShift = encounterID % 32;
|
2020-10-14 18:45:54 +02:00
|
|
|
|
2020-10-12 20:46:04 +02:00
|
|
|
currentEncounter->defeatFlags[mapID][encounterIdx] |= (1 << encounterShift);*/
|
2020-10-12 03:59:42 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 04:31:40 +01:00
|
|
|
ApiStatus func_8003EE98(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
if (isInitialCall) {
|
|
|
|
func_80045D00(0, 60);
|
|
|
|
}
|
2020-10-28 18:34:02 +01:00
|
|
|
return (func_80045FA4() == 0) * ApiStatus_DONE2;
|
2020-10-27 04:31:40 +01:00
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 04:31:40 +01:00
|
|
|
ApiStatus func_8003EECC(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
if (isInitialCall) {
|
|
|
|
func_80045D00(1, 60);
|
|
|
|
}
|
2020-10-28 18:34:02 +01:00
|
|
|
return (func_80045FA4() == 0) * ApiStatus_DONE2;
|
2020-10-27 04:31:40 +01:00
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-12-03 09:07:39 +01:00
|
|
|
ApiStatus FadeBackgroundToBlack(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
if (isInitialCall) {
|
|
|
|
func_8011D82C(1);
|
|
|
|
*D_801512F0 = 1;
|
|
|
|
set_background_color_blend(0, 0, 0, 0);
|
|
|
|
script->functionTemp[0].s = 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_background_color_blend(0, 0, 0, ((25 - script->functionTemp[0].s) * 10) & 254);
|
|
|
|
script->functionTemp[0].s--;
|
2020-12-03 10:33:03 +01:00
|
|
|
do {} while (0);
|
2020-12-03 09:07:39 +01:00
|
|
|
return (script->functionTemp[0].s == 0) * ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
ApiStatus UnfadeBackgroundFromBlack(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
if (isInitialCall) {
|
2020-10-26 02:12:01 +01:00
|
|
|
script->functionTemp[0].s = 25;
|
2020-09-25 23:18:09 +02:00
|
|
|
}
|
|
|
|
|
2020-10-26 02:12:01 +01:00
|
|
|
set_background_color_blend(0, 0, 0, (script->functionTemp[0].s * 10) & 0xFE);
|
|
|
|
script->functionTemp[0].s -= 5;
|
2020-09-25 23:18:09 +02:00
|
|
|
|
2020-10-26 02:12:01 +01:00
|
|
|
if (script->functionTemp[0].s == 0) {
|
2020-09-25 23:18:09 +02:00
|
|
|
set_background_color_blend(0, 0, 0, 0);
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
} else {
|
|
|
|
return ApiStatus_BLOCK;
|
|
|
|
}
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 04:31:40 +01:00
|
|
|
ApiStatus func_8003F018(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Npc* npc = get_npc_unsafe(-0xA);
|
|
|
|
|
|
|
|
if (isInitialCall) {
|
|
|
|
play_sound(0x24B);
|
|
|
|
npc->unk_AC = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
npc->unk_AC += 17;
|
|
|
|
|
|
|
|
if ((u32)(npc->unk_AC & 0xFF) >= 0xFF) {
|
|
|
|
npc->unk_AC = 0xFF;
|
|
|
|
return ApiStatus_DONE1;
|
|
|
|
}
|
|
|
|
return ApiStatus_BLOCK;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-12-03 09:07:39 +01:00
|
|
|
ApiStatus func_8003F084(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Npc* npc = get_npc_unsafe(-0xA);
|
|
|
|
|
|
|
|
npc->unk_AC -= 17;
|
|
|
|
if (npc->unk_AC == 0) {
|
|
|
|
npc->unk_AC = 0;
|
|
|
|
return ApiStatus_DONE1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiStatus_BLOCK;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8003F0C4);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8003F384);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
ApiStatus GetCamLookAtObjVector(ScriptInstance* script, s32 isInitialCall) {
|
2020-11-06 18:32:30 +01:00
|
|
|
script->varTable[0] = CURRENT_CAM->lookAt_obj.x;
|
|
|
|
script->varTable[1] = CURRENT_CAM->lookAt_obj.y;
|
|
|
|
script->varTable[2] = CURRENT_CAM->lookAt_obj.z;
|
2020-09-06 17:53:48 +02:00
|
|
|
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
ApiStatus HasMerleeCasts(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
script->varTable[0] = 0;
|
|
|
|
if (gPlayerData.merleeCastsLeft > 0) {
|
|
|
|
script->varTable[0] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8003F414);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8003F4CC);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-26 03:51:54 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", OnDefeatEnemy, ScriptInstance* script, s32 isInitialCall);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
ApiStatus OnFleeBattleDrops(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
PlayerStatus* playerStatus = &gPlayerStatus;
|
|
|
|
PlayerData* playerData = &gPlayerData;
|
|
|
|
|
|
|
|
if (isInitialCall) {
|
2020-10-26 02:12:01 +01:00
|
|
|
script->functionTemp[0].s = 0;
|
|
|
|
script->functionTemp[1].s = 40;
|
|
|
|
script->functionTemp[2].s = 0;
|
2020-09-06 17:53:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-26 02:12:01 +01:00
|
|
|
script->functionTemp[2].s++;
|
|
|
|
if (script->functionTemp[2].s >= 5) {
|
2020-09-06 17:53:48 +02:00
|
|
|
if (rand_int(100) < 50) {
|
|
|
|
if (playerData->coins != 0) {
|
|
|
|
playerData->coins--;
|
|
|
|
make_item_entity_delayed(ItemId_COIN, playerStatus->position.x, playerStatus->position.y + playerStatus->colliderHeight,
|
|
|
|
playerStatus->position.z, 3, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2020-10-26 02:12:01 +01:00
|
|
|
script->functionTemp[2].s = 0;
|
2020-09-06 17:53:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-26 02:12:01 +01:00
|
|
|
return --script->functionTemp[1].s == 0;
|
2020-09-06 17:53:48 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8003F7CC);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
void func_8004135C() {
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_80041364);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_80041964);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", show_first_strike_message);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_80041F10);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
s32 func_8004304C(void) {
|
|
|
|
EncounterStatus* currentEncounter = &gCurrentEncounter;
|
|
|
|
s32 ret = currentEncounter->unk_98;
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
func_80137D88(0, currentEncounter->unk_90);
|
|
|
|
ret = func_80137E10(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8004309C);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
void func_800431D4() {
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_800431DC);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_1a1f0_len_5390", create_npcs);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
void func_80044140() {
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_80044148(void) {
|
|
|
|
s32 ret = gGameState == 3;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-06 17:53:48 +02:00
|
|
|
if (gCurrentEncounter.hitType == 5) {
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|