ESF Knockback help

AMXX Coder (:
✔️ HL Verified
Discord Member
Joined
Dec 31, 2008
Messages
55
Best answers
0
So, i'm trying to do a knockback, but works only if players aren't flying, if they are in the air wont work. Could you tell me how to fix it?


PHP:
stock UTIL_KnockBack( id, Float:flRadius, Float:flSpeed )
{
	new Float:flEntityOrigin[ 3 ];
    	pev( id, pev_origin, flEntityOrigin );
    
    	new iClient = FM_NULLENT, Float:flClientOrigin[ 3 ];
	new Float:flDistance, Float:flVelocity[ 3 ], Float:flCalcSpeed;

    	while( ( iClient = engfunc( EngFunc_FindEntityInSphere, iClient, flEntityOrigin, flRadius ) ) )
    	{
        	if( IsPlayer( iClient ) && is_user_alive( iClient ) && esf_get_team( id ) != esf_get_team( iClient ) )
		{
			pev( iClient, pev_origin, flClientOrigin );

       			flDistance = get_distance_f( flEntityOrigin, flClientOrigin );
			flCalcSpeed = flSpeed * ( 1.0 - ( flDistance / flRadius ) );

			if( flDistance <= flRadius )
			{
       				get_speed_vector2( id, iClient, flCalcSpeed, flVelocity );
				set_pev( iClient, pev_velocity, flVelocity );
			}
    		}
	}
}
stock get_speed_vector2(ent1, ent2, Float:speed, Float:new_velocity[3])
{
	if(!pev_valid(ent1) || !pev_valid(ent2))
		return 0;

	static Float:origin1[3]
	pev(ent1,pev_origin,origin1)
	static Float:origin2[3]
	pev(ent2,pev_origin,origin2)

	new_velocity[0] = origin2[0] - origin1[0]
	new_velocity[1] = origin2[1] - origin1[1]
	new_velocity[2] = origin2[2] - origin1[2]
	new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
	new_velocity[0] *= num
	new_velocity[1] *= num
	new_velocity[2] *= num

	return 1;
}
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
1.) prepare a knockback: if one of the conditions is true stop it: flying, turbo, swoop, powerup etc
2.) Set the movetype to MOVETYPE_PLAYERTOSS ( 2 ) and pev->gravity = 1
3.) set the desired knockback vector pev->vuser4 = Normalized(vecDirection)*Speed;
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Haha, too much C++.
 
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
this ain't c++ this are just hint and tips where the data is if you seriously understood the language behind AMXX and the sample that you provided up there you should have no problem using my tip to get it working.
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
this ain't c++ this are just hint and tips where the data is if you seriously understood the language behind AMXX and the sample that you provided up there you should have no problem using my tip to get it working.
Nah, I just noticed your pev-> stuff, as that's how it's done in C++, not Pawn. I understood everything, not sure about tuty, though.

EDIT: May be lame to ask a non-related thing, but is it possible to add lightning sparks the way it's done in ESF Open Beta: Final? I mean, the way sparks follow the player.
 
Last edited:
Project Manager
🌠 Staff
✔️ HL Verified
💻 Oldtimer
Joined
Nov 25, 2001
Messages
1,729
Best answers
0
since amxx only works serverside you only got two options, one would be update the origin as fast as possible server-side but even with the think function it will look like it's "lagging" other option is to create an entity and attach it to the player but, this could have a sprite assigned or a model, but either way it won't really look that good.
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
Location
Lithuania
Thought so.

I wonder if aura model could be made with such sparks.
 

Users who are viewing this thread

Top Bottom