Elevator when hit player go up

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

Moderator: Core Staff

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 23rd, 2010, 12:07 pm

I have this code;

Code: Select all

main()
{
thread elevator();
}

elevator()
{
   speaker = getent("speaker_one","targetname");
   move_trig = getent("elevatorright","targetname");
//////////////////////////////////////////////////////
hit_trig = getent("hitright","targetname");
//////////////////////////////////////////////////////
   move = getent("elevatorright_base","targetname");
   move_trig enablelinkto();
   move_trig linkto(move);
   

   while(1)
   {
      move_trig waittill("trigger");
      move movez(282, 1.4);
      speaker playsound ("elevator_move");      
      move waittill("movedone");
      speaker playsound ("elevator_stop");      
      wait 2;
      move movez(-282, 1.4);    
      speaker playsound ("elevator_move");
/////////////////////////////////////////////////      
if ("hit_trig", user)
Go back up
wait 2;
go back down again
////////////////////////////////////////////////
move waittill("movedone");
      speaker playsound ("elevator_stop");
}
}
I know how to link that hit_trigger and I figured it had to be something like if :|
I want the elevator to go down but when the player is underneath and gets hit the elevator should go up again.
Any ideas ? I wish I could script better :?

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 24th, 2010, 1:42 pm

Ok I can think of a solution but this would require some work.

Basic Idea:

The script that you have stays almost the same we only add an endon("elevator1_hit_player").

In a 2nd thread we link a new trigger that is below the elevator to it so it moves with up and down. If this trigger got triggered we notify("elevator1_hit_player") so the normal thread will end. Now we move the elevator up and start the other thread again.

That this will work we need to work with moveTo and a script_origin otherwise we could not move the elevator to the position.

What you need todo:

1. Ungroup the elevator and delete the targetname
2. Then add the script_origin and make a new brushmodel out of it and give it the targetname
3. Add a new trigger below the elevator. Give it a targetname
4. Now we need the scripting
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 24th, 2010, 2:06 pm

Ok, thx m8. I don't think I'll get it all done by myself but I'll see how far I'll get.
I'll get back to you on this one probably :)

MCNAB
CJ Wannabe
CJ Wannabe
Posts: 16
Joined: July 18th, 2010, 5:11 pm
Location: United Kingdom, Kent

Re: Elevator when hit player go up

Post by MCNAB » July 25th, 2010, 1:20 pm

good script

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 25th, 2010, 9:42 pm

Ok I made this script (it's for two elevators, I'm only scripting one now as a test);
But I don't know how you can make the elevator out of a script_origin ?

Code: Select all

main()
{
thread elevator1();
thread elevator2();
thread elevator1_hit();
//thread elevator2_hit();
}

elevator1()
{
   speaker = getent("speaker_one","targetname");
   move_trig = getent("elevatorright","targetname");
   move = getent("elevatorright_base","targetname");
   move_trig enablelinkto();
   move_trig linkto(move);
   

   while(1)
   {
      move_trig waittill("trigger");
      move movez(282, 1.4);
      speaker playsound ("elevator_move");      
      move waittill("movedone");
      speaker playsound ("elevator_stop");      
      wait 2;
      move movez(-282, 1.4);    
      speaker playsound ("elevator_move");
      move waittill("movedone");
      speaker playsound ("elevator_stop");
      endon("elevator1_hit_player").  
}
}

elevator2()
{
   speaker2 = getent("speaker_two","targetname");
   move_left = getent("elevatorleft","targetname");
   moveleft = getent("elevatorleft_base","targetname");
   move_left enablelinkto(); 
   move_left linkto(moveleft);
   
   while(1)
   {
      move_left waittill("trigger");
      moveleft movez(282, 1.4);
      speaker2 playsound ("elevator_move");
      moveleft waittill("movedone");
      speaker2 playsound ("elevator_stop");
      wait 2;
      moveleft movez(-282, 1.4);
      speaker2 playsound ("elevator_move");      
      moveleft waittill("movedone");
      speaker2 playsound ("elevator_stop");
      //endon("elevator2_hit_player").
}
}
elevator1_hit()

   hit_trig = getent("elevatorhit","targetname");
   move = getent("elevatorright_base","targetname");
   hit_trig enablelinkto();
   hit_trig linkto(move);
   
   while(1)
   {
   hit_trig waittill("trigger");
   notify("elevator1_hit_player");

}
}

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 9:49 pm

no just place a script_origin brush in the middle and select all brushes which belong to the elevator and make out of them a brush_model
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 10:05 pm

edit:

tested the script well atleast debugged it so it passes the lexer :D

Code: Select all

main(){

	thread elevator_init();
}

elevator_init(){
	
	// elevator 1
	thread elevator(getent ("elevatorright_base", "targetname"), 
							getent ("elevatorright", "targetname"), 
							getent ("elevatorhit", "targetname"), 
							getent ("speaker_one", "targetname"),
							"elevator1_hit_player");
}

elevator(elevator, move_trig, hit_trig, speaker, elendon){

	level endon(elendon);

	move_trig enablelinkto();
	move_trig linkto(move);
   
   thread elevator_hit(elevator, move_trig, hit_trig, speaker, elendon);

   while(1)
   {
		move_trig waittill("trigger");
		elevator moveTo((0, 0, 282), 1.4);
		speaker playsound ("elevator_move");      
		elevator waittill("movedone");
		speaker playsound ("elevator_stop");      
		wait 2;
		elevator moveTo((0, 0, 0), 1.4);   
		speaker playsound ("elevator_move");
		elevator waittill("movedone");
		speaker playsound ("elevator_stop");
	}
}

elevator_hit(elevator, move_trig, hit_trig, speaker, elendon){
	// all elevator parts and triggers

	hit_trig enablelinkto();
	move_trig enablelinkto();
	
	move_trig linkto(move);
	hit_trig linkto(move);
	
	while(1)
	{
		hit_trig waittill("trigger");
		level notify(elendon);
		elevator moveTo((0, 0, 282), 1.4);
		speaker playsound ("elevator_move");
		elevator waittill("movedone");
		
		thread elevator(elevator, move_trig, hit_trig, speaker, elendon);
		
		wait 0.5;
	}
}
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 25th, 2010, 10:35 pm

omg thx m8 (have said that aloot lately :) )

I tested it bu I get this message;

Code: Select all

bad syntax: (file 'maps/mp/elevator_hit.gsc', line 18)
   endon(elendon);
   *

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 10:44 pm

see my edit :D
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 25th, 2010, 11:13 pm

I changed this code;

Code: Select all

// all elevator parts and triggers

   hit_trig enablelinkto();
   move_trig enablelinkto();
   
   move_trig linkto(move);
   hit_trig linkto(move);
   
Into this;

Code: Select all

]// all elevator parts and triggers

   hit_trig enablelinkto();
   
   hit_trig linkto(move);
   
Cause i got error messages saying move_trig was already linked.
Nowi can start the map but when I jump onto the elevator it moves first in the "Y" direction (onto the place where the jumppads are) and from that place it goes up and down when triggered.

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 11:16 pm

Did you add the script_origin?
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 25th, 2010, 11:27 pm

Script origin or an origin texture ? ahahahaahahah wait you meant link the whole alevator thingy to the script origin with "w"...right ?
I'll get back to you on that one...off to bed right now :)

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 11:30 pm

Ah my fault. Make a new brush and give it the origin texture. Now place it in the middle of your elevator. Select all brushes that are the elevator and the origin brush. Now make out of it a brush_model :D
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: Elevator when hit player go up

Post by <LT>YosemiteSam[NL] » July 25th, 2010, 11:33 pm

Still here :) I did that cause I thought you meant it like that but still the elevator moves in the Y direction.
Do I first have to select the whole elevator and then the origin ? That doesn't matter does it ?

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Elevator when hit player go up

Post by waywaaaard » July 25th, 2010, 11:41 pm

try this

Code: Select all

main(){

	thread elevator_init();
}

elevator_init(){
	
	// elevator 1
	thread elevator(getent ("elevatorright_base", "targetname"), 
							getent ("elevatorright", "targetname"), 
							getent ("elevatorhit", "targetname"), 
							getent ("speaker_one", "targetname"),
							"elevator1_hit_player");
}

elevator(elevator, move_trig, hit_trig, speaker, elendon){

	level endon(elendon);
	
	default_origin = elevator.origin;
	
	move_trig enablelinkto();
	move_trig linkto(move);
   
   thread elevator_hit(elevator, move_trig, hit_trig, speaker, elendon);

   while(1)
   {
		move_trig waittill("trigger");
		elevator moveTo(default_origin + (0, 0, 282), 1.4);
		speaker playsound ("elevator_move");      
		elevator waittill("movedone");
		speaker playsound ("elevator_stop");      
		wait 2;
		elevator moveTo(default_origin - (0, 0, 282), 1.4);   
		speaker playsound ("elevator_move");
		elevator waittill("movedone");
		speaker playsound ("elevator_stop");
	}
}

elevator_hit(elevator, move_trig, hit_trig, speaker, elendon){
	// all elevator parts and triggers
	
	default_origin = elevator.origin;
	
	hit_trig enablelinkto();
	move_trig enablelinkto();
	
	move_trig linkto(move);
	hit_trig linkto(move);
	
	while(1)
	{
		hit_trig waittill("trigger");
		level notify(elendon);
		elevator moveTo(default_origin + (0, 0, 282), 1.4);
		speaker playsound ("elevator_move");
		elevator waittill("movedone");
		
		thread elevator(elevator, move_trig, hit_trig, speaker, elendon);
		
		wait 0.5;
	}
}
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests