AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Skip knife draw animation (https://forums.alliedmods.net/showthread.php?t=317141)

felhasznalo 06-29-2019 06:42

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

CrazY. 06-29-2019 08:26

Re: Skip knife draw animation
 
Execute the Ham_Weapon_PrimaryAttack/Ham_Weapon_SecondaryAttack in Ham_Item_Deploy.

felhasznalo 06-29-2019 15:28

Re: Skip knife draw animation
 
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.

felhasznalo 06-29-2019 15:34

Re: Skip knife draw animation
 
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 :(

HamletEagle 06-29-2019 16:12

Re: Skip knife draw animation
 
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).

CrazY. 06-29-2019 16:36

Re: Skip knife draw animation
 
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.

felhasznalo 06-30-2019 03:50

Re: Skip knife draw animation
 
I set m_flNextPrimaryAttack/m_flNextAttack to 0.0, but I was unable to attack while the animation was playing.

HamletEagle 06-30-2019 05:16

Re: Skip knife draw animation
 
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

EFFx 06-30-2019 08:10

Re: Skip knife draw animation
 
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?


All times are GMT -4. The time now is 17:27.

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