time, timing, timey-wimey
Moderator: InsideQC Admins
9 posts
• Page 1 of 1
time, timing, timey-wimey
This is coming from another thread, where I had an idea to dynamically affect a torchlight over time, e.g. it will get duller as the battery runs out. I've two problems
1) I've always struggled with using time in quakeC, e.g. getting something to happen after a certain amount of time, without messing up everything
2) Also I've realised that it'll have to stop/start when the player turns off the torch
Any suggestions/thoughts would be nice. Ta, Andy.
1) I've always struggled with using time in quakeC, e.g. getting something to happen after a certain amount of time, without messing up everything
2) Also I've realised that it'll have to stop/start when the player turns off the torch
Any suggestions/thoughts would be nice. Ta, Andy.
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
Not too hard.
First, set up:
in defs.qc or wherever. Then. assuming self.brightness is the torch brightness, set it to 100 or whatever when the torch is turned on, then do something like this is a function run every frame (W_WeaponFrame is where I normally stick things like this)
That'll dim by one brightness point every ten seconds, adjust as you see fit.
For the turning off and on functions, just set brightness to 0 or 100 or whatever.
First, set up:
- Code: Select all
.float torch_dim_time;
.float brightness;
in defs.qc or wherever. Then. assuming self.brightness is the torch brightness, set it to 100 or whatever when the torch is turned on, then do something like this is a function run every frame (W_WeaponFrame is where I normally stick things like this)
- Code: Select all
if ((self.brightness > 0) && (self.torch_dim_time < time))
{
self.brightness = self.brightness - 1;
self.torch_dim_time = time + 10;
}
That'll dim by one brightness point every ten seconds, adjust as you see fit.
For the turning off and on functions, just set brightness to 0 or 100 or whatever.
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
self.torchtime = time + 30;
void () LightTorch =
{
if (time > self.torchtime) return;
...
I cant remember the dynamic light command in QuakeC, not EF_DIMLIGHT, but the one darkplaces supports that has a radius parameter.... you could lower the radius based on time..
radius = ((self.torchtime - time)/self.torchtime) * units;
units can be your preference of how bright 10 maybe good enough..
void () LightTorch =
{
if (time > self.torchtime) return;
...
I cant remember the dynamic light command in QuakeC, not EF_DIMLIGHT, but the one darkplaces supports that has a radius parameter.... you could lower the radius based on time..
radius = ((self.torchtime - time)/self.torchtime) * units;
units can be your preference of how bright 10 maybe good enough..
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
However it doesn't seem to be working. The light's not getting any dimmer. Is it the light cannot be changed after being spawned, and therefore is just remaining at its initial value?
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
I don't know if it works with dynamic lights, but if somehow you could apply a lightstyle that would be one way to dim it without reducing the radius. I doubt you can do it though.
Actually, it may be a mistake with the timer, or with how you're setting its brightness in code. Try creating an impulse that will reduce the light's brightness by 10 each time, so you can just tap a key to test its brightness reduction. That way you can narrow it down to the timer or brightness code, to see which is the problem.
Actually, it may be a mistake with the timer, or with how you're setting its brightness in code. Try creating an impulse that will reduce the light's brightness by 10 each time, so you can just tap a key to test its brightness reduction. That way you can narrow it down to the timer or brightness code, to see which is the problem.
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
- Wazat
- Posts: 771
- Joined: Fri Oct 15, 2004 9:50 pm
- Location: Middle 'o the desert, USA
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest