Frictional Games Forum (read-only)
Can't get scare script to work - 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: Can't get scare script to work (/thread-19835.html)



Can't get scare script to work - zergling50 - 01-06-2013

Here is my script:

////////////////////////////
// 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);
}
////////////////////////////
// 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 asEntity)
{
SetPlayerActive(false);
StartPlayerLookAt("ScriptArea_2", 2, 3, "StopLook");
AddPropImpulse("arabic_carafe_3", 10, 0, 0, "world");
GiveSanityDamage(3, true);
SetPlayerActive(true);
}
void StopLook()
{
StopPlayerLookAt();
}

im trying to get the LampScare script to work, but as of now the game runs fine but when I enter ScriptArea_1 nothing happens. I get no errors or anything.


RE: Can't get scare script to work - DnALANGE - 01-06-2013

Make it this
void LampScare(string &in asParent, string &in asChild, int alState)


RE: Can't get scare script to work - zergling50 - 01-06-2013

(01-06-2013, 06:38 PM)dnalange Wrote: Make it this
void LampScare(string &in asParent, string &in asChild, int alState)

Thanks! That fixed it.


RE: Can't get scare script to work - stokesie95 - 01-06-2013

(01-06-2013, 06:35 PM)zergling50 Wrote: Here is my script:

////////////////////////////
// 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);
}
////////////////////////////
// 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 asEntity)
{
SetPlayerActive(false);
StartPlayerLookAt("ScriptArea_2", 2, 3, "StopLook");
AddPropImpulse("arabic_carafe_3", 10, 0, 0, "world");
GiveSanityDamage(3, true);
SetPlayerActive(true);
}
void StopLook()
{
StopPlayerLookAt();
}

im trying to get the LampScare script to work, but as of now the game runs fine but when I enter ScriptArea_1 nothing happens. I get no errors or anything.


also you need to add in a timer in because you have a conflict with the "SetPlayerActive(true);" code. create a timer and move it into the timer's callback


RE: Can't get scare script to work - DnALANGE - 01-06-2013

True make it like this->
void LampScare(string &in asEntity)
{
SetPlayerActive(false);
StartPlayerLookAt("ScriptArea_2", 2, 3, "StopLook");
AddPropImpulse("arabic_carafe_3", 10, 0, 0, "world");
GiveSanityDamage(3, true);
SetPlayerActive(true);
AddTimer("", 3.1, "settheplayeractiveagain");
}

void settheplayeractiveagain(string &in asTimer)
{
SetPlayerActive(true);
StopPlayerLookAt();
}

---
Just make the timer like you want it
-btw, you can remove this stoplook behind the StartPlayerLookat..
infact you are making a timer so Just put it in the timer if that will fit the scare\event


RE: Can't get scare script to work - Victor - 01-08-2013

You have to replace asEntity with the entity you want to play the sound, for example, "Player".