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
Surprised Looking Script Help
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#1
Surprised Looking Script Help

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-
03-31-2011, 10:00 PM
Find
Streetboat Offline
Posting Freak

Posts: 1,099
Threads: 40
Joined: Mar 2011
Reputation: 56
#2
RE: Surprised Looking Script Help

If the name of the script you want the player to trigger is 'area_name':
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();
}

[Image: signature-2.png]
(This post was last modified: 03-31-2011, 10:32 PM by Streetboat.)
03-31-2011, 10:27 PM
Find
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#3
RE: Surprised Looking Script Help

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


Attached Files
.png   screen-capture-14.png (Size: 42.84 KB / Downloads: 72)
03-31-2011, 11:30 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#4
RE: Surprised Looking Script Help

One small error; all the int alState should be int alStates, just add an s to all those.
04-01-2011, 12:44 AM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#5
RE: Surprised Looking Script Help

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

(This post was last modified: 04-01-2011, 12:55 AM by Pandemoneus.)
04-01-2011, 12:49 AM
Find
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#6
RE: Surprised Looking Script Help

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) =/
04-01-2011, 07:23 AM
Find
Simpanra Offline
Senior Member

Posts: 314
Threads: 28
Joined: Mar 2011
Reputation: 0
#7
RE: Surprised Looking Script Help

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


Attached Files
.png   screen-capture-16.png (Size: 44.23 KB / Downloads: 67)
04-01-2011, 09:21 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#8
RE: Surprised Looking Script Help

Change the 2nd stoplook to another name. You can't have two functions with the same name and parameters.
04-01-2011, 03:43 PM
Find




Users browsing this thread: 1 Guest(s)