Raised This Month: $51 Target: $400
 12% 

Solved Knockback Wrong Calculation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-25-2020 , 17:51   Knockback Wrong Calculation
Reply With Quote #1

Hey, i try to make the zombie bomb from cso based on player's velocity and user's fistance from the explosion but the knockback power to be 100.0 + player's velocity based on the distance of the player from the bomb, longer distance = less knockback.

But.. didn't work as expected, i know it 100% is wrong but yeah.

PHP Code:
fl_Velocity[0] = (speed VicVelocity[0]) * ((EntOrigin[0] - VicOrigin[0]) / fl_Time)
fl_Velocity[1] = (speed VicVelocity[1]) * ((EntOrigin[1] - VicOrigin[1]) / fl_Time)
fl_Velocity[2] = (speed VicVelocity[2]) * ((EntOrigin[2] - VicOrigin[2]) / fl_Time)

fl_Time get_distance_f(EntOriginVicOrigin) / speed 
Edit: nevermind, i got it working the way i wanted eliminating the VicVelocity but
I put the speed as first thing multiplied by entorigin - vicorigin * fl_Time everything / 2

Last edited by AnimalMonster; 12-25-2020 at 18:22.
AnimalMonster is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-25-2020 , 19:27   Re: Knockback Wrong Calculation
Reply With Quote #2

this is kind bad calculations show what is fl_Time is equal to... or atleast the calculation function.

i'm certain there's a better way to achieve such thing.


Edit : Try this :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>

#define VERSION "1.0"
#define AUTHOR "Natsheh"


player_explosion_knockback(victimFloat:fExpOrigin[3], Float:fExpShockwaveRadius=500.0Float:fExpShockwavePower=500.0)
{
    new 
Float:fOrigin[3], Float:fDistVec[3];
    
pev(victimpev_originfOrigin);
    
    
xs_vec_sub(fExpOriginfOriginfDistVec);
    
    new 
Float:g_fTemp;
    
// victim is in the range of the shockwave explosion!
    
if((g_fTemp=xs_vec_len(fDistVec)) <= fExpShockwaveRadius)
    {
        new 
Float:fPower fExpShockwavePower * ( 1.0 - ( g_fTemp floatmin(fExpShockwaveRadius1.0) ) ), Float:fVelo[3], Float:fKnockBackVelo[3];
        
        
pev(victimpev_velocityfVelo);
        
xs_vec_normalize(fDistVecfKnockBackVelo);
        
xs_vec_mul_scalar(fKnockBackVelofPowerfKnockBackVelo);
        
xs_vec_add(fVelofKnockBackVelofVelo);
        
set_pev(victimpev_velocityfVelo);
    }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-26-2020 at 08:24.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-26-2020 , 08:05   Re: Knockback Wrong Calculation
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
this is kind bad calculations show what is fl_Time is equal to... or atleast the calculation function.

i'm certain there's a better way to achieve such thing.


Edit : Try this :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>

#define VERSION "1.0"
#define AUTHOR "Natsheh"


player_explosion_knockback(victimFloat:fExpOrigin[3], Float:fExpShockwaveRadius=500.0Float:fExpShockwavePower=500.0)
{
    new 
Float:fOrigin[3], Float:fDistVec[3];
    
pev(victimpev_originfOrigin);
    
    
xs_vec_sub(fExpOriginfOriginfDistVec);
    
    new 
Float:g_fTemp;
    
// victim is in the range of the shockwave explosion!
    
if((g_fTemp=xs_vec_len(fDistVec)) <= fExpShockwaveRadius)
    {
        new 
Float:fPower fExpShockwavePower * ( 1.0 - ( g_fTemp floatmin(fExpShockwaveRadius) ) ), Float:fVelo[3], Float:fKnockBackVelo[3];
        
        
pev(victimpev_velocityfVelo);
        
xs_vec_normalize(fDistVecfKnockBackVelo);
        
xs_vec_mul_scalar(fKnockBackVelofPowerfKnockBackVelo);
        
xs_vec_add(fVelofKnockBackVelofVelo);
        
set_pev(victimpev_velocityfVelo);
    }

Never mind i got more problems so i decided to use x = ((distance/max)-1.0)*(-1.0) but also didn t work great. the velocity would have been equal to speed * x.
I tried to get a invers-proportional value from 0 to 1.0 that based on the distance of the player on bomb, did work but not as expected since only on 0 would kick you great.
fl_Time was equal to get_distance_f(EntOrigin, VicOrigin) / speed.

So, what was the problem in my calculation? I think it is perfect rn and works great, i will also try yours because it may be better but the thing is, it's kinda hilarious that i could do that thing without these xs natives.

Edit: yours didn't work at all...

Last edited by AnimalMonster; 12-26-2020 at 10:43.
AnimalMonster is offline
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 20:24.


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