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
problem with scare script
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#1
problem with scare script

I want to make it so that a door flings open and there is a man (corpse) standing on the other side, and then he suddenly disappears.
It gives me an error and terminates the program when I launch and I can't find the problem.

Here's my code:
(*note the code im talking about is CorpseDoorScare*)
////////////////////////////
// Run when starting map
void OnStart()
{
SetEntityPlayerInteractCallback("mansion_1", "GetCrowDoorQuest", true);
AddUseItemCallback("", "crowbar_1", "mansion_1", "CrowDoorBreak", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "LampScare", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "CorpseDoorScare", true, 1);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}

void GetCrowDoorQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("", "crowdoorquest");
}
void CrowDoorBreak(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "break_wood_metal", asEntity, 0.0f, false);
PlaySoundAtEntity("", "impact_metal_high", asEntity, 0.0f, false);
SetPropHealth(asEntity, 0);
GiveSanityBoostSmall();
SetEntityActive("crowbar_broken_1", true);
RemoveItem(asItem);
SetMessage("GameMessage", "crow_door_message", 4);
}
void CompleteCrowDoor(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("", "crowdoorquest");
}
void LampScare(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
StartPlayerLookAt("ScriptArea_2", 2, 3, "StopLook");
AddPropImpulse("arabic_carafe_3", 10, 0, 0, "world");
GiveSanityDamage(3, true);
SetPlayerActive(true);
}
void StopLook()
{
StopPlayerLookAt();
}
void CorpseDoorscare(string &in asParent, string &in asChild, int alState);
{
SetPlayerActive(false);
SetEntityActive("corpse_male_1", true);
AddPropImpulse("mansion_6", 20, 0, 0, "world");
StartPlayerLookAt("corpse_male_1", 2, 3, "StopLook2");
PlaySoundAtEntity("", "insanity_baby_cry_custom", asEntity, 0.0f, false);
PlaySoundAtEntity("", "insanity_imageflash01_custom", asEntity, 0.0f, false);
}
void StopLook2()
{
StopPlayerLookAt();
SetEntityActive("corpse_male_1", false);
SetPlayerActive(true);
}

FYI, the custom sounds are in a folder within my custom story that is labeled correctly, they work in other maps so I know that's not the problem.
(This post was last modified: 06-13-2013, 08:15 PM by zergling50.)
01-06-2013, 10:18 PM
Find
Rapture Offline
Posting Freak

Posts: 1,078
Threads: 79
Joined: May 2011
Reputation: 30
#2
RE: problem with scare script

AddEntityCollideCallback("Player", "ScriptArea_3", "CorpseDoorScare", true, 1);

=/=

void CorpseDoorscare(string &in asParent, string &in asChild, int alState);

Put DebugMessages in your code to see if it runs, it would help determine if you have spelled something wrong, like in this case.
(This post was last modified: 01-06-2013, 10:35 PM by Rapture.)
01-06-2013, 10:33 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#3
RE: problem with scare script

Also, any time you get an error, please post that too. It helps us pinpoint the error's location.

01-07-2013, 03:10 AM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#4
RE: problem with scare script

(01-06-2013, 10:33 PM)Rapture Wrote: AddEntityCollideCallback("Player", "ScriptArea_3", "CorpseDoorScare", true, 1);

=/=

void CorpseDoorscare(string &in asParent, string &in asChild, int alState);

Put DebugMessages in your code to see if it runs, it would help determine if you have spelled something wrong, like in this case.

How do I add DebugMessages to my code so that it will work? Is it on the frictional games srict engine website (if so I can figure it out myself)

(01-07-2013, 03:10 AM)Damascus Wrote: Also, any time you get an error, please post that too. It helps us pinpoint the error's location.

I fixed the spelling error but the game still crashes and I get an error. The error reads:

FATAL ERROR: Could not load script file 'custom_stories/a/maps/04.hps'! main (52, 1) : ERR : Unexpected token '{'
(This post was last modified: 01-08-2013, 01:46 AM by zergling50.)
01-08-2013, 01:34 AM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#5
RE: problem with scare script

Debug Messages:
These won't magically make your code work, but you can use them to see if parts of your code (like functions) get called at all, once the script compiles without error messages. A debug message will show up in the lower left part of the screen, when it's line of code gets executed.

To use them, simply type:
AddDebugMessage("Whatever message you want goes here.", false);

The second parameter (false) just indicates if the engine should check for duplicate messages or not, you can ignore it for now.

For example, to see if a specific function get's called (useful for misbehaving callbacks), put something like this at the start of the function (after the '{').
AddDebugMessage("Inside FunctionNameHere", false);

This is documented on the wiki, on the Engine Scripts page.

Error:
The error means, most likely, that on line 52 (or somewhere close, above or below) there's an extra '{' that's not supposed to be there.

Make sure that there's all '{' and '}' are exactly matched. The '{' starts a block of code, '}' ends it. Think of it as of a "folder" for code. They need to be matched.

Also, there can't be any free {} blocks at the top level - there must be a function associated with it. This second case can also occur if there's a ';' at the end of the function declaration (function "header"), since semicolon ends statements, so the code block below it becomes "orphaned".
Check if there's a function declaration ending with a ';' just above, on line 51, or close by.
EDIT: I checked it for you, it's visible in your first post. Here:

void CorpseDoorscare(string &in asParent, string &in asChild, int alState);

Delete that ';'.
(This post was last modified: 01-08-2013, 02:04 AM by TheGreatCthulhu.)
01-08-2013, 02:02 AM
Find
Victor Offline
Member

Posts: 83
Threads: 19
Joined: Oct 2011
Reputation: 2
#6
RE: problem with scare script

"PlaySoundAtEntity("", "impact_metal_high", asEntity, 0.0f, false);"
You have to replace asEntity with the entity you want the sound to play on.
In all of them.
(This post was last modified: 01-08-2013, 04:37 PM by Victor.)
01-08-2013, 04:32 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#7
RE: problem with scare script

The unexpected token { error seems to refer specifically to this part:

void CorpseDoorscare(string &in asParent, string &in asChild, int alState);

{

SetPlayerActive(false);

SetEntityActive("corpse_male_1", true);

AddPropImpulse("mansion_6", 20, 0, 0, "world");

StartPlayerLookAt("corpse_male_1", 2, 3, "StopLook2");

PlaySoundAtEntity("", "insanity_baby_cry_custom", asEntity, 0.0f, false);

PlaySoundAtEntity("", "insanity_imageflash01_custom", asEntity, 0.0f, false);

}

That first semicolon should not be there.

01-08-2013, 08:14 PM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#8
RE: problem with scare script

I know it has been a while since I last made this post, I had to take a break from the custom story for a bit but I am back at it now. I still can't seem to get it to work and I have taken what you guys have said into consideration. Here is what my code is currently.
////////////////////////////
// Run when starting map
void OnStart()
{
SetEntityPlayerInteractCallback("mansion_1", "GetCrowDoorQuest", true);
AddUseItemCallback("", "crowbar_1", "mansion_1", "CrowDoorBreak", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "LampScare", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_3", "CorpseDoorScare", true, 1);

}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
void GetCrowDoorQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("", "crowdoorquest");
}
void CrowDoorBreak(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "break_wood_metal", asEntity, 0.0f, false);
PlaySoundAtEntity("", "impact_metal_high", asEntity, 0.0f, false);
SetPropHealth(asEntity, 0);
GiveSanityBoostSmall();
SetEntityActive("crowbar_broken_1", true);
RemoveItem(asItem);
SetMessage("GameMessage", "crow_door_message", 4);
}
void CompleteCrowDoor(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("", "crowdoorquest");
}
void LampScare(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
StartPlayerLookAt("ScriptArea_2", 2, 3, "StopLook");
AddPropImpulse("arabic_carafe_3", 10, 0, 0, "world");
GiveSanityDamage(3, true);
SetPlayerActive(true);
}
void StopLook()
{
StopPlayerLookAt();
}
void CorpseDoorScare(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
SetEntityActive("corpse_male_1", true);
AddPropImpulse("mansion_6", 20, 0, 0, "world");
StartPlayerLookAt("corpse_male_1", 2, 3, "StopLook2");
PlaySoundAtEntity("", "insanity_baby_cry_custom", asEntity, 0.0f, false);
PlaySoundAtEntity("", "insanity_imageflash01_custom", asEntity, 0.0f, false);
}
void StopLook2()
{
StopPlayerLookAt();
SetEntityActive("corpse_male_1", false);
SetPlayerActive(true);
}
It is giving the same error and aborting the game, I am unsure of the problem.
04-06-2013, 08:16 PM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#9
RE: problem with scare script

Still giving this exact error?

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

[Image: Tv0YgQb.gif]
Image by BandyGrass
04-06-2013, 08:29 PM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#10
RE: problem with scare script

(04-06-2013, 08:29 PM)Kreekakon Wrote: Still giving this exact error?

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

Actually now it is saying
FATAL ERROR: Could no load script file 'custom_stories/a/maps/04.hps'!
main (69, 55) : ERR : 'asEntity' is not declared
main (70, 5) : ERR : No matching signatures to 'PlaySoundAtEntity(string@&, string@&, int, const float, const bool)'


from looking at this I can tell the first problem is with asEntity so ill look into that and the second one mentions playsoundatentity but I don't know what the problem with it is.
04-06-2013, 09:01 PM
Find




Users browsing this thread: 2 Guest(s)