Frictional Games Forum (read-only)

Full Version: Surprised Looking Script Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys,
I am learning some C++ and Java script atm but i still require a bit of hands on knowledge of amnesia scripting (as i have now dubbed it).
I would really like to know how to script it so that when the player stands on a script area he spins around to look at a specific object (location?). My scenario is this;
I have managed to (with a lot of help from forum members) script part of my level so that a door slams shut as the character reaches a script area which is about one metre past the door. I want that same script area to make the player spin and look at the door that has slammed shut.
I would very much appreciate some help in how i would go about doing this =)
Thank you so much,
Simpanra-
If the name of the script you want the player to trigger is 'area_name':
Code:
void OnStart()
{
AddEntityCollideCallback("Player", "area_name", "script_callback", true, 1);
}

void script_callback(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("door_name", 10.0f, 10.0f, "");
AddTimer("", 1.0f, "stoplook");
}

void stoplook(string &in asTimer)
{
StopPlayerLookAt();
}
Hmmm, i have put that script into my hps and the game still loads fine, but the script doesn't seem to take effect =( Here is a screenshot...have i done it correctly? =)
One small error; all the int alState should be int alStates, just add an s to all those.
(04-01-2011, 12:44 AM)MrBigzy Wrote: [ -> ]One small error; all the int alState should be int alStates, just add an s to all those.

Err.. no. ^^
Formal parameters can be named like you want, you just have to use the same name inside the function.

You could use
void script_callback(string &in a, string &in b, int c)
aswell
The thing that is wrong is that you used the entity in the AddEntityCollideCallback instead of the script area, so the function would only be called when you bump the door (or whatever cellar_wood01_1 is).
ah ok....so how do i set the target i want him to look at then? (thats what i thought i was doing at that point) =/
Aha! Success! I have managed to get him to look at the door when it slams shut, now i just need to get him too look at the Grunt when it spawns behind him (a little bit further through the level). I have tried duplicating the script i used to make him look at the door and re-setting the names to the Grunt, however it doesn't work (the map just doesn't load...yet again) I have attached a new image with my newest update of the script, im sorry about this guys) =/
Change the 2nd stoplook to another name. You can't have two functions with the same name and parameters.