Frictional Games Forum (read-only)
A few script questions.. - 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: A few script questions.. (/thread-16373.html)

Pages: 1 2


A few script questions.. - SiderealStop - 06-21-2012

Still working on figuring out:

This is something that seems like it'd be more complicated...I just don't know how I'd pull it off. My friend and I were thinking of how to start the story. We didn't want to just have our character wake up and be like 'wtf, where am?' and be on with it. We thought about this: He wakes up because he hears crashing or something, something comes into his room, a grunt. The player's vision is not so great, maybe the flashback-type of vision? The player is forced to sit up and look at the creature. It attacks and kills the player. (all happens in a few seconds.) When the player respawns, it'll seem like they'd just been knocked out, but now they're in a different map almost identical to the first, only everything is messy and stuff is knocked over, there's a bit of blood and stuff. Player is rolled up into a sitting position and then you gain control of the player.

Been given tutorials and am working on figuring it all out, but any extra tips/help would be amazing! Thanks~


RE: A few script questions.. - Nice - 06-21-2012

music script is this

void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);


RE: A few script questions.. - SiderealStop - 06-21-2012

Thanks for the help! I'm not sure how to put that in and where to put the name of the music file though... Sorry xD Still a bit new to this!

I only have this in the script so far:

void OnStart()
{
}

So where would I put that?


RE: A few script questions.. - Cruzore - 06-21-2012

void OnStart()
{
}
void OnEnter()
{
PlayMusic("yourmusicnamehere.ogg", true, 2, 0, 10, true);
}
the first true is for looping, e.g. if the sound should loop. It should be true if you want some sort of ambient music, false if you want to use it once.
the 2 is the volume. try different out.

For question 2, is that just a "room" or a whole map where that circle is?
For question 3, you should first look at Your Computer's wake up tutorial(http://www.frictionalgames.com/forum/thread-10798.html), then look at the Engine scripts page([url]http://wiki.frictionalgames.com/hpl2/amnesia/script_functions[/url]) and see how you could do it.


RE: A few script questions.. - SiderealStop - 06-21-2012

Thanks so much! The music works! =D



Question 2- Here's what it looks like: http://i1022.photobucket.com/albums/af350/Slapkat/MachineryRoom.png



Question 3 - Ah thanks! =D I'll update first post if I can figure it
out. I've followed a few tutorials and such and was able to figure out a
few things with this scripting before so I should be able to get it. ^^


RE: A few script questions.. - Cruzore - 06-21-2012

for question 2, put all the stuff in OnEnter() and delete the "callbackfunctionarea in level editor".
for the patrolling, someone already made a post I believe, use the search option.


RE: A few script questions.. - SiderealStop - 06-21-2012

Ah I had, I must have missed it. Oops ^^

I've looked at quite a few things on patrolling and couldn't find anything that worked. =3 That or I'm a complete idiot and am completely getting the script wrong ;A;

So I tried that and I think I remember doing this before...tried it again anyway, this is how my script now looks. I think I'm doing something wrong:

Code:
void onstart()
{
    AddEntityCollideCallback("Player", "PlayerCollide", "servant_grunt_1", true, 1);
}
    OnEnter()
    void MachineryGruntPatrol(string &in asParent , string &in asChild , int alState)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 1, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}

Then I run the game and load my map, walk down the first hallway and through the level door that brings me to the room with the grunt. The game crashes on the loading screen with this message:

FATAL ERROR: Could not load script file 'my directory/filename.hps'!
ExecuteString (1,1): ERR :no matching signatures to 'OnLeave()'
main (5,9) : ERR :Expected identifier


RE: A few script questions.. - Cruzore - 06-21-2012

first line, it's OnStart()
not onstart()
also, put a void before OnEnter()


RE: A few script questions.. - SiderealStop - 06-21-2012

I realized I missed the void actually, and I thought OnStart/OnEnter/OnLeave weren't case sensitive?

Anyway this is what it now looks like, and it's still crashing - with the same error message - upon hitting the loading screen:

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "PlayerCollide", "servant_grunt_1", true, 1);
}
void OnEnter()
    void MachineryGruntPatrol(string &in asParent , string &in asChild , int alState)
{
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 1, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 4, "");
}



RE: A few script questions.. - Cruzore - 06-21-2012

delete this line:
void MachineryGruntPatrol(string &in asParent , string &in asChild , int alState)