Frictional Games Forum

Full Version: Looking at, or not looking at script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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?
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.
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
(alState == 1)
Try dat :3
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);
}
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
(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
Why not try my idea?

(alState == 1)
Change it from a negative to a positive.
Nope same thing happens... it disappears after 1 second
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.
Pages: 1 2