#include "scenario_common.h" // Global variable int bStartGame = 0; int BossID = -1; int GuardID[4]; int GuardCount = 0; int Step = 0; /* // natu_38_lightning float fCurTime = 0; float fCycleTime = 0.5; float fEffectTime = -1; */ // cannon int CannonManID[8]; float AITimer = -1; int CannonID[8]; float CannonTimer[8]; float ReloadTime = 4; float ShootV[8]; ShootV[0] = 350; ShootV[1] = 420; ShootV[2] = 420; ShootV[3] = 350; ShootV[4] = -350; ShootV[5] = -300; ShootV[6] = -300; ShootV[7] = -350; int CannonToGuard[8]; int CannonWaypoint[8]; CannonWaypoint[0] = 49; CannonWaypoint[1] = 48; CannonWaypoint[2] = 47; CannonWaypoint[3] = 46; CannonWaypoint[4] = 53; CannonWaypoint[5] = 52; CannonWaypoint[6] = 51; CannonWaypoint[7] = 50; // Boss Position float BossX = 0; float BossY = -848; float BossZ = 270; // Partner Position SpawnPartnerX = 0; SpawnPartnerY = 0; SpawnPartnerZ = -50; // local variable int i; int LocID, ObjectID; float dx, dy, dz; // --------- // global // --------- /* void TurnOffnatu_38_lightning() { fEffectTime = -1; SetSceneLightFunction("Ambient", "function=none,min=1,max=1,value=1"); } */ void ShootBomb(float x, float y, float z, float vx, float vy, float vz) { ObjectID = SpawnItem("Bomb", x, y, z); ThrowItem(ObjectID, vx, vy, vz); Play3DSound("impa_01_bomb_small_01", x, y, z); } // --------- // Game // --------- void OnCache() { LoadScene("sw01s"); CacheLevelModel("boom02"); } void OnHostGame() { SetGameMaxTime(-1); InitScenario(); // spawn all guards for (i = 0 ; i < 4 ; i++) { // get guard location LocID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(LocID, x, y, z); GuardID[i] = SpawnChara("guard", x, y, z); SetCharaDart(GuardID[i], 1, 30); // set direction GetSceneItemRot(LocID, x, y, z); SetEntityRot(GuardID[i], x, y, z); } GuardCount = 4; // spawn boss BossID = SpawnChara("boss", BossX, BossY, BossZ); ShowEntity(BossID, 0); ActivateEntity(BossID, 0); // cannon for (i = 0 ; i < 8 ; i++) { CannonID[i] = FindItem(NumToStr("cannon_%02d", i)); CannonTimer[i] = 0; CannonToGuard[i] = 0; } var_aiLockCountLimit = 2; // mission SetMissionObjectiveText(0, MOBJ_SW01_1); SetMissionObjectiveText(1, MOBJ_SW01_2); SetMissionObjectiveText(2, MOBJ_SW01_3); var_uiGameOverVoice2 = NumToStr("onitsuka_d%d", rand()%4+1); PlaySound("bgs_08_warship"); // TurnOffnatu_38_lightning(); Print("Cutscene 13\n"); BeginCutscene("cutscene13"); bStartGame = 1; } void OnCharaDead(int id, int killer) { Print("Chara ", id, " is killed by ", killer, "\n"); // Player dead if (id == PlayerID) PlayerDead(); if (id == PartnerID) PartnerDead(); string CharaName = GetCharaString(id, CHARA_NAME); // guard if ( CharaName == "GUARD") { KillScore(0, 325); GuardCount--; Destroy(id); if (GuardCount == 0) { if (Step == 0) { Print("shortcut4-3\n"); BeginCutscene("shortcut4_3"); } else if (Step == 1) { Print("shortcut4-4\n"); BeginCutscene("shortcut4_4"); } } } else if ( CharaName == "CANNONGUARD") { for (i = 0 ; i < 8 ; i++) { if (CannonManID[i] == id) { KillScore(0, 325); GuardCount--; CannonManID[i] = 0; Destroy(id); if (GuardCount == 0) { Print("shortcut4-4\n"); BeginCutscene("shortcut4_4"); } break; } } } // boss if ( id == BossID) { KillScore(1, 1250); SetMissionObjectiveSwitch(0, 0); var_uiGameOverVoice2 = ""; // TurnOffnatu_38_lightning(); PlayAICutsceneCB("cutscene14", "GameComplete"); } // CharaReborn(id); } void OnTimeOver() { Print("TimeOver\n"); GameOver(GAMEOVER_LOSE); } void OnUpdate(float t) { CommonUpdate(t); if (bStartGame == 1) { bStartGame = 0; } // reload cannon for (i = 0 ; i < 8 ; i++) { if (CannonTimer[i] > 0) { CannonTimer[i] = CannonTimer[i] - t; } } for(i = 0 ; i < 8 ; i++) { if(CannonManID[i] > 0) { if(CannonToGuard[i] == 0) { if(Distance(CannonManID[i], PlayerID) < 300) { AIPerform(CannonManID[i], AI_PERFORM_NONE); ClearAIAllBehavior(CannonManID[i]); AI_Guard(PlayerID, CannonManID[i]); CannonToGuard[i] = 1; } } else { if(Distance(CannonManID[i], PlayerID) > 300) { AIPerform(CannonManID[i], AI_PERFORM_NONE); AIPerform(CannonManID[i], AI_PERFORM_MOVETOPOINT, CannonWaypoint[i]); AIPerform(CannonManID[i], AI_PERFORM_FACETO, CannonID[i]); ClearAIAllBehavior(CannonManID[i]); AI_Idle(PlayerID, CannonManID[i]); CannonToGuard[i] = 0; } } } } if (AITimer >= 0) { AITimer = AITimer + t; if ( (AITimer > ReloadTime/2) && (AITimer < ReloadTime*2) ) { for (i = 0 ; i < 8 ; i = i+2) { if(CannonToGuard[i] == 1) continue; GetEntityPos(CannonManID[i], x, y, z); GetEntityPos(CannonID[i], dx, dy, dz); x = x - dx; y = y - dy; z = z - dz; Print("Distance ", i, ": ", x*x+y*y+z*z, "\n"); if ( (x*x+y*y+z*z) > 5000) continue; AIPerform(CannonManID[i], AI_PERFORM_FACETO, CannonID[i]); // AIPerform(CannonManID[i], AI_PERFORM_ATTACK, "Y"); AIPerform(CannonManID[i], AI_PERFORM_INSPECT); } AITimer = ReloadTime*2; } else if ( (AITimer > 2.5*ReloadTime)) { for (i = 1 ; i < 8 ; i = i+2) { if(CannonToGuard[i] == 1) continue; GetEntityPos(CannonManID[i], x, y, z); GetEntityPos(CannonID[i], dx, dy, dz); x = x - dx; y = y - dy; z = z - dz; Print("Distance ", i, ": ", x*x+y*y+z*z, "\n"); if ( (x*x+y*y+z*z) > 5000) continue; AIPerform(CannonManID[i], AI_PERFORM_FACETO, CannonID[i]); // AIPerform(CannonManID[i], AI_PERFORM_ATTACK, "Y"); AIPerform(CannonManID[i], AI_PERFORM_INSPECT); } AITimer = 0; } } /* // natu_38_lightning fCurTime = fCurTime + t; if (fCurTime > fCycleTime) { PlaySound("natu_38_lightning"); SetSceneLightFunction("Ambient", "function=InvSawTooth,min=1,max=50,cycle0=0.1,cycle1=0.3,loop=1"); fEffectTime = 0; while (fCurTime > fCycleTime) fCurTime = fCurTime - fCycleTime; fCycleTime = (rand() % 10001)/10000.0; fCycleTime = 5.0 + fCycleTime*(15.0-5.0); } if (fEffectTime >= 0) fEffectTime = fEffectTime + t; if (fEffectTime > 0.9) { fEffectTime = -1; SetSceneLightFunction("Ambient", "function=none,min=1,max=1,value=1"); } if (fCurTime < 0.2) { for (i = 0 ; i < 2 ; i++) { ObjectID = FindItem(NumToStr("cannon_%02d", i)); GetEntityPos(ObjectID, x, y, z); GetEntityDir(ObjectID, dx, dy, dz); ShootBomb(x+30*dx, y+30*dy, z, 0, ShootV[i], 100); } } */ } /* void OnContinueGame() { CharaReborn(PlayerID); CharaReborn(PartnerID); TeleportChara(PlayerID, 127, 353, -130); SetEntityDir(PlayerID, 0, 1, 0); TeleportChara(PartnerID, -127, 326, -130); if (!bHatchOpen) { for (i = 0 ; i < 3 ; i++) { CharaReborn(GuardBID[i], 0); } GuardBCount = 3; } PlayMusic("s09_warship_bgm", 1, 1); SetAudioVariable(0, 0); bStartGame = 1; } */ // -------------------- // Cutscene Callback // -------------------- void CUTSCENE13_OnEnd() { PlayMusic("s09_warship_bgm", 1, 1); CutsceneEndPos3(-20.1, -10.8, -117.9, 0, 1, 0, 9.6, -16.2, -117.9, 0, 1, 0); } void SHORTCUT4_3_OnEnd() { // spawn all guards for (i = 0 ; i < 3 ; i++) { // get guard location LocID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(LocID, x, y, z); GuardID[i] = SpawnChara("guard", x, y, z); SetCharaDart(GuardID[i], 1, 30); // set direction GetSceneItemRot(LocID, x, y, z); SetEntityRot(GuardID[i], x, y, z); } // spawn cannon man again for (i = 0 ; i < 8 ; i++) { ObjectID = FindSceneItem(NumToStr("CANNONGUARD_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); if (CannonManID[i] > 0) { Destroy(CannonManID[i]); CannonManID[i] = 0; } CannonManID[i] = SpawnChara("cannonguard", x, y, z); SetAIAttrib(CannonManID[i], AI_LOOK_RANGE, 120); SetAIAttrib(CannonManID[i], AI_LOOK_ANGLE, 180); SetAIAttrib(CannonManID[i], AI_ATTACK_RANGE, 80); } GuardCount = 11; AITimer = 0; var_aiLockCountLimit = 2; } void SHORTCUT4_4_OnEnd() { // spawn all guards for (i = 0 ; i < 2 ; i++) { // get guard location LocID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(LocID, x, y, z); GuardID[i] = SpawnChara("guard", x, y, z); SetCharaDart(GuardID[i], 1, 30); // set direction GetSceneItemRot(LocID, x, y, z); SetEntityRot(GuardID[i], x, y, z); } // Show Boss ShowEntity(BossID, 1); ActivateEntity(BossID, 1); } // --------- // Enemy // --------- void GUARD_InitChara(int id) { NPCE15_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 150*HandicapHP); // 生命上限 SetCharaAttrib(id, CHARA_HP, 150*HandicapHP); // 生命 SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 42); } void GUARD_InitAI(int id) { AI_Guard(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 50*ResponseRate); } void CANNONGUARD_InitChara(int id) { NPCE15_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 150*HandicapHP); // 生命上限 SetCharaAttrib(id, CHARA_HP, 150*HandicapHP); // 生命 SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 72); } void CANNONGUARD_InitAI(int id) { AI_Idle(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 50*ResponseRate); } void BOSS_InitChara(int id) { // should be ce07 CE07_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 2000*HandicapHP); SetCharaAttrib(id, CHARA_HP, 2000*HandicapHP); SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 90); SetCharaDart(id, 3, 30); } void BOSS_InitAI(int id) { AI_Boss(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 100*ResponseRate); SetAIAttrib(id, AI_LOOK_RANGE, 50); SetAIAttrib(id, AI_ATTACK_RANGE, 100); // set AI behavior ClearAIAllBehavior(id); SetAIBehavior(id, AI_STATE_SEARCH, AI_SEARCH_IDLE, 100); SetAIBehavior(id, AI_STATE_LOCK, AI_LOCK_NEAREST_TARGET, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DIRECT, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_MOVE_SIDE, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DASH_BACK , 50); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_RANDOM, 10); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_COMBO, 90); UpdateAIAttrib(id); } // ------- // Door // ------- void DOORLEFT_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_MODEL, "sw01doorl", 1); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x-20, y, z); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_WAITTIME, 0); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 30); SetItemAttrib(id, ITEM_NEXTPOINT, 0); } void DOORRIGHT_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_MODEL, "sw01doorr", 1); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x+20, y, z); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_WAITTIME, 0); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 30); SetItemAttrib(id, ITEM_NEXTPOINT, 0); } void HATCHDOOR_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_MODEL, "sw01hdoor", 1); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x, y, z + 60); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_MACHINE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_WAITTIME, 0); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 100); SetItemAttrib(id, ITEM_NEXTPOINT, 1); } // --------- // Bomb // --------- void BOMB_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "boom02", 1); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_SLEEP); SetItemAttrib(id, ITEM_LIFTABLE, 1); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_MASS, 3); SetItemAttrib(id, ITEM_GRAVITY, -500); SetItemAttrib(id, ITEM_BOUNCE, 0.1); SetItemAttrib(id, ITEM_FRICTION, 0.5); SetItemAttrib(id, ITEM_DAMAGE, 25); // OLD 50 // SetItemAttrib(id, ITEM_LIGHT_SFX, "OBJ_Dart_Normal"); SetItemAttrib(id, ITEM_FLY_SFX, "OBJ_Bomb01Drag"); SetItemAttrib(id, ITEM_HITWALL_SFX, "OBJ_Bomb01Down"); } void BombExplode2(int id) { float x, y, z; GetEntityPos(id, x, y, z); SpawnAttackSFX("OBJ_Bomb01", x, y, z, 2, 200, 0, GetItemThrower(id)); Destroy(id); // BreakItem(id, 500); } void BOMB_OnHitWall(int id) { BombExplode2(id); } void BOMB_OnHitItem(int id, int item) { BombExplode2(id); } void BOMB_OnHitChara(int id, int c) { BombExplode2(id); } void BOMB_OnAttack(int id, int c, int damage) { BombExplode2(id); } // -------------- // Trigger // -------------- void CLTRGHINTSW011_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void CLTRGHINTSW011_OnTouch(int id, int charaId) { if (!IsLocalPlayerChara(charaId)) return; ShowHint(HINT_SW01_1); } // ------------- // Cannon // ------------- void CANNON_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "cannon", 1); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void CANNON_OnAttack(int id, int charaId, int damage) { for (i = 0 ; i < 8 ; i++) { if (CannonID[i] == id) break; } if (i >= 8) return; if (CannonTimer[i] <= 0) { GetEntityPos(id, x, y, z); GetEntityDir(id, dx, dy, dz); ShootBomb(x+90*dx, y+90*dy, z+10, 0, ShootV[i], 0); CannonTimer[i] = ReloadTime; } }