#include "scenario_common.h" // Global variable int bStartGame = 0; int GuardID[9]; int CaptainID[6]; int EnemyID[7]; int CheckPointNum = 13; int CheckPointID[CheckPointNum]; int CurrentCheckPoint = -1; int NumGuard = -1; int bGetKey = 0; // test int Counter = 0; // SFX float LavaTimer = 0; int DistortionTimer = 0; // Partner Position SpawnPartnerX = 100; SpawnPartnerY = 13; SpawnPartnerZ = 60; // local variable int i, ObjectID; void PlayLavaSFX(); void PlayDistortionSFX(); // --------- // Game // --------- void OnCache() { LoadScene("se05"); // CacheLevelModel(""); CacheLevelModel("se05key01"); CacheLevelCharacter("ce12"); CacheLevelCharacter("ce13"); CacheLevelCharacter("ce14"); } void OnHostGame() { SetGameMaxTime(-1); SetAudioVariable(0,1000); InitScenario(); // get check point id for (i = 0; i < CheckPointNum ; i++) { CheckPointID[i] = FindItem(NumToStr("JUMPZONE_%02d", i)); } float dx, dy, dz; // spawn all guards for (i = 0 ; i < 3 ; i++) { // get guard location ObjectID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); GuardID[i] = SpawnChara("GUARD", x, y, z, dx); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(GuardID[i], x, y, z); } SetAIAttrib(GuardID[0], AI_PATROL_POINT, 4, 5, 6, 7); SetAIAttrib(GuardID[1], AI_PATROL_POINT, 99, 98, 114); SetAIAttrib(GuardID[2], AI_PATROL_POINT, 97, 98, 100); // spawn all guard captains for (i = 0 ; i < 1 ; i++) { // get captain location ObjectID = FindSceneItem(NumToStr("CAPTAIN_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); CaptainID[i] = SpawnChara("CAPTAIN", x, y, z, dx); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(CaptainID[i], x, y, z); } SetAIAttrib(CaptainID[0], AI_PATROL_POINT, 108, 109, 110, 111, 112, 113); var_aiLockCountLimit = 4; SetMissionObjectiveText(0, MOBJ_SE05_1); SetMissionObjectiveText(1, MOBJ_SE05_2); Print("Cutscene09\n"); BeginCutscene("cutscene09"); bStartGame = 1; } void CUTSCENE09_OnEnd() { ObjectID = FindSceneItem("LAVA"); GetSceneItemPos(ObjectID, x, y, z); ObjectID = FindItem("LAVA"); SetEntityPos(ObjectID, x, y, z); SetItemMachine(ObjectID, 1); ObjectID = FindItem("TriggerLava"); SetItemMachine(ObjectID, 1); PlayMusic("s07_castle_bgm", 1, 1); SetAudioVariable(0, 0); CutsceneEndPos3(78, 211, 27.8, -0.9, -0.4, 0, 93.4, 180.7, 27.8, -0.9, 0.3, 0); } void OnCharaDead(int id, int killer) { Print("Chara ", id, " is killed by ", killer, "\n"); // Player dead if (id == PlayerID) PlayerDead(); if (id == PartnerID) PartnerDead(); if ( (NumGuard >= 0) && (NumGuard < 7) ) { for (i = 0 ; i < 7 ; i++) { if (id == EnemyID[i]) { EnemyID[i] = -1; NumGuard++; break; } } if (NumGuard == 7) SpawnItem("key", 840, 600, 1010); } string charaName = GetCharaString(id, CHARA_NAME); if (charaName == "GUARD") { for (i = 0 ; i < 9 ; i++) { if (id == GuardID[i]) { GuardID[i] = -1; break; } } KillScore(0, 225); Destroy(id); } else if (charaName == "CAPTAIN") { for (i = 0 ; i < 6 ; i++) { if (id == CaptainID[i]) { CaptainID[i] = -1; break; } } KillScore(0, 250); Destroy(id); } else if (charaName == "GENERAL") { KillScore(0, 275); Destroy(id); } // CharaReborn(id); } void OnTimeOver() { Print("TimeOver\n"); GameOver(GAMEOVER_LOSE); } void OnUpdate(float t) { if (bStartGame == 1) { SetAudioVariable(0, 1000); bStartGame = 0; } LavaTimer = LavaTimer + t; if (LavaTimer > 2) { // play lava sfx PlayLavaSFX(); PlayLavaSFX(); PlayLavaSFX(); // reset timer LavaTimer = (rand()%200)/100.0 - 1; } PlayDistortionSFX(); } void SHORTCUT_AMBUSH_OnEnd(); void OnContinueGame() { // reborn player CharaReborn(PlayerID); TeleportChara(PlayerID, 825, 1290, 860); CharaReborn(PartnerID); // destroy guard for (i = 0 ; i < 6 ; i++) { if (EnemyID[i] > 0) { Destroy(EnemyID[i]); EnemyID[i] = -1; } } // destroy key ObjectID = FindItem("key"); if (ObjectID > 0) Destroy(ObjectID); bGetKey = 0; ShowMissionItem(0, 0); SHORTCUT_AMBUSH_OnEnd(); PlayMusic("s07_castle_bgm", 1, 1); SetAudioVariable(0, 0); bStartGame = 1; } // --------- // Enemy // --------- void GUARD_InitChara(int id) { // ce12 NPCE12_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 150*HandicapHP); // 生命上限 SetCharaAttrib(id, CHARA_HP, 150*HandicapHP); // 生命 SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 22); SetCharaDart(id, 2, 30); } void GUARD_InitAI(int id) { AI_Guard(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 50*ResponseRate); // set AI behavior ClearAIAllBehavior(id); SetAIBehavior(id, AI_STATE_SEARCH, AI_SEARCH_PATROL, 50); SetAIBehavior(id, AI_STATE_LOCK, AI_LOCK_NEAREST_TARGET, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DIRECT, 50); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_RANDOM, 50); UpdateAIAttrib(id); } void CAPTAIN_InitChara(int id) { // ce13 NPCE13_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 300*HandicapHP); // 生命上限 SetCharaAttrib(id, CHARA_HP, 300*HandicapHP); // 生命 SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 72); } void CAPTAIN_InitAI(int id) { AI_Captain(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 60*ResponseRate); // set AI behavior ClearAIAllBehavior(id); SetAIBehavior(id, AI_STATE_SEARCH, AI_SEARCH_PATROL, 50); SetAIBehavior(id, AI_STATE_LOCK, AI_LOCK_NEAREST_TARGET, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DIRECT, 50); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_RANDOM, 60); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_COMBO, 40); UpdateAIAttrib(id); } void GENERAL_InitChara(int id) { // ce14 NPCE14_InitChara(id); SetCharaAttrib(id, CHARA_MAX_HP, 300*HandicapHP); // 生命上限 SetCharaAttrib(id, CHARA_HP, 300*HandicapHP); // 生命 SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 62); } void GENERAL_InitAI(int id) { AI_Captain(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 70*ResponseRate); } // -------------- // Trigger // -------------- void TRIGGER_YAMAHALLDOOR_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (bGetKey) { SetMissionObjectiveSwitch(1, 0); // Play cutscene 10 Print("cutscene10\n"); PlayAICutsceneCB("cutscene10", "GameComplete"); ActivateEntity(id, 0); } } void TRIGGER_AMBUSH_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; CurrentCheckPoint = 99; // destroy emeny for (i = 0 ; i < 9 ; i++) { if (GuardID[i] > 0) { Destroy(GuardID[i]); GuardID[i] = -1; } } for (i = 0 ; i < 6 ; i++) { if (CaptainID[i] > 0) { Destroy(CaptainID[i]); CaptainID[i] = -1; } } SetMissionObjectiveSwitch(0, 0); PlayAICutsceneCB("shortcut_ambush", "shortcut_ambush"); ActivateEntity(id, 0); } void SHORTCUT_AMBUSH_OnEnd() { float dx, dy, dz; CutsceneEndPos(847.95, 1234.47, 839.95, -0.2, -0.98, 0, 847.95, 1234.47, 839.95, -0.2, -0.98, 0, 847.95, 1234.47, 839.95, -0.2, -0.98, 0, 824.94, 1230.88, 839.93, 0.9, -0.44, 0); ObjectID = FindSceneItem("general_00"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[0] = SpawnChara("general", x, y, z, dx); ObjectID = FindSceneItem("captain_06"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[1] = SpawnChara("captain", x, y, z, dx); ObjectID = FindSceneItem("captain_07"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[2] = SpawnChara("captain", x, y, z, dx); ObjectID = FindSceneItem("guard_09"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[3] = SpawnChara("guard", x, y, z, dx); ObjectID = FindSceneItem("guard_10"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[4] = SpawnChara("guard", x, y, z, dx); ObjectID = FindSceneItem("guard_11"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[5] = SpawnChara("guard", x, y, z, dx); ObjectID = FindSceneItem("guard_12"); GetSceneItemPos(ObjectID, x, y, z); GetSceneItemRot(ObjectID, dx, dy, dz); EnemyID[6] = SpawnChara("guard", x, y, z, dx); NumGuard = 0; bContinue = 1; } void HINTSE051_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void HINTSE051_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; ShowHint(HINT_SE05_1); } void HINTSE052_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void HINTSE052_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; ShowHint(HINT_SE05_2); } // ----------------- // Cheat Jumpzone // ----------------- void CheckGuard(int idx) { if ( (idx == 2) || (idx == 3) ) { for (i = 3 ; i < 6 ; i++) { if (GuardID[i] == 0) { // get guard location ObjectID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GuardID[i] = SpawnChara("GUARD", x, y, z); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(GuardID[i], x, y, z); return; } } if (GuardID[3] > 0) SetAIAttrib(GuardID[3], AI_PATROL_POINT, 15, 16, 17, 18); if (GuardID[4] > 0) SetAIAttrib(GuardID[4], AI_PATROL_POINT, 20, 21, 22, 23); if (GuardID[5] > 0) SetAIAttrib(GuardID[5], AI_PATROL_POINT, 115, 119, 120); // spawn all guard captains for (i = 1 ; i < 4 ; i++) { if (CaptainID[i] == 0) { // get captain location ObjectID = FindSceneItem(NumToStr("CAPTAIN_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); CaptainID[i] = SpawnChara("CAPTAIN", x, y, z); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(CaptainID[i], x, y, z); return; } } if (CaptainID[1] > 0) SetAIAttrib(CaptainID[1], AI_PATROL_POINT, 26, 27, 28, 29); if (CaptainID[2] > 0) SetAIAttrib(CaptainID[2], AI_PATROL_POINT, 36, 37, 38, 39); if (CaptainID[3] > 0) SetAIAttrib(CaptainID[3], AI_PATROL_POINT, 116, 117, 120); } else if ( (idx >= 5) || (idx <= 10) ) { for (i = 6 ; i < 9 ; i++) { if (GuardID[i] == 0) { // get guard location ObjectID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GuardID[i] = SpawnChara("GUARD", x, y, z); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(GuardID[i], x, y, z); if (i == 6) SetAIAttrib(GuardID[6], AI_PATROL_POINT, 40, 41, 42, 43); else if (i == 7) SetAIAttrib(GuardID[7], AI_PATROL_POINT, 48, 49, 50, 51); else if (i == 8) SetAIAttrib(GuardID[8], AI_PATROL_POINT, 58, 59, 60, 61); return; } } // spawn all guard captains for (i = 4 ; i < 6 ; i++) { if (CaptainID[i] == 0) { // get captain location ObjectID = FindSceneItem(NumToStr("CAPTAIN_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); CaptainID[i] = SpawnChara("CAPTAIN", x, y, z); // set direction GetSceneItemDir(ObjectID, x, y, z); SetEntityDir(CaptainID[i], x, y, z); if (i == 4) SetAIAttrib(CaptainID[4], AI_PATROL_POINT, 129, 130, 131, 132); if (i == 5) SetAIAttrib(CaptainID[5], AI_PATROL_POINT, 68, 69, 70, 71); return; } } } } void JUMPZONE_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void JUMPZONE_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; // arrive last square if (CurrentCheckPoint == 99) return; for (i = 0 ; i < CheckPointNum ; i++) { if (CheckPointID[i] == id) break; } if ( i < CheckPointNum) { if (CurrentCheckPoint != i) { Print("Player Arrive Check Point ", i, "\n"); CurrentCheckPoint = i; ObjectID = FindSceneItem(NumToStr("AIJUMP_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); TeleportChara(PartnerID, x, y, z); AIPerform(PartnerID, AI_PERFORM_NONE); CheckGuard(CurrentCheckPoint); } else { Counter++; if (Counter > 3) { CheckGuard(CurrentCheckPoint); Counter = 0; } } } } // ------- // key // ------- void KEY_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "se05key01", 1); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_ROTATE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_LIGHT_SFX, "OBJ_Chi_Others"); } void KEY_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; Destroy(id); bGetKey = 1; PlaySound("fant_01_chimes_01"); ShowMissionItem(1, 1); } // --------------- // Lava // --------------- void LAVA_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_MODEL, "lava", 1); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); // SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_MACHINE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x, y, z+1050); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 4.5); } void TRIGGERLAVA_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); // SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_MACHINE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x, y, z+1050); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 4.5); } void TRIGGERLAVA_OnTouch(int id, int charaId) { if (charaId == PartnerID) { // CharaReborn(PartnerID, 0); if (CurrentCheckPoint == 99) { TeleportChara(PartnerID, 825, 1190, 860); } else if ( (CurrentCheckPoint < 0) || (CurrentCheckPoint >= CheckPointNum) ) { TeleportChara(charaId, SpawnPartnerX, SpawnPartnerY, SpawnPartnerZ); } else { ObjectID = FindSceneItem(NumToStr("AIJUMP_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); TeleportChara(charaId, x, y, z); AIPerform(charaId, AI_PERFORM_NONE); } } else { GetEntityPos(id, x, y, z); CharaHurt(charaId, 2, 20000, x, y, z); } } void PlayLavaSFX() { int range = rand() % 2; if (range) { ObjectID = FindSceneItem(NumToStr("sfxfire1k_%02d", rand()%10+1)); GetSceneItemPos(ObjectID, x, y, z); x = x + rand() % 1000 - 500; y = y + rand() % 1000 - 500; } else { ObjectID = FindSceneItem(NumToStr("sfxfire2k_%02d", rand()%3+1)); GetSceneItemPos(ObjectID, x, y, z); x = x + rand() % 2000 - 1000; y = y + rand() % 2000 - 1000; } /* ObjectID = FindSceneItem("sfxfire1k_01"); GetSceneItemPos(ObjectID, x, y, z); */ float dx, dy, dz; ObjectID = FindItem("lava"); GetEntityPos(ObjectID, dx, dy, dz); int type = rand() % 4; if (type == 0) { SpawnAttackSFX2("SE05_CurveFire0", x, y, dz-200, rand()%360, 0, 0, 2, 200); } else if (type == 1) { SpawnAttackSFX("SE05_Lava_Fire2", x, y, dz-200, 2, 200); } else if (type == 2) { SpawnAttackSFX("SE05_Lava_Fire3", x, y, dz-200, 2, 200); } else if (type == 3) { SpawnAttackSFX("SE05_Lava_Fire4", x, y, dz-200, 2, 200); } } void PlayDistortionSFX() { float dx, dy, dz; int timenow = GetRealTime() / 1000; ObjectID = GetPlayerChara(); GetEntityPos(ObjectID, dx, dy, dz); if (timenow % 5 == 0 && DistortionTimer != 0) { SpawnSFX("SE05_Lava_Dist", dx, dy, dz-40); DistortionTimer = 0; } else if (timenow % 5 == 1 && DistortionTimer != 1) { SpawnSFX("SE05_Lava_Dist", dx-100, dy-100, dz-10); SpawnSFX("SE05_Lava_Dist", dx+100, dy-100, dz-10); SpawnSFX("SE05_Lava_Dist", dx-100, dy+100, dz-10); SpawnSFX("SE05_Lava_Dist", dx+100, dy+100, dz-10); DistortionTimer = 1; } else if (timenow % 5 == 2 && DistortionTimer != 2) { SpawnSFX("SE05_Lava_Dist", dx-150 , dy , dz+20); SpawnSFX("SE05_Lava_Dist", dx+150 , dy , dz+20); SpawnSFX("SE05_Lava_Dist", dx , dy-150, dz+20); SpawnSFX("SE05_Lava_Dist", dx , dy+150, dz+20); DistortionTimer = 2; } else if (timenow % 5 == 3 && DistortionTimer != 3) { SpawnSFX("SE05_Lava_Dist", dx-100, dy-100, dz+50); SpawnSFX("SE05_Lava_Dist", dx+100, dy-100, dz+50); SpawnSFX("SE05_Lava_Dist", dx-100, dy+100, dz+50); SpawnSFX("SE05_Lava_Dist", dx+100, dy+100, dz+50); DistortionTimer = 3; } else if (timenow % 5 == 4 && DistortionTimer != 4) { SpawnSFX("SE05_Lava_Dist", dx, dy, dz+80); DistortionTimer = 4; } }