View previous topic :: View next topic |
Author |
Message |
Static_Fiend
Joined: 17 Mar 2010 Posts: 6
|
Posted: Wed Apr 14, 2010 1:55 am Post subject: |
|
|
Sajt wrote: | Darkplaces fixed this a long time ago. I don't remember if it was made into a sv_gameplayfix cvar, but it should be. |
Indeed it was, sv_gameplayfix_gravityunaffectedbyticrate |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Wed Apr 14, 2010 3:53 am Post subject: |
|
|
I understand now, I had to do some ticrate leveling gamecode in my ctf mod. At different ticrate the hook cause irrational damages.
Code: |
void () HookPull =
{
local vector vel;
local float v, dorg, a, b, c;
if ((ctf_state & CTF_MATCH_PAUSED))
{
return;
}
if ((!self.owner.button0 && self.owner.weapon == IT_HOOK) || (self.owner.teleport_time > time ) || (self.owner.deadflag) || (gameover))
{
HookVanish();
return;
}
if (self.enemy.style & CTF_OBSERVER)
{
HookVanish();
return;
}
if (self.enemy.takedamage)
{
if (!teamplay || self.enemy.team != self.owner.team)
{
if (!CanDamage(self.enemy, self.owner,"hook"))
{
HookVanish();
return;
}
self.enemy.deathtype = "hook";
//R00k: tear-away hook if the chain is pulled too hard...
a = vlen (self.enemy.velocity);
b = vlen (self.owner.velocity);
c = (a - b);
if (c > 640)
{
sound (self, CHAN_WEAPON, "shambler/smack.wav", 1, ATTN_NORM);
T_Damage (self.enemy, self, self.owner, 20);//same damage as an AXE hit
HookVanish();
return;
}
//T_Damage (self.enemy, self, self.owner, 1);
//at lower ticrates the hook damage is updated too fast
//default 200a+100h = 30 seconds to death by hook
self.hookdmg = (self.hookdmg + (sys_ticrate/0.1));
if (self.hookdmg >= 1)
{
sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
T_Damage (self.enemy, self, self.owner, 1);
if (self.enemy.classname == "player")
{
SpawnBlood (self.origin, self.velocity, 10);
}
self.hookdmg = 0.00;
}
makevectors (self.v_angle);
}
if (self.enemy.classname == "player")
{
setorigin (self, self.enemy.origin + self.enemy.mins + (self.enemy.size * 0.5));
}
else
{
self.velocity = self.enemy.velocity;//Fixme REMOVE/test effect
}
}
else
{
self.velocity = self.enemy.velocity;//Fixme :REMOVE
}
if (self.enemy.solid == SOLID_NOT)// obsolete?
{
HookVanish();
return;
}
makevectors (self.owner.angles);
vel = self.origin - ( self.owner.origin + (v_up * 16 * (!self.owner.button2)) + (v_forward * 16));
v = vlen (vel);
if ( v > 100 )
{
vel = (normalize(vel) * hookspeedpull);
}
else
{
if (v <= 100)
{
vel = ((normalize(vel) * v) * 10);
}
}
self.owner.velocity = vel;
if (!(self.owner.flags & FL_WATERJUMP)) //Slow down the hook pull if underwater 20% less...
{
self.owner.velocity = ((1 - ((0.8 * self.owner.waterlevel) * frametime)) * self.owner.velocity);
}
if (ctf_state & CTF_TEAM_CAPTURE_CUSTOM)
{
dorg = vlen(self.owner.origin - self.dest);
if (dorg > 10 && self.style == 3)
{
sound(self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
self.style = 2;
}
else
{
if (dorg < 10 && self.style == 2)
{
sound(self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
self.style = 3;
}
}
}
self.dest = self.owner.origin;
self.nextthink = (time + sys_ticrate);
};
|
also to countermeasure QW CTF, this converts bunnyhops at any ticrate to simulate default Quake ticrate.
Code: |
if ((ctf_playmode & CTF_DYNAMIC_HOOK) && (hookspeedpull > 999)) //normalize bunny hop at all ticrates
{
if ((self.flags & FL_ONGROUND) && self.button2)
{
if (vlen(self.velocity) >= 576)
{
self.velocity = (self.velocity * (576 / (vlen(self.velocity))));
}
}
}
|
|
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Wed Apr 14, 2010 9:04 am Post subject: |
|
|
metlslime wrote: | the client and server only need readonly access to the shared model data once it's loaded, right? So they probably don't need their own copies of it. |
In theory I guess so, but the concern is that the client thread might modify some memory while the server thread is reading it. It might not be a big deal but I'm just about paranoid enough to be worried about it. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Wed Apr 14, 2010 9:50 am Post subject: |
|
|
the client doesn't modify models, but it does flush the cache system occasionally, and on map changes. _________________ What's a signature? |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
|
Back to top |
|
 |
mk

Joined: 04 Jul 2008 Posts: 94
|
Posted: Thu Jul 01, 2010 8:07 am Post subject: |
|
|
Static_Fiend wrote: | Sajt wrote: | Darkplaces fixed this a long time ago. I don't remember if it was made into a sv_gameplayfix cvar, but it should be. |
Indeed it was, sv_gameplayfix_gravityunaffectedbyticrate |
From what I've seen in this version of Nexuis' source code, their implementation was wrong, as it doesn't seem to add the other half of the velocity update after updating the position. The solution mh posted here also has the same problem.
To implement this fix properly, I've searched for every call to SV_AddGravity, and added another call after the position update in each function that calls it. Now it behaves the same as before when playing with high framerates.
However, I still have to check for everything else that may also (de)accelerate the velocity, such as friction. _________________ Makaqu engine blog / website.
Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Thu Jul 01, 2010 9:09 am Post subject: |
|
|
Another crazy idea here. Since we're talking about host_frametime as a multiplier for all of the physics functions, why not do the change directly on host_frametime itself? _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Thu Jul 01, 2010 10:14 am Post subject: |
|
|
making physics framerate independant (gravity specifically), you need:
vel += graivty*time/2;
origin += vel*time;
vel += gravity*time/2;
yeah, you could be lazy, split time into two, call it twice, with the second time with the origin-based frametimes set to 0.
but it would give lower fps, as you'd prolly be tracing through stuff twice. _________________ What's a signature? |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Thu Jul 01, 2010 12:36 pm Post subject: |
|
|
Interesting ...
This may some erratic behavior on some maps where the host_fps is really high (most NQ clients running in single player the maxfps is also the server maxfps). _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Thu Jul 01, 2010 4:36 pm Post subject: |
|
|
Related:
In JoeQuake build 1862, there is a feature called cl_independent physics which I am assuming the goal is to get all the benefits of a higher frame rate (mouse polling mostly I'd think) without screwing up the physics.
Code: | if (cl_independentphysics.value)
{
double minphysframetime = MinPhysFrameTime ();
extraphysframetime += host_frametime;
if (extraphysframetime < minphysframetime)
{
physframe = false;
}
else
{
physframe = true;
if (extraphysframetime > minphysframetime * 2) // FIXME: this is for the case when
physframetime = extraphysframetime; // actual fps is too low
else // Dunno how to do it right
physframetime = minphysframetime;
extraphysframetime -= physframetime;
}
}
#ifdef INDEPENDENTPHYSICS
if (!cl_independentphysics.value)
{
#endif
// get new key events
Sys_SendKeyEvents ();
// allow mice or other external controllers to add commands
IN_Commands ();
// process console commands
Cbuf_Execute ();
NET_Poll ();
// if running the server locally, make intentions now
if (sv.active)
CL_SendCmd (); |
_________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Thu Jul 01, 2010 10:31 pm Post subject: |
|
|
Physics/collision programming drives me crazy. Fixed framerate is the least you can do to "improve" the situation a bit... but fixed framerate is evil too. Things were good in the old days... nothing rotated, and you could even use integers if you wanted... _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 909
|
Posted: Thu Jul 01, 2010 11:20 pm Post subject: |
|
|
Obviously proper separation of server and client, with the server running at a fixed 72fps and the client running as fast or slow as it wants is the correct solution here. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Thu Jul 01, 2010 11:28 pm Post subject: |
|
|
Probably true. It means departure from the cherished "client sends input, server frame, rest of client frame" high-response scheme for local games, but that's probably a necessary (and probably unnoticeable) sacrifice. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
|