Frictional Games Forum (read-only)
Scripts Recollection - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Scripts Recollection (/thread-5117.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


RE: Scripts Recollection - Zinnkio - 02-26-2011

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


RE: Scripts Recollection - Ongka - 02-26-2011

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


RE: Scripts Recollection - Zinnkio - 02-26-2011

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


RE: Scripts Recollection - nkmol - 02-26-2011

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


RE: Scripts Recollection - Zinnkio - 02-26-2011

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]


RE: Scripts Recollection - kozek - 03-01-2011

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


RE: Scripts Recollection - nkmol - 03-01-2011

I suppose its OnStart() or OnEnter()?
Did it Worked before?


RE: Scripts Recollection - kozek - 03-04-2011

No, I haven't gotten it to work at all


RE: Scripts Recollection - Pandemoneus - 03-04-2011

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


RE: Scripts Recollection - TheGreatCthulhu - 03-04-2011

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?