Raised This Month: $12 Target: $400
 3% 

Detecting walk/run [SHIFT]


Post New Thread Reply   
 
Thread Tools Display Modes
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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-21-2021 , 09:04   Re: Detecting walk/run [SHIFT]
Reply With Quote #2

You want to catch if the player is holding the shift walking or if the player is walking?

I know they sound similar but they're different because shift walking its the maxspeed times cl_movespeedkey client cvar value equal to player speed or greater than it.

And the other one is any speed equal or below 135/210 is said to trigger the walking animation.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-21-2021 at 18:26. Reason: cl_movespeedkey
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-21-2021 , 18:13   Re: Detecting walk/run [SHIFT]
Reply With Quote #3

This has been discussed a few times in the past. The below thread/code will tell you if a player is walking or running, but only when moving, which to me makes sense because who cares if a player is standing still?

https://forums.alliedmods.net/showpo...62&postcount=9
__________________
Bugsy is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-21-2021 , 22:21   Re: Detecting walk/run [SHIFT]
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
You want to catch if the player is holding the shift walking or if the player is walking?

I know they sound similar but they're different because shift walking its the maxspeed times cl_movespeedkey client cvar value equal to player speed or greater than it.

And the other one is any speed equal or below 135/210 is said to trigger the walking animation.
I was confused "Detect" and "Hook" a bit.

I actually aimming for "Change holding Shift from walk to sprint" so holding Shift increased speed instead of slowdown.

So can we increase player speed by increase cl_movespeedkey? and isn't it would consider "Slowhacking" if we try to change it?
__________________
My plugin:

Last edited by Celena Luna; 10-21-2021 at 22:26.
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-21-2021 , 22:50   Re: Detecting walk/run [SHIFT]
Reply With Quote #5

Quote:
Originally Posted by Celena Luna View Post
I was confused "Detect" and "Hook" a bit.

I actually aimming for "Change holding Shift from walk to sprint" so holding Shift increased speed instead of slowdown.

So can we increase player speed by increase cl_movespeedkey? and isn't it would consider "Slowhacking" if we try to change it?
No we're not doing that, we will only retrieve the value to check if the player holding the shift walk, then you can change player maxspeed and set it back on release or setting velocity
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-22-2021 at 00:30.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 04:01.


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