Forum

nextthink + csqc entity

Discuss CSQC related programming.

Moderator: InsideQC Admins

nextthink + csqc entity

Postby Nahuel » Mon Jun 19, 2017 10:50 pm

Ok guys, I’m sending an entity (2 seconds duration) to csqc. Once in csqc, that entity (which has a think() function) displays an image on screen. When the entity is removed in ssqc the image fades down in alpha to disappear and be removed in csqc. I am using nextthink = frametime to get the time of fading but it’s very problematic because at different fps it fades with different timing!! I am not sure if I can get time like ssqc does!! i wanna something similar but in csqc. (you know time + 0.1 is update each 0.1 seconds)

I did try using “time” and “frametime” with the same result, which is that fade times differ depending on FPS.
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 475
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: nextthink + csqc entity

Postby Spike » Tue Jun 20, 2017 6:18 am

1: thinks are probably not what you want in csqc. if its something that should be happening every single video frame (so its actually smooth) then you should generally use .predraw instead, or just fade the alpha as part of drawing it.
if (ent.alpha > 0)
{
drawimage(foo);
ent.alpha -= frametime/totalduration;
}

2: you probably shouldn't be removing csqc copy of an ssqc ent, until the engine says to do so. Trying to do it prematurely will just result in double frees or even premature reuse, which is something you really do not want.

3: time+frametime exist in csqc.
note that 'time' approximately matches the 'time' global in ssqc, which means it stops counting when the game is paused, and may briefly change faster or slower than on the server, or even jump a lot following packetloss. This also means that thinks STOP when the game is paused.
cltime also exists. this is the client's local time, and is completely independent of the game speed.
frametime is also based on the client's local time, which makes things fun. If you want the server time since the last video frame, you'll need to manually calculate that yourself.
Spike
 
Posts: 2838
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest