PDA

View Full Version : Show Jump-Distance



DjTranceFire
21st October 2013, 10:16
Hey guys..
At first i want to say sorry for my bad english! :P
I'm new to modding but i try my best..
I created a small script to show the jump distance of a player but its not working as it should.
It prints the distance but the distance is not realy precise.
I tested it on a custom map with known gap's to check everything..
I jumped a distance of 240 Units but my script prints smaller distances then 240.
Maybe someone has a good idea to improve this script? :x



while(1)
{
if(!self.InJump && self isOnGround())
{
self.startJumpPos = self.origin;
}
else if(self.InJump && self isOnGround())
{
self.jump_distance = distance( self.startJumpPos, self.origin );
self iPrintLn("You jumped "+self.jump_distance+" units.");
self.InJump = false;
}
else if(!self isOnGround())
{
self.InJump = true;
}
wait 0.05;
}

IzNoGoD
21st October 2013, 11:09
Not possible, i tried a while back with speed prediction, but still was not possible. You cannot know where you land or take off.

DjTranceFire
21st October 2013, 12:56
ok, thank you for the quick answer! :)

kung foo man
21st October 2013, 15:37
For a side note, things like this would require client side scripting for running a function each com_maxfps-frame, which is not possible in CoD2.

Any server side while (1) { wait 0.05; } loop is just too slow.

megazor
24th October 2013, 03:19
You could try setting sv_fps to 125 :)

But any way, even if you managed somehow to get the exact distance jumped, it wouldn't work correctly for gap jumping.

I found out that the movement of the player in the air depends on solid objects they are flying by. I used my .cfg jump script for various gap distances, and I noticed: the greater distance it was, the bigger value my distance-meter would show. Although jumping with a script is supposed to be pretty much the same regardless of which gap you jump over.

That there problem limits the use of the distance jumped check.

Tally
25th October 2013, 00:11
You could try setting sv_fps to 125 :)

But any way, even if you managed somehow to get the exact distance jumped, it wouldn't work correctly for gap jumping.

I found out that the movement of the player in the air depends on solid objects they are flying by. I used my .cfg jump script for various gap distances, and I noticed: the greater distance it was, the bigger value my distance-meter would show. Although jumping with a script is supposed to be pretty much the same regardless of which gap you jump over.

That there problem limits the use of the distance jumped check.

If you set your server's FPS to 125 you would screw up the gametype timing which was designed with 20 FPS in mind. Things would be ending too soon; the game would be over before it really was.

The only way you can screw around with sv_fps is to re-code all the wait times in a gametype, and make the waits a variable based on what sv_fps is set to. This is how it is done in PAM and eXtreme+ mods.

Tally
25th October 2013, 00:20
Not possible, i tried a while back with speed prediction, but still was not possible. You cannot know where you land or take off.

What about monitoring when a player jumps (leaves the ground), get the origin at the point they left the ground (origin 1), then get the origin where the player lands (is no longer in the air - origin 2), and then measuring the distance between origin 1 and origin 2. It's very easy to monitor when a player jumps:


jumpMonitor()
{
self endon( "disconnect" );
self endon( "death" );
level endon( "intermission" );

count = 0;
stop_db = (level.anti_dbbh == 1) || (level.anti_dbbh == 3);
stop_bh = (level.anti_dbbh == 2) || (level.anti_dbbh == 3);
lastjump = 3;

for( ;; )
{
count ++;
if( count > 3 )
{
jump = self StanceCheck( true );

// Test if dive bombing
if( stop_db && self getStance() == "prone" )
self thread WeaponPause( 0.4 );

// Test if bunny hopping
if( stop_bh && ( (jump == 3) && (lastjump != 3) ) )
self thread WeaponPause( 0.4 + randomfloat( 0.3 ) );

lastjump = jump;
count = 0;
}

wait( 0.05 );
}
}

WeaponPause( time )
{
self endon( "death" );
self endon( "disconnect" );
level endon( "intermission" );

self disableWeapon();

wait( time );

self enableWeapon();
}

StanceCheck( checkjump )
{
if( checkjump && !self isOnGround() )
{
groundpos = physicstrace( self.origin, self.origin + (0, 0, -100) );
if( distance( self.origin, groundpos ) >= level.anti_dbbh_jump_height )
return 3;
}

return 0;
}


In theory, an adaptation of the above script would be fairly simple.

megazor
25th October 2013, 03:07
What about monitoring when a player jumps (leaves the ground), get the origin at the point they left the ground (origin 1), then get the origin where the player lands (is no longer in the air - origin 2), and then measuring the distance between origin 1 and origin 2.
I guess many people tried it, including IzNoGoD and me. The problem is, there are usually multiple client frames between two server frames.

If on server frame #n a player was on the ground and on frame #(n+1) they turned to be in the air, it doesn't necessarily mean that the player's origin on frame #n was the last ground-based origin.

But still, have you read my post through? You quoted it all but commented only first part. As I said, even with a perfectly working distance-meter, you can't use it for accurate jump measurement like in Counter-Strike.

---
I'll say even more on the sv_fps workaround. Not only it changes the gametype timing, it also changes the player's physics, especially the length of jump.

IzNoGoD
25th October 2013, 08:27
I guess many people tried it, including IzNoGoD and me. The problem is, there are usually multiple client frames between two server frames.

If on server frame #n a player was on the ground and on frame #(n+1) they turned to be in the air, it doesn't necessarily mean that the player's origin on frame #n was the last ground-based origin.

But still, have you read my post through? You quoted it all but commented only first part. As I said, even with a perfectly working distance-meter, you can't use it for accurate jump measurement like in Counter-Strike.

---
I'll say even more on the sv_fps workaround. Not only it changes the gametype timing, it also changes the player's physics, especially the length of jump.

True, thats why i tried some prediction (if player is not onground anymore on frame n+1, then wait for frame n+2, make an educated guess of vertical speed (i have 2 not-onground frames), interpolate using g_gravity and bullettrace back to the supposed start origin to determine actual height of it, then do something similar for landing (onground on frame m+2, then interpolate using m and m+1 and g_gravity).

It didn't work, although it showed as if it was working (but too much difference between equal jumps)