moving objects,

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

Moderator: Core Staff

Post Reply
flawy
CJ Wannabe
CJ Wannabe
Posts: 7
Joined: March 29th, 2011, 7:39 pm

moving objects,

Post by flawy » March 29th, 2011, 7:44 pm

at first .... i'm new here :D so hello all 0.0

i'm creating a new codjumper map :D but i'm trying to make objects move...
i looked everywhere and the only thing i can find is something about elevators. can som1 tell me how i can rotate
brushes or let it moove over the map. all help will we greatly appreciated :D

greetz

User avatar
Xpayne
PC Team
PC Team
Posts: 1764
Joined: May 13th, 2008, 8:17 am
Location: Estonia

Re: moving objects,

Post by Xpayne » March 29th, 2011, 8:44 pm

Niceee cant wait for another new map!


I'm big zero on those stuff so cant help you :mrgreen:
I'll take care of checking whether the music is royalty-free or not

Let's save this post.

Image

Uploaded with ImageShack.us

Lawless
CJ Fan
CJ Fan
Posts: 110
Joined: January 25th, 2011, 7:11 pm
Gamertag: x STRAF3Zz v2

Re: moving objects,

Post by Lawless » March 29th, 2011, 11:17 pm

I dont know much about scripting for objects to move you eill need to know the basics of scripting in order to make objects move.

http://www.modsonline.com/
This website has alot of basic tutorials and scripts to help you make a brush move and rotate.
Good luck

- Lawless
Join my server @ 217.163.22.223:28960

flawy
CJ Wannabe
CJ Wannabe
Posts: 7
Joined: March 29th, 2011, 7:39 pm

Re: moving objects,

Post by flawy » March 30th, 2011, 1:01 pm

KillerSam wrote:There are loads of tutorials on this website, check out the mapping tutorial forums, most of the cod1/cod2 stuff still applies in cod4.

lets try that :D

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: moving objects,

Post by Rezil » March 30th, 2011, 8:19 pm

Part 1: Mapping

Basically, you need to assign a key/value to the entity you want to move. You do this by right clicking on your selected brushes and going to script->brushmodel. If done correctly, the brushes should turn blue. You can select all of them by using shift+alt+click. Assign your brushmodel a targetname:

- Select brushmodel
- Press N to open up the entity window
- Under key, type 'targetname' without ''
- under value, type whatever you want your brush to be called from the script(eg. 'b1')

Save.

Part 2: Scripting

You'll need to create a .gsc file, which is basically a normal text file with a different extension. Use a formatted text editor such as Notepad++ because it makes scripting a lot easier. Now, a few things you need to know before you start scripting:

- Every map .gsc needs a main function(basically a block of code which executes) as a starting point.
- Most of what the scripting is done with built-in functions such as moveZ, rotateYaw, iPrintLn etc. Check the IW docs for further explanation.
- The syntax is simmilar to C and the same general rules apply. If you haven't done any scripting before, I'd advise you to at least check some pre-made code in the tutorials section or for scripting in C in general.

This is the basic code for moving an entity:

Code: Select all

main()
{
	thread moveEnt();
}

moveEnt()
{
	ent = getEnt("b1","targetname");
	//Gets a single entity with the value 'b1' from key 'targetname'
	//then saves it in the variable 'ent'
	
	while(1)
	//A 'while' loop, code in the curly brackets below will execute as long as
	//the map is active
	{
		ent moveZ(200, 1);
		//Common syntax: <variable> <function>
		//You 'call' a function on an entity, basically this means that, in
		//our case, the function 'moveZ' will do something with entity 'ent' ie.
		//move it along the Z axis. The function moveZ takes two integers(whole numbers)
		//moveZ(int units, int time,<optional>int accel,<optional>int deccel);
		//in our case, we move our entity 200 units in 1 second.
		ent waittill("movedone");
		//This makes the thread wait until entity 'ent' is done moving. Sort of like
		//notifiying when to continue. Other examples include "rotatedone", "trigger" etc.
		
		ent moveZ(-200,1);
		//Same thing, but in reverse
		ent waittil("movedone");
		
		//Now here we've reached the end of the 'while' block of code. Because it's
		//an infinite loop, at this point the code starts repeating, so
		//ent moveZ(200, 1) is called, then ent waittill("movedone"), then
		//ent moveZ(-200,1) and so forth.
	}
}
I'd really advise you to check out the documentation IW provided, either from your own docs or online. The most common functions are explained there, while not exactly in detail, they should give you a general idea of what does what. Save this as yourmapname.gsc, compile and test.

There, a crash course in scripting 101. Questions are welcome.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests