Damage Conc Jumping
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(victim, inflictor, attacker, Float:damage, damagetype)
{
new iOwnerTeam = get_user_team(attacker)
if(!(1 <= 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(victim, Vec, 3)
IVecFVec(Vec, fVec)
pev(attacker, pev_origin, origin);
new Float:dist = get_distance_f( origin, fVec );
new Float:radius = 400.0
new Float:boost = maxboost - ((maxboost * dist) / radius );
if(get_user_weapon(attacker) == CSW_AWP)
{
set_velocity_from_origin(victim, fVec, boost);
}
return HAM_HANDLED
}
stock get_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3] )
{
new Float:fEntOrigin[3];
pev( ent, pev_origin, fEntOrigin );
// 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_distance( fEntOrigin,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_origin( ent, Float:fOrigin[3], Float:fSpeed )
{
new Float:fVelocity[3];
get_velocity_from_origin( ent, fOrigin, fSpeed, fVelocity )
set_pev( ent, pev_velocity, fVelocity );
return ( 1 );
}
I also try code from https://forums.alliedmods.net/showthread.php?t=6559
|