//////////////////////
////////////////////////////
// Run first time starting map
void OnStart()
{
PreloadParticleSystem("ps_orb_room_alex_die.ps");
PreloadParticleSystem("ps_hit_rock.ps");
PreloadParticleSystem("ps_break_prison_tunnel.ps");
PreloadSound("explosion_rock_large.snt");
PreloadSound("29_crumble.snt");
SetMapDisplayNameEntry("mithraeum");
SetEntityPlayerLookAtCallback("BlowPillarArea", "PillarMessage", true);
PlayPropAnimation("alexander_1", "Death", 0.3, false, "");
AddTimer("rumble", RandFloat(15.0f, 25.0f), "TimerRumble");
SetEntityConnectionStateChangeCallback("elevator_lever_1", "Switch1");
SetEntityConnectionStateChangeCallback("elevator_lever_2", "Switch2");
AddTimer("check", 0.0f, "CheckGold");
AddUseItemCallback("", "flask01_orpiment", "potash", "FormGold", false);
for(int x=1;x<=10;x++)
{
AddEntityCollideCallback("potash_"+x, "BlowPillarArea", "PillarVar", false, 0);
}
SetLocalVarInt("PotAshNumber", 1);
SetEntityPlayerInteractCallback("orb", "GotOrb", true);
AddEntityCollideCallback("Player", "HaakArea", "ActivateHaak", true, 1);
AddCombineCallback("", "chemical_container_1", "vitriol", "AquaRegia", true);
AddCombineCallback("", "flask01_aqua_regia", "gold", "AuricHydro", true);
AutoSave();
}
////////////////////////////
// Run when entering map
void OnEnter()
{
if(GetGlobalVarInt("GotOrb") == 0)
{
PlayMusic("TGW_35_anatomy", true, 1, 5, 0, true);
}
if(GetGlobalVarString("Ending") == "Captured")
{
AddTimer("", 0.0f, "TimerCaptured");
}
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
SetupLoadScreen("LoadingText7", "Loading", 7, "ch7load.jpg");
}
void AquaRegia(string &in asItemA, string &in asItemB)
{
RemoveItem(asItemA); RemoveItem(asItemB);
PlayGuiSound("puzzle_add_chemical", 1.0f);
GiveItem("flask01_aqua_regia", "flask01_aqua_regia", "aqua_regia", "flask01_aqua_regia.tga", 1);
}
void AuricHydro(string &in asItemA, string &in asItemB)
{
RemoveItem(asItemA); RemoveItem(asItemB);
PlayGuiSound("puzzle_acid", 1.0f);
GiveItem("flask01_orpiment", "flask01_orpiment", "auric_hydroxide", "flask01_orpiment.tga", 1);
}
void TimerRumble(string &in asTimer)
{
StartScreenShake(0.01f, 3.0f, 1.0f, 1.0f);
CreateParticleSystemAtEntity("","ps_green_wind_breeze.ps", "SmokeArea", false);
PlayGuiSound("03_cloud_solo.snt", 1.0f);
AddTimer("rumble", RandFloat(20.0f, 45.0f), "TimerRumble");
}
void ActivateHaak(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("college_1", true);
for (int i = 0; i < 5; i++)
{
if (i == 5)
{
i = 0;
}
AddEnemyPatrolNode("college_1", "PathNodeArea_"+i, 0.001f, "");
}
}
///////////////////////
// BRIDGES
////////////////////////
void Switch1(string &in asEntity, int alState)
{
if (alState == -1)
{
if(GetLocalVarInt("Lift") == 0)
{
SetLeverStuckState("elevator_lever_1", -1, true);
AddTimer("", 0.0, "LiftUp");
}
}
if (alState == 1)
{
if(GetLocalVarInt("Lift") == 1)
{
SetLeverStuckState("elevator_lever_1", 1, true);
AddTimer("", 0.0, "LiftDown");
}
}
}
void Switch2(string &in asEntity, int alState)
{
if (alState == -1)
{
if(GetLocalVarInt("Lift") == 0)
{
SetLeverStuckState("elevator_lever_2", -1, true);
AddTimer("", 0.0, "LiftUp");
}
}
if (alState == 1)
{
if(GetLocalVarInt("Lift") == 1)
{
SetLeverStuckState("elevator_lever_2", 1, true);
AddTimer("", 0.0, "LiftDown");
}
}
}
void LiftUp(string &in asTimer)
{
SetLocalVarInt("Lift", 1);
SetEntityInteractionDisabled("elevator_lever_1", true);
SetEntityInteractionDisabled("elevator_lever_2", true);
SetMoveObjectState("bridge_metal_vert_1", 1);
StartScreenShake(0.005f, 0.5f, 0.2f, 0.6f);
PlaySoundAtEntity("", "14_elevator_clank", "Player", 0.5f, false);
PlaySoundAtEntity("bridge1", "16_winch_bridge", "bridge_metal_vert_1", 1.0f, true);
AddTimer("", 13.0, "TimerStopLift");
}
void LiftDown(string &in asTimer)
{
SetLocalVarInt("Lift", 0);
SetEntityInteractionDisabled("elevator_lever_1", true);
SetEntityInteractionDisabled("elevator_lever_2", true);
SetMoveObjectState("bridge_metal_vert_1", 0);
StartScreenShake(0.005f, 0.5f, 0.2f, 0.6f);
PlaySoundAtEntity("", "14_elevator_clank", "Player", 0.5f, false);
PlaySoundAtEntity("bridge1", "16_winch_bridge", "bridge_metal_vert_1", 1.0f, true);
AddTimer("", 13.0, "TimerStopLift");
}
void TimerStopLift(string &in asTimer)
{
SetLeverStuckState("elevator_lever_1", 0, true);
SetLeverStuckState("elevator_lever_2", 0, true);
SetEntityInteractionDisabled("elevator_lever_1", false);
SetEntityInteractionDisabled("elevator_lever_2", false);
StopSound("bridge1", 1.0f);
PlaySoundAtEntity("", "14_elevator_clank", "Player", 0.5f, false);
StartScreenShake(0.005f, 0.5f, 0.2f, 0.6f);
SetLeverInteractionDisablesStuck("elevator_lever_1", true);
}
///////////////////////////////
//Fulminating Gold
///////////////////////////////
void FormGold(string &in asItem, string &in asEntity)
{
FadeLightTo("PointLight_2", 0.6f, 0.55f, 0.05f, 1.0f, -1, 1);
PlaySoundAtEntity("", "puzzle_add_chemical", "potash", 1.0f, false);
SetPropActiveAndFade("potash", false, 2.0f);
SetPropActiveAndFade("potash_1", true, 1.0f);
AddTimer("", 1.0f, "TimerEndlight");
AddTimer("check", 0.0f, "CheckGold");
GiveSanityBoost();
}
void TimerEndlight(string &in asTimer)
{
FadeLightTo("PointLight_2", 0.0f, 0.0f, 0.0f, 0.0f, -1, 1);
}
void CheckGold(string &in asTimer)
{
int x = GetLocalVarInt("PotAshNumber");
if (GetPropHealth("potash_"+x) < 1)
{
if (GetLocalVarInt("Pillar") == 1)
{
AddTimer("", 0.0f, "StartScene");
SetEntityActive("SignArea_1", false);
}
else
{
AddLocalVarInt("PotAshNumber", 1);
if (GetLocalVarInt("PotAshNumber") < 11)
{
CreateEntityAtArea("potash_"+x, "crystal_rock_02.ent", "FulmGoldArea", false);
AddTimer("check", 0.1f, "CheckGold");
}
}
}
else
{
AddTimer("check", 0.1f, "CheckGold");
}
}
void DoOver(string &in asTimer)
{
if(asTimer == "doover1")
{
SetMessage("Ch07Misc", "gold", 0);
}
if(asTimer == "doover2")
{
PlayGuiSound("intelligencer1_attack_claw", 1);
}
if(asTimer == "doover3")
{
PlaySoundAtEntity("", "attack_claw_hit.snt", "Player", 0, false);
GivePlayerDamage(110.0f, "Slash", true, true);
}
}
void PillarVar(string &in asParent, string &in asChild, int alState)
{
if (alState == 1)
{
SetLocalVarInt("Pillar", 1);
SetLampLit("torch_static01_5", true, true);
}
else if (alState == -1)
{
SetLocalVarInt("Pillar", 0);
SetLampLit("torch_static01_5", false, true);
}
}
void StartScene(string &in asTimer)
{
SetPlayerJumpDisabled(true);
SetPlayerCrouchDisabled(true);
SetPlayerRunSpeedMul(0);
SetPlayerMoveSpeedMul(0);
SetPlayerLookSpeedMul(0.06f);
StopMusic(0.0f, 0);
PlayMusic("TGW_35_column.ogg", false, 0.7, 1.0, 10, false);
CreateParticleSystemAtEntity("AlexAura", "ps_orb_room_agrippa_end_effect.ps", "BlowPillarArea_1", false);
StartEffectFlash(1.0f, 1.0f, 1.0f);
FadeOut(2);
AddTimer("", 2.0f, "Teleport");
AddTimer("", 3.0f, "BlowPillar");
}
void Teleport(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_4");
StartPlayerLookAt("BlowPillarArea", 444.4f, 444.4f, "");
}
void BlowPillar(string &in asTimer)
{
FadeIn(2);
StartPlayerLookAt("CrackArea_5", 0.5f, 0.5f, "");
StartScreenShake(0.1f,6.0f,4.0f,2.0f);
PlaySoundAtEntity("", "29_crumble.snt", "Player", 0, false);
AddTimer("", 5.0f, "PillarDone");
AddTimer("crack1", 0.0f, "PillarCrack");
AddTimer("crack2", 0.6f, "PillarCrack");
AddTimer("crack3", 1.2f, "PillarCrack");
AddTimer("crack4", 2.0f, "PillarCrack");
AddTimer("crack5", 3.4f, "PillarCrack");
}
void PillarCrack(string &in asTimer)
{
if(asTimer == "crack1")
{
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "CrackArea_1", false);
}
if(asTimer == "crack2")
{
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "CrackArea_2", false);
}
if(asTimer == "crack3")
{
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "CrackArea_3", false);
}
if(asTimer == "crack4")
{
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "CrackArea_4", false);
}
if(asTimer == "crack5")
{
CreateParticleSystemAtEntity("", "ps_hit_rock.ps", "CrackArea_5", false);
}
}
void BlowPillarArea(string &in asEntity, int alState)
{
if(alState == -1)
{
SetMessage("Ch07Misc", "weak", 0);
}
}
void PillarDone(string &in asTimer)
{
StartPlayerLookAt("alexander_1", 0.5f, 0.5f, "");
FadeLightTo("PointLight_1", -1, -1, -1, -1, 0, 10.0f);
FadeLightTo("SpotLight_1", -1, -1, -1, -1, 0, 10.0f);
FadeLightTo("SpotLight_2", -1, -1, -1, -1, 0, 10.0f);
FadeLightTo("SpotLight_3", -1, -1, -1, -1, 0, 10.0f);
PlaySoundAtEntity("killalex", "explosion_rock_large.snt", "pillar_gigantic_1", 0.0f, false);
SetEntityActive("pillar_gigantic_1", false);
SetEntityActive("pillar_gigantic_2", true);
CreateParticleSystemAtEntity("", "ps_break_prison_tunnel.ps", "CrackArea_1", false);
CreateParticleSystemAtEntity("", "ps_break_prison_tunnel.ps", "CrackArea_2", false);
CreateParticleSystemAtEntity("", "ps_break_prison_tunnel.ps", "CrackArea_3", false);
CreateParticleSystemAtEntity("", "ps_break_prison_tunnel.ps", "CrackArea_4", false);
CreateParticleSystemAtEntity("", "ps_break_prison_tunnel.ps", "CrackArea_5", false);
SetEntityActive("bridge_torch_1", false);
SetEntityActive("bridge_torch_2", false);
SetEntityActive("bridge_torch_3", false);
SetEntityActive("bridge_torch_4", false);
SetEntityActive("bridge_torch_5", true);
SetEntityActive("bridge_torch_6", true);
SetEntityActive("bridge_torch_7", true);
SetEntityActive("bridge_torch_8", true);
SetEntityActive("orb_altar_1", false);
SetEntityActive("orb_altar_2", true);
CompleteQuest("Ritual", "Ritual");
StartScreenShake(0.22, 3, 1, 3);
SetEntityActive("orb_6_of_7", false);
SetEntityActive("orb", true);
DestroyParticleSystem("ParticleSystem_1");
DestroyParticleSystem("ParticleSystem_2");
DestroyParticleSystem("ParticleSystem_3");
StopSound("Sound_1", 10.0f);
StopSound("Sound_2", 2.0f);
RemoveTimer("rumble");
AddTimer("", 3.0f, "MoriaenSplode");
}
void MoriaenSplode(string &in asTimer)
{
SetEntityActive("orb_altar_2", false);
SetPropActiveAndFade("alexander_1", false, 2);
DestroyParticleSystem("AlexAura");
PlaySoundAtEntity("", "27_orb_implode.snt", "BlowPillarArea_1", 0.0f, false);
CreateParticleSystemAtEntity("AlexExplode","ps_orb_room_alex_die.ps", "BlowPillarArea_1", false);
CreateParticleSystemAtEntity("AlexExplode2","ps_orb_shockwave.ps", "BlowPillarArea_1", false);
AddTimer("scene1", 5.0f, "SceneEnd");
AddTimer("scene2", 8.0f, "SceneEnd");
}
void SceneEnd(string &in asTimer)
{
if(asTimer == "scene1")
{
FadeOut(2);
SetPropActiveAndFade("bridge_torch_5", false, 2.0f);
SetPropActiveAndFade("bridge_torch_6", false, 2.0f);
SetPropActiveAndFade("bridge_torch_7", false, 2.0f);
SetPropActiveAndFade("bridge_torch_8", false, 2.0f);
}
if(asTimer == "scene2")
{
TeleportPlayer("PlayerStartArea_5");
FadeIn(2);
StopPlayerLookAt();
SetPlayerJumpDisabled(false);
SetPlayerCrouchDisabled(false);
SetPlayerMoveSpeedMul(1.0f);
SetPlayerRunSpeedMul(1.0f);
SetPlayerLookSpeedMul(1.0f);
}
}
///////////////////////////////
//ORB CAPTURED
///////////////////////////////
void GotOrb(string &in asEntity)
{
CheckPoint ("check2", "PlayerStartArea_2", "Captured", "Death", "allover");
AddEntityCollideCallback("Player", "CollegeCharge_1", "HullCharge", true, 1);
AddEntityCollideCallback("Player", "CollegeCharge_2", "HaakCharge", true, 1);
AddEntityCollideCallback("Player", "HullArea", "ActivateHull", true, 1);
SetGlobalVarInt("GotOrb", 1);
AutoSave();
}
void ActivateHull(string &in asParent, string &in asChild, int alState)
{
CheckPoint ("check2", "PlayerStartArea_2", "Captured", "Death", "allover");
AddTimer("", 2.0f, "TimerMusic");
SetEntityActive("college_2", true);
for (int i = 0; i < 6; i++)
{
if (i == 6)
{
i = 0;
}
AddEnemyPatrolNode("college_2", "HullNodeArea_"+i, 0.001f, "");
}
}
void TimerMusic(string &in asTimer)
{
PlayMusic("TGW_35_chase", true, 1, 10, 0, true);
}
void HullCharge(string &in asParent, string &in asChild, int alState)
{
ShowEnemyPlayerPosition("college_2");
}
void HaakCharge(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("college_1", false);
SetEntityActive("college_3", true);
ShowEnemyPlayerPosition("college_3");
}
///////////////////////////////
// CAPTURED ENDING
///////////////////////////////
void Captured(string &in asName, int alCount)
{
SetGlobalVarString("Ending", "Captured");
AddTimer("", 0.0f, "TimerCaptured");
}
void TimerCaptured(string &in asTimer)
{
StopMusic(10, 0);
FadeOut(0);
SetEntityActive("orb_6_of_8", true);
SetPropStaticPhysics("orb_6_of_8", true);
SetEntityActive("stone_table_1", true);
PlaySoundAtEntity("orbloop", "03_orb_loop", "orb_6_of_8", 0.5f, false);
FadeImageTrailTo(2,1);
MovePlayerHeadPos(0, -1.5f, 0, 1, 0.5f);
FadePlayerRollTo(90, 100, 100);
SetPlayerLookSpeedMul(0.25f);
SetPlayerMoveSpeedMul(0.0f);
SetLanternDisabled(true);
SetPlayerJumpDisabled(true);
SetInventoryDisabled(true);
SetEntityActive("bridge_torch_5", false);
SetEntityActive("bridge_torch_6", false);
SetEntityActive("bridge_torch_7", false);
SetEntityActive("bridge_torch_8", false);
SetEntityActive("orb_altar_2", false);
SetEntityActive("college_4", true);
AddEnemyPatrolNode("college_4", "PathNodeArea_197", 60.0f, "");
PlayMusic("TGW_35_sacrifice", true, 1, 1, 0, true);
AddTimer("drag", 3.0f, "PlayerDrag");
AddTimer("sac1", 5.0f, "TimerSacrifice");
AddTimer("sac2", 7.5f, "TimerSacrifice");
AddTimer("sac3", 12.0f, "TimerSacrifice");
AddTimer("sac4", 16.0f, "TimerSacrifice");
AddTimer("sac5", 18.0f, "TimerSacrifice");
AddTimer("sac6", 20.0f, "TimerSacrifice");
AddTimer("sac7", 22.0f, "TimerSacrifice");
AddTimer("sac8", 28.0f, "TimerSacrifice");
AddTimer("sac9", 30.0f, "TimerSacrifice");
AddTimer("sac10", 35.0f, "TimerSacrifice");
AddTimer("sac11", 37.0f, "TimerSacrifice");
FadeIn(2);
}
void PlayerDrag(string &in asTimer)
{
AddPlayerBodyForce(8000, 0, -8000, false);
PlayGuiSound("35_drag.snt", 1.0f);
AddTimer(asTimer, 1.5f, "PlayerDrag");
}
void TimerSacrifice(string &in asTimer)
{
if(asTimer == "sac1")
{
FadeOut(1);
PlayGuiSound("react_breath_slow.snt", 1.0f);
}
if(asTimer == "sac2")
{
FadeIn(2);
}
if(asTimer == "sac3")
{
FadeOut(2);
PlayGuiSound("react_sigh.snt", 1.0f);
AddEffectVoice("intelligencer_body.ogg", "", "Ch07Misc", "haak", true, "college_4", 0, 20);
}
if(asTimer == "sac4")
{
PlayGuiSound("35_place.snt", 1.0f);
RemoveTimer("drag");
TeleportPlayer("PlayerStartArea_3");
StartPlayerLookAt("orb_6_of_8", 1.0f, 5.0f, "");
FadePlayerRollTo(0, 100, 100);
}
if(asTimer == "sac5")
{
FadeIn(3);
}
if(asTimer == "sac6")
{
StopPlayerLookAt();
}
if(asTimer == "sac7")
{
SetPropStaticPhysics("orb_6_of_8", false);
PlayGuiSound("react_breath.snt", 1.0f);
}
if(asTimer == "sac8")
{
StopMusic(10, 0);
PlayGuiSound("puzzle_acid.snt", 1.0f);
PlayGuiSound("react_scare.snt", 1.0f);
StopSound("orbloop", 2.0f);
StartEffectFlash(0.5f, 4.0f, 0.5f);
SetPlayerSanity(100.0f);
SetSanityDrainDisabled(true);
}
if(asTimer == "sac9")
{
FadeOut(3);
}
if(asTimer == "sac10")
{
PlayGuiSound("react_breath_slow.snt", 1.0f);
SetEntityActive("college_4", false);
}
if(asTimer == "sac11")
{
AddEffectVoice("moriaen_012.ogg", "", "Ch07Misc", "moriaen12", true, "Player", 4, 16);
SetEffectVoiceOverCallback("EndGame");
}
}
void EndGame()
{
StartCredits("END_anatomy.ogg", false, "Ending", "MainCredits", 5);
}
///////////////////////////////
// FAILED ENDING
///////////////////////////////
void Failed(string &in asName, int alCount)
{
SetGlobalVarString("Ending", "Failed");
ChangeMap("33_prison_redux.map", "PlayerStartArea_3", "intell_haak/intelligencer1_victory", "22_end");
}