Jump to content

I need help with elevator script


Go to solution Solved by PK_Azlon,

Recommended Posts

Posted

Here is the script to bring my elevator to the top floor.

//Generated by BehavEd

rem ( "Begin Elevator Function" );
wait ( 1000.000 );

affect ( "elev_dr_dn_lf", /*@AFFECT_TYPE*/ FLUSH )
{
	move ( < -88.000 6000.000 -2188.000 >, < 0.000 0.000 0.000 >, 500.000 );
}


affect ( "elev_dr_dn_rt", /*@AFFECT_TYPE*/ FLUSH )
{
	move ( < 88.000 6000.000 -2188.000 >, < 0.000 0.000 0.000 >, 500.000 );
}

wait ( 500.000 );

affect ( "elevator", /*@AFFECT_TYPE*/ FLUSH )
{
	move ( < 0.000 6080.000 -304.000 >, < 0.000 0.000 0.000 >, 5000.000 );
}

wait ( 5000.000 );

affect ( "elev_dr_up_lf", /*@AFFECT_TYPE*/ FLUSH )
{
	move ( < 168.000 6160.000 -304.000 >, < 0.000 0.000 0.000 >, 500.000 );
}


affect ( "elev_dr_up_rt", /*@AFFECT_TYPE*/ FLUSH )
{
	move ( < -168.000 6160.000 -304.000 >, < 0.000 0.000 0.000 >, 500.000 );
}

I need to create a script to check if the elevator is at < 0.000 6080.000 -304.000 > already. If it is then I want to just play a sound. If it isn't then I want it to run the above code to bring it up. I have been wracking my brain trying to figure this one out and I am stumped. Someone PLEASE help. I can't go forward until this is working!

Posted

Try this, @@PK_Azlon:

 

 

 

//Generated by BehavEd

rem ( Begin, Elevator, Function );

affect ( "elevator", /*@AFFECT_TYPE*/ FLUSH )
{

	if ( $get( VECTOR, "SET_ORIGIN")$, $=$, $0.000 6080.000 -304.000$ )
	{
		sound ( /*@CHANNELS*/ CHAN_AUTO, "FILENAME" );
	}


	else (  )
	{
		wait ( 1000.000 );

		affect ( elev_dr_dn_rt, AFFECT_TYPE, FLUSH )
		{
			move ( 88.000, 6000.000, -2188.000, 0.000, 0.000, 0.000, 500.000 );
		}


		affect ( elev_dr_dn_lf, AFFECT_TYPE, FLUSH )
		{
			move ( -88.000, 6000.000, -2188.000, 0.000, 0.000, 0.000, 500.000 );
		}

		wait ( 500.000 );

		affect ( elevator, AFFECT_TYPE, FLUSH )
		{
			move ( 0.000, 6080.000, -304.000, 0.000, 0.000, 0.000, 5000.000 );
		}

		wait ( 5000.000 );

		affect ( elev_dr_up_lf, AFFECT_TYPE, FLUSH )
		{
			move ( 168.000, 6160.000, -304.000, 0.000, 0.000, 0.000, 500.000 );
		}


		affect ( elev_dr_up_rt, AFFECT_TYPE, FLUSH )
		{
			move ( -168.000, 6160.000, -304.000, 0.000, 0.000, 0.000, 500.000 );
		}

	}

}


 

 

 

I just added to the script you created. The sound "FILENAME" is just a placeholder. You'll need to change that. If this doesn't work, I can rig up an example of the system I described earlier, if you like.

Posted

@therfiles , I thought for sure this would work. I was actually thinking of this same solution a couple minutes before i saw your response but unfortunately it throws up an error on compile...

compile_error.jpg

Posted

@@MoonDog: Wouldn't something like this work?

 

 

Oh are you useing a func_door/plat? This would really work with a func_static.

 

First, make you elevator a func_static with an origin brush. Then, give it a script_targetname. Run a script on startup that affects your elevator (lets say you gave it the script_targetname of elevator_01). Then, on elevator_01, set parm1 to 0. In this example. we'll use parm1 as variable that states whether or not the elevator is at the extended position (hence the initial value of 0, or false). Then, make 2 ref tags, one where you make your origin brush (this will be used when your elevator returns to it's location, call it elevator_01_start) the other where it will end up. Then make a script that would run when the player presses the activating button or switch that checks the value of parm1 on elevator_01. If parm1 = 0, the elevator needs to move up, so include the move commands and set parm1 to 1. If parm1 = 1, the opposite should occur.

 

I'm just afraid since you are using a func_plat that you won't quite be able to exactly know the location of the entity, thus the if vector command wouldn't really work. Does this make sense? I've experienced several problems with using func_plats/doors, and I have found this to work pretty well.

 

Using ref_tags and parms would probably work much better in this situation.

Posted

Use parameters or a global variable to track its location. Trying to do checks based on vectors in Icarus is a waste of time.

ALSO. comparing floating point numbers (such as vectors) using something like = is a pretty big missed steak, since floating point numbers in particular suffer from severe rounding errors (protip: don't ever compare against 0.00, ever, PCs can't physically represent 0.0 in floating point)

Futuza and therfiles like this
Posted

That's how it should have been done, imo. Using the position of ref_tags will help to visualize the positions much better and lead to much less in the way of headaches.

Posted

I learned how to script elevators by examining the source files for DarthNormaN's Battle Over Coruscant. I even figured out a workaround for the lighting problem with the top floor's doors. Because they are drawn open the parts obscured by the walls are almost black when the doors close. I fixed this by having the doors closed and running a spawnscript to open them when the map loads. Works like a charm.

Posted

If anyone could be so kind as to break down this method for me that'd be great. I literally learned to script TODAY. I'm a fast learner but there is almost no useful tutorials out there for moving entities and other more advanced uses. I want to learn things like elevators, switches, moving targets etc.

 

But yeah, like a quick breakdown of the script and what to set up in gtkradiant. that would be really helpful.

  • Solution
Posted

Nevermind! I solved my dilemma a different way where I didnt have to rewrite all my scripts!

 

 I simply added the following code to my elevator_up script

affect ( "elev_top_switch", /*@AFFECT_TYPE*/ FLUSH )
{
	set ( /*@SET_TYPES*/ "SET_INACTIVE", "true" );
}


affect ( "elev_bottom_switch", /*@AFFECT_TYPE*/ FLUSH )
{
	set ( /*@SET_TYPES*/ "SET_INACTIVE", "false" );
}

and the opposite for elevator_down and then I set "elev_top_switch" to inactive in radiant (since the elevator starts on the top floor) This prevents knuckleheads from hitting the call switch when the elevator is already there. (It didn't move before, but it still played the soundsets because it was still "trying" to move to its current location) Now it won't work unless the elevator is at the other position!

 

The first of many changes and fixes to Phantom Knights Training Academy. Now that I am finally learning scripting, (as well as many other things thanks to JKHub) I can fix or improve various things that annoyed me about the map. 

therfiles and Futuza like this

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...