Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking at, or not looking at script
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
Looking at, or not looking at script

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?

Trying is the first step to success.
05-06-2012, 01:14 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#2
RE: Looking at, or not looking at script

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.

05-06-2012, 01:26 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Looking at, or not looking at script

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

Trying is the first step to success.
05-06-2012, 01:41 PM
Find
Xanthos Offline
Senior Member

Posts: 318
Threads: 9
Joined: Mar 2012
Reputation: 8
#4
RE: Looking at, or not looking at script

(alState == 1)
Try dat :3

05-06-2012, 01:44 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Looking at, or not looking at script

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);
}

Trying is the first step to success.
(This post was last modified: 05-06-2012, 02:24 PM by FlawlessHappiness.)
05-06-2012, 01:49 PM
Find
Dutton Offline
Member

Posts: 121
Threads: 3
Joined: Apr 2012
Reputation: 2
#6
RE: Looking at, or not looking at script

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

[Image: 15isy6C]
(This post was last modified: 05-06-2012, 04:48 PM by Dutton.)
05-06-2012, 04:47 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Looking at, or not looking at script

(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

Trying is the first step to success.
05-06-2012, 05:56 PM
Find
Xanthos Offline
Senior Member

Posts: 318
Threads: 9
Joined: Mar 2012
Reputation: 8
#8
RE: Looking at, or not looking at script

Why not try my idea?

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

05-06-2012, 09:29 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: Looking at, or not looking at script

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

Trying is the first step to success.
05-06-2012, 09:35 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#10
RE: Looking at, or not looking at script

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.

05-07-2012, 05:45 AM
Find




Users browsing this thread: 1 Guest(s)