AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Detect Walls In A Radius (https://forums.alliedmods.net/showthread.php?t=320574)

hellmonja 12-28-2019 14:44

[HELP] Detect Walls In A Radius
 
Okay, this is something I've been trying to do for a long time and still don't even know where to begin. I've been trying to fix Arkshine's Prone Position plugin, where the player's vision can go outside the walls if you crawl up to one and potentially do wallhacks. I think it has something to do with using "usehull" though I'm not sure.

The idea I have is simple: While on prone, the plugin will detect if any walls are nearby within a radius, record which direction the wall/s are from and push the player back away from it. Right, I don't know where to even begin.

I was studying TraceHull but it doesn't seem to have a radius that you could set. The prone plugin seems to make player clipping much smaller so it has to detect the wall a bit of distance away from the player.

Another idea I had is to just detect if the player was outside the map and would just fade his screen black until said player comes back inside, as posted here (https://forums.alliedmods.net/showthread.php?t=185682). But again, it doesn't work. Probably because burying your head in walls while in prone doesn't count as being outside since the clipping becomes small...

georgik57 12-29-2019 18:38

Re: [HELP] Detect Walls In A Radius
 
What you said works both when crouching and standing and if I'm not mistaking only on oblique walls.
A sideways TraceLine should do the trick.
Anyway, I would recommend using WhBlocker instead.

Natsheh 12-30-2019 01:15

Re: [HELP] Detect Walls In A Radius
 
My advice is don't use bad maps.

Or you can use wall guard plugin to block players from getting there.

hellmonja 01-29-2020 09:04

Re: [HELP] Detect Walls In A Radius
 
Hi guys. Sorry but both didn't work. I've installed WhBlocker properly. I know that for a fact since producing error-free logs. And I've tried some anti-wallhack plugins that I could find. The problem I think is the prone_position plugin makes your hull very small and as long as that part doesn't go thru the wall it doesn't count as a wallhack.

I tried studying TraceLine and came up with a test plugin. It works but I think it could be a lot better. So just a refresher, I'm trying to make the player keep a certain distance (50 units) away from walls. In the test plugin I fire a TraceLine that's 50 units long towards the direction they're going and when the line gets a hit any movement towards that object is halted. This is what I got:
PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define TRACE_DIST         50.0 // Fixed distace of trace
#define TRACE_HEIGHT         25.0 // To avoid blocking movement when going up slopes
#define PUSH_DIST         -0.1 // Strength of push when player goes near a wall

new beampoint;
new 
bool:g_push_enabled;
new 
Float:g_origin[33][3];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_PlayerPreThink,"FM_PreThink"false);
    
register_forward(FM_PlayerPreThink,"FM_PostThink"true);
    
    
register_concmd("debug""Debug");
}

public 
plugin_precache()
{
    
beampoint precache_model("sprites/laserbeam.spr")
}

// Toggle command to enable/disable plugin
public Debug(user)
{
    if(!
g_push_enabled)
        
g_push_enabled true;
    else
        
g_push_enabled false;
}

public 
FM_PreThink(user)
{
    if(!
g_push_enabled)
        return 
FMRES_IGNORED
    
    pev
(userpev_origing_origin[user]);
    
    return 
FMRES_HANDLED
}

public 
FM_PostThink(user)
{
    if(!
g_push_enabled)
        return 
FMRES_IGNORED
    
    
static Float:origin2[3];
    static 
Float:velocity[3];
    static 
Float:velocity2[3];
    static 
Float:fraction
    
static tracetrace 0;
        
    
pev(userpev_velocityvelocity);
        
    
origin2[0] = g_origin[user][0];
    
origin2[1] = g_origin[user][1];
    
origin2[2] = g_origin[user][2] + TRACE_HEIGHT;
    
    
velocity2[0] = velocity[0];
    
velocity2[1] = velocity[1];
    
velocity2[2] = velocity[2];
    
    
// This part I don't know what I'm doing.
    // Supposedly I want to fire a TraceLine that's 50 units long
    // directly towards the diretion the player is moving
    
if(velocity[0] != 0.0)
    {
        if(
velocity[0] < 0.0origin2[0] -= TRACE_DIST;
        else 
origin2[0] += TRACE_DIST;
        
        
velocity2[0] = velocity[0] * PUSH_DIST;
    }
    
    if(
velocity[1] != 0.0)
    {
        if(
velocity[1] < 0.0origin2[1] -= TRACE_DIST;
        else 
origin2[1] += TRACE_DIST;
        
        
velocity2[1] = velocity[1] * PUSH_DIST;
    }

    
engfunc(EngFunc_TraceLineg_origin[user], origin2IGNORE_MONSTERS0trace);
    
get_tr2(traceTR_flFractionfraction)

//    draw_laser(g_origin[user], origin2, 1);                // Laser effect to visually see the trace
    
    
if(fraction 1.0)
    {
//        set_pev(user, pev_maxspeed, 1.0);            // Sets player speed
//        engfunc(EngFunc_SetOrigin, user, g_origin[user]);    // Teleports player back to old origin
        
set_pev(userpev_velocityvelocity2);            // Pushes player back opposite the direction they're going
        
        // Cheap way of blocking movement
        
client_cmd(user"-forward");
        
client_cmd(user"-back");
        
client_cmd(user"-left");
        
client_cmd(user"-right");
    }
    
    return 
FMRES_HANDLED
}

public 
draw_laser(Float:start[3], Float:end[3], staytime)
{                    
    
message_begin(MSG_ALLSVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)
    
engfunc(EngFunc_WriteCoordstart[0])
    
engfunc(EngFunc_WriteCoordstart[1])
    
engfunc(EngFunc_WriteCoordstart[2])
    
engfunc(EngFunc_WriteCoordend[0])
    
engfunc(EngFunc_WriteCoordend[1])
    
engfunc(EngFunc_WriteCoordend[2])
    
write_short(beampoint)
    
write_byte(0)
    
write_byte(0)
    
write_byte(staytime// In tenths of a second.
    
write_byte(10)
    
write_byte(1)
    
write_byte(0// Red
    
write_byte(255// Green
    
write_byte(0// Blue
    
write_byte(127)
    
write_byte(1)
    
message_end()


It works but there are issues I'm having with this:
1. The trace is not directly towards where the player is moving.
2. My method of blocking movement is kinda cheap. Also counter-intuitive since you have to re-press the movement keys to get them to work again. The other two I tried (teleporting and setting player speed) doesn't block movement completely. The player can still slowly get near the wall...


All times are GMT -4. The time now is 02:41.

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