2020-08-04 08:49:11 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", func_802D5B10);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", func_802D5C70);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus FadeOutMusic(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32* ptrNextPos = args++;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
return (set_music_track(itemID, -1, 0, get_variable(script, *ptrNextPos++), 8) != 0) * 2;
|
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus SetMusicTrack(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 musicPlayer = get_variable(script, *args++);
|
|
|
|
s32 songID = get_variable(script, *args++);
|
|
|
|
s32 variation = get_variable(script, *args++);
|
|
|
|
s16 volume = get_variable(script, *args++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-12 04:45:27 +02:00
|
|
|
return (set_music_track(musicPlayer, songID, variation, 0x1F4, volume) != 0) * 2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus FadeInMusic(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 var0 = get_variable(script, *args++);
|
|
|
|
s32 var1 = get_variable(script, *args++);
|
|
|
|
s32 var2 = get_variable(script, *args++);
|
|
|
|
s32 var3 = get_variable(script, *args++);
|
|
|
|
s16 var4 = get_variable(script, *args++);
|
|
|
|
s16 var5 = get_variable(script, *args++);
|
|
|
|
|
|
|
|
return (func_8014A964(var0, var1, var2, var3, var4, var5) != 0) * 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", func_802D5EE0);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus func_802D5F28(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
|
|
|
|
func_8014AA54(get_variable(script, *args++), get_variable(script, *args++), (s16)get_variable(script, *args++));
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiStatus func_802D5FA4(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
func_8014AB0C(0, (s16)get_variable(script, *script->ptrReadPos));
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiStatus func_802D5FD8(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
func_8014ADA4();
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus func_802D5FF8(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
func_8014ADF8(get_variable(script, *args++), get_variable(script, *args++));
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus func_802D6050(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
func_8014AE6C();
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus func_802D6070(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
func_8014AEF8();
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus func_802D6090(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
func_8014AF8C(get_variable(script, *args++), get_variable(script, *args++));
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
//INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", ClearAmbientSounds);
|
|
|
|
ApiStatus ClearAmbientSounds(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 flags = get_variable(script, *args++);
|
|
|
|
|
|
|
|
return (play_ambient_sounds(-1, flags) != 0) * 2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus PlayAmbientSounds(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *args++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
|
|
|
return (play_ambient_sounds(soundID, 0xFA) != 0) * 2;
|
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus PlaySound(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *args++);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
play_sound(soundID);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus func_802D617C(ScriptInstance* script, s32 initialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *args++);
|
|
|
|
s32 value2 = get_variable(script, *args++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
|
|
|
_play_sound(soundID, value2 & 0xFF, 0, 0);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus PlaySoundAt(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *args++);
|
|
|
|
s32 value2 = get_variable(script, *args++);
|
|
|
|
s32 x = get_variable(script, *args++);
|
|
|
|
s32 y = get_variable(script, *args++);
|
|
|
|
s32 z = get_variable(script, *args++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-12 04:29:31 +02:00
|
|
|
play_sound_at_position(soundID, value2, x, y, z);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus StopSound(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
stop_sound(get_variable(script, *args++));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus func_802D62E4(ScriptInstance* script, s32 initialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
func_80149A6C(get_variable(script, *args++), 1);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus UseDoorSounds(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
gCurrentDoorSoundsSet = get_variable(script, *args++);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus func_802D6340(ScriptInstance* script, s32 initialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
D_80151308 = get_variable(script, *args++);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus PlaySoundAtF(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
Bytecode soundID = *args++;
|
|
|
|
u16 value2 = get_variable(script, *args++);
|
|
|
|
f32 x = get_float_variable(script, *args++);
|
|
|
|
f32 y = get_float_variable(script, *args++);
|
|
|
|
f32 z = get_float_variable(script, *args++);
|
|
|
|
|
|
|
|
play_sound_at_position(soundID, value2, x, y, z);
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", func_802D6420);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-09-25 23:18:09 +02:00
|
|
|
INCLUDE_ASM(s32, "code_fa4c0_len_3bf0", func_802D663C);
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus RemoveKeyItemAt(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 index = get_variable(script, *args++);
|
2020-08-19 02:16:12 +02:00
|
|
|
s16* ptrKeyItems = (s16*) &gPlayerData.keyItems;
|
2020-08-12 04:29:31 +02:00
|
|
|
|
2020-08-13 06:10:41 +02:00
|
|
|
ptrKeyItems[index] = 0;
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 03:59:46 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus RemoveItemAt(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 index = get_variable(script, *args++);
|
2020-08-19 02:16:12 +02:00
|
|
|
s16* ptrInvItems = (s16*) &gPlayerData.invItems;
|
2020-08-16 05:19:00 +02:00
|
|
|
|
2020-08-13 06:10:41 +02:00
|
|
|
ptrInvItems[index] = 0;
|
2020-08-12 03:59:46 +02:00
|
|
|
sort_items();
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 03:59:46 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddKeyItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 value = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
PlayerData* playerData = &gPlayerData;
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 itemID = get_variable(script, value);
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-16 06:24:20 +02:00
|
|
|
if (itemID == ItemId_FORTRESS_KEY) {
|
2020-08-12 22:53:01 +02:00
|
|
|
playerData->fortressKeyCount++;
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 22:53:01 +02:00
|
|
|
}
|
|
|
|
|
2020-08-13 07:03:47 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 00:52:55 +02:00
|
|
|
if (i < ARRAY_COUNT(playerData->keyItems)) {
|
2020-08-12 22:53:01 +02:00
|
|
|
playerData->keyItems[i] = itemID;
|
|
|
|
}
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 22:53:01 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus func_802D6954(ScriptInstance* script, s32 isInitialCall) {
|
2020-09-24 05:16:13 +02:00
|
|
|
enable_player_input();
|
|
|
|
enable_player_static_collisions();
|
2020-08-12 22:53:01 +02:00
|
|
|
func_800EF600();
|
2020-08-13 00:52:55 +02:00
|
|
|
D_8009A650[0] &= ~0x40;
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 22:53:01 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus HasKeyItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 value = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
PlayerData* playerData = &gPlayerData;
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 i;
|
2020-08-16 05:19:00 +02:00
|
|
|
|
2020-08-19 02:16:12 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_variable(script, value, i < ARRAY_COUNT(playerData->keyItems));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 22:53:01 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus FindKeyItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 value = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
PlayerData* playerData = &gPlayerData;
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
|
|
|
|
2020-08-19 02:16:12 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->keyItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-12 22:53:01 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
Bytecode outItemIdx = *args++;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-19 02:23:52 +02:00
|
|
|
set_variable(script, outItemIdx, add_item(itemID));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus func_802D6AF0(ScriptInstance* script, s32 initialCall) {
|
2020-08-11 23:38:21 +02:00
|
|
|
set_variable(script, *script->ptrReadPos, 0);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus FindItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 value = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
PlayerData* playerData = &gPlayerData;
|
2020-08-14 03:43:04 +02:00
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 03:43:04 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
|
|
|
if (playerData->invItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 03:43:04 +02:00
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->invItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-14 03:43:04 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus RemoveItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 value = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
PlayerData* playerData = &gPlayerData;
|
2020-08-14 03:55:06 +02:00
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 03:55:06 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
|
|
|
if (playerData->invItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->invItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemIndex >= 0) {
|
2020-08-14 04:07:24 +02:00
|
|
|
// This is `playerData->invItems[i]`, but we have to do weird
|
|
|
|
// pointer math to get the output asm to exactly match :/
|
|
|
|
*(playerData->invItems + i) = 0;
|
2020-08-14 03:55:06 +02:00
|
|
|
}
|
|
|
|
sort_items();
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-14 03:55:06 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus CountFortressKeys(ScriptInstance* script, s32 isInitialCall) {
|
2020-08-14 04:22:25 +02:00
|
|
|
s32 outVar = *script->ptrReadPos;
|
|
|
|
|
|
|
|
set_variable(script, outVar, get_fortress_key_count());
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-14 04:22:25 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus RemoveFortressKeys(ScriptInstance* script, s32 isInitialCall) {
|
2020-08-14 04:24:21 +02:00
|
|
|
s32 num = get_variable(script, *script->ptrReadPos);
|
|
|
|
|
|
|
|
subtract_fortress_keys(num);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-14 04:24:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus MakeItemEntity(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 x = get_variable(script, *args++);
|
|
|
|
s32 y = get_variable(script, *args++);
|
|
|
|
s32 z = get_variable(script, *args++);
|
|
|
|
s32 itemSpawnMode = get_variable(script, *args++);
|
|
|
|
s32 pickupVar = get_variable_index(script, *args++);
|
|
|
|
|
|
|
|
script->varTable[0] = make_item_entity_nodelay(itemID, x, y, z, itemSpawnMode, pickupVar);
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiStatus DropItemEntity(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 x = get_variable(script, *args++);
|
|
|
|
s32 y = get_variable(script, *args++);
|
|
|
|
s32 z = get_variable(script, *args++);
|
|
|
|
s32 itemSpawnMode = get_variable(script, *args++);
|
|
|
|
s32 pickupVar = get_variable(script, *args++);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
script->varTable[0] = make_item_entity_nodelay(itemID, x, y, z, itemSpawnMode, pickupVar);
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus DropItemEntityB(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *args++);
|
|
|
|
s32 x = get_variable(script, *args++);
|
|
|
|
s32 y = get_variable(script, *args++);
|
|
|
|
s32 z = get_variable(script, *args++);
|
|
|
|
s32 itemSpawnMode = get_variable(script, *args++);
|
2020-10-27 00:10:32 +01:00
|
|
|
s32 pickupVar = get_variable_index(script, *args++);
|
2020-08-13 20:37:53 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
script->varTable[0] = make_item_entity_nodelay(itemID, x, y, z, itemSpawnMode, pickupVar);
|
|
|
|
set_item_entity_flags(script->varTable[0], 0x4000);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-13 20:37:53 +02:00
|
|
|
}
|
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus RemoveItemEntity(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemEntityIndex = get_variable(script, *args++);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-19 02:16:12 +02:00
|
|
|
remove_item_entity_by_index(itemEntityIndex);
|
|
|
|
return ApiStatus_DONE2;
|
2020-08-13 20:37:53 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddBadge(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 badgeID = get_variable(script, *args++);
|
|
|
|
Bytecode outBadgeIdx = *args++;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-19 02:23:52 +02:00
|
|
|
set_variable(script, outBadgeIdx, add_badge(badgeID));
|
2020-08-19 02:16:12 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus RemoveBadge(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
PlayerData* playerData = PLAYER_DATA;
|
|
|
|
s32 badge = get_variable(script, *args++);
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) {
|
|
|
|
if (playerData->badges[i] == badge) {
|
|
|
|
playerData->badges[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
|
|
|
|
if (playerData->equippedBadges[i] == badge) {
|
|
|
|
playerData->equippedBadges[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus SetItemPos(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-08-16 05:19:00 +02:00
|
|
|
ItemEntity* ptrItemEntity;
|
2020-08-12 03:59:46 +02:00
|
|
|
s32 itemEntityIndex;
|
|
|
|
s32 x, y, z;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
itemEntityIndex = get_variable(script, *args++);
|
|
|
|
x = get_variable(script, *args++);
|
|
|
|
y = get_variable(script, *args++);
|
|
|
|
z = get_variable(script, *args++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-19 02:16:12 +02:00
|
|
|
ptrItemEntity = (ItemEntity*) get_item_entity(itemEntityIndex);
|
2020-08-15 06:27:01 +02:00
|
|
|
ptrItemEntity->position.x = x;
|
|
|
|
ptrItemEntity->position.y = y;
|
|
|
|
ptrItemEntity->position.z = z;
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus SetItemFlags(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemEntityIndex = get_variable(script, *args++);
|
|
|
|
s32 flagBits = *args++;
|
|
|
|
s32 var2 = get_variable(script, *args++);
|
|
|
|
ItemEntity* itemEntity = get_item_entity(itemEntityIndex);
|
|
|
|
|
|
|
|
if (var2 != 0) {
|
|
|
|
itemEntity->flags |= flagBits;
|
|
|
|
} else {
|
|
|
|
itemEntity->flags &= ~flagBits;
|
|
|
|
}
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
ApiStatus func_802D721C(ScriptInstance* script, s32 isInitialCall) {
|
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemEntityIndex = get_variable(script, *args++);
|
|
|
|
s32 var2 = get_variable(script, *args++);
|
|
|
|
ItemEntity* itemEntity = get_item_entity(itemEntityIndex);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
itemEntity->unk_2F = var2;
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
2020-09-24 05:16:13 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddCoin(ScriptInstance* script, s32 isInitialCall) {
|
2020-08-11 23:38:21 +02:00
|
|
|
script->varTable[0] = add_coins(get_variable(script, *script->ptrReadPos));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddStarPoints(ScriptInstance* script, s32 isInitialCall) {
|
2020-08-11 23:38:21 +02:00
|
|
|
script->varTable[0] = add_star_points(get_variable(script, *script->ptrReadPos));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus AddStarPieces(ScriptInstance* script, s32 isInitialCall) {
|
2020-08-11 23:38:21 +02:00
|
|
|
script->varTable[0] = add_star_pieces(get_variable(script, *script->ptrReadPos));
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-16 08:55:51 +02:00
|
|
|
ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
|
|
|
s32 itemIdx = get_variable(script, *args++);
|
|
|
|
Bytecode out1 = *args++;
|
|
|
|
Bytecode out2 = *args++;
|
2020-08-16 05:19:00 +02:00
|
|
|
|
2020-10-08 21:03:58 +02:00
|
|
|
set_variable(script, out1, (&gItemTable[itemIdx])->potencyA);
|
|
|
|
set_variable(script, out2, (&gItemTable[itemIdx])->potencyB);
|
2020-08-16 08:55:51 +02:00
|
|
|
return ApiStatus_DONE2;
|
2020-10-08 21:03:58 +02:00
|
|
|
}
|
2020-08-13 06:10:41 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
ApiStatus ShowGotItem(ScriptInstance* script, s32 isInitialCall) {
|
2020-10-08 21:03:58 +02:00
|
|
|
Bytecode* args = script->ptrReadPos;
|
2020-10-27 00:10:32 +01:00
|
|
|
ItemEntity* e;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
if (isInitialCall) {
|
|
|
|
script->functionTemp[0].s = 0;
|
|
|
|
}
|
2020-08-13 06:10:41 +02:00
|
|
|
|
2020-10-27 00:10:32 +01:00
|
|
|
switch (script->functionTemp[0].s) {
|
|
|
|
case 0:
|
|
|
|
script->functionTemp[1].s = init_got_item(get_variable(script, *args++), get_variable(script, *args++), *args++);
|
|
|
|
script->functionTemp[0].s = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (get_item_entity(script->functionTemp[1].s) == NULL) {
|
|
|
|
return ApiStatus_DONE2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ApiStatus_BLOCK;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|