Moving Triggers

Tutorials for Call of Duty 2 mapping

Moderator: Core Staff

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Moving Triggers

Post by Drofder2004 » July 11th, 2006, 12:32 pm

I forgot to test this a while back. An [IW] member posted an extremely important command that a lot of people wanted. It allow you to MOVE triggers.

So, here is my tutorial on how to use a moving trigger...

In this tutorial, I am going to be moving a small platform with a trigger hurt attached to it.

Ok.
1 - First make a base unit (this is important, your trigger will be attached to this). If you want this to be invisble, simply give it the texture [nodraw_notsolid] found under "usage<tools"
2 - Make the base unit a script_brushmodel and give it a relevant targetname.
3 - Now make you trigger_hurt. Give it a relevant targetname and the relevant settings.

Thats it for the map.

Now the scripting.

Code: Select all

main()
{
	maps\mp\_load::main(); //Always include this in all main map gsc's
	move_trig = getent("move_trig","targetname"); //Name of your hurt_trigger
	move = getent("move","targetname"); //Name of your base
	move_trig enablelinkto(); // This is the most important part of the script. this allows you to move the trigger.
	move_trig linkto(move); //Now you must link the trigger to the base
	
// The following is how you want your BASE to move. (Your trigger will follow your base)
	while(1)
	{
		move moveX(500, 5);
		wait 5;
		move moveY(500, 5);
		wait 5;
		move moveX(-500, 5);
		wait 5;
		move moveY(-500, 5);
		wait 5;
	}
}
Enjoy.
Last edited by Drofder2004 on August 9th, 2006, 8:18 pm, edited 2 times in total.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » July 11th, 2006, 4:02 pm

awsome! you think this could work for cod1?
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » July 11th, 2006, 5:20 pm

excellentay

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 11th, 2006, 7:12 pm

Nightmare wrote:awsome! you think this could work for cod1?
If the command works in CoD1, then it works. I havent tested it personally (im sure someone will do so)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » July 19th, 2006, 9:25 pm

Has anyone tried it yet? i'm trying it with a trigger_multiple but the trigger won't move :?

User avatar
Marshall
CJ Spammer!
CJ Spammer!
Posts: 820
Joined: December 10th, 2005, 11:28 am
Location: UK

Post by Marshall » July 19th, 2006, 9:46 pm

ill try it now, luke

bare with me

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 20th, 2006, 12:36 am

Luke wrote:Has anyone tried it yet? i'm trying it with a trigger_multiple but the trigger won't move :?
I have tried it with a moving vehicle.... I'll say no more ;)

(I cannot guarentee *all* triggers can be moved, if the command is accepted then it can move )
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 20th, 2006, 12:59 am

trigger_multiple works...

Here is the code, you figure out the rest ;)

Code: Select all

main()
{
	maps\mp\_load::main();
	move_trig = getent("move_trig","targetname");
	move = getent("move","targetname");
	move_trig enablelinkto();
	move_trig linkto(move);
	move_trig thread check();
	
	while(1)
	{
		move moveX(500, 5);
		wait 5;
		move moveY(500, 5);
		wait 5;
		move moveX(-500, 5);
		wait 5;
		move moveY(-500, 5);
		wait 5;
	}
}

check()
{
while(1)
{
self waittill("trigger");
iprintln("TRIGGERED");
wait 3;
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » July 20th, 2006, 1:47 am

Sorry, stupid mistake..i thought you had to put enablelinkto for the model/brushmodel rather than the trigger. But it does work thx anyway...now I can ride my trolley :)

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 20th, 2006, 4:35 pm

Luke wrote:Sorry, stupid mistake..i thought you had to put enablelinkto for the model/brushmodel rather than the trigger. But it does work thx anyway...now I can ride my trolley :)
LOL...

Just a question have you made it so that the trolley moves only while touching the multiple?

If not... i'll brb :P
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » July 20th, 2006, 5:46 pm

Yep thats what i've done. But it needs some tweaking, as it doesn't work very well yet. It tends to stop sometimes, and then the trigger won't work for awhile, sometimes it goes really far though.

Code: Select all

main()
{
thread trolley1();
} 

trolley1()
{
   move_trolley = getent("move_trolley","targetname");
   trolley1 = getent("trolley1","targetname"); 
   move_trolley enablelinkto(); 
   move_trolley linkto(trolley1);
   while (1)
{
move_trolley waittill ("trigger");
trolley1 movex (0 + (-50),0.5);
}
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 20th, 2006, 6:52 pm

You missed 1 minor detail, and you made 1 weird bit of maths :P

Code: Select all

main()
{
thread trolley1(); // If you gonna do more, it may be better to use another method...

trolley1()
{
   move_trolley = getent("move_trolley","targetname");
   trolley1 = getent("trolley1","targetname");
   move_trolley enablelinkto();
   move_trolley linkto(trolley1);

   while (1)
   {
      move_trolley waittill ("trigger");
      trolley1 movex (0 + (-50),0.5); // Why 0 + (-50)? just use -50 O_O
      trolley1 waittill("movedone"); // Stop the script keep triggering
   }
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Marshall
CJ Spammer!
CJ Spammer!
Posts: 820
Joined: December 10th, 2005, 11:28 am
Location: UK

Post by Marshall » July 20th, 2006, 7:32 pm

how bout, use that to attach script_origins also...


so for custom sounds, planes, radios, cars ect or maybe just a trolley :P

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » July 20th, 2006, 11:23 pm

Drofder2004 wrote:You missed 1 minor detail, and you made 1 weird bit of maths :P

Code: Select all

main()
{
thread trolley1(); // If you gonna do more, it may be better to use another method...

trolley1()
{
   move_trolley = getent("move_trolley","targetname");
   trolley1 = getent("trolley1","targetname");
   move_trolley enablelinkto();
   move_trolley linkto(trolley1);

   while (1)
   {
      move_trolley waittill ("trigger");
      trolley1 movex (0 + (-50),0.5); // Why 0 + (-50)? just use -50 O_O
      trolley1 waittill("movedone"); // Stop the script keep triggering
   }
}
Well it made no difference to how it works, but changing the size/position of the trigger and the speed helps. For what i was trying was based on having to hold W (forward) to keep it moving, but i think this will only work smoothly if the speed is in sync with the player...which i haven't worked out yet

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 21st, 2006, 12:37 am

trig waittill("trigger", user);
trolley linkto(user);

Don't know if that works very well :P

Or try this...

Code: Select all

while(1)
{
trig waittill("trigger",user);
user moveTrolley();
}

Code: Select all

moveTrolley()
{
trolley = getent("trolley","targetname");
trig = getent("trigger","targetname");

while(self isTouching(trig)
{
trolley setOrigin(trolley.origin + (5, 0, 0))
wait 0.05;
}
}
may need abit of adjusting and may even be wrong... but there is a way of this working (i have done it with a stuka)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests