Frictional Games Forum (read-only)
Need some help with this script.... - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Need some help with this script.... (/thread-8676.html)

Pages: 1 2


Need some help with this script.... - Doctorcheese - 06-18-2011

So here it is. I'm trying to make it so that when you enter an area called MonsterDoor a suitor called Scarydude starts bashing a door down to get to the player. There will also be a blurring of the screen and the player making a scared sound. Here's the script:

Code:
void OnStart()
{
AddEntityCollideCallback("Player","MonsterDoor","CollidePlayerWithMonsterDoor");
}

void CollidePlayerWithMonsterDoor(string &in asParent, string &in asChild, int alState)
{
ShowEnemyPlayerPosition(''Scarydude'');
FadeRadialBlurto(1.0f, 1.0f);
PlaySoundAtEntity(''MonsterDoor'', ''react_scare6.ogg'', ''Player'', true);
SetEntityActive("Scarydude", true);
}

////////////////////////////
// Run first time starting map
void OnStart()
{

}

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

}

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

}

Is there something wrong here?

Also a side question, anyone know why my game became extremely laggy when I deleted my map's .cache file?

Thanks for any help in advance.


RE: Need some help with this script.... - Roenlond - 06-18-2011

You have two void OnStart() { }. Is the script working at all? Are there errors?


RE: Need some help with this script.... - xtron - 06-18-2011

(06-18-2011, 06:39 PM)Roenlond Wrote: You have two void OnStart() { }. Is the script working at all? Are there errors?

Two void OnStart() ?

Only one is required.


RE: Need some help with this script.... - Doctorcheese - 06-18-2011

Oh snap.. missed that, I'll try editing so there's only one.
Ok so that didn't work. Here's how my entire .hps file for this map looks like;

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player","MonsterDoor","CollidePlayerWithMonsterDoor");
}

void CollidePlayerWithMonsterDoor (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("ScaryDude", true);
ShowEnemyPlayerPosition(''ScaryDude'');    
FadeRadialBlurto(float 1, float 1);
PlaySoundAtEntity(''MonsterDoor'', ''react_scare6.ogg'', ''Player'', true);
}

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

}

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

}

Any errors? The script isn't working at all, nothing happens when I pass the script area. Also might it be the .ogg sound file in the script? Can it playe .ogg's or do they have to be .SNT?


RE: Need some help with this script.... - Roenlond - 06-18-2011

PlaySoundAtEntity needs .snt, yes, but the rest should work anyhow.

Try this

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}

void CollidePlayerWithMonsterDoor (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("ScaryDude", true);
ShowEnemyPlayerPosition(''ScaryDude'');    
FadeRadialBlurTo(1.0f, 1.0f);
PlaySoundAtEntity(''MonsterDoor'', ''react_scare6.ogg'', ''Player'', 0.0f, true);
}

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

}

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

}

If that's not working, double-check that you have matching names in your code and map.


RE: Need some help with this script.... - Doctorcheese - 06-18-2011

I've checked the names and they're all identical. I don't know what the problem could be! Undecided

Here's a picture of the map with the area and the suitor both selected just in case you'd need to take a look at it:

http://imageshack.us/photo/my-images/705/amnesia.png/

Btw, his ''Active'' box should be left unchecked if I want the script to spawn him, right?
Cause it's unchecked now.


RE: Need some help with this script.... - Linus Ă…gren - 06-18-2011

This Line: PlaySoundAtEntity(''MonsterDoor'', ''react_scare6.ogg'', ''Player'', 0.0f, true);
And this line: ShowEnemyPlayerPosition(''ScaryDude'');

I think the problem is that you use TWO ' instead of an actual ". Change the ' ' to " like this:
PlaySoundAtEntity("MonsterDoor", "react_scare6.ogg", "Player", 0.0f, true);
ShowEnemyPlayerPosition("ScaryDude");


RE: Need some help with this script.... - Doctorcheese - 06-18-2011

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}

void CollidePlayerWithMonsterDoor (string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Scarydude", true);
ShowEnemyPlayerPosition("Scarydude");    
FadeRadialBlurTo(1.0f, 1.0f);
PlaySoundAtEntity("MonsterDoor", "react_scare.snt", "Player", 0.0f, true);
}

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

}

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

}

So there's my script now, the names are all identical, the '' are correct now, only one OnStart. And it still won't work Q_Q Dam scripting, yo scary.

Anything that isn't correct in that script? By all logic it's supposed to now spawn the suitor and do the other things...


RE: Need some help with this script.... - Tanshaydar - 06-18-2011

You can use debug messages to check if player actually collides with the area.


RE: Need some help with this script.... - Doctorcheese - 06-18-2011

(06-18-2011, 09:18 PM)Tanshaydar Wrote: You can use debug messages to check if player actually collides with the area.

I'm not too familiar with debug messages, how do I know if I don't collide with it?

Also might it be something I've left unchecked in the Area tab of the Script's Area? I havn't checked any of the options except ''PlayerLookAtCallbackAutoRemove''. Should the others be checked too?