Moving Light FX

Tutorials for Call of Duty mapping

Moderator: Core Staff

Post Reply
User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Moving Light FX

Post by Nightmare » April 22nd, 2009, 1:50 am

Moving lights isn't that hard in theory, all it takes is a moving effect that will play a light effect, which can be custom.

So first, with the mapping.
Very simple if you know how to create your typical entities.
In this case, all you have to do is spawn a script_origin by right clicking on the 2d grid and selecting script then origin.
Now you want to give it values, you can use the example below, but I highly advise putting your map name in front to avoid conflicting.
Key: targetname
Value: fxOrigin

That's all it takes for the mapping part.

Now on to the scripting.
First off, you will need to make a brand new effect, and lucky you, I have a light emiting effect here just for you!
Now I'm going to assume you know how to make a pk3 file, so beside your maps, mp, and levelshots folder, you will want to make another folder called fx. In this folder, you can put an extra folder with your map name to avoid conflicting.
I went ahead and put another folder called myFxFolder inside the fx folder.
Now make a txt file in this folder, and paste the following.

Code: Select all

Light
{
	life				1000   //Length of time the light is on in milliseconds, 1000 = 1 second

	rgb   //Color of the light can be changed here, with Red Green Blue (2.55 2.55 2.55 = White)
	{
		start	2.55 2.55 2.55   //Color of the light at the beginning of its life
		end		2.55 2.55 2.55   //Color of the light at the end of its life
		flags			linear
	}

	size
	{
		start			250   //Intensity of the light at the beginning of its life
		end				250   //Intensity of the light at the end of its life
		flags			linear
	}
}
This is the code to give off a light effect, you can modify the variables to your liking to fit your needs.
Now when saving the file, make sure that it is saved as an efx file. I called this file myLight.efx

Now for the actual map scripting.
I'm going to assume you know the basics of how to script for a map, such as making a gsc file and how to code simple movements.
So here, we want to both play an effect and make it move, so I will be running two threads in parallel.

Code: Select all

main()
{
	maps\mp\_load::main();   //Load main functions
	lightOrigin = getent ("fxOrigin","targetname");   //Assign the fxOrigin entity to lightOrigin
	level._effect["light"] = loadfx ("fx/myFxFolder/myLight.efx");  //Load myLight effect from myFxFolder
	maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
	lightOrigin thread lightsMove();   //Run moving light thread while sending assigned lightOrigin
}

lightsMove(){    //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
   while(1){
      self moveX (64,1,0.5,0.5);
      self waittill ("movedone");
      self moveX (-64,1,0.5,0.5);
      self waittill ("movedone");
   }
}
That's about it. Now of course, if you have any questions, just ask, I'll explain a little more in detail if you don't understand.
Feel free to modify it however you want.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest