Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 16 Vote(s) - 4.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripts Recollection
Zinnkio Offline
Junior Member

Posts: 14
Threads: 3
Joined: Feb 2011
Reputation: 0
#61
RE: Scripts Recollection

Whats would be the script for making the player look at something and give sanity damage when he enters an area??

Out Of All The Things I Fear Most, Death Is One Of Them. But One Day I Will Become It.
02-26-2011, 04:42 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#62
RE: Scripts Recollection

void OnStart()
{
AddEntityCollideCallback("Player", "AreaSanity", "CollideAreaSanity", true, 1);
}

void CollideAreaSanity(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("objectname", 2.0f, 2.0f, "");
GiveSanityDamage(50.0f, true);
AddTimer("xyz", 1.0f, "TimerStopLookAt");
}

void TimerStopLookAt(string &in asTimer)
{
StopPlayerLookAt();
}

[Image: 18694.png]
02-26-2011, 05:28 PM
Find
Zinnkio Offline
Junior Member

Posts: 14
Threads: 3
Joined: Feb 2011
Reputation: 0
#63
Question  RE: Scripts Recollection

(02-26-2011, 05:28 PM)Ongka Wrote: void OnStart()
{
AddEntityCollideCallback("Player", "AreaSanity", "CollideAreaSanity", true, 1);
}

void CollideAreaSanity(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("objectname", 2.0f, 2.0f, "");
GiveSanityDamage(50.0f, true);
AddTimer("xyz", 1.0f, "TimerStopLookAt");
}

void TimerStopLookAt(string &in asTimer)
{
StopPlayerLookAt();
}

Much Appreciated
(02-26-2011, 05:28 PM)Ongka Wrote: void OnStart()
{
AddEntityCollideCallback("Player", "AreaSanity", "CollideAreaSanity", true, 1);
}

void CollideAreaSanity(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("objectname", 2.0f, 2.0f, "");
GiveSanityDamage(50.0f, true);
AddTimer("xyz", 1.0f, "TimerStopLookAt");
}

void TimerStopLookAt(string &in asTimer)
{
StopPlayerLookAt();
}

If I were to add a sound would I add

PlaySoundAtEntity("", "Sound_3", "player", 0.5f, false);

under

AddTimer("xyz", 1.0f, "TimerStopLookAt");

I'm a newbe to this...

Out Of All The Things I Fear Most, Death Is One Of Them. But One Day I Will Become It.
(This post was last modified: 02-26-2011, 06:27 PM by Zinnkio.)
02-26-2011, 05:49 PM
Find
nkmol Offline
Senior Member

Posts: 252
Threads: 19
Joined: Feb 2011
Reputation: 4
#64
RE: Scripts Recollection

(02-26-2011, 05:49 PM)Zinnkio Wrote: If I were to add a sound would I add

PlaySoundAtEntity("", "Sound_3", "player", 0.5f, false);

under

AddTimer("xyz", 1.0f, "TimerStopLookAt");

I'm a newbe to this...

if you want the sound to be played when you're done whith looking at the object, you should put it under AddTimer.
When you want the sound to be played when the player is looking at the object, you should put it under CollideAreaSanit.
02-26-2011, 07:18 PM
Find
Zinnkio Offline
Junior Member

Posts: 14
Threads: 3
Joined: Feb 2011
Reputation: 0
#65
RE: Scripts Recollection

If I were to add a sound would I add

PlaySoundAtEntity("", "Sound_3", "player", 0.5f, false);

under

AddTimer("xyz", 1.0f, "TimerStopLookAt");

I'm a newbe to this...
[/quote]

if you want the sound to be played when you're done whith looking at the object, you should put it under AddTimer.
When you want the sound to be played when the player is looking at the object, you should put it under CollideAreaSanit.
[/quote]

All sorted, thanks anyway. Any Feedback on my Test.map would be great.
[attachment=1120]

Out Of All The Things I Fear Most, Death Is One Of Them. But One Day I Will Become It.
(This post was last modified: 02-26-2011, 09:58 PM by Zinnkio.)
02-26-2011, 09:55 PM
Find
kozek Offline
Junior Member

Posts: 3
Threads: 0
Joined: Feb 2011
Reputation: 0
#66
RE: Scripts Recollection

I changed Subitemname on the key but I couldn't do it on the door.
But then when I load the Story this comes up:

FATAL ERROR: Could not load script file 'custom_stories/***/maps/***.hps'! main (21, 1) : ERR : Unexpected token '{'.

And this is how my script looks like:
{
AddUseItemCallback("", "key_prison_1", "prison_section_plain_6", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_section_plain_6", true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_section_plain_6", 0.0f, true);
}
03-01-2011, 07:12 PM
Find
nkmol Offline
Senior Member

Posts: 252
Threads: 19
Joined: Feb 2011
Reputation: 4
#67
RE: Scripts Recollection

I suppose its OnStart() or OnEnter()?
Did it Worked before?
03-01-2011, 11:31 PM
Find
kozek Offline
Junior Member

Posts: 3
Threads: 0
Joined: Feb 2011
Reputation: 0
#68
RE: Scripts Recollection

No, I haven't gotten it to work at all
03-04-2011, 05:45 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#69
RE: Scripts Recollection

OnStart()
{
AddUseItemCallback("", "key_prison_1", "prison_section_plain_6", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_section_plain_6", true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_section_plain_6", 0.0f, true);
}

03-04-2011, 05:47 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#70
RE: Scripts Recollection

The { and } encompass a body of a function - the function body is where you put all the work that needs to be done.
The { and } obviously need to match.

This is preceded by a function signature, comprising of:
return_type FunctionName(parameter_list)
where parameter_list may be empty.

So, whenever you get a similar error (unexpected token '{'), you either have an extra (or a few extra) of { or }, or as in your case, you have a missing function signature.

The previous posters most likely guessed the candidate methods correctly, since you would typically assign callback functions for this type of events in OnStart() or OnEnter().

Except for one thing: you should type
void OnStart()
{
// whatever...
}


BTW, can someone more experienced with HPL2 scripting tell me what is the key difference between OnStart() and OnEnter(), their descriptions are a little vague?
When is OnStart() called? When the level is first loaded? Just once?
And OnEnter() - is it called every time the player comes back to the level?
What?
(This post was last modified: 03-04-2011, 11:03 PM by TheGreatCthulhu.)
03-04-2011, 11:01 PM
Find




Users browsing this thread: 2 Guest(s)