Inside3D!
     

time, timing, timey-wimey

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Tue Nov 11, 2008 8:21 pm    Post subject: time, timing, timey-wimey Reply with quote

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
View user's profile Send private message MSN Messenger
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Wed Nov 12, 2008 12:20 am    Post subject: Reply with quote

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
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Wed Nov 12, 2008 12:29 am    Post subject: Reply with quote

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
View user's profile Send private message
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Wed Nov 12, 2008 12:59 am    Post subject: Reply with quote

r00k: he's using a cubemap torch, so no need for the radus etc.
_________________
Apathy Now!
Back to top
View user's profile Send private message
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Wed Nov 12, 2008 2:29 pm    Post subject: Reply with quote

Thanks a lot, thats brilliant help, cheers Very Happy
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Wed Nov 12, 2008 7:58 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Wed Nov 12, 2008 8:32 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Thu Nov 13, 2008 5:35 am    Post subject: Reply with quote

Maybe you can yell obscenities at the tourch and it will coward in fright Razz
ya well that didnt work with my acne either! Sad
Back to top
View user's profile Send private message
Chris



Joined: 05 Aug 2006
Posts: 78

PostPosted: Thu Nov 13, 2008 8:14 pm    Post subject: Reply with quote

grow up.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group