Frictional Games Forum (read-only)
[SCRIPT] Need some script help! - 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: [SCRIPT] Need some script help! (/thread-13548.html)

Pages: 1 2


Need some script help! - ammislol - 02-24-2012

Hello, I've been trying to fix this - but getting nowhere

I want a script that makes the player look in 4 different directions when he pass a area.

to the left, to the right and backwards. And when looked all those
directions - look at a door "mansion_2"
where a monster "servant_grunt_1" spawns and destroys it and starts chasing you

I have made areas called
ScriptArea_1 - left

ScriptArea_2 - right

ScriptArea_3 - back

ScriptArea_4 - the area you pass and start looking


Is this possible? And if it is, can someone help me?..
Thanks in advance!


RE: Need some script help! - ammislol - 02-24-2012

No one? :/


RE: Need some script help! - Obliviator27 - 02-24-2012

Combine LookAtCallbacks with Timers as well as SetEntityActive and SHowEnemyPlayerPosition.



RE: Need some script help! - ammislol - 02-24-2012

(02-24-2012, 09:09 PM)Obliviator27 Wrote: Combine LookAtCallbacks with Timers as well as SetEntityActive and SHowEnemyPlayerPosition.
Anyway you could help me with the script? or is it to much mate? :3


RE: Need some script help! - Obliviator27 - 02-24-2012

Code:
void OnStart()
{
  AddEntityCollideCallback("Player", "LookArea", "StartLookSequence", true, 1);
}
void StartLookSequence(string &in asParent, string &in asChild, int alState
{
  AddTimer("LookTimer1", 4, "NextLook");
  AddTimer("LookTimer2", 8, "NextLook");
  AddTimer("LookTimer3", 12, "NextLook");
  AddTimer("LookTime4", 16, "NextLook");
  StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
void NextLook(string &in asTimer)
{
  if(asTimer == "LookTimer1")
  {
  StartPlayerLookAt("ScriptArea_2", 2, 2, "");
  }
  if(asTimer == "LookTimer2")
  {
  StartPlayerLookAt("ScriptArea_3", 2, 2, "");
  }
  if(asTimer == "LookTimer3")
  {
  StartPlayerLookAt("ScriptArea_4", 2, 2, "");
  }
  if(asTimer == "LookTimer4")
  {
  SetEntityActive("servant_grunt_1", true);
  ShowEnemyPlayerPosition("servant_grunt_1");
  }
}



RE: Need some script help! - ammislol - 02-24-2012

(02-24-2012, 09:53 PM)Obliviator27 Wrote:
Code:
void OnStart()
{
  AddEntityCollideCallback("Player", "LookArea", "StartLookSequence", true, 1);
}
void StartLookSequence(string &in asParent, string &in asChild, int alState
{
  AddTimer("LookTimer1", 4, "NextLook");
  AddTimer("LookTimer2", 8, "NextLook");
  AddTimer("LookTimer3", 12, "NextLook");
  AddTimer("LookTime4", 16, "NextLook");
  StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
void NextLook(string &in asTimer)
{
  if(asTimer == "LookTimer1")
  {
  StartPlayerLookAt("ScriptArea_2", 2, 2, "");
  }
  if(asTimer == "LookTimer2")
  {
  StartPlayerLookAt("ScriptArea_3", 2, 2, "");
  }
  if(asTimer == "LookTimer3")
  {
  StartPlayerLookAt("ScriptArea_4", 2, 2, "");
  }
  if(asTimer == "LookTimer4")
  {
  SetEntityActive("servant_grunt_1", true);
  ShowEnemyPlayerPosition("servant_grunt_1");
  }
}


Hmm, I get Error : Unexpected end of file, and also.
Is that script activated when i pass the area? I want it when you pass "ScriptArea_5" the script starts - you look at ScriptArea_1, then ScriptArea_2 etcetc.. do you understand?


RE: Need some script help! - Obliviator27 - 02-24-2012

(02-24-2012, 09:53 PM)Obliviator27 Wrote:
Code:
void OnStart()
{
  AddEntityCollideCallback("Player", "ScriptArea_5", "StartLookSequence", true, 1);
}
void StartLookSequence(string &in asParent, string &in asChild, int alState)
{
  AddTimer("LookTimer1", 4, "NextLook");
  AddTimer("LookTimer2", 8, "NextLook");
  AddTimer("LookTimer3", 12, "NextLook");
  AddTimer("LookTimee4", 16, "NextLook");
  StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
void NextLook(string &in asTimer)
{
  if(asTimer == "LookTimer1")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_2", 2, 2, "");
  }
  if(asTimer == "LookTimer2")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_3", 2, 2, "");
  }
  if(asTimer == "LookTimer3")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_4", 2, 2, "");
  }
  if(asTimer == "LookTimer4")
  {
StopPlayerLookAt();
  SetEntityActive("servant_grunt_1", true);
  ShowEnemyPlayerPosition("servant_grunt_1");
  }
}
I typed it out hastily. This code should be the fixed one.

What happens is when you hit ScriptArea_5, it forces the player to look at one of the areas and activates a few timers. As each timer runs out, the player looks at the subsequent areas.




RE: Need some script help! - ammislol - 02-24-2012

(02-24-2012, 10:12 PM)Obliviator27 Wrote:
(02-24-2012, 09:53 PM)Obliviator27 Wrote:
Code:
void OnStart()
{
  AddEntityCollideCallback("Player", "ScriptArea_5", "StartLookSequence", true, 1);
}
void StartLookSequence(string &in asParent, string &in asChild, int alState)
{
  AddTimer("LookTimer1", 4, "NextLook");
  AddTimer("LookTimer2", 8, "NextLook");
  AddTimer("LookTimer3", 12, "NextLook");
  AddTimer("LookTimee4", 16, "NextLook");
  StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
void NextLook(string &in asTimer)
{
  if(asTimer == "LookTimer1")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_2", 2, 2, "");
  }
  if(asTimer == "LookTimer2")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_3", 2, 2, "");
  }
  if(asTimer == "LookTimer3")
  {
StopPlayerLookAt();
  StartPlayerLookAt("ScriptArea_4", 2, 2, "");
  }
  if(asTimer == "LookTimer4")
  {
StopPlayerLookAt();
  SetEntityActive("servant_grunt_1", true);
  ShowEnemyPlayerPosition("servant_grunt_1");
  }
}
I typed it out hastily. This code should be the fixed one.

What happens is when you hit ScriptArea_5, it forces the player to look at one of the areas and activates a few timers. As each timer runs out, the player looks at the subsequent areas.
Okay it works great, tho ive got 2 questions.
1. is there anyway to like lock the camera on each area? Cause now you can move the mouse around while the camera look at each area.

2. when it takes me to area 4, it just stands there and look - it wont release. and no monster is spawning.

Huge thanks in advance


RE: Need some script help! - Obliviator27 - 02-24-2012

To lock the Camera, put
SetPlayerActive(false); in the StartLookSequence function, and then
I messed up on the timers. Where it says
AddTimer("LookTimee4", 12, "NextLook");
Replace it with
AddTimer("LookTimer4", 12, "NextLook");

And finally, put
SetPlayerActive(true);
where the SetEntityActive script is.




RE: Need some script help! - ammislol - 02-24-2012

(02-24-2012, 11:29 PM)Obliviator27 Wrote: To lock the Camera, put
SetPlayerActive(false); in the StartLookSequence function, and then
I messed up on the timers. Where it says
AddTimer("LookTimee4", 12, "NextLook");
Replace it with
AddTimer("LookTimer4", 12, "NextLook");

And finally, put
SetPlayerActive(true);
where the SetEntityActive script is.
So where excact should i change? my script looks like this atm -


void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_5", "StartLookSequence", false, 1);
}
void StartLookSequence(string &in asParent, string &in asChild, int alState)
{
AddTimer("LookTimer1", 4, "NextLook");
AddTimer("LookTimer2", 8, "NextLook");
AddTimer("LookTimer3", 12, "NextLook");
AddTimer("LookTimee4", 12, "NextLook");
StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
void NextLook(string &in asTimer)
{
if(asTimer == "LookTimer1")
{
StopPlayerLookAt();
StartPlayerLookAt("ScriptArea_2", 2, 2, "");
}
if(asTimer == "LookTimer2")
{
StopPlayerLookAt();
StartPlayerLookAt("ScriptArea_3", 2, 2, "");
}
if(asTimer == "LookTimer3")
{
StopPlayerLookAt();
StartPlayerLookAt("ScriptArea_4", 2, 2, "");
}
if(asTimer == "LookTimer4")
{
StopPlayerLookAt();
SetEntityActive("servant_grunt_1", true);
ShowEnemyPlayerPosition("servant_grunt_1");
}
}



Sorry for being such a noob :< Great help tho! thanks alot.