View previous topic :: View next topic |
Author |
Message |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Tue Nov 11, 2008 8:21 pm Post subject: 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. _________________ my site |
|
Back to top |
|
 |
MauveBib

Joined: 04 Nov 2004 Posts: 602
|
Posted: Wed Nov 12, 2008 12:20 am Post subject: |
|
|
Not too hard.
First, set up:
Code: |
.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: |
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! |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Wed Nov 12, 2008 12:29 am Post subject: |
|
|
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.. |
|
Back to top |
|
 |
MauveBib

Joined: 04 Nov 2004 Posts: 602
|
Posted: Wed Nov 12, 2008 12:59 am Post subject: |
|
|
r00k: he's using a cubemap torch, so no need for the radus etc. _________________ Apathy Now! |
|
Back to top |
|
 |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Wed Nov 12, 2008 2:29 pm Post subject: |
|
|
Thanks a lot, thats brilliant help, cheers  _________________ my site |
|
Back to top |
|
 |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Wed Nov 12, 2008 7:58 pm Post subject: |
|
|
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? _________________ my site |
|
Back to top |
|
 |
Wazat
Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA
|
Posted: Wed Nov 12, 2008 8:32 pm Post subject: |
|
|
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. _________________ 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. |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Thu Nov 13, 2008 5:35 am Post subject: |
|
|
Maybe you can yell obscenities at the tourch and it will coward in fright
ya well that didnt work with my acne either!  |
|
Back to top |
|
 |
Chris
Joined: 05 Aug 2006 Posts: 78
|
Posted: Thu Nov 13, 2008 8:14 pm Post subject: |
|
|
grow up. |
|
Back to top |
|
 |
|