Raised This Month: $ Target: $400
 0% 

Damage Conc Jumping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 03-29-2017 , 07:16   Damage Conc Jumping
Reply With Quote #1

What I'm trying to do:
a player who receives damage to be pushed directly in the air,not to the side(left,back,forward,right) only in the air.
I try this code but in this case the player gets pushed on side,not in the air. I found copy this code from scout_conc.sma.
PHP Code:
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"
PHP Code:
public fw_TakeDamage(victiminflictorattackerFloat:damagedamagetype)

    new 
iOwnerTeam get_user_team(attacker)

    if(!(
<= attacker <= gMaxPlayers) || inflictor != attacker || !is_user_connected(attacker))
            return 
HAM_IGNORED

    
if(iOwnerTeam == get_user_team(victim)) 
            return 
HAM_IGNORED

    
if(get_user_health(victim) < 20
            return 
HAM_IGNORED

    
new Float:maxboost 800.0
    
new Vec[3], Float:fVec[3], Float:origin[3]
    
get_user_origin(victimVec3)
    
IVecFVec(VecfVec)
    
pev(attackerpev_originorigin);
    new 
Float:dist get_distance_foriginfVec );
    new 
Float:radius 400.0
    
new Float:boost maxboost - ((maxboost dist) / radius );

    if(
get_user_weapon(attacker) == CSW_AWP)
    {                        
        
set_velocity_from_origin(victimfVecboost);
    }
    return 
HAM_HANDLED      
}

stock get_velocity_from_originentFloat:fOrigin[3], Float:fSpeedFloat:fVelocity[3] )
{
    new 
Float:fEntOrigin[3];
    
peventpev_originfEntOrigin );

    
// Velocity = Distance / Time

    
new Float:fDistance[3];
    
fDistance[0] = fEntOrigin[0] - fOrigin[0];
    
fDistance[1] = fEntOrigin[1] - fOrigin[1];
    
fDistance[2] = fEntOrigin[2] - fOrigin[2];

    new 
Float:fTime = ( vector_distancefEntOrigin,fOrigin ) / fSpeed );

    
fVelocity[0] = fDistance[0] / fTime;
    
fVelocity[1] = fDistance[1] / fTime;
    
fVelocity[2] = fDistance[2] / fTime;

    return ( 
fVelocity[0] && fVelocity[1] && fVelocity[2] );
}


// Sets velocity of an entity (ent) away from origin with speed (speed)

stock set_velocity_from_originentFloat:fOrigin[3], Float:fSpeed )
{
    new 
Float:fVelocity[3];
    
get_velocity_from_originentfOriginfSpeedfVelocity )

    
set_peventpev_velocityfVelocity );

    return ( 
);

I also try code from https://forums.alliedmods.net/showthread.php?t=6559
Krtola is offline
Send a message via Skype™ to Krtola
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 17:59.


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