diff --git a/include/common_structs.h b/include/common_structs.h index 49b59915e3..a8e1b8aec0 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -233,8 +233,18 @@ typedef struct ScriptInstance { /* 0x13C */ s32* array; /* 0x140 */ s32* flagArray; /* 0x144 */ ScriptID id; - /* 0x148 */ struct Enemy* ownerActorID; /* controller*, battle ID, trigger* */ - /* 0x14C */ u32 ownerID; /* can be an npcID, a triggerID, a trigger ptr */ + /* 0x148 */ union { + s32 enemyID; + s32 actorID; + struct Enemy* enemy; ///< For overworld scripts owned by an Npc + struct Actor* actor; ///< For battle scripts + } owner1; ///< Initially -1 + /* 0x14C */ union { + NpcId npcID; + s32 triggerID; + struct Npc* npc; ///< For overworld scripts owned by an Npc + struct Trigger* trigger; + } owner2; ///< Initially -1 /* 0x150 */ f32 timeScale; /* 0x154 */ f32 frameCounter; /* 0x158 */ s32 unk_158; diff --git a/src/code_181810.c b/src/code_181810.c index f9aab5c231..599c30af1c 100644 --- a/src/code_181810.c +++ b/src/code_181810.c @@ -34,7 +34,7 @@ ApiStatus ActorSpeak(ScriptInstance* script, s32 isInitialCall) { stringID2 = stringID; if (actorID == ActorId_SELF) { - actorID = script->ownerActorID; + actorID = script->owner1.actorID; } actor = get_actor(actorID); @@ -145,7 +145,7 @@ ApiStatus PlaySoundAtActor(ScriptInstance* script, s32 isInitialCall) { Actor* actor; if (actorID == ActorId_SELF) { - actorID = script->ownerActorID; + actorID = script->owner1.actorID; } actor = get_actor(actorID); @@ -202,7 +202,7 @@ INCLUDE_ASM(s32, "code_181810", func_80253FB0); ApiStatus MultiplyByActorScale(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Actor* actor = get_actor(script->ownerActorID); + Actor* actor = get_actor(script->owner1.actorID); set_float_variable(script, *args, get_float_variable(script, *args) * actor->scalingFactor); return ApiStatus_DONE2; diff --git a/src/code_18F340.c b/src/code_18F340.c index 1b34427f99..fdf1217c10 100644 --- a/src/code_18F340.c +++ b/src/code_18F340.c @@ -125,7 +125,7 @@ ApiStatus IncrementPlayerFP(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_80261D98(ScriptInstance* script, s32 isInitialCall) { - inflict_status_set_duration(get_actor(script->ownerActorID), 4, 0, 1); + inflict_status_set_duration(get_actor(script->owner1.actorID), 4, 0, 1); func_8026777C(); return ApiStatus_DONE2; } diff --git a/src/code_197F40.c b/src/code_197F40.c index 41398f8678..81c18630ff 100644 --- a/src/code_197F40.c +++ b/src/code_197F40.c @@ -227,12 +227,12 @@ INCLUDE_ASM(s32, "code_197F40", func_8026DA94); INCLUDE_ASM(s32, "code_197F40", SummonEnemy); ApiStatus GetOwnerID(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID); + set_variable(script, *script->ptrReadPos, script->owner1.actorID); return ApiStatus_DONE2; } ApiStatus SetOwnerID(ScriptInstance* script, s32 isInitialCall) { - script->ownerActorID = get_variable(script, *script->ptrReadPos); + script->owner1.actorID = get_variable(script, *script->ptrReadPos); return ApiStatus_DONE2; } @@ -243,7 +243,7 @@ ApiStatus ActorExists(ScriptInstance* script, s32 isInitialCall) { ActorId actorID = get_variable(script, *args++); if (actorID == ActorId_SELF) { - actorID = script->ownerActorID; + actorID = script->owner1.actorID; } isExist = get_actor(actorID) != NULL; @@ -330,7 +330,7 @@ INCLUDE_ASM(s32, "code_197F40", func_8026E260); ApiStatus PlayerCreateTargetList(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Actor* actor = get_actor(script->ownerActorID); + Actor* actor = get_actor(script->owner1.actorID); gBattleStatus.currentTargetListFlags = *args; player_create_target_list(actor); @@ -340,7 +340,7 @@ ApiStatus PlayerCreateTargetList(ScriptInstance* script, s32 isInitialCall) { ApiStatus EnemyCreateTargetList(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Actor* actor = get_actor(script->ownerActorID); + Actor* actor = get_actor(script->owner1.actorID); gBattleStatus.currentTargetListFlags = *args; enemy_create_target_list(actor); diff --git a/src/code_1AC760.c b/src/code_1AC760.c index 0ddc07c968..fafdcec8c8 100644 --- a/src/code_1AC760.c +++ b/src/code_1AC760.c @@ -24,7 +24,7 @@ ApiStatus GetActorLevel(ScriptInstance* script, s32 isInitialCall) { Bytecode* outVar; if (actorID == -0x7F) { - actorID = script->ownerActorID; + actorID = script->owner1.enemyID; } outVar = *args++; diff --git a/src/code_1f580_len_1940.c b/src/code_1f580_len_1940.c index 62b1c7593b..13b82780f2 100644 --- a/src/code_1f580_len_1940.c +++ b/src/code_1f580_len_1940.c @@ -49,22 +49,22 @@ ApiStatus GetBattleOutcome(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_800445A8(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID->unk_C4); + set_variable(script, *script->ptrReadPos, script->owner1.enemy->unk_C4); return ApiStatus_DONE2; } ApiStatus func_800445D4(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID->unk_C8); + set_variable(script, *script->ptrReadPos, script->owner1.enemy->unk_C8); return ApiStatus_DONE2; } ApiStatus GetOwnerEncounterTrigger(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID->encountered); + set_variable(script, *script->ptrReadPos, script->owner1.enemy->encountered); return ApiStatus_DONE2; } ApiStatus DoNpcDefeat(ScriptInstance* script, s32 isInitialCall) { - Enemy* owner = script->ownerActorID; + Enemy* owner = script->owner1.enemy; Npc* temp_s1 = get_npc_unsafe(owner->npcID); ScriptInstance* newScript; @@ -73,8 +73,8 @@ ApiStatus DoNpcDefeat(ScriptInstance* script, s32 isInitialCall) { newScript = start_script(&SCRIPT_NpcDefeat, 10, 0); owner->defeatScript = newScript; owner->defeatScriptID = newScript->id; - newScript->ownerActorID = owner; - newScript->ownerID = owner->npcID; + newScript->owner1.enemy = owner; + newScript->owner2.npcID = owner->npcID; newScript->groupFlags = owner->scriptGroup; return ApiStatus_FINISH; @@ -108,7 +108,7 @@ INCLUDE_ASM(s32, "code_1f580_len_1940", BindNpcAI, ScriptInstance* script, s32 i ApiStatus BindNpcIdle(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* owner = script->ownerActorID; + Enemy* owner = script->owner1.enemy; NpcId npcID = get_variable(script, *args++); Bytecode* aiBytecode = (Bytecode*)get_variable(script, *args); @@ -124,7 +124,7 @@ ApiStatus BindNpcIdle(ScriptInstance* script, s32 isInitialCall) { ApiStatus RestartNpcAI(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); ScriptInstance* newScript; s32 groupFlags; @@ -149,8 +149,8 @@ ApiStatus RestartNpcAI(ScriptInstance* script, s32 isInitialCall) { newScript = start_script(npc->aiBytecode, 10, 0); npc->aiScript = newScript; npc->aiScriptID = newScript->id; - newScript->ownerActorID = npc; - newScript->ownerID = script->ownerID; + newScript->owner1.enemy = npc; + newScript->owner2.npc = script->owner2.npc; newScript->groupFlags = groupFlags; return ApiStatus_DONE2; @@ -158,7 +158,7 @@ ApiStatus RestartNpcAI(ScriptInstance* script, s32 isInitialCall) { ApiStatus EnableNpcAI(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); s32 var2 = get_variable(script, *args); @@ -183,7 +183,7 @@ INCLUDE_ASM(s32, "code_1f580_len_1940", SetNpcAux, ScriptInstance* script, s32 i ApiStatus BindNpcAux(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); Bytecode* auxBytecode = (Bytecode*)get_variable(script, *args); @@ -199,16 +199,16 @@ ApiStatus BindNpcAux(ScriptInstance* script, s32 isInitialCall) { ApiStatus RestartNpcAux(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; - NpcId npcId = get_variable(script, *args++); + Enemy* npc = script->owner1.enemy; + NpcId npcID = get_variable(script, *args++); ScriptInstance* newScript; s32 groupFlags; - if (npcId == NpcId_SELF) { - npcId = npc->npcID; + if (npcID == NpcId_SELF) { + npcID = npc->npcID; } - npc = get_enemy(npcId); + npc = get_enemy(npcID); if (npc->flags & 1) { groupFlags = 10; @@ -223,8 +223,8 @@ ApiStatus RestartNpcAux(ScriptInstance* script, s32 isInitialCall) { newScript = start_script(npc->auxBytecode, 10, 0); npc->auxScript = newScript; npc->auxScriptID = newScript->id; - newScript->ownerActorID = npc; - newScript->ownerID = npcId; + newScript->owner1.enemy = npc; + newScript->owner2.npcID = npcID; newScript->groupFlags = groupFlags; return ApiStatus_DONE2; @@ -232,7 +232,7 @@ ApiStatus RestartNpcAux(ScriptInstance* script, s32 isInitialCall) { ApiStatus EnableNpcAux(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); s32 var2 = get_variable(script, *args); @@ -255,7 +255,7 @@ ApiStatus EnableNpcAux(ScriptInstance* script, s32 isInitialCall) { ApiStatus BindNpcInteract(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); Bytecode* interactBytecode = (Bytecode*)get_variable(script, *args); @@ -275,7 +275,7 @@ ApiStatus BindNpcInteract(ScriptInstance* script, s32 isInitialCall) { ApiStatus BindNpcHit(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); Bytecode* hitBytecode = (Bytecode*)get_variable(script, *args); @@ -295,7 +295,7 @@ ApiStatus BindNpcHit(ScriptInstance* script, s32 isInitialCall) { ApiStatus BindNpcDefeat(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; s32 npcId = get_variable(script, *args++); Bytecode* defeatBytecode = (Bytecode*)get_variable(script, *args); @@ -311,7 +311,7 @@ ApiStatus BindNpcDefeat(ScriptInstance* script, s32 isInitialCall) { ApiStatus SetSelfVar(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* owner = script->ownerActorID; + Enemy* owner = script->owner1.enemy; s32 var1 = get_variable(script, *args++); s32 var2 = get_variable(script, *args); @@ -322,13 +322,13 @@ ApiStatus SetSelfVar(ScriptInstance* script, s32 isInitialCall) { ApiStatus GetSelfVar(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - set_variable(script, *args, script->ownerActorID->varTable[get_variable(script, *args++)]); + set_variable(script, *args, script->owner1.enemy->varTable[get_variable(script, *args++)]); return ApiStatus_DONE2; } ApiStatus SetNpcVar(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); s32 varIdx = get_variable(script, *args++); s32 val = get_variable(script, *args); @@ -350,7 +350,7 @@ ApiStatus GetNpcVar(ScriptInstance* script, s32 isInitialCall) { s32 varIdx; s32 var3; - npc = script->ownerActorID; + npc = script->owner1.enemy; npcID = get_variable(script, *args++); varIdx = get_variable(script, *args++); var3 = *args; @@ -367,7 +367,7 @@ ApiStatus GetNpcVar(ScriptInstance* script, s32 isInitialCall) { ApiStatus SetSelfRotation(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Npc* self = get_npc_unsafe(script->ownerID); + Npc* self = get_npc_unsafe(script->owner2.npcID); s32 rotX = get_variable(script, *args++); s32 rotY = get_variable(script, *args++); s32 rotZ = get_variable(script, *args++); @@ -380,13 +380,13 @@ ApiStatus SetSelfRotation(ScriptInstance* script, s32 isInitialCall) { } ApiStatus SetSelfEnemyFlags(ScriptInstance* script, s32 isInitialCall) { - script->ownerActorID->flags = *script->ptrReadPos; + script->owner1.enemy->flags = *script->ptrReadPos; return ApiStatus_DONE2; } ApiStatus SetSelfEnemyFlagBits(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* owner = script->ownerActorID; + Enemy* owner = script->owner1.enemy; s32 bits = *args++; if (get_variable(script, *args)) { @@ -399,8 +399,8 @@ ApiStatus SetSelfEnemyFlagBits(ScriptInstance* script, s32 isInitialCall) { ApiStatus func_80045580(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* owner = script->ownerActorID; - Npc* npc = get_npc_unsafe(script->ownerID); + Enemy* owner = script->owner1.enemy; + Npc* npc = get_npc_unsafe(script->owner2.npcID); owner->unk_07 = get_variable(script, *args); owner->unk_10.x = npc->pos.x; @@ -411,7 +411,7 @@ ApiStatus func_80045580(ScriptInstance* script, s32 isInitialCall) { } ApiStatus GetSelfNpcID(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID->npcID); + set_variable(script, *script->ptrReadPos, script->owner1.enemy->npcID); return ApiStatus_DONE2; } @@ -430,7 +430,7 @@ ApiStatus ClearDefeatedEnemies(ScriptInstance* script, s32 isInitialCall) { ApiStatus SetEnemyFlagBits(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* npc = script->ownerActorID; + Enemy* npc = script->owner1.enemy; NpcId npcId = get_variable(script, *args++); s32 bits = *args++; s32 var2 = get_variable(script, *args); @@ -456,7 +456,7 @@ ApiStatus func_8004572C(ScriptInstance* script, s32 isInitialCall) { ApiStatus GetSelfAnimationFromTable(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; - Enemy* owner = script->ownerActorID; + Enemy* owner = script->owner1.enemy; set_variable(script, *args, owner->animList[get_variable(script, *args++)]); return ApiStatus_DONE2; @@ -468,7 +468,7 @@ ApiStatus func_80045798(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_800457C4(ScriptInstance* script, s32 isInitialCall) { - Enemy* ownerActor = script->ownerActorID; + Enemy* ownerActor = script->owner1.enemy; ownerActor->unk_B5 = get_variable(script, *script->ptrReadPos); return ApiStatus_DONE2; @@ -502,7 +502,7 @@ ApiStatus func_80045838(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_800458CC(ScriptInstance* script, s32 isInitialCall) { - set_variable(script, *script->ptrReadPos, script->ownerActorID->npcSettings->unk_2A & 8); + set_variable(script, *script->ptrReadPos, script->owner1.enemy->npcSettings->unk_2A & 8); return ApiStatus_DONE2; } diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index 935cbcef54..3b948d5688 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -190,8 +190,8 @@ ScriptInstance* start_script(Bytecode* initialLine, s32 priority, s32 initialSta newScript->childScript = NULL; newScript->parentScript = NULL; newScript->id = gStaticScriptCounter++; - newScript->ownerActorID = -1; - newScript->ownerID = -1; + newScript->owner1.actorID = -1; + newScript->owner2.npcID = -1; newScript->loopDepth = -1; newScript->switchDepth = -1; newScript->groupFlags = ~0x10; @@ -261,8 +261,8 @@ ScriptInstance* start_script_in_group(Bytecode* initialLine, u8 priority, s32 in newScript->childScript = NULL; newScript->parentScript = NULL; newScript->id = gStaticScriptCounter++; - newScript->ownerActorID = -1; - newScript->ownerID = -1; + newScript->owner1.actorID = -1; + newScript->owner2.npcID = -1; newScript->loopDepth = -1; newScript->switchDepth = -1; newScript->groupFlags = groupFlags; @@ -334,8 +334,8 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, child->childScript = NULL; child->priority = parentScript->priority; child->id = gStaticScriptCounter++; - child->ownerActorID = parentScript->ownerActorID; - child->ownerID = parentScript->ownerID; + child->owner1.actorID = parentScript->owner1.actorID; + child->owner2.npcID = parentScript->owner2.npcID; child->loopDepth = -1; child->switchDepth = -1; child->groupFlags = parentScript->groupFlags; diff --git a/src/code_f2470_len_27f0.c b/src/code_f2470_len_27f0.c index ab3ecf7e0c..a988b52c36 100644 --- a/src/code_f2470_len_27f0.c +++ b/src/code_f2470_len_27f0.c @@ -2,7 +2,7 @@ Npc* resolve_npc(ScriptInstance* script, NpcId npcIdOrPtr) { if (npcIdOrPtr == NpcId_SELF) { - return get_npc_safe(script->ownerID); + return get_npc_safe(script->owner2.npcID); } else if (npcIdOrPtr >= -270000000) { return get_npc_safe(npcIdOrPtr); } else { diff --git a/src/si.c b/src/si.c index 3827d3cd18..e0158cef0b 100644 --- a/src/si.c +++ b/src/si.c @@ -864,8 +864,8 @@ ApiStatus si_handle_exec1(ScriptInstance* script) { newScript = start_script_in_group((ScriptInstance*)get_variable(script, *script->ptrReadPos), script->priority, 0, script->groupFlags); - newScript->ownerActorID = script->ownerActorID; - newScript->ownerID = script->ownerID; + newScript->owner1 = script->owner1; + newScript->owner2 = script->owner2; i = 0; while (i < ARRAY_COUNT(script->varTable)) { @@ -892,8 +892,8 @@ ApiStatus si_handle_exec2(ScriptInstance* script) { newScript = start_script_in_group(var, script->priority, 0, script->groupFlags); - newScript->ownerActorID = script->ownerActorID; - newScript->ownerID = script->ownerID; + newScript->owner1 = script->owner1; + newScript->owner2 = script->owner2; for (i = 0; i < ARRAY_COUNT(script->varTable); i++) { newScript->varTable[i] = script->varTable[i]; @@ -939,7 +939,7 @@ s32 _bound_script_trigger_handler(Trigger* trigger) { script->varTable[0] = trigger->scriptVars[0]; script->varTable[1] = trigger->scriptVars[1]; script->varTable[2] = trigger->scriptVars[2]; - script->ownerID = trigger; + script->owner2.trigger = trigger; } if (!does_script_exist(trigger->runningScriptID)) { @@ -988,7 +988,7 @@ ApiStatus DeleteTrigger(ScriptInstance* script, s32 isInitialCall) { } ApiStatus si_handle_unbind(ScriptInstance* script) { - delete_trigger(script->ownerID); + delete_trigger(script->owner2.trigger); return ApiStatus_DONE2; } @@ -1059,7 +1059,7 @@ void si_standard_trigger_executor(Trigger* trigger) { newScript->varTable[0] = trigger->scriptVars[0]; newScript->varTable[1] = trigger->scriptVars[1]; newScript->varTable[2] = trigger->scriptVars[2]; - newScript->ownerID = trigger; + newScript->owner2.trigger = trigger; } if (!does_script_exist(trigger->runningScriptID)) { diff --git a/src/world/area_isk/isk_02/978800.c b/src/world/area_isk/isk_02/978800.c index ba4bb373f9..41dd65ca48 100644 --- a/src/world/area_isk/isk_02/978800.c +++ b/src/world/area_isk/isk_02/978800.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_isk/isk_02/978800", func_802400F0_978800); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_isk/isk_04/97B670.c b/src/world/area_isk/isk_04/97B670.c index 40313a04a5..76df6567b8 100644 --- a/src/world/area_isk/isk_04/97B670.c +++ b/src/world/area_isk/isk_04/97B670.c @@ -12,6 +12,6 @@ INCLUDE_ASM(s32, "world/area_isk/isk_04/97B670", func_802403D4); INCLUDE_ASM(s32, "world/area_isk/isk_04/97B670", func_80240814); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_isk/isk_04/97B670", func_802408B4_97BEE4); diff --git a/src/world/area_isk/isk_08/984E30.c b/src/world/area_isk/isk_08/984E30.c index 86101c9330..ba9dbe0f54 100644 --- a/src/world/area_isk/isk_08/984E30.c +++ b/src/world/area_isk/isk_08/984E30.c @@ -12,6 +12,6 @@ INCLUDE_ASM(s32, "world/area_isk/isk_08/984E30", func_80240394); INCLUDE_ASM(s32, "world/area_isk/isk_08/984E30", func_802407D4); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_isk/isk_08/984E30", func_80240874); diff --git a/src/world/area_isk/isk_18/997F70.c b/src/world/area_isk/isk_18/997F70.c index 25c057fc06..ecc03abf2f 100644 --- a/src/world/area_isk/isk_18/997F70.c +++ b/src/world/area_isk/isk_18/997F70.c @@ -12,6 +12,6 @@ INCLUDE_ASM(s32, "world/area_isk/isk_18/997F70", func_80240394_998304); INCLUDE_ASM(s32, "world/area_isk/isk_18/997F70", func_802407D4_998744); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_isk/isk_18/997F70", func_80240874_9987E4); diff --git a/src/world/area_kpa/kpa_01/A470C0.c b/src/world/area_kpa/kpa_01/A470C0.c index ae27c8e2ed..6ffe914d07 100644 --- a/src/world/area_kpa/kpa_01/A470C0.c +++ b/src/world/area_kpa/kpa_01/A470C0.c @@ -12,6 +12,6 @@ INCLUDE_ASM(s32, "world/area_kpa/kpa_01/A470C0", func_802404F4); INCLUDE_ASM(s32, "world/area_kpa/kpa_01/A470C0", func_80240934); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kpa/kpa_01/A470C0", func_802409D4_A47934); diff --git a/src/world/area_kpa/kpa_03/A48720.c b/src/world/area_kpa/kpa_03/A48720.c index 9f2b7bdb5d..77d2d00e6c 100644 --- a/src/world/area_kpa/kpa_03/A48720.c +++ b/src/world/area_kpa/kpa_03/A48720.c @@ -12,7 +12,7 @@ INCLUDE_ASM(s32, "world/area_kpa/kpa_03/A48720", func_802404F4_A48AB4); INCLUDE_ASM(s32, "world/area_kpa/kpa_03/A48720", func_80240934_A48EF4); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kpa/kpa_03/A48720", func_802409D4_A48F94); diff --git a/src/world/area_kpa/kpa_113/A9CC70.c b/src/world/area_kpa/kpa_113/A9CC70.c index ac8819fa06..496891b3cb 100644 --- a/src/world/area_kpa/kpa_113/A9CC70.c +++ b/src/world/area_kpa/kpa_113/A9CC70.c @@ -16,6 +16,6 @@ INCLUDE_ASM(s32, "world/area_kpa/kpa_113/A9CC70", func_80240544_A9D174); INCLUDE_ASM(s32, "world/area_kpa/kpa_113/A9CC70", func_80240984_A9D5B4); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kpa/kpa_113/A9CC70", func_80240A24_A9D654); diff --git a/src/world/area_kzn/kzn_03/C61020.c b/src/world/area_kzn/kzn_03/C61020.c index 0b3fc40b84..e9a66200c6 100644 --- a/src/world/area_kzn/kzn_03/C61020.c +++ b/src/world/area_kzn/kzn_03/C61020.c @@ -12,7 +12,7 @@ INCLUDE_ASM(s32, "world/area_kzn/kzn_03/C61020", func_802406A4_C613B4); INCLUDE_ASM(s32, "world/area_kzn/kzn_03/C61020", func_80240AE4_C617F4); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kzn/kzn_03/C61020", func_80240B84_C61894); diff --git a/src/world/area_kzn/kzn_09/C77D00.c b/src/world/area_kzn/kzn_09/C77D00.c index 1274636a66..bd31db9c6b 100644 --- a/src/world/area_kzn/kzn_09/C77D00.c +++ b/src/world/area_kzn/kzn_09/C77D00.c @@ -42,7 +42,7 @@ INCLUDE_ASM(s32, "world/area_kzn/kzn_09/C77D00", func_80242D58); INCLUDE_ASM(s32, "world/area_kzn/kzn_09/C77D00", func_80243198_C79E78); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kzn/kzn_09/C77D00", func_80243238_C79F18); diff --git a/src/world/area_kzn/kzn_17/C85DC0.c b/src/world/area_kzn/kzn_17/C85DC0.c index efe6fbe633..e337c75937 100644 --- a/src/world/area_kzn/kzn_17/C85DC0.c +++ b/src/world/area_kzn/kzn_17/C85DC0.c @@ -42,7 +42,7 @@ INCLUDE_ASM(s32, "world/area_kzn/kzn_17/C85DC0", func_80242048); INCLUDE_ASM(s32, "world/area_kzn/kzn_17/C85DC0", func_80242488_C87F38); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_kzn/kzn_17/C85DC0", func_80242528_C87FD8); diff --git a/src/world/area_sbk/sbk_00/9292B0.c b/src/world/area_sbk/sbk_00/9292B0.c index 5d6a2f411c..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_00/9292B0.c +++ b/src/world/area_sbk/sbk_00/9292B0.c @@ -1,7 +1 @@ -#include "common.h" -#include "map.h" - -ApiStatus func_80240040_9292B0(ScriptInstance* script, s32 isInitialCall) { - script->ownerActorID->unk_B5 = 3; - return ApiStatus_DONE2; -} +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_01/929AD0.c b/src/world/area_sbk/sbk_01/929AD0.c index e7b53eb32d..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_01/929AD0.c +++ b/src/world/area_sbk/sbk_01/929AD0.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_01/929AD0", func_80240040_929AD0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_03/92F8F0.c b/src/world/area_sbk/sbk_03/92F8F0.c index e66ad4f435..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_03/92F8F0.c +++ b/src/world/area_sbk/sbk_03/92F8F0.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_03/92F8F0", func_80240040_92F8F0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_04/930510.c b/src/world/area_sbk/sbk_04/930510.c index f709f9cc01..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_04/930510.c +++ b/src/world/area_sbk/sbk_04/930510.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_04/930510", func_80240040_930510); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_05/930D30.c b/src/world/area_sbk/sbk_05/930D30.c index 003d13131f..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_05/930D30.c +++ b/src/world/area_sbk/sbk_05/930D30.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_05/930D30", func_80240040_930D30); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_11/934080.c b/src/world/area_sbk/sbk_11/934080.c index 669c25cdff..d49d96c170 100644 --- a/src/world/area_sbk/sbk_11/934080.c +++ b/src/world/area_sbk/sbk_11/934080.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_11/934080", func_80240040_934080); -INCLUDE_ASM(s32, "world/area_sbk/sbk_11/934080", func_80240140_934180); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_12/934D80.c b/src/world/area_sbk/sbk_12/934D80.c index 69fc34be9a..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_12/934D80.c +++ b/src/world/area_sbk/sbk_12/934D80.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_12/934D80", func_80240040_934D80); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_13/935820.c b/src/world/area_sbk/sbk_13/935820.c index f3d7a2216d..8b24f1bb11 100644 --- a/src/world/area_sbk/sbk_13/935820.c +++ b/src/world/area_sbk/sbk_13/935820.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_13/935820", func_80240040_935820); -INCLUDE_ASM(s32, "world/area_sbk/sbk_13/935820", func_80240140_935920); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_15/936D10.c b/src/world/area_sbk/sbk_15/936D10.c index a2f1448c45..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_15/936D10.c +++ b/src/world/area_sbk/sbk_15/936D10.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_15/936D10", func_80240040_936D10); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_22/939970.c b/src/world/area_sbk/sbk_22/939970.c index 92cb6c99e9..ee49fab3a9 100644 --- a/src/world/area_sbk/sbk_22/939970.c +++ b/src/world/area_sbk/sbk_22/939970.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_22/939970", func_80240040_939970); -INCLUDE_ASM(s32, "world/area_sbk/sbk_22/939970", func_80240140_939A70); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_26/93DD10.c b/src/world/area_sbk/sbk_26/93DD10.c index a1d7178790..85ca8d674f 100644 --- a/src/world/area_sbk/sbk_26/93DD10.c +++ b/src/world/area_sbk/sbk_26/93DD10.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_26/93DD10", func_80240040_93DD10); -INCLUDE_ASM(s32, "world/area_sbk/sbk_26/93DD10", func_80240140_93DE10); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_32/944AA0.c b/src/world/area_sbk/sbk_32/944AA0.c index 330debca07..9015629261 100644 --- a/src/world/area_sbk/sbk_32/944AA0.c +++ b/src/world/area_sbk/sbk_32/944AA0.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_32/944AA0", func_80240040_944AA0); -INCLUDE_ASM(s32, "world/area_sbk/sbk_32/944AA0", func_80240140_944BA0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_44/94D5E0.c b/src/world/area_sbk/sbk_44/94D5E0.c index 8b17b5b824..6190cc2076 100644 --- a/src/world/area_sbk/sbk_44/94D5E0.c +++ b/src/world/area_sbk/sbk_44/94D5E0.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_44/94D5E0", func_80240040_94D5E0); -INCLUDE_ASM(s32, "world/area_sbk/sbk_44/94D5E0", func_80240140_94D6E0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_46/94E9E0.c b/src/world/area_sbk/sbk_46/94E9E0.c index f455b6eef7..efd8c4e1b0 100644 --- a/src/world/area_sbk/sbk_46/94E9E0.c +++ b/src/world/area_sbk/sbk_46/94E9E0.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_46/94E9E0", func_80240040_94E9E0); -INCLUDE_ASM(s32, "world/area_sbk/sbk_46/94E9E0", func_80240140_94EAE0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_51/9509B0.c b/src/world/area_sbk/sbk_51/9509B0.c index 9d5e0a8b6d..9c4aa717af 100644 --- a/src/world/area_sbk/sbk_51/9509B0.c +++ b/src/world/area_sbk/sbk_51/9509B0.c @@ -2,4 +2,4 @@ INCLUDE_ASM(s32, "world/area_sbk/sbk_51/9509B0", func_80240040_9509B0); -INCLUDE_ASM(s32, "world/area_sbk/sbk_51/9509B0", func_80240140_950AB0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_53/951B20.c b/src/world/area_sbk/sbk_53/951B20.c index 51ae7d5336..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_53/951B20.c +++ b/src/world/area_sbk/sbk_53/951B20.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_53/951B20", func_80240040_951B20); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_55/952A90.c b/src/world/area_sbk/sbk_55/952A90.c index dbcfa38df9..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_55/952A90.c +++ b/src/world/area_sbk/sbk_55/952A90.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_55/952A90", func_80240040_952A90); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_60/956A30.c b/src/world/area_sbk/sbk_60/956A30.c index 20608e0dca..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_60/956A30.c +++ b/src/world/area_sbk/sbk_60/956A30.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_60/956A30", func_80240040_956A30); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_62/957390.c b/src/world/area_sbk/sbk_62/957390.c index ed28371a52..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_62/957390.c +++ b/src/world/area_sbk/sbk_62/957390.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_62/957390", func_80240040_957390); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_sbk/sbk_63/957DB0.c b/src/world/area_sbk/sbk_63/957DB0.c index 37d620bc18..41dd65ca48 100644 --- a/src/world/area_sbk/sbk_63/957DB0.c +++ b/src/world/area_sbk/sbk_63/957DB0.c @@ -1,3 +1 @@ -#include "common.h" - -INCLUDE_ASM(s32, "world/area_sbk/sbk_63/957DB0", func_80240040_957DB0); +#include "world/common/SetNpcB5_3.inc.c" diff --git a/src/world/area_tik/tik_12/88A530.c b/src/world/area_tik/tik_12/88A530.c index 1db5f9659e..083796bd84 100644 --- a/src/world/area_tik/tik_12/88A530.c +++ b/src/world/area_tik/tik_12/88A530.c @@ -12,6 +12,6 @@ INCLUDE_ASM(s32, "world/area_tik/tik_12/88A530", func_80241CF4); INCLUDE_ASM(s32, "world/area_tik/tik_12/88A530", func_80242134); -#include "world/common/AwaitPlayerNearNPC.inc.c" +#include "world/common/AwaitPlayerNearNpc.inc.c" INCLUDE_ASM(s32, "world/area_tik/tik_12/88A530", func_802421D4); diff --git a/src/world/common/AwaitPlayerNearNPC.inc.c b/src/world/common/AwaitPlayerNearNpc.inc.c similarity index 69% rename from src/world/common/AwaitPlayerNearNPC.inc.c rename to src/world/common/AwaitPlayerNearNpc.inc.c index 77426813fa..4e238f36b6 100644 --- a/src/world/common/AwaitPlayerNearNPC.inc.c +++ b/src/world/common/AwaitPlayerNearNpc.inc.c @@ -1,8 +1,8 @@ #include "common.h" -static ApiStatus AwaitPlayerNearNPC(ScriptInstance* script, s32 isInitialCall) { +static ApiStatus AwaitPlayerNearNpc(ScriptInstance* script, s32 isInitialCall) { PlayerStatus* playerStatus = PLAYER_STATUS; - Npc* npc = get_npc_safe(script->ownerID); + Npc* npc = get_npc_safe(script->owner2.npcID); if (dist2D(npc->pos.x, npc->pos.z, playerStatus->position.x, playerStatus->position.z) < 50.0f) { return ApiStatus_DONE2; diff --git a/src/world/common/SetNpcB5_3.inc.c b/src/world/common/SetNpcB5_3.inc.c new file mode 100644 index 0000000000..938904b750 --- /dev/null +++ b/src/world/common/SetNpcB5_3.inc.c @@ -0,0 +1,7 @@ +#include "common.h" +#include "map.h" + +static ApiStatus func_80240040_9292B0(ScriptInstance* script, s32 isInitialCall) { + script->owner1.enemy->unk_B5 = 3; + return ApiStatus_DONE2; +} diff --git a/src/world_goombaria.c b/src/world_goombaria.c index 14d843f948..dff0cc2fd4 100644 --- a/src/world_goombaria.c +++ b/src/world_goombaria.c @@ -6,25 +6,25 @@ void func_802BD100_324F10(Npc* npc) { } ApiStatus func_802BD114_324F10(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EECC4(ownerID); + func_800EECC4(owner); } - return func_800EECE8(ownerID) != 0; + return func_800EECE8(owner) != 0; } ApiStatus func_802BD14C_324F10(ScriptInstance* script, s32 isInitialCall) { PlayerData* playerData = &gPlayerData; - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - enable_partner_walking(ownerID, TRUE); + enable_partner_walking(owner, TRUE); } - func_800EBA3C(ownerID); - func_800EBB40(ownerID); + func_800EBA3C(owner); + func_800EBB40(owner); playerData->unk_2F4[PartnerId_GOOMBARIA]++; return ApiStatus_BLOCK; @@ -35,10 +35,10 @@ ApiStatus func_802BD1AC_324F10(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_802BD1B4(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EE994(ownerID); + func_800EE994(owner); } - return func_800EE9B8(ownerID) != 0; + return func_800EE9B8(owner) != 0; } diff --git a/src/world_goompa.c b/src/world_goompa.c index 245f423088..49d63e216f 100644 --- a/src/world_goompa.c +++ b/src/world_goompa.c @@ -6,12 +6,12 @@ void func_802BD100_324A10(Npc* npc) { } ApiStatus func_802BD114(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EECC4(ownerID); + func_800EECC4(owner); } - return func_800EECE8(ownerID) != 0; + return func_800EECE8(owner) != 0; } @@ -24,10 +24,10 @@ ApiStatus func_802BD524(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_802BD52C(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EE994(ownerID); + func_800EE994(owner); } - return func_800EE9B8(ownerID) != 0; + return func_800EE9B8(owner) != 0; } diff --git a/src/world_twink.c b/src/world_twink.c index 08f8d7a7fb..1fb4e6a25d 100644 --- a/src/world_twink.c +++ b/src/world_twink.c @@ -7,24 +7,24 @@ void func_802BD100_325070(Npc* npc) { } ApiStatus func_802BD110(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EECC4(ownerID); + func_800EECC4(owner); } - return func_800EECE8(ownerID) != 0; + return func_800EECE8(owner) != 0; } ApiStatus func_802BD148_325070(ScriptInstance* script, s32 isInitialCall) { PlayerData* playerData = &gPlayerData; - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - enable_partner_flying(ownerID, TRUE); + enable_partner_flying(owner, TRUE); } - update_player_move_history(ownerID); - func_800ED5D0(ownerID); + update_player_move_history(owner); + func_800ED5D0(owner); playerData->unk_2F4[PartnerId_TWINK]++; return ApiStatus_BLOCK; @@ -35,10 +35,10 @@ ApiStatus func_802BD1A8(ScriptInstance* script, s32 isInitialCall) { } ApiStatus func_802BD1B0(ScriptInstance* script, s32 isInitialCall) { - s32 ownerID = script->ownerID; + Npc* owner = script->owner2.npc; if (isInitialCall) { - func_800EE994(ownerID); + func_800EE994(owner); } - return func_800EE9B8(ownerID) != 0; + return func_800EE9B8(owner) != 0; }