AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why is pev_v_angle so choppy? (https://forums.alliedmods.net/showthread.php?t=65324)

jameszhao00 01-05-2008 22:26

Why is pev_v_angle so choppy?
 
1 Attachment(s)
Hi,
I'm recording a player's view vectors and importing them into another application for analysis. Currently I update a list of all the view vectors each server_frame, and when the fire button has been pressed and released, I save it to a file. Although it works, the results are very choppy. Is this an coding error or just how the HL1 engine works?

Also included is a screenshot of vertical viewvec recording's plot. Notice how choppy it is.

Here's my server_frame. recordAngles records the angles to disk.
Code:

//anges stuff
new Float:angles[100][3];
new angleCurrent = 0;
//player stuff
new Players[32]
new playerCount
new inAttack=0;
public server_frame()
{
    get_players(Players, playerCount, "c")
    if(playerCount>0)
    {
        //a human player is in the game
        new playerID = Players[0];
        pev(playerID, pev_v_angle, angles[angleCurrent])
        if(get_user_button(playerID) & IN_ATTACK)
        {
            inAttack=1;   
           
        }
        else if(inAttack ==1)
        {
            //here the attack button has been clicked and released
            //record the data
            recordAngles();
            inAttack=0;
            client_print(playerID, print_chat, "Recorded Aim Vectors");
        }
        angleCurrent++;
        if(angleCurrent > 99)
            angleCurrent=0;
               
    }
}

Thanks,
James

Drak 01-05-2008 23:27

Re: Why is pev_v_angle so choppy?
 
It's most likely caused when using "server_frame()". Also, the way you're using "get_players()" it would only return the first player it finds.
Code:
//anges stuff new Float:angles[100][3]; new angleCurrent = 0; //player stuff new Players[32] new playerCount new inAttack=0; public server_frame() {     get_players(Players,playerCount,"c");     for(new i;i<playerCount;i++)     {         new playerID = Players[i]         pev(playerID, pev_v_angle, angles[angleCurrent])         if(get_user_button(playerID) & IN_ATTACK)         {             inAttack=1;                         }         else if(inAttack ==1)         {             //here the attack button has been clicked and released             //record the data             recordAngles();             inAttack=0;             client_print(playerID, print_chat, "Recorded Aim Vectors");         }                 angleCurrent++;         if(angleCurrent > 99)             angleCurrent=0;                         } }

jameszhao00 01-06-2008 00:39

Re: Why is pev_v_angle so choppy?
 
If so, which event should I listen to? I already tried the client_PostThink, which didn't work out so well...

I only needed the first non-bot player's data, as I'm testing stuff and there's only myself on the server. (except the bots) When I start analyzing cal demos I'm probably going to make it support up to 32 players.

Drak 01-06-2008 01:15

Re: Why is pev_v_angle so choppy?
 
Well.. Maybe a task, although more efficient then "server_frame()" it can only call a function as fast as 0.1 seconds.
Example:
Code:
set_task(0.1,"MyFunc",0,"",0,"b");


All times are GMT -4. The time now is 11:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.