#include "scenario_common.h" // Global variable int bStartGame = 0; int bSavePartner = 0; int CurRegion = -1; int CaptainID[4]; int GeneralID[2]; int GuardID[8]; int DoorID[5]; int CaptainCount = 0; int GeneralCount = 0; int GuardCount = 0; int EnemyRemain = 0; int bGetKey = 0; float GameOverTime = -1; // Partner Position SpawnPartnerX = -100; SpawnPartnerY = -3000; SpawnPartnerZ = 50; // use secondary bUseSecondary = 1; // local variable int WeaponID, ObjectID; int i; int CLow, CHigh, GELow, GEHigh, GULow, GUHigh; int CWeapon, GEWeapon, GUWeapon, GUDart; void BornEnemy(int region) { /* if (CurRegion == region) return; */ // delete old region enemy for(i = 0 ; i < CaptainCount ; i++) { if (CaptainID[i]) { Destroy(CaptainID[i]); CaptainID[i] = 0; } } for(i = 0 ; i < GeneralCount ; i++) { if (GeneralID[i]) { Destroy(GeneralID[i]); GeneralID[i] = 0; } } for(i = 0 ; i < GuardCount ; i++) { if (GuardID[i]) { Destroy(GuardID[i]); GuardID[i] = 0; } } CaptainCount = GeneralCount = GuardCount = 0; CurRegion = region; // born new region enemy switch(region) { case 1: { CLow = 0; CHigh = 1; GELow = 0; GEHigh = 0; GULow = 0; GUHigh = 3; GUWeapon = 72; CWeapon = 42; GEWeapon = 62; GUDart = 1; EnemyRemain = 7; break; } case 2: { CLow = 4; CHigh = 5; GELow = 2; GEHigh = 2; GULow = 8; GUHigh = 14; GUWeapon = 12; CWeapon = 92; GEWeapon = 52; GUDart = 3; EnemyRemain = 10; break; } case 3: { CLow = 6; CHigh = 7; GELow = 3; GEHigh = 3; GULow = 15; GUHigh = 18; GUWeapon = 72; CWeapon = 42; GEWeapon = 82; GUDart = 2; EnemyRemain = 7; break; } case 4: { CLow = 8; CHigh = 9; GELow = 4; GEHigh = 5; GULow = 19; GUHigh = 26; GUWeapon = 12; CWeapon = 82; GEWeapon = 62; GUDart = 4; EnemyRemain = 12; break; } } for(i = CLow ; i <= CHigh ; i++) { // get captain location ObjectID = FindSceneItem(NumToStr("CAPTAIN_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); CaptainID[CaptainCount] = SpawnChara("captain", x, y, z); SetCharaWeapon(CaptainID[CaptainCount], CWeapon); CaptainCount++; } for(i = GELow ; i <= GEHigh ; i++) { // get general location ObjectID = FindSceneItem(NumToStr("GENERAL_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GeneralID[GeneralCount] = SpawnChara("general", x, y, z); SetCharaWeapon(GeneralID[GeneralCount], GEWeapon); GeneralCount++; } for(i = GULow ; i <= GUHigh ; i++) { // get captain location ObjectID = FindSceneItem(NumToStr("GUARD_%02d", i)); GetSceneItemPos(ObjectID, x, y, z); GuardID[GuardCount] = SpawnChara("guard", x, y, z); SetCharaWeapon(GuardID[GuardCount], GUWeapon); SetCharaDart(GuardID[GuardCount], GUDart, 30); ClearAIAllBehavior(GuardID[GuardCount]); AI_Shooter(PlayerID, GuardID[GuardCount]); GuardCount++; } } // --------- // Game // --------- void OnCache() { LoadScene("se07"); // CacheLevelModel(""); CacheLevelModel("sw01keyitem"); CacheLevelCharacter("ce12"); CacheLevelCharacter("ce13"); CacheLevelCharacter("ce14"); } void OnHostGame() { SetGameMaxTime(-1); InitScenario(); // move player to his(her) room if (IsMale()) { SetEntityDir(PlayerID, -0.2, -1, 0); TeleportChara(PlayerID, 442, 319.3, 4); SetEntityDir(PartnerID, 1, -0.2, 0); TeleportChara(PartnerID, -497, 331.2, 4); } else { SetEntityDir(PlayerID, -0.7, -0.7, 0); TeleportChara(PlayerID, -437.3, 325.7, 4); SetEntityDir(PartnerID, -0.8, -0.5, 0); TeleportChara(PartnerID, 495.4, 314.5, 4); } ShowEntity(PartnerID, 0); ActivateEntity(PartnerID, 0); DoorID[0] = FindItem("se07door01_00"); DoorID[1] = FindItem("se07door01_01"); DoorID[2] = FindItem("se07door02_00"); DoorID[3] = FindItem("se07door02_01"); DoorID[4] = FindItem("se07door03"); var_aiLockCountLimit = 6; // mission SetMissionObjectiveText(0, MOBJ_SE07_1); SetMissionObjectiveText(1, MOBJ_SE07_2); SetMissionObjectiveText(2, MOBJ_SE07_3); SetMissionObjectiveText(3, MOBJ_SE07_4); SetMissionObjectiveText(4, MOBJ_SE07_5); BornEnemy(1); Print("Cutscene27\n"); PlayCharaCutscene("cutscene27"); bStartGame = 1; } void CUTSCENE27_OnEnd() { PlayMusic("s16_yongJian_bgm", 1, 1); SetAudioVariable(0, 0); } void OnTimeOver() { Print("TimeOver\n"); GameOver(GAMEOVER_LOSE); } void OnUpdate(float t) { CommonUpdate(t); if (bStartGame == 1) { SetAudioVariable(0, 1000); bStartGame = 0; } if (GameOverTime > 0) { GameOverTime = GameOverTime - t; if (GameOverTime < 0) PlayerDead(); } } void OnCharaDead(int id, int killer) { Print("Chara ", id, " is killed by ", killer, "\n"); // Player dead if (id == PlayerID) { PlayerDead(); return; } if (id == PartnerID) { PartnerDead(); ShowHint(HINT_SE07_4, 2); GameOverTime = 2; return; } string CharaName = GetCharaString(id, CHARA_NAME); // guard captain if ( CharaName == "GUARD") { EnemyRemain--; KillScore(0, 550); } if ( CharaName == "CAPTAIN") { EnemyRemain--; KillScore(0, 575); } if ( CharaName == "GENERAL") { EnemyRemain--; KillScore(0, 600); } if (EnemyRemain == 0) { switch(CurRegion) { case 1: { SpawnItem("key", 0, 0, 20); break; } case 2: { SpawnItem("key", -785, 1438, 317); break; } case 3: { SpawnItem("key", -1570, 2606, 518); break; } case 4: { SpawnItem("key", -1220, 3275, 780); break; } } } } void OnContinueGame() { CharaReborn(PlayerID); if (bSavePartner) { CharaReborn(PartnerID); if (CurRegion == 2) TeleportChara(PartnerID, 50, 678, 10); else if (CurRegion == 3) TeleportChara(PartnerID, -856, 1580, 300); else if (CurRegion == 4) TeleportChara(PartnerID, -1570, 2760, 530); } if (CurRegion == 2) TeleportChara(PlayerID, 30, 678, 10); else if (CurRegion == 3) TeleportChara(PlayerID, -876, 1580, 300); else if (CurRegion == 4) TeleportChara(PlayerID, -1590, 2760, 530); // destroy key ObjectID = FindItem("key"); if (ObjectID > 0) Destroy(ObjectID); BornEnemy(CurRegion); bGetKey = 0; ShowMissionItem(0, 0); PlayMusic("s16_yongJian_bgm", 1, 1); SetAudioVariable(0, 0); bStartGame = 1; } // ------------ // Trigger // ------------ void TRIGGER_KAIROOM_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; // check player if (!IsMale()) { SetMissionObjectiveSwitch(0, 0); BeginCutscene("cutscene28_2", "PartnerRoom"); } ActivateEntity(id, 0); } void TRIGGER_MIAROOM_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; // check player if (IsMale()) { SetMissionObjectiveSwitch(0, 0); BeginCutscene("cutscene28_1", "PartnerRoom"); } ActivateEntity(id, 0); } void PARTNERROOM_OnEnd() { bSavePartner = 1; if (IsMale()) { SetEntityDir(PlayerID, -0.8, -0.5, 0); TeleportChara(PlayerID, -416.2, 281.4, 4); } else { SetEntityDir(PlayerID, 0.8, 0.5, 0); TeleportChara(PlayerID, 482.2, 308, 4); } ShowEntity(PartnerID, 1); ActivateEntity(PartnerID, 1); } void TRIGGER_OUT_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (!bSavePartner) PlayCharaCutsceneCB("shortcut_out", "savepartner"); else ActivateEntity(id, 0); } void SAVEPARTNER_OnEnd() { TeleportChara(PlayerID, -0.1, 825.3, 11.2); SetEntityDir(PlayerID, 0, -1, 0); } /* void TRIGGER_ENEMYREGION01_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; BornEnemy(1); ActivateEntity(id, 0); } void TRIGGER_ENEMYREGION02_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; BornEnemy(2); ActivateEntity(id, 0); } void TRIGGER_ENEMYREGION03_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; BornEnemy(3); ActivateEntity(id, 0); } void TRIGGER_ENEMYREGION04_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; BornEnemy(4); ActivateEntity(id, 0); } */ void TRIGGER_DOOR00_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (!bGetKey) { ShowHint(HINT_SE07_1); return; } BornEnemy(2); bGetKey = 0; SetMissionObjectiveSwitch(1, 0); ShowMissionItem(0, 0); SetItemMachine(DoorID[0], 1); SetItemMachine(DoorID[1], 1); // continue point bContinue = 1; ActivateEntity(id, 0); } void TRIGGER_DOOR01_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (!bGetKey) { ShowHint(HINT_SE07_1); return; } BornEnemy(3); bGetKey = 0; SetMissionObjectiveSwitch(2, 0); ShowMissionItem(0, 0); SetItemMachine(DoorID[2], 1); ActivateEntity(id, 0); } void TRIGGER_DOOR02_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (!bGetKey) { ShowHint(HINT_SE07_1); return; } BornEnemy(4); bGetKey = 0; SetMissionObjectiveSwitch(3, 0); ShowMissionItem(0, 0); SetItemMachine(DoorID[3], 1); ActivateEntity(id, 0); } void TRIGGER_CAVE_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; if (!bSavePartner) return; if (!bGetKey) { ShowHint(HINT_SE07_1); return; } SetMissionObjectiveSwitch(4, 0); SetItemMachine(DoorID[4], 1); SetCutsceneDelayTime(2); PlayAICutsceneCB("shortcut7_1", "GameComplete"); SetCutsceneDelayTime(0); ActivateEntity(id, 0); } void HINTSE072_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void HINTSE072_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; ShowHint(HINT_SE07_2); } void HINTSE073_InitItem(int id) { SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); } void HINTSE073_OnTouch(int id, int charaId) { if (charaId != PlayerID) return; ShowHint(HINT_SE07_3); } // ------- // 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, 32); } 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_IDLE, 100); SetAIBehavior(id, AI_STATE_LOCK, AI_LOCK_NEAREST_TARGET, 50); SetAIBehavior(id, AI_STATE_LOCK, AI_LOCK_ONE_TARGET, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DIRECT, 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_DASH_BACK , 50); SetAIBehavior(id, AI_STATE_PREATTACK, AI_ATTACKMOVE_SHIFTMOVE, 50); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_RANDOM, 50); SetAIBehavior(id, AI_STATE_ATTACK, AI_ATTACK_COMBO, 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, 52); } void CAPTAIN_InitAI(int id) { AI_Captain(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 70*ResponseRate); } // General void GENERAL_InitChara(int id) { NPCE14_InitChara(id); SetCharaAttrib(id, CHARA_TEAM, 2); SetCharaWeapon(id, 62); } void GENERAL_InitAI(int id) { AI_Captain(PlayerID, id); SetAIAttrib(id, AI_THINK_SPEED, 90*ResponseRate); } // -------- // key // -------- void KEY_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "sw01keyitem", 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); } // --------- // Door // --------- void SE07DOOR01_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "door_1", 1); 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_ROTATEAXIS, 0, 0, 1); SetItemAttrib(id, ITEM_ROTATESPEED, 0.5); SetItemAttrib(id, ITEM_ROTATEANGLE, 1.57); } void SE07DOOR02_InitItem(int id) { SetItemAttrib(id, ITEM_MODEL, "door_3", 1); 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_ROTATEAXIS, 0, 0, 1); SetItemAttrib(id, ITEM_ROTATESPEED, 0.5); SetItemAttrib(id, ITEM_ROTATEANGLE, 1.55); } void SE07DOOR03_InitItem(int id) { GetEntityPos(id, x, y, z); SetItemAttrib(id, ITEM_MODEL, "door_5", 1); SetItemAttrib(id, ITEM_PHYSICS, ITEM_PHYSICS_NONE); SetItemAttrib(id, ITEM_LIFTABLE, 0); SetItemAttrib(id, ITEM_PICKABLE, 0); SetItemAttrib(id, ITEM_MOVEPOINT, 2, x, y, z, x, y, z + 80); SetItemAttrib(id, ITEM_WAITTIME, 0); SetItemAttrib(id, ITEM_MOVETYPE, 0); SetItemAttrib(id, ITEM_MOVESPEED, 20); SetItemAttrib(id, ITEM_NEXTPOINT, 1); }