(07-15-2013, 02:17 PM)Alex Ros Wrote: New question.
Is it possible to script areas so when a player just looks at them the voiced over monologue would be pronounced aloud? I mean free-roaming and free-looking. For example, if a player by himself will look at the window (just for example) and at the moment he will point his eyes at the window a voiced-over monologue would be triggered? Is that possible at all? Without touching anything, just by looking at some particular area.
I presume it's not possible. I suppose it's not possible with just a player looking at something. I suppose player should enter the area and that would trigger voice-script, no other way... or I am wrong and looking at the area is also could trigger scripted voice-over?
Yeh it's totally possible.
http://wiki.frictionalgames.com/hpl2/amn...s#entities
5th on the list for Entity related functions is SetEntityPlayerLookAtCallback, you can use a script area in place of the entity name. Then in the function that the LookAtCallback calls, you can use PlayMusic or whichever function suits for the sound files you have
Here's some sample code
void OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea", "LookedAtWindow", true);
}
void LookedAtWindow(string &in strEntity, int inState)
{
PlayMusic("Talking.ogg", false, 10, 0, 1, false);
}
I'm only using the PlayMusic function because it's the simplest, you'll only need the sound file in .ogg to use it. Check out the details for the parameters to give to PlayMusic so that it suits you're needs.
With the LookAtCallback, once you've implemeneted that test it to make sure it doesn't trigger through a wall, I've had issues with that before. You could potentially make the window into an Entity just for the purposes of using that function in case you have problems with the script area.
EDIT: ninja'd! scum! oh well. In addition to all that Alex, you may find it useful to take the time to read through the whole list of functions on the engine script page. You don't need to understand them all, or even know how to use them instantly, but it's really helpful just from the name & descriptions to know what is technically possible given the options there. Many people underestimate how important it is just to have a basic overview of everything first, before you get into specifics