Raised This Month: $32 Target: $400
 8% 

Flashbang Dynamic Light


Post New Thread Reply   
 
Thread Tools Display Modes
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-13-2008 , 20:50   Re: Flashbang Dynamic Light
Reply With Quote #61

This is pretty much a copy of the original plugin, except for HE grenades. Replace all of the fbl_* cvars with hel_*
Attached Files
File Type: sma Get Plugin or Get Source (henade_dlight.sma - 1213 views - 2.3 KB)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 12-21-2008 at 17:28.
XxAvalanchexX is offline
AcidoX
Senior Member
Join Date: Oct 2007
Location: Vilnius
Old 11-23-2008 , 08:26   Re: Flashbang Dynamic Light
Reply With Quote #62

Yo Avalanche, maybe you can update you plugin a little bit? because the <fun> function can be replaced by fm
__________________
Who need lockerz invite? Pm me.
AcidoX is offline
Send a message via Skype™ to AcidoX
Igoreso
Junior Member
Join Date: Aug 2008
Old 12-25-2008 , 03:36   Re: Flashbang Dynamic Light
Reply With Quote #63

Works perfect. I think you should add this to the first post.
Igoreso is offline
eduardolucioac
Member
Join Date: Jan 2016
Old 10-25-2019 , 12:53   Re: Flashbang Dynamic Light
Reply With Quote #64

Here is your code with some modification proposals to add a player shake effect and some code changes.

The idea of the shake effect was based on the plugin Realistic FlashBang https://forums.alliedmods.net/showthread.php?t=118626 from @gladius .

I brought the idea to Flashbang Dynamic Light because I like the effects of it.

Observe the function...
PHP Code:
public event_flash(id
... and the line...
PHP Code:
cvNoShake register_cvar("fbl_noshake","0"); 
.

Thanks!

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

new enabled_cvarradius_cvarcolor_cvargmsgScreenFadegmsgScreenShakecvNoBlindcvNoShakecvRefreshmaxPlayers;

public 
plugin_init()
{
    
register_plugin("Flashbang Dynamic Light","0.21","Avalanche, GlaDiuS and Questor");
    
register_forward(FM_EmitSound,"fw_emitsound");

    
enabled_cvar register_cvar("fbl_enabled","1");
    
radius_cvar register_cvar("fbl_radius","50");
    
color_cvar register_cvar("fbl_color","255 255 255");
    
    
cvNoBlind register_cvar("fbl_noblind","0");
    
cvNoShake register_cvar("fbl_noshake","0");

    
cvRefresh register_cvar("fbl_refresh","0.0");

    
gmsgScreenFade get_user_msgid("ScreenFade");
    
gmsgScreenShake get_user_msgid("ScreenShake");

    
register_event("ScreenFade","event_flash","be","1>0","2>0","3=0","4=255","5=255","6=255","7>199"); // from VEN
    
maxPlayers get_maxplayers();
    
    
set_task(10.0,"refresh_nades");
}

public 
event_flash(id)
{
    if(
get_pcvar_num(enabled_cvar)) {
        if(
get_pcvar_num(cvNoBlind)) {

            
// overwrite it
            
message_begin(MSG_ONE,gmsgScreenFade,_,id);
            
write_short(0);
            
write_short(0);
            
write_short(1<<2);
            
write_byte(0);
            
write_byte(0);
            
write_byte(0);
            
write_byte(0);
            
message_end();

        }
        if(!
get_pcvar_num(cvNoShake)) {
            
set_task(3.0"shake_effect"id);
        }
    }
}

public 
shake_effect(id)
{
    new 
Dura UTIL_FixedUnsigned16(4.0<< 12)
    new 
Freq UTIL_FixedUnsigned16(0.7 << 8)
    new 
Ampl UTIL_FixedUnsigned16(20.0<< 12)
    
message_begin(MSG_ONE gmsgScreenShake , {0,0,0} ,id)
    
write_shortAmpl // --| Shake amount.
    
write_shortDura // --| Shake lasts this long.
    
write_shortFreq // --| Shake noise frequency.
    
message_end ()
}

public 
refresh_nades(id)
{
    new 
Float:time get_pcvar_float(cvRefresh);
    if(
time <= 0.0 || !get_pcvar_num(enabled_cvar))
    {
        
set_task(30.0,"refresh_nades");
        return;
    }
    
set_task(time,"refresh_nades");
    
    new 
i;
    for(
i=1;i<=maxPlayers;i++)
    {
        if(
is_user_alive(i) && !cs_get_user_bpammo(i,CSW_FLASHBANG))
        
fm_give_item(i,"weapon_flashbang");
    }
}

public 
fw_emitsound(entity,channel,const sample[],Float:volume,Float:attenuation,fFlags,pitch)
{
    
// plugin disabled
    
if(!get_pcvar_num(enabled_cvar))
    return 
FMRES_IGNORED;

    
// not a flashbang exploding
    
if(!equali(sample,"weapons/flashbang-1.wav") && !equali(sample,"weapons/flashbang-2.wav"))
    return 
FMRES_IGNORED;

    
// light effect
    
flashbang_explode(entity);

    return 
FMRES_IGNORED;
}


public 
flashbang_explode(greindex)
{
    
// invalid entity
    
if(!pev_valid(greindex)) return;

    
// get origin of explosion
    
new Float:origin[3];
    
pev(greindex,pev_origin,origin);

    
// get color from cvar
    
new color[16];
    
get_pcvar_string(color_cvar,color,15);

    
// split it into red, green, blue
    
new redamt[5], greenamt[5], blueamt[5];
    
parse(color,redamt,4,greenamt,4,blueamt,4);

    
// send the light flash
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(27); // TE_DLIGHT
    
write_coord(floatround(origin[0])); // x
    
write_coord(floatround(origin[1])); // y
    
write_coord(floatround(origin[2])); // z
    
write_byte(get_pcvar_num(radius_cvar)); // radius
    
write_byte(str_to_num(redamt)); // r
    
write_byte(str_to_num(greenamt)); // g
    
write_byte(str_to_num(blueamt)); // b
    
write_byte(8); // life
    
write_byte(60); // decay rate
    
message_end();
}

UTIL_FixedUnsigned16 ( const Float:Value, const Scale ) {
    return 
clampfloatroundValue Scale ), 00xFFFF );

eduardolucioac is offline
Reply


Thread Tools
Display Modes

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 03:42.


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