Page 1 of 3
Need help with rotating script.
Posted: July 19th, 2007, 9:10 pm
by Coontang
Hi, im making a new map (secret to me, Golden and levi atm) but i need help on a rotating air vent door.
It will start off vertical, and when pressed i would like it to rotate about 170 degrees on its (invisible) hinges, downwards to the ground so it is 10 degrees up if you understand.
if anyone could make me a script for this id be chuffed!
Thanks.
Posted: July 19th, 2007, 10:39 pm
by Luke
Well you can do it much like a door script and edit the values as needed:
Code: Select all
main()
{
thread vent();
}
vent()
{
vent = getent ("vent","targetname");
vent_trig = getent ("vent_trig","targetname");
while (1)
{
vent_trig waittill ("trigger");
vent rotateto ((0, 170,0), 1); //this will rotate 170 degrees on the y axis in 1 second
}
}
Posted: July 19th, 2007, 10:47 pm
by Coontang
soo i just pop this in my gsc??
Posted: July 19th, 2007, 11:25 pm
by Coontang
ok what do i need to do and call these things? I have made a before and after, how to name them and everything? sorry, im totally new to scripting.
Posted: July 20th, 2007, 12:45 am
by Luke
If you've not got any scripting in your map yet, then you can just paste this into notepad and save it as yourmapname.gsc, then put it in the same folder as your d3dbsp file(maps/mp).
Code: Select all
main()
{
maps\mp\_load::main();
thread vent();
}
vent()
{
vent = getent ("vent","targetname");
vent_trig = getent ("vent_trig","targetname");
while (1)
{
vent_trig waittill ("trigger");
vent rotateto ((0, 170,0), 1); //this will rotate 170 degrees on the y axis in 1 second
}
}
For the mapping part, create the vent then create a brush where the hinge would be and give that the origin texture. The origin brush is where it will pivot, it will pivot from the very center of this brush. Now select the vent and the origin brush and while both are selected, right click and select script>brushmodel. Now give the brushmodel a targetname, by selecting it and pressing N, then type targetname in the key field, and vent in the value. Hit enter to apply, press N again to close.
Create a trigger_use and give a targetname of vent_trig(assuming you know how to make a trigger). And that's it!
Posted: July 20th, 2007, 9:52 am
by Coontang
nope i havent used triggers in my map yet. so what i need is to start with my 'before' vent, give it the details etc and make a hinge for it to pivot around? could this be made out of caulk? and how could i measure how many degrees are in this rotation?
Posted: July 20th, 2007, 10:21 am
by Pedsdude
jimbojetuk wrote:nope i havent used triggers in my map yet. so what i need is to start with my 'before' vent, give it the details etc and make a hinge for it to pivot around? could this be made out of caulk? and how could i measure how many degrees are in this rotation?
Luke already said, it needs the 'origin' texture (found in common). If it's caulk, it'll block people and mess up your map a bit.
As for the angle it is rotated through, it tells you in the script.
Posted: July 20th, 2007, 10:57 am
by Coontang
so do i need to create an 'after'? I mean how can i make my after brush?
Posted: July 20th, 2007, 11:14 am
by Luke
No, as i said thats the mapping done. Unless you want this door to look different after its rotated

so all you should be doing is creating it at the position you want it to be rotated from, the script will do the rest.
Triggers: I'll suggest my favourite trigger, the use_touch. When the player touches this trigger, a use icon will appear.
All you need to do is create a brush at the place you want this to happen, while the brush is selected, right click and select trigger>use_touch(the texture will change to the trig texture by its self). Then give it a targetname like you did with the vent door, except this time you name it vent_trig.
Posted: July 20th, 2007, 11:19 am
by Coontang
ok so whenever a player touches this trigger they can 'use' it to open the door?
EDIT; this should be near the vent , but could be placed anywhere?
Posted: July 20th, 2007, 11:27 am
by Luke
Yes, when they're touching it and press the use key at the same time.
It can be placed anywhere.
Posted: July 20th, 2007, 11:42 am
by Coontang
ok ill go do that and see how it works....also to change the time it takes after the rotate(o, 170, 0) do i change the 1 to whatever seconds i want?
Posted: July 20th, 2007, 2:39 pm
by Coontang
EDIT: IT WORKS!
could i create another vent called vent2 with vent2_trig?
Posted: July 20th, 2007, 3:24 pm
by Luke
You could do that, but if you're planning on making several of them, then it would best to use an array, then you can add as many as you want without adding more code.
Posted: July 20th, 2007, 3:25 pm
by Coontang
how do i add an array? also this one is going to rotate 90 degrees instead. Im having 4 in total.