Page 1 of 1

moving objects,

Posted: March 29th, 2011, 7:44 pm
by flawy
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

Re: moving objects,

Posted: March 29th, 2011, 8:44 pm
by Xpayne
Niceee cant wait for another new map!


I'm big zero on those stuff so cant help you :mrgreen:

Re: moving objects,

Posted: March 29th, 2011, 11:17 pm
by Lawless
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

Re: moving objects,

Posted: March 30th, 2011, 1:01 pm
by flawy
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

Re: moving objects,

Posted: March 30th, 2011, 8:19 pm
by Rezil
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.