Frictional Games Forum (read-only)

Full Version: SetEntityPlayerLookAtCallback Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys!

Here's my problem:
If you look at an arm, lying in the drawer, the SetEntityPlayerLookAtCallback should trigger.
Now you can't see the arm (because it's in the drawer, which is closed), but the function gets called, and triggers my actions.

Is there any way to only run the function, if I really can SEE the arm, and
not looking at the point where the arm is (Doesn't matter if you see it or not)?
(07-06-2011, 10:45 PM)MrCookieh Wrote: [ -> ]Hello guys!

Here's my problem:
If you look at an arm, lying in the drawer, the SetEntityPlayerLookAtCallback should trigger.
Now you can't see the arm (because it's in the drawer, which is closed), but the function gets called, and triggers my actions.

Is there any way to only run the function, if I really can SEE the arm, and
not looking at the point where the arm is (Doesn't matter if you see it or not)?

No, but from your situation what you really want to happen is to alter the sanity when the drawer is opened, right?
There are probably several ways to do this, but a collision callback between the chest-of-drawers entity and a script area (positioned such that it is triggered when the drawer with the arm is pulled out) should achieve this in a very simple, robust manner without creating new entities.

For example:
Code:
void OnStart()
{
AddEntityCollideCallback("chest_of_drawers_42", "AreaDraw", "collideAreaDraw", true, 1);
}

void collideAreaDraw(string &in asParent, string &in asChild, int alState)
{
AddDebugMessage(" BOO! ", false);
//Sanity stuff
}

You might also want to look at CH01/11_study.hps for how the scripted skulls sanity effect is done (note that the desk entity is split into a desk & a desk door, which isn't the case for drawers).
I was have similar problem. You must for example next to drawer create area which is called when drawer is ejected. After SetEnttiyActive (arm) on true and call SetEntityPlayerLookAtCallback. Simple (function on function ;p)
Thanks to both of you, it works perfectly!