Frictional Games Forum (read-only)
Surprised Looking Script Help - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Surprised Looking Script Help (/thread-7134.html)



Surprised Looking Script Help - Simpanra - 03-31-2011

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-


RE: Surprised Looking Script Help - Streetboat - 03-31-2011

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



RE: Surprised Looking Script Help - Simpanra - 03-31-2011

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? =)


RE: Surprised Looking Script Help - MrBigzy - 04-01-2011

One small error; all the int alState should be int alStates, just add an s to all those.


RE: Surprised Looking Script Help - Pandemoneus - 04-01-2011

(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).


RE: Surprised Looking Script Help - Simpanra - 04-01-2011

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) =/


RE: Surprised Looking Script Help - Simpanra - 04-01-2011

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) =/


RE: Surprised Looking Script Help - MrBigzy - 04-01-2011

Change the 2nd stoplook to another name. You can't have two functions with the same name and parameters.