.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
player_run () Improvement (Groups : qc : Forum : hard_code() : player_run () Improvement) Locked
Thread Options
Dec 9 2015 Anchor

I collaborated on this with another coder years ago, seems to work pretty well, but could use some adjustments maybe. The goal is to eliminate the player from animating when you are blocked and cant really move. Vanilla Q has the player doing player_run even if you are moving into a wall indefinitely, so this is the code we came up with.


// add this new function

float(entity head) Blocked =
{
if (head.health < 1 || head.waterlevel > 0) return 0; // not needed if in liquid or dead
local float score;
local vector here;
here = head.origin - '0 0 10'; // all calcs take place at about knee level

if (vlen(head.velocity) >= 28) return 0; 
// a reinforcement , this assumes a normal player using always run = on, might need improvement in some cases such as falling...



if (head.flags &amp; FL_CLIENT) // Only for real clients
{
if (pointcontents (here + '18 0 0') == CONTENT_SOLID) 
score = score + 1; // Front at knee level
if (pointcontents (here + '-18 0 0') == CONTENT_SOLID) score = score + 1; // back at knee level
if (pointcontents (here + '18 18 0') == CONTENT_SOLID) 
score = score + 1; // Front side at knee level
if (pointcontents (here + '18 -18 0') == CONTENT_SOLID) 
score = score + 1; // Front side knee level
if (pointcontents (here + '-18 18 0') == CONTENT_SOLID) 
score = score + 1; // back side at knee level
if (pointcontents (here + '-18 -18 0') == CONTENT_SOLID) 
score = score + 1; // back side at knee level
if (pointcontents (here + '0 18 0') == CONTENT_SOLID) 
score = score + 1; // side at knee level
if (pointcontents (here + '0 -18 0') == CONTENT_SOLID) 
score = score + 1; // side at knee level
}


if (score)
{
if (vlen(head.velocity) > 44.5)&nbsp;return 0; // a reinforcement to make sure of looks

return 1; // we are blocked
}
return FALSE; // Entity is not in blocked.
};

// Alter this , change existing code in player_run

if ((!self.velocity_x &amp;&amp; !self.velocity_y) || (Blocked (self) &amp;&amp; !self.waterlevel))
{
self.walkframe = 0;
player_stand1 ();
return;
}

// Plus identical changes in player_stand1

if ((self.velocity_x || self.velocity_y) && !Blocked (self))
	{
		self.walkframe = 0;
		player_run ();
		return;
	}



numbersix
numbersix quake-c coder++
Dec 11 2015 Anchor

This is a tricky one. What is really strange - with 0 velocity on the vanilla tests you stay in run frames if you hold the button.
If you go by the qc code, you should go to stand frames at 0 velocity - this must be an engine thing.

And if I had to guess, I'd say it might have to do with early multiplayer. Which often happened over modem or slow
lan connection (10 base 2, hello...) Lots of lag, slowdowns and hiccups. Multiplayer was really hit or miss like that.
From what I remember usually miss. Now we are all (almost anyway) LPB's.

You could also try tracking origin. Then you dont need all that pointcontents.

A vlen of new - old less than a certain value could indicate no motion. Have to experiment to find good test numbers.

You want to remove z of course - dont need to run while you are falling.

Just make sure the tests dont constantly bounce back and forth from run to stand:

player.qc : player_run : statement 11
player.qc : player_stand1 : statement 9
player.qc : player_run : statement 11
player.qc : player_stand1 : statement 9
Host_ShutdownServer
Client "player" dropped

--

\|/
-*- Support free code: Patreon.com
/|\

Dec 12 2015 Anchor

You could be right regarding MP / modem play as the symptom of this.

Good idea on vlen (old - new).


As the code is now, even if you are facing a wall, and sorta "sliding" on an angle accross it, such as angling the mouse slightly off center, it will animate. Those vlen statements are the reinforcements for that condition I believe. Yea an engine fix would be best. I also at first had that runaway loop , but it was because I forgot to add the stuff in player_stand1.

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.