Moving FX Lights

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

Moderator: Core Staff

Scorpion
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: November 18th, 2007, 9:14 pm
Location: Burnley,United Kingdom

Moving FX Lights

Post by Scorpion » April 19th, 2009, 7:50 pm

Hello

Is there any Tutorials out there for Moving FX Lights?

Thanks 8)

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Moving FX Lights

Post by waywaaaard » April 19th, 2009, 8:11 pm

moving your FX shouldn't be that hard, only creating your light in effectsed could take some time
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

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

Re: Moving FX Lights

Post by Nightmare » April 20th, 2009, 4:29 am

Hark! What is that in the sky? Is it a bird, a plane? No! It's NM coming to save the day!

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]

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 FX Lights

Post by Rezil » April 20th, 2009, 3:24 pm

Wow awesome tut nm, do you think this will work in cod2 aswell?
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.

Scorpion
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: November 18th, 2007, 9:14 pm
Location: Burnley,United Kingdom

Re: Moving FX Lights

Post by Scorpion » April 20th, 2009, 9:12 pm

Thanks for the Tutorial :D

Instead of lights , there is flames :roll:

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

Re: Moving FX Lights

Post by Nightmare » April 20th, 2009, 10:54 pm

Rez|l wrote:Wow awesome tut nm, do you think this will work in cod2 aswell?
I don't see why it shouldn't
Scorpion wrote:Thanks for the Tutorial :D

Instead of lights , there is flames :roll:
Are you sure? What kind of flames is it?
The reason I am asking is because if the flames go very high into the sky, then that is the error.efx playing.
This effect usually plays when it cannot find the efx file you are refering to, so make sure to double check the path and file name.
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]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Moving FX Lights

Post by Drofder2004 » April 21st, 2009, 8:25 pm

And make sure you simply haven't copied and pasted NM's script (which we all know, you have).
You need to change the FX file location in both script and folder.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Scorpion
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: November 18th, 2007, 9:14 pm
Location: Burnley,United Kingdom

Re: Moving FX Lights

Post by Scorpion » April 22nd, 2009, 6:46 pm

Hi , Finally Works :D (I was using the compile MP folder and it didnt like it, so i placed into a pk3 and it worked :lol: )

Iv tried to add a trigger to it

Code: Select all

main()
{
   maps\mp\_load::main();   //Load main functions
   lightOrigin = getent ("fxOrigin","targetname");   //Assign the fxOrigin entity to lightOrigin
   trigger = getent ("lighttrigger","targetname");
   level._effect["light"] = loadfx ("fx/light/light.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)
      {
      trigger waittill ("trigger");
      wait(1);
      lightOrigin moveZ (-1000,1,0.5,0.5);
      lightOrigin waittill ("movedone");
      wait(10);      
      lightOrigin moveZ (1000,1,0.5,0.5);
      lightOrigin waittill ("movedone");
   }
}


The light shows up but it doesnt move up or down with the trigger or without the trigger.

Any ideas?

Thanks :)

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Moving FX Lights

Post by waywaaaard » April 22nd, 2009, 7:31 pm

main()
{
maps\mp\_load::main(); //Load main functions
lightOrigin = getent ("fxOrigin","targetname"); //Assign the fxOrigin entity to lightOrigin
trigger = getent ("lighttrigger","targetname");
level._effect["light"] = loadfx ("fx/light/light.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)
{
trigger waittill ("trigger");
wait(1);
self moveZ (-1000,1,0.5,0.5);
self waittill ("movedone");
wait(10);
self moveZ (1000,1,0.5,0.5);
self waittill ("movedone");
}
}
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

Scorpion
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: November 18th, 2007, 9:14 pm
Location: Burnley,United Kingdom

Re: Moving FX Lights

Post by Scorpion » April 22nd, 2009, 7:40 pm

Hi

Doesnt work

The light shows but doesnt go up / down.

Iv checked the names etc and there right

I took out the trgger part of it and it still doesnt work :shock:

Any idea?

Thanks :)

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

Re: Moving FX Lights

Post by Nightmare » April 23rd, 2009, 2:11 am

Scorpion wrote:Hi , Finally Works :D (I was using the compile MP folder and it didnt like it, so i placed into a pk3 and it worked :lol: )

Iv tried to add a trigger to it

CODE

The light shows up but it doesnt move up or down with the trigger or without the trigger.

Any ideas?

Thanks :)
Obvious problem is very obvious, you are defining what trigger is all the way in the main, but for the game, by the time it gets to that thread, it has forgotten about it. (Lev made the same mistake. :))
Two solutions, make trigger a level wide variable or define it in the movement thread.
I chose the later for simplicity.

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/light/light.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)
	{
		trigger = getent ("lighttrigger","targetname");
		trigger waittill ("trigger");
		wait(1);
		self moveZ (-1000,1,0.5,0.5);
		self waittill ("movedone");
		wait(10);      
		self moveZ (1000,1,0.5,0.5);
		self waittill ("movedone");
	}
}
You can also have it so the light turns on and stays on only after you press the trigger by doing this:

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/light/light.efx");  //Load myLight effect from myFxFolder
	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)
	{
		trigger = getent ("lighttrigger","targetname");
		trigger waittill ("trigger");
		maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.
		wait(1);
		self moveZ (-1000,1,0.5,0.5);
		self waittill ("movedone");
		wait(10);      
		self moveZ (1000,1,0.5,0.5);
		self waittill ("movedone");
	}
}
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]

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: Moving FX Lights

Post by waywaaaard » April 23rd, 2009, 7:26 am

oopsy, was reading to fast -.-

yep no trigger was defined
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Moving FX Lights

Post by Drofder2004 » April 23rd, 2009, 2:45 pm

small modification to the above...

Code: Select all

lightsMove(){    //Move lightOrigin back and forth along the X axis 64 units while looping continuously.
   trigger = getent ("lighttrigger","targetname");
   maps\mp\_fx::loopfx("light",lightOrigin.origin, 1); //Play loaded light effect at lightOrigin's origin every sec.

   while(1)
   {     
      trigger waittill ("trigger");
      wait(1);
      self moveZ (-1000,1,0.5,0.5);
      self waittill ("movedone");
      wait(10);     
      self moveZ (1000,1,0.5,0.5);
      self waittill ("movedone");
   }
}
Firstly, remember this is an INFINITE LOOP, why would you want the engine to find the entity more than once if it isn't changing? Keep it outside the loop.

Secondly, Loops inside loops = infinite amounts of infinite loops.
Every time the loop went round, it created a NEW fx to play, after 1 minute passing you would have 6, eventually stacking to the point where your FPS would be shot and the server would crash.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Scorpion
CJ Wannabe
CJ Wannabe
Posts: 39
Joined: November 18th, 2007, 9:14 pm
Location: Burnley,United Kingdom

Re: Moving FX Lights

Post by Scorpion » April 23rd, 2009, 5:25 pm

Hello

The light still shows up but it doesnt move. :roll:

Any Ideas?

Thanks

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Moving FX Lights

Post by Drofder2004 » April 23rd, 2009, 10:01 pm

Are you definitely using a script_origin?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests