Raised This Month: $ Target: $400
 0% 

Detecting walk/run [SHIFT]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-21-2021 , 04:27   Detecting walk/run [SHIFT]
Reply With Quote #1

It is something I want to discuss than actually a question.

1. Wrong way to detect walk
PHP Code:
buttons pev(idpev_buttons//or buttons = get_uc(cmd, UC_Buttons) if using at CmdStart

//Check running
if(buttons IN_RUN)
{
     
//Do stuff

This is most people thought at first if they try to check running/walking but it actually didn't work at all
Because IN_RUN exist but it never been called or set anywhere


2. The usual way to detect walk
Usually, when we want to detect walk/run, we have to check via Player Maxspeed
There was an old topic discussed about this (Link)

3. Detect via player sequence
This way, we try to detect walk/run via checking player sequence. More specifically - Gaitsequence

PHP Code:
stock IsPlayerWalking(id)
{
    static 
buttonssequence;
    
buttons pev(idpev_button);
    
sequence pev(idpev_gaitsequence);
 
    if((
buttons IN_FORWARD || buttons IN_BACK || buttons IN_LEFT || buttons IN_RIGHT))
    {
        if(
sequence == 3)
            return 
true;
        else 
            return 
false
    
}

    return 
false

sequence == 3 because Player Model's walk sequence is 3 and we know it is gaitsequence because the animation was on the lower part of the body.



4. Detect via m_Activity (reHLDS/reGameDLL)
When I look up in reGameDLL, I saw player animation was set depend on Activity and from Activity, to LookUpSequence

In ReAPI we have a member called m_Activity so we can actually check it like this
PHP Code:
stock IsPlayerWalking(id)
{
    static 
Activity:Act//cssdk_const
    
Act get_member(idm_Activity//I am not sure what this return though, haven't try
    
if(Act == ACT_WALK)
        return 
true;
    
    return 
false

I don't want to post in TUT section because I am not sure how many % all of this is correct so I want to make it as a discussion first.

PS: Also, I saw this part which related to speed
PHP Code:
if (speed 135.0f)
    
pev->gaitsequence LookupActivity(ACT_RUN);
else
    
pev->gaitsequence LookupActivity(ACT_WALK); 
So it still lead to a problem when we try to detect walk to turn it into "Sprint" (Hold Shift to run faster) or the player speed modified (like Zombie Mod), it will automatically change to RUN when speed > 135.0f (I am lazy to convert for now).

This all might be non-sense so forgive me if all of this is wrong
__________________
My plugin:

Last edited by Celena Luna; 10-21-2021 at 04:43.
Celena Luna is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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