AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating knockback. (https://forums.alliedmods.net/showthread.php?t=84388)

Fry! 01-25-2009 08:45

Creating knockback.
 
Hi, guys! I want to ask something is it possible to create knockback for knife too? just like for all other weapons? If yes please show it how...

Regards.

ConnorMcLeod 01-25-2009 10:13

Re: Creating knocback.
 
Try this :

PHP Code:

/*    Copyright © 2009, ConnorMcLeod

    Knife KnockBack is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Knife KnockBack; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#define PLUGIN "Knife KnockBack"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

new g_pCvarKnockBack

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_pCvarKnockBack register_cvar("amx_knife_knockback""10")

    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage"1)
}

public 
Player_TakeDamage(ididinflictoridattackerFloat:flDamagedamagebits)
{
    if(    !
idattacker
    
||    id == idattacker
    
||    idinflictor != idattacker//    )
    
||    get_user_weapon(idattacker) != CSW_KNIFE    )
    {
        return
    }

    new 
Float:fDir[3], Float:fOrigin[3], Float:fVelocity[3]

    
pev(idpev_originfDir)
    
pev(idattackerpev_originfOrigin)

    
xs_vec_sub(fDirfOriginfDir)
    
xs_vec_normalize(fDirfDir)

    
flDamage *= get_pcvar_num(g_pCvarKnockBack)
    if( 
flDamage 1500.0 )
        
flDamage 1500.0

    pev
(idpev_velocityfVelocity)
    
xs_vec_mul_scalar(fDirflDamagefDir)
    
xs_vec_add(fVelocityfDirfVelocity)
    
set_pev(idpev_velocityfVelocity)



Fry! 01-25-2009 11:44

Re: Creating knockback.
 
Um, no doesn't work even cvar wont work.

ConnorMcLeod 01-25-2009 12:26

Re: Creating knockback.
 
I have tested with high cvar value and was working.

Fry! 01-25-2009 12:50

Re: Creating knockback.
 
um, can you add distance too how far victim will knocked back? Cuz otherwise looks like it's just a knife hit... ;/

Dores 01-25-2009 15:08

Re: Creating knockback.
 
Quote:

Originally Posted by Fry! (Post 749942)
um, can you add distance too how far victim will knocked back? Cuz otherwise looks like it's just a knife hit... ;/

The higher the cvar's value, the farther he will get knocked back.
I suggest making it random though.

Fry! 01-25-2009 16:28

Re: Creating knockback.
 
When I tested with bots this plugin didn't work at all... When I knife enemys they even wont knocked back... wtf?

ConnorMcLeod 01-25-2009 17:02

Re: Creating knockback.
 
Tested with podbots and works, but may be it would help to set the player higher when he is on ground.

stupok 01-25-2009 17:06

Re: Creating knockback.
 
Bots will behave a little bit differently than regular clients when you're setting their velocity.

From experience, I've found that bots need to be pushed much harder.

Dores 01-25-2009 17:33

Re: Creating knockback.
 
@Fry: According to stupok, just remove those lines:
Code:
if( flDamage > 1500.0 )         flDamage = 1500.0
And then you could set the cvar's value to a much higher one.


All times are GMT -4. The time now is 01:38.

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