Frictional Games Forum (read-only)
Multiple triggers - 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: Multiple triggers (/thread-16317.html)

Pages: 1 2


Multiple triggers - The Shanus - 06-19-2012

So, straight to the point. I would like to go about setting up a trigger - this would be once "NOTETWO" is picked up, it causes a door ("room102") to be unlocked, a monster ("brute1") to spawn in "brute1area", and the player to turn to look at it. I have one trigger already setup, but I'm not sure about how to setup a second one. Any help would be greatly appreciated.

Here is my current script:
PHP Code:
void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
AddUseItemCallback("""room101key""room101""UsedKeyOnDoor"true);
AddUseItemCallback("""room100key""room100""UsedKeyOnDoor"true);
SetEntityCallbackFunc("room100key""OnPickup");
SetEntityCallbackFunc("NOTETWO""OnPickup");
AddUseItemCallback("""hatch101key""hatch101""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity(""asEntity"room101"0false);
PlaySoundAtEntity(""asEntity"room100"0false);
PlaySoundAtEntity(""asEntity"hatch101"0false);
RemoveItem(asItem);
}

void OnPickup(string &in asEntitystring &in type)
{
    if(
asEntity == "room100key")
{
  
SetEntityActive("poofer1"true);
  
ShowEnemyPlayerPosition("poofer1");
  
PlaySoundAtEntity("""04_break.snt""poofer1"0false);
  
StartPlayerLookAt("poofer1",2,2,"");
  
StopPlayerLookAt();
}
    else if(
asEntity == "NOTETWO")
{
  
SetSwingDoorLocked("room102",false,false);
  
SetEntityActive("brute1",true);  
  
ShowEnemyPlayerPosition("brute1");
  
StartPlayerLookAt("brute1",2,2,"");
  
StopPlayerLookAt();
}


Thanks


RE: Multiple triggers - Cruzore - 06-19-2012

the setEntitycallbackfunc for room100key is confusing me, but let's say it's there: Since you got 2 callbacks for OnPickup, I would go for this:
void Onpickup(same as above)
{
if(asEntity == "room100key")
{Whatever it does
}
else if(asEntity == "NOTETWO")
{//if it's a normal door:
SetSwingDoorLocked("room102", false, false);
//for the brute spawn part, it's easier to set him inactive in level editor and set him active when you need to:
SetEntityActive("brute1", true);
//The look at part:
StartPlayerLookAt("brute1", 2, 2, "");
//adjust the 2 2s as you need the speed, and add a timer for:
StopPlayerLookAt();
//after you turn. Just look how fast you want it and set the timer and speed how you want.


RE: Multiple triggers - The Shanus - 06-19-2012

(06-19-2012, 08:56 PM)FastHunteR Wrote: the setEntitycallbackfunc for room100key is confusing me, but let's say it's there: Since you got 2 callbacks for OnPickup, I would go for this:
void Onpickup(same as above)
{
if(asEntity == "room100key")
{Whatever it does
}
else if(asEntity == "NOTETWO")
{//if it's a normal door:
SetSwingDoorLocked("room102", false, false);
//for the brute spawn part, it's easier to set him inactive in level editor and set him active when you need to:
SetEntityActive("brute1", true);
//The look at part:
StartPlayerLookAt("brute1", 2, 2, "");
//adjust the 2 2s as you need the speed, and add a timer for:
StopPlayerLookAt();
//after you turn. Just look how fast you want it and set the timer and speed how you want.
So does this go within the same void OnPickup, as above - or do I create a new one for this?


RE: Multiple triggers - Cruzore - 06-19-2012

It goes with the same. You basically check which callback it was, by using if and asEntity.(that's how I would go for it)


RE: Multiple triggers - The Shanus - 06-19-2012

(06-19-2012, 09:01 PM)FastHunteR Wrote: It goes with the same. You basically check which callback it was, by using if and asEntity.(that's how I would go for it)
I'm afraid you're going to have to be a bit more blunt, or give an example please. I'm new to this, which I'm sure you've gathered by now :p


RE: Multiple triggers - Cruzore - 06-19-2012

Hehe Smile
I learned that way from the wake up script tutorial from Your Computer.
Let's go with a example:
Let's say you got 2 keys and you need functions to get them to open their doors. if you want the same thing to happen for both cases(like, for this example, both just to open the door, or both playing the same sound), you go for those variables you got in the callback syntax, like asEntity. This way you save a whole function just for the other key.
But, if you want those keys to do something differently, like 1 opening the door and the other spawning a brute, you go for if.
It's there to set a difference between those 2 keys, and you won't need a second function to take up a lot of space in the file.
Sorry, but I can't explain it that great Smile Hope it helped, and you could just see Your Computer's tutorial, may explain it better.

Edit: Or, in the case there is just 1 function avaible, to get both things under 1 function.


RE: Multiple triggers - The Shanus - 06-19-2012

(06-19-2012, 09:13 PM)FastHunteR Wrote: Hehe Smile
I learned that way from the wake up script tutorial from Your Computer.
Let's go with a example:
Let's say you got 2 keys and you need functions to get them to open their doors. if you want the same thing to happen for both cases(like, for this example, both just to open the door, or both playing the same sound), you go for those variables you got in the callback syntax, like asEntity. This way you save a whole function just for the other key.
But, if you want those keys to do something differently, like 1 opening the door and the other spawning a brute, you go for if.
It's there to set a difference between those 2 keys, and you won't need a second function to take up a lot of space in the file.
Sorry, but I can't explain it that great Smile Hope it helped, and you could just see Your Computer's tutorial, may explain it better.

Edit: Or, in the case there is just 1 function avaible, to get both things under 1 function.
Okay, I think I understand what you're saying, just not how I'm supposed to implement it :p Which video of Your Computer should I look at for this? Would a link be too much to ask?

Edit: roomkey100 opens a door called room100, just so you know! :]


RE: Multiple triggers - Cruzore - 06-19-2012

http://www.frictionalgames.com/forum/thread-10798.html
Number 18, wake up script


RE: Multiple triggers - The Shanus - 06-19-2012

(06-19-2012, 09:41 PM)FastHunteR Wrote: http://www.frictionalgames.com/forum/thread-10798.html
Number 18, wake up script
Perfect, thanks alot mate.


RE: Multiple triggers - The Shanus - 06-19-2012

(06-19-2012, 09:41 PM)FastHunteR Wrote: http://www.frictionalgames.com/forum/thread-10798.html
Number 18, wake up script
Okay so these are the errors I'm now getting:
"main (26,1) : INFO : Compiling void OnPickup (string&in string&in)
main (34,3) : ERR : Expected ';' "
And my script as of now:
PHP Code:
void OnStart()
{
}

////////////////////////////
// Run when entering map

void OnEnter()
{
AddUseItemCallback("""room101key""room101""UsedKeyOnDoor"true);
AddUseItemCallback("""room100key""room100""UsedKeyOnDoor"true);
SetEntityCallbackFunc("room100key""OnPickup");
SetEntityCallbackFunc("NOTETWO""OnPickup");
AddUseItemCallback("""hatch101key""hatch101""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity(""asEntity"room101"0false);
PlaySoundAtEntity(""asEntity"room100"0false);
PlaySoundAtEntity(""asEntity"hatch101"0false);
RemoveItem(asItem);
}

void OnPickup(string &in asEntitystring &in type)
{
    if(
asEntity == "room100key")
{
  
SetEntityActive("poofer1"true);
  
ShowEnemyPlayerPosition("poofer1");
  
PlaySoundAtEntity("""04_break.snt""poofer1"0false);
  
StartPlayerLookAt("poofer1",2,2,"")
  
StopPlayerLookAt();
}
    if(
asEntity == "NOTETWO")
{
  
SetSwingDoorLocked("room102",false,false);
  
SetEntityActive("brute1",true);
  
StartPlayerLookAt("brute1",2,2,"");
  
StopPlayerLookAt();
}


Can't tell what's wrong Confused