AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Force Push (https://forums.alliedmods.net/showthread.php?t=54485)

Rolnaaba 04-27-2007 10:56

Force Push
 
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);

regalis 04-27-2007 11:34

Re: Force Push
 
1 Attachment(s)
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:
Attachment 15737


greetz regalis

stupok 04-28-2007 00:40

Re: Force Push
 
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

Rolnaaba 04-30-2007 08:21

Re: Force Push
 
I will look into it thanks, when I get internet I will test it.

Rolnaaba 05-11-2007 11:16

Re: Force Push
 
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);         }     }

_Master_ 05-11-2007 15:34

Re: Force Push
 
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.

Silencer123 05-12-2007 17:42

Re: Force Push
 
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.

_Master_ 05-13-2007 03:56

Re: Force Push
 
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)
    }



Rolnaaba 05-14-2007 08:16

Re: Force Push
 
Quote:

Originally Posted by _Master_ (Post 476094)
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_ (Post 475667)
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 (Post 475970)
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?

_Master_ 05-14-2007 11:13

Re: Force Push
 
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 ?!?


All times are GMT -4. The time now is 06:35.

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