Frictional Games Forum (read-only)
Amnesia crashes due to unexpected end in my .HPS file - 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 Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Amnesia crashes due to unexpected end in my .HPS file (/thread-16570.html)



Amnesia crashes due to unexpected end in my .HPS file - EddieShoe - 06-28-2012

So I've been using this script for a while, but after I added the latest section it says: main (58, 2) : ERR Unexpected end of file. Any suggestions? It's been working so far :/ It crashes on game startup and it started after I added the "CastleSecret" func and the void for it, the bottom part of the script.

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "FlyingBodyArea", "FlyingBody", true, 1);
AddEntityCollideCallback("Player", "PotExplodeArea", "Explode", true, 1);
SetEntityConnectionStateChangeCallback("CastleLever", "CastleDoorOpen");
SetEntityConnectionStateChangeCallback("SecretLever", "CastleSecret");
}

void FlyingBody(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("pant1", "24_iron_maiden.snt", "Player", 2, true);
    SetPropHealth("CorpseWindow", 0);
    SetEntityActive("FlyingCorpse", true);
    AddPropImpulse("FlyingCorpse", -30, 0, 0, "world");
}

void Explode(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("pant2", "scare_wind.snt", "Player", 2, true);
    SetPropHealth("ExplodePot", 0);
}

void CastleDoorOpen(string &in asEntity, int alState)
{
    if (alState == 1)
{
    SetSwingDoorLocked("mansion_3", false, true);
    SetSwingDoorLocked("CastleDoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
return;
}

void CastleSecret(string &in asEntity, int alState)
{
    if (alState == 1)
{
    SetMoveObjectState("CastleSecretShelf",1.0f);
    PlaySoundAtEntity("", "quest_completed.snt", "Player", 0, false);  
return;

}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}



RE: Amnesia crashes due to unexpected end in my .HPS file - Rapture - 06-28-2012

Your right, your missing a ending squiggly bracket for your "CastleSecret" & "CastleDoorOpen".


RE: Amnesia crashes due to unexpected end in my .HPS file - EddieShoe - 06-28-2012

(06-28-2012, 11:19 PM)Rapture Wrote: Your right, your missing a ending squiggly bracket for your "CastleSecret" & "CastleDoorOpen".
Uhm, sorry if this is a stupid question. But where exactly do you mean? Been looking for a while and I can't find what you mean, and "squiggly bracket", is that the { } ?


RE: Amnesia crashes due to unexpected end in my .HPS file - Adny - 06-28-2012

Here you go:


////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "FlyingBodyArea", "FlyingBody", true, 1);
AddEntityCollideCallback("Player", "PotExplodeArea", "Explode", true, 1);
SetEntityConnectionStateChangeCallback("CastleLever", "CastleDoorOpen");
SetEntityConnectionStateChangeCallback("SecretLever", "CastleSecret");
}

void FlyingBody(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("pant1", "24_iron_maiden.snt", "Player", 2, true);
SetPropHealth("CorpseWindow", 0);
SetEntityActive("FlyingCorpse", true);
AddPropImpulse("FlyingCorpse", -30, 0, 0, "world");
}

void Explode(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("pant2", "scare_wind.snt", "Player", 2, true);
SetPropHealth("ExplodePot", 0);
}

void CastleDoorOpen(string &in asEntity, int alState)
{
if (alState == 1)
{
SetSwingDoorLocked("mansion_3", false, true);
SetSwingDoorLocked("CastleDoor", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Player", 0, false);
}
}

void CastleSecret(string &in asEntity, int alState)
{
if(alState == 1)
{
SetMoveObjectState("CastleSecretShelf",1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "Player", 0, false);
}
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}


RE: Amnesia crashes due to unexpected end in my .HPS file - EddieShoe - 06-28-2012

It worked, thanks a lot! May I ask why this additional } is required on that func? I've never used 2 before, It's my first day using the scripts so I'm not that good at it :-)


RE: Amnesia crashes due to unexpected end in my .HPS file - Adny - 06-28-2012

(06-28-2012, 11:35 PM)EddieShoe Wrote: It worked, thanks a lot! May I ask why this additional } is required on that func? I've never used 2 before, It's my first day using the scripts so I'm not that good at it :-)
I must start by saying WOW if thats your first try at scripting and you've already implemented if/else statements. Anyways:

For if/else statements, think of it as a function within a function (funception!).

void Function()
{

}

^^ That is the most basic function, adding the if/else statement takes it one step further, and 2 additional brackets need to be added in the same manner, like so:

void Function()
{
if(alState = 1)
{
//second part
}
}


Basically, there needs to be equal amounts of open "{" and closed "}" brackets for the script to work properly.


RE: Amnesia crashes due to unexpected end in my .HPS file - EddieShoe - 06-28-2012

(06-28-2012, 11:39 PM)andyrockin123 Wrote:
(06-28-2012, 11:35 PM)EddieShoe Wrote: It worked, thanks a lot! May I ask why this additional } is required on that func? I've never used 2 before, It's my first day using the scripts so I'm not that good at it :-)
I must start by saying WOW if thats your first try at scripting and you've already implemented if/else statements. Anyways:

For if/else statements, think of it as a function within a function (funception!).

void Function()
{

}

^^ That is the most basic function, adding the if/else statement takes it one step further, and 2 additional brackets need to be added in the same manner, like so:

void Function()
{
if(alState = 1)
{
//second part
}
}


Basically, there needs to be equal amounts of open "{" and closed "}" brackets for the script to work properly.
Thanks, that was very helpful! I realized that when you said it, there was something familiar in RPG Maker VX which I used before, the "condition branch". May I be rude and ask for another thing? I've tried googling it myself but with no results.

When the bookshelf rotates, it rotates, obviously. But it's empty so the secret is so obvious! If I put books in it they stand still while it rotates, as expected. So I tried using the "ConnectedProps" thingie but nothing happened there either. Any suggestions? I'm searching myself at the moment, but any help is much appreciated!

(Dunno if I can ask Off-Topic questions here, if so tell me. This is a new problem.)


RE: Amnesia crashes due to unexpected end in my .HPS file - Rapture - 06-29-2012

Well if you know how to use the Model Editor, you can convert the static_objects (I'm guessing your using the Stacked Books. Their not static_objects, but they have no body mass shall we say.) into entities that can be moved around.

http://wiki.frictionalgames.com/hpl2/tutorials/scripting/elevator_tutorial

I haven't finished this tutorial, but I got around the part to where you can convert a static_object to a entity (Still isn't even completed) but it has the neccesary steps for wha your doing. Just scroll down to the part with the Elevator and me opening it up in the Model Editor...

Or if you don't want to concern yourself with all that rubbish...

You can just put the individual books + other moveable objects on the Shelf instead.