Raised This Month: $ Target: $400
 0% 

Air/Ground Speed Boost


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 01-05-2016 , 23:31   Air/Ground Speed Boost
Reply With Quote #1

I want to make a speed boost that works both ground and air.

I want it to first get the current speed of the player, and then add a X amount to it (to look like it gets "boosted").

I dont wanna use Velocity by Aim, because like the title says, this needs to work while in Air (for example in Surf)

Full example: If the player is going forward (but its not in the ground), with X current speed, when he shoots he gets +10 speed added to his current speed, whiout changing his direction, i mean, where he aims doesnt effect anything.

I have tryied some methods.
Right now this is what i have:

PHP Code:
public forward_PreThink(id)
{
    if(
pev(idpev_button) & IN_ATTACK)
    {    
        new 
Float:CurrentVelocity[3], Float:FinalVelocity[3]
        
pev(idpev_velocityCurrentVelocity)

        
FinalVelocity[2] = CurrentVelocity[2] + 10
        
        set_pev
(idpev_velocityFinalVelocity)
    }

And ofc it doesnt work correctly.

How can i fix it? Thank you.

Last edited by Syturi0; 01-05-2016 at 23:36.
Syturi0 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-06-2016 , 19:54   Re: Air/Ground Speed Boost
Reply With Quote #2

Use this to detect if is player surfing and set velocity :click here

Else if is not surfing then set maxspeed to player.
siriusmd99 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 01-07-2016 , 01:57   Re: Air/Ground Speed Boost
Reply With Quote #3

Quote:
Originally Posted by siriusmd99 View Post
Use this to detect if is player surfing and set velocity :click here

Else if is not surfing then set maxspeed to player.
How can i set velocity? Thats what i asked.
I have tried alot of methods, but none of them work the way i want.
Syturi0 is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 01-07-2016 , 03:13   Re: Air/Ground Speed Boost
Reply With Quote #4

For example, when i use
PHP Code:
set_pev(idpev_velocity2000.0
It boosts my speed ye, but it will always make my player/model go into a certain direction of the map, it doesnt go forward or anything according to where i was previosly going (its kinda hard to explain), it just always go to that direction of the map.

How can i fix that?

Last edited by Syturi0; 01-07-2016 at 03:14.
Syturi0 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-07-2016 , 03:55   Re: Air/Ground Speed Boost
Reply With Quote #5

Get user velocity, multiply it and then set it back, like this:

PHP Code:

new Float:origin[3];
     
pev(iUserpev_velocityorigin)
     
origin[0] *= // it's x
     
origin[1] *= //it's y
     
origin[2] *= //it's z
     
set_pev(iUser,pev_velocity,origin
But i don't understand exactly how it works. I made once like that and it pushed me down on surf, so in this case you shall multiply "x" by 4 ,and z with y by 2.
Just play with z,x,y and try to modify values until you get perfect surfing boost.

Last edited by siriusmd99; 01-07-2016 at 04:10.
siriusmd99 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-07-2016 , 04:14   Re: Air/Ground Speed Boost
Reply With Quote #6

It's rather easy, just some simple vector math.

If you want to increase velocity magnitude (speed) by a relative amount (a percentage) in the current direction, you can just multiply it by a scalar value, i.e (you have to include xs.inc):
PHP Code:
new FloatfVelocity[3];

pev(idpev_velocityfVelocity);
xs_vec_mul_scalar(fVelocity1.5fVelocity); // 50% speed boost
set_pev(idpev_velocityfVelocity); 
If you want to increase velocity magnitude by an absolute amount, you have to get a unit vector in the current direction, multiply it by your desired amount, and add it to the current velocity:
PHP Code:
new FloatfVelocity[3], FloatfDirection[3];
    
pev(idpev_velocityfVelocity);
xs_vec_normalize(fVelocityfDirection); // Get unit vector that has the same direction as velocity
xs_vec_mul_scalar(fDirection100.0fDirection); // Multiply it by 100, giving us a vector with magnitude of 100
xs_vec_add(fVelocityfDirectionfVelocity); // Add these 2 together
set_pev(idpev_velocityfVelocity); 
klippy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 01-07-2016 , 05:50   Re: Air/Ground Speed Boost
Reply With Quote #7

Quote:
Originally Posted by KliPPy View Post
It's rather easy, just some simple vector math.

If you want to increase velocity magnitude (speed) by a relative amount (a percentage) in the current direction, you can just multiply it by a scalar value, i.e (you have to include xs.inc):
PHP Code:
new FloatfVelocity[3];

pev(idpev_velocityfVelocity);
xs_vec_mul_scalar(fVelocity1.5fVelocity); // 50% speed boost
set_pev(idpev_velocityfVelocity); 
If you want to increase velocity magnitude by an absolute amount, you have to get a unit vector in the current direction, multiply it by your desired amount, and add it to the current velocity:
PHP Code:
new FloatfVelocity[3], FloatfDirection[3];
    
pev(idpev_velocityfVelocity);
xs_vec_normalize(fVelocityfDirection); // Get unit vector that has the same direction as velocity
xs_vec_mul_scalar(fDirection100.0fDirection); // Multiply it by 100, giving us a vector with magnitude of 100
xs_vec_add(fVelocityfDirectionfVelocity); // Add these 2 together
set_pev(idpev_velocityfVelocity); 
how to do it with xs.inc in this case its using origin
Code:
public shovePlayer(id) {     if(!is_user_alive(id))         return PLUGIN_HANDLED         if(get_systime() - gLastShove[id] < get_pcvar_num(cCooldown))     {         client_print(id, print_chat, "[Shove Mod] Your muscles are weak from shoving the player. You must wait to do it again. (%i)", (get_pcvar_num(cCooldown) - (get_systime() - gLastShove[id])))         return PLUGIN_HANDLED     }         new Index,Body, pName[64], tName[64]     get_user_aiming(id,Index,Body,200)         if(!Index || !is_user_alive(Index))         return PLUGIN_HANDLED         new Float:size[3]     pev(id, pev_size, size)     if(size[2] < 72.0)     {         client_print(id, print_chat, "[Shove Mod] You can't shove somebody while doing that action.")         return PLUGIN_HANDLED     }         get_user_name(id, pName, 63)     get_user_name(Index, tName, 63)     new Float:velocity[3], Float:shover[3], Float:shovee[3]     pev(id, pev_origin, shover)     pev(Index, pev_origin, shovee)         for(new Count;Count < 3;Count++)     velocity[Count] = (shovee[Count] - shover[Count]) * get_pcvar_float(cShove)     set_pev(Index, pev_velocity, velocity)     client_print(id, print_chat, "[Shove Mod] You have just shoved %s!", tName)     client_print(Index, print_chat, "[Shove Mod] You have just been shoved by %s!", pName)     gLastShove[id] = get_systime()     return PLUGIN_HANDLED     }

plugin from here : https://forums.alliedmods.net/showthread.php?t=61237
__________________

Last edited by JusTGo; 01-07-2016 at 05:50.
JusTGo is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-07-2016 , 05:56   Re: Air/Ground Speed Boost
Reply With Quote #8

There's no reason to use xs.inc if the current code works properly, XS most likely won't give you any performance boost. Just keep it as it is.
klippy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 01-07-2016 , 11:21   Re: Air/Ground Speed Boost
Reply With Quote #9

Quote:
Originally Posted by KliPPy View Post
There's no reason to use xs.inc if the current code works properly, XS most likely won't give you any performance boost. Just keep it as it is.
but there is a chance to get a negative value if the distance is 0 which cause velocity bug.
__________________
JusTGo is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 01-08-2016 , 01:27   Re: Air/Ground Speed Boost
Reply With Quote #10

Quote:
Originally Posted by KliPPy View Post
It's rather easy, just some simple vector math.

If you want to increase velocity magnitude (speed) by a relative amount (a percentage) in the current direction, you can just multiply it by a scalar value, i.e (you have to include xs.inc):
PHP Code:
new FloatfVelocity[3];

pev(idpev_velocityfVelocity);
xs_vec_mul_scalar(fVelocity1.5fVelocity); // 50% speed boost
set_pev(idpev_velocityfVelocity); 
If you want to increase velocity magnitude by an absolute amount, you have to get a unit vector in the current direction, multiply it by your desired amount, and add it to the current velocity:
PHP Code:
new FloatfVelocity[3], FloatfDirection[3];
    
pev(idpev_velocityfVelocity);
xs_vec_normalize(fVelocityfDirection); // Get unit vector that has the same direction as velocity
xs_vec_mul_scalar(fDirection100.0fDirection); // Multiply it by 100, giving us a vector with magnitude of 100
xs_vec_add(fVelocityfDirectionfVelocity); // Add these 2 together
set_pev(idpev_velocityfVelocity); 
Thank you, thats isactly what i wanted.

Syturi0 is offline
Reply


Thread Tools
Display Modes

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 09:27.


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