Converted SNARK INFECTOR

Zombies/Humans Extra-Items
Post Reply
User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

SNARK INFECTOR

#1

Post by Mark » 5 years ago

SNARK INFECTOR


I saw this plugin was requested in public request after i already fixed it.
viewtopic.php?f=17&t=3160&start=20

Description:
  • New Item for Zombies
  • Buy this and you will get a bug in your hand that you can release, it will run around for x amount of time then explode.
  • If will not infect the last human it will only damage him

CODE:
    1. #include <zombie_escape>
    2. #include <cstrike>
    3. #include <engine>
    4. #include <fun>
    5.  
    6.  
    7. #define Plugin   "[ZE] Extra: Squeak Grenade"
    8. #define Version  "1.0.6-wwm"
    9. #define Author   "Arkshine/Mark"
    10.  
    11.  
    12. // --| Comment if you want to use the default model from valve.
    13. #define ALTERNATIVE_MODEL
    14.  
    15. // --| Snark trail.
    16. #define TRAIL_LIFE        40    // Life
    17. #define TRAIL_WIDTH       4     // Width
    18. #define TRAIL_RED         10    // Red
    19. #define TRAIL_GREEN       224   // Red
    20. #define TRAIL_BLUE        10    // Green
    21. #define TRAIL_BRIGTHNESS  200   // Blue
    22.  
    23.  
    24.  /* - - -
    25.  |  WEAPON MODELS  |
    26.              - - - */
    27.     #if !defined ALTERNATIVE_MODEL
    28.         new const gModel_P[] = "models/p_squeak.mdl";
    29.         new const gModel_V[] = "models/v_squeak.mdl";
    30.     #else
    31.         new const gModel_P[] = "models/p_alt_squeak.mdl";
    32.         new const gModel_V[] = "models/v_alt_squeak_gflip.mdl";
    33.     #endif
    34.  
    35. /* - - -
    36.  |  SNARK SOUNDS  |
    37.             - - - */
    38.         new const gSnarkHunt1Sound    [] = "squeek/sqk_hunt1.wav";
    39.         new const gSnarkHunt2Sound    [] = "squeek/sqk_hunt2.wav";
    40.         new const gSnarkHunt3Sound    [] = "squeek/sqk_hunt3.wav";
    41.         new const gSnarkDieSound      [] = "squeek/sqk_die1.wav";
    42.         new const gSnarkAttackSound   [] = "squeek/sqk_deploy1.wav";
    43.         new const gSnarkBlastSound    [] = "weapons/sqk_blast2.wav";
    44.         new const gSnarkBodySplatSound[] = "common/bodysplat.wav";
    45.  
    46. /* - - -
    47.  |  SNARK MODEL  |
    48.            - - - */
    49.     new
    50.     #if !defined ALTERNATIVE_MODEL
    51.         gSnarkModel[] = "models/w_squeak.mdl";
    52.     #else
    53.         gSnarkModel[] = "models/w_alt_squeak.mdl";
    54.     #endif
    55.  
    56. /* - - -
    57.  |    SEQUENCE   |
    58.            - - - */
    59.     enum
    60.     {
    61.         wsqueak_idle1,
    62.         wsqueak_fidget,
    63.         wsqueak_jump,
    64.         wsqueak_run
    65.     };
    66.  
    67.     enum
    68.     {
    69.         squeak_idle1,
    70.         squeak_fidgetfit,
    71.         squeak_fidgetnip,
    72.         squeak_down,
    73.         squeak_up,
    74.         squeak_throw
    75.     };
    76.  
    77. /* - -
    78.  |  CONSTANTS  |
    79.            - - */
    80.     const BLOOD_COLOR_RED_N        = 247;
    81.     const BLOOD_COLOR_YELLOW_N     = 195;
    82.            
    83.     const MAX_CLIENTS_N            = 32;
    84.     const MAX_KNIFE_MODEL_LENGTH = 128;
    85.     const NONE                   = -1;
    86.     const NULL_ENT               = 0;
    87.  
    88.     enum _:Coord_e
    89.     {
    90.         Float:x,
    91.         Float:y,
    92.         Float:z
    93.     };
    94.  
    95.     enum _:Angle_e
    96.     {
    97.         Float:Pitch,
    98.         Float:Yaw,
    99.         Float:Roll
    100.     };
    101.  
    102.     enum
    103.     {
    104.         HuntThink = 1,
    105.         SuperBounceTouch,
    106.         RemoveSnark
    107.     };
    108.  
    109.     new const Float:gHullMin    [ Coord_e ] = { -16.0, -16.0, -36.0 };
    110.     new const Float:gDuckHullMin[ Coord_e ] = { -16.0, -16.0, -18.0 };
    111.  
    112.     new const gWeaponCommand [] = "weapon_hegrenade";
    113.     new const gWeaponIndex      = CSW_HEGRENADE;
    114.  
    115.     new const gGenericEntity [] = "info_target";
    116.     new const gSnarkClassName[] = "wpn_snark";
    117.  
    118. /* - - -
    119.  |  CUSTOM FIELD  |
    120.             - - - */
    121.     #define pev_NextHunt            pev_fuser1
    122.     #define pev_NextBounceSoundTime pev_fuser2
    123.     #define pev_NextHit             pev_fuser3
    124.     #define pev_NextAttack          pev_fuser4
    125.     #define pev_DetonateDelay       pev_ltime
    126.     #define pev_RealOwner           pev_iuser1
    127.     #define pev_Remove              pev_iuser2
    128.     #define pev_EnemyTarget         pev_vuser1
    129.     #define pev_PosPrev             pev_vuser2
    130.  
    131. /* - - -
    132.  |  CVAR POINTER  |
    133.             - - - */
    134.     new pCvarAmmo;
    135.     new pCvarRefireRate;
    136.     new pCvarHealth;
    137.     new pCvarVelocity;
    138.     new pCvarDamagePop;
    139.     new pCvarDamageRadius;
    140.     new pCvarGravity;
    141.     new pCvarFriction;
    142.     new pCvarDetonateDelay;
    143.     new pCvarFieldOfView;
    144.     new pCvarShowTrail;
    145.  
    146. /* - - - -
    147.  |  SPRITES/MODELS INDEX  |
    148.                   - - - - */
    149.     new gBloodSpray;
    150.     new gBloodDrop;
    151.     new gSmokeTrail;
    152.  
    153. /* - - - -
    154.  |  OTHERS STUFFS  |
    155.              - - - */
    156.     new bool:gHasSnark    [ MAX_CLIENTS_N + 1 char ];
    157.     new bool:gWeaponActive[ MAX_CLIENTS_N + 1 char ];
    158.     new bool:gJustThrown  [ MAX_CLIENTS_N + 1 char ];
    159.  
    160.     new Float:gNextShot      [ MAX_CLIENTS_N + 1 ];
    161.     new Float:gTimeWeaponIdle[ MAX_CLIENTS_N + 1 ];
    162.  
    163.     new gPlayerAmmo[ MAX_CLIENTS_N + 1 char ];
    164.  
    165.     new const gSnarkHealthReference = 10000;
    166.     new gSnarkClassNameReference;
    167.     new gMaxEntities;
    168.     new gMaxClients;
    169.     new gMsgidAmmoX;
    170.     new gSnarInfector;
    171.  
    172. /* - -
    173.  |  MACROS  |
    174.         - - */
    175.     #define VectorSubtract(%1,%2,%3)  ( %3[ x ] = %1[ x ] - %2[ x ], %3[ y ] = %1[ y ] - %2[ y ], %3[ z ] = %1[ z ] - %2[ z ] )
    176.     #define VectorAdd(%1,%2,%3)       ( %3[ x ] = %1[ x ] + %2[ x ], %3[ y ] = %1[ y ] + %2[ y ], %3[ z ] = %1[ z ] + %2[ z ] )
    177.     #define VectorCopy(%1,%2)         ( %2[ x ] = %1[ x ],  %2[ y ] = %1[ y ], %2[ z ] = %1[ z ] )
    178.     #define VectorScale(%1,%2,%3)     ( %3[ x ] = %2 * %1[ x ], %3[ y ] = %2 * %1[ y ], %3[ z ] = %2 * %1[ z ] )
    179.     #define VectorMA(%1,%2,%3,%4)     ( %4[ x ] = %1[ x ] + %2 * %3[ x ], %4[ y ] = %1[ y ] + %2 * %3[ y ], %4[ z ] = %1[ z ] + %2 * %3[ z ] )
    180.     #define VectorMS(%1,%2,%3,%4)     ( %4[ x ] = %1[ x ] - %2 * %3[ x ], %4[ y ] = %1[ y ] - %2 * %3[ y ], %4[ z ] = %1[ z ] - %2 * %3[ z ] )
    181.     #define VectorLength(%1)          ( floatsqroot ( %1[ x ] * %1[ x ] + %1[ y ] * %1[ y ] + %1[ z ] * %1[ z ] ) )
    182.     #define VectorEqual(%1,%2)        ( %1[ x ] == %2[ x ] && %1[ y ] == %2[ y ] && %1[ z ] == %2[ z ] )
    183.     #define DotProduct(%1,%2)         ( %1[ x ] * %2[ x ]+ %1[ y ] * %2[ y ] + %1[ z ] * %2[ z ] )
    184.  
    185.     #define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
    186.     #define write_coord_f(%1)         ( engfunc ( EngFunc_WriteCoord, %1 ) )
    187.    
    188.  
    189. public plugin_precache ()
    190. {
    191.     // --| Weapon models.
    192.     precache_model( gModel_P );
    193.     precache_model( gModel_V );
    194.  
    195.     // --| Snark model.
    196.     precache_model( gSnarkModel );
    197.  
    198.     // --| Snark sounds.
    199.     precache_sound( gSnarkBlastSound );
    200.     precache_sound( gSnarkBodySplatSound );
    201.     precache_sound( gSnarkDieSound );
    202.     precache_sound( gSnarkHunt1Sound );
    203.     precache_sound( gSnarkHunt2Sound );
    204.     precache_sound( gSnarkHunt3Sound );
    205.     precache_sound( gSnarkAttackSound );
    206.  
    207.     gBloodSpray = precache_model( "sprites/bloodspray.spr" );   // initial blood
    208.     gBloodDrop  = precache_model( "sprites/blood.spr" );        // splattered blood
    209. }
    210.  
    211.  
    212. public plugin_init ()
    213. {
    214.     register_plugin( Plugin, Version, Author );
    215.     register_cvar( "ze_snark_version", Version, FCVAR_SERVER | FCVAR_SPONLY );
    216.  
    217.     gSnarInfector = ze_register_item("Snark INFECTOR", 120, 0);
    218.    
    219.     pCvarAmmo          = register_cvar( "wpn_sg_ammo"           , "5"   );
    220.     pCvarRefireRate    = register_cvar( "wpn_sg_refire_rate"    , "0.3" );
    221.     pCvarHealth        = register_cvar( "wpn_sg_health"         , "10"  );
    222.     pCvarVelocity      = register_cvar( "wpn_sg_velocity"       , "400" );
    223.     pCvarDamagePop     = register_cvar( "wpn_sg_damage_pop"     , "6"   );
    224.     pCvarDamageRadius  = register_cvar( "wpn_sg_damage_radius"  , "15"  );
    225.     pCvarGravity       = register_cvar( "wpn_sg_gravity"        , "0.8" );
    226.     pCvarFriction      = register_cvar( "wpn_sg_friction"       , "0.8" );
    227.     pCvarDetonateDelay = register_cvar( "wpn_sg_detonate_delay" , "60"  );
    228.     pCvarFieldOfView   = register_cvar( "wpn_sg_fov"            , "0"   );
    229.     pCvarShowTrail     = register_cvar( "wpn_sg_show_trail"     , "1"   );
    230.  
    231.     RegisterHam( Ham_Item_Deploy , gWeaponCommand, "CSqueak_Deploy", 1 );
    232.     RegisterHam( Ham_Item_Holster, gWeaponCommand, "CSqueak_Holster", 1 );
    233.     RegisterHam( Ham_TakeDamage, gGenericEntity, "CSqueak_TakeDamage", 1 );
    234.  
    235.     register_forward( FM_CmdStart, "CSqueak_HookButtons" );
    236.     register_forward( FM_PlayerPreThink, "CSqueak_WeaponIdle" );
    237.  
    238.     register_think( gSnarkClassName, "CSqueak_HuntThink" );
    239.     register_touch( gSnarkClassName, "*", "CSqueak_SuperBounceTouch" );
    240.  
    241.     // register_clcmd( "say test", "CSqueak_GiveWeapon" );
    242.  
    243.     gMaxEntities = global_get( glb_maxEntities );
    244.     gMaxClients  = global_get( glb_maxClients );
    245.    
    246.     gSnarkClassNameReference = engfunc( EngFunc_AllocString, gSnarkClassName );
    247.     gMsgidAmmoX = get_user_msgid( "AmmoX" );
    248.  
    249.     if ( get_pcvar_num( pCvarShowTrail ) )
    250.     {
    251.         gSmokeTrail = engfunc( EngFunc_PrecacheModel, "sprites/smoke.spr" );
    252.     }
    253. }
    254.  
    255. public ze_select_item_pre(id, itemid)
    256. {
    257.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    258.     if (itemid != gSnarInfector)
    259.         return ZE_ITEM_AVAILABLE
    260.    
    261.     // Available for Humans only, So don't show it for zombies
    262.     if (!ze_is_user_zombie(id))
    263.         return ZE_ITEM_DONT_SHOW
    264.    
    265.     return ZE_ITEM_AVAILABLE
    266. }
    267.  
    268. public ze_select_item_post(id, itemid)
    269. {
    270.     // This is not our item, Block it here
    271.     if (itemid != gSnarInfector)
    272.         return
    273.    
    274.     CSqueak_GiveWeapon ( id );
    275. }
    276.  
    277. public ze_roundend ( WinTeam )
    278. {
    279.     new Snark = -1;
    280.    
    281.     while ( ( Snark = find_ent_by_class( Snark, gSnarkClassName ) ) != NULL_ENT )
    282.     {
    283.         CSqueak_Killed ( Snark, 0, true );
    284.     }
    285.    
    286.     for ( new Player = 1; Player <= gMaxClients; Player++ )
    287.     {
    288.         CheckAndRemoveWeapon ( Player );
    289.     }
    290. }
    291.  
    292.  
    293. public ze_user_humanized ( Player )
    294. {
    295.     gHasSnark    { Player } = false;
    296. }
    297.  
    298. stock CheckAndRemoveWeapon ( const Player )
    299. {
    300.     if ( user_has_weapon( Player, gWeaponIndex ) )
    301.     {
    302.         RemoveWeapon ( Player, get_user_weapon( Player ) == gWeaponIndex ?
    303.            
    304.             get_pdata_cbase( Player, 373 ) :
    305.             find_ent_by_owner ( -1, gWeaponCommand, Player ) );
    306.     }
    307. }
    308.  
    309.  
    310. public client_connect ( Player )
    311. {
    312.     gHasSnark    { Player } = false;
    313.     gWeaponActive{ Player } = false;
    314.     gJustThrown  { Player } = false;
    315.     gPlayerAmmo  { Player } = get_pcvar_num( pCvarAmmo );
    316. }
    317.  
    318.  
    319. public CSqueak_GiveWeapon( const Player )
    320. {
    321.     gHasSnark{ Player } = true;
    322.     gPlayerAmmo{ Player } = get_pcvar_num( pCvarAmmo );
    323.  
    324.     give_item( Player, gWeaponCommand );
    325.     engclient_cmd( Player, gWeaponCommand );
    326. }
    327.  
    328.  
    329. public CSqueak_PrimaryAttack ( const Player )
    330. {
    331.     static Float:VAngle     [ Angle_e ];
    332.     static Float:Origin     [ Coord_e ];
    333.     static Float:TraceOrigin[ Coord_e ];
    334.     static Float:Forward    [ Coord_e ];
    335.     static Float:Start      [ Coord_e ];
    336.     static Float:End        [ Coord_e ];
    337.     static Float:EndPos     [ Coord_e ];
    338.     static Float:Velocity   [ Coord_e ];
    339.     static Float:Fraction;
    340.  
    341.     if ( gPlayerAmmo{ Player } )
    342.     {
    343.         if ( pev( Player, pev_waterlevel ) >= 3 )
    344.         {
    345.             emit_sound( Player, CHAN_WEAPON, gSnarkDieSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM + 5 );
    346.             gNextShot[ Player ] = get_gametime() + get_pcvar_float( pCvarRefireRate );
    347.             return PLUGIN_HANDLED;
    348.         }
    349.  
    350.         pev( Player, pev_origin, Origin );
    351.         pev( Player, pev_v_angle, VAngle );
    352.         pev( Player, pev_velocity, Velocity );
    353.  
    354.         engfunc( EngFunc_MakeVectors, VAngle );
    355.  
    356.         VectorCopy( Origin, TraceOrigin );
    357.  
    358.         if ( pev( Player, pev_flags ) & FL_DUCKING )
    359.         {
    360.             TraceOrigin[ x ] = TraceOrigin[ x ] - ( gHullMin[ x ] - gDuckHullMin[ x ] );
    361.             TraceOrigin[ y ] = TraceOrigin[ y ] - ( gHullMin[ y ] - gDuckHullMin[ y ] );
    362.             TraceOrigin[ z ] = TraceOrigin[ z ] - ( gHullMin[ z ] - gDuckHullMin[ z ] );
    363.         }
    364.  
    365.         global_get( glb_v_forward, Forward );
    366.  
    367.         VectorMA ( TraceOrigin, 20.0, Forward, Start );
    368.         VectorMA ( TraceOrigin, 64.0, Forward, End );
    369.  
    370.         engfunc( EngFunc_TraceLine, Start, End, DONT_IGNORE_MONSTERS, NULL_ENT, 0 );
    371.  
    372.         get_tr2( 0, TR_Fraction, Fraction );
    373.         get_tr2( 0, TR_vecEndPos, EndPos );
    374.  
    375.         if ( !get_tr2( 0, TR_AllSolid ) && !get_tr2( 0, TR_StartSolid ) && Fraction > 0.25 )
    376.         {
    377.             // --| Play the throw animation.
    378.             UTIL_PlayWeaponAnimation ( Player, squeak_throw );
    379.  
    380.             // --| player "shoot" animation
    381.             //
    382.  
    383.             VectorMA ( Velocity, get_pcvar_float( pCvarVelocity ), Forward, Velocity );
    384.  
    385.             if ( CSqueak_Create ( Player, EndPos, VAngle, Velocity ) )
    386.             {
    387.                 new Float:CurrentTime = get_gametime();
    388.  
    389.                 switch ( random_num( 0, 2 ) )
    390.                 {
    391.                     case 0: emit_sound( Player, CHAN_WEAPON, gSnarkHunt1Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
    392.                     case 1: emit_sound( Player, CHAN_WEAPON, gSnarkHunt2Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
    393.                     case 2: emit_sound( Player, CHAN_WEAPON, gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
    394.                 }
    395.  
    396.                 gPlayerAmmo{ Player }--;
    397.                 gJustThrown{ Player } = true;
    398.                
    399.                 UpdateHud ( Player );
    400.  
    401.                 gNextShot[ Player ] = CurrentTime + get_pcvar_float( pCvarRefireRate );
    402.                 gTimeWeaponIdle[ Player ] = CurrentTime + 1.0;
    403.  
    404.                 return PLUGIN_CONTINUE;
    405.             }
    406.         }
    407.     }
    408.  
    409.     return PLUGIN_HANDLED;
    410. }
    411.  
    412.  
    413. public CSqueak_Deploy ( const Weapon )
    414. {
    415.     // --| Get the knife's owner index.
    416.     new Player = get_pdata_cbase( Weapon, 41, 4 );
    417.  
    418.     if ( Player && gHasSnark{ Player } )
    419.     {
    420.         // --| Change knife to snark weapon.
    421.         ChangeWeaponToSnark ( Player );
    422.  
    423.         // --| Play the deploy animation.
    424.         UTIL_PlayWeaponAnimation ( Player, squeak_up );
    425.         emit_sound ( Weapon, CHAN_VOICE , random_float ( 0.0, 1.0 ) <= 0.5 ? gSnarkHunt2Sound : gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
    426.  
    427.         // --| Block the primary attack.
    428.         set_pdata_float( Weapon, 46, 9999.0, 4 );
    429.         set_pdata_float( Player, 83, 9999.0 );
    430.        
    431.         // --| Update Ammo on HUD.
    432.         UpdateHud ( Player );
    433.  
    434.         // --| We are holding the weapon.
    435.         gWeaponActive{ Player } = true;
    436.     }
    437. }
    438.  
    439.  
    440. public CSqueak_Holster ( const Weapon )
    441. {
    442.     // --| Get the knife's owner index.
    443.     new Player = get_pdata_cbase( Weapon, 41, 4 );
    444.  
    445.     if ( Player && gHasSnark{ Player } && gWeaponActive{ Player } )
    446.     {
    447.         // --| We are not holding the weapon anymore.
    448.         gWeaponActive{ Player } = false;
    449.         set_pdata_float( Player, 83, get_gametime() + 0.5 );
    450.  
    451.         if ( !gPlayerAmmo{ Player } && user_has_weapon( Player, gWeaponIndex ) )
    452.         {
    453.             RemoveWeapon ( Player, get_pdata_cbase( Player, 373 ) );
    454.         }
    455.         else
    456.         {
    457.             // --| Play the holster animation.
    458.             UTIL_PlayWeaponAnimation ( Player, squeak_down );
    459.             emit_sound( Player, CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
    460.         }
    461.     }
    462. }
    463.  
    464.  
    465. public CSqueak_Killed ( const Snark, const Killer, const bool:ShouldGib )
    466. {
    467.     new Float:Direction[ Coord_e ];
    468.     new Float:Origin   [ Coord_e ];
    469.  
    470.     pev( Snark, pev_origin, Origin );
    471.  
    472.     set_pev( Snark, pev_model, 0 );
    473.     set_pev( Snark, pev_Remove, RemoveSnark );
    474.     set_pev( Snark, pev_DetonateDelay, get_gametime() + 0.1 );
    475.  
    476.     set_pev( Snark, pev_takedamage, DAMAGE_NO );
    477.  
    478.     emit_sound( Snark, CHAN_ITEM, gSnarkBlastSound, VOL_NORM, ATTN_NORM / 2, 0, PITCH_NORM );
    479.     emit_sound( Snark, CHAN_VOICE, gSnarkBodySplatSound, 0.75, ATTN_NORM, 0, PITCH_NORM * 2 );
    480.  
    481.     UTIL_RandomBloodVector( Direction );
    482.    
    483.     FX_BloodDrips ( Origin, BLOOD_COLOR_YELLOW_N, .Amount = 60 );
    484.     FX_StreakSplash ( Origin, Direction, .Color = 5, .Count = 16, .Speed = 50, .VelocityRange = 200 );
    485.    
    486.     UTIL_RadiusDamage ( Origin, Snark, pev( Snark, pev_RealOwner ), get_pcvar_float( pCvarDamagePop ), get_pcvar_float( pCvarDamageRadius ), DMG_BLAST );
    487. }
    488.  
    489.  
    490. /* public CZombie_Killed ( const Zombie, const Human, const bool:ShouldGid )
    491. {
    492.     if ( ze_is_user_zombie( Zombie ) && gHasSnark{ Zombie } )
    493.     {
    494.        
    495.     }
    496. } */
    497.  
    498.  
    499. public CSqueak_TakeDamage ( const Snark, const Inflictor, const Attacker, const Float:Damage, const DamageBits )
    500. {
    501.     if ( is_valid_ent( Snark ) && pev( Snark, pev_groupinfo ) == gSnarkClassNameReference )
    502.     {
    503.         if ( pev( Snark, pev_health ) - gSnarkHealthReference <= 0 )
    504.         {
    505.             CSqueak_Killed ( Snark, Attacker, .ShouldGib = true );
    506.         }
    507.     }
    508. }
    509.  
    510.  
    511. public CSqueak_HookButtons ( const Player, const UC_Handle, const Seed )
    512. {
    513.     static Float:CurrentTime;
    514.     static Buttons;
    515.  
    516.     if ( gHasSnark{ Player } && gWeaponActive{ Player } && ( Buttons = get_uc( UC_Handle, UC_Buttons ) ) & IN_ATTACK )
    517.     {
    518.         CurrentTime = get_gametime();
    519.  
    520.         if ( gNextShot[ Player ] > CurrentTime )
    521.         {
    522.             return FMRES_HANDLED;
    523.         }
    524.        
    525.         if ( CSqueak_PrimaryAttack ( Player ) == PLUGIN_HANDLED )
    526.         {
    527.             return FMRES_HANDLED;
    528.         }
    529.  
    530.         set_uc( UC_Handle, UC_Buttons, Buttons & ~IN_ATTACK );
    531.         return FMRES_HANDLED;
    532.     }
    533.  
    534.     return FMRES_IGNORED;
    535. }
    536.  
    537.  
    538. public CSqueak_HuntThink ( const Snark )
    539. {
    540.     if ( !is_valid_ent( Snark ) )
    541.     {
    542.         return HAM_IGNORED;
    543.     }
    544.  
    545.     static Float:Origin  [ Coord_e ];
    546.     static Float:Velocity[ Coord_e ];
    547.     static Float:Angles  [ Coord_e ];
    548.     static Float:Flat    [ Coord_e ];
    549.     static Float:CurrentTime;
    550.     static Float:DieDelay;
    551.     static Float:NextHunt;
    552.     static Float:SPitch;
    553.     static Enemy;
    554.  
    555.     pev( Snark, pev_velocity, Velocity );
    556.     pev( Snark, pev_origin, Origin );
    557.  
    558.     if ( !UTIL_IsInWorld ( Origin, Velocity ) )
    559.     {
    560.         set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_KILLME );
    561.         return HAM_IGNORED;
    562.     }
    563.  
    564.     CurrentTime = get_gametime();
    565.     set_pev( Snark, pev_nextthink, CurrentTime + 0.1 );
    566.  
    567.     pev( Snark, pev_NextHunt, NextHunt );
    568.     pev( Snark, pev_DetonateDelay, DieDelay );
    569.     pev( Snark, pev_angles, Angles );
    570.  
    571.     if ( CurrentTime >= DieDelay )
    572.     {
    573.         if ( pev( Snark, pev_Remove ) )
    574.         {
    575.             set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_KILLME );
    576.             return HAM_IGNORED;
    577.         }
    578.  
    579.         set_pev( Snark, pev_health, -1.0 );
    580.         CSqueak_Killed ( Snark, 0, true );
    581.         return HAM_IGNORED;
    582.     }
    583.  
    584.     if ( pev( Snark, pev_waterlevel ) != 0 )
    585.     {
    586.         if ( pev( Snark, pev_movetype ) == MOVETYPE_BOUNCE )
    587.         {
    588.             set_pev( Snark, pev_movetype, MOVETYPE_FLY );
    589.         }
    590.  
    591.         VectorScale ( Velocity, 0.9, Velocity );
    592.         Velocity[ z ] += 8.0;
    593.  
    594.         set_pev( Snark, pev_velocity, Velocity );
    595.     }
    596.     else if ( pev( Snark, pev_movetype ) == MOVETYPE_FLY )
    597.     {
    598.         set_pev( Snark, pev_movetype, MOVETYPE_BOUNCE );
    599.     }
    600.  
    601.     if ( NextHunt > CurrentTime )
    602.     {
    603.         return HAM_IGNORED;
    604.     }
    605.  
    606.     set_pev( Snark, pev_NextHunt, CurrentTime + 2.0 );
    607.  
    608.     VectorCopy ( Velocity, Flat );
    609.     Flat[ z ] = 0.0;
    610.     VectorNormalize ( Flat, Flat );
    611.  
    612.     engfunc( EngFunc_MakeVectors, Angles );
    613.  
    614.     if ( ( Enemy = pev( Snark, pev_enemy ) ) == NULL_ENT || !is_user_alive( Enemy ) || !ze_is_user_zombie( Enemy ) )
    615.     {
    616.         Enemy = UTIL_BestVisibleEnemy ( Snark, 512.0 );
    617.     }
    618.  
    619.     if ( 0.3 <= DieDelay - CurrentTime <= 0.5 )
    620.     {
    621.         set_pev( Snark, pev_scale, 2.0 );
    622.         emit_sound( Snark, CHAN_VOICE, gSnarkDieSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM + random_num( 0, 0x3F ) );
    623.     }
    624.  
    625.     SPitch = 155.0 - 60.0 * ( ( DieDelay - CurrentTime ) / get_pcvar_float( pCvarDetonateDelay ) );
    626.  
    627.     if ( SPitch < 80.0 )  { SPitch = 80.0; }
    628.  
    629.     if ( Enemy != NULL_ENT && !ze_is_user_zombie( Enemy ) )
    630.     {
    631.         static Float:Target[ Coord_e ];
    632.         static Float:Vel;
    633.         static Float:Adj;
    634.  
    635.         pev( Snark, pev_EnemyTarget, Target );
    636.  
    637.         if ( UTIL_FVisible( Snark, Enemy ) )
    638.         {
    639.             static Float:EyePosition[ Coord_e ];
    640.             UTIL_EyePosition ( Enemy, EyePosition );
    641.  
    642.             VectorSubtract ( EyePosition, Origin, Target );
    643.             VectorNormalize ( Target, Target );
    644.  
    645.             set_pev( Snark, pev_EnemyTarget, Target );
    646.         }
    647.  
    648.         Vel = VectorLength ( Velocity );
    649.         Adj = 50.0 / ( Vel + 10.0 );
    650.  
    651.         if ( Adj > 1.2 )  { Adj = 1.2; }
    652.  
    653.         Velocity[ x ] = Velocity[ x ] * Adj + Target[ x ] * 300.0;
    654.         Velocity[ y ] = Velocity[ y ] * Adj + Target[ y ] * 300.0;
    655.         Velocity[ z ] = Velocity[ z ] * Adj + Target[ z ] * 300.0;
    656.  
    657.         set_pev( Snark, pev_velocity, Velocity );
    658.     }
    659.  
    660.     if ( pev( Snark, pev_flags ) & FL_ONGROUND )
    661.     {
    662.         set_pev( Snark, pev_avelocity, Float:{ 0.0, 0.0, 0.0 } );
    663.     }
    664.     else
    665.     {
    666.         static Float:AVelocity[ Coord_e ];
    667.         pev( Snark, pev_avelocity, AVelocity );
    668.  
    669.         if ( AVelocity[ x ] == 0.0 && AVelocity[ y ] == 0.0 && AVelocity[ z ] == 0.0 )
    670.         {
    671.             AVelocity[ x ] = random_float( -100.0, 100.0 );
    672.             AVelocity[ z ] = random_float( -100.0, 100.0 );
    673.  
    674.             set_pev( Snark, pev_avelocity, AVelocity );
    675.         }
    676.     }
    677.  
    678.     static Float:PosPrev[ Coord_e ];
    679.     pev( Snark, pev_PosPrev, PosPrev );
    680.  
    681.     VectorSubtract ( Origin, PosPrev, PosPrev );
    682.  
    683.     if ( VectorLength ( PosPrev ) < 1.0 )
    684.     {
    685.         Velocity[ x ] = random_float( -100.0, 100.0 );
    686.         Velocity[ y ] = random_float( -100.0, 100.0 );
    687.  
    688.         set_pev( Snark, pev_velocity, Velocity );
    689.     }
    690.  
    691.     set_pev( Snark, pev_PosPrev, Origin );
    692.  
    693.     vector_to_angle( Velocity, Angles );
    694.  
    695.     Angles[ z ] = 0.0;
    696.     Angles[ x ] = 0.0;
    697.  
    698.     set_pev( Snark, pev_angles, Angles );
    699.  
    700.     return HAM_IGNORED;
    701. }
    702.  
    703.  
    704. public CSqueak_SuperBounceTouch ( const Snark, const Other )
    705. {
    706.     if ( !is_valid_ent( Snark ) )
    707.     {
    708.         return;
    709.     }
    710.    
    711.     static Float:Angles [ Angle_e ];
    712.     static Float:NextHit;
    713.     static Float:DieDelay;
    714.     static Float:NextAttack;
    715.     static Float:NextBounceSoundTime;
    716.     static Float:SPitch;
    717.     static Float:CurrentTime;
    718.     static Owner;
    719.  
    720.     Owner = pev( Snark, pev_owner );
    721.  
    722.     if ( Owner && Other == Owner )
    723.     {
    724.         return;
    725.     }
    726.  
    727.     SPitch = PITCH_NORM * 1.0;
    728.     CurrentTime = get_gametime();
    729.  
    730.     set_pev( Snark, pev_owner, NULL_ENT );
    731.  
    732.     pev( Snark, pev_angles, Angles );
    733.     pev( Snark, pev_NextHit, NextHit );
    734.     pev( Snark, pev_DetonateDelay, DieDelay );
    735.     pev( Snark, pev_NextAttack, NextAttack );
    736.     pev( Snark, pev_NextBounceSoundTime, NextBounceSoundTime );
    737.  
    738.     Angles[ x ] = 0.0;
    739.     Angles[ z ] = 0.0;
    740.  
    741.     set_pev( Snark, pev_angles, Angles );
    742.  
    743.     if ( NextHit > CurrentTime )
    744.     {
    745.         return;
    746.     }
    747.  
    748.     SPitch = 155.0 - 60.0 * ( ( DieDelay - CurrentTime ) / get_pcvar_float( pCvarDetonateDelay ) );
    749.  
    750.     if ( 1 <= Other <= gMaxClients && pev( Other, pev_takedamage ) && NextAttack < CurrentTime )
    751.     {
    752.         static Hit;
    753.         Hit = global_get( glb_trace_ent );
    754.  
    755.         if ( Hit == Other && pev( Hit, pev_modelindex ) != pev( Snark, pev_modelindex ) && 1 <= Other <= gMaxClients )
    756.         {
    757.             Owner = pev( Snark, pev_RealOwner );
    758.            
    759.             if ( !ze_is_user_zombie( Other ) && GetAlivePlayersNum(CsTeams:TEAM_CT) == 1 )
    760.             {
    761.                 static Float:Forward    [ Coord_e ];
    762.                 static Float:EndPos     [ Coord_e ];
    763.                 static Float:OriginSnark[ Coord_e ];
    764.                 static Float:OriginOther[ Coord_e ];
    765.                 static Trace;
    766.                 static Float:Damage;
    767.  
    768.                 Trace = create_tr2();
    769.                    
    770.                 pev( Snark, pev_dmg, Damage );
    771.                 pev( Snark, pev_origin, OriginSnark );
    772.                 pev( Other, pev_origin, OriginOther );
    773.  
    774.                 engfunc( EngFunc_TraceLine, OriginSnark, OriginOther, DONT_IGNORE_MONSTERS, Snark, Trace );
    775.                    
    776.                 get_tr2( Trace, TR_vecPlaneNormal, Forward );
    777.                 get_tr2( Trace, TR_vecEndPos, EndPos );
    778.  
    779.                 ExecuteHam( Ham_TraceBleed, Other, Damage, Forward, Trace, DMG_SLASH );
    780.                 free_tr2( Trace );
    781.                    
    782.                 FX_BloodDrips ( EndPos, BLOOD_COLOR_RED_N, .Amount = floatround( Damage ) );
    783.                    
    784.                 ExecuteHam( Ham_TakeDamage, Other, Snark, Owner, Damage, DMG_SLASH );
    785.                 set_pev( Snark, pev_dmg, pev( Snark, pev_dmg ) + get_pcvar_float( pCvarDamagePop ) );
    786.             }
    787.             else
    788.             {
    789.                 ze_set_user_zombie( Other );
    790.                 ze_set_escape_coins( Owner, ze_get_escape_coins( Owner ) + 2 );
    791.                 set_user_frags( Owner, get_user_frags( Owner ) + 1 );
    792.                 set_pev( Snark, pev_enemy, NULL_ENT );
    793.             }
    794.            
    795.             emit_sound( Snark, CHAN_WEAPON, gSnarkAttackSound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
    796.             set_pev( Snark, pev_NextAttack, CurrentTime + 0.5 );
    797.         }
    798.     }
    799.  
    800.     set_pev( Snark, pev_NextHit, CurrentTime + 0.1 );
    801.     set_pev( Snark, pev_NextHunt, CurrentTime );
    802.  
    803.     if ( CurrentTime < NextBounceSoundTime )
    804.     {
    805.         return;
    806.     }
    807.  
    808.     if ( !( pev( Snark, pev_flags ) & FL_ONGROUND ) )
    809.     {
    810.         switch ( random( 10 ) )
    811.         {
    812.             case 0 .. 3 : emit_sound( Snark, CHAN_VOICE, gSnarkHunt1Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
    813.             case 4 .. 7 : emit_sound( Snark, CHAN_VOICE, gSnarkHunt2Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
    814.             default     : emit_sound( Snark, CHAN_VOICE, gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
    815.         }
    816.     }
    817.  
    818.     set_pev( Snark, pev_NextBounceSoundTime, CurrentTime + 0.5 );
    819. }
    820.  
    821.  
    822. CSqueak_Create ( const Player, const Float:Origin[ Coord_e ], const Float:Angles[ Coord_e], const Float:Velocity[ Coord_e ] )
    823. {
    824.     new Snark = create_entity( gGenericEntity );
    825.  
    826.     if ( is_valid_ent( Snark ) )
    827.     {
    828.         set_pev( Snark, pev_classname, gSnarkClassName );
    829.         set_pev( Snark, pev_groupinfo, gSnarkClassNameReference );
    830.         set_pev( Snark, pev_owner, Player );
    831.         set_pev( Snark, pev_origin, Origin );
    832.         set_pev( Snark, pev_angles, Angles );
    833.         set_pev( Snark, pev_velocity, Velocity );
    834.  
    835.         CSqueak_Spawn ( Player, Snark, Origin );
    836.  
    837.         return Snark;
    838.     }
    839.  
    840.     return NULL_ENT;
    841. }
    842.  
    843.  
    844. CSqueak_Spawn ( const Player, const Snark, const Float:Origin[ Coord_e ] )
    845. {
    846.     new Float:CurrentTime = get_gametime();
    847.  
    848.     set_pev( Snark, pev_movetype, MOVETYPE_BOUNCE );
    849.     set_pev( Snark, pev_solid, SOLID_BBOX );
    850.  
    851.     entity_set_model ( Snark, gSnarkModel );
    852.     entity_set_size  ( Snark, Float:{ -4.0, -4.0, 0.0 }, Float:{ 4.0, 4.0, 8.0 } );
    853.     entity_set_origin( Snark, Origin );
    854.  
    855.     set_pev( Snark, pev_nextthink, CurrentTime + 0.1 );
    856.  
    857.     set_pev( Snark, pev_NextHunt, CurrentTime + 1000000.0 ); // NextHunt
    858.     set_pev( Snark, pev_DetonateDelay, CurrentTime + get_pcvar_float( pCvarDetonateDelay ) ); // DetonateDelay
    859.     set_pev( Snark, pev_NextBounceSoundTime, CurrentTime ); // NextBounceSoundTime
    860.     set_pev( Snark, pev_RealOwner, Player ); // RealOwner
    861.  
    862.     set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_MONSTER );
    863.     set_pev( Snark, pev_takedamage, DAMAGE_AIM );
    864.     set_pev( Snark, pev_health, get_pcvar_float( pCvarHealth ) + gSnarkHealthReference );
    865.     set_pev( Snark, pev_gravity, get_pcvar_float( pCvarGravity ) );
    866.     set_pev( Snark, pev_friction, get_pcvar_float( pCvarFriction ) );
    867.     set_pev( Snark, pev_fov, get_pcvar_num( pCvarFieldOfView ) );
    868.     // set_pev( Snark, pev_dmg, get_pcvar_float( pCvarDamagePop ) );
    869.  
    870.     // --| Force snark to run.
    871.     set_pev( Snark, pev_sequence, wsqueak_run );
    872.     set_pev( Snark, pev_framerate, 1.0 );
    873.     set_pev( Snark, pev_animtime, CurrentTime );
    874.  
    875.     if ( get_pcvar_num( pCvarShowTrail ) )
    876.     {
    877.         message_begin ( MSG_BROADCAST, SVC_TEMPENTITY );
    878.         write_byte ( TE_BEAMFOLLOW );
    879.         write_short ( Snark );
    880.         write_short ( gSmokeTrail );
    881.         write_byte ( TRAIL_LIFE );   // life
    882.         write_byte ( TRAIL_WIDTH );  // width
    883.         write_byte ( TRAIL_RED );
    884.         write_byte ( TRAIL_GREEN );
    885.         write_byte ( TRAIL_BLUE );
    886.         write_byte ( TRAIL_BRIGTHNESS );
    887.         message_end();
    888.     }
    889. }
    890.  
    891.  
    892. public CSqueak_WeaponIdle ( const Player )
    893. {
    894.     if ( gHasSnark{ Player } && gWeaponActive{ Player } )
    895.     {
    896.         static Float:CurrentTime;
    897.         CurrentTime = get_gametime();
    898.  
    899.         if ( gTimeWeaponIdle[ Player ] > CurrentTime )
    900.         {
    901.             return;
    902.         }
    903.  
    904.         if ( gJustThrown{ Player } )
    905.         {
    906.             gJustThrown{ Player } = false;
    907.  
    908.             if ( !gPlayerAmmo{ Player } )
    909.             {
    910.                 RemoveWeapon ( Player, get_pdata_cbase( Player, 373 ) );
    911.                 return;
    912.             }
    913.  
    914.             UTIL_PlayWeaponAnimation ( Player, squeak_up );
    915.             gTimeWeaponIdle[ Player ] = CurrentTime + random_float ( 10.0, 15.0 );
    916.  
    917.             return;
    918.         }
    919.  
    920.         new Animation;
    921.         new Float:NewTime;
    922.  
    923.         switch ( random_num( 0, 10 ) )
    924.         {
    925.             case 0 .. 6 :
    926.             {
    927.                 Animation = squeak_idle1;
    928.                 NewTime   = 30.0 / 16.0 * ( 2.0 );
    929.             }
    930.             case 7 .. 8 :
    931.             {
    932.                 Animation = squeak_fidgetfit;
    933.                 NewTime   = 70.0 / 16.0;
    934.             }
    935.             default :
    936.             {
    937.                 Animation = squeak_fidgetnip;
    938.                 NewTime   = 80.0 / 16.0;
    939.             }
    940.         }
    941.  
    942.         UTIL_PlayWeaponAnimation ( Player, Animation );
    943.         gTimeWeaponIdle[ Player ] = CurrentTime + NewTime;
    944.     }
    945. }
    946.  
    947.  
    948. ChangeWeaponToSnark ( const Player )
    949. {
    950.     set_pev( Player, pev_viewmodel2  , gModel_V );
    951.     set_pev( Player, pev_weaponmodel2, gModel_P );
    952. }
    953.  
    954.  
    955. UpdateHud ( const Player )
    956. {
    957.     message_begin( MSG_ONE_UNRELIABLE, gMsgidAmmoX, .player = Player );
    958.     write_byte( 12 );
    959.     write_byte( gPlayerAmmo{ Player } );
    960.     message_end();
    961. }
    962.  
    963.  
    964. RemoveWeapon ( const Player, const Weapon )
    965. {
    966.     ExecuteHamB( Ham_Weapon_RetireWeapon, Weapon );
    967.     ExecuteHamB( Ham_RemovePlayerItem, Player, Weapon );
    968.     ExecuteHamB( Ham_Item_Kill, Weapon );
    969.  
    970.     set_pev( Player, pev_weapons, pev( Player, pev_weapons ) & ~( 1 << gWeaponIndex ) );
    971.     cs_set_user_bpammo( Player, gWeaponIndex, 0 );
    972.  
    973.     gHasSnark{ Player } = false;
    974.     gWeaponActive{ Player } = false;
    975. }
    976.  
    977.  
    978. stock bool:UTIL_IsBSPModel ( const Entity )
    979. {
    980.     return ( pev( entity, pev_solid ) == SOLID_BSP || pev( Entity, pev_movetype ) == MOVETYPE_STEP );
    981. }
    982.  
    983.  
    984. UTIL_BestVisibleEnemy ( const Snark, const Float:DistanceToSearch /* , const Flags */ )
    985. {
    986.     static List[ MAX_CLIENTS_N ];
    987.     static Float:Distance;
    988.     static Float:Nearest;
    989.     static ReturnEntity;
    990.     static Count;
    991.     static Entity;
    992.     static i;
    993.  
    994.     Nearest = 8192.0;
    995.     ReturnEntity = NULL_ENT;
    996.  
    997.     Count = find_sphere_class( Snark, "player", DistanceToSearch, List, sizeof List );
    998.  
    999.     for ( i = 0; i < Count; i++ )
    1000.     {
    1001.         Entity = List[ i ];
    1002.        
    1003.         if ( ze_is_user_zombie( Entity ) )
    1004.         {
    1005.             continue;
    1006.         }
    1007.  
    1008.         if ( UTIL_FInViewCone ( Snark, Entity ) && UTIL_FVisible( Snark, Entity ) )
    1009.         {
    1010.             if ( ( Distance = entity_range( Snark, Entity ) ) <= Nearest )
    1011.             {
    1012.                 Nearest = Distance;
    1013.                 ReturnEntity = Entity;
    1014.             }
    1015.         }
    1016.     }
    1017.  
    1018.     set_pev( Snark, pev_enemy, ReturnEntity );
    1019.     return ReturnEntity;
    1020. }
    1021.  
    1022.  
    1023.  
    1024. UTIL_PlayWeaponAnimation ( const Player, const Sequence )
    1025. {
    1026.     set_pev( Player, pev_weaponanim, Sequence );
    1027.  
    1028.     message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player );
    1029.     write_byte( Sequence );
    1030.     write_byte( pev( Player, pev_body ) );
    1031.     message_end();
    1032. }
    1033.  
    1034.  
    1035. bool:UTIL_IsInWorld ( const Float:Origin[ Coord_e ], const Float:Velocity[ Coord_e ] )
    1036. {
    1037.     static i;
    1038.  
    1039.     for ( i = x; i <= z; i++ )
    1040.     {
    1041.         if ( !( -4096.0 < Origin[ i ] < 4096.0 ) && !( -2000.0 < Velocity[ x ] < 2000.0 ) )
    1042.         {
    1043.             return false;
    1044.         }
    1045.     }
    1046.  
    1047.     return true;
    1048. }
    1049.  
    1050.  
    1051. UTIL_RandomBloodVector ( Float:Direction[ Coord_e ] )
    1052. {
    1053.     Direction[ x ] = random_float( -1.0, 1.0 );
    1054.     Direction[ y ] = random_float( -1.0, 1.0 );
    1055.     Direction[ z ] = random_float(  0.0, 1.0 );
    1056. }
    1057.  
    1058.  
    1059. FX_BloodDrips ( const Float:Origin[ Coord_e ], const BloodColor, const Amount )
    1060. {
    1061.     message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, NULL_ENT );
    1062.     write_byte( TE_BLOODSPRITE );
    1063.     write_coord_f( Origin[ x ] );
    1064.     write_coord_f( Origin[ y ] );
    1065.     write_coord_f( Origin[ z ] );
    1066.     write_short( gBloodSpray );         // initial sprite model
    1067.     write_short( gBloodDrop );          // droplet sprite models
    1068.     write_byte( BloodColor );           // color index into host_basepal
    1069.     write_byte( min( max( 3, ( Amount > 255 ? 255 : Amount ) / 10 ), 16 ) );  // size
    1070.     message_end();
    1071. }
    1072.  
    1073.  
    1074. FX_StreakSplash ( const Float:Origin[ Coord_e ], const Float:Direction[ Coord_e ], const Color, const Count, const Speed, const VelocityRange )
    1075. {
    1076.     message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, NULL_ENT );
    1077.     write_byte( TE_STREAK_SPLASH );
    1078.     write_coord_f( Origin[ x ] );
    1079.     write_coord_f( Origin[ y ] );
    1080.     write_coord_f( Origin[ z ] );
    1081.     write_coord_f( Direction[ x ] );
    1082.     write_coord_f( Direction[ y ] );
    1083.     write_coord_f( Direction[ z ] );
    1084.     write_byte( min( Color, 255 ) );
    1085.     write_short( Count );
    1086.     write_short( Speed );
    1087.     write_short( VelocityRange );// random velocity modifier
    1088.     message_end();
    1089. }
    1090.  
    1091.  
    1092. stock FX_TraceBleed( const Victim, const Float:Damage, const Float:Dir[ Coord_e ], const TraceResult:Trace )
    1093. {
    1094.     new TraceResult:BloodTrace;
    1095.     new Float:TraceDir[ Coord_e ];
    1096.     new Float:EndPos  [ Coord_e ];
    1097.     new Float:Noise;
    1098.     new Float:Fraction;
    1099.     new Count;
    1100.  
    1101.     if ( Damage < 10 )
    1102.     {
    1103.         Noise = 0.1;
    1104.         Count = 1;
    1105.     }
    1106.     else if ( Damage < 25 )
    1107.     {
    1108.         Noise = 0.2;
    1109.         Count = 2;
    1110.     }
    1111.     else
    1112.     {
    1113.         Noise = 0.3;
    1114.         Count = 4;
    1115.     }
    1116.  
    1117.     for ( new i = 0 ; i < Count ; i++ )
    1118.     {
    1119.         VectorScale ( Dir, -1.0, TraceDir );
    1120.  
    1121.         TraceDir[ x ] += random_float( -Noise, Noise );
    1122.         TraceDir[ y ] += random_float( -Noise, Noise );
    1123.         TraceDir[ z ] += random_float( -Noise, Noise );
    1124.        
    1125.         get_tr2( Trace, TR_vecEndPos, EndPos );
    1126.         VectorMA ( EndPos, -172.0, TraceDir, TraceDir );
    1127.        
    1128.         engfunc( EngFunc_TraceLine, EndPos, TraceDir, IGNORE_MONSTERS, Victim, BloodTrace );
    1129.         get_tr2( BloodTrace, TR_flFraction, Fraction );
    1130.  
    1131.         if ( Fraction != 1.0 )
    1132.         {
    1133.             FX_BloodDecalTrace( BloodTrace, EndPos, BLOOD_COLOR_RED_N );
    1134.         }
    1135.     }
    1136. }
    1137.  
    1138.  
    1139. stock FX_BloodDecalTrace ( const TraceResult:Trace, const Float:EndPos[ Coord_e ], const BloodColor )
    1140. {
    1141.     new Hit;
    1142.     new BaseIndex;
    1143.     new DecalIndex;
    1144.     new Float:Fraction;
    1145.  
    1146.     switch ( BloodColor )
    1147.     {
    1148.         case BLOOD_COLOR_YELLOW_N : BaseIndex = get_decal_index( "{yblood1" );
    1149.         case BLOOD_COLOR_RED_N    : BaseIndex = get_decal_index( "{blood1" );
    1150.     }
    1151.    
    1152.     DecalIndex = BaseIndex + random_num( 0, 5 );
    1153.  
    1154.     Hit = max( 0, get_tr2( Trace, TR_pHit ) );
    1155.     get_tr2( Trace, TR_flFraction, Fraction );
    1156.  
    1157.     if ( Fraction == 1.0 || ( Hit && !UTIL_IsBSPModel ( Hit ) ) )
    1158.     {
    1159.         return;
    1160.     }  
    1161.    
    1162.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
    1163.     write_byte( Hit ? TE_DECAL : TE_WORLDDECAL );
    1164.     write_coord_f( EndPos[ x ] );
    1165.     write_coord_f( EndPos[ y ] );
    1166.     write_coord_f( EndPos[ z ] );
    1167.     write_byte( DecalIndex );
    1168.     if ( Hit )
    1169.     {
    1170.         write_short( Hit );
    1171.     }
    1172.     message_end();
    1173. }
    1174.  
    1175.  
    1176. stock UTIL_RadiusDamage ( const Float:Origin[ Coord_e ], const Inflictor, const Attacker, const Float:Damage, const Float:Radius, const DamageBits )
    1177. {
    1178.     static Entity;
    1179.     static Trace;
    1180.     static Float:AdjustedDamage;
    1181.     static bool:InWater;
    1182.  
    1183.     Entity = NULL_ENT;
    1184.     InWater = UTIL_LiquidContents( Origin );
    1185.  
    1186.     while ( ( Entity = find_ent_in_sphere( Entity, Origin, Radius ) ) != NULL_ENT )
    1187.     {
    1188.         if ( Entity == Inflictor )
    1189.         {
    1190.             continue;
    1191.         }
    1192.  
    1193.         if ( pev( Entity, pev_takedamage ) && !ze_is_user_zombie( Entity ) && !(GetAlivePlayersNum(CsTeams:TEAM_CT) == 1) )
    1194.         {
    1195.             static Float:EntOrigin[ Coord_e ];
    1196.             static Float:EndPos   [ Coord_e ];
    1197.             static Float:Fraction;
    1198.  
    1199.             pev( Entity, pev_origin, EntOrigin );
    1200.  
    1201.             engfunc( EngFunc_TraceLine, Origin, EntOrigin, IGNORE_MONSTERS, Inflictor, Trace );
    1202.  
    1203.             get_tr2( Trace, TR_flFraction, Fraction );
    1204.             get_tr2( Trace, TR_vecEndPos, EndPos );
    1205.  
    1206.             if ( Fraction == 1.0 || get_tr2( Trace, TR_pHit ) == Entity )
    1207.             {
    1208.                 static Float:Delta[ Coord_e ];
    1209.                 static Float:Len;
    1210.  
    1211.                 if ( get_tr2( Trace, TR_StartSolid ) )
    1212.                 {
    1213.                     EndPos = Origin;
    1214.                     Fraction = 0.0;
    1215.                 }
    1216.  
    1217.                 AdjustedDamage = Damage;
    1218.                 VectorSubtract ( EndPos, Origin, Delta );
    1219.  
    1220.                 if ( ( Len = VectorLength ( Delta ) ) != 0.0 )
    1221.                 {
    1222.                     VectorScale ( Delta, 1 / Len, Delta );
    1223.                 }
    1224.  
    1225.                 if ( Len > 2.0 )
    1226.                 {
    1227.                     Len -= 2.0;
    1228.                 }
    1229.  
    1230.                 if ( ( AdjustedDamage *= ( 1.0 - Len / Radius ) ) <= 0 )
    1231.                 {
    1232.                     continue;
    1233.                 }
    1234.  
    1235.                 if ( InWater || pev( Entity, pev_waterlevel ) > 2 )
    1236.                 {
    1237.                     AdjustedDamage *= 0.5;
    1238.                 }
    1239.  
    1240.                 if ( Fraction != 1.0 )
    1241.                 {
    1242.                     ExecuteHam( Ham_TraceAttack, Entity, Inflictor, AdjustedDamage, Delta, Trace, DamageBits );
    1243.                     ExecuteHam( Ham_TakeDamage, Entity, Inflictor, Attacker, AdjustedDamage, DamageBits );
    1244.                 }
    1245.                 else
    1246.                 {
    1247.                     ExecuteHam( Ham_TakeDamage, Entity, Inflictor, Attacker, AdjustedDamage, DamageBits );
    1248.                 }
    1249.             }
    1250.         }
    1251.     }
    1252. }
    1253.  
    1254.  
    1255. stock UTIL_EntitiesInBox ( List[], const ListMax, const Float:Mins[ Coord_e ], const Float:Maxs[ Coord_e ], const Flags )
    1256. {
    1257.     /*
    1258.     static Float:Origin [ Coord_e ];
    1259.     static Float:Delta  [ Coord_e ];
    1260.     static Float:Mins   [ Coord_e ];
    1261.     static Float:Maxs   [ Coord_e ];
    1262.  
    1263.     pev( Snark, pev_origin, Origin );
    1264.  
    1265.     Delta[ x ] = Delta[ y ] = Delta[ z ] = DistanceToSearch;
    1266.  
    1267.     VectorSubtract ( Origin, Delta, Mins );
    1268.     VectorAdd ( Origin, Delta, Maxs );
    1269.  
    1270.     Count = UTIL_EntitiesInBox ( List, sizeof List, Mins, Maxs, Flags );
    1271.     */
    1272.  
    1273.     static Float:AbsMins[ Coord_e ];
    1274.     static Float:AbsMaxs[ Coord_e ];
    1275.     static Count;
    1276.     static Entity;
    1277.  
    1278.     Count = 0;
    1279.  
    1280.     for ( Entity = 1; Entity <= gMaxEntities; Entity++ )  if( is_valid_ent( Entity ) )
    1281.     {
    1282.         if ( !( pev( Entity, pev_flags ) & Flags ) )
    1283.         {
    1284.             continue;
    1285.         }
    1286.  
    1287.         pev( Entity, pev_absmin, AbsMins );
    1288.         pev( Entity, pev_absmax, AbsMaxs );
    1289.  
    1290.         if ( Mins[ x ] > AbsMaxs[ x ] || Mins[ y ] > AbsMaxs[ y ] || Mins[ z ] > AbsMaxs[ z ] ||
    1291.              Maxs[ x ] < AbsMins[ x ] || Maxs[ y ] < AbsMins[ y ] || Maxs[ z ] < AbsMins[ z ] )
    1292.         {
    1293.             continue;
    1294.         }
    1295.  
    1296.         List[ Count ] = Entity;
    1297.  
    1298.         if ( Count++ >= ListMax )
    1299.         {
    1300.             return Count;
    1301.         }
    1302.     }
    1303.  
    1304.     return Count;
    1305. }
    1306.  
    1307.  
    1308. bool:UTIL_FVisible ( const Entity, const Other )
    1309. {
    1310.     static Float:LookerOrigin[ Coord_e ];
    1311.     static Float:TargetOrigin[ Coord_e ];
    1312.     static Float:Fraction;
    1313.     static LookerWLevel;
    1314.     static TargetWLevel;
    1315.  
    1316.     if ( pev( Other, pev_flags ) & FL_NOTARGET )
    1317.     {
    1318.         return false;
    1319.     }
    1320.  
    1321.     LookerWLevel = pev ( Entity, pev_waterlevel );
    1322.     TargetWLevel = pev ( Other, pev_waterlevel );
    1323.  
    1324.     if ( ( LookerWLevel != 3 && TargetWLevel == 3 ) || ( LookerWLevel == 3 && TargetWLevel == 0  ) )
    1325.     {
    1326.         return false;
    1327.     }
    1328.  
    1329.     UTIL_EyePosition ( Entity, LookerOrigin );
    1330.     UTIL_EyePosition ( Other, TargetOrigin );
    1331.  
    1332.     engfunc( EngFunc_TraceLine, LookerOrigin, TargetOrigin, IGNORE_MONSTERS | IGNORE_GLASS, Entity, 0 );
    1333.     get_tr2( 0, TR_flFraction, Fraction );
    1334.  
    1335.     return Fraction == 1.0 ? true : false;
    1336. }
    1337.  
    1338.  
    1339. bool:UTIL_FInViewCone ( const Entity, const Other )
    1340. {
    1341.     static Float:Angles [ Coord_e ];
    1342.     static Float:HOrigin[ Coord_e ];
    1343.     static Float:Origin [ Coord_e ];
    1344.  
    1345.     pev( Entity, pev_angles, Angles );
    1346.     engfunc( EngFunc_MakeVectors, Angles );
    1347.     global_get( glb_v_forward, Angles );
    1348.  
    1349.     Angles[ z ] = 0.0;
    1350.  
    1351.     pev( Entity, pev_origin, HOrigin );
    1352.     pev( Other, pev_origin, Origin );
    1353.  
    1354.     VectorSubtract ( Origin, HOrigin, Origin );
    1355.     Origin[ z ] = 0.0;
    1356.  
    1357.     VectorNormalize ( Origin, Origin );
    1358.  
    1359.     if ( DotProduct ( Origin, Angles ) > pev( Entity, pev_fov ) )
    1360.     {
    1361.         return true;
    1362.     }
    1363.  
    1364.     return false;
    1365. }
    1366.  
    1367.  
    1368. UTIL_EyePosition ( const Entity, Float:Origin[ Coord_e ] )
    1369. {
    1370.     static Float:ViewOfs[ Coord_e ];
    1371.  
    1372.     pev( Entity, pev_origin, Origin );
    1373.     pev( Entity, pev_view_ofs, ViewOfs );
    1374.  
    1375.     VectorAdd ( Origin, ViewOfs, Origin );
    1376. }
    1377.  
    1378.  
    1379. stock bool:UTIL_LiquidContents( const Float:Source[ Coord_e ] )
    1380. {
    1381.     new Contents = point_contents( Source );
    1382.     return ( Contents == CONTENTS_WATER || Contents == CONTENTS_SLIME || Contents == CONTENTS_LAVA );
    1383. }
    1384.  
    1385.  
    1386. VectorNormalize ( const Float:Source[ Coord_e ], Float:Output[ Coord_e ] )
    1387. {
    1388.     static Float:InvLen;
    1389.  
    1390.     InvLen = 1.0 / VectorLength ( Source );
    1391.  
    1392.     Output[ x ] = Source[ x ] * InvLen;
    1393.     Output[ y ] = Source[ y ] * InvLen;
    1394.     Output[ z ] = Source[ z ] * InvLen;
    1395. }
    1396.  
    1397.  
Demo:

Video (YouTube)

https://www.youtube.com/watch?v=yxk2eWpw8QQ



Download:
ze_extra_squeakgrenade.zip
(10.58 KiB) Downloaded 480 times
ze_extra_squeakgrenade.zip
(10.58 KiB) Downloaded 480 times

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#2

Post by Rain1153 » 5 years ago

How can u fix when raheem can't fix it? Interesting 😂
LOL

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#3

Post by Mark » 5 years ago

Rain1153 wrote: 5 years ago How can u fix when raheem can't fix it? Interesting 😂
Try it

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#4

Post by czirimbolo » 5 years ago

It works fine, but can you block infecting zombies by snark? When some have Heroine class, he will lose it after being touched by snark
Image

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#5

Post by Rain1153 » 5 years ago

ohkay bro good job btw
LOL

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#6

Post by Raheem » 5 years ago

Rain1153 wrote: 5 years ago How can u fix when raheem can't fix it? Interesting 😂
I don't say that i tried fixing it and failed but i said i will not have time to do.

[mention]Mark[/mention], Good job thanks.
He who fails to plan is planning to fail

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#7

Post by czirimbolo » 5 years ago

L 11/12/2018 - 16:49:30: Start of error session.
L 11/12/2018 - 16:49:30: Info (map "zm_westwood") (file "addons/amxmodx/logs/error_20181112.log")
L 11/12/2018 - 16:49:30: [ZE] Invalid Player id (24)
L 11/12/2018 - 16:49:30: [AMXX] Displaying debug trace (plugin "ze_extra_zombie_snark_infector.amxx", version "1.0.6-wwm")
L 11/12/2018 - 16:49:30: [AMXX] Run time error 10: native error (native "ze_get_escape_coins")
L 11/12/2018 - 16:49:30: [AMXX] [0] ze_extra_zombie_snark_infector.sma::CSqueak_SuperBounceTouch (line 792)

can someone fix this?
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#8

Post by czirimbolo » 2 years ago

@ Raheem
@ Mark

can you improve this plugin? Its crashing and needs some fix
Image

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#9

Post by z0h1r-LK » 2 years ago

czirimbolo wrote: 2 years ago @ Raheem
@ Mark

can you improve this plugin? Its crashing and needs some fix
I will try bro

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: Bing [Bot] and 2 guests