AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   flashing through wall (https://forums.alliedmods.net/showthread.php?t=82908)

padilha007 01-01-2009 01:48

flashing through wall
 
Is possible make flash granade with this event?

anakin_cstrike 01-01-2009 09:21

Re: flashing through wall
 
Exaplain a bit more what do you want to do.

padilha007 01-01-2009 09:33

Re: flashing through wall
 
I want to make a wall that does not prevent the light from the flash bang stop. Only a blind person even if he is behind the wall.


Styles 01-01-2009 18:20

Re: flashing through wall
 
Ya you could, what you would probably do is as the

RegisterHam(Ham_Think,"grenade","hGernadeThin k",0);

Then, get the entity of the flash nades origin, pev_origin, then, for each person in the server get their radius, subtract it, if their within the radius, turn their screen white, you will probabaly have to do some math to detect deepening on fair. Look at the HL SDK, I mean this is how I would do it, I might be going over board lol.

Exolent[jNr] 01-01-2009 18:31

Re: flashing through wall
 
Or, make the wall entity SOLID_NOT when the flash goes off, then add a 0.1 second delay for the entity to be SOLID_BBOX.
Only problem with that is that players would get stuck if they were running against it while the flash went off.

Styles 01-01-2009 19:34

Re: flashing through wall
 
Quote:

Originally Posted by Exolent[jNr] (Post 736716)
Or, make the wall entity SOLID_NOT when the flash goes off, then add a 0.1 second delay for the entity to be SOLID_BBOX.
Only problem with that is that players would get stuck if they were running against it while the flash went off.

But that wouldn't work if he wanted it to go through a main game map :P

padilha007 01-01-2009 21:18

Re: flashing through wall
 
someone can give my a exemple?

Exolent[jNr] 01-01-2009 22:42

Re: flashing through wall
 
This plugin allows flashbang effects to work as if there are no walls between you and the flashbang.
There is only one problem. It doesn't make it partial alpha if you aren't looking at it.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

// From testing, I got these results:
// 
// Max distance was ~1460
// Max duration was 12
// 
// Duration -    max / (max - distance)
// HoldTime -    1 ( in register_message(), holdtime is not 1, but it is in register_event() )
// Flags -    0
// Red -    255
// Green -    255
// Blue -    255
// Alpha -    255 (200 if angle of aim is 90 degrees or more away from the flashbang)

#define seconds_to_units(%1) (%1 * (1<<12))

#define MAX_DISTANCE        1460
#define MAX_DURATION        12

#define FLASH_HOLDTIME_FAKE    1
#define FLASH_FLAGS        0
#define FLASH_RED        255
#define FLASH_GREEN        255
#define FLASH_BLUE        255
#define FLASH_ALPHA1        200
#define FLASH_ALPHA2        255

new bool:g_allow_flashbang[33];
new 
g_flash_distance[33];

new 
ScreenFade;

new 
g_max_clients;

public 
plugin_init()
{
    
register_plugin("Flashbang Through Walls""0.1""Exolent");
    
    
RegisterHam(Ham_Think"grenade""FwdGrenadeThink");
    
    
register_message((ScreenFade get_user_msgid("ScreenFade")), "MessageScreenFade");
    
    
g_max_clients get_maxplayers();
}

public 
client_connect(client)
{
    
g_allow_flashbang[client] = false;
}

public 
FwdGrenadeThink(ent)
{
    
// HamSandwich should provide valid entities
    // but I wanna be safe
    
if( !pev_valid(ent) ) return;
    
    static 
Float:dmgtime;
    
pev(entpev_dmgtimedmgtime);
    
    if( 
dmgtime get_gametime() ) return;
    
    static 
model[32];
    
pev(entpev_modelmodelsizeof(model) - 1);
    
    if( 
containi(model"flashbang") == -) return; 
    
    
// make sure we only detect 1 explosion per flash
    
if( pev(entpev_bInDuck) ) return;
    
set_pev(entpev_bInDuck1);
    
    static 
Float:ent_origin[3];
    
pev(entpev_originent_origin);
    
    static 
aliveFloat:client_origin[3], Float:angles[3];
    for( new 
client 1client <= g_max_clientsclient++ )
    {
        if( !
is_user_connected(client) ) continue;
        
        if( 
is_user_alive(client) )
        {
            
alive client;
        }
        else
        {
            
alive pev(clientpev_iuser1);
            if( !
is_user_alive(alive) )
            {
                
alive client;
            }
        }
        
        
engfunc(EngFunc_GetBonePositionalive8client_originangles);
        
        
g_flash_distance[client] = min(floatround(get_distance_f(ent_originclient_origin) / 10.0floatround_ceil) * 10MAX_DISTANCE);
        
        
// 0.1 is the delay I found between the explosion and blinding
        
set_task(0.1"TaskDoFlashbang"client);
    }
}

public 
MessageScreenFade(msgiddestclient)
{
    if( !(
<= client <= g_max_clients)
    || 
get_msg_arg_int(3) != FLASH_FLAGS
    
|| get_msg_arg_int(4) != FLASH_RED
    
|| get_msg_arg_int(5) != FLASH_GREEN
    
|| get_msg_arg_int(6) != FLASH_BLUE )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    new 
alpha get_msg_arg_int(7);
    if( 
alpha != FLASH_ALPHA1 && alpha != FLASH_ALPHA2 ) return PLUGIN_CONTINUE;
    
    if( 
g_allow_flashbang[client] )
    {
        
g_allow_flashbang[client] = false;
        return 
PLUGIN_CONTINUE;
    }
    
    return 
PLUGIN_HANDLED;
}

public 
TaskDoFlashbang(client)
{
    new 
duration seconds_to_units(floatround(float(MAX_DISTANCE g_flash_distance[client]) / float(MAX_DISTANCE) * MAX_DURATION));
    
    
g_allow_flashbang[client] = true;
    
    
emessage_begin(MSG_ONEScreenFade_client);
    
ewrite_short(duration);
    
ewrite_short(FLASH_HOLDTIME_FAKE);
    
ewrite_short(FLASH_FLAGS);
    
ewrite_byte(FLASH_RED);
    
ewrite_byte(FLASH_GREEN);
    
ewrite_byte(FLASH_BLUE);
    
ewrite_byte(FLASH_ALPHA2); // TODO: Add support for 200 alpha (FLASH_ALPHA1)
    
emessage_end();



padilha007 01-02-2009 10:04

Re: flashing through wall
 
works perfect, i can use no_flash_team with this plugin?

+K

Exolent[jNr] 01-02-2009 10:05

Re: flashing through wall
 
Yes, because it sends a flashbang event that can be caught by other plugins.


All times are GMT -4. The time now is 09:04.

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