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

auto unstuck Optimize


Post New Thread Reply   
 
Thread Tools Display Modes
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-08-2012 , 12:52   Re: auto unstuck Optimize
Reply With Quote #11

how do I do that?
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-25-2012 , 08:53   Re: auto unstuck Optimize
Reply With Quote #12

Quote:
Originally Posted by SpeeDeeR View Post
@vamppa, it`s better to register the entity`s think rather then just the think forward.
is anyone willing to do this adjustment for us quickly?
this is for the AG/HLDM community, anything that I do on these forums is :-]
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-25-2012 , 12:48   Re: auto unstuck Optimize
Reply With Quote #13

optimized the code for AG/HLDM.
ive added the spectator check from the other thread, thx

only thing missing is this
Quote:
Originally Posted by Speed
@vamppa, it`s better to register the entity`s think rather then just the think forward.
PHP Code:
#include <amxmodx>
#include <fakemeta>

#define IsObserver(%1) pev(%1, pev_iuser1)

new UnstuckClassname[] = "UnstuckEnt"

new MaxPlayers
new cvar[3]

new const 
Float:size[][3] =
{
    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0}
}

public 
plugin_init()
{
    
register_plugin("Automatic Unstuck","1.5p","NL)Ramon(NL"//Patched by wbyokomo
    
cvar[0] = register_cvar("amx_autounstuck","1")
    
cvar[2] = register_cvar("amx_autounstuckdelay","1.0"//set 0.5 or 1.0 is enough, so less native called.
    
MaxPlayers get_maxplayers()
    new 
ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    
set_pev(ent,pev_classname,UnstuckClassname)
    
set_pev(ent,pev_nextthink,5.0)
    
    
register_forward(FM_Think,"ForwardThink")
}

public 
ForwardThink(ent)
{
    static 
Classname[33]
    
pev(ent,pev_classname,Classname,charsmax(Classname))
    
    if(!
equal(Classname,UnstuckClassname)) return FMRES_IGNORED;
    
    if(
get_pcvar_num(cvar[0])) checkstuck();
    
    
set_pev(ent,pev_nextthink,get_gametime()+get_pcvar_float(cvar[2]))
    
    return 
FMRES_IGNORED
}

checkstuck()
{
    new 
Float:origin[3], Float:mins[3], Float:vec[3], hulloplayer
    
for(player=1player<=MaxPlayersplayer++)
    {
        if(!
IsObserver(player))
        {
            
pev(playerpev_originorigin)
            
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
            
if(!is_hull_vacant(originhull,player) && !(pev(player,pev_solid) & SOLID_NOT))
            {
                
pev(playerpev_minsmins)
                
vec[2] = origin[2]
                for(
o=0sizeof size; ++o)
                {
                    
vec[0] = origin[0] - mins[0] * size[o][0]
                    
vec[1] = origin[1] - mins[1] * size[o][1]
                    
vec[2] = origin[2] - mins[2] * size[o][2]
                    if(
is_hull_vacant(vechull,player))
                    {
                        
engfunc(EngFunc_SetOriginplayervec)
                        
set_pev(player,pev_velocity,{0.0,0.0,0.0})
                        
sizeof size
                    
}
                }
            }
        }
    }
}

bool:is_hull_vacant(const Float:origin[3], hull,id)
{
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if(!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen))
        
return true
    
    
return false

vamppa is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-25-2012 , 13:14   Re: auto unstuck Optimize
Reply With Quote #14

No need to check classname, you can directly check it's id (stored as global variable).
__________________
<VeCo> is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-25-2012 , 13:43   Re: auto unstuck Optimize
Reply With Quote #15

damn so now two things can be improved, nice
how about this?
PHP Code:
#include <amxmodx> 
#include <fakemeta> 

#define IsObserver(%1) pev(%1, pev_iuser1) 

new cvar[3

new const 
Float:size[][3] = 

    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0}, 
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0}, 
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0}, 
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0}, 
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0


public 
plugin_init() 

    
register_plugin("Automatic Unstuck","1.5p","NL)Ramon(NL"//Patched by wbyokomo 
    
cvar[0] = register_cvar("amx_autounstuck","1"
    
cvar[2] = register_cvar("amx_autounstuckdelay","1.0"//set 0.5 or 1.0 is enough, so less native called. 
     
    
register_think("player""Thinkythinky"); 


public 
Thinkythinky(id
{   
    if(
get_pcvar_num(cvar[0])) checkstuck(); 
     
    
entity_set_float(idEV_FL_nextthinkget_gametime() +get_pcvar_float(cvar[2])) 
     
    return 
FMRES_IGNORED 


checkstuck() 

    new 
Float:origin[3], Float:mins[3], Float:vec[3], hulloplayer 
    
for(player=1player<=MaxPlayersplayer++) 
    { 
        if(!
IsObserver(player)) 
        { 
            
pev(playerpev_originorigin
            
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN 
            
if(!is_hull_vacant(originhull,player) && !(pev(player,pev_solid) & SOLID_NOT)) 
            { 
                
pev(playerpev_minsmins
                
vec[2] = origin[2
                for(
o=0sizeof size; ++o
                { 
                    
vec[0] = origin[0] - mins[0] * size[o][0
                    
vec[1] = origin[1] - mins[1] * size[o][1
                    
vec[2] = origin[2] - mins[2] * size[o][2
                    if(
is_hull_vacant(vechull,player)) 
                    { 
                        
engfunc(EngFunc_SetOriginplayervec
                        
set_pev(player,pev_velocity,{0.0,0.0,0.0}) 
                        
sizeof size 
                    

                } 
            } 
        } 
    } 


bool:is_hull_vacant(const Float:origin[3], hull,id

    static 
tr 
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr
    if(!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen)) 
        
return true 
     
    
return false 

vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-31-2012 , 15:06   Re: auto unstuck Optimize
Reply With Quote #16

cant get the last 2 things done.
vamppa is offline
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 07-01-2012 , 07:42   Re: auto unstuck Optimize
Reply With Quote #17

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

#define IsObserver(%1) pev(%1, pev_iuser1) 

new UnstuckClassname[] = "UnstuckEnt" 

new MaxPlayers 
new cvar[3

new const 
Float:size[][3] = 

    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0}, 
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0}, 
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0}, 
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0}, 
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0


public 
plugin_init() 

    
register_plugin("Automatic Unstuck","1.5p","NL)Ramon(NL"//Patched by wbyokomo 
    
cvar[0] = register_cvar("amx_autounstuck","1"
    
cvar[2] = register_cvar("amx_autounstuckdelay","1.0"//set 0.5 or 1.0 is enough, so less native called. 
    
MaxPlayers get_maxplayers() 
    new 
ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target")) 
    
set_pev(ent,pev_classname,UnstuckClassname
    
set_pev(ent,pev_nextthink,5.0
     
    
register_forward(FM_Think,"ForwardThink"


public 
ForwardThink(ent

    static 
Classname[33
    
pev(ent,pev_classname,Classname,charsmax(Classname)) 
     
    if(!
equal(Classname,UnstuckClassname)) return FMRES_IGNORED
     
    if(
get_pcvar_num(cvar[0])) checkstuck(); 
     
    
set_pev(ent,pev_nextthink,get_gametime()+get_pcvar_float(cvar[2])) 
     
    return 
FMRES_IGNORED 


checkstuck() 

    new 
Float:origin[3], Float:mins[3], Float:vec[3], hulloplayer 
    
for(player=1player<=MaxPlayersplayer++) 
    { 
        if(!
IsObserver(player)) 
        { 
            
pev(playerpev_originorigin
            
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN 
            
if(!is_hull_vacant(originhull,player) && !(pev(player,pev_solid) & SOLID_NOT)) 
            { 
                
pev(playerpev_minsmins
                
vec[2] = origin[2
                for(
o=0sizeof size; ++o
                { 
                    
vec[0] = origin[0] - mins[0] * size[o][0
                    
vec[1] = origin[1] - mins[1] * size[o][1
                    
vec[2] = origin[2] - mins[2] * size[o][2
                    if(
is_hull_vacant(vechull,player)) 
                    { 
                        
engfunc(EngFunc_SetOriginplayervec
                        
set_pev(player,pev_velocity,{0.0,0.0,0.0}) 
                        
sizeof size 
                    

                } 
            } 
        } 
    } 


bool:is_hull_vacant(const Float:origin[3], hull,id

    static 
tr 
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr
    if(!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen)) 
        
return true 
     
    
return false 

is anyone able to do the unstuck function with engine? (instead of fakemeta)
vamppa 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 20:01.


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