Frictional Games Forum (read-only)
How to make things happen when you return hub after picking up item? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to make things happen when you return hub after picking up item? (/thread-9666.html)



How to make things happen when you return hub after picking up item? - HumiliatioN - 08-09-2011

Okay my big problem my custom story trying to fix it. I have already project released but noticed this when final testing my map.

Basicly this is have to happen.

I have Item to pick that up in "Dark Storage" but when I came back from "Dark Storage" to the hub "Areas triggers many slimes, and atmosphere changes. but when I came back this not happens. Now where is the problem? This is my script:

Last area trigger when I pick up that item and go back:

void Leaving_events(string &in entity)
{
PlaySoundAtEntity("", "guardian_activated", "Player", 0, false);
SetPlayerActive(false);
SetEntityActive("Falling_grunt", true);
SetEntityActive("Falling_grunt_2", true);
StartEffectFlash(0.2f, 1.0f, 1.0f);
SetLampLit("hanging_lantern_ceiling_1", true, true);
SetLampLit("hanging_lantern_ceiling_2", true, true);
SetPropActiveAndFade("slime_egg_1", true, 1.5);
SetPropActiveAndFade("slime_egg_2", true, 1.5);
SetPropActiveAndFade("slime_pile_large_1", true, 1.5);
SetPropActiveAndFade("slime_pile_large_2", true, 1.5);
SetPropActiveAndFade("slime_pile_large_3", true, 1.5);
SetPropActiveAndFade("slime_pile_1", true, 1.5);
SetPropActiveAndFade("slime_pile_2", true, 1.5);
SetPropActiveAndFade("slime_pile_3", true, 1.5);
SetPropActiveAndFade("slime_6way_1", true, 1.5);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_egg_1", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_egg_2", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_large_1", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_large_2", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_large_3", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_1", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_2", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_pile_3", false);
CreateParticleSystemAtEntity("", "ps_guardian_appear_explosion", "slime_6way_1", false);
SetEntityActive("corpse_pile2_2", true);
SetEntityActive("corpse_pile2_3", true);
SetEntityActive("corpse_pile2_4", true);
SetEntityActive("corpse_pile2_5", true);
SetEntityActive("corpse_pile2_6", true);
SetEntityActive("corpse_pile2_7", true);
SetEntityActive("corpse_pile2_8", true);
SetEntityActive("corpse_pile2_9", true);
SetEntityActive("hanging_prisoner_1", true);
StartPlayerLookAt("hanging_prisoner_1", 15.5f, 15.5f, "");
AddTimer("Stopstare", 3, "Stoplook_corpse");
}

void Stoplook_corpse(string &in asTimer)
{
SetEntityActive("hanging_prisoner_1", false);
SetPlayerActive(true);
StopPlayerLookAt();
}

Map where "Strange things have to happen" :

{
AddEntityCollideCallback("Player", "Slimespawn", "noback", true, 1);
AddEntityCollideCallback("Player", "Slimespawn2", "noback2", true, 1);
}

void noback(string &in asParent, string &in asChild, int alState)
{
if(HasItem("Underground Tunnel Key"))
{
PlayMusic("14_elevator_falls", true, 3, 3, 10, true);
StartScreenShake(0.008, 0.5f, 0.1f,0.3f);
RemoveEntityCollideCallback("Player", "Slimespawn");
SetEntityActive("SlimeDamageArea_1", true);
SetEntityActive("slime_6way_1", true);
StartScreenShake(0.1, 3, 0.3, 2);
PlaySoundAtEntity("", "04_scream.snt", "Player", 0, false);
}
}

void noback2(string &in asParent, string &in asChild, int alState)
{
if(HasItem("Underground Tunnel Key"))
{
StartEffectFlash(0.2f, 1.0f, 1.0f);
StartScreenShake(0.008, 0.5f, 0.1f,0.3f);
PlaySoundAtEntity("", "guardian_ontop.snt", "slime_6way_3", 0, false);
RemoveEntityCollideCallback("Player", "Slimespawn");
SetPropActiveAndFade("slime_pile_large_1", true, 1.5);
SetPropActiveAndFade("slime_anim_wall_1", true, 1.5);
SetPropActiveAndFade("slime_anim_wall_2", true, 1.5);
SetPropActiveAndFade("slime_pile_large_2", true, 1.5);
SetPropActiveAndFade("slime_pile_large_3", true, 1.5);
SetPropActiveAndFade("slime_6way_3", true, 1.5);
SetPropActiveAndFade("slime_6way_4", true, 1.5);
SetEntityActive("fountain_childsnake_blood_1", true);
SetEntityActive("fountain_childsnake_blood_2", false);
SetEntityActive("slime_6way_3", true);
SetEntityActive("slime_6way_4", true);
SetEntityActive("slime_pile_large_1", true);
SetEntityActive("slime_pile_large_2", true);
SetEntityActive("slime_pile_large_3", true);
SetEntityActive("slime_anim_wall_1", true);
SetEntityActive("slime_anim_wall_2", true);
StartScreenShake(0.1, 3, 0.3, 2);

}
}

These scripts are not activating why? What I am doing wrong ?

Help is quickly appreciated. Thanks.


RE: How to make things happen when you return hub after picking up item? - Phoroneus - 08-09-2011

I'd say the easiest way to do this would be to create a second, identical "hub" map. Once you pick up the item from DarkStorage, the leveldoor in DarkStorage leading back to the hub could be set to inactive and a duplicate in the same location could be set to active, sending you to "hub2" or somesuch instead of the original hub. This way you could constrain the player's ability to leave hub2 as well, or allow them to freely go to any of the other maps to escape (assuming that's what you want them to do).

Alternately, you can run an OnEnter function in the hub map's .hps that checks whether you have whatever item is in your inventory and triggers the events, though in order to make the changes permanent (i.e. they don't happen every time you come back to the hub, but their effects remain) I might still go with an alternate map.


RE: How to make things happen when you return hub after picking up item? - Kyle - 08-09-2011

Actually, nice one Phoroneus, but you simply can use a global variable.


RE: How to make things happen when you return hub after picking up item? - Phoroneus - 08-09-2011

http://i641.photobucket.com/albums/uu131/KevlarPaperclip/double-facepalm.jpg


RE: How to make things happen when you return hub after picking up item? - HumiliatioN - 08-10-2011

Okay nice option but how to use that Global variable can you tell me example? To take with work Kyle?

EDIT: Nothing anymore I fixed it and solved the reason. But you can tell me more about Global Variables how they work Smile