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

Solved [HELP] Moving Players for Dodge Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-02-2018 , 11:24   [HELP] Moving Players for Dodge Plugin
Reply With Quote #1

I'm trying to do a Dodge Plugin where if you double-tap either left or right the player 'skips' or side-steps a short distance.

I've done the double-tap part but I don't know how to move the player. I'm not very knowledgeable in vectors and coordinates or using the xs module so I also hope of learning a thing or 2...
__________________

Last edited by hellmonja; 09-02-2018 at 13:05. Reason: Solved...
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-02-2018 , 12:01   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #2

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

public plugin_init()
{
    
register_clcmd("dodge""ClientCommand_Dodge")
}

public 
ClientCommand_Dodge(id)
{
    new 
Float:PlayerAngles[3], Float:PlayerVelocity[3]
    
pev(idpev_anglesPlayerAngles)
    
angle_vector(PlayerAnglesANGLEVECTOR_RIGHTPlayerVelocity)
    
xs_vec_mul_scalar(PlayerVelocity800.0PlayerVelocity)
    
set_pev(idpev_velocityPlayerVelocity)

Example with always going to the right.
__________________

Last edited by HamletEagle; 09-02-2018 at 12:01.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-02-2018 , 12:08   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
[php]
OMG, it worked like magic! May I ask how this works exactly? A lot of these codes I don't know what they do like "xs_vec_mul_scalar"...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-02-2018 , 12:11   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #4

I forgot to say, in order to move left you need to multiply the vector by -1.0(xs_vec_mul_scalar).
It's not hard, just look in xs.inc
PHP Code:
    XS_LIBFUNC_ATTRIB xs_vec_mul_scalar(const Float:vec[], Float:scalarFloat:out[])
    {
        
out[0] = vec[0] * scalar;
        
out[1] = vec[1] * scalar;
        
out[2] = vec[2] * scalar;
    } 
It simply multiples each component of the array(vector) by a given value.
__________________

Last edited by HamletEagle; 09-02-2018 at 12:11.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-02-2018 , 12:18   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #5

Okay so...

PHP Code:
 pev(idpev_anglesPlayerAngles
This records the players current angles?

PHP Code:
angle_vector(PlayerAnglesANGLEVECTOR_RIGHTPlayerVelocity
Tells plugin which direction is right based on player's angle? Also I noticed there is no ANGLEVECTOR_LEFT. I just replaced '800.0' with '-800.0' and it worked. Like you said, multiply by -1. =)

PHP Code:
set_pev(idpev_velocityPlayerVelocity
So this one does the actual moving...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-02-2018 , 12:33   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #6

I suggest you to read this 2 topics, should answer all your questions.
https://forums.alliedmods.net/showthread.php?t=91474
https://forums.alliedmods.net/showthread.php?t=262138

About velocity: to move you need a direction and a speed. velocity is a vector quantity that gives you both the direction and the speed.

PHP Code:
xs_vec_mul_scalar(PlayerVelocity800.0PlayerVelocity
This controls the speed at which we are moving, it doesn't change the direction. As I said, to change direction you need to multiply by -1(so from right to left).
If you want to go faster use a scalar bigger than 800, to mover slower use a lower value(obviously).

Yes, setting pev_velocity moves the player, because you are telling the game where you want to move and how fast.
__________________

Last edited by HamletEagle; 09-02-2018 at 12:35.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 09-02-2018 , 12:38   Re: [HELP] Moving Players for Dodge Plugin
Reply With Quote #7

Thank you, sensei, as well as for the links. I will read them to finally learn about vectors.
The dodge mechanic is working perfectly now. I just had to reduce 800.0 to 300.0.
Once again, my deepest gratitude...
__________________
hellmonja 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 07:33.


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