Frictional Games Forum (read-only)
Scripting a LookAt? - 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: Scripting a LookAt? (/thread-6300.html)



Scripting a LookAt? - Linus Ågren - 01-20-2011

Well, I have tried scripting a LookAt event, but it doesn't work. What's wrong with this script? The Monster Spawn is working perfectly btw.

Code:
void CollideAreaMonster(string &in asParent, string &in asChild, int alState)
{
  StartPlayerLookAt("corpses", 6.0f, 5.0f, "");
  PlaySoundAtEntity("ScareSound2", "react_pant.snt", "Player", 0, true);
  GiveSanityDamage(6.0f, true);
  AddTimer("look_at_corpses", 0.5f, "corpses_scare");
}

void corpses_scare(string &in asTimer)
{
  StopPlayerLookAt();
}

void ClosetMonster(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("grunt_1", true);
  ShowEnemyPlayerPosition("grunt_1");
}


////////////////////////////
// Run first time starting map
void OnStart()
{
  AddEntityCollideCallback("Player", "closetScare" , "ClosetMonster" , true , 1);
  AddEntityCollideCallback("Player", "corpseScare" , "corpses_scare" , true , 1);
}



RE: Scripting a LookAt? - jens - 01-20-2011

AddEntityCollideCallback("Player", "corpseScare" , "corpses_scare" , true , 1);
Is meant to be?
AddEntityCollideCallback("Player", "corpseScare" , "CollideAreaMonster" , true , 1);


RE: Scripting a LookAt? - Linus Ågren - 01-20-2011

Nope, no differance =/
It worked without the timer, but then my char would look at that place forever.


RE: Scripting a LookAt? - Vradcly - 01-20-2011

I did like this, maybe you can find what is missing by comparing?

AddEntityCollideCallback("Player", "Torso_area1", "CollideTorso_area1", true, 1);

void CollideTorso_area1(string &in asParent, string &in asChild, int alState)
{
AddDebugMessage("Looking at torso", false);
StartPlayerLookAt("corpse_male_1", 10, 10, "");
AddTimer("stoplook", 25.0f, "TimerStopLook");
}

void TimerStopLook(string &in asTimer)
{
AddDebugMessage("Stoped looking", false);
StopPlayerLookAt();
}

Im getting confused by your code so I cant say exactly what you have to do,
hopefully that will help Smile


RE: Scripting a LookAt? - Seragath - 01-21-2011

Code:
void CollideAreaMonster(string &in asParent, string &in asChild, int alState)
{
  StartPlayerLookAt("corpses", 6.0f, 5.0f, "");
  PlaySoundAtEntity("ScareSound2", "react_pant.snt", "Player", 0, true);
  GiveSanityDamage(6.0f, true);
  AddTimer("look_at_corpses", 0.5f, "corpses_scare"); // Change the timer to 6.0f not 0.5f
}

void corpses_scare(string &in asTimer)
{
  StopPlayerLookAt();
}

void ClosetMonster(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("grunt_1", true);
  ShowEnemyPlayerPosition("grunt_1");
}


////////////////////////////
// Run first time starting map
void OnStart()
{
  AddEntityCollideCallback("Player", "closetScare" , "ClosetMonster" , true , 1);
  AddEntityCollideCallback("Player", "corpseScare" , "corpses_scare" , true , 1);
}

The mistake is that the timer will trigger in 0.5 seconds. change it to the same as the amount the StartLookingAt is.