Results 1 to 9 of 9

Thread: Show Jump-Distance

  1. #1
    Private
    Join Date
    Oct 2013
    Posts
    48
    Thanks
    10
    Thanked 4 Times in 2 Posts

    Show Jump-Distance

    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

    Code:
    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;
    }

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Not possible, i tried a while back with speed prediction, but still was not possible. You cannot know where you land or take off.

  3. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    DjTranceFire (21st October 2013),kung foo man (21st October 2013)

  4. #3
    Private
    Join Date
    Oct 2013
    Posts
    48
    Thanks
    10
    Thanked 4 Times in 2 Posts
    ok, thank you for the quick answer!

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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.
    timescale 0.01

  6. #5
    Private
    Join Date
    Jul 2013
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 2 Posts
    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.

  7. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by megazor View Post
    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.

  8. #7
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by IzNoGoD View Post
    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:

    PHP Code:
    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 )
            {
                
    jump self StanceChecktrue );

                
    // Test if dive bombing
                
    if( stop_db && self getStance() == "prone" )
                    
    self thread WeaponPause0.4 );
                
                
    // Test if bunny hopping
                
    if( stop_bh && ( (jump == 3) && (lastjump != 3) ) )
                    
    self thread WeaponPause0.4 randomfloat0.3 ) );
                    
                
    lastjump jump;
                
    count 0;
            }

            
    wait0.05 );
        }
    }

    WeaponPausetime )
    {
        
    self endon"death" );
        
    self endon"disconnect" );
        
    level endon"intermission" );

        
    self disableWeapon();
        
        
    waittime );
        
        
    self enableWeapon();
    }

    StanceCheckcheckjump )
    {
        if( 
    checkjump && !self isOnGround() )
        {
            
    groundpos physicstraceself.originself.origin + (00, -100) );
            if( 
    distanceself.origingroundpos ) >= level.anti_dbbh_jump_height )
                return 
    3;
        }
        
        return 
    0;

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

  9. #8
    Private
    Join Date
    Jul 2013
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Tally View Post
    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.
    Last edited by megazor; 25th October 2013 at 02:15.

  10. #9