AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Imune from hs (https://forums.alliedmods.net/showthread.php?t=194455)

GhostMan 08-28-2012 14:55

Imune from hs
 
How to do that every time player gets a shot into head there would be 50% chance to avoid that shot's damage?
PHP Code:

public player_Attack idiAttackerFloat:flDamageFloat:fVecDir[3], tr )
{
    if ( 
get_user_flagsid ) & VIP_ACCESS )
    {
        if ( 
IsPlayeriAttacker ) && heavy_activeid ] && cs_get_user_teamid ) != cs_get_user_teamiAttacker ) && get_tr2trTR_iHitgroup ) == HIT_HEAD && get_tr2trTR_iHitgroup ) == HIT_HEAD )
        {
            
set_tr2trTR_iHitgroupHIT_CHEST );
            
set_tr2trTR_iHitgroupHIT_STOMACH );
            
            
            
message_beginMSG_ONE_UNRELIABLEg_msgFade, .player=id );
            {
                
write_short1<<12 );
                
write_short1<<);
                
write_shortFFADE_IN );
                
write_byte139 );
                
write_byte34 );
                
write_byte34 );
                
write_byte75 );
            }
            
message_end( );
            
            
message_beginMSG_ONE_UNRELIABLEg_msgShake, .player=id );
            {
                
write_short255<<);
                
write_short50<<);
                
write_short255<<);
            }
            
message_end( );
        }
    }



GhostMan 09-08-2012 12:38

Re: Imune from hs
 
Anybody?

Liverwiz 09-08-2012 13:26

Re: Imune from hs
 
how do you hook the function?

also...
Code:

&& get_tr2( tr, TR_iHitgroup ) == HIT_HEAD && get_tr2( tr, TR_iHitgroup ) == HIT_HEAD )
why?

Check out this plugin. Its a good example of how to catch headshots
http://forums.alliedmods.net/showthr...light=headshot

GhostMan 09-08-2012 15:31

Re: Imune from hs
 
I dont know why there is that part, i even wasnt sure what it was for untill you show me HS Modes plugin.

Now i think i get it :) So would this code work? It should give 50% chance to entiraly block damage if you get HS.

PHP Code:

public player_Attack idiAttackerFloat:flDamageFloat:fVecDir[3], tr )
{
    if ( 
get_user_flagsid ) & VIP_ACCESS )
    {
        if ( 
IsPlayeriAttacker ) && heavy_activeid ] && cs_get_user_teamid ) != cs_get_user_teamiAttacker ))
        {
            if( 
get_tr2trTR_iHitgroup ) == HIT_HEAD )
            {
                new 
p_Random random_num(1100)
                
                if(
p_Random <= 50)
                {
                    
message_beginMSG_ONE_UNRELIABLEg_msgFade, .player=id );
                    {
                        
write_short1<<12 );
                        
write_short1<<);
                        
write_shortFFADE_IN );
                        
write_byte139 );
                        
write_byte34 );
                        
write_byte34 );
                        
write_byte75 );
                    }
                    
message_end( );
                    
                    
message_beginMSG_ONE_UNRELIABLEg_msgShake, .player=id );
                    {
                        
write_short255<<);
                        
write_short50<<);
                        
write_short255<<);
                    }
                    
message_end( );
                    
                    return 
HAM_SUPERCEDE;
                }
            }
        }
    }
    return 
HAM_IGNORED;



Doc-Holiday 09-08-2012 15:38

Code is hard to read but.... Random(1); gets numbers 0-1 and if == 1 is a 50% chance also.....


All times are GMT -4. The time now is 05:48.

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