light_torch_small_walltorch ()

Discuss programming in the QuakeC language.
Post Reply
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

light_torch_small_walltorch ()

Post by Cobalt »

In my mod, I am randomly giving these torches health so they can be shot off the walls, and also they will inflict damage when a takedamage ent contacts them. Using DP I was able to give them an orange modelflag that enhances their light a bit....though I am finding that modelflag seems to be angle or PVS dependent. Not much a problem, but I noticed some of these, depending on the map are having a lightstyyle assigned via the map ents using .style and .light to make them flicker, usually the ones placed in enclosed roomas /caves. So if I shoot a torch, it falls the ground, does a flameout using the explosion sprite, then remove (self). Works ok, except the light still stays up where the torch was. Not really a HUGE issue per say, but I thought maybe during the th_pain frame or the kill frame, I could flicker that light and remove it, however it does not seem to be possible. If I alter .style nothing happens, and I cant assign .light during the "quaked" loading of the map ent in the torches spawn , even with a new declaration, there already is a light () function, which gives a compile conflict error. Is any of this possible another way? I guess the map has to be recompiled or "relighted" ? Once the lightmap is done, there is no altering it ??
mankrip
Posts: 924
Joined: Fri Jul 04, 2008 3:02 am

Re: light_torch_small_walltorch ()

Post by mankrip »

The lightstyles defines how the map's lightmap should be animated. Once the map is compiled, those lights don't belong to the torches anymore, they belong to the map's lightmap.

I don't understand much about light interaction in Quake, but you can probably take some clues from how the light switches at the end of E1M1 works. Only in your case, instead of turning the lights on, you're going to switch them off.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: light_torch_small_walltorch ()

Post by Cobalt »

Yes, I thought I examined that code a while ago and it was merely using self.use to turn the light on or off. Just peeked at it now and it does that for some plain light ents as well as the fluro light. I thought when I looked at those ents in the map itself, they have a "light" float applied always....which is what I was trying to replicate in QC for the torch, but for the redeclaration conflict.

I think I might have to declare a new style for the damagable torches, because if use existing ones, other light on the map sharing that style will be effected. So it looke like theres no way around editing the map walltorch ents to give them a "light" float level of some sorts, as I suspect that will be how the engine lightmaps the ent. Other problem is I guess turning it off when the torch dies...which I guess the only way would be lightstyle "a" for total darkness. Too bad there is no way in QC to fool the engine when the map loads to lightmap it with the "light" float. In DP there is a [ TENEBRAE_GFX_DLIGHTS ] extension where you can dynamicly light any entity with the lightstyle system just described, however for some reason , the vector float .angles was selected as the angles of the light, so if you have a real ent with its own angles, you will mess it up if you light it that way. Otherwise the angle of the light will be stuck at '0 0 0' ..... :?
mankrip wrote:The lightstyles defines how the map's lightmap should be animated. Once the map is compiled, those lights don't belong to the torches anymore, they belong to the map's lightmap.

I don't understand much about light interaction in Quake, but you can probably take some clues from how the light switches at the end of E1M1 works. Only in your case, instead of turning the lights on, you're going to switch them off.
ceriux
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: light_torch_small_walltorch ()

Post by ceriux »

i'm not sure if you can do this with premade maps. the lights are kind of baked into the map on compile. i think you would have to set it up on a custom map with your changes already compiled into the map. an ON flag and an OFF flag. i'm not sure but you might be able to do it with dynamic lights. but then it would be broken if someone wanted to play your mod on lower settings.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: light_torch_small_walltorch ()

Post by Spike »

angle -> angles_y
light -> light_lev

the two special cases of entity parsing.

a light with a targetname will be assigned a .style value by the light util, which will then write back to the entity lump or something. lights with the same targetname will have the same .style field, and thus will all switch on/off at once.

non-switched lights will just use whatever .style value the mapper assigned. this means that if you try switching one of those off, *ALL* will switch off.
the lightstyle builtin affects all lights with that style. that's just the way it works. any other way would limit you to only 255 lights per map, and that's simply not viable (its also more expensive, as you'd need to mix more lightmaps, and there's a max of 4 styles per surface, would be far far worse if it was 4 lights per surface).

you can add realtime lights instead of static ones, and directly control each one (instead of relying on .style only). however, this can decimate your framerate.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: light_torch_small_walltorch ()

Post by Cobalt »

Good info , thanks to all.

Did some more checks, looks like the torches (not the flames) use either style 1 or 6 so far checking the start and e2m2 maps. ID coded the maps very consistently, so I will assume the rest of their levels that have torches that they want flickering use the same lightstyle.

Unfortunately, removing the "style" or "light" reference in the torches that have these fields does nothing.....so I guess those are "baked" into the lightmap via the light util, and the engine does not override....even with an engine named: Darkplaces ..... :D

So I changed lightstyle 1 & 6 to "a" (total darkness) for now, and made 2 new lighstyles with those same strings to possibly support reassigning to the torches using the TENEBRAE_GFX_DLIGHTS extension later in my experiments.

Maybe I will wind up recompiling the maps later if I see a conflict , but for now at least when a walltorch is shot, the flickering light behind it is no longer there.

Another idea along the same lines are the fluorescents on the base style maps, but those definately mean recompiling the map, placing I guess a trigger field on the surfaces of the textures that when killed no longer emit the light. I also suppose the textures would be better removed, and func_walls put in to replicate those textures, and have damage skins.

Similar idea for the stained Glass windows on some levels....except for Elder God Shrine and I think one other where they made the windows func_wall ents. With DP you can now assign them a health and other effects that will show up when tye are broken, and also a alpha level for transparency.... :D
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: light_torch_small_walltorch ()

Post by frag.machine »

Just for reference, from world.qc:

Code: Select all

	// 0 normal
	// 1 FLICKER (first variety)
	// 2 SLOW STRONG PULSE
	// 3 CANDLE (first variety)
	// 4 FAST STROBE
	// 5 GENTLE PULSE 1
	// 6 FLICKER (second variety)
	// 7 CANDLE (second variety)
	// 8 CANDLE (third variety)
	// 9 SLOW STROBE (fourth variety)
	// 10 FLUORESCENT FLICKER
	// 11 SLOW PULSE NOT FADE TO BLACK
Obs: at least 6 and 7 in the list above are inverted in vanilla QuakeC.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply