#include "sam_08.h"

#include "world/common/todo/PlayBigSmokePuff.inc.c"

API_CALLABLE(N(AdjustFightingSoundsPos)) {
    Bytecode* args = script->ptrReadPos;
    s32 x = evt_get_variable(script, *args++);
    s32 y = evt_get_variable(script, *args++);
    s32 z = evt_get_variable(script, *args++);

    // @bug need to use real sound id, not environmental sound id
    sfx_adjust_env_sound_pos(SOUND_8000006C, SOUND_SPACE_MODE_0, x, y, z);

    return ApiStatus_DONE2;
}

API_CALLABLE(N(StartFightingRumble)) {
    Bytecode* args = script->ptrReadPos;
    s32 rumbleFreq = evt_get_variable(script, *args++);
    s32 rumbleTime = evt_get_variable(script, *args++);

    start_rumble(rumbleFreq & 0xFF, rumbleTime & 0xFFFF);

    return ApiStatus_DONE2;
}

EvtScript N(EVS_TwoKoopesFightingFX) = {
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_01A, SOUND_8000006C, 0)
    EVT_LOOP(0)
        EVT_CALL(N(StartFightingRumble), 80, 10)
        EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_CALL(N(AdjustFightingSoundsPos), LVar0, LVar1, LVar2)
        EVT_WAIT(6)
    EVT_END_LOOP
    EVT_RETURN
    EVT_END
};

EvtScript N(EVS_Scene_ImposterAppears) = {
    EVT_CALL(DisablePlayerInput, TRUE)
    EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_CLEAR_BITS, COLLIDER_o47, COLLIDER_FLAGS_UPPER_MASK)
    EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_o47, COLLIDER_FLAG_IGNORE_SHELL)
    EVT_THREAD
        EVT_CALL(EnableModel, MODEL_m1_kabe, TRUE)
        EVT_CALL(PlaySoundAtCollider, COLLIDER_m1_kabe, SOUND_39B, 0)
        EVT_CALL(MakeLerp, -120, 0, 60, EASING_COS_IN_OUT)
        EVT_LABEL(0)
        EVT_CALL(UpdateLerp)
        EVT_CALL(TranslateGroup, MODEL_move1, 0, LVar0, 0)
        EVT_CALL(UpdateColliderTransform, COLLIDER_m1_kabe)
        EVT_WAIT(1)
        EVT_IF_EQ(LVar1, 1)
            EVT_GOTO(0)
        EVT_END_IF
    EVT_END_THREAD
    EVT_CALL(SetNpcFlagBits, NPC_PARTNER, NPC_FLAG_INVISIBLE, TRUE)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_01A, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_02A, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
    EVT_CALL(EnableNpcShadow, NPC_PARTNER, FALSE)
    EVT_CALL(GetNpcPos, NPC_PARTNER, LVar2, LVar3, LVar4)
    EVT_CALL(GetPlayerPos, LVar5, LVar6, LVar7)
    EVT_THREAD
        EVT_CALL(SetNpcPos, NPC_Kooper_01A, LVar2, LVar3, LVar4)
        EVT_SUB(LVar5, 30)
        EVT_CALL(MakeLerp, LVar2, LVar5, 20, EASING_QUADRATIC_OUT)
        EVT_LABEL(1)
        EVT_CALL(UpdateLerp)
        EVT_CALL(SetNpcPos, NPC_Kooper_01A, LVar0, LVar3, LVar4)
        EVT_WAIT(1)
        EVT_IF_EQ(LVar1, 1)
            EVT_GOTO(1)
        EVT_END_IF
    EVT_END_THREAD
    EVT_CALL(SetNpcPos, NPC_Kooper_02A, LVar2, LVar3, LVar4)
    EVT_SUB(LVar5, 60)
    EVT_CALL(MakeLerp, LVar2, LVar5, 20, EASING_QUADRATIC_OUT)
    EVT_LABEL(2)
    EVT_CALL(UpdateLerp)
    EVT_CALL(SetNpcPos, NPC_Kooper_02A, LVar0, LVar3, LVar4)
    EVT_WAIT(1)
    EVT_IF_EQ(LVar1, 1)
        EVT_GOTO(2)
    EVT_END_IF
    EVT_CALL(InterpPlayerYaw, 270, 0)
    EVT_WAIT(70)
    EVT_CALL(DisablePartnerAI, 0)
    EVT_CALL(SetNpcPos, NPC_PARTNER, NPC_DISPOSE_LOCATION)
    EVT_CALL(SetNpcFlagBits, NPC_PARTNER, NPC_FLAG_INACTIVE, TRUE)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Idle)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Idle)
    EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, 270, 0)
    EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, 90, 0)
    EVT_WAIT(15)
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_02A, SOUND_263, 0)
    EVT_CALL(ShowEmote, NPC_Kooper_02A, EMOTE_QUESTION, 45, 20, EMOTER_NPC, 0, 0, 0, 0)
    EVT_WAIT(15)
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_01A, SOUND_263, 0)
    EVT_CALL(ShowEmote, NPC_Kooper_01A, EMOTE_QUESTION, 0, 20, EMOTER_NPC, 0, 0, 0, 0)
    EVT_WAIT(15)
    EVT_CALL(PlaySoundAtPlayer, SOUND_263, 0)
    EVT_CALL(ShowEmote, 0, EMOTE_QUESTION, -45, 20, EMOTER_PLAYER, 0, 0, 0, 0)
    EVT_WAIT(15)
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_02A, SOUND_263, 0)
    EVT_CALL(ShowEmote, NPC_Kooper_02A, EMOTE_QUESTION, 45, 20, EMOTER_NPC, 0, 0, 0, 0)
    EVT_WAIT(15)
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_01A, SOUND_263, 0)
    EVT_CALL(ShowEmote, NPC_Kooper_01A, EMOTE_QUESTION, 0, 20, EMOTER_NPC, 0, 0, 0, 0)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Idle, ANIM_WorldKooper_Idle, 5, MSG_CH7_011F)
    EVT_THREAD
        EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Jump)
        EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(1.0))
        EVT_CALL(NpcJump1, NPC_Kooper_01A, -1062, -120, -37, 15)
        EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Idle)
    EVT_END_THREAD
    EVT_THREAD
        EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Jump)
        EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(1.0))
        EVT_CALL(NpcJump1, NPC_Kooper_02A, -1172, -120, -37, 15)
        EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Idle)
    EVT_END_THREAD
    EVT_WAIT(5)
    EVT_CALL(ShowMessageAtScreenPos, MSG_CH7_0120, 160, 40)
    EVT_WAIT(20)
    EVT_CALL(SetCamLeadPlayer, CAM_DEFAULT, FALSE)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar1, LVar2, LVar3)
    EVT_CALL(GetPlayerPos, LVar4, LVar5, LVar6)
    EVT_ADD(LVar1, LVar4)
    EVT_ADD(LVar2, LVar5)
    EVT_ADD(LVar3, LVar6)
    EVT_DIVF(LVar1, EVT_FLOAT(2.0))
    EVT_DIVF(LVar2, EVT_FLOAT(2.0))
    EVT_DIVF(LVar3, EVT_FLOAT(2.0))
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar1, LVar2, LVar3)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar1, LVar2, LVar3)
    EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(250.0))
    EVT_CALL(SetCamPitch, CAM_DEFAULT, EVT_FLOAT(15.0), EVT_FLOAT(-8.0))
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0121)
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar7, LVar8, LVar9)
    EVT_ADD(LVar7, LVar4)
    EVT_ADD(LVar8, LVar5)
    EVT_ADD(LVar9, LVar6)
    EVT_DIVF(LVar7, EVT_FLOAT(2.0))
    EVT_DIVF(LVar8, EVT_FLOAT(2.0))
    EVT_DIVF(LVar9, EVT_FLOAT(2.0))
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar7, LVar8, LVar9)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.5))
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0122)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar1, LVar2, LVar3)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0123)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar7, LVar8, LVar9)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0124)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar1, LVar2, LVar3)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0125)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar7, LVar8, LVar9)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0126)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar1, LVar2, LVar3)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0127)
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(400.0))
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0128)
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_0129)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_01A, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_02A, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
    EVT_CALL(DisablePlayerInput, FALSE)
    EVT_CALL(SetPlayerFlagBits, PS_FLAG_NO_CHANGE_PARTNER | PS_FLAG_NO_PARTNER_USAGE, TRUE)
    EVT_UNBIND
    EVT_RETURN
    EVT_END
};

EvtScript N(EVS_Scene_HitTrueKooper) = {
    EVT_CALL(DisablePlayerInput, TRUE)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Hurt)
    EVT_WAIT(20)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Idle)
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar0, LVar1, LVar2)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar3, LVar4, LVar5)
    EVT_ADDF(LVar0, LVar3)
    EVT_ADDF(LVar1, LVar4)
    EVT_ADDF(LVar2, LVar5)
    EVT_DIVF(LVar0, 2)
    EVT_DIVF(LVar1, 2)
    EVT_DIVF(LVar2, 2)
    EVT_SETF(LVar6, LVar0)
    EVT_SETF(LVar7, LVar1)
    EVT_SETF(LVar8, LVar2)
    EVT_ADDF(LVar0, LVar3)
    EVT_ADDF(LVar1, LVar4)
    EVT_ADDF(LVar2, LVar5)
    EVT_DIVF(LVar0, EVT_FLOAT(2.0))
    EVT_DIVF(LVar1, EVT_FLOAT(2.0))
    EVT_DIVF(LVar2, EVT_FLOAT(2.0))
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(250.0))
    EVT_CALL(SetCamPitch, CAM_DEFAULT, EVT_FLOAT(15.0), EVT_FLOAT(-8.0))
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(3.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkSad, ANIM_WorldKooper_StillSad, 0, MSG_CH7_012C)
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar0, LVar1, LVar2)
    EVT_SETF(LVar3, LVar6)
    EVT_SETF(LVar4, LVar7)
    EVT_SETF(LVar5, LVar8)
    EVT_ADDF(LVar3, LVar0)
    EVT_ADDF(LVar4, LVar1)
    EVT_ADDF(LVar5, LVar2)
    EVT_DIVF(LVar3, EVT_FLOAT(2.0))
    EVT_DIVF(LVar4, EVT_FLOAT(2.0))
    EVT_DIVF(LVar5, EVT_FLOAT(2.0))
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.5))
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_CelebrateLoop, ANIM_WorldKooper_Idle, 0, MSG_CH7_012D)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
    EVT_SETF(LVar3, LVar6)
    EVT_SETF(LVar4, LVar7)
    EVT_SETF(LVar5, LVar8)
    EVT_ADDF(LVar3, LVar0)
    EVT_ADDF(LVar4, LVar1)
    EVT_ADDF(LVar5, LVar2)
    EVT_DIVF(LVar3, EVT_FLOAT(2.0))
    EVT_DIVF(LVar4, EVT_FLOAT(2.0))
    EVT_DIVF(LVar5, EVT_FLOAT(2.0))
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_TalkSad, ANIM_WorldKooper_StillSad, 0, MSG_CH7_012E)
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar0, LVar1, LVar2)
    EVT_SETF(LVar3, LVar6)
    EVT_SETF(LVar4, LVar7)
    EVT_SETF(LVar5, LVar8)
    EVT_ADDF(LVar3, LVar0)
    EVT_ADDF(LVar4, LVar1)
    EVT_ADDF(LVar5, LVar2)
    EVT_DIVF(LVar3, EVT_FLOAT(2.0))
    EVT_DIVF(LVar4, EVT_FLOAT(2.0))
    EVT_DIVF(LVar5, EVT_FLOAT(2.0))
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.5))
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_TalkHappy, ANIM_WorldKooper_Idle, 0, MSG_CH7_012F)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_01A, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_02A, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar3, LVar4, LVar5)
    EVT_CALL(GetAngleBetweenNPCs, NPC_Kooper_01A, NPC_Kooper_02A, LVar9)
    EVT_CALL(GetDist2D, LVarA, LVar0, LVar2, LVar3, LVar5)
    EVT_MULF(LVarA, EVT_FLOAT(0.6))
    EVT_CALL(AddVectorPolar, LVar0, LVar2, LVarA, LVar9)
    EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(1.0))
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Jump)
    EVT_CALL(NpcJump0, NPC_Kooper_01A, LVar0, LVar1, LVar2, 20)
    EVT_CALL(NpcJump0, NPC_Kooper_01A, LVar3, LVar4, LVar5, 10)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(400.0))
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_EXEC_GET_TID(N(EVS_TwoKoopesFightingFX), MV_KoopersFightingScript)
    EVT_THREAD
        EVT_CALL(SetPlayerSpeed, EVT_FLOAT(3.0))
        EVT_CALL(PlayerMoveTo, LVar6, LVar8, 0)
    EVT_END_THREAD
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Run)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Run)
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_LOOP(3)
        EVT_CALL(GetNpcYaw, NPC_Kooper_01A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, LVar0, 0)
        EVT_CALL(GetNpcYaw, NPC_Kooper_02A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, LVar0, 0)
        EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_WAIT(5)
    EVT_END_LOOP
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_ADD(LVar2, -30)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_THREAD
        EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(1.0))
        EVT_CALL(NpcJump1, NPC_Kooper_01A, LVar0, LVar1, LVar2, 20)
    EVT_END_THREAD
    EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(1.0))
    EVT_CALL(NpcJump1, NPC_Kooper_02A, LVar0, LVar1, LVar2, 20)
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_LOOP(3)
        EVT_CALL(GetNpcYaw, NPC_Kooper_01A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, LVar0, 0)
        EVT_CALL(GetNpcYaw, NPC_Kooper_02A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, LVar0, 0)
        EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_WAIT(5)
    EVT_END_LOOP
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_ADD(LVar0, 55)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_THREAD
        EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(0.0))
        EVT_CALL(NpcJump1, NPC_Kooper_01A, LVar0, LVar1, LVar2, 20)
    EVT_END_THREAD
    EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(0.0))
    EVT_CALL(NpcJump1, NPC_Kooper_02A, LVar0, LVar1, LVar2, 20)
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_LOOP(5)
        EVT_CALL(GetNpcYaw, NPC_Kooper_01A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, LVar0, 0)
        EVT_CALL(GetNpcYaw, NPC_Kooper_02A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, LVar0, 0)
        EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_WAIT(4)
    EVT_END_LOOP
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.0))
    EVT_ADD(LVar2, 30)
    EVT_THREAD
        EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(1.0))
        EVT_CALL(NpcJump1, NPC_Kooper_01A, LVar0, LVar1, LVar2, 20)
    EVT_END_THREAD
    EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(1.0))
    EVT_CALL(NpcJump1, NPC_Kooper_02A, LVar0, LVar1, LVar2, 20)
    EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
    EVT_LOOP(6)
        EVT_CALL(GetNpcYaw, NPC_Kooper_01A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, LVar0, 0)
        EVT_CALL(GetNpcYaw, NPC_Kooper_02A, LVar0)
        EVT_ADD(LVar0, 180)
        EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, LVar0, 0)
        EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_WAIT(6)
    EVT_END_LOOP
    EVT_CALL(StopSound, SOUND_8000006C)
    EVT_KILL_THREAD(MV_KoopersFightingScript)
    EVT_CALL(RandInt, 100, LVar0)
    EVT_IF_GT(LVar0, 50)
        EVT_THREAD
            EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, 270, 0)
            EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(2.0))
            EVT_CALL(NpcJump1, NPC_Kooper_01A, -1062, -120, -37, 15)
        EVT_END_THREAD
        EVT_THREAD
            EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, 90, 0)
            EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(2.0))
            EVT_CALL(NpcJump1, NPC_Kooper_02A, -1172, -120, -37, 15)
        EVT_END_THREAD
    EVT_ELSE
        EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
        EVT_THREAD
            EVT_CALL(InterpNpcYaw, NPC_Kooper_01A, 90, 0)
            EVT_CALL(SetNpcJumpscale, NPC_Kooper_01A, EVT_FLOAT(2.0))
            EVT_CALL(NpcJump1, NPC_Kooper_01A, -1172, -120, -37, 15)
        EVT_END_THREAD
        EVT_THREAD
            EVT_CALL(InterpNpcYaw, NPC_Kooper_02A, 270, 0)
            EVT_CALL(SetNpcJumpscale, NPC_Kooper_02A, EVT_FLOAT(2.0))
            EVT_CALL(NpcJump1, NPC_Kooper_02A, -1062, -120, -37, 15)
        EVT_END_THREAD
    EVT_END_IF
    EVT_WAIT(30)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Idle)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Idle)
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar3, LVar4, LVar5)
    EVT_ADDF(LVar3, LVar0)
    EVT_ADDF(LVar4, LVar1)
    EVT_ADDF(LVar5, LVar2)
    EVT_DIVF(LVar3, EVT_FLOAT(2.0))
    EVT_DIVF(LVar4, EVT_FLOAT(2.0))
    EVT_DIVF(LVar5, EVT_FLOAT(2.0))
    EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar6, LVar7, LVar8)
    EVT_ADDF(LVar6, LVar0)
    EVT_ADDF(LVar7, LVar1)
    EVT_ADDF(LVar8, LVar2)
    EVT_DIVF(LVar6, EVT_FLOAT(2.0))
    EVT_DIVF(LVar7, EVT_FLOAT(2.0))
    EVT_DIVF(LVar8, EVT_FLOAT(2.0))
    EVT_CALL(RandInt, 100, LVar0)
    EVT_IF_GT(LVar0, 50)
        EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar3, LVar4, LVar5)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
        EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(205.0))
        EVT_CALL(SetCamPitch, CAM_DEFAULT, EVT_FLOAT(15.0), EVT_FLOAT(-9.0))
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
        EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0125)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar6, LVar7, LVar8)
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.5))
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0124)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0127)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar6, LVar7, LVar8)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0126)
        EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
        EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
        EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(400.0))
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
        EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0129)
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0128)
    EVT_ELSE
        EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar6, LVar7, LVar8)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar6, LVar7, LVar8)
        EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(205.0))
        EVT_CALL(SetCamPitch, CAM_DEFAULT, EVT_FLOAT(15.0), EVT_FLOAT(-9.0))
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
        EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0124)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0125)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar6, LVar7, LVar8)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0126)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar3, LVar4, LVar5)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0127)
        EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
        EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
        EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
        EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(400.0))
        EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(90.0))
        EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
        EVT_CALL(WaitForCam, CAM_DEFAULT, EVT_FLOAT(1.0))
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_02A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_02A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0128)
        EVT_CALL(PlayerFaceNpc, NPC_Kooper_01A, FALSE)
        EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 0, MSG_CH7_0129)
    EVT_END_IF
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_01A, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
    EVT_CALL(SetNpcFlagBits, NPC_Kooper_02A, NPC_FLAG_IGNORE_PLAYER_COLLISION, FALSE)
    EVT_CALL(DisablePlayerInput, FALSE)
    EVT_CALL(SetPlayerFlagBits, PS_FLAG_NO_CHANGE_PARTNER | PS_FLAG_NO_PARTNER_USAGE, TRUE)
    EVT_RETURN
    EVT_END
};

EvtScript N(EVS_Scene_HitFakeKooper) = {
    EVT_CALL(DisablePlayerInput, TRUE)
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetCamDistance, CAM_DEFAULT, EVT_FLOAT(250.0))
    EVT_CALL(SetCamPitch, CAM_DEFAULT, EVT_FLOAT(15.0), EVT_FLOAT(-8.0))
    EVT_CALL(SetCamSpeed, CAM_DEFAULT, EVT_FLOAT(2.0))
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 1)
    EVT_CALL(SetNpcAnimation, NPC_Kooper_02A, ANIM_WorldKooper_Hurt)
    EVT_WAIT(20)
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_02A, SOUND_20B8, 0)
    EVT_LOOP(10)
        EVT_CALL(GetNpcPos, NPC_Kooper_02A, LVar0, LVar1, LVar2)
        EVT_ADD(LVar2, 3)
        EVT_CALL(N(PlayBigSmokePuff), LVar0, LVar1, LVar2)
        EVT_WAIT(5)
    EVT_END_LOOP
    EVT_CALL(PlaySoundAtNpc, NPC_Kooper_02A, SOUND_SMOKE_BURST, 0)
    EVT_CALL(SetNpcPos, NPC_Kooper_02A, NPC_DISPOSE_LOCATION)
    EVT_CALL(EnableNpcShadow, NPC_Kooper_02A, FALSE)
    EVT_CALL(SetNpcPos, NPC_Duplighost, LVar0, LVar1, LVar2)
    EVT_CALL(MakeLerp, 0, 2880, 40, EASING_QUADRATIC_OUT)
    EVT_LABEL(1)
    EVT_CALL(UpdateLerp)
    EVT_CALL(SetNpcRotation, NPC_Duplighost, 0, LVar0, 0)
    EVT_WAIT(1)
    EVT_IF_EQ(LVar1, 1)
        EVT_GOTO(1)
    EVT_END_IF
    EVT_CALL(GetAngleToPlayer, NPC_Duplighost, LVar0)
    EVT_CALL(InterpNpcYaw, NPC_Duplighost, LVar0, 0)
    EVT_THREAD
        EVT_SET(MF_KooperDoneMoving, FALSE)
        EVT_CALL(GetAngleToNPC, NPC_Kooper_01A, LVar0)
        EVT_CALL(GetPlayerPos, LVar1, LVar2, LVar3)
        EVT_CALL(AddVectorPolar, LVar1, LVar3, EVT_FLOAT(40.0), LVar0)
        EVT_CALL(SetNpcSpeed, NPC_Kooper_01A, EVT_FLOAT(3.0))
        EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Run)
        EVT_CALL(SetNpcFlagBits, NPC_Kooper_01A, NPC_FLAG_IGNORE_PLAYER_COLLISION, TRUE)
        EVT_CALL(NpcMoveTo, NPC_Kooper_01A, LVar1, LVar3, 0)
        EVT_CALL(SetNpcAnimation, NPC_Kooper_01A, ANIM_WorldKooper_Idle)
        EVT_SET(MF_KooperDoneMoving, TRUE)
    EVT_END_THREAD
    EVT_CALL(PlayerFaceNpc, NPC_Duplighost, FALSE)
    EVT_CALL(SpeakToPlayer, NPC_Duplighost, ANIM_Duplighost_Anim05, ANIM_Duplighost_Anim02, 0, MSG_CH7_0130)
    EVT_LABEL(0)
    EVT_IF_EQ(MF_KooperDoneMoving, FALSE)
        EVT_WAIT(1)
        EVT_GOTO(0)
    EVT_END_IF
    EVT_CALL(SpeakToPlayer, NPC_Kooper_01A, ANIM_WorldKooper_Talk, ANIM_WorldKooper_Idle, 5, MSG_CH7_0131)
    EVT_WAIT(10)
    EVT_CALL(SpeakToPlayer, NPC_Duplighost, ANIM_Duplighost_Anim05, ANIM_Duplighost_Anim02, 0, MSG_CH7_0132)
    EVT_CALL(SetNpcAnimation, NPC_Duplighost, ANIM_Duplighost_Anim06)
    EVT_CALL(GetPlayerPos, LVar0, LVar1, LVar2)
    EVT_CALL(UseSettingsFrom, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(SetPanTarget, CAM_DEFAULT, LVar0, LVar1, LVar2)
    EVT_CALL(PanToTarget, CAM_DEFAULT, 0, 0)
    EVT_CALL(GetNpcPos, NPC_Kooper_01A, LVar0, LVar1, LVar2)
    EVT_CALL(SetNpcPos, NPC_Kooper_01A, NPC_DISPOSE_LOCATION)
    EVT_CALL(EnableNpcShadow, NPC_Kooper_01A, FALSE)
    EVT_CALL(SetNpcPos, NPC_PARTNER, LVar0, LVar1, LVar2)
    EVT_CALL(GetNpcYaw, NPC_Kooper_01A, LVar0)
    EVT_CALL(SetNpcYaw, NPC_PARTNER, LVar0)
    EVT_CALL(SetNpcFlagBits, NPC_PARTNER, NPC_FLAG_INVISIBLE | NPC_FLAG_INACTIVE, FALSE)
    EVT_CALL(EnableNpcShadow, NPC_PARTNER, TRUE)
    EVT_CALL(EnablePartnerAI)
    EVT_CALL(SetNpcVar, NPC_Duplighost, 0, 1)
    EVT_RETURN
    EVT_END
};

EvtScript N(EVS_SetupBridge) = {
    EVT_CALL(ParentColliderToModel, COLLIDER_m1_kabe, MODEL_m1_kabe)
    EVT_IF_LT(GB_StoryProgress, STORY_CH7_DEFEATED_FIRST_DUPLIGHOST)
        EVT_CALL(TranslateGroup, MODEL_move1, 0, -120, 0)
        EVT_CALL(UpdateColliderTransform, COLLIDER_m1_kabe)
        EVT_CALL(EnableModel, MODEL_m1_kabe, FALSE)
        EVT_BIND_TRIGGER(EVT_PTR(N(EVS_Scene_ImposterAppears)), TRIGGER_AREA_FLAG_SET, AF_SAM_06, 1, 0)
    EVT_END_IF
    EVT_RETURN
    EVT_END
};
