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

Skip knife draw animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
felhasznalo
AlliedModders Donor
Join Date: Aug 2015
Location: Hungary
Old 06-29-2019 , 06:42   Skip knife draw animation
Reply With Quote #1

Is it possible to skip the knife draw animation and be able to slash/stab players instantly when switching to weapon_knife?

Last edited by felhasznalo; 06-29-2019 at 06:45.
felhasznalo is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-29-2019 , 08:26   Re: Skip knife draw animation
Reply With Quote #2

Execute the Ham_Weapon_PrimaryAttack/Ham_Weapon_SecondaryAttack in Ham_Item_Deploy.
__________________








CrazY. is offline
felhasznalo
AlliedModders Donor
Join Date: Aug 2015
Location: Hungary
Old 06-29-2019 , 15:28   Re: Skip knife draw animation
Reply With Quote #3

I would like to make the player to be able to execute the attack by pressing the mouse button, not attacking automatically.

I would like to skip the animation and allow the player to use the knife if they want.

Last edited by felhasznalo; 06-29-2019 at 15:29.
felhasznalo is offline
felhasznalo
AlliedModders Donor
Join Date: Aug 2015
Location: Hungary
Old 06-29-2019 , 15:34   Re: Skip knife draw animation
Reply With Quote #4

So if I'm correct, I need to do the following tasks:

- Detect when switching weapons -> I can detect this event with Ham_Item_Deploy
- Set knife viewmodel animation to idle -> I've tried set_pev(playerId, pev_weaponanim, 0) without success
- Set next attack timer to zero to allow the player to attack as soon as they want -> I've tried setting m_flNextPrimaryAttack, m_flNextSecondaryAttack without success

Last edited by felhasznalo; 06-29-2019 at 15:54.
felhasznalo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-29-2019 , 16:12   Re: Skip knife draw animation
Reply With Quote #5

IIRC the knife draw animation is played in the client (too) so even if you disable it server side it would still play for anyone with cl_lw 1(basically every player).
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-29-2019 , 16:36   Re: Skip knife draw animation
Reply With Quote #6

So set the m_flNextPrimaryAttack/m_flNextAttack to 0.0. The animation would't be removed but player would be able to attack without wait untill the idle animation.
__________________









Last edited by CrazY.; 06-29-2019 at 16:37.
CrazY. is offline
felhasznalo
AlliedModders Donor
Join Date: Aug 2015
Location: Hungary
Old 06-30-2019 , 03:50   Re: Skip knife draw animation
Reply With Quote #7

I set m_flNextPrimaryAttack/m_flNextAttack to 0.0, but I was unable to attack while the animation was playing.
felhasznalo is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-30-2019 , 05:16   Re: Skip knife draw animation
Reply With Quote #8

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <orpheu>
#include <hamsandwich>

const m_pPlayer 41
const m_iId     43
const XoWeapon  4

enum
{
    
KNIFE_IDLE,
    
KNIFE_ATTACK1HIT,
    
KNIFE_ATTACK2HIT,
    
KNIFE_DRAW,
    
KNIFE_STABHIT,
    
KNIFE_STABMISS,
    
KNIFE_MIDATTACK1HIT,
    
KNIFE_MIDATTACK2HIT,
    
KNIFE_INSPECT
}

public 
plugin_init()
{
    
register_forward(FM_UpdateClientData"pfnUpdateClientData"true)
    
OrpheuRegisterHook(OrpheuGetFunctionFromClass("weapon_knife""SendWeaponAnim""CBasePlayerWeapon"), "OnSendWeaponAnim"OrpheuHookPre)
}

public 
pfnUpdateClientData(idSendWeaponsCD_Handle)
{
    if(
is_user_alive(id) && SendWeapons)
    {
        if(
get_user_weapon(id) == CSW_KNIFE)
        {
            
set_cd(CD_HandleCD_ID0);         
        }
    }
}

public 
OrpheuHookReturn:OnSendWeaponAnim(WeaponEntityAnimationSkipLocal)
{
    if(
pev_valid(WeaponEntity))
    {
        new 
id get_pdata_cbase(WeaponEntitym_pPlayerXoWeapon)
        if(
is_user_alive(id))
        {
            new 
WeaponIndex get_pdata_int(WeaponEntitym_iIdXoWeapon)
            
            if(
WeaponIndex != CSW_KNIFE)
            {
                return 
OrpheuIgnored
            
}
            
            if(
Animation != KNIFE_DRAW)
            {
                
SendWeaponAnim(idAnimation)
            }

            return 
OrpheuSupercede
        
}
    }

    return 
OrpheuIgnored
}

SendWeaponAnim(idAnimation)
{
    
set_pev(idpev_weaponanimAnimation)
    
message_begin(MSG_ONESVC_WEAPONANIM_id)
    {
        
write_byte(Animation)
        
write_byte(0)
        
message_end()
    }

Didn't test, but maybe it will work, give it a try.

Code:
{
    "name"    : "SendWeaponAnim",
    "class"   : "CBasePlayerWeapon",
    "library" : "mod",
    "arguments" :
    [
        {
            "type" : "int"
        },
        {
            "type" : "int"
        }
    ],
    "indexes" : 
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : 85
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : 87
        }
    ]
}
Put this in \configs\orpheu\virtualFunctions\CBasePlayerW eapon
__________________

Last edited by HamletEagle; 06-30-2019 at 05:17.
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-30-2019 , 08:10   Re: Skip knife draw animation
Reply With Quote #9

A little off-topic here, but I always wanted to know if the CD_ID blocks get_user_weapon from returning the weapon ID in others plugins, am I right?
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Reply



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 18:57.


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