AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] WalkGuard Block Bombsites (https://forums.alliedmods.net/showthread.php?t=297803)

LegacyCode 05-24-2017 06:33

[Help] WalkGuard Block Bombsites
 
Hello,

so, I made this: https://forums.alliedmods.net/showpo...&postcount=172
But I'm 99.9% certain that my edit is far from being good, so I would like to ask for help here :bee:
I know I'm still making dumb mistakes, please bear with me.

One player reported a "CL_Flush Entity Packet" error but I'm not sure if it's related to the edit I made.

Edited lines:

Global scope
PHP Code:

#define MIN_CTS_BOMBSITE 7
#define HUD_BOMBSITE_DURATION 4.0
#define TASK_SHOW_BLOCK 3000
new bool:g_BlockBombsite,
    
bool:g_HasBombsiteBlock,
    
g_CountCTsg_HudBombsiteBlocked,
    
g_BlockBombsiteStr[2

PHP Code:

public plugin_precache() {
    [...]
    
g_HudBombsiteBlocked CreateHudSyncObj()


Modified DrawLine
PHP Code:

public draw_block_line(Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2color[3]) {
    new 
start[3]
    new 
stop[3]

    
start[0] = floatroundx1 )
    
start[1] = floatroundy1 )
    
start[2] = floatroundz1 )

    
stop[0] = floatroundx2 )
    
stop[1] = floatroundy2 )
    
stop[2] = floatroundz2 )

    
message_beginMSG_BROADCASTSVC_TEMPENTITY )

    
write_byteTE_BEAMPOINTS )

    
write_coord(start[0])
    
write_coord(start[1])
    
write_coord(start[2])

    
write_coord(stop[0])
    
write_coord(stop[1])
    
write_coord(stop[2])

    
write_shortspr_dot )

    
write_byte)    // framestart
    
write_byte)    // framerate
    
write_byte)    // life in 0.1's
    
write_byte25 )    // width
    
write_byte)     // noise

    
write_bytecolor[0] )   // r, g, b
    
write_bytecolor[1] )   // r, g, b
    
write_bytecolor[2] )   // r, g, b

    
write_byte200 )      // brightness
    
write_byte)       // speed

    
message_end()


Modified ShowZoneBox to work without editor (show to all players)
PHP Code:

public show_zone_cross(entity)
{
    
entity -= TASK_SHOW_BLOCK
    
if (!pev_valid(entity)) return

    new 
Float:pos[3]
    
pev(entitypev_originpos)

    new 
Float:mins[3], Float:maxs[3]
    
pev(entitypev_minsmins)
    
pev(entitypev_maxsmaxs)

    
mins[0] += pos[0]
    
mins[1] += pos[1]
    
mins[2] += pos[2]
    
maxs[0] += pos[0]
    
maxs[1] += pos[1]
    
maxs[2] += pos[2]

    
// x
    
draw_block_line(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_red)
    
draw_block_line(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
    
draw_block_line(mins[0], maxs[1], maxs[2], mins[0], mins[1], mins[2], zone_color_red)
    
draw_block_line(mins[0], maxs[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
    
// y
    
draw_block_line(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
    
draw_block_line(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
    
draw_block_line(mins[0], maxs[1], mins[2], maxs[0], maxs[1], maxs[2], zone_color_red)
    
draw_block_line(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_red)
    
// z
    
draw_block_line(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_red)
    
draw_block_line(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_red)
    
draw_block_line(maxs[0], maxs[1], mins[2], mins[0], mins[1], mins[2], zone_color_red)
    
draw_block_line(maxs[0], mins[1], mins[2], mins[0], maxs[1], mins[2], zone_color_red)


Execute on each Event_RoundStart()
PHP Code:

check_bombsite_availability()
{
    new 
n_Playersa_Players[32]
    
get_playersa_Playersn_Players )

    
// reset
    
g_CountCTs 0
    g_HasBombsiteBlock 
false

    
for ( new in_Playersi++ )
    {
        if ( 
cs_get_user_team(a_Players[i]) == CS_TEAM_CT )
            
g_CountCTs++
    }

    
g_BlockBombsite = !(g_CountCTs >= MIN_CTS_BOMBSITE)

    for ( new 
imaxzonesi++ )
    {
        new 
zone[i]
        new 
zm pev(zZONEID)

        if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B )
        {
            
g_HasBombsiteBlock true

            
if ( g_BlockBombsite )
            {
                
set_pevzpev_solidSOLID_BBOX )

                
remove_taskTASK_SHOW_BLOCK )
                
set_task0.2"show_zone_cross"TASK_SHOW_BLOCK z__"b" )

                if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A )
                    
formatexg_BlockBombsiteStrcharsmax(g_BlockBombsiteStr), "A" )
                else
                    
formatexg_BlockBombsiteStrcharsmax(g_BlockBombsiteStr), "B" )
            }
            else
            {
                
set_pevzpev_solidSOLID_NOT )

                if ( 
task_existsTASK_SHOW_BLOCK ) )
                    
remove_taskTASK_SHOW_BLOCK )
            }
        }
    }

    if ( 
g_BlockBombsite && n_Players && g_HasBombsiteBlock )
    {
        for ( new 
in_Playersi++ )
        {
            if ( !
is_user_connected(a_Players[i]) ) continue

            if ( 
is_user_alive(a_Players[i]) )
            {
                
set_hudmessage25500, -1.00.203.0HUD_BOMBSITE_DURATION0.51.0, -)
                
ShowSyncHudMsga_Players[i], g_HudBombsiteBlocked"%L"a_Players[i], "WALKGUARD_BLOCK_BOMBSITE_HUD"MIN_CTS_BOMBSITEg_BlockBombsiteStr )
            }
        }

        return
    }

    return


PHP Code:

public Event_RoundStart() {
    [...]
    
check_bombsite_availability()


PHP Code:

public ZoneTouch(playerzone) {
    [...]

    if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B )
    {
        if ( 
g_BlockBombsite )
        {
            
client_printplayerprint_center"%L"player"WALKGUARD_BLOCK_BOMBSITE_PRINT"g_BlockBombsiteStrMIN_CTS_BOMBSITE )
        }
    }

    [...]


I hope you guys can help make this code great again.
A message that only shows once after all bombsites are enabled again would be cool too, and I already had it working, but then I got lost again and ended up deleting it...

- LegacyCode

LegacyCode 05-25-2017 06:59

Re: [Help] WalkGuard Block Bombsites
 
Hello,

so I've just encountered a "Reliable channel overflowed" when touching a block like this.
This only happened for the first time on a map where I have like 8+ of these blocks.
What could it be?

//e:
I can only think of "client_print()" in "ZoneTouch()"... but I guess some expert can enlighten me here. Will test without client_print().

//e2:
I set sv_gravity to 200 and spam-touched (jump + duck) the block. This also happens with only one of these blocks, but only with client_print() and sv_gravity not being 800. Does anyone know how to solve this?
Only allow printing the message once every x seconds for a player?

//e3:
This whole stuff lags the server like hell, I suppose because it shows the crosses the whole time. I really need your help :(

- LegacyCode

JusTGo 05-25-2017 08:17

Re: [Help] WalkGuard Block Bombsites
 
your are sending to many messages, if you remove the show crosses and client_print you will not get more over flows

LegacyCode 05-25-2017 08:24

Re: [Help] WalkGuard Block Bombsites
 
Hello,

yeah, that's what I thought. But I need an indicator for a blocked zone, preferably that red cross.
Any ideas how I can accomplish this without a massive performance hit?

Also it should draw that red cross on all sites of the block, because someone could block a zone on the ground, etc.
I would like to avoid any custom stuff like textures/sprites, too.

- LegacyCode

JusTGo 05-25-2017 08:28

Re: [Help] WalkGuard Block Bombsites
 
you have to spawn an entity give it a model (wall model or any thing that you want). then remove it when not needed that way you don't need to keep sending the show cross each 0.2 sec

LegacyCode 05-25-2017 10:40

Re: [Help] WalkGuard Block Bombsites
 
Hello,

what I did for now:

- increasing the task time to 1.0 (instead of 0.2)
- only show one side of the block (x/y) by comparing the size with pev_size
(- always show top z)
- set a task when player touches a bombsite block, to only show the message every 5 seconds

This should at least decrease the performance hit a bit for now, as it only draws a max of 4 lines at once for a box instead of 12.

PHP Code:

public show_zone_cross(entity)
{
    
entity -= TASK_SHOW_BLOCK
    
if (!pev_valid(entity)) return

    new 
Float:pos[3]
    
pev(entitypev_originpos)

    new 
Float:size[3], Float:mins[3], Float:maxs[3]
    
pev(entitypev_sizesize)
    
pev(entitypev_minsmins)
    
pev(entitypev_maxsmaxs)

    
mins[0] += pos[0]
    
mins[1] += pos[1]
    
mins[2] += pos[2]
    
maxs[0] += pos[0]
    
maxs[1] += pos[1]
    
maxs[2] += pos[2]

    if ( 
size[0] < size[1] )
    {
        
// x
        
draw_block_line(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_red)
        
draw_block_line(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
    }
    else if ( 
size[0] > size[1] )
    {
        
// y
        
draw_block_line(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
        
draw_block_line(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
    }

    
// z
    
draw_block_line(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_red)
    
draw_block_line(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_red)


Quote:

Originally Posted by JusTGo (Post 2523330)
you have to spawn an entity give it a model (wall model or any thing that you want). then remove it when not needed that way you don't need to keep sending the show cross each 0.2 sec

I want to avoid any custom models clients would have to download...

- LegacyCode

JusTGo 05-25-2017 11:10

Re: [Help] WalkGuard Block Bombsites
 
one model/sprite is not much

LegacyCode 05-25-2017 11:16

Re: [Help] WalkGuard Block Bombsites
 
Quote:

Originally Posted by JusTGo (Post 2523383)
one model/sprite is not much

Still, I myself used to have cl_allowdownload 0 and I'm only editing the already existing WalkGuard plugin here, which also doesn't require any downloads.

- LegacyCode

LegacyCode 05-25-2017 13:09

Re: [Help] WalkGuard Block Bombsites
 
Hello,

The lines now only show to the specific player (not like before via MSG_BROADCAST).
I'm now trying to apply a basic grid of points to the side where it shows the cross:

http://i.imgur.com/CoJW1P5.png

PHP Code:

                // y
                
draw_block_line(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], {0,230,0}, p_userid)
                
draw_block_line(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], {0,230,0}, p_userid)

                for ( new 
i_coli_col maxcolsi_col++ )
                    for ( new 
i_rowi_row maxrowsi_row++ )
                        
draw_block_line(
                            
grid_x+(m[0]*i_col), grid_ygrid_z+(m[2]*i_row),
                            
grid_x+(m[0]*i_col)+1grid_y+1grid_z+(m[2]*i_row)+1,
                            {
255,255,255},
                            
p_userid
                        


I saw a "fm_trace_line()" function which I would use to check if any of those points are visible for the player.
If not, it doesn't draw the cross. Is this a "good" solution, or am I overthinking this? There must be a better way to deal with this...

//e:
Current status:
http://i.imgur.com/GZgNXeO.jpg

I currently use
PHP Code:

#define BLOCK_VISIBILITY_ACCURACY 11

// the check
fm_is_visible(p_useridpoint_pos) && fm_is_in_viewcone(p_useridpoint_pos

to define 11 points per col/row to check in combination with fm_is_visible & fm_is_in_viewcone.
Everything works now. Will test and optimize this a little further, hoping someone stumbles across this thread with better knowledge. :bee:

- LegacyCode

JusTGo 05-25-2017 17:42

Re: [Help] WalkGuard Block Bombsites
 
check your pm i sended you a plugin that does what you want.


All times are GMT -4. The time now is 10:34.

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