Need help with rotating script.

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

Moderator: Core Staff

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Need help with rotating script.

Post by Coontang » July 19th, 2007, 9:10 pm

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.
Image
JDogg: 'I have a video of me pissing, wanna see?'

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, 2007, 10:39 pm

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
}
}
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 19th, 2007, 10:47 pm

soo i just pop this in my gsc??
Image
JDogg: 'I have a video of me pissing, wanna see?'

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 19th, 2007, 11:25 pm

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.
Image
JDogg: 'I have a video of me pissing, wanna see?'

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, 2007, 12:45 am

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!
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 9:52 am

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?
Image
JDogg: 'I have a video of me pissing, wanna see?'

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » July 20th, 2007, 10:21 am

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.
Image
Image

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 10:57 am

so do i need to create an 'after'? I mean how can i make my after brush?
Image
JDogg: 'I have a video of me pissing, wanna see?'

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, 2007, 11:14 am

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.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 11:19 am

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?
Image
JDogg: 'I have a video of me pissing, wanna see?'

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, 2007, 11:27 am

Yes, when they're touching it and press the use key at the same time.

It can be placed anywhere.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 11:42 am

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?
Image
JDogg: 'I have a video of me pissing, wanna see?'

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 2:39 pm

EDIT: IT WORKS! :D

could i create another vent called vent2 with vent2_trig?
Image
JDogg: 'I have a video of me pissing, wanna see?'

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, 2007, 3:24 pm

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.
Watch this before posting a question: http://www.albinoblacksheep.com/flash/posting.php

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » July 20th, 2007, 3:25 pm

how do i add an array? also this one is going to rotate 90 degrees instead. Im having 4 in total.
Image
JDogg: 'I have a video of me pissing, wanna see?'

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests