Raised This Month: $ Target: $400
 0% 

Force Push


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 04-27-2007 , 10:56   Force Push
Reply With Quote #1

I am trying to make a push that will shove everyone away from you, but what is a good way to determine which direction is "away" from someone?
this is what I was doing:
Code:
if(is_user_alive(id)) return;         new players = get_playersnum(0);     new t_origin[3], t_aim_origin[3], p_origin[3];         get_user_origin(id, p_origin);         for(new i = 0; i < players; i++) {         get_user_origin(i, t_origin);                 if(get_distance(p_origin, t_origin) <= get_cvar_num("distance_to")) {             new Float:t_velocity[3];             //here I need to get the direction to make             //them get pushed and store in t_velocity,             //then entity set vec to move them.             //how to get direction though?             entity_set_vector(i, EV_VEC_velocity, t_velocity);
__________________
DO NOT PM me about avp mod.

Last edited by Rolnaaba; 04-27-2007 at 10:58.
Rolnaaba is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-27-2007 , 11:34   Re: Force Push
Reply With Quote #2

There is a hero (sh_blop from AssKicR) for the superHero MOD with which you can push people outher your way...
Maybe this helps you!?

here you go:
sh_blob.sma


greetz regalis
__________________
regalis is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 04-28-2007 , 00:40   Re: Force Push
Reply With Quote #3

I would give this a shot:

Code:
new Float:t_velocity[3] t_velocity[0] = (opponent_origin[0] - player_origin[0]) * constant t_velocity[1] = (opponent_origin[1] - player_origin[1]) * constant t_velocity[2] = (opponent_origin[2] - player_origin[2]) * constant
stupok is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 04-30-2007 , 08:21   Re: Force Push
Reply With Quote #4

I will look into it thanks, when I get internet I will test it.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 05-11-2007 , 11:16   Re: Force Push
Reply With Quote #5

sry for bump but how about this:
Code:
    new players = get_playersnum(0);     new t_origin[3], t_aim_origin[3], p_origin[3];         get_user_origin(id, p_origin);         for(new i = 0; i < players; i++) {         get_user_origin(i, t_origin);                 if(get_distance(p_origin, t_origin) <= get_cvar_num("distance_to")) {             new Float:t_velocity[3];             new Float:p_origin_f[3];             new Float:t_origin_f[3];                         pev(i, pev_origin, t_origin_f);             pev(id, pev_origin, p_origin_f);                         t_velocity[0] = (t_origin_f[0] - p_origin_f[0]) * get_cvar_float("knuck_force");             t_velocity[1] = (t_origin_f[1] - p_origin_f[1]) * get_cvar_float("knuck_force");             t_velocity[2] = (t_origin_f[2] - p_origin_f[2]) * get_cvar_float("knuck_force");                         set_pev(i, pev_velocity, t_velocity);         }     }
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 05-11-2007 , 15:34   Re: Force Push
Reply With Quote #6

not good.

get_playersnum() returns the number of players but you have no indication that the player index starts from 0 and ends with that number-1.
Also there is no indication of WHEN that piece of code is executed.

I think you should hook FM_Touch for this.
_Master_ is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 05-12-2007 , 17:42   Re: Force Push
Reply With Quote #7

Mh... something is not good at your code.
Because your code will:
- Push people less harder the closer they are to you.
- Push them antiproportional, so no matter what the distance is
you are handling a distance of for example (2*100²)^0.5 with twice
the power you use for a distance of 100, although (2*100²)^0.5=141.421.
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 05-12-2007 at 17:57.
Silencer123 is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 05-13-2007 , 03:56   Re: Force Push
Reply With Quote #8

For use in FM_Touch:
PHP Code:
new Float:pos_ptr[3], Float:pos_ptd[3], Float:push_power get_cvar_float("knuck_force")

pev(ptrpev_originpos_ptr)
pev(ptdpev_originpos_ptd)

for(new 
02i++){
    
    
pos_ptd[i] -= pos_ptr[i]
    
pos_ptd[i] *= push_power
}

set_pev(ptdpev_velocitypos_ptd
For use in whatever:
PHP Code:
new Floatpos_idFloatpos_iFloatdistance_fFloat:push_power get_cvar_float("knuck_force")
new 
Floatdist
new players[32], numi

get_players
(playersnum"a")
pev(idpev_originpos_id)
dist get_cvar_float("distance_to")

for(new 
0numa++){
    
    
players[a]
    
pev(ipev_originpos_i)
    
    
distance_f get_distance_f(pos_idpos_i)
    if(
distance_f <= dist){
        
        for(new 
02i++){
            
            
pos_i[a] -= pos_id[a]
            
pos_i[a] *= push_power
        
}
        
        
set_pev(ipev_velocitypos_i)
    }

_Master_ is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 05-14-2007 , 08:16   Re: Force Push
Reply With Quote #9

Quote:
Originally Posted by _Master_ View Post
For use in FM_Touch:
PHP Code:
new Float:pos_ptr[3], Float:pos_ptd[3], Float:push_power get_cvar_float("knuck_force")
 
pev(ptrpev_originpos_ptr)
pev(ptdpev_originpos_ptd)
 
for(new 
02i++){
 
    
pos_ptd[i] -= pos_ptr[i]
    
pos_ptd[i] *= push_power
}
 
set_pev(ptdpev_velocitypos_ptd
omg stop talking your telling me things I already know.

Quote:
Originally Posted by _Master_ View Post
not good.

get_playersnum() returns the number of players but you have no indication that the player index starts from 0 and ends with that number-1.
Also there is no indication of WHEN that piece of code is executed.

I think you should hook FM_Touch for this.
Duh, its in FM_Touch I am not an idiot.

Quote:
Originally Posted by Silencer123 View Post
Mh... something is not good at your code.
Because your code will:
- Push people less harder the closer they are to you.
- Push them antiproportional, so no matter what the distance is
you are handling a distance of for example (2*100²)^0.5 with twice
the power you use for a distance of 100, although (2*100²)^0.5=141.421.
What do you suggest?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 05-14-2007 , 11:13   Re: Force Push
Reply With Quote #10

If yor code is in FM_Touch then it's not an issue as FM_Touch will be called when the players actually "touch" each-other. The distance between them is irrelevant in this case and will always be constant.

BTW I didn't say you're an idiot, I've just failed to undestand your code and where it should be placed. And if you already knew this then what's the point of this thread ?!?
_Master_ 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 06:35.


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