AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Push, or Attract (https://forums.alliedmods.net/showthread.php?t=108876)

meTaLiCroSS 11-10-2009 14:06

Push, or Attract
 
PHP Code:

// Attacker origin
static Float:flOrigin[3]
entity_get_vector(iAttackerEV_VEC_originflOrigin)

// Victim origin
static Float:flDirection[3]
entity_get_vector(iVictimEV_VEC_originflDirection)

// Subtract vector
xs_vec_sub(flDirectionflOriginflDirection)

// Normalize vector
xs_vec_normalize(flDirectionflDirection)

// Get victim's velocity
get_user_velocity(iVictimflVelocity)

// Multiply direction by Punch force
xs_vec_mul_scalar(flDirectionget_pcvar_float(cvar_punchforce), flDirection)

// Apply vector direction
xs_vec_add(flVelocityflDirectionflVelocity)

// Punch it!
set_user_velocity(iVictimflVelocity

If this code is used to "Push" an entity, as it would be to "Attract" an entity?

Arkshine 11-10-2009 14:15

Re: Push, or Attract
 
Scale flDirection after be normalized by -1.

meTaLiCroSS 11-10-2009 15:16

Re: Push, or Attract
 
PHP Code:

// Attacker origin
static Float:flOrigin[3]
entity_get_vector(iAttackerEV_VEC_originflOrigin)

// Victim origin
static Float:flDirection[3]
entity_get_vector(iVictimEV_VEC_originflDirection)

// Subtract vector
xs_vec_sub(flDirectionflOriginflDirection)

// Scale Direction by -1
xs_vec_mul_scalar(flDirection, -1.0flDirection)

// Normalize vector
xs_vec_normalize(flDirectionflDirection)

// Get victim's velocity
get_user_velocity(iVictimflVelocity)

// Multiply direction by Punch force
xs_vec_mul_scalar(flDirectionget_pcvar_float(cvar_punchforce), flDirection)

// Apply vector direction
xs_vec_add(flVelocityflDirectionflVelocity)

// Punch it!
set_user_velocity(iVictimflVelocity

This is correct?

Arkshine 11-10-2009 15:24

Re: Push, or Attract
 
Quote:

Originally Posted by Arkshine (Post 985969)
Scale flDirection after be normalized by -1.


meTaLiCroSS 11-10-2009 16:07

Re: Push, or Attract
 
Sorry >.<


All times are GMT -4. The time now is 13:39.

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