Frictional Games Forum (read-only)
Looking at, or not looking at script - 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: Looking at, or not looking at script (/thread-15287.html)

Pages: 1 2


Looking at, or not looking at script - FlawlessHappiness - 05-06-2012

I've read some threads about this, but i didn't really get the answer i need.

In my custom story, there is an iron maiden, working like in the main story. The iron maiden opens, and you get blur effects and so on, but there is also a body inside that iron maiden, and i want that body to disappear just when you look away...

The script i made myself looks like this:

Spoiler below!


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "OnPlayerCollide1", true, 1);

}


void OnPlayerCollide1(string &in asParent, string &in asChild, int alState)
{

AddBodyImpulse("iron_maiden_1_leftDoor", 0, 0, -10, "world");
AddBodyImpulse("iron_maiden_1_rightDoor", 0, 0, 10, "world");
SetEntityActive("corpse_male_1", true);
FadeRadialBlurTo(1, 0.3);
GiveSanityDamage(5.0, true);
StartPlayerLookAt("corpse_male_1", 10, 10, "");
AddTimer("", 2, "StopPlayerLookAt_2");

SetEntityPlayerLookAtCallback("corpse_male_1", "CorpseDisappear_1", false);

}

void CorpseDisappear_1(string &in asEntity, int alState)
{

if (alState == -1)
{
SetEntityActive("corpse_male_1", false);
}

}

void StopPlayerLookAt_2(string &in asTimer)
{
StopPlayerLookAt();
FadeRadialBlurTo(0, 0.1);
}


Everything works perfect, except, the body disappears no matter where im looking... It just spawns, and despawns..

I heard something about Localvar checking stuff.. haven't used it before.. is that it?


RE: Looking at, or not looking at script - Rownbear - 05-06-2012

Not sure exactly how you want it to work but you could add a timer to make it disappear, or you could make another script box in the room but behind the player thats inactive. so when you trigger the script with the body it also enables the inactive script box behind the player. that way when he turns around the script box that was inactive, is now active and when you look at that the guy disappears.

I usually make my maps going this way, it probably takes alittle more effort but it works.


RE: Looking at, or not looking at script - FlawlessHappiness - 05-06-2012

What i want is for the player, not to notice the body disappearing. Because it looks stupid if the body disappears in the bare air. So when the player turns around (Not looking at the body) It will disappear, and when he (or her) look back at the body, its gone


RE: Looking at, or not looking at script - Xanthos - 05-06-2012

(alState == 1)
Try dat :3


RE: Looking at, or not looking at script - FlawlessHappiness - 05-06-2012

Thats what i did in my script as shown above, now also below Tongue

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "OnPlayerCollide1", true, 1);

}


void OnPlayerCollide1(string &in asParent, string &in asChild, int alState)
{

AddBodyImpulse("iron_maiden_1_leftDoor", 0, 0, -10, "world");
AddBodyImpulse("iron_maiden_1_rightDoor", 0, 0, 10, "world");
SetEntityActive("corpse_male_1", true);
FadeRadialBlurTo(1, 0.3);
GiveSanityDamage(5.0, true);
StartPlayerLookAt("corpse_male_1", 10, 10, "");
AddTimer("", 2, "StopPlayerLookAt_2");

SetEntityPlayerLookAtCallback("corpse_male_1", "CorpseDisappear_1", false);

}

void CorpseDisappear_1(string &in asEntity, int alState)
{

if (alState == -1), but 1 is when you ARE looking at it Wink
{
SetEntityActive("corpse_male_1", false);
}

}

void StopPlayerLookAt_2(string &in asTimer)
{
StopPlayerLookAt();
FadeRadialBlurTo(0, 0.1);
}


RE: Looking at, or not looking at script - Dutton - 05-06-2012

I think you'll be able to get you answer in this thread. palistov made it work in another thread with the exact same problem

http://www.frictionalgames.com/forum/thread-7135.html


RE: Looking at, or not looking at script - FlawlessHappiness - 05-06-2012

(05-06-2012, 04:47 PM)Dutton Wrote: I think you'll be able to get you answer in this thread. palistov made it work in another thread with the exact same problem

http://www.frictionalgames.com/forum/thread-7135.html
No sorry. I tried making my script look like this:


void OnStart()
{
SetEntityPlayerLookAtCallback("corpse_male_1", "CorpseDisappear_1", false);

}


void CorpseDisappear_1(string &in entity, int alState)
{
if(alState == -1)
{
SetEntityActive("corpse_male_1", false);
}
}

The game plays fine, but the body disappears after one second


RE: Looking at, or not looking at script - Xanthos - 05-06-2012

Why not try my idea?

(alState == 1)
Change it from a negative to a positive.



RE: Looking at, or not looking at script - FlawlessHappiness - 05-06-2012

Nope same thing happens... it disappears after 1 second


RE: Looking at, or not looking at script - Damascus - 05-07-2012

I'm actually working on something exactly the same in my custom story right now. The problem is that you are technically looking away from something as long as your crosshairs are off of it. So it will disappear as soon as the camera isn't centered on it. I would try making a large script area around the iron maiden, and having the script target that instead of the body. That way, it shouldn't disappear until your camera is directed away from the whole area.