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

[REQ/HELP] Fixing Arkshine's Snark Infector


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-16-2015 , 12:49   [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #1

Later Edit:

Im using this lightly edited version of Arkshine's Snark Infector

The problem is i encounter run time errors, could anyone help me fix them?


P.S: I know this more like a request, but i rather edit my old thread about the issue, than create a new one in the request section

Spoiler


Spoiler


Spoiler


PHP Code:
/* - - - - - - - - - - -

AMX Mod X script.

| Author  : ARKSHINE
| Plugin  : WPN Squea2 Grenade
| Version : v1.0.6 - without WM.

(!) Support : http://forums.alliedmods.net/showthread.php?t=93659
(!) Version without WeaponMod required and for Zombie Plague.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

- - - - - - - - - - - */

#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <engine>
#include <zp50_core>
#include <zp50_class_hive>
#include <fun>
#include <dhudmessage>

#define Plugin   "[ZP] Extra: Squea2 Grenade"
#define Version  "1.0.6-wwm"
#define Author   "ARKSHINE"

// --| Comment if you want to use the default model from valve.
#define ALTERNATIVE_MODEL

// --| Snark trail.
#define TRAIL_LIFE        15    // Life
#define TRAIL_WIDTH       4     // Width
#define TRAIL_RED         10    // Red
#define TRAIL_GREEN       224   // Red
#define TRAIL_BLUE        10    // Green
#define TRAIL_BRIGTHNESS  200   // Blue


/* - - -
|  WEAPON MODELS  |
- - - */
new const gModel_P[] = "models/adn_models/adn_p_insect.mdl";
new const 
gModel_V[] = "models/adn_models/adn_v_insect2.mdl";

/* - - -
|  SNARK SOUNDS  |
- - - */
new const gSnarkHunt1Sound[] = "squeek/sqk_hunt1.wav";
new const 
gSnarkHunt2Sound[] = "squeek/sqk_hunt2.wav";
new const 
gSnarkHunt3Sound[] = "squeek/sqk_hunt3.wav";
new const 
gSnarkDieSound[] = "squeek/sqk_die1.wav";
new const 
gSnarkAttackSound[] = "squeek/sqk_deploy1.wav";
new const 
gSnarkBlastSound[] = "squeek/sqk_blast1.wav";
new const 
gSnarkBodySplatSound[] = "common/bodysplat.wav";

/* - - -
|  SNARK MODEL  |
- - - */

new gSnarkModel[] = "models/adn_models/adn_w_insect2.mdl";

/* - - -
|    SEQUENCE   |
- - - */
enum
{
    
wsqueak_idle1,
    
wsqueak_fidget,
    
wsqueak_jump,
    
wsqueak_run
};

enum
{
    
squeak_idle1,
    
squeak_fidgetfit,
    
squeak_fidgetnip,
    
squeak_down,
    
squeak_up,
    
squeak_throw
};

/* - -
|  CONSTANTS  |
- - */
const BLOOD_COLOR_RED 247;
const 
BLOOD_COLOR_YELLOW 195;

const 
MAX_CLIENTS 32;
const 
MAX_KNIFE_MODEL_LENGTH 128;
const 
NONE = -1;
const 
NULL_ENT 0;

enum _:Coord_e
{
    
Float:x,
    
Float:y,
    
Float:z
};

enum _:Angle_e
{
    
Float:Pitch,
    
Float:Yaw,
    
Float:Roll
};

enum
{
    
HuntThink 1,
    
SuperBounceTouch,
    
RemoveSnark
};

new const 
Float:gHullMinCoord_e ] = { -16.0, -16.0, -36.0 };
new const 
Float:gDuckHullMinCoord_e ] = { -16.0, -16.0, -18.0 };

new const 
gWeaponCommand[] = "weapon_hegrenade";
new const 
gWeaponIndex CSW_HEGRENADE;

new const 
gGenericEntity[] = "info_target";
new const 
gSnarkClassName[] = "wpn_snark";

/* - - - -
|  PLAYER/WEAPON OFFSETS  |
- - - - */
const m_flNextAttack 83    // Player.
const m_pActiveWeapon 373;  // Player.
const m_pPlayer 41;   // Weapon.
const m_flNextPrimaryAttack 46;   // Weapon.

/* - - -
|  CUSTOM FIELD  |
- - - */
#define pev_NextHunt            pev_fuser1
#define pev_NextBounceSoundTime pev_fuser2
#define pev_NextHit             pev_fuser3
#define pev_NextAttack          pev_fuser4
#define pev_DetonateDelay       pev_ltime
#define pev_RealOwner           pev_iuser1
#define pev_Remove              pev_iuser2
#define pev_EnemyTarget         pev_vuser1
#define pev_PosPrev             pev_vuser2

/* - - -
|  CVAR POINTER  |
- - - */
new pCvarAmmo;
new 
pCvarRefireRate;
new 
pCvarHealth;
new 
pCvarVelocity;
new 
pCvarDamage;
new 
pCvarDamagePop;
new 
pCvarDamageRadius;
new 
pCvarGravity;
new 
pCvarFriction;
new 
pCvarDetonateDelay;
new 
pCvarFieldOfView;
new 
pCvarShowTrail;
new 
pCvarCooldown;

/* - - - -
|  SPRITES/MODELS INDEX  |
- - - - */
new gBloodSpray;
new 
gBloodDrop;
new 
gSmokeTrail;

/* - - - -
|  OTHERS STUFFS  |
- - - */
new bool:gHasSnark    MAX_CLIENTS 1 char ];
new 
bool:gWeaponActiveMAX_CLIENTS 1 char ];
new 
bool:gJustThrown  MAX_CLIENTS 1 char ];

new 
Float:gNextShot      MAX_CLIENTS ];
new 
Float:gTimeWeaponIdleMAX_CLIENTS ];

new 
gPlayerAmmoMAX_CLIENTS 1 char ];

new const 
gSnarkHealthReference 10000;
new 
gSnarkClassNameReference;
new 
gMaxEntities;
new 
gMaxClients;
new 
gMsgidAmmoX;


/* - -
|  MACROS  |
- - */
#define VectorSubtract(%1,%2,%3)  ( %3[ x ] = %1[ x ] - %2[ x ], %3[ y ] = %1[ y ] - %2[ y ], %3[ z ] = %1[ z ] - %2[ z ] )
#define VectorAdd(%1,%2,%3)       ( %3[ x ] = %1[ x ] + %2[ x ], %3[ y ] = %1[ y ] + %2[ y ], %3[ z ] = %1[ z ] + %2[ z ] )
#define VectorCopy(%1,%2)         ( %2[ x ] = %1[ x ],  %2[ y ] = %1[ y ], %2[ z ] = %1[ z ] )
#define VectorScale(%1,%2,%3)     ( %3[ x ] = %2 * %1[ x ], %3[ y ] = %2 * %1[ y ], %3[ z ] = %2 * %1[ z ] )
#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 ] )
#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 ] )
#define VectorLength(%1)          ( floatsqroot ( %1[ x ] * %1[ x ] + %1[ y ] * %1[ y ] + %1[ z ] * %1[ z ] ) )
#define VectorEqual(%1,%2)        ( %1[ x ] == %2[ x ] && %1[ y ] == %2[ y ] && %1[ z ] == %2[ z ] )
#define DotProduct(%1,%2)         ( %1[ x ] * %2[ x ]+ %1[ y ] * %2[ y ] + %1[ z ] * %2[ z ] )

#define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
#define write_coord_f(%1)         ( engfunc ( EngFunc_WriteCoord, %1 ) )


public plugin_precache ()
{
    
// --| Weapon models.
    
precache_modelgModel_P );
    
precache_modelgModel_V );
    
    
// --| Snark model.
    
precache_modelgSnarkModel );
    
    
// --| Snark sounds.
    
precache_soundgSnarkBlastSound );
    
precache_soundgSnarkBodySplatSound );
    
precache_soundgSnarkDieSound );
    
precache_soundgSnarkHunt1Sound );
    
precache_soundgSnarkHunt2Sound );
    
precache_soundgSnarkHunt3Sound );
    
precache_soundgSnarkAttackSound );
    
    
gBloodSpray precache_model"sprites/bloodspray.spr" );   // initial blood
    
gBloodDrop  precache_model"sprites/blood.spr" );        // splattered blood
}


public 
plugin_init ()
{
    
register_pluginPluginVersionAuthor );
    
register_cvar"zp_snark_version"VersionFCVAR_SERVER FCVAR_SPONLY );
    
    
pCvarAmmo          register_cvar"zp_insect_ammo"           "25"   );
    
pCvarRefireRate    register_cvar"zp_insect_fire"    "0.1" );
    
pCvarHealth        register_cvar"zp_insect_health"         "16"  );
    
pCvarVelocity      register_cvar"zp_insect_velocity"       "200" );
    
pCvarDamage     register_cvar"zp_insect_damage"         "15"   );
    
pCvarDamagePop     register_cvar"zp_insect_damage_pop"     "10"   );
    
pCvarDamageRadius  register_cvar"zp_insect_damage_radius"  "15"  );
    
pCvarGravity       register_cvar"zp_insect_gravity"        "0.3" );
    
pCvarFriction      register_cvar"zp_insect_friction"       "0.3" );
    
pCvarDetonateDelay register_cvar"zp_insect_life" "480"  );
    
pCvarFieldOfView   register_cvar"zp_insect_fov"            "2000"   );
    
pCvarShowTrail     register_cvar"zp_insect_glow"     "1"   );
    
pCvarCooldown      register_cvar"zp_insect_cooldown"     "60"   );
    
    
register_logevent("logevent_round_end"2"1=Round_End"
    
    
RegisterHamHam_Item_Deploy gWeaponCommand"CSqueak_Deploy");
    
RegisterHamHam_Item_HolstergWeaponCommand"CSqueak_Holster");
    
RegisterHamHam_TakeDamagegGenericEntity"CSqueak_TakeDamage");
    
    
register_forwardFM_CmdStart"CSqueak_HookButtons" );
    
register_forwardFM_PlayerPreThink"CSqueak_WeaponIdle" );
    
    
register_thinkgSnarkClassName"CSqueak_HuntThink" );
    
register_touchgSnarkClassName"*""CSqueak_SuperBounceTouch" );
    
    
// register_clcmd( "say test", "CSqueak_GiveWeapon" );
    
    
gMaxEntities global_getglb_maxEntities );
    
gMaxClients  global_getglb_maxClients );
    
    
gSnarkClassNameReference engfuncEngFunc_AllocStringgSnarkClassName );
    
gMsgidAmmoX get_user_msgid"AmmoX" );
    
    if ( 
get_pcvar_numpCvarShowTrail ) )
    {
        
gSmokeTrail engfuncEngFunc_PrecacheModel"sprites/smoke.spr" );
    }

}


public 
logevent_round_end()
{
    new 
Snark = -1;
    
    while ( ( 
Snark find_ent_by_classSnarkgSnarkClassName ) ) != NULL_ENT )
    {
        
CSqueak_Killed Snark0true );
    }
    
    for ( new 
Player 1Player <= gMaxClientsPlayer++ )
    {
        
CheckAndRemoveWeapon Player );
    }
    for(new 
id 1id <= get_maxplayers(); id++) 
    {
        
remove_task(id)
    }


public 
zp_fw_core_cure_post(id)
{
    
CheckAndRemoveWeapon(id)
}

public 
zp_fw_core_infect_post(id)
{
    if(
is_user_alive(id) && zp_core_is_zombie(id) && zp_class_hive_get(id))
    {
        
iGive(id)
    }
}


stock CheckAndRemoveWeapon ( const Player )
{
    if ( 
user_has_weaponPlayergWeaponIndex ) )
    {
        
RemoveWeapon Playerget_user_weaponPlayer ) == gWeaponIndex 
    
        
get_pdata_cbasePlayerm_pActiveWeapon ) : 
        
find_ent_by_owner ( -1gWeaponCommandPlayer ) );
    }
}


public 
client_connect Player )
{
    
gHasSnark    Player } = false;
    
gWeaponActivePlayer } = false;
    
gJustThrown  Player } = false;
    
gPlayerAmmo  Player } = 0;
}

public 
client_disconnect(Player)
{
    
remove_task(Player)
}


public 
CSqueak_GiveWeapon( const Player )
{
    
gHasSnarkPlayer } = true;
    
gPlayerAmmoPlayer } = get_pcvar_numpCvarAmmo );
    
    
give_itemPlayergWeaponCommand );
    
engclient_cmdPlayergWeaponCommand );
}


public 
CSqueak_PrimaryAttack ( const Player )
{
    static 
Float:VAngle     Angle_e ];
    static 
Float:Origin     Coord_e ];
    static 
Float:TraceOriginCoord_e ];
    static 
Float:Forward    Coord_e ];
    static 
Float:Start      Coord_e ];
    static 
Float:End        Coord_e ];
    static 
Float:EndPos     Coord_e ];
    static 
Float:Velocity   Coord_e ];
    static 
Float:Fraction;

    if ( 
gPlayerAmmoPlayer } )
    {
        if ( 
pevPlayerpev_waterlevel ) >= )
        {
            
emit_soundPlayerCHAN_WEAPONgSnarkDieSoundVOL_NORMATTN_NORM0PITCH_NORM );
            
gNextShotPlayer ] = get_gametime() + get_pcvar_floatpCvarRefireRate );
        
            return 
PLUGIN_HANDLED;
        }

        
pevPlayerpev_originOrigin );
        
pevPlayerpev_v_angleVAngle );
        
pevPlayerpev_velocityVelocity );
        
        
engfuncEngFunc_MakeVectorsVAngle );
        
        
VectorCopyOriginTraceOrigin );

        if ( 
pevPlayerpev_flags ) & FL_DUCKING )
        {
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
        }

        
global_getglb_v_forwardForward );
        
        
VectorMA TraceOrigin20.0ForwardStart );
        
VectorMA TraceOrigin64.0ForwardEnd );
        
        
engfuncEngFunc_TraceLineStartEndDONT_IGNORE_MONSTERSNULL_ENT);
        
        
get_tr20TR_FractionFraction );
        
get_tr20TR_vecEndPosEndPos );

        if ( !
get_tr20TR_AllSolid ) && !get_tr20TR_StartSolid ) && Fraction 0.25 )
        {
            
// --| Play the throw animation.
            
UTIL_PlayWeaponAnimation Playersqueak_throw );
            
            
// --| player "shoot" animation
            //
            
            
VectorMA Velocityget_pcvar_floatpCvarVelocity ), ForwardVelocity );

            if ( 
CSqueak_Create PlayerEndPosVAngleVelocity ) )
            {
                new 
Float:CurrentTime get_gametime();
                
                switch ( 
random_num0) )
                {
                    case 
0emit_soundPlayerCHAN_WEAPONgSnarkHunt1SoundVOL_NORMATTN_NORM0PITCH_NORM );
                    case 
1emit_soundPlayerCHAN_WEAPONgSnarkHunt2SoundVOL_NORMATTN_NORM0PITCH_NORM );
                    case 
2emit_soundPlayerCHAN_WEAPONgSnarkHunt3SoundVOL_NORMATTN_NORM0PITCH_NORM );
                }
    
                
gPlayerAmmoPlayer }--;
                
gJustThrownPlayer } = true;
                
                
UpdateHud Player );
                
                
gNextShotPlayer ] = CurrentTime get_pcvar_floatpCvarRefireRate );
                
gTimeWeaponIdlePlayer ] = CurrentTime 1.0;
                
                return 
PLUGIN_CONTINUE;
            }
        }
    }
    return 
PLUGIN_HANDLED;
}


public 
CSqueak_Deploy ( const Weapon )
{
    
// --| Get the knife's owner index.
    
new Player get_pdata_cbaseWeaponm_pPlayer);
    
    if ( 
Player && gHasSnarkPlayer } )
    {
        
// --| Change knife to snark weapon.
        
ChangeWeaponToSnark Player );
        
        
// --| Play the deploy animation.
        
UTIL_PlayWeaponAnimation Playersqueak_up );
        
emit_sound WeaponCHAN_VOICE random_float 0.01.0 ) <= 0.5 gSnarkHunt2Sound gSnarkHunt3SoundVOL_NORMATTN_NORM0PITCH_NORM );
        
        
// --| Block the primary attack.
        
set_pdata_floatWeaponm_flNextPrimaryAttack9999.0);
        
set_pdata_floatPlayerm_flNextAttack9999.0 );
        
        
// --| Update Ammo on HUD.
        
UpdateHud Player );
        
        
// --| We are holding the weapon.
        
gWeaponActivePlayer } = true;
    }
}


public 
CSqueak_Holster ( const Weapon )
{
    
// --| Get the knife's owner index.
    
new Player get_pdata_cbaseWeaponm_pPlayer);
    
    if ( 
Player && gHasSnarkPlayer } && gWeaponActivePlayer } )
    {
        
// --| We are not holding the weapon anymore.
        
gWeaponActivePlayer } = false;
        
set_pdata_floatPlayerm_flNextAttackget_gametime() + 0.5 );
    
        if ( !
gPlayerAmmoPlayer } && user_has_weaponPlayergWeaponIndex ) )
        {
            
RemoveWeapon Playerget_pdata_cbasePlayerm_pActiveWeapon ) );
        }
        else
        {
            
// --| Play the holster animation.
            
UTIL_PlayWeaponAnimation Playersqueak_down );
            
emit_soundPlayerCHAN_WEAPON"common/null.wav"VOL_NORMATTN_NORM0PITCH_NORM );
        }
    }
}


public 
CSqueak_Killed ( const Snark, const Killer, const bool:ShouldGib )
{
    new 
Float:DirectionCoord_e ];
    new 
Float:Origin   Coord_e ];
    
    
pevSnarkpev_originOrigin );
    
    
set_pevSnarkpev_model);
    
set_pevSnarkpev_RemoveRemoveSnark );
    
set_pevSnarkpev_DetonateDelayget_gametime() + 0.1 );
    
    
set_pevSnarkpev_takedamageDAMAGE_NO );
    
    
emit_soundSnarkCHAN_ITEMgSnarkBlastSoundVOL_NORMATTN_NORM 20PITCH_NORM );
    
emit_soundSnarkCHAN_VOICEgSnarkBodySplatSound0.75ATTN_NORM0PITCH_NORM );
    
    
UTIL_RandomBloodVectorDirection );
    
    
FX_BloodDrips OriginBLOOD_COLOR_YELLOW, .Amount 60 );
    
FX_StreakSplash OriginDirection, .Color 5, .Count 16, .Speed 50, .VelocityRange 200 );
    
    
UTIL_RadiusDamage OriginSnarkpevSnarkpev_RealOwner ), get_pcvar_floatpCvarDamagePop ), get_pcvar_floatpCvarDamageRadius ), DMG_BLAST );
}    

public 
CSqueak_TakeDamage ( const Snark, const Inflictor, const Attacker, const Float:Damage, const DamageBits )
{
    if ( 
is_valid_entSnark ) && pevSnarkpev_groupinfo ) == gSnarkClassNameReference )
    {
        if ( 
pevSnarkpev_health ) - gSnarkHealthReference <= )
        {
            
CSqueak_Killed SnarkAttacker, .ShouldGib true );
        }
    }
}


public 
iGive(id)
{
    if(
is_user_alive(id) && zp_core_is_zombie(id) && zp_class_hive_get(id))
    {
        
CSqueak_GiveWeapon(id)
        
set_task(get_pcvar_float(pCvarCooldown), "iGive"id)
        
set_dhudmessage3520035, -1.00.2516.05.00.11.5 );
        
show_dhudmessage(id"Your Minions Are Ready! You will recieve more in %i seconds"get_pcvar_num(pCvarCooldown));
    }
}

public 
CSqueak_HookButtons ( const Player, const UC_Handle, const Seed )
{

    static 
Float:CurrentTime;
    static 
Buttons;
    
    if ( 
gHasSnarkPlayer } && gWeaponActivePlayer } && ( Buttons get_ucUC_HandleUC_Buttons ) ) & IN_ATTACK )
    {
        
CurrentTime get_gametime();
    
        if ( 
gNextShotPlayer ] > CurrentTime )
        {
            return 
FMRES_HANDLED;
        }
    
        if ( 
CSqueak_PrimaryAttack Player ) == PLUGIN_HANDLED )
        {
            return 
FMRES_HANDLED;
        }
    
        
set_ucUC_HandleUC_ButtonsButtons & ~IN_ATTACK );
        return 
FMRES_HANDLED;
    }
    return 
FMRES_IGNORED;
}


public 
CSqueak_HuntThink ( const Snark )
{
    if ( !
is_valid_entSnark ) )
    {
        return 
HAM_IGNORED;
    }

    static 
Float:Origin  Coord_e ];
    static 
Float:VelocityCoord_e ];
    static 
Float:Angles  Coord_e ];
    static 
Float:Flat    Coord_e ];
    static 
Float:CurrentTime;
    static 
Float:DieDelay;
    static 
Float:NextHunt;
    static 
Float:SPitch;
    static 
Enemy;
    
    
pevSnarkpev_velocityVelocity );
    
pevSnarkpev_originOrigin );

    if ( !
UTIL_IsInWorld OriginVelocity ) )
    {
        
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_KILLME );
        return 
HAM_IGNORED;
    }

    
CurrentTime get_gametime();
    
set_pevSnarkpev_nextthinkCurrentTime 0.1 );
    
    
pevSnarkpev_NextHuntNextHunt );
    
pevSnarkpev_DetonateDelayDieDelay );
    
pevSnarkpev_anglesAngles );

    if ( 
CurrentTime >= DieDelay )
    {
        if ( 
pevSnarkpev_Remove ) )
        {
            
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_KILLME );
            return 
HAM_IGNORED;
        }

        
set_pevSnarkpev_health, -1.0 );
        
CSqueak_Killed Snark0true );
        return 
HAM_IGNORED;
    }

    if ( 
pevSnarkpev_waterlevel ) != )
    {
        if ( 
pevSnarkpev_movetype ) == MOVETYPE_BOUNCE )
        {
            
set_pevSnarkpev_movetypeMOVETYPE_FLY );
        }

        
VectorScale Velocity0.9Velocity );
        
Velocity] += 8.0;

        
set_pevSnarkpev_velocityVelocity );
    }
    else if ( 
pevSnarkpev_movetype ) == MOVETYPE_FLY )
    {
        
set_pevSnarkpev_movetypeMOVETYPE_BOUNCE );
    }

    if ( 
NextHunt CurrentTime )
    {
        return 
HAM_IGNORED;
    }

    
set_pevSnarkpev_NextHuntCurrentTime 2.0 );
    
    
VectorCopy VelocityFlat );
    
Flat] = 0.0;
    
VectorNormalize FlatFlat );

    
engfuncEngFunc_MakeVectorsAngles );

    if ( ( 
Enemy pevSnarkpev_enemy ) ) == NULL_ENT || !is_user_aliveEnemy ) || zp_core_is_zombieEnemy ) )
    {
        
Enemy UTIL_BestVisibleEnemy Snark512.0 );
    }

    if ( 
0.3 <= DieDelay CurrentTime <= 0.5 )
    {
        
set_pevSnarkpev_scale2.0 );
        
emit_soundSnarkCHAN_VOICEgSnarkDieSoundVOL_NORMATTN_NORM0PITCH_NORM random_num00x3F ) );
    }

    
SPitch 155.0 60.0 * ( ( DieDelay CurrentTime ) / get_pcvar_floatpCvarDetonateDelay ) );

    if ( 
SPitch 80.0 )  { SPitch 80.0; }

    if ( 
Enemy != NULL_ENT && !zp_core_is_zombieEnemy ) && is_user_aliveEnemy ) )
    {
        static 
Float:TargetCoord_e ];
        static 
Float:Vel;
        static 
Float:Adj;
    
        
pevSnarkpev_EnemyTargetTarget );
        
        if ( 
UTIL_FVisibleSnarkEnemy ) )
        {
            static 
Float:EyePositionCoord_e ];
            
UTIL_EyePosition EnemyEyePosition );

            
VectorSubtract EyePositionOriginTarget );
            
VectorNormalize TargetTarget );
        
            
set_pevSnarkpev_EnemyTargetTarget );
        }

        
Vel VectorLength Velocity );
        
Adj 50.0 / ( Vel 10.0 );
        
        if ( 
Adj 1.2 )  { Adj 1.2; }
        
        
Velocity] = Velocity] * Adj Target] * 300.0;
        
Velocity] = Velocity] * Adj Target] * 300.0;
        
Velocity] = Velocity] * Adj Target] * 300.0;

        
set_pevSnarkpev_velocityVelocity );
    }

    if ( 
pevSnarkpev_flags ) & FL_ONGROUND )
    {
        
set_pevSnarkpev_avelocityFloat:{ 0.00.00.0 } );
    }
    else
    {
        static 
Float:AVelocityCoord_e ];
        
pevSnarkpev_avelocityAVelocity );

        if ( 
AVelocity] == 0.0 && AVelocity] == 0.0 && AVelocity] == 0.0 )
            {
            
AVelocity] = random_float( -100.0100.0 );
            
AVelocity] = random_float( -100.0100.0 );
        
            
set_pevSnarkpev_avelocityAVelocity );
        }
    }

    static 
Float:PosPrevCoord_e ];
    
pevSnarkpev_PosPrevPosPrev );
    
    
VectorSubtract OriginPosPrevPosPrev );

    if ( 
VectorLength PosPrev ) < 1.0 )
    {
        
Velocity] = random_float( -100.0100.0 );
        
Velocity] = random_float( -100.0100.0 );
        
        
set_pevSnarkpev_velocityVelocity );
    }

    
set_pevSnarkpev_PosPrevOrigin );
    
    
vector_to_angleVelocityAngles );
    
    
Angles] = 0.0;
    
Angles] = 0.0;
    
    
set_pevSnarkpev_anglesAngles );
    
    return 
HAM_IGNORED;
}


public 
CSqueak_SuperBounceTouch ( const Snark, const Other )
{
    if ( !
is_valid_entSnark ) )
    {
        return;
    }

    static 
Float:Angles Angle_e ];
    static 
Float:NextHit;
    static 
Float:DieDelay;
    static 
Float:NextAttack;
    static 
Float:NextBounceSoundTime;
    static 
Float:SPitch;
    static 
Float:CurrentTime;
    static 
Owner;

    
Owner pevSnarkpev_owner );
    
    if ( 
Owner && Other == Owner )
    {
        return;
    }

    
SPitch PITCH_NORM 1.0;
    
CurrentTime get_gametime();
    
    
set_pevSnarkpev_ownerNULL_ENT );
    
    
pevSnarkpev_anglesAngles );
    
pevSnarkpev_NextHitNextHit );
    
pevSnarkpev_DetonateDelayDieDelay );
    
pevSnarkpev_NextAttackNextAttack );
    
pevSnarkpev_NextBounceSoundTimeNextBounceSoundTime );
    
    
Angles] = 0.0;
    
Angles] = 0.0;
    
    
set_pevSnarkpev_anglesAngles );

    if ( 
NextHit CurrentTime )
    {
        return;
    }

    
SPitch 155.0 60.0 * ( ( DieDelay CurrentTime ) / get_pcvar_floatpCvarDetonateDelay ) );

    if ( 
<= Other <= gMaxClients && pevOtherpev_takedamage ) && NextAttack CurrentTime )
    {
        static 
Hit;
        
Hit global_getglb_trace_ent );
    
        if ( 
Hit == Other && pevHitpev_modelindex ) != pevSnarkpev_modelindex ) && <= Other <= gMaxClients )
        {
            
Owner pevSnarkpev_RealOwner );

            if ( 
is_user_aliveOther ) && !zp_core_is_zombieOther ) )
            {
                static 
Float:Forward    Coord_e ];
                static 
Float:EndPos     Coord_e ];
                static 
Float:OriginSnarkCoord_e ];
                static 
Float:OriginOtherCoord_e ];
                static 
Trace;
                static 
Float:Damage;

                
Trace create_tr2();
                
                
pevSnarkpev_dmgDamage );
                
pevSnarkpev_originOriginSnark );
                
pevOtherpev_originOriginOther );
                
                
engfuncEngFunc_TraceLineOriginSnarkOriginOtherDONT_IGNORE_MONSTERSSnarkTrace );
                
                
get_tr2TraceTR_vecPlaneNormalForward );
                
get_tr2TraceTR_vecEndPosEndPos );
                
                
ExecuteHamHam_TraceBleedOtherDamageForwardTraceDMG_SLASH );
                
free_tr2Trace );

                
FX_BloodDrips EndPosBLOOD_COLOR_RED, .Amount floatroundDamage ) ); 
                
                
ExecuteHamBHam_TakeDamageOtherSnarkOwnerDamageDMG_SLASH );
                
set_pevSnarkpev_dmgget_pcvar_floatpCvarDamage ) );
            }

            
emit_soundSnarkCHAN_WEAPONgSnarkAttackSoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            
set_pevSnarkpev_NextAttackCurrentTime 0.5 );
        }
    }    

    
set_pevSnarkpev_NextHitCurrentTime 0.1 );
    
set_pevSnarkpev_NextHuntCurrentTime );

    if ( 
CurrentTime NextBounceSoundTime )
    {
        return;
    }

    if ( !( 
pevSnarkpev_flags ) & FL_ONGROUND ) )
    {
        switch ( 
random10 ) )
        {
            case 
.. emit_soundSnarkCHAN_VOICEgSnarkHunt1SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            case 
.. emit_soundSnarkCHAN_VOICEgSnarkHunt2SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            default     : 
emit_soundSnarkCHAN_VOICEgSnarkHunt3SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
        }
    }

    
set_pevSnarkpev_NextBounceSoundTimeCurrentTime 0.5 );
}


CSqueak_Create ( const Player, const Float:OriginCoord_e ], const Float:AnglesCoord_e], const Float:VelocityCoord_e ] )
{
    new 
Snark create_entitygGenericEntity );
    
    if ( 
is_valid_entSnark ) )
    {
        
set_pevSnarkpev_classnamegSnarkClassName );
        
set_pevSnarkpev_groupinfogSnarkClassNameReference );
        
set_pevSnarkpev_ownerPlayer );
        
set_pevSnarkpev_originOrigin );
        
set_pevSnarkpev_anglesAngles );
        
set_pevSnarkpev_velocityVelocity );
        
        
CSqueak_Spawn PlayerSnarkOrigin );
        
        return 
Snark;
    }
    
    return 
NULL_ENT;
}


CSqueak_Spawn ( const Player, const Snark, const Float:OriginCoord_e ] )
{
    new 
Float:CurrentTime get_gametime();
    
    
set_pevSnarkpev_movetypeMOVETYPE_BOUNCE );
    
set_pevSnarkpev_solidSOLID_BBOX );
    
    
entity_set_model SnarkgSnarkModel );
    
entity_set_size  SnarkFloat:{ -6.0, -6.00.0 }, Float:{ 6.06.08.0 } );
    
entity_set_originSnarkOrigin );
    
    
set_pevSnarkpev_nextthinkCurrentTime 0.1 );
    
    
set_pevSnarkpev_NextHuntCurrentTime 1000000.0 ); // NextHunt
    
set_pevSnarkpev_DetonateDelayCurrentTime get_pcvar_floatpCvarDetonateDelay ) ); // DetonateDelay
    
set_pevSnarkpev_NextBounceSoundTimeCurrentTime ); // NextBounceSoundTime
    
set_pevSnarkpev_RealOwnerPlayer ); // RealOwner
    
    
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_MONSTER );
    
set_pevSnarkpev_takedamageDAMAGE_AIM );
    
set_pevSnarkpev_healthget_pcvar_floatpCvarHealth ) + gSnarkHealthReference );
    
set_pevSnarkpev_gravityget_pcvar_floatpCvarGravity ) );
    
set_pevSnarkpev_frictionget_pcvar_floatpCvarFriction ) );
    
set_pevSnarkpev_fovget_pcvar_numpCvarFieldOfView ) );
    
// set_pev( Snark, pev_dmg, get_pcvar_float( pCvarDamagePop ) );
    
    // --| Force snark to run.
    
set_pevSnarkpev_sequencewsqueak_run );
    
set_pevSnarkpev_framerate1.0 );
    
set_pevSnarkpev_animtimeCurrentTime );
    
    if ( 
get_pcvar_numpCvarShowTrail ) )
    {
        
message_begin MSG_BROADCASTSVC_TEMPENTITY );
        
write_byte TE_BEAMFOLLOW );
        
write_short Snark );
        
write_short gSmokeTrail );
        
write_byte TRAIL_LIFE );   // life
        
write_byte TRAIL_WIDTH );  // width
        
write_byte TRAIL_RED );
        
write_byte TRAIL_GREEN );
        
write_byte TRAIL_BLUE );
        
write_byte TRAIL_BRIGTHNESS );
        
message_end();
    }
}


public 
CSqueak_WeaponIdle ( const Player )
{
    if ( 
gHasSnarkPlayer } && gWeaponActivePlayer } )
    {
        static 
Float:CurrentTime;
        
CurrentTime get_gametime();
    
        if ( 
gTimeWeaponIdlePlayer ] > CurrentTime )
        {
            return;
        }
    
        if ( 
gJustThrownPlayer } )
        {
            if ( !
gPlayerAmmoPlayer } )
            {
                
RemoveWeapon Playerget_pdata_cbasePlayerm_pActiveWeapon ) );
                return;
            }

            
UTIL_PlayWeaponAnimation Playersqueak_up );
            
gTimeWeaponIdlePlayer ] = CurrentTime random_float 10.015.0 );
            
            return;
        }

        new 
Animation;
        new 
Float:NewTime;

        switch ( 
random_num010 ) )
        {
            case 
.. :
            {
                
Animation squeak_idle1;
                
NewTime   30.0 16.0 * ( 2.0 );
            }
            case 
.. :
            {
                
Animation squeak_fidgetfit;
                
NewTime   70.0 16.0;
            }
            default :
            {
                
Animation squeak_fidgetnip;
                
NewTime   80.0 16.0;
            }
        }

        
UTIL_PlayWeaponAnimation PlayerAnimation );
        
gTimeWeaponIdlePlayer ] = CurrentTime NewTime;
    }
}


ChangeWeaponToSnark ( const Player )
{
    
set_pevPlayerpev_viewmodel2  gModel_V );
    
set_pevPlayerpev_weaponmodel2gModel_P );
}


UpdateHud ( const Player )
{
    
message_beginMSG_ONE_UNRELIABLEgMsgidAmmoX, .player Player );
    
write_byte12 );
    
write_bytegPlayerAmmoPlayer } );
    
message_end();
}


RemoveWeapon ( const Player, const Weapon )
{
    
ExecuteHamBHam_Weapon_RetireWeaponWeapon );
    
ExecuteHamBHam_RemovePlayerItemPlayerWeapon );
    
ExecuteHamBHam_Item_KillWeapon );
    
    
set_pevPlayerpev_weaponspevPlayerpev_weapons ) & ~( << gWeaponIndex ) );
    
cs_set_user_bpammoPlayergWeaponIndex);
    
    
gHasSnarkPlayer } = false;
    
gWeaponActivePlayer } = false;
}


stock bool:UTIL_IsBSPModel ( const Entity )
{
    return ( 
peventitypev_solid ) == SOLID_BSP || pevEntitypev_movetype ) == MOVETYPE_STEP );
}


UTIL_BestVisibleEnemy ( const Snark, const Float:DistanceToSearch /* , const Flags */ )
{
    static List[ 
MAX_CLIENTS ];
    static 
Float:Distance;
    static 
Float:Nearest;
    static 
ReturnEntity;
    static 
Count;
    static 
Entity;
    static 
i;
    
    
Nearest 8192.0;
    
ReturnEntity NULL_ENT;
    
    
Count find_sphere_classSnark"player"DistanceToSearch, List, sizeof List );

    for ( 
0Counti++ )
    {
        
Entity = List[ ];
    
        if ( 
zp_core_is_zombieEntity ) )
        {
            continue;
        }
        
        if ( 
UTIL_FInViewCone SnarkEntity ) && UTIL_FVisibleSnarkEntity ) )
        {
            if ( ( 
Distance entity_rangeSnarkEntity ) ) <= Nearest )
            {
                
Nearest Distance;
                
ReturnEntity Entity;
            }
        }
    }

    
set_pevSnarkpev_enemyReturnEntity );
    return 
ReturnEntity;
}



UTIL_PlayWeaponAnimation ( const Player, const Sequence )
{
    
set_pevPlayerpev_weaponanimSequence );
    
    
message_beginMSG_ONE_UNRELIABLESVC_WEAPONANIM, .player Player );
    
write_byteSequence );
    
write_bytepevPlayerpev_body ) );
    
message_end();
}


bool:UTIL_IsInWorld ( const Float:OriginCoord_e ], const Float:VelocityCoord_e ] )
{
    static 
i;
    
    for ( 
x<= zi++ )
    {
        if ( !( -
4096.0 Origin] < 4096.0 ) && !( -2000.0 Velocity] < 2000.0 ) )
        {
            return 
false;
        }
    }
    return 
true;
}


UTIL_RandomBloodVector Float:DirectionCoord_e ] )
{
    
Direction] = random_float( -1.01.0 );
    
Direction] = random_float( -1.01.0 );
    
Direction] = random_float(  0.01.0 );
}


FX_BloodDrips ( const Float:OriginCoord_e ], const BloodColor, const Amount )
{
    
message_begin_fMSG_PVSSVC_TEMPENTITYOriginNULL_ENT );
    
write_byteTE_BLOODSPRITE );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_shortgBloodSpray );         // initial sprite model
    
write_shortgBloodDrop );          // droplet sprite models
    
write_byteBloodColor );           // color index into host_basepal
    
write_byteminmax3, ( Amount 255 255 Amount ) / 10 ), 16 ) );  // size
    
message_end();
}


FX_StreakSplash ( const Float:OriginCoord_e ], const Float:DirectionCoord_e ], const Color, const Count, const Speed, const VelocityRange )
{
    
message_begin_fMSG_PVSSVC_TEMPENTITYOriginNULL_ENT );
    
write_byteTE_STREAK_SPLASH );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fDirection] );
    
write_coord_fDirection] );
    
write_coord_fDirection] );
    
write_byteminColor255 ) );
    
write_shortCount );
    
write_shortSpeed );
    
write_shortVelocityRange );// random velocity modifier
    
message_end();
}


stock FX_TraceBleed( const Victim, const Float:Damage, const Float:DirCoord_e ], const TraceResult:Trace )
{
    new 
TraceResult:BloodTrace;
    new 
Float:TraceDirCoord_e ]; 
    new 
Float:EndPos  Coord_e ];
    new 
Float:Noise;
    new 
Float:Fraction;
    new 
Count;

    if ( 
Damage 10 )
    {
        
Noise 0.1;
        
Count 1;
    }
    else if ( 
Damage 25 )
    {
        
Noise 0.2;
        
Count 2;
    }
    else
    {
        
Noise 0.3;
        
Count 4;
    }

    for ( new 
Count i++ )
    {
        
VectorScale Dir, -1.0TraceDir );
        
        
TraceDir] += random_float( -NoiseNoise );
        
TraceDir] += random_float( -NoiseNoise );
        
TraceDir] += random_float( -NoiseNoise );
        
        
get_tr2TraceTR_vecEndPosEndPos );
        
VectorMA EndPos, -172.0TraceDirTraceDir );

        
engfuncEngFunc_TraceLineEndPosTraceDirIGNORE_MONSTERSVictimBloodTrace );
        
get_tr2BloodTraceTR_flFractionFraction );
        
        if ( 
Fraction != 1.0 )
        {
            
FX_BloodDecalTraceBloodTraceEndPosBLOOD_COLOR_RED );
        }
    }
}


stock FX_BloodDecalTrace ( const TraceResult:Trace, const Float:EndPosCoord_e ], const BloodColor )
{
    new 
Hit;
    new 
BaseIndex;
    new 
DecalIndex;
    new 
Float:Fraction
    
    switch ( 
BloodColor )
    {
        case 
BLOOD_COLOR_YELLOW BaseIndex get_decal_index"{yblood1" );
        case 
BLOOD_COLOR_RED    BaseIndex get_decal_index"{blood1" );
    }

    
DecalIndex BaseIndex random_num0);
    
    
Hit max0get_tr2TraceTR_pHit ) );
    
get_tr2TraceTR_flFractionFraction );
    
    if ( 
Fraction == 1.0 || ( Hit && !UTIL_IsBSPModel Hit ) ) )
    {
        return;
    }   

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteHit TE_DECAL TE_WORLDDECAL );
    
write_coord_fEndPos] );
    
write_coord_fEndPos] );
    
write_coord_fEndPos] );
    
write_byteDecalIndex );

    if ( 
Hit )
    {
        
write_shortHit );
    }

    
message_end();
}


stock UTIL_RadiusDamage ( const Float:OriginCoord_e ], const Inflictor, const Attacker, const Float:Damage, const Float:Radius, const DamageBits )
{
    static 
Entity;
    static 
Trace;
    static 
Float:AdjustedDamage;
    static 
bool:InWater;
    
    
Entity NULL_ENT;
    
InWater UTIL_LiquidContentsOrigin );

    while ( ( 
Entity find_ent_in_sphereEntityOriginRadius ) ) != NULL_ENT )
    {
    
        if ( 
Entity == Inflictor )
        {
            continue;
        }

        if ( 
pevEntitypev_takedamage ) && !zp_core_is_zombieEntity ) && is_user_alive Entity ) )
        {
            static 
Float:EntOriginCoord_e ];
            static 
Float:EndPos   Coord_e ];
            static 
Float:Fraction;
            
            
pevEntitypev_originEntOrigin );
            
            
engfuncEngFunc_TraceLineOriginEntOriginIGNORE_MONSTERSInflictorTrace );
            
            
get_tr2TraceTR_flFractionFraction );
            
get_tr2TraceTR_vecEndPosEndPos );

            if ( 
Fraction == 1.0 || get_tr2TraceTR_pHit ) == Entity )
            {
                static 
Float:DeltaCoord_e ];
                static 
Float:Len;

                if ( 
get_tr2TraceTR_StartSolid ) )
                {
                    
EndPos Origin;
                    
Fraction 0.0;
                }
                    
                
AdjustedDamage Damage;
                
VectorSubtract EndPosOriginDelta );
                    
                if ( ( 
Len VectorLength Delta ) ) != 0.0 )
                {
                    
VectorScale DeltaLenDelta );
                }

                if ( 
Len 2.0 )
                {
                    
Len -= 2.0;
                }

                if ( ( 
AdjustedDamage *= ( 1.0 Len Radius ) ) <= )
                {
                    continue;
                }

                if ( 
InWater || pevEntitypev_waterlevel ) > )
                {
                    
AdjustedDamage *= 0.5;
                }

                if ( 
Fraction != 1.0 )
                {
                    
ExecuteHamHam_TraceAttackEntityInflictorAdjustedDamageDeltaTraceDamageBits );
                    
ExecuteHamBHam_TakeDamageEntityInflictorAttackerAdjustedDamageDamageBits );
                }
                else
                {
                    
ExecuteHamBHam_TakeDamageEntityInflictorAttackerAdjustedDamageDamageBits );
                }
            }
        }
    }
}


stock UTIL_EntitiesInBox ( List[], const ListMax, const Float:MinsCoord_e ], const Float:MaxsCoord_e ], const Flags )
{
    
/*
    static Float:Origin [ Coord_e ];
    static Float:Delta  [ Coord_e ];
    static Float:Mins   [ Coord_e ];
    static Float:Maxs   [ Coord_e ];
    
    pev( Snark, pev_origin, Origin );
    
    Delta[ x ] = Delta[ y ] = Delta[ z ] = DistanceToSearch;
    
    VectorSubtract ( Origin, Delta, Mins );
    VectorAdd ( Origin, Delta, Maxs );
    
    Count = UTIL_EntitiesInBox ( List, sizeof List, Mins, Maxs, Flags );
    */
    
    
static Float:AbsMinsCoord_e ];
    static 
Float:AbsMaxsCoord_e ];
    static 
Count;
    static 
Entity;
    
    
Count 0;
    
    for ( 
Entity 1Entity <= gMaxEntitiesEntity++ )  if( is_valid_entEntity ) )
    {
        if ( !( 
pevEntitypev_flags ) & Flags ) )
        {
            continue;
        }

        
pevEntitypev_absminAbsMins );
        
pevEntitypev_absmaxAbsMaxs );

        if ( 
Mins] > AbsMaxs] || Mins] > AbsMaxs] || Mins] > AbsMaxs] ||
        
Maxs] < AbsMins] || Maxs] < AbsMins] || Maxs] < AbsMins] )
        {
            continue;
        }

        List[ 
Count ] = Entity;
        
        if ( 
Count++ >= ListMax )
        {
            return 
Count;
        }
    }

    return 
Count;
}


bool:UTIL_FVisible ( const Entity, const Other )
{
    static 
Float:LookerOriginCoord_e ];
    static 
Float:TargetOriginCoord_e ];
    static 
Float:Fraction;
    static 
LookerWLevel;
    static 
TargetWLevel;
    
    if ( 
pevOtherpev_flags ) & FL_NOTARGET )
    {
        return 
false;
    }

    
LookerWLevel pev Entitypev_waterlevel );
    
TargetWLevel pev Otherpev_waterlevel );
    
    if ( ( 
LookerWLevel != && TargetWLevel == ) || ( LookerWLevel == && TargetWLevel == 0  ) )
    {
        return 
false;
    }

    
UTIL_EyePosition EntityLookerOrigin );
    
UTIL_EyePosition OtherTargetOrigin );
    
    
engfuncEngFunc_TraceLineLookerOriginTargetOriginIGNORE_MONSTERS IGNORE_GLASSEntity);
    
get_tr20TR_flFractionFraction );
    
    return 
Fraction == 1.0 true false;
}


bool:UTIL_FInViewCone ( const Entity, const Other )
{
    static 
Float:Angles Coord_e ];
    static 
Float:HOriginCoord_e ];
    static 
Float:Origin Coord_e ];
    
    
pevEntitypev_anglesAngles );
    
engfuncEngFunc_MakeVectorsAngles );
    
global_getglb_v_forwardAngles );
    
    
Angles] = 0.0;
    
    
pevEntitypev_originHOrigin );
    
pevOtherpev_originOrigin );
    
    
VectorSubtract OriginHOriginOrigin );
    
Origin] = 0.0;
    
    
VectorNormalize OriginOrigin );

    if ( 
DotProduct OriginAngles ) > pevEntitypev_fov ) )
    {
        return 
true;
    }
    
    return 
false;
}


UTIL_EyePosition ( const EntityFloat:OriginCoord_e ] )
{
    static 
Float:ViewOfsCoord_e ];
    
    
pevEntitypev_originOrigin );
    
pevEntitypev_view_ofsViewOfs );
    
    
VectorAdd OriginViewOfsOrigin );
}


stock bool:UTIL_LiquidContents( const Float:SourceCoord_e ] )
{
    new 
Contents point_contentsSource );
    return ( 
Contents == CONTENTS_WATER || Contents == CONTENTS_SLIME || Contents == CONTENTS_LAVA );
}


VectorNormalize ( const Float:SourceCoord_e ], Float:OutputCoord_e ] )
{
    static 
Float:InvLen;
    
    
InvLen 1.0 VectorLength Source );
    
    
Output] = Source] * InvLen;
    
Output] = Source] * InvLen;
    
Output] = Source] * InvLen;


Last edited by Depresie; 10-10-2015 at 13:47.
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-28-2015 , 15:14   Re: [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #2

BUMP
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-10-2015 , 13:16   Re: [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #3

BUMP
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-11-2015 , 06:27   Re: [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #4

I managed to fix i think most of the errors, but how the heck do i fix this null traceresult error?

Later Edit: pfffff, sorry for double post

Code:
L 10/11/2015 - 12:52:44: Start of error session.
L 10/11/2015 - 12:52:44: Info (map "zm_foda") (file "addons/amxmodx/logs/error_20151011.log")
L 10/11/2015 - 12:52:44: [HAMSANDWICH] Null traceresult provided.
L 10/11/2015 - 12:52:44: [AMXX] Displaying debug trace (plugin "zp50_class_hive_insect.amxx")
L 10/11/2015 - 12:52:44: [AMXX] Run time error 10: native error (native "ExecuteHam")
L 10/11/2015 - 12:52:44: [AMXX]    [0] zp50_class_hive_insect.sma::UTIL_RadiusDamage (line 1271)
L 10/11/2015 - 12:52:44: [AMXX]    [1] zp50_class_hive_insect.sma::CSqueak_Killed (line 518)
L 10/11/2015 - 12:52:44: [AMXX]    [2] zp50_class_hive_insect.sma::CSqueak_TakeDamage (line 527)
PHP Code:
public CSqueak_Killed ( const Snark, const Killer, const bool:ShouldGib )
{
    new 
Float:DirectionCoord_e ];
    new 
Float:Origin   Coord_e ];
        
    
pevSnarkpev_originOrigin );
        
    
set_pevSnarkpev_model);
    
set_pevSnarkpev_RemoveRemoveSnark );
    
set_pevSnarkpev_DetonateDelayget_gametime() + 0.1 );
        
    
set_pevSnarkpev_takedamageDAMAGE_NO );
        
    
emit_soundSnarkCHAN_ITEMgSnarkBlastSoundVOL_NORMATTN_NORM 20PITCH_NORM );
    
emit_soundSnarkCHAN_VOICEgSnarkBodySplatSound0.75ATTN_NORM0PITCH_NORM );
        
    
UTIL_RandomBloodVectorDirection );
        
    
FX_BloodDrips OriginBLOOD_COLOR_YELLOW, .Amount 60 );
    
FX_StreakSplash OriginDirection, .Color 5, .Count 16, .Speed 50, .VelocityRange 200 );
        
    
UTIL_RadiusDamage OriginSnarkpevSnarkpev_RealOwner ), get_pcvar_floatpCvarDamagePop ), get_pcvar_floatpCvarDamageRadius ), DMG_BLAST );
}

public 
CSqueak_TakeDamage ( const Snark, const Inflictor, const Attacker, const Float:Damage, const DamageBits )
{
    if ( 
is_valid_entSnark ) && is_user_aliveAttacker ) && pevSnarkpev_groupinfo ) == gSnarkClassNameReference )
    {
        if ( 
pevSnarkpev_health ) - gSnarkHealthReference <= )
        {
            
CSqueak_Killed SnarkAttacker, .ShouldGib true );
        }
    }
}

stock UTIL_RadiusDamage ( const Float:OriginCoord_e ], const Inflictor, const Attacker, const Float:Damage, const Float:Radius, const DamageBits )
{
    static 
Entity;
    static 
Trace;
    static 
Float:AdjustedDamage;
    static 
bool:InWater;
    
    
Entity NULL_ENT;
    
InWater UTIL_LiquidContentsOrigin );

    while ( ( 
Entity find_ent_in_sphereEntityOriginRadius ) ) != NULL_ENT )
    {
    
        if ( 
Entity == Inflictor )
        {
            continue;
        }

        if ( 
pevEntitypev_takedamage ) && is_user_alive Entity ) && !zp_core_is_zombieEntity ) )
        {
            static 
Float:EntOriginCoord_e ];
            static 
Float:EndPos   Coord_e ];
            static 
Float:Fraction;
            
            
pevEntitypev_originEntOrigin );
            
            
engfuncEngFunc_TraceLineOriginEntOriginIGNORE_MONSTERSInflictorTrace );
            
            
get_tr2TraceTR_flFractionFraction );
            
get_tr2TraceTR_vecEndPosEndPos );

            if ( 
Fraction == 1.0 || get_tr2TraceTR_pHit ) == Entity )
            {
                static 
Float:DeltaCoord_e ];
                static 
Float:Len;

                if ( 
get_tr2TraceTR_StartSolid ) )
                {
                    
EndPos Origin;
                    
Fraction 0.0;
                }
                    
                
AdjustedDamage Damage;
                
VectorSubtract EndPosOriginDelta );
                    
                if ( ( 
Len VectorLength Delta ) ) != 0.0 )
                {
                    
VectorScale DeltaLenDelta );
                }

                if ( 
Len 2.0 )
                {
                    
Len -= 2.0;
                }

                if ( ( 
AdjustedDamage *= ( 1.0 Len Radius ) ) <= )
                {
                    continue;
                }

                if ( 
InWater || pevEntitypev_waterlevel ) > )
                {
                    
AdjustedDamage *= 0.5;
                }

                if ( 
Fraction != 1.0 )
                {
                    
ExecuteHamHam_TraceAttackEntityInflictorAdjustedDamageDeltaTraceDamageBits );
                    
ExecuteHamHam_TakeDamageEntityInflictorAttackerAdjustedDamageDamageBits );
                }
                else
                {
                    
ExecuteHamHam_TakeDamageEntityInflictorAttackerAdjustedDamageDamageBits );
                }
            }
        }
    }

Spoiler

Last edited by Depresie; 10-11-2015 at 06:28.
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-11-2015 , 08:07   Re: [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #5

Either replace Trace with 0 everywhere, or use create_tr2()/free_tr2(), I guess.
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-11-2015 , 08:38   Re: [REQ/HELP] Fixing Arkshine's Snark Infector
Reply With Quote #6

how exactly? lol

Later Edit:

Nvm, i will just delete that radius damage function, i don't need it anyway, but im still curious if you have time to tell me what exactly i had to change in order to fix the error

Later Later Edit:

Added many user_is_alive checks, remove util radius damage which caused run time errors, still crashing without displaying any error in the logs.. any ideea?

PHP Code:
/* - - - - - - - - - - -

AMX Mod X script.

| Author  : ARKSHINE
| Plugin  : WPN Squea2 Grenade
| Version : v1.0.6 - without WM.

(!) Support : http://forums.alliedmods.net/showthread.php?t=93659
(!) Version without WeaponMod required and for Zombie Plague.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

- - - - - - - - - - - */

#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <engine>
#include <zp50_core>
#include <zp50_class_hive>
#include <fun>
#include <dhudmessage>

#define Plugin   "[ZP] Extra: Squea2 Grenade"
#define Version  "1.0.6-wwm"
#define Author   "ARKSHINE"

// --| Comment if you want to use the default model from valve.
#define ALTERNATIVE_MODEL

// --| Snark trail.
#define TRAIL_LIFE        15    // Life
#define TRAIL_WIDTH       4     // Width
#define TRAIL_RED         10    // Red
#define TRAIL_GREEN       224   // Red
#define TRAIL_BLUE        10    // Green
#define TRAIL_BRIGTHNESS  200   // Blue


/* - - -
|  WEAPON MODELS  |
- - - */
new const gModel_P[] = "models/adn_models/adn_p_insect.mdl";
new const 
gModel_V[] = "models/adn_models/adn_v_insect2.mdl";

/* - - -
|  SNARK SOUNDS  |
- - - */
new const gSnarkHunt1Sound[] = "squeek/sqk_hunt1.wav";
new const 
gSnarkHunt2Sound[] = "squeek/sqk_hunt2.wav";
new const 
gSnarkHunt3Sound[] = "squeek/sqk_hunt3.wav";
new const 
gSnarkDieSound[] = "squeek/sqk_die1.wav";
new const 
gSnarkAttackSound[] = "squeek/sqk_deploy1.wav";
new const 
gSnarkBlastSound[] = "squeek/sqk_blast1.wav";
new const 
gSnarkBodySplatSound[] = "common/bodysplat.wav";

/* - - -
|  SNARK MODEL  |
- - - */

new gSnarkModel[] = "models/adn_models/adn_w_insect2.mdl";

/* - - -
|    SEQUENCE   |
- - - */
enum
{
    
wsqueak_idle1,
    
wsqueak_fidget,
    
wsqueak_jump,
    
wsqueak_run
};

enum
{
    
squeak_idle1,
    
squeak_fidgetfit,
    
squeak_fidgetnip,
    
squeak_down,
    
squeak_up,
    
squeak_throw
};

/* - -
|  CONSTANTS  |
- - */
const BLOOD_COLOR_RED 247;
const 
BLOOD_COLOR_YELLOW 195;

const 
MAX_CLIENTS 32;
const 
MAX_KNIFE_MODEL_LENGTH 128;
const 
NONE = -1;
const 
NULL_ENT 0;

enum _:Coord_e
{
    
Float:x,
    
Float:y,
    
Float:z
};

enum _:Angle_e
{
    
Float:Pitch,
    
Float:Yaw,
    
Float:Roll
};

enum
{
    
HuntThink 1,
    
SuperBounceTouch,
    
RemoveSnark
};

new const 
Float:gHullMinCoord_e ] = { -16.0, -16.0, -36.0 };
new const 
Float:gDuckHullMinCoord_e ] = { -16.0, -16.0, -18.0 };

new const 
gWeaponCommand[] = "weapon_hegrenade";
new const 
gWeaponIndex CSW_HEGRENADE;

new const 
gGenericEntity[] = "info_target";
new const 
gSnarkClassName[] = "wpn_snark";

/* - - - -
|  PLAYER/WEAPON OFFSETS  |
- - - - */
const m_flNextAttack 83    // Player.
const m_pActiveWeapon 373;  // Player.
const m_pPlayer 41;   // Weapon.
const m_flNextPrimaryAttack 46;   // Weapon.

/* - - -
|  CUSTOM FIELD  |
- - - */
#define pev_NextHunt            pev_fuser1
#define pev_NextBounceSoundTime pev_fuser2
#define pev_NextHit             pev_fuser3
#define pev_NextAttack          pev_fuser4
#define pev_DetonateDelay       pev_ltime
#define pev_RealOwner           pev_iuser1
#define pev_Remove              pev_iuser2
#define pev_EnemyTarget         pev_vuser1
#define pev_PosPrev             pev_vuser2

/* - - -
|  CVAR POINTER  |
- - - */
new pCvarAmmo;
new 
pCvarRefireRate;
new 
pCvarHealth;
new 
pCvarVelocity;
new 
pCvarDamage;
new 
pCvarGravity;
new 
pCvarFriction;
new 
pCvarDetonateDelay;
new 
pCvarFieldOfView;
new 
pCvarShowTrail;
new 
pCvarCooldown;

/* - - - -
|  SPRITES/MODELS INDEX  |
- - - - */
new gBloodSpray;
new 
gBloodDrop;
new 
gSmokeTrail;

/* - - - -
|  OTHERS STUFFS  |
- - - */
new bool:gHasSnark    MAX_CLIENTS 1 char ];
new 
bool:gWeaponActiveMAX_CLIENTS 1 char ];
new 
bool:gJustThrown  MAX_CLIENTS 1 char ];

new 
Float:gNextShot      MAX_CLIENTS ];
new 
Float:gTimeWeaponIdleMAX_CLIENTS ];

new 
gPlayerAmmoMAX_CLIENTS 1 char ];

new const 
gSnarkHealthReference 10000;
new 
gSnarkClassNameReference;
new 
gMaxEntities;
new 
gMaxClients;
new 
gMsgidAmmoX;


/* - -
|  MACROS  |
- - */
#define VectorSubtract(%1,%2,%3)  ( %3[ x ] = %1[ x ] - %2[ x ], %3[ y ] = %1[ y ] - %2[ y ], %3[ z ] = %1[ z ] - %2[ z ] )
#define VectorAdd(%1,%2,%3)       ( %3[ x ] = %1[ x ] + %2[ x ], %3[ y ] = %1[ y ] + %2[ y ], %3[ z ] = %1[ z ] + %2[ z ] )
#define VectorCopy(%1,%2)         ( %2[ x ] = %1[ x ],  %2[ y ] = %1[ y ], %2[ z ] = %1[ z ] )
#define VectorScale(%1,%2,%3)     ( %3[ x ] = %2 * %1[ x ], %3[ y ] = %2 * %1[ y ], %3[ z ] = %2 * %1[ z ] )
#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 ] )
#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 ] )
#define VectorLength(%1)          ( floatsqroot ( %1[ x ] * %1[ x ] + %1[ y ] * %1[ y ] + %1[ z ] * %1[ z ] ) )
#define VectorEqual(%1,%2)        ( %1[ x ] == %2[ x ] && %1[ y ] == %2[ y ] && %1[ z ] == %2[ z ] )
#define DotProduct(%1,%2)         ( %1[ x ] * %2[ x ]+ %1[ y ] * %2[ y ] + %1[ z ] * %2[ z ] )

#define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
#define write_coord_f(%1)         ( engfunc ( EngFunc_WriteCoord, %1 ) )


public plugin_precache ()
{
    
// --| Weapon models.
    
precache_modelgModel_P );
    
precache_modelgModel_V );
    
    
// --| Snark model.
    
precache_modelgSnarkModel );
    
    
// --| Snark sounds.
    
precache_soundgSnarkBlastSound );
    
precache_soundgSnarkBodySplatSound );
    
precache_soundgSnarkDieSound );
    
precache_soundgSnarkHunt1Sound );
    
precache_soundgSnarkHunt2Sound );
    
precache_soundgSnarkHunt3Sound );
    
precache_soundgSnarkAttackSound );
    
    
gBloodSpray precache_model"sprites/bloodspray.spr" );   // initial blood
    
gBloodDrop  precache_model"sprites/blood.spr" );        // splattered blood
}


public 
plugin_init ()
{
    
register_pluginPluginVersionAuthor );
    
register_cvar"zp_snark_version"VersionFCVAR_SERVER FCVAR_SPONLY );
    
    
pCvarAmmo          register_cvar"zp_insect_ammo"           "25"   );
    
pCvarRefireRate    register_cvar"zp_insect_fire"    "0.1" );
    
pCvarHealth        register_cvar"zp_insect_health"         "16"  );
    
pCvarVelocity      register_cvar"zp_insect_velocity"       "200" );
    
pCvarDamage     register_cvar"zp_insect_damage"         "15"   );
    
pCvarGravity       register_cvar"zp_insect_gravity"        "0.3" );
    
pCvarFriction      register_cvar"zp_insect_friction"       "0.3" );
    
pCvarDetonateDelay register_cvar"zp_insect_life" "480"  );
    
pCvarFieldOfView   register_cvar"zp_insect_fov"            "2000"   );
    
pCvarShowTrail     register_cvar"zp_insect_glow"     "1"   );
    
pCvarCooldown      register_cvar"zp_insect_cooldown"     "60"   );
    
    
register_logevent("logevent_round_end"2"1=Round_End"
    
    
RegisterHamHam_Item_Deploy gWeaponCommand"CSqueak_Deploy");
    
RegisterHamHam_Item_HolstergWeaponCommand"CSqueak_Holster");
    
RegisterHamHam_TakeDamagegGenericEntity"CSqueak_TakeDamage");
    
    
register_forwardFM_CmdStart"CSqueak_HookButtons" );
    
register_forwardFM_PlayerPreThink"CSqueak_WeaponIdle" );
    
    
register_thinkgSnarkClassName"CSqueak_HuntThink" );
    
register_touchgSnarkClassName"*""CSqueak_SuperBounceTouch" );
    
    
// register_clcmd( "say test", "CSqueak_GiveWeapon" );
    
    
gMaxEntities global_getglb_maxEntities );
    
gMaxClients  global_getglb_maxClients );
    
    
gSnarkClassNameReference engfuncEngFunc_AllocStringgSnarkClassName );
    
gMsgidAmmoX get_user_msgid"AmmoX" );
    
    if ( 
get_pcvar_numpCvarShowTrail ) )
    {
        
gSmokeTrail engfuncEngFunc_PrecacheModel"sprites/smoke.spr" );
    }

}


public 
logevent_round_end()
{
    new 
Snark = -1;
    
    while ( ( 
Snark find_ent_by_classSnarkgSnarkClassName ) ) != NULL_ENT )
    {
        
CSqueak_Killed Snark0true );
    }
    
    for ( new 
Player 1Player <= gMaxClientsPlayer++ )
    {
        
CheckAndRemoveWeapon Player );
        
remove_taskPlayer )
    }


public 
zp_fw_core_cure_post(id)
{
    
CheckAndRemoveWeapon(id)
}

public 
zp_fw_core_infect_post(id)
{
    if(
is_user_alive(id) && zp_core_is_zombie(id) && zp_class_hive_get(id))
    {
        
iGive(id)
    }
}


stock CheckAndRemoveWeapon ( const Player )
{
    if ( 
is_user_alive(Player) && user_has_weaponPlayergWeaponIndex ) )
    {
        
RemoveWeapon Playerget_user_weaponPlayer ) == gWeaponIndex 
    
        
get_pdata_cbasePlayerm_pActiveWeapon ) : 
        
find_ent_by_owner ( -1gWeaponCommandPlayer ) );
    }
}

public 
client_disconnect(Player)
{
    
gHasSnark    Player } = false;
    
gWeaponActivePlayer } = false;
    
gJustThrown  Player } = false;
    
gPlayerAmmo  Player } = 0;
    
remove_task(Player)
}


public 
CSqueak_GiveWeapon( const Player )
{
    if(
is_user_alive(Player))
    {
        
gHasSnarkPlayer } = true;
        
gPlayerAmmoPlayer } = get_pcvar_numpCvarAmmo );
        
        
give_itemPlayergWeaponCommand );
        
engclient_cmdPlayergWeaponCommand );
    }
}


public 
CSqueak_PrimaryAttack ( const Player )
{
    if(!
is_user_alive(Player))
    {
        return 
PLUGIN_HANDLED
    
}
    
    static 
Float:VAngle     Angle_e ];
    static 
Float:Origin     Coord_e ];
    static 
Float:TraceOriginCoord_e ];
    static 
Float:Forward    Coord_e ];
    static 
Float:Start      Coord_e ];
    static 
Float:End        Coord_e ];
    static 
Float:EndPos     Coord_e ];
    static 
Float:Velocity   Coord_e ];
    static 
Float:Fraction;

    if ( 
gPlayerAmmoPlayer } )
    {
        if ( 
pevPlayerpev_waterlevel ) >= )
        {
            
emit_soundPlayerCHAN_WEAPONgSnarkDieSoundVOL_NORMATTN_NORM0PITCH_NORM );
            
gNextShotPlayer ] = get_gametime() + get_pcvar_floatpCvarRefireRate );
        
            return 
PLUGIN_HANDLED;
        }

        
pevPlayerpev_originOrigin );
        
pevPlayerpev_v_angleVAngle );
        
pevPlayerpev_velocityVelocity );
        
        
engfuncEngFunc_MakeVectorsVAngle );
        
        
VectorCopyOriginTraceOrigin );

        if ( 
pevPlayerpev_flags ) & FL_DUCKING )
        {
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
            
TraceOrigin] = TraceOrigin] - ( gHullMin] - gDuckHullMin] );
        }

        
global_getglb_v_forwardForward );
        
        
VectorMA TraceOrigin20.0ForwardStart );
        
VectorMA TraceOrigin64.0ForwardEnd );
        
        
engfuncEngFunc_TraceLineStartEndDONT_IGNORE_MONSTERSNULL_ENT);
        
        
get_tr20TR_FractionFraction );
        
get_tr20TR_vecEndPosEndPos );

        if ( !
get_tr20TR_AllSolid ) && !get_tr20TR_StartSolid ) && Fraction 0.25 )
        {
            
// --| Play the throw animation.
            
UTIL_PlayWeaponAnimation Playersqueak_throw );
            
            
// --| player "shoot" animation
            //
            
            
VectorMA Velocityget_pcvar_floatpCvarVelocity ), ForwardVelocity );

            if ( 
CSqueak_Create PlayerEndPosVAngleVelocity ) )
            {
                new 
Float:CurrentTime get_gametime();
                
                switch ( 
random_num0) )
                {
                    case 
0emit_soundPlayerCHAN_WEAPONgSnarkHunt1SoundVOL_NORMATTN_NORM0PITCH_NORM );
                    case 
1emit_soundPlayerCHAN_WEAPONgSnarkHunt2SoundVOL_NORMATTN_NORM0PITCH_NORM );
                    case 
2emit_soundPlayerCHAN_WEAPONgSnarkHunt3SoundVOL_NORMATTN_NORM0PITCH_NORM );
                }
    
                
gPlayerAmmoPlayer }--;
                
gJustThrownPlayer } = true;
                
                
UpdateHud Player );
                
                
gNextShotPlayer ] = CurrentTime get_pcvar_floatpCvarRefireRate );
                
gTimeWeaponIdlePlayer ] = CurrentTime 1.0;
                
                return 
PLUGIN_CONTINUE;
            }
        }
    }
    return 
PLUGIN_HANDLED;
}


public 
CSqueak_Deploy ( const Weapon )
{
    
// --| Get the knife's owner index.
    
new Player get_pdata_cbaseWeaponm_pPlayer);
    
    if ( 
Player && is_user_alive(Player) && gHasSnarkPlayer } )
    {
        
// --| Change knife to snark weapon.
        
ChangeWeaponToSnark Player );
        
        
// --| Play the deploy animation.
        
UTIL_PlayWeaponAnimation Playersqueak_up );
        
emit_sound WeaponCHAN_VOICE random_float 0.01.0 ) <= 0.5 gSnarkHunt2Sound gSnarkHunt3SoundVOL_NORMATTN_NORM0PITCH_NORM );
        
        
// --| Block the primary attack.
        
set_pdata_floatWeaponm_flNextPrimaryAttack9999.0);
        
set_pdata_floatPlayerm_flNextAttack9999.0 );
        
        
// --| Update Ammo on HUD.
        
UpdateHud Player );
        
        
// --| We are holding the weapon.
        
gWeaponActivePlayer } = true;
    }
}


public 
CSqueak_Holster ( const Weapon )
{
    
// --| Get the knife's owner index.
    
new Player get_pdata_cbaseWeaponm_pPlayer);
    
    if ( 
Player && is_user_alive(Player) && gHasSnarkPlayer } && gWeaponActivePlayer } )
    {
        
// --| We are not holding the weapon anymore.
        
gWeaponActivePlayer } = false;
        
set_pdata_floatPlayerm_flNextAttackget_gametime() + 0.5 );
    
        if ( !
gPlayerAmmoPlayer } && user_has_weaponPlayergWeaponIndex ) )
        {
            
RemoveWeapon Playerget_pdata_cbasePlayerm_pActiveWeapon ) );
        }
        else
        {
            
// --| Play the holster animation.
            
UTIL_PlayWeaponAnimation Playersqueak_down );
            
emit_soundPlayerCHAN_WEAPON"common/null.wav"VOL_NORMATTN_NORM0PITCH_NORM );
        }
    }
}


public 
CSqueak_Killed ( const Snark, const Killer, const bool:ShouldGib )
{
    new 
Float:DirectionCoord_e ];
    new 
Float:Origin   Coord_e ];
        
    
pevSnarkpev_originOrigin );
        
    
set_pevSnarkpev_model);
    
set_pevSnarkpev_RemoveRemoveSnark );
    
set_pevSnarkpev_DetonateDelayget_gametime() + 0.1 );
        
    
set_pevSnarkpev_takedamageDAMAGE_NO );
        
    
emit_soundSnarkCHAN_ITEMgSnarkBlastSoundVOL_NORMATTN_NORM 20PITCH_NORM );
    
emit_soundSnarkCHAN_VOICEgSnarkBodySplatSound0.75ATTN_NORM0PITCH_NORM );
        
    
UTIL_RandomBloodVectorDirection );
        
    
FX_BloodDrips OriginBLOOD_COLOR_YELLOW, .Amount 60 );
    
FX_StreakSplash OriginDirection, .Color 5, .Count 16, .Speed 50, .VelocityRange 200 );
}

public 
CSqueak_TakeDamage ( const Snark, const Inflictor, const Attacker, const Float:Damage, const DamageBits )
{
    if ( 
is_valid_entSnark ) && is_user_aliveAttacker ) && pevSnarkpev_groupinfo ) == gSnarkClassNameReference )
    {
        if ( 
pevSnarkpev_health ) - gSnarkHealthReference <= )
        {
            
CSqueak_Killed SnarkAttacker, .ShouldGib true );
        }
    }
}


public 
iGive(id)
{
    if(
is_user_alive(id) && zp_core_is_zombie(id) && zp_class_hive_get(id))
    {
        
CSqueak_GiveWeapon(id)
        
set_task(get_pcvar_float(pCvarCooldown), "iGive"id)
        
set_dhudmessage3520035, -1.00.2516.05.00.11.5 );
        
show_dhudmessage(id"Your Minions Are Ready! You will recieve more in %i seconds"get_pcvar_num(pCvarCooldown));
    }
}

public 
CSqueak_HookButtons ( const Player, const UC_Handle, const Seed )
{

    static 
Float:CurrentTime;
    static 
Buttons;
    
    if ( 
is_user_alivePlayer) && gHasSnarkPlayer } && gWeaponActivePlayer } && ( Buttons get_ucUC_HandleUC_Buttons ) ) & IN_ATTACK )
    {
        
CurrentTime get_gametime();
    
        if ( 
gNextShotPlayer ] > CurrentTime )
        {
            return 
FMRES_HANDLED;
        }
    
        if ( 
CSqueak_PrimaryAttack Player ) == PLUGIN_HANDLED )
        {
            return 
FMRES_HANDLED;
        }
    
        
set_ucUC_HandleUC_ButtonsButtons & ~IN_ATTACK );
        return 
FMRES_HANDLED;
    }
    return 
FMRES_IGNORED;
}


public 
CSqueak_HuntThink ( const Snark )
{
    if ( !
is_valid_entSnark ) )
    {
        return 
HAM_IGNORED;
    }

    static 
Float:Origin  Coord_e ];
    static 
Float:VelocityCoord_e ];
    static 
Float:Angles  Coord_e ];
    static 
Float:Flat    Coord_e ];
    static 
Float:CurrentTime;
    static 
Float:DieDelay;
    static 
Float:NextHunt;
    static 
Float:SPitch;
    static 
Enemy;
    
    
pevSnarkpev_velocityVelocity );
    
pevSnarkpev_originOrigin );

    if ( !
UTIL_IsInWorld OriginVelocity ) )
    {
        
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_KILLME );
        return 
HAM_IGNORED;
    }

    
CurrentTime get_gametime();
    
set_pevSnarkpev_nextthinkCurrentTime 0.1 );
    
    
pevSnarkpev_NextHuntNextHunt );
    
pevSnarkpev_DetonateDelayDieDelay );
    
pevSnarkpev_anglesAngles );

    if ( 
CurrentTime >= DieDelay )
    {
        if ( 
pevSnarkpev_Remove ) )
        {
            
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_KILLME );
            return 
HAM_IGNORED;
        }

        
set_pevSnarkpev_health, -1.0 );
        
CSqueak_Killed Snark0true );
        return 
HAM_IGNORED;
    }

    if ( 
pevSnarkpev_waterlevel ) != )
    {
        if ( 
pevSnarkpev_movetype ) == MOVETYPE_BOUNCE )
        {
            
set_pevSnarkpev_movetypeMOVETYPE_FLY );
        }

        
VectorScale Velocity0.9Velocity );
        
Velocity] += 8.0;

        
set_pevSnarkpev_velocityVelocity );
    }
    else if ( 
pevSnarkpev_movetype ) == MOVETYPE_FLY )
    {
        
set_pevSnarkpev_movetypeMOVETYPE_BOUNCE );
    }

    if ( 
NextHunt CurrentTime )
    {
        return 
HAM_IGNORED;
    }

    
set_pevSnarkpev_NextHuntCurrentTime 2.0 );
    
    
VectorCopy VelocityFlat );
    
Flat] = 0.0;
    
VectorNormalize FlatFlat );

    
engfuncEngFunc_MakeVectorsAngles );

    if ( ( 
Enemy pevSnarkpev_enemy ) ) == NULL_ENT || !is_user_aliveEnemy ) || zp_core_is_zombieEnemy ) )
    {
        
Enemy UTIL_BestVisibleEnemy Snark512.0 );
    }

    if ( 
0.3 <= DieDelay CurrentTime <= 0.5 )
    {
        
set_pevSnarkpev_scale2.0 );
        
emit_soundSnarkCHAN_VOICEgSnarkDieSoundVOL_NORMATTN_NORM0PITCH_NORM random_num00x3F ) );
    }

    
SPitch 155.0 60.0 * ( ( DieDelay CurrentTime ) / get_pcvar_floatpCvarDetonateDelay ) );

    if ( 
SPitch 80.0 )  { SPitch 80.0; }

    if ( 
Enemy != NULL_ENT && !zp_core_is_zombieEnemy ) && is_user_aliveEnemy ) )
    {
        static 
Float:TargetCoord_e ];
        static 
Float:Vel;
        static 
Float:Adj;
    
        
pevSnarkpev_EnemyTargetTarget );
        
        if ( 
UTIL_FVisibleSnarkEnemy ) )
        {
            static 
Float:EyePositionCoord_e ];
            
UTIL_EyePosition EnemyEyePosition );

            
VectorSubtract EyePositionOriginTarget );
            
VectorNormalize TargetTarget );
        
            
set_pevSnarkpev_EnemyTargetTarget );
        }

        
Vel VectorLength Velocity );
        
Adj 50.0 / ( Vel 10.0 );
        
        if ( 
Adj 1.2 )  { Adj 1.2; }
        
        
Velocity] = Velocity] * Adj Target] * 300.0;
        
Velocity] = Velocity] * Adj Target] * 300.0;
        
Velocity] = Velocity] * Adj Target] * 300.0;

        
set_pevSnarkpev_velocityVelocity );
    }

    if ( 
pevSnarkpev_flags ) & FL_ONGROUND )
    {
        
set_pevSnarkpev_avelocityFloat:{ 0.00.00.0 } );
    }
    else
    {
        static 
Float:AVelocityCoord_e ];
        
pevSnarkpev_avelocityAVelocity );

        if ( 
AVelocity] == 0.0 && AVelocity] == 0.0 && AVelocity] == 0.0 )
            {
            
AVelocity] = random_float( -100.0100.0 );
            
AVelocity] = random_float( -100.0100.0 );
        
            
set_pevSnarkpev_avelocityAVelocity );
        }
    }

    static 
Float:PosPrevCoord_e ];
    
pevSnarkpev_PosPrevPosPrev );
    
    
VectorSubtract OriginPosPrevPosPrev );

    if ( 
VectorLength PosPrev ) < 1.0 )
    {
        
Velocity] = random_float( -100.0100.0 );
        
Velocity] = random_float( -100.0100.0 );
        
        
set_pevSnarkpev_velocityVelocity );
    }

    
set_pevSnarkpev_PosPrevOrigin );
    
    
vector_to_angleVelocityAngles );
    
    
Angles] = 0.0;
    
Angles] = 0.0;
    
    
set_pevSnarkpev_anglesAngles );
    
    return 
HAM_IGNORED;
}


public 
CSqueak_SuperBounceTouch ( const Snark, const Other )
{
    if ( !
is_valid_entSnark ) )
    {
        return;
    }

    static 
Float:Angles Angle_e ];
    static 
Float:NextHit;
    static 
Float:DieDelay;
    static 
Float:NextAttack;
    static 
Float:NextBounceSoundTime;
    static 
Float:SPitch;
    static 
Float:CurrentTime;
    static 
Owner;

    
Owner pevSnarkpev_owner );
    
    if ( 
Owner && Other == Owner )
    {
        return;
    }

    
SPitch PITCH_NORM 1.0;
    
CurrentTime get_gametime();
    
    
set_pevSnarkpev_ownerNULL_ENT );
    
    
pevSnarkpev_anglesAngles );
    
pevSnarkpev_NextHitNextHit );
    
pevSnarkpev_DetonateDelayDieDelay );
    
pevSnarkpev_NextAttackNextAttack );
    
pevSnarkpev_NextBounceSoundTimeNextBounceSoundTime );
    
    
Angles] = 0.0;
    
Angles] = 0.0;
    
    
set_pevSnarkpev_anglesAngles );

    if ( 
NextHit CurrentTime )
    {
        return;
    }

    
SPitch 155.0 60.0 * ( ( DieDelay CurrentTime ) / get_pcvar_floatpCvarDetonateDelay ) );

    if ( 
is_user_aliveOther ) && pevOtherpev_takedamage ) && NextAttack CurrentTime )
    {
        static 
Hit;
        
Hit global_getglb_trace_ent );
    
        if ( 
Hit == Other && pevHitpev_modelindex ) != pevSnarkpev_modelindex ))
        {
            
Owner pevSnarkpev_RealOwner );

            if (
is_user_aliveOwner ) && !zp_core_is_zombieOther ) )
            {
                static 
Float:Forward    Coord_e ];
                static 
Float:EndPos     Coord_e ];
                static 
Float:OriginSnarkCoord_e ];
                static 
Float:OriginOtherCoord_e ];
                static 
Trace;
                static 
Float:Damage;

                
Trace create_tr2();
                
                
pevSnarkpev_dmgDamage );
                
pevSnarkpev_originOriginSnark );
                
pevOtherpev_originOriginOther );
                
                
engfuncEngFunc_TraceLineOriginSnarkOriginOtherDONT_IGNORE_MONSTERSSnarkTrace );
                
                
get_tr2TraceTR_vecPlaneNormalForward );
                
get_tr2TraceTR_vecEndPosEndPos );
                
                
ExecuteHamHam_TraceBleedOtherDamageForwardTraceDMG_SLASH );
                
free_tr2Trace );

                
FX_BloodDrips EndPosBLOOD_COLOR_RED, .Amount floatroundDamage ) ); 
                
                
ExecuteHamHam_TakeDamageOtherSnarkOwnerDamageDMG_SLASH );
                
set_pevSnarkpev_dmgget_pcvar_floatpCvarDamage ) );
            }

            
emit_soundSnarkCHAN_WEAPONgSnarkAttackSoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            
set_pevSnarkpev_NextAttackCurrentTime 0.5 );
        }
    }    

    
set_pevSnarkpev_NextHitCurrentTime 0.1 );
    
set_pevSnarkpev_NextHuntCurrentTime );

    if ( 
CurrentTime NextBounceSoundTime )
    {
        return;
    }

    if ( !( 
pevSnarkpev_flags ) & FL_ONGROUND ) )
    {
        switch ( 
random10 ) )
        {
            case 
.. emit_soundSnarkCHAN_VOICEgSnarkHunt1SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            case 
.. emit_soundSnarkCHAN_VOICEgSnarkHunt2SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
            default     : 
emit_soundSnarkCHAN_VOICEgSnarkHunt3SoundVOL_NORMATTN_NORM0floatroundSPitch ) );
        }
    }

    
set_pevSnarkpev_NextBounceSoundTimeCurrentTime 0.5 );
}


CSqueak_Create ( const Player, const Float:OriginCoord_e ], const Float:AnglesCoord_e], const Float:VelocityCoord_e ] )
{
    new 
Snark create_entitygGenericEntity );
    
    if (
is_user_alivePlayer ) && is_valid_entSnark ) )
    {
        
set_pevSnarkpev_classnamegSnarkClassName );
        
set_pevSnarkpev_groupinfogSnarkClassNameReference );
        
set_pevSnarkpev_ownerPlayer );
        
set_pevSnarkpev_originOrigin );
        
set_pevSnarkpev_anglesAngles );
        
set_pevSnarkpev_velocityVelocity );
        
        
CSqueak_Spawn PlayerSnarkOrigin );
        
        return 
Snark;
    }
    
    return 
NULL_ENT;
}


CSqueak_Spawn ( const Player, const Snark, const Float:OriginCoord_e ] )
{
    new 
Float:CurrentTime get_gametime();
    
    
set_pevSnarkpev_movetypeMOVETYPE_BOUNCE );
    
set_pevSnarkpev_solidSOLID_BBOX );
    
    
entity_set_model SnarkgSnarkModel );
    
entity_set_size  SnarkFloat:{ -6.0, -6.00.0 }, Float:{ 6.06.08.0 } );
    
entity_set_originSnarkOrigin );
    
    
set_pevSnarkpev_nextthinkCurrentTime 0.1 );
    
    
set_pevSnarkpev_NextHuntCurrentTime 1000000.0 ); // NextHunt
    
set_pevSnarkpev_DetonateDelayCurrentTime get_pcvar_floatpCvarDetonateDelay ) ); // DetonateDelay
    
set_pevSnarkpev_NextBounceSoundTimeCurrentTime ); // NextBounceSoundTime
    
set_pevSnarkpev_RealOwnerPlayer ); // RealOwner
    
    
set_pevSnarkpev_flagspevSnarkpev_flags ) | FL_MONSTER );
    
set_pevSnarkpev_takedamageDAMAGE_AIM );
    
set_pevSnarkpev_healthget_pcvar_floatpCvarHealth ) + gSnarkHealthReference );
    
set_pevSnarkpev_gravityget_pcvar_floatpCvarGravity ) );
    
set_pevSnarkpev_frictionget_pcvar_floatpCvarFriction ) );
    
set_pevSnarkpev_fovget_pcvar_numpCvarFieldOfView ) );
    
// set_pev( Snark, pev_dmg, get_pcvar_float( pCvarDamagePop ) );
    
    // --| Force snark to run.
    
set_pevSnarkpev_sequencewsqueak_run );
    
set_pevSnarkpev_framerate1.0 );
    
set_pevSnarkpev_animtimeCurrentTime );
    
    if ( 
get_pcvar_numpCvarShowTrail ) )
    {
        
message_begin MSG_BROADCASTSVC_TEMPENTITY );
        
write_byte TE_BEAMFOLLOW );
        
write_short Snark );
        
write_short gSmokeTrail );
        
write_byte TRAIL_LIFE );   // life
        
write_byte TRAIL_WIDTH );  // width
        
write_byte TRAIL_RED );
        
write_byte TRAIL_GREEN );
        
write_byte TRAIL_BLUE );
        
write_byte TRAIL_BRIGTHNESS );
        
message_end();
    }
}


public 
CSqueak_WeaponIdle ( const Player )
{
    if (
is_user_alivePlayer ) && gHasSnarkPlayer } && gWeaponActivePlayer } )
    {
        static 
Float:CurrentTime;
        
CurrentTime get_gametime();
    
        if ( 
gTimeWeaponIdlePlayer ] > CurrentTime )
        {
            return;
        }
    
        if ( 
gJustThrownPlayer } )
        {
            if ( !
gPlayerAmmoPlayer } )
            {
                
RemoveWeapon Playerget_pdata_cbasePlayerm_pActiveWeapon ) );
                return;
            }

            
UTIL_PlayWeaponAnimation Playersqueak_up );
            
gTimeWeaponIdlePlayer ] = CurrentTime random_float 10.015.0 );
            
            return;
        }

        new 
Animation;
        new 
Float:NewTime;

        switch ( 
random_num010 ) )
        {
            case 
.. :
            {
                
Animation squeak_idle1;
                
NewTime   30.0 16.0 * ( 2.0 );
            }
            case 
.. :
            {
                
Animation squeak_fidgetfit;
                
NewTime   70.0 16.0;
            }
            default :
            {
                
Animation squeak_fidgetnip;
                
NewTime   80.0 16.0;
            }
        }

        
UTIL_PlayWeaponAnimation PlayerAnimation );
        
gTimeWeaponIdlePlayer ] = CurrentTime NewTime;
    }
}


ChangeWeaponToSnark ( const Player )
{
    
set_pevPlayerpev_viewmodel2  gModel_V );
    
set_pevPlayerpev_weaponmodel2gModel_P );
}


UpdateHud ( const Player )
{
    
message_beginMSG_ONE_UNRELIABLEgMsgidAmmoX, .player Player );
    
write_byte12 );
    
write_bytegPlayerAmmoPlayer } );
    
message_end();
}


RemoveWeapon ( const Player, const Weapon )
{
    if(
is_user_alivePlayer ))
    {
        
ExecuteHamBHam_Weapon_RetireWeaponWeapon );
        
ExecuteHamBHam_RemovePlayerItemPlayerWeapon );
        
ExecuteHamBHam_Item_KillWeapon );
        
        
set_pevPlayerpev_weaponspevPlayerpev_weapons ) & ~( << gWeaponIndex ) );
        
cs_set_user_bpammoPlayergWeaponIndex);
        
        
gHasSnarkPlayer } = false;
        
gWeaponActivePlayer } = false;
    }
}


stock bool:UTIL_IsBSPModel ( const Entity )
{
    return (
pevEntitypev_movetype ) == MOVETYPE_STEP );
}


UTIL_BestVisibleEnemy ( const Snark, const Float:DistanceToSearch /* , const Flags */ )
{
    static List[ 
MAX_CLIENTS ];
    static 
Float:Distance;
    static 
Float:Nearest;
    static 
ReturnEntity;
    static 
Count;
    static 
Entity;
    static 
i;
    
    
Nearest 8192.0;
    
ReturnEntity NULL_ENT;
    
    
Count find_sphere_classSnark"player"DistanceToSearch, List, sizeof List );

    for ( 
0Counti++ )
    {
        
Entity = List[ ];
    
        if ( !
is_user_aliveEntity ) || zp_core_is_zombieEntity ))
        {
            continue;
        }
        
        if ( 
UTIL_FInViewCone SnarkEntity ) && UTIL_FVisibleSnarkEntity ) )
        {
            if ( ( 
Distance entity_rangeSnarkEntity ) ) <= Nearest )
            {
                
Nearest Distance;
                
ReturnEntity Entity;
            }
        }
    }

    
set_pevSnarkpev_enemyReturnEntity );
    return 
ReturnEntity;
}



UTIL_PlayWeaponAnimation ( const Player, const Sequence )
{
    
set_pevPlayerpev_weaponanimSequence );
    
    
message_beginMSG_ONE_UNRELIABLESVC_WEAPONANIM, .player Player );
    
write_byteSequence );
    
write_bytepevPlayerpev_body ) );
    
message_end();
}


bool:UTIL_IsInWorld ( const Float:OriginCoord_e ], const Float:VelocityCoord_e ] )
{
    static 
i;
    
    for ( 
x<= zi++ )
    {
        if ( !( -
4096.0 Origin] < 4096.0 ) && !( -2000.0 Velocity] < 2000.0 ) )
        {
            return 
false;
        }
    }
    return 
true;
}


UTIL_RandomBloodVector Float:DirectionCoord_e ] )
{
    
Direction] = random_float( -1.01.0 );
    
Direction] = random_float( -1.01.0 );
    
Direction] = random_float(  0.01.0 );
}


FX_BloodDrips ( const Float:OriginCoord_e ], const BloodColor, const Amount )
{
    
message_begin_fMSG_PVSSVC_TEMPENTITYOriginNULL_ENT );
    
write_byteTE_BLOODSPRITE );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_shortgBloodSpray );         // initial sprite model
    
write_shortgBloodDrop );          // droplet sprite models
    
write_byteBloodColor );           // color index into host_basepal
    
write_byteminmax3, ( Amount 255 255 Amount ) / 10 ), 16 ) );  // size
    
message_end();
}


FX_StreakSplash ( const Float:OriginCoord_e ], const Float:DirectionCoord_e ], const Color, const Count, const Speed, const VelocityRange )
{
    
message_begin_fMSG_PVSSVC_TEMPENTITYOriginNULL_ENT );
    
write_byteTE_STREAK_SPLASH );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fOrigin] );
    
write_coord_fDirection] );
    
write_coord_fDirection] );
    
write_coord_fDirection] );
    
write_byteminColor255 ) );
    
write_shortCount );
    
write_shortSpeed );
    
write_shortVelocityRange );// random velocity modifier
    
message_end();
}


stock FX_TraceBleed( const Victim, const Float:Damage, const Float:DirCoord_e ], const TraceResult:Trace )
{
    new 
TraceResult:BloodTrace;
    new 
Float:TraceDirCoord_e ]; 
    new 
Float:EndPos  Coord_e ];
    new 
Float:Noise;
    new 
Float:Fraction;
    new 
Count;

    if ( 
Damage 10 )
    {
        
Noise 0.1;
        
Count 1;
    }
    else if ( 
Damage 25 )
    {
        
Noise 0.2;
        
Count 2;
    }
    else
    {
        
Noise 0.3;
        
Count 4;
    }

    for ( new 
Count i++ )
    {
        
VectorScale Dir, -1.0TraceDir );
        
        
TraceDir] += random_float( -NoiseNoise );
        
TraceDir] += random_float( -NoiseNoise );
        
TraceDir] += random_float( -NoiseNoise );
        
        
get_tr2TraceTR_vecEndPosEndPos );
        
VectorMA EndPos, -172.0TraceDirTraceDir );

        
engfuncEngFunc_TraceLineEndPosTraceDirIGNORE_MONSTERSVictimBloodTrace );
        
get_tr2BloodTraceTR_flFractionFraction );
        
        if ( 
Fraction != 1.0 )
        {
            
FX_BloodDecalTraceBloodTraceEndPosBLOOD_COLOR_RED );
        }
    }
}


stock FX_BloodDecalTrace ( const TraceResult:Trace, const Float:EndPosCoord_e ], const BloodColor )
{
    new 
Hit;
    new 
BaseIndex;
    new 
DecalIndex;
    new 
Float:Fraction
    
    switch ( 
BloodColor )
    {
        case 
BLOOD_COLOR_YELLOW BaseIndex get_decal_index"{yblood1" );
        case 
BLOOD_COLOR_RED    BaseIndex get_decal_index"{blood1" );
    }

    
DecalIndex BaseIndex random_num0);
    
    
Hit max0get_tr2TraceTR_pHit ) );
    
get_tr2TraceTR_flFractionFraction );
    
    if ( 
Fraction == 1.0 || ( Hit && !UTIL_IsBSPModel Hit ) ) )
    {
        return;
    }   

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteHit TE_DECAL TE_WORLDDECAL );
    
write_coord_fEndPos] );
    
write_coord_fEndPos] );
    
write_coord_fEndPos] );
    
write_byteDecalIndex );

    if ( 
Hit )
    {
        
write_shortHit );
    }

    
message_end();
}

stock UTIL_EntitiesInBox ( List[], const ListMax, const Float:MinsCoord_e ], const Float:MaxsCoord_e ], const Flags )
{
    
/*
    static Float:Origin [ Coord_e ];
    static Float:Delta  [ Coord_e ];
    static Float:Mins   [ Coord_e ];
    static Float:Maxs   [ Coord_e ];
    
    pev( Snark, pev_origin, Origin );
    
    Delta[ x ] = Delta[ y ] = Delta[ z ] = DistanceToSearch;
    
    VectorSubtract ( Origin, Delta, Mins );
    VectorAdd ( Origin, Delta, Maxs );
    
    Count = UTIL_EntitiesInBox ( List, sizeof List, Mins, Maxs, Flags );
    */
    
    
static Float:AbsMinsCoord_e ];
    static 
Float:AbsMaxsCoord_e ];
    static 
Count;
    static 
Entity;
    
    
Count 0;
    
    for ( 
Entity 1Entity <= gMaxEntitiesEntity++ )  if( is_valid_entEntity ) )
    {
        if ( !( 
pevEntitypev_flags ) & Flags ) )
        {
            continue;
        }

        
pevEntitypev_absminAbsMins );
        
pevEntitypev_absmaxAbsMaxs );

        if ( 
Mins] > AbsMaxs] || Mins] > AbsMaxs] || Mins] > AbsMaxs] ||
        
Maxs] < AbsMins] || Maxs] < AbsMins] || Maxs] < AbsMins] )
        {
            continue;
        }

        List[ 
Count ] = Entity;
        
        if ( 
Count++ >= ListMax )
        {
            return 
Count;
        }
    }

    return 
Count;
}


bool:UTIL_FVisible ( const Entity, const Other )
{
    static 
Float:LookerOriginCoord_e ];
    static 
Float:TargetOriginCoord_e ];
    static 
Float:Fraction;
    static 
LookerWLevel;
    static 
TargetWLevel;
    
    if ( 
pevOtherpev_flags ) & FL_NOTARGET )
    {
        return 
false;
    }

    
LookerWLevel pev Entitypev_waterlevel );
    
TargetWLevel pev Otherpev_waterlevel );
    
    if ( ( 
LookerWLevel != && TargetWLevel == ) || ( LookerWLevel == && TargetWLevel == 0  ) )
    {
        return 
false;
    }

    
UTIL_EyePosition EntityLookerOrigin );
    
UTIL_EyePosition OtherTargetOrigin );
    
    
engfuncEngFunc_TraceLineLookerOriginTargetOriginIGNORE_MONSTERS IGNORE_GLASSEntity);
    
get_tr20TR_flFractionFraction );
    
    return 
Fraction == 1.0 true false;
}


bool:UTIL_FInViewCone ( const Entity, const Other )
{
    static 
Float:Angles Coord_e ];
    static 
Float:HOriginCoord_e ];
    static 
Float:Origin Coord_e ];
    
    
pevEntitypev_anglesAngles );
    
engfuncEngFunc_MakeVectorsAngles );
    
global_getglb_v_forwardAngles );
    
    
Angles] = 0.0;
    
    
pevEntitypev_originHOrigin );
    
pevOtherpev_originOrigin );
    
    
VectorSubtract OriginHOriginOrigin );
    
Origin] = 0.0;
    
    
VectorNormalize OriginOrigin );

    if ( 
DotProduct OriginAngles ) > pevEntitypev_fov ) )
    {
        return 
true;
    }
    
    return 
false;
}


UTIL_EyePosition ( const EntityFloat:OriginCoord_e ] )
{
    static 
Float:ViewOfsCoord_e ];
    
    
pevEntitypev_originOrigin );
    
pevEntitypev_view_ofsViewOfs );
    
    
VectorAdd OriginViewOfsOrigin );
}


stock bool:UTIL_LiquidContents( const Float:SourceCoord_e ] )
{
    new 
Contents point_contentsSource );
    return ( 
Contents == CONTENTS_WATER || Contents == CONTENTS_SLIME || Contents == CONTENTS_LAVA );
}


VectorNormalize ( const Float:SourceCoord_e ], Float:OutputCoord_e ] )
{
    static 
Float:InvLen;
    
    
InvLen 1.0 VectorLength Source );
    
    
Output] = Source] * InvLen;
    
Output] = Source] * InvLen;
    
Output] = Source] * InvLen;


Last edited by Depresie; 10-12-2015 at 13:47.
Depresie 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 05:31.


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