Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple triggers
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#1
Question  Multiple triggers

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: (Select All)
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

[Image: theshanusyoutube.jpg]
(This post was last modified: 06-20-2012, 09:35 AM by The Shanus.)
06-19-2012, 08:02 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#2
RE: Multiple triggers

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.
06-19-2012, 08:56 PM
Find
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#3
RE: Multiple triggers

(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?

[Image: theshanusyoutube.jpg]
06-19-2012, 08:59 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#4
RE: Multiple triggers

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)
06-19-2012, 09:01 PM
Find
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#5
RE: Multiple triggers

(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

[Image: theshanusyoutube.jpg]
06-19-2012, 09:05 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#6
RE: Multiple triggers

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.
(This post was last modified: 06-19-2012, 09:16 PM by Cruzore.)
06-19-2012, 09:13 PM
Find
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#7
RE: Multiple triggers

(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! :]

[Image: theshanusyoutube.jpg]
(This post was last modified: 06-19-2012, 09:41 PM by The Shanus.)
06-19-2012, 09:38 PM
Find
Cruzore Offline
Senior Member

Posts: 301
Threads: 2
Joined: Jun 2012
Reputation: 37
#8
RE: Multiple triggers

http://www.frictionalgames.com/forum/thread-10798.html
Number 18, wake up script
06-19-2012, 09:41 PM
Find
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#9
RE: Multiple triggers

(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.

[Image: theshanusyoutube.jpg]
06-19-2012, 09:44 PM
Find
The Shanus Offline
Member

Posts: 134
Threads: 15
Joined: Jun 2012
Reputation: 3
#10
RE: Multiple triggers

(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: (Select All)
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

[Image: theshanusyoutube.jpg]
(This post was last modified: 06-19-2012, 10:56 PM by The Shanus.)
06-19-2012, 10:56 PM
Find




Users browsing this thread: 1 Guest(s)