2 trigger = 1 door

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Levcek
CJ Fan
CJ Fan
Posts: 129
Joined: March 7th, 2010, 11:37 am
Location: sLOVEnia, stajerska FTW

2 trigger = 1 door

Post by Levcek » July 10th, 2010, 10:07 am

ok i need a little help... i dont know how to make that two triggers will open one door so heres the question:

do anyone know how to make that 2 triggers will open 1 door

plz help ^^

tnx
__________________________________________________________

Image THE MAPPER
__________________________________________________________

Image

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: 2 trigger = 1 door

Post by Rezil » July 10th, 2010, 10:52 am

Same scripting as with one door, only give the two triggers the same targetname.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
JuMPZoR
CJ Newbie
CJ Newbie
Posts: 88
Joined: May 16th, 2010, 7:23 pm

Re: 2 trigger = 1 door

Post by JuMPZoR » July 10th, 2010, 11:34 am

You think you can post the regular script to open 1 door, Rez?
Image

Image

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: 2 trigger = 1 door

Post by Rezil » July 10th, 2010, 11:59 am

Code: Select all

//Simple door opening script by Rezil
main()
{
	thread mp_jm_mapname_door(); //Change to avoid conflicts with other .gscs
}

mp_jm_mapname_door()
{
	t = getent("trig","targetname"); //trig is the targetname of the trigger you will use to open the door
	d = getent("door","targetname"); //door is the targetname of the actual door that will open and "d" is what we will call it in the script
	
	while(1)
	{
		t waittill("trigger", user); //wait for the user to trigger
		d rotateyaw(90,1,0.5,0.2); //this rotates the entity(in our case, "door") 90 degrees in 1 second with the entity accelerating 0.5 seconds and deccelrating for 0.2 seconds
		d waittill("rotatedone"); //wait for the door to stop rotating, better than simply using the wait command as it prevents bugging the door(blocking it)
		t delete(); //door is open, delete trigger
	}
}
That's the basic code, you can of course check whether the door is open or not and what the code will do accordingly. Like this:

Code: Select all

//A bit more advanced door opening script by Rezil
main()
{
	level.is_door_open = false; //Define a global boolean(true/false) variable that will be used for checking whether the door is open or not
	thread mp_jm_mapname_door(); //Change to avoid conflicts with other .gscs
}

mp_jm_mapname_door()
{
	t = getent("trig","targetname"); //trig is the targetname of the trigger you will use to open the door
	d = getent("door","targetname"); //door is the targetname of the actual door that will open and "d" is what we will call it in the script
	
	while(1) //while true, infinite loop basically
	{
		t waittill("trigger", user); //wait for the user to trigger
		if(level.is_door_open) //if the global variable is_door_open is true
		{
		d rotateyaw(90,1,0.5,0.2); 
		d waittill("rotatedone");
		//user iprintln("Door open."); //Optionally inform the user that the door is open 
		}
		else { //do this if all other checks are false - you could do the same with if(!level.is_door_open)
		d rotateyaw(-90,1,0.5,0.2); //-90, close the door
		d waittill("rotatedone"); 
		//user iprintln("Door closed."); //Optionally inform the user that the door is closed
		}
	}
}
Untested but should work.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
JuMPZoR
CJ Newbie
CJ Newbie
Posts: 88
Joined: May 16th, 2010, 7:23 pm

Re: 2 trigger = 1 door

Post by JuMPZoR » July 11th, 2010, 1:01 pm

Thanks, will try it today.
Image

Image

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests