UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: sgray97 on June 11, 2014, 10:12:44 pm

Title: automatic door script advice
Post by: sgray97 on June 11, 2014, 10:12:44 pm
i just set up a basic door movement script and have a some questions about how to  make it truly "automatic" like for example if a player is in the radius of the trigger the movement will occur.



Code Snippet
Plaintext
#include maps\_music;
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_utility;

main()
{
thread auto_door();
}

auto_door()
{
auto = GetEnt( "auto_door", "targetname" );
auto1 = GetEnt( "auto_door1", "targetname" );
auto_trigger = GetEnt( "auto_trig", "targetname");

auto_trigger waittill ("trigger", user);

auto movex(-50, 6); 
auto1 movex(50, 6);

wait 3;
auto movex(25, 6); 
auto1 movex(-25, 6);

wait 3;

thread auto_door();
}

this is one of my first few scripts and i would like some advice to improve my scripting any help will be appreciated and credit given
Title: Re: automatic door script advice
Post by: daedra descent on June 11, 2014, 10:18:37 pm
I don't see anyway to really improve it besides using getentarray() so you can have more than one "automatic" door. For what your trying to do in your code you can't simplify it any.

But you don't need

Code Snippet
Plaintext
waittill ("trigger", user);

the "user" in this unless you need to specify who is triggering the entity.
Title: Re: automatic door script advice
Post by: DidUknowiPwn on June 11, 2014, 10:41:45 pm
Make it a while or a for loop (while( true ) preferably) and check if the door is moving if it is pull it back again so player doesn't have to wait (unless you want to). Currently you're only making it only run once.
Title: Re: automatic door script advice
Post by: daedra descent on June 11, 2014, 10:45:49 pm
Make it a while or a for loop (while( true ) preferably) and check if the door is moving if it is pull it back again so player doesn't have to wait (unless you want to). Currently you're only making it only run once.

It is looping. He just didn't use a while() or for() loop on it.

Calling the same function within itself will loop it.
Title: Re: automatic door script advice
Post by: sgray97 on June 11, 2014, 10:50:37 pm
i wanted to have the doors open without having to use F key to open it maybe use a trigger_radius would that do that?
Title: Re: automatic door script advice
Post by: daedra descent on June 11, 2014, 10:51:43 pm
i wanted to have the doors open without having to use F key to open it maybe use a trigger_radius would that do that?

I don't know about trigger radius's, but i know a trigger_multiple will work for that.
Title: Re: automatic door script advice
Post by: sgray97 on June 11, 2014, 10:53:31 pm
alright thanks ill try that is there a way to reduce the stock radius of the trigger maybe use KvP "radius" "#"
Title: Re: automatic door script advice
Post by: PROxFTW on June 11, 2014, 10:56:40 pm
Quick script I made waiting to dl something. Simply what it does it checks if a player is in a certain distance then opens the door. Hasn't been tested so if any errors just let me know.
Code Snippet
Plaintext
#include maps\_music;
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_utility;

main()
{
Auto = GetEntArray( "auto_door", "targetname" );
Auto1 = GetEntArray( "auto_door1", "targetname" );// Also wanna know what this is for it would let me know if this is needed or not. Put it here since you had but might not be needed.

for( i = 0; i < Auto.size; i++ )
Auto[i] thread auto_door( -50, 25 );

for( i = 0; i < Auto1.size; i++ )
Auto1[i] thread auto_door( 50, -25 );
}

auto_door( Num, Num2 )
{
NotAlreadyIn = undefined;
        Play = GetPlayers();

for( i = 0; i < Play.size; i++ )
{
if( distance( Play[i].origin, self.origin ) < 300 && !IsDefined( NotAlreadyIn ) ) // Maybe bigger/smaller depending on distance you want
{
NotAlreadyIn = true;
                        self MoveX( Num, 6 );
wait 3;
self MoveX( Num2, 6 );
wait 3;
}
}
self thread auto_door();
}
Title: Re: automatic door script advice
Post by: daedra descent on June 11, 2014, 10:57:24 pm
The trigger is activated when a player touches it. Simply resize the trigger until you have it where you want for the radius.
Title: Re: automatic door script advice
Post by: steviewonder87 on June 11, 2014, 11:09:10 pm
But what about zombies? Do they trigger it too, otherwise they're gonna spawn in the adjacent/current zone and just pile up on the other side of the door if the player is standing on the other side..
Title: Re: automatic door script advice
Post by: sgray97 on June 11, 2014, 11:28:02 pm
i was thinking about a way to do that but i guess i might have to just give them a path around the doors through barriers or something but quick question how would i make the doors open faster then the slow opening of the doors?
Title: Re: automatic door script advice
Post by: daedra descent on June 11, 2014, 11:40:06 pm
i was thinking about a way to do that but i guess i might have to just give them a path around the doors through barriers or something but quick question how would i make the doors open faster then the slow opening of the doors?

The second argument defines the speed. See Zeroys script reference for function arguments http://www.zeroy.com/script/motion/movex.htm (http://www.zeroy.com/script/motion/movex.htm)
Title: Re: automatic door script advice
Post by: sgray97 on June 12, 2014, 01:02:33 am
any idea on how to have zombies trigger the trigger_multiple im keeping this as simple as possible since im just starting off
Title: Re: automatic door script advice
Post by: jjbradman on June 12, 2014, 01:54:44 am
The second argument defines the speed. See Zeroys script reference for function arguments http://www.zeroy.com/script/motion/movex.htm (http://www.zeroy.com/script/motion/movex.htm)
why not tell him how to use "moveto" that way he han move the  doors to structs and made prefabs instead of having to make 1 script for every door lol
Title: Re: automatic door script advice
Post by: daedra descent on June 12, 2014, 02:02:37 am
why not tell him how to use "moveto" that way he han move the  doors to structs and made prefabs instead of having to make 1 script for every door lol

Forgot that even exists. I don't use the move<whatever>() functions very often.
Title: Re: automatic door script advice
Post by: sgray97 on June 12, 2014, 02:39:23 am
why not tell him how to use "moveto" that way he han move the  doors to structs and made prefabs instead of having to make 1 script for every door lol
how would i do that? ive normally just used the movex function
Title: Re: automatic door script advice
Post by: daedra descent on June 12, 2014, 02:42:14 am
how would i do that? ive normally just used the movex function

Zeroy's scripting references is your best friend. http://www.zeroy.com/script/ (http://www.zeroy.com/script/)

http://www.zeroy.com/script/motion/moveto.htm (http://www.zeroy.com/script/motion/moveto.htm)