Page 1 of 1

event_lightning

Posted: Thu May 06, 2010 8:00 pm
by ajay
I must confess I've only used this once, and it was rubbish and about 8 years ago. I can't even get it to work, I'm starting with a map trigger, though eventually it will be purely set off qc-wise, but as I can't get it work now, I'll forget about that for now.
So how do you set up lightning in a map and how to direct it?

Re: event_lightning

Posted: Thu May 06, 2010 8:49 pm
by Chip
ajay wrote:I must confess I've only used this once, and it was rubbish and about 8 years ago. I can't even get it to work, I'm starting with a map trigger, though eventually it will be purely set off qc-wise, but as I can't get it work now, I'll forget about that for now.
So how do you set up lightning in a map and how to direct it?
I'd go for creating a new entity. I'm not sure if there is a lightning QC code somewhere in some mod. Here is some pseudocode*:

Code: Select all

void lightning_entity() = // wrap this up as a func_lightning
{
set rand(1,10) // set up a random value between 1 and 10
if(rand==5) {
make_lightning(); // if rand is 5 call the lightning function
}
}
And here is the lightning function (again pseudocode*):

Code: Select all

void make_lightning() =
{
// use here EF_DIMLIGHT or even load a light type, the strobe one
}
You can continue this with a traceline function and generate a lightning visual effect with code similar to the lightning gun one. This could become an interesting effect.

Sorry for my lack of QuakeC knowledge, I suppose this could be a starting point for a more experienced coder. I also work a lot with pseudocode as starting point for my employees doing PHP, so I'm kinda comfy with it.

*This is not QuakeC!

Posted: Thu May 06, 2010 11:28 pm
by frag.machine
Are you talking about the Chton lightning ? Have you checked E1M7 map source ? I remember using that once, but it was really tricky.

Posted: Fri May 07, 2010 12:49 am
by Chip
frag.machine wrote:Are you talking about the Chton lightning ? Have you checked E1M7 map source ? I remember using that once, but it was really tricky.
Damn, you're right! Why didn't I think of that?

That code should be somewhere in the source.

Posted: Fri May 07, 2010 6:46 am
by ajay
Yep the Chthon lightning. Checked the map source quickly; the lightning's triggers point to a func_door, but I couldn't find an event_lightning entity anyway, but as I said, I only had a quick look. I got it working in raptors years ago, but it was bloody annoying as I remember and I wasn't happy with it. I may quakec it and use the lightning gun as a base...

Posted: Fri May 07, 2010 12:40 pm
by frag.machine
I made a random lightning function eons ago, was not that hard really. When I 'm in home I'll check if I still have this code.

Posted: Fri May 07, 2010 3:53 pm
by Dr. Shadowborg
Here's something that might help:

http://tlb.quakedev.com/files/qsrbeta3a_src.zip

Look for lightningbars related stuff in the hip/hip_part.qc file. If nothing else, it should give you a framework to use. (Note that lightningbars is NOT hipnotic code, but rather my own because the particlefields not being visible past a certain distance coupled with the non-intuitive usage of hipnotic's particlefields pissed me off.)

Posted: Fri May 07, 2010 5:23 pm
by ajay
Thanks a lot. One question; in the level editor I create an entity called event_lightningbars, what do I use (call) as the end point? Sorry if it's obvious, I'm having that kind of day!

Posted: Fri May 07, 2010 7:13 pm
by frag.machine
ajay wrote:Yep the Chthon lightning. Checked the map source quickly; the lightning's triggers point to a func_door, but I couldn't find an event_lightning entity anyway, but as I said, I only had a quick look. I got it working in raptors years ago, but it was bloody annoying as I remember and I wasn't happy with it. I may quakec it and use the lightning gun as a base...
AS I said, it's awkward to use. From what I can say quickly reading the QC, this should do the trick:

1) put an "event_lightining" in the map, setting it's targetname (ex: "zap");
2) put a button or trigger setting its tagret with the same value (in this case, "zap");
3) put the doors that will represent the extremities of the lightning beam (AFAIK it may not work with other kind of entities), set the "target" field in each one with the "lightning" value.

EDIT: Hey, doesn't Pox's Extras has some ready to use lightning effects ?

Posted: Sat May 08, 2010 3:38 am
by Dr. Shadowborg
ajay wrote:Thanks a lot. One question; in the level editor I create an entity called event_lightningbars, what do I use (call) as the end point? Sorry if it's obvious, I'm having that kind of day!
Use an info_notnull or path_corner (info_notnull is probably better for this) give it a targetname and then set event_lightningbars target field to whatever you targetnamed said info_notnull.

To toggle it on / off, give the event_lightningbars itself a targetname and have a switch / trigger target it.

Set wait for duration in seconds between lightning zaps. (i.e. how frequently it shoots lighting to the endpoint.)

Posted: Sat May 08, 2010 11:02 am
by ajay
Thanks. I'm getting a no spawn function for event_lightningbars error when loading the map?

Posted: Sat May 08, 2010 2:40 pm
by Dr. Shadowborg
ajay wrote:Thanks. I'm getting a no spawn function for event_lightningbars error when loading the map?
Sounds like you haven't put the event_lightningbars code into your QC, thus resulting in quake not knowing what the heck event_lightningbars is.

Another thing to check would be to make sure the quakec name and the entity name for the entity in your mapping program match up. (i.e. event_lightningbars NOT event_lightingbars or something. Don't laugh, but this actually happened to me when I was adding the entity entry into my worldcraft .fgd file. It took me a while to figure out what the hell was going wrong...:oops:)

Posted: Sat May 08, 2010 3:57 pm
by ajay
Thanks again. Turned out it was where I had the .qc file in prog.src. Moved it up the list and alls well. I think it was not having it before world.qc, but I'm not sure...