AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   shake (https://forums.alliedmods.net/showthread.php?t=217246)

GhostMan 05-31-2013 14:44

shake
 
PHP Code:

public shake(id)
{
    
message_begin(MSG_ONE_UNRELIABLEg_msgFade, .player=id)
    {
        
write_short(1<<14)
        
write_short(1<<5)
        
write_short(FFADE_IN)
        
write_byte(34)
        
write_byte(34)
        
write_byte(139)
        
write_byte(75)
    }
    
message_end()
    
    
message_begin(MSG_ONE_UNRELIABLEg_msgShake, .player=id)
    {
        
write_short(255<<15)
        
write_short(50<<8)
        
write_short(255<<15)
    }
    
message_end()


where is shake's duration?

ConnorMcLeod 05-31-2013 14:48

Re: shake
 
PHP Code:

stock FixedUnsigned16Float:valuescale )
{
    new 
output;

    
output floatround(value scale);
    if ( 
output )
        
output 0;
    if ( 
output 0xFFFF )
        
output 0xFFFF;

    return 
output;
}

// ScreenShake
stock Util_ScreenShake(idFloat:durationFloat:frequencyFloat:amplitude)
{
    static 
ScreenShake 0;
    if( !
ScreenShake )
    {
        
ScreenShake get_user_msgid("ScreenShake");
    }
    
message_beginid MSG_ONE MSG_ALLScreenShake_id);
    
write_shortFixedUnsigned16amplitude1<<12 ) ); // shake amount
    
write_shortFixedUnsigned16duration1<<12 ) ); // shake lasts this long
    
write_shortFixedUnsigned16frequency1<<) ); // shake noise frequency
    
message_end();
}

// ScreenFade
enum ( <<=){
    
FFADE_IN// Just here so we don't pass 0 into the function
    
FFADE_OUT 1// Fade out (not in)
    
FFADE_MODULATE// Modulate (don't blend)
    
FFADE_STAYOUT // ignores the duration, stays faded out until new ScreenFade message received
}

enum {
    
_Red,
    
_Green,
    
_Blue
};

stock UTIL_ScreenFade(const id=0,const iColor[3]={0,0,0},const Float:flFxTime=-1.0,const Float:flHoldTime=0.0,const iAlpha=0,const iFlags=FFADE_IN,bool:bReliable=false,bool:bExternal=false)
{
    if( 
id && !is_user_connected(id))
        return;

    new 
iFadeTime;
    if( 
flFxTime == -1.0 )
    {
        
iFadeTime 4;
    }
    else
    {
        
iFadeTime FixedUnsigned16flFxTime 1<<12 );
    }

    static 
msgScreenFade 0;
    if( !
msgScreenFade )
    {
        
msgScreenFade get_user_msgid("ScreenFade");
    }

    new 
MSG_DEST;
    if( 
bReliable )
    {
        
MSG_DEST id MSG_ONE MSG_ALL;
    }
    else
    {
        
MSG_DEST id MSG_ONE_UNRELIABLE MSG_BROADCAST;
    }

    if( 
bExternal )
    {
        
emessage_beginMSG_DESTmsgScreenFade_id );
        
ewrite_shortiFadeTime );
        
ewrite_shortFixedUnsigned16flHoldTime 1<<12 ) );
        
ewrite_shortiFlags );
        
ewrite_byteiColor[_Red] );
        
ewrite_byteiColor[_Green] );
        
ewrite_byteiColor[_Blue] );
        
ewrite_byteiAlpha );
        
emessage_end();
    }
    else
    {
        
message_beginMSG_DESTmsgScreenFade_id );
        
write_shortiFadeTime );
        
write_shortFixedUnsigned16flHoldTime 1<<12 ) );
        
write_shortiFlags );
        
write_byteiColor[_Red] );
        
write_byteiColor[_Green] );
        
write_byteiColor[_Blue] );
        
write_byteiAlpha );
        
message_end();
    }


->

PHP Code:

public shake(id)
{
    
UTIL_ScreenFade(id, {34,34,139}, 4.00.00175)
    
Util_ScreenShake(id3.0255.015.0// maxs : ( , 15.0, 255.0, 15.0)




All times are GMT -4. The time now is 16:14.

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