AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Knife switch error ? (https://forums.alliedmods.net/showthread.php?t=324280)

elmedin 05-11-2020 07:03

[Help] Knife switch error ?
 
Hey, im having a glitch with this knife, when i press 3 and use the knife everything is ok but when i wanna go back to my primary or secondary weapon ( 1 or 2 ) it wont work it will switch me back to the knife :S

PHP Code:

#include <amxmodx>
#include <fakemeta_util>
#include <hamsandwich>
#include <zombieplague>
#include <xs>

// https://forums.alliedmods.net/showthread.php?t=184780
#include <beams>

#define IsCustomItem(%1) (get_pdata_int(%1, m_iId, linux_diff_weapon) == CSW_KNIFE)
#define IsUserHasDreadNova(%1) get_bit(gl_iBitUserHasDreadNova, %1)
#define IsUserHasSummoner(%1) get_bit(gl_iBitUserHasSummoner, %1)
#define DreadNovaInBMode(%1) (get_pdata_int(%1, m_iAttackState, linux_diff_weapon) >= WPNSTATE_KNIFE_B)
#define getComboData(%1) (get_pdata_int(%1, m_iComboData, linux_diff_weapon))
#define setComboData(%1,%2) (set_pdata_int(%1, m_iComboData, %2, linux_diff_weapon))

#define m_iSlashAnim m_iGlock18ShotsFired
#define m_iAttackState m_iFamasShotsFired
#define m_iComboData m_iWeaponState

#define pev_flHoldTime pev_fuser1
#define pev_flNextEnergy pev_fuser2
#define pev_iEnergy pev_iuser1

#define pev_iSumAnim pev_iuser3
#define pev_iSumState pev_iuser4

#define get_bit(%1,%2) ((%1 & (1 << (%2 & 31))) ? 1 : 0)
#define set_bit(%1,%2) %1 |= (1 << (%2 & 31))
#define reset_bit(%1,%2) %1 &= ~(1 << (%2 & 31))

#define DONT_BLEED -1
#define PDATA_SAFE 2
#define ACT_RANGE_ATTACK1 28
#define DMG_GRENADE (1<<24)

enum
{
    
WPNSTATE_KNIFE_A 0,
    
WPNSTATE_KNIFE_A_ATTACK,

    
WPNSTATE_KNIFE_B,
    
WPNSTATE_KNIFE_B_ATTACK,
    
WPNSTATE_KNIFE_B_HIT,
    
WPNSTATE_KNIFE_B_CHARGE,
    
WPNSTATE_KNIFE_B_CHARGE_HIT,
    
WPNSTATE_KNIFE_B_CHARGE_END
};

enum
{
    
SUMMONER_IDLE 0,
    
SUMMONER_SLASH,
    
SUMMONER_SLASH_HIT,
    
SUMMONER_SLASH_END,
    
SUMMONER_STAB,
    
SUMMONER_STAB_FIRE,
    
SUMMONER_STAB_END,
    
SUMMONER_SPAWN,
    
SUMMONER_DISAPPEAR
};

/* ~ [ Weapon Settings ] ~ */
#define ADD_KNIFE_TO_EXTRA_ITEMS true
#define REMOVE_KNIFE_IF_INFECTED false

new const WEAPON_REFERENCE[] = "weapon_knife";
new const 
WEAPON_WEAPONLIST[] = "x/knife_summonknife";
new const 
WEAPON_MODEL_VIEW[] = "models/x/v_summonknife.mdl";
new const 
WEAPON_MODEL_PLAYER[][] =
{
    
"models/x/p_summonknife_a.mdl",
    
"models/x/p_summonknife_b.mdl",
    
"models/x/p_summonknife_charging.mdl"
};
new const 
WEAPON_ANIMATIONS[][] = 
{
    
"knife"// A mode (in CSO: katanad)
    
"knife" // B mode (in CSO: sfsword)
};
new const 
WEAPON_SOUNDS[][] = 
{
    
// Slash
    
"weapons/summonknife1.wav"// 0
    
"weapons/summonknife2.wav"// 1
    
"weapons/summonknife3.wav"// 2
    
"weapons/summonknife4.wav"// 3

    // Stab
    
"weapons/summonknife_stab.wav"// 4
    
"weapons/summonknife_charging_relese.wav"// 5
    
    // Hit Sounds
    
"weapons/mastercombat_hit1.wav"// 6
    
"weapons/mastercombat_stab.wav"// 7
    
"weapons/mastercombat_wall.wav"// 8

    // Summoner ready
    
"weapons/summoning_ready.wav" // 9
};
new const 
WEAPON_COMBO_DATA[] = { 11}; // 0 - Slash, 1 - stab
const FloatWEAPON_NEXT_ATTACK 0.27;

const 
WEAPON_MAX_ENERGY 100;
const 
FloatWEAPON_ENERGY_LEFT 0.15// time for lost energy in summoner mode
const FloatWEAPON_ENERGY_DELAY 0.25// time for new energy

const FloatWEAPON_SLASH_DISTANCE 125.0;
const 
FloatWEAPON_SLASH_DAMAGE 100.0;
const 
FloatWEAPON_SLASH_DAMAGE_EX 100.0;
const 
FloatWEAPON_SLASH_KNOCKBACK 100.0;

const 
FloatWEAPON_STAB_DISTANCE 150.0;
const 
FloatWEAPON_STAB_DAMAGE 190.0;
const 
FloatWEAPON_STAB_KNOCKBACK 500.0;

const 
FloatENTITY_EXP_KNOCK_POWER 1500.0// It is knockback for victims of laser and cannon explosions

/* ~ [ TraceLine: Attack Angles ] ~ */
new FloatflAngles_Forward[] =

    
0.0
    
2.55.07.510.012.515.017.520.022.525.0,
    -
2.5, -5.0, -7.5, -10.0, -12.5, -15.0, -17.5, -20.0, -22.5, -25.0
};

/* ~ [ Entity: Cannon ] ~ */
new const ENTITY_CANNON_CLASSNAME[] = "ent_dn_cannon";
new const 
ENTITY_CANNON_MODEL[] = "models/x/ef_summonknife_cannon.mdl";
new const 
ENTITY_CANNON_SOUND[] = "weapons/plasmagun_exp.wav"// idk what sounds use in CSO, but it sound similar original
new const ENTITY_CANNON_SPRITE[] = "sprites/x/ef_summon_charging_exp.spr";
const 
FloatENTITY_CANNON_SPEED 1500.0;
const 
FloatENTITY_CANNON_RADIUS 100.0;
const 
ENTITY_CANNON_DMGTYPE DMG_GRENADE;
#define ENTITY_CANNON_DAMAGE random_float(500.0, 700.0)

/* ~ [ Entity: Summoner ] ~ */
new const ENTITY_SUMMONER_CLASSNAME[] = "ent_dn_summoner";
new const 
ENTITY_SUMMONER_MODEL[] = "models/x/summoner.mdl";
new const 
ENTITY_SUMMONER_SPRITES[][] =
{
    
"sprites/x/ef_summoner_summon02.spr"// 0 | summon
    
"sprites/x/ef_summoner_unsummon02.spr"// 1 | disappear
    
"sprites/x/ef_summoner_stab1.spr" // 2 | stab exp
};
new const 
ENTITY_SUMMONER_SOUNDS[][] =
{
    
// Summoner slash
    
"weapons/summon_slash1.wav"// 0
    
"weapons/summon_slash2.wav"// 1
    
"weapons/summon_slash3.wav"// 2
    
"weapons/summon_slash4.wav"// 3

    // Summoner stab
    
"weapons/summon_stab.wav"// 4 | start
    
"weapons/summon_stab_fire.wav"// 5 | fire

    // Summoner spawn and disappear
    
"weapons/summon_summon.wav"// 6 | spawn
    
"weapons/summon_unsummon.wav" // 7 | die
};
const 
FloatENTITY_SUMMONER_RAISED 10.0;
const 
FloatENTITY_SUMMONER_NEXTTHINK 0.1// in idle (im recomend 0.1)
const FloatSUMMONER_SLASH_DISTANCE 200.0;
const 
FloatSUMMONER_SLASH_DAMAGE 300.0;
const 
FloatSUMMONER_SLASH_KNOCKBACK 300.0;
const 
FloatSUMMONER_STAB_EXP_RADIUS 150.0;
const 
SUMMONER_STAB_EXP_DMGTYPE DMG_GRENADE;
#define ENTITY_STAB_EXP_DAMAGE random_float(300.0, 400.0)

/* ~ [ Entity: Summoner Swing ] ~ */
new const ENTITY_SWING_CLASSNAME[] = "ent_dn_swing";
new const 
ENTITY_SWING_MODEL[] = "models/x/ef_summoner_swing.mdl";

/* ~ [ Entity: Explosion Ring ] ~ */
new const ENTITY_RING_CLASSNAME[] = "ent_dn_ring";
new const 
ENTITY_RING_MODEL[] = "models/x/ef_summoner_summoning.mdl";
const 
FloatENTITY_RING_KNOCK_RADIUS 250.0;
const 
FloatENTITY_RING_KNOCK_POWER 50.0;

/* ~ [ Entity: Beam ] ~ */
new const ENTITY_BEAM_CLASSNAME[] = "ent_dn_beam";
new const 
ENTITY_BEAM_SPRITE[] = "sprites/x/ef_summoner_laserbeam.spr";
const 
FloatENTITY_BEAM_WIDTH 350.0;
const 
FloatENTITY_BEAM_BRIGHTNESS 255.0;
const 
FloatENTITY_BEAM_SCROLLRATE 16.0;
#define ENTITY_BEAM_COLOR {255.0, 255.0, 255.0}

/* ~ [ Weapon Animations ] ~ */
#define WEAPON_ANIM_IDLE_TIME 61/30.0
#define WEAPON_ANIM_SLASH_TIME 16/30.0
#define WEAPON_ANIM_SLASH_END_TIME 26/30.0
#define WEAPON_ANIM_DRAW_A_TIME 21/30.0
#define WEAPON_ANIM_STAB1_TIME 26/30.0
#define WEAPON_ANIM_STAB2_TIME 21/30.0
#define WEAPON_ANIM_STAB_END_TIME 26/30.0
#define WEAPON_ANIM_DRAW_B_TIME 31/30.0
#define WEAPON_ANIM_CHARGING_S_TIME 40/30.0
#define WEAPON_ANIM_CHARGING_L_TIME 11/30.0
#define WEAPON_ANIM_CHARGING_R_TIME 26/30.0
#define WEAPON_ANIM_SUMMONING_TIME 40/30.0

enum
{
    
WEAPON_ANIM_IDLE_A 0,
    
WEAPON_ANIM_SLASH_1,
    
WEAPON_ANIM_SLASH_2,
    
WEAPON_ANIM_SLASH_3,
    
WEAPON_ANIM_SLASH_4,
    
WEAPON_ANIM_SLASH_END,
    
WEAPON_ANIM_DRAW_A,
    
WEAPON_ANIM_IDLE_B,
    
WEAPON_ANIM_STAB1// from A mode
    
WEAPON_ANIM_STAB2,
    
WEAPON_ANIM_STAB_END,
    
WEAPON_ANIM_DRAW_B,
    
WEAPON_ANIM_CHARGING_START,
    
WEAPON_ANIM_CHARGING_LOOP,
    
WEAPON_ANIM_CHARGING_RELEASE,
    
WEAPON_ANIM_SUMMONING
};

/* ~ [ Summoner Animations ] ~ */
enum
{
    
SUMMONER_ANIM_IDLE 0,
    
SUMMONER_ANIM_SLASH,
    
SUMMONER_ANIM_STAB 5,
    
SUMMONER_ANIM_SUMMON
};

#define SUMMONER_ANIM_IDLE_TIME 151/30.0
#define SUMMONER_ANIM_SLASH_TIME 41/30.0 - 0.4
#define SUMMONER_ANIM_STAB_TIME 61/30.0 - 0.5
#define SUMMONER_ANIM_SUMMON_TIME 83/30.0

/* ~ [ Offset's ] ~ */
// Linux extra offsets
#define linux_diff_animating 4
#define linux_diff_weapon 4
#define linux_diff_player 5

// CBaseAnimating
#define m_flFrameRate 36
#define m_flGroundSpeed 37
#define m_flLastEventCheck 38
#define m_fSequenceFinished 39
#define m_fSequenceLoops 40

// CBasePlayerItem
#define m_pPlayer 41
#define m_iId 43

// CBasePlayerWeapon
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
#define m_flTimeWeaponIdle 48
#define m_iGlock18ShotsFired 70
#define m_iFamasShotsFired 72
#define m_iWeaponState 74

// CBaseMonster
#define m_Activity 73
#define m_IdealActivity 74
#define m_LastHitGroup 75
#define m_flNextAttack 83

// CBasePlayer
#define m_flPainShock 108
#define m_iPlayerTeam 114
#define m_flLastAttackTime 220
#define m_rpgPlayerItems 367
#define m_pActiveItem 373
#define m_szAnimExtention 492

/* ~ [ Param's ] ~ */
new gl_iszAllocString_InfoTarget,
    
gl_iszAllocString_Cannon,
    
gl_iszAllocString_Summoner,
    
gl_iszAllocString_ExplosionRing,
    
gl_iszAllocString_Swing,
    
gl_iszAllocString_BeamKey,

    
gl_iszModelIndex_BloodSpray,
    
gl_iszModelIndex_BloodDrop,
    
gl_iszModelIndex_CannonExp,
    
gl_iszModelIndex_LaserExp,

    
gl_iszModelIndex_Summon,
    
gl_iszModelIndex_Unsummon,

    
gl_iMsgID_AmmoX,
    
gl_iMsgID_CurWeapon,
    
gl_iMsgID_WeaponList,
    
gl_iMsgID_ScreenFade,

    
gl_iBitUserHasDreadNova,
    
gl_iBitUserHasSummoner,

    
gl_iMaxPlayers;

#if ADD_KNIFE_TO_EXTRA_ITEMS == true

    
new gl_iItemID;

#endif

public plugin_init()
{
    
// https://cso.fandom.com/wiki/Dread_Nova
    
register_plugin("[ZP] Knife: Dread Nova""1.0 | 2019""xUnicorn (t3rkecorejz)");

    
#if ADD_KNIFE_TO_EXTRA_ITEMS == true

        //gl_iItemID = zp_register_extra_item("Dread Nova", 0, ZP_TEAM_HUMAN);

    #endif

    
register_event("HLTV""EV_RoundStart""a""1=0""2=0");

    
register_forward(FM_UpdateClientData,     "FM_Hook_UpdateClientData_Post"true);

    
// Weapon
    
RegisterHam(Ham_Weapon_WeaponIdle,         WEAPON_REFERENCE,     "CKnife__Idle_Pre"false);
    
RegisterHam(Ham_Item_Deploy,             WEAPON_REFERENCE,     "CKnife__Deploy_Post"true);
    
RegisterHam(Ham_Item_Holster,             WEAPON_REFERENCE,     "CKnife__Holster_Post"true);
    
RegisterHam(Ham_Item_PostFrame,         WEAPON_REFERENCE,     "CKnife__PostFrame_Pre"false);
    
RegisterHam(Ham_Weapon_PrimaryAttack,     WEAPON_REFERENCE,     "CKnife__PrimaryAttack_Pre"false);
    
RegisterHam(Ham_Weapon_SecondaryAttack,    WEAPON_REFERENCE,     "CKnife__SecondaryAttack_Pre"false);

    
// Entity
    
RegisterHam(Ham_Touch,                    "info_target",        "CEntity__Touch_Post"true);
    
RegisterHam(Ham_Think,                    "info_target",        "CEntity__Think_Pre"false);
    
RegisterHam(Ham_Think,                    "beam",                "CBeam__Think_Pre"false);
    
RegisterHam(Ham_Player_PreThink,        "player",            "CPlayer__PreThink_Pre"false);

    
gl_iMaxPlayers get_maxplayers();

    
// Messages
    
gl_iMsgID_AmmoX get_user_msgid("AmmoX");
    
gl_iMsgID_CurWeapon get_user_msgid("CurWeapon");
    
gl_iMsgID_WeaponList get_user_msgid("WeaponList");
    
gl_iMsgID_ScreenFade get_user_msgid("ScreenFade");
}

public 
plugin_precache()
{
    
// Weapon List
    
register_clcmd(WEAPON_WEAPONLIST"Command__HookWeapon");

    new 
i;

    
// Models
    
for(0sizeof WEAPON_MODEL_PLAYERi++)
        
engfunc(EngFunc_PrecacheModelWEAPON_MODEL_PLAYER[i]);

    
engfunc(EngFunc_PrecacheModelWEAPON_MODEL_VIEW);
    
engfunc(EngFunc_PrecacheModelENTITY_CANNON_MODEL);
    
engfunc(EngFunc_PrecacheModelENTITY_SUMMONER_MODEL);
    
engfunc(EngFunc_PrecacheModelENTITY_RING_MODEL);
    
engfunc(EngFunc_PrecacheModelENTITY_SWING_MODEL);
    
engfunc(EngFunc_PrecacheModelENTITY_BEAM_SPRITE);

    
// Sounds
    
for(0sizeof WEAPON_SOUNDSi++)
        
engfunc(EngFunc_PrecacheSoundWEAPON_SOUNDS[i]);

    for(
0sizeof ENTITY_SUMMONER_SOUNDSi++)
        
engfunc(EngFunc_PrecacheSoundENTITY_SUMMONER_SOUNDS[i]);

    
engfunc(EngFunc_PrecacheSoundENTITY_CANNON_SOUND);

    
UTIL_PrecacheSoundsFromModel(WEAPON_MODEL_VIEW);

    
// Generic
    
UTIL_PrecacheSpritesFromTxt(WEAPON_WEAPONLIST);

    
// Alloc String
    
gl_iszAllocString_InfoTarget engfunc(EngFunc_AllocString"info_target");
    
gl_iszAllocString_Cannon engfunc(EngFunc_AllocStringENTITY_CANNON_CLASSNAME);
    
gl_iszAllocString_Summoner engfunc(EngFunc_AllocStringENTITY_SUMMONER_CLASSNAME);
    
gl_iszAllocString_ExplosionRing engfunc(EngFunc_AllocStringENTITY_RING_CLASSNAME);
    
gl_iszAllocString_Swing engfunc(EngFunc_AllocStringENTITY_SWING_CLASSNAME);
    
gl_iszAllocString_BeamKey engfunc(EngFunc_AllocStringENTITY_BEAM_CLASSNAME);

    
// Model Index
    
gl_iszModelIndex_BloodSpray engfunc(EngFunc_PrecacheModel"sprites/bloodspray.spr");
    
gl_iszModelIndex_BloodDrop engfunc(EngFunc_PrecacheModel"sprites/blood.spr");
    
gl_iszModelIndex_CannonExp engfunc(EngFunc_PrecacheModelENTITY_CANNON_SPRITE);

    
gl_iszModelIndex_Summon engfunc(EngFunc_PrecacheModelENTITY_SUMMONER_SPRITES[0]);
    
gl_iszModelIndex_Unsummon engfunc(EngFunc_PrecacheModelENTITY_SUMMONER_SPRITES[1]);
    
gl_iszModelIndex_LaserExp engfunc(EngFunc_PrecacheModelENTITY_SUMMONER_SPRITES[2]);
    
//gl_iItemID = zp_register_extra_item("Dread Nova", 0, ZP_TEAM_HUMAN);
    
}








public 
plugin_natives()
{
    
register_native("zp_get_user_dreadnova""_get_user_dreadnova"1);
    
register_native("zp_give_user_dreadnova""_give_user_dreadnova"1);
    
register_native("zp_delete_user_dreadnova""_delete_user_dreadnova"1);
}

/* ~ [ AMX Mod X ] ~ */
#if AMXX_VERSION_NUM < 183
    
public client_disconnect(iPlayer_delete_user_dreadnova(iPlayer);
#else
    
public client_disconnected(iPlayer_delete_user_dreadnova(iPlayer);
#endif

public Command__HookWeapon(iPlayer)
{
    
engclient_cmd(iPlayerWEAPON_REFERENCE);
    return 
PLUGIN_HANDLED;
}

public 
_get_user_dreadnova(iPlayer) return get_bit(gl_iBitUserHasDreadNovaiPlayer);
public 
_give_user_dreadnova(iPlayer)
{
    
set_bit(gl_iBitUserHasDreadNovaiPlayer);
    
UTIL_WeaponList(iPlayerWEAPON_WEAPONLIST15100, -1, -121290);

    new 
iItem get_pdata_cbase(iPlayerm_pActiveItemlinux_diff_player);
    if(
pev_valid(iItem) == PDATA_SAFE)
    {
        
set_pev(iItempev_iEnergy0);

        if(
is_user_alive(iPlayer) && IsCustomItem(iItem))
            
ExecuteHamB(Ham_Item_DeployiItem);
    }
}

public 
_delete_user_dreadnova(iPlayer)
{
    
set_summoner_state(iPlayerSUMMONER_DISAPPEAR);

    
reset_bit(gl_iBitUserHasDreadNovaiPlayer);
    
UTIL_WeaponList(iPlayerWEAPON_REFERENCE, -1, -1, -1, -121290);
    
    if(
zp_get_user_sniper(iPlayer)){
    
_delete_user_dreadnova(iPlayer)
    }
    
}

/* ~ [ Zombie Plague ] ~ */
#if ADD_KNIFE_TO_EXTRA_ITEMS == true

    
public zp_extra_item_selected(iPlayeriItem)
    {
        if(
iItem != gl_iItemID) return PLUGIN_HANDLED;

        if(
IsUserHasDreadNova(iPlayer))
        {
            
client_print(iPlayerprint_center"*** You have already [Dread Nova] ***");
            return 
ZP_PLUGIN_HANDLED;
        }

        
_give_user_dreadnova(iPlayer);
        return 
PLUGIN_HANDLED;
    }

#endif

public zp_user_humanized_pre(iPlayer)
{
    if(
IsUserHasDreadNova(iPlayer))
        
UTIL_WeaponList(iPlayerWEAPON_WEAPONLIST15100, -1, -121290);
}

public 
zp_user_infected_pre(iPlayer)
{
    
#if REMOVE_KNIFE_IF_INFECTED == true

        
if(IsUserHasDreadNova(iPlayer))
            
reset_bit(gl_iBitUserHasSummoneriPlayer);

    
#endif

    
UTIL_WeaponList(iPlayerWEAPON_REFERENCE, -1, -1, -1, -121290);
    
set_summoner_state(iPlayerSUMMONER_DISAPPEAR);
}

/* ~ [ Events ] ~ */
public EV_RoundStart()
{
    new 
iEntity FM_NULLENT;
    while((
iEntity engfunc(EngFunc_FindEntityByStringiEntity"classname"ENTITY_SUMMONER_CLASSNAME)))
    {
        if(
pev_valid(iEntity))
            
set_pev(iEntitypev_flagsFL_KILLME);
    }

    for(new 
iPlayer 1iPlayer <= gl_iMaxPlayersiPlayer++)
    {
        if(!
is_user_connected(iPlayer)) continue;
        if(!
IsUserHasDreadNova(iPlayer)) continue;

        new 
iItem get_pdata_cbase(iPlayerm_rpgPlayerItems 3linux_diff_player);
        if(
pev_valid(iItem) && iItem)
            
set_pev(iItempev_iEnergy0);
    }
}

/* ~ [ Fakemeta ] ~ */
public FM_Hook_UpdateClientData_Post(iPlayerSendWeaponsCD_Handle)
{
    if(!
is_user_alive(iPlayer) || zp_get_user_zombie(iPlayer)) return;
    if(!
IsUserHasDreadNova(iPlayer)) return;

    new 
iItem get_pdata_cbase(iPlayerm_pActiveItemlinux_diff_player);
    if(
pev_valid(iItem) != PDATA_SAFE || !IsCustomItem(iItem)) return;

    
set_cd(CD_HandleCD_flNextAttackget_gametime() + 0.001);
}

/* ~ [ HamSandwich ] ~ */
public CKnife__Idle_Pre(iItem)
{
    if(!
IsCustomItem(iItem)) return HAM_IGNORED;
    if(
get_pdata_float(iItemm_flTimeWeaponIdlelinux_diff_weapon) > 0.0) return HAM_IGNORED;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;

    
UTIL_SendWeaponAnim(iPlayerDreadNovaInBMode(iItem) ? WEAPON_ANIM_IDLE_B WEAPON_ANIM_IDLE_A);
    
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_IDLE_TIMElinux_diff_weapon);

    return 
HAM_SUPERCEDE;
}

public 
CKnife__Deploy_Post(iItem)
{
    if(!
IsCustomItem(iItem)) return;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return;

    
set_pev(iPlayerpev_viewmodel2WEAPON_MODEL_VIEW);
    
set_pev(iPlayerpev_weaponmodel2WEAPON_MODEL_PLAYER[DreadNovaInBMode(iItem) ? 0]);

    
UTIL_SendWeaponAnim(iPlayerDreadNovaInBMode(iItem) ? WEAPON_ANIM_DRAW_B WEAPON_ANIM_DRAW_A);

    
set_pev(iItempev_flNextEnergyget_gametime() + 0.1);
    
UTIL_AmmoX(iPlayer15pev(iItempev_iEnergy));
    
UTIL_CurWeapon(iPlayer1CSW_KNIFE, -1);

    
set_pdata_string(iPlayerm_szAnimExtention 4WEAPON_ANIMATIONS[DreadNovaInBMode(iItem) ? 0], -1linux_diff_player linux_diff_animating);
    
set_pdata_float(iItemm_flTimeWeaponIdleDreadNovaInBMode(iItem) ? WEAPON_ANIM_DRAW_B_TIME WEAPON_ANIM_DRAW_A_TIMElinux_diff_weapon);
    
set_pdata_float(iPlayerm_flNextAttackDreadNovaInBMode(iItem) ? WEAPON_ANIM_DRAW_B_TIME WEAPON_ANIM_DRAW_A_TIMElinux_diff_player);
}

public 
CKnife__Holster_Post(iItem)
{
    if(!
IsCustomItem(iItem)) return;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return;

    if(
DreadNovaInBMode(iItem))
        
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Blinux_diff_weapon);
    else 
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Alinux_diff_weapon);

    
set_summoner_state(iPlayerSUMMONER_DISAPPEAR);

    
set_pev(iItempev_flHoldTime0.0);
    
set_pev(iItempev_flNextEnergy0.0);
    
setComboData(iItem0);
    
set_pdata_int(iItemm_iSlashAnim0linux_diff_weapon);
    
set_pdata_float(iItemm_flNextPrimaryAttack0.0linux_diff_weapon);
    
set_pdata_float(iItemm_flNextSecondaryAttack0.0linux_diff_weapon);
    
set_pdata_float(iItemm_flTimeWeaponIdle0.0linux_diff_weapon);
    
set_pdata_float(iPlayerm_flNextAttack0.0linux_diff_player);
}

public 
CKnife__PostFrame_Pre(iItem)
{
    if(!
IsCustomItem(iItem)) return HAM_IGNORED;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;

    new 
iButton pev(iPlayerpev_button);
    new 
iWeaponState get_pdata_int(iItemm_iAttackStatelinux_diff_weapon);
    new 
FloatflHoldTimepev(iItempev_flHoldTimeflHoldTime);
    
    switch(
iWeaponState)
    {
        case 
WPNSTATE_KNIFE_A_ATTACK// Slash end
        
{
            if(!(
iButton IN_ATTACK))
            {
                
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_SLASH_END);

                
set_pdata_int(iItemm_iSlashAnim0linux_diff_weapon);
                
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Alinux_diff_weapon);

                
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_SLASH_END_TIME 0.4linux_diff_player);
                
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_SLASH_END_TIME 0.4linux_diff_weapon);
                
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_SLASH_END_TIME 0.4linux_diff_weapon);
                
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_SLASH_END_TIMElinux_diff_weapon);
            }
        }
        case 
WPNSTATE_KNIFE_B_ATTACK// Hit
        
{
            
UTIL_FakeTraceLine(iPlayer7WEAPON_STAB_DISTANCEWEAPON_STAB_DAMAGEWEAPON_STAB_KNOCKBACKflAngles_Forwardsizeof flAngles_Forward);

            
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_HITlinux_diff_weapon);
            
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_STAB2_TIME 9/30.0linux_diff_player);
        }
        case 
WPNSTATE_KNIFE_B_HIT// After hit
        
{
            if(
iButton IN_ATTACK2 && get_pdata_float(iItemm_flNextSecondaryAttacklinux_diff_weapon) < 0.0// Charging start
            
{
                if(
flHoldTime WEAPON_ANIM_CHARGING_S_TIME)
                {
                    if(
pev(iPlayerpev_weaponanim) != WEAPON_ANIM_CHARGING_START)
                        
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_CHARGING_START);

                    
set_pev(iItempev_flHoldTimeflHoldTime 0.1);
                    
set_pdata_float(iItemm_flNextSecondaryAttack0.1linux_diff_weapon);
                    
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_CHARGING_S_TIMElinux_diff_weapon);
                }
                else 
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_CHARGElinux_diff_weapon); // Charging loop
            
}

            if(!(
iButton IN_ATTACK2))
            {
                if(
pev(iPlayerpev_weaponanim) == WEAPON_ANIM_CHARGING_START// If now in charge start and unhold attack2
                
{
                    
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_CHARGElinux_diff_weapon);

                    
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_STAB_END_TIME flHoldTimelinux_diff_player);
                    
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_STAB_END_TIME flHoldTimelinux_diff_weapon);
                    
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_STAB_END_TIME flHoldTimelinux_diff_weapon);
                    
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_STAB_END_TIMElinux_diff_weapon);

                    return 
HAM_IGNORED;
                }

                
// End stab
                
CKnife__StabEnd(iPlayeriItem);
            }
        }
        case 
WPNSTATE_KNIFE_B_CHARGE:
        {
            if(
iButton IN_ATTACK2// Charging loop
            
{
                
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_CHARGING_LOOP);
                
set_pev(iPlayerpev_weaponmodel2WEAPON_MODEL_PLAYER[2]);

                
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_CHARGElinux_diff_weapon);

                
set_pdata_float(iPlayerm_flNextAttack0.1linux_diff_player);
                
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_CHARGING_L_TIMElinux_diff_weapon);
                
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_CHARGING_L_TIMElinux_diff_weapon);
                
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_CHARGING_L_TIMElinux_diff_weapon);
            }
            else 
// Charging release (shoot)
            
{
                
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_CHARGING_RELEASE);
                
emit_sound(iPlayerCHAN_ITEMWEAPON_SOUNDS[5], VOL_NORMATTN_NORM0PITCH_NORM);
                
set_pev(iPlayerpev_weaponmodel2WEAPON_MODEL_PLAYER[1]);

                
// Player animation
                
static szAnimation[64];
                
formatex(szAnimationcharsmax(szAnimation), pev(iPlayerpev_flags) & FL_DUCKING "crouch_shoot_%s" "ref_shoot_%s"WEAPON_ANIMATIONS[1]);
                
UTIL_PlayerAnimation(iPlayerszAnimation);

                
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_CHARGE_HITlinux_diff_weapon);

                
set_pdata_float(iPlayerm_flNextAttack11/30.0linux_diff_player);
                
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_CHARGING_R_TIMElinux_diff_weapon);
                
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_CHARGING_R_TIMElinux_diff_weapon);
                
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_CHARGING_R_TIMElinux_diff_weapon);
            }
        }
        case 
WPNSTATE_KNIFE_B_CHARGE_HIT:
        {
            
Create_KnifeCannon(iPlayer);
            
UTIL_FakeTraceLine(iPlayer7WEAPON_STAB_DISTANCEWEAPON_STAB_DAMAGEWEAPON_STAB_KNOCKBACKflAngles_Forwardsizeof flAngles_Forward);

            
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_CHARGE_ENDlinux_diff_weapon);
            
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_CHARGING_R_TIME 11/30.0linux_diff_player);
        }
        case 
WPNSTATE_KNIFE_B_CHARGE_END// Stab end
        
{
            
CKnife__StabEnd(iPlayeriItem);
        }
    }

    return 
HAM_IGNORED;
}

public 
CKnife__PrimaryAttack_Pre(iItem)
{
    if(!
IsCustomItem(iItem)) return HAM_IGNORED;
    if(
get_pdata_int(iItemm_iAttackStatelinux_diff_weapon) >= WPNSTATE_KNIFE_B_ATTACK) return HAM_SUPERCEDE;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;

    if(
CKnife__CheckCombo(iPlayeriItem0) == 1)
    {
        
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Alinux_diff_weapon);
        return 
HAM_SUPERCEDE;
    }

    new 
FloatflNextAttack WEAPON_NEXT_ATTACK;
    new 
iSlashAnim get_pdata_int(iItemm_iSlashAnimlinux_diff_weapon);

    
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_SLASH_1 iSlashAnim);
    
emit_sound(iPlayerCHAN_ITEMWEAPON_SOUNDS[iSlashAnim], VOL_NORMATTN_NORM0PITCH_NORM);
    
set_pev(iPlayerpev_weaponmodel2WEAPON_MODEL_PLAYER[0]);

    
// Player animation
    
static szAnimation[64];
    
formatex(szAnimationcharsmax(szAnimation), pev(iPlayerpev_flags) & FL_DUCKING "crouch_shoot_%s" "ref_shoot_%s"WEAPON_ANIMATIONS[0]);
    
UTIL_PlayerAnimation(iPlayerszAnimation);

    if(
iSlashAnim >= 2)
    {
        
iSlashAnim 0;
        
flNextAttack WEAPON_NEXT_ATTACK 0.2;
    }
    else if(
iSlashAnim == 1iSlashAnim random_num(2,3);
    else 
iSlashAnim++;

    if(
iSlashAnim >= 2)
        
UTIL_FakeTraceLine(iPlayer6WEAPON_SLASH_DISTANCEWEAPON_SLASH_DAMAGEWEAPON_SLASH_KNOCKBACKflAngles_Forwardsizeof flAngles_Forward);
    else 
UTIL_FakeTraceLine(iPlayer6WEAPON_SLASH_DISTANCEWEAPON_SLASH_DAMAGE_EXWEAPON_SLASH_KNOCKBACKflAngles_Forwardsizeof flAngles_Forward);

    
set_summoner_state(iPlayerSUMMONER_SLASH);
    
set_pdata_int(iItemm_iSlashAnimiSlashAnimlinux_diff_weapon);
    
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_A_ATTACKlinux_diff_weapon);

    
set_pdata_float(iPlayerm_flNextAttackflNextAttacklinux_diff_player);
    
set_pdata_float(iItemm_flNextPrimaryAttackflNextAttacklinux_diff_weapon);
    
set_pdata_float(iItemm_flNextSecondaryAttackflNextAttacklinux_diff_weapon);
    
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_SLASH_TIMElinux_diff_weapon);

    return 
HAM_SUPERCEDE;
}

public 
CKnife__SecondaryAttack_Pre(iItem)
{
    if(!
IsCustomItem(iItem)) return HAM_IGNORED;
    if(
get_pdata_int(iItemm_iAttackStatelinux_diff_weapon) >= WPNSTATE_KNIFE_B_ATTACK) return HAM_SUPERCEDE;

    new 
iPlayer get_pdata_cbase(iItemm_pPlayerlinux_diff_weapon);
    if(!
IsUserHasDreadNova(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;

    if(
CKnife__CheckCombo(iPlayeriItem1) == 1)
    {
        
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Alinux_diff_weapon);
        return 
HAM_SUPERCEDE;
    }

    new 
FloatflNextAttack DreadNovaInBMode(iItem) ? WEAPON_ANIM_STAB2_TIME WEAPON_ANIM_STAB1_TIME;

    
UTIL_SendWeaponAnim(iPlayerDreadNovaInBMode(iItem) ? WEAPON_ANIM_STAB2 WEAPON_ANIM_STAB1);
    
emit_sound(iPlayerCHAN_ITEMWEAPON_SOUNDS[4], VOL_NORMATTN_NORM0PITCH_NORM);
    
set_pev(iPlayerpev_weaponmodel2WEAPON_MODEL_PLAYER[1]);

    
// Player animation
    
static szAnimation[64];
    
formatex(szAnimationcharsmax(szAnimation), pev(iPlayerpev_flags) & FL_DUCKING "crouch_shoot_%s" "ref_shoot_%s"WEAPON_ANIMATIONS[1]);
    
UTIL_PlayerAnimation(iPlayerszAnimation);

    
set_summoner_state(iPlayerSUMMONER_STAB);
    
set_pev(iItempev_flHoldTime0.0);
    
set_pdata_int(iItemm_iSlashAnim0linux_diff_weapon);
    
set_pdata_float(iPlayerm_flNextAttackDreadNovaInBMode(iItem) ? 9/30.0 14/30.0linux_diff_player);
    
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_B_ATTACKlinux_diff_weapon);

    
set_pdata_float(iItemm_flNextPrimaryAttackflNextAttacklinux_diff_weapon);
    
set_pdata_float(iItemm_flNextSecondaryAttackflNextAttacklinux_diff_weapon);
    
set_pdata_float(iItemm_flTimeWeaponIdleflNextAttacklinux_diff_weapon);

    return 
HAM_SUPERCEDE;
}

public 
CEntity__Touch_Post(iEntityiTouch)
{
    if(
pev_valid(iEntity) != PDATA_SAFE) return HAM_IGNORED;
    if(
pev(iEntitypev_classname) == gl_iszAllocString_Cannon)
    {
        new 
iOwner pev(iEntitypev_owner);
        if(
iTouch == iOwner) return HAM_SUPERCEDE;

        new 
FloatvecOrigin[3]; pev(iEntitypev_originvecOrigin);
        if(
engfunc(EngFunc_PointContentsvecOrigin) == CONTENTS_SKY)
        {
            
set_pev(iEntitypev_flagsFL_KILLME);
            return 
HAM_IGNORED;
        }

        new 
FloatvecVelocity[3]; pev(iEntitypev_vuser1vecVelocity);
        
Create_SphereDamage(iEntityiOwnervecVelocityvecOriginENTITY_CANNON_RADIUSENTITY_CANNON_DAMAGEENTITY_CANNON_DMGTYPE);

        
emit_sound(iEntityCHAN_ITEMENTITY_CANNON_SOUNDVOL_NORMATTN_NORM0PITCH_NORM);
        
UTIL_CreateExplosion(0vecOrigin0.0gl_iszModelIndex_CannonExp10322|4|8);

        
set_pev(iEntitypev_solidSOLID_NOT);
        
set_pev(iEntitypev_velocityFloat: {0.00.00.0});
        
engfunc(EngFunc_SetModeliEntity"");
        
set_pev(iEntitypev_flagsFL_KILLME);
    }

    return 
HAM_IGNORED;
}

public 
CEntity__Think_Pre(iEntity)
{
    if(
pev_valid(iEntity) != PDATA_SAFE) return HAM_IGNORED;
    if(
pev(iEntitypev_classname) == gl_iszAllocString_Swing// Swing
    
{
        
set_pev(iEntitypev_flagsFL_KILLME);
        return 
HAM_IGNORED;
    }

    if(
pev(iEntitypev_classname) == gl_iszAllocString_ExplosionRing// Explosion ring
    
{
        switch(
pev(iEntitypev_iuser4))
        {
            case 
0:
            {
                new 
FloatflGameTime get_gametime();

                
// Knockback all victims from owner of Summner
                
new iVictim FM_NULLENT;
                new 
FloatvecOrigin[3]; pev(iEntitypev_originvecOrigin);

                while((
iVictim engfunc(EngFunc_FindEntityInSphereiVictimvecOriginENTITY_RING_KNOCK_RADIUS)) > 0)
                {
                    if(
iVictim == iEntity || !is_user_alive(iVictim) || !zp_get_user_zombie(iVictim))
                        continue;

                    if(!
is_wall_between_points(iEntityiVictim))
                        continue;

                    
UTIL_KnockBackFromCenter(iEntityiVictimENTITY_RING_KNOCK_POWER);
                }

                
set_pev(iEntitypev_iuser41);
                
set_pev(iEntitypev_nextthinkflGameTime + ((81/30.0) - (25/30.0)));
            }
            case 
1:
            {
                
set_pev(iEntitypev_flagsFL_KILLME);
            }
        }
    }

    if(
pev(iEntitypev_classname) == gl_iszAllocString_Summoner// Summoner
    
{
        new 
iOwner pev(iEntitypev_owner);
        if(!
is_user_connected(iOwner))
        {
            
set_pev(iEntitypev_flagsFL_KILLME);
            return 
HAM_IGNORED;
        }

        new 
FloatflNextThink;
        new 
FloatflGameTime get_gametime();
        new 
FloatvecEntOrigin[3]; pev(iEntitypev_originvecEntOrigin);
        new 
FloatvecOrigin[3]; get_position_for_summoner(iOwnervecOrigin, -25.0);

        switch(
pev(iEntitypev_iSumState))
        {
            case 
SUMMONER_SPAWN:
            {
                
set_pev(iEntitypev_iSumStateSUMMONER_IDLE);

                
flNextThink ENTITY_SUMMONER_NEXTTHINK;
            }
            case 
SUMMONER_IDLE:
            {
                new 
FloatflSpeed;
                new 
FloatflDistance get_distance_f(vecOriginvecEntOrigin);
                new 
FloatvecVelocity[3], FloatvecAngles[3]; pev(iOwnerpev_anglesvecAngles);

                if(
flDistance 50.0)
                {
                    if(
flDistance 75.0flSpeed flDistance 3.0;
                    else 
flSpeed flDistance 1.5;

                    
get_speed_vector(vecEntOriginvecOriginflSpeedvecVelocity);
                    
set_pev(iEntitypev_velocityvecVelocity);
                }
                else
                {
                    if(
xs_vec_equal(vecOriginvecEntOrigin) || flDistance 5.0)
                        
set_pev(iEntitypev_velocityFloat: { 0.00.00.0 });
                    else
                    {
                        
get_speed_vector(vecEntOriginvecOrigin100.0vecVelocity);
                        
set_pev(iEntitypev_velocityvecVelocity);
                    }
                }

                if(
pev(iEntitypev_sequence) != SUMMONER_ANIM_IDLE)
                    
set_entity_anim(iEntitySUMMONER_ANIM_IDLE);

                
set_pev(iEntitypev_anglesvecAngles);
                
flNextThink ENTITY_SUMMONER_NEXTTHINK;
            }
            case 
SUMMONER_SLASH:
            {
                new 
iSumAnim pev(iEntitypev_iSumAnim);
                if(
iSumAnim >= 3iSumAnim 0;
                else 
iSumAnim++;

                
set_entity_anim(iEntitySUMMONER_ANIM_SLASH iSumAnim);
                
emit_sound(iEntityCHAN_ITEMENTITY_SUMMONER_SOUNDS[iSumAnim], VOL_NORMATTN_NORM0PITCH_NORM);
                
Create_SlashSwing(iOwneriSumAnim);

                
set_pev(iEntitypev_iSumAnimiSumAnim);
                
set_pev(iEntitypev_velocityFloat: { 0.00.00.0 });
                
set_pev(iEntitypev_iSumStateSUMMONER_SLASH_HIT);

                
flNextThink 10/30.0;
            }
            case 
SUMMONER_SLASH_HIT:
            {
                
UTIL_FakeTraceLine(iOwner, -1SUMMONER_SLASH_DISTANCESUMMONER_SLASH_DAMAGESUMMONER_SLASH_KNOCKBACKflAngles_Forwardsizeof flAngles_Forward);
                
set_pev(iEntitypev_iSumStateSUMMONER_SLASH_END);

                
flNextThink SUMMONER_ANIM_SLASH_TIME 10/30.0;
            }
            case 
SUMMONER_STAB:
            {
                
set_entity_anim(iEntitySUMMONER_ANIM_STAB);
                
emit_sound(iEntityCHAN_ITEMENTITY_SUMMONER_SOUNDS[4], VOL_NORMATTN_NORM0PITCH_NORM);

                
set_pev(iEntitypev_velocityFloat: { 0.00.00.0 });
                
set_pev(iEntitypev_iSumStateSUMMONER_STAB_FIRE);

                
flNextThink 20/30.0;
            }
            case 
SUMMONER_STAB_FIRE:
            {
                new 
FloatvecEndPos[3]; fm_get_aim_origin(iOwnervecEndPos);
                new 
FloatvecVelocity[3]; velocity_by_aim(iOwnerfloatround(ENTITY_EXP_KNOCK_POWER), vecVelocity);

                
emit_sound(iEntityCHAN_ITEMENTITY_SUMMONER_SOUNDS[5], VOL_NORMATTN_NORM0PITCH_NORM);
                
UTIL_CreateExplosion(0vecEndPos0.0gl_iszModelIndex_LaserExp10322|4|8);
                
UTIL_DrawAttachmentBeam(iEntityENTITY_BEAM_SPRITEvecEndPos, (35/30.0) - (20/30.0));

                
// Create explosion sound
                
new iExpEntity engfunc(EngFunc_CreateNamedEntitygl_iszAllocString_InfoTarget);
                if(
iExpEntity)
                {
                    
engfunc(EngFunc_SetOriginiExpEntityvecEndPos);
                    
Create_SphereDamage(iExpEntityiOwnervecVelocityvecEndPosSUMMONER_STAB_EXP_RADIUSENTITY_STAB_EXP_DAMAGESUMMONER_STAB_EXP_DMGTYPE);

                    
emit_sound(iExpEntityCHAN_ITEMENTITY_CANNON_SOUNDVOL_NORMATTN_NORM0PITCH_NORM);
                    
set_pev(iExpEntitypev_flagsFL_KILLME);
                }

                
set_pev(iEntitypev_iSumStateSUMMONER_STAB_END);

                
flNextThink SUMMONER_ANIM_STAB_TIME 20/30.0;
            }
            case 
SUMMONER_SLASH_ENDSUMMONER_STAB_END:
            {
                
set_pev(iEntitypev_iSumStateSUMMONER_IDLE);

                
flNextThink 0.1;
            }
            case 
SUMMONER_DISAPPEAR:
            {
                
iEntity FM_NULLENT;
                while((
iEntity fm_find_ent_by_owner(iEntityENTITY_SUMMONER_CLASSNAMEiOwner)) > 0)
                {
                    
UTIL_CreateExplosion(0vecEntOrigin75.0gl_iszModelIndex_Unsummon7322|4|8);
                    
emit_sound(iEntityCHAN_ITEMENTITY_SUMMONER_SOUNDS[7], VOL_NORMATTN_NORM0PITCH_NORM);

                    
set_pev(iEntitypev_velocityFloat: { 0.00.00.0 });
                    
set_pev(iEntitypev_flagsFL_KILLME);
                }

                return 
HAM_IGNORED;
            }
        }

        
set_pev(iEntitypev_nextthinkflGameTime flNextThink);
    }

    return 
HAM_IGNORED;
}

public 
CBeam__Think_Pre(iEntity)
{
    if(
pev_valid(iEntity) != PDATA_SAFE) return HAM_IGNORED;
    if(
pev(iEntitypev_impulse) == gl_iszAllocString_BeamKey)
    {
        
set_pev(iEntitypev_flagsFL_KILLME);
    }

    return 
HAM_IGNORED;
}

public 
CPlayer__PreThink_Pre(iPlayer)
{
    if(!
is_user_alive(iPlayer) || zp_get_user_zombie(iPlayer)) return HAM_IGNORED;
    if(!
IsUserHasDreadNova(iPlayer)) return HAM_IGNORED;

    new 
iItem get_pdata_cbase(iPlayerm_pActiveItemlinux_diff_player);
    if(
pev_valid(iItem) != PDATA_SAFE) return HAM_IGNORED;
    if(!
IsCustomItem(iItem)) return HAM_IGNORED;

    new 
FloatflGameTime get_gametime();
    new 
FloatflNextEnergypev(iItempev_flNextEnergyflNextEnergy);
    new 
iEnergy pev(iItempev_iEnergy);

    if(
IsUserHasSummoner(iPlayer))
    {
        if(
flNextEnergy flGameTime && flNextEnergy != 0.0 && iEnergy >= 0)
        {
            if(
iEnergy <= 1)
            {
                
set_summoner_state(iPlayerSUMMONER_DISAPPEAR);
                
set_pev(iItempev_flNextEnergyflGameTime 1.0);
            }

            
iEnergy--;
            
set_pev(iItempev_iEnergyiEnergy);
            
set_pev(iItempev_flNextEnergyflGameTime WEAPON_ENERGY_LEFT);

            
UTIL_AmmoX(iPlayer15iEnergy);
        }
    }
    else
    {
        if(
flNextEnergy flGameTime && flNextEnergy != 0.0 && iEnergy WEAPON_MAX_ENERGY)
        {
            if(
iEnergy == WEAPON_MAX_ENERGY 1)
            {
                
emit_sound(iPlayerCHAN_ITEMWEAPON_SOUNDS[9], VOL_NORMATTN_NORM0PITCH_NORM);
                
UTIL_ScreenFade(iPlayer, (1<<10) * 2, (1<<10) * 20x00000020070);
            }

            
iEnergy++;
            
set_pev(iItempev_iEnergyiEnergy);
            
set_pev(iItempev_flNextEnergyflGameTime WEAPON_ENERGY_DELAY);

            
UTIL_AmmoX(iPlayer15iEnergy);
        }
    }

    return 
HAM_IGNORED;
}

/* ~ [ Other ] ~ */
public CKnife__StabEnd(iPlayeriItem)
{
    
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_STAB_END);

    
set_pev(iItempev_flHoldTime0.0);
    
set_pdata_int(iItemm_iAttackStateWPNSTATE_KNIFE_Blinux_diff_weapon);

    
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_STAB_END_TIME 0.5linux_diff_player);
    
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_STAB_END_TIME 0.5linux_diff_weapon);
    
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_STAB_END_TIME 0.5linux_diff_weapon);
    
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_STAB_END_TIMElinux_diff_weapon);
}

public 
CKnife__CheckCombo(iPlayeriItemiValue)
{
    if(
pev(iItempev_iEnergy) < WEAPON_MAX_ENERGY) return 0;
    if(
IsUserHasSummoner(iPlayer)) return 0;

    new 
iComboData getComboData(iItem);

    if(
WEAPON_COMBO_DATA[iComboData] != iValue)
    {
        
iComboData 0;
    }
    else
    {
        
iComboData++;

        if(
iComboData >= sizeof WEAPON_COMBO_DATA)
        {
            
setComboData(iItem0);
            
set_bit(gl_iBitUserHasSummoneriPlayer);

            
Create_Summoner(iPlayer);
            
UTIL_SendWeaponAnim(iPlayerWEAPON_ANIM_SUMMONING);

            
set_pdata_float(iPlayerm_flNextAttackWEAPON_ANIM_SUMMONING_TIMElinux_diff_player);
            
set_pdata_float(iItemm_flNextPrimaryAttackWEAPON_ANIM_SUMMONING_TIMElinux_diff_weapon);
            
set_pdata_float(iItemm_flNextSecondaryAttackWEAPON_ANIM_SUMMONING_TIMElinux_diff_weapon);
            
set_pdata_float(iItemm_flTimeWeaponIdleWEAPON_ANIM_SUMMONING_TIMElinux_diff_weapon);

            return 
1;
        }
    }

    
setComboData(iItemiComboData);
    return 
0;
}

public 
Create_SphereDamage(iEntityiAttackerFloatvecVelocity[3], FloatvecOrigin[3], FloatflRadiusFloatflDamageibitsDamageBits)
{
    new 
iVictim FM_NULLENT;
    while((
iVictim engfunc(EngFunc_FindEntityInSphereiVictimvecOriginflRadius)) > 0)
    {
        if(
pev(iVictimpev_takedamage) == DAMAGE_NO
            continue;

        if(
is_user_alive(iVictim))
        {
            if(
iVictim == iAttacker || !zp_get_user_zombie(iVictim) || !is_wall_between_points(iEntityiVictim))
                continue;
        }
        else if(
pev(iVictimpev_solid) == SOLID_BSP)
        {
            if(
pev(iVictimpev_spawnflags) & SF_BREAK_TRIGGER_ONLY)
                continue;
        }

        if(
is_user_alive(iVictim))
            
set_pdata_int(iVictimm_LastHitGroupHIT_GENERIClinux_diff_player);

        
ExecuteHamB(Ham_TakeDamageiVictimiAttackeriAttackerflDamageibitsDamageBits);

        if(
is_user_alive(iVictim))
        {
            
set_pev(iVictimpev_velocityvecVelocity);
            
set_pdata_float(iVictimm_flPainShock1.0linux_diff_player);
        }
    }
}

public 
Create_KnifeCannon(iPlayer)
{
    new 
iEntity engfunc(EngFunc_CreateNamedEntitygl_iszAllocString_InfoTarget);
    if(!
iEntity) return FM_NULLENT;

    new 
FloatvecOrigin[3]; pev(iPlayerpev_originvecOrigin);
    new 
FloatvecAngles[3]; pev(iPlayerpev_v_anglevecAngles);
    new 
FloatvecForward[3]; angle_vector(vecAnglesANGLEVECTOR_FORWARDvecForward);
    new 
FloatvecVelocity[3]; xs_vec_copy(vecForwardvecVelocity);
    new 
FloatvecViewOfs[3]; pev(iPlayerpev_view_ofsvecViewOfs);

    
vecOrigin[0] += vecViewOfs[0] + vecForward[0] * 20.0;
    
vecOrigin[1] += vecViewOfs[1] + vecForward[1] * 20.0;
    
vecOrigin[2] += vecViewOfs[2] + vecForward[2] * 20.0;

    
vecVelocity[0] *= ENTITY_CANNON_SPEED;
    
vecVelocity[1] *= ENTITY_CANNON_SPEED;
    
vecVelocity[2] *= ENTITY_CANNON_SPEED;

    
engfunc(EngFunc_SetModeliEntityENTITY_CANNON_MODEL);
    
engfunc(EngFunc_SetOriginiEntityvecOrigin);

    
set_pev_string(iEntitypev_classnamegl_iszAllocString_Cannon);
    
set_pev(iEntitypev_solidSOLID_TRIGGER);
    
set_pev(iEntitypev_movetypeMOVETYPE_FLY);
    
set_pev(iEntitypev_owneriPlayer);
    
set_pev(iEntitypev_velocityvecVelocity);

    
engfunc(EngFunc_VecToAnglesvecVelocityvecAngles);
    
set_pev(iEntitypev_anglesvecAngles);

    
set_pev(iEntitypev_rendermodekRenderTransAdd);
    
set_pev(iEntitypev_renderamt150.0);

    
velocity_by_aim(iPlayerfloatround(ENTITY_EXP_KNOCK_POWER), vecVelocity);
    
set_pev(iEntitypev_vuser1vecVelocity);

    
set_entity_anim(iEntity1);

    return 
iEntity;
}

public 
Create_Summoner(iPlayer)
{
    new 
iEntity engfunc(EngFunc_CreateNamedEntitygl_iszAllocString_InfoTarget);
    if(!
iEntity) return FM_NULLENT;

    new 
FloatflGameTime get_gametime();
    new 
FloatvecOrigin[3]; get_position_for_summoner(iPlayervecOrigin, -25.0);
    new 
FloatvecAngles[3]; pev(iPlayerpev_anglesvecAngles);

    
engfunc(EngFunc_SetModeliEntityENTITY_SUMMONER_MODEL);
    
engfunc(EngFunc_SetSizeiEntityFloat: { -30.0, -30.0, -30.0 }, Float: { 30.030.030.0 });
    
engfunc(EngFunc_SetOriginiEntityvecOrigin);

    
set_pev_string(iEntitypev_classnamegl_iszAllocString_Summoner);
    
set_pev(iEntitypev_solidSOLID_NOT);
    
set_pev(iEntitypev_movetypeMOVETYPE_NOCLIP);
    
set_pev(iEntitypev_owneriPlayer);
    
set_pev(iEntitypev_iSumStateSUMMONER_SPAWN);
    
set_pev(iEntitypev_nextthinkflGameTime SUMMONER_ANIM_SUMMON_TIME);
    
set_pev(iEntitypev_anglesvecAngles);

    
set_entity_anim(iEntitySUMMONER_ANIM_SUMMON);

    
set_pev(iEntitypev_rendermodekRenderTransAdd);
    
set_pev(iEntitypev_renderamt150.0);

    
Create_ExplosionRing(iPlayer);
    
UTIL_CreateExplosion(0vecOrigin42.5gl_iszModelIndex_Summon8322|4|8);
    
emit_sound(iEntityCHAN_ITEMENTITY_SUMMONER_SOUNDS[6], VOL_NORMATTN_NORM0PITCH_NORM);

    return 
iEntity;
}

public 
Create_SlashSwing(iPlayeriSequence)
{
    new 
iEntity engfunc(EngFunc_CreateNamedEntitygl_iszAllocString_InfoTarget);
    if(!
iEntity) return FM_NULLENT;

    new 
FloatflGameTime get_gametime();
    new 
FloatvecOrigin[3]; get_position_for_summoner(iPlayervecOrigin0.0);
    new 
FloatvecAngles[3]; pev(iPlayerpev_anglesvecAngles);

    
vecOrigin[2] -= 5.0;

    
engfunc(EngFunc_SetModeliEntityENTITY_SWING_MODEL);
    
engfunc(EngFunc_SetOriginiEntityvecOrigin);

    
set_pev_string(iEntitypev_classnamegl_iszAllocString_Swing)
    
set_pev(iEntitypev_solidSOLID_NOT);
    
set_pev(iEntitypev_movetypeMOVETYPE_NONE);
    
set_pev(iEntitypev_nextthinkflGameTime 25/30.0);
    
set_pev(iEntitypev_anglesvecAngles);

    
set_pev(iEntitypev_rendermodekRenderTransAdd);
    
set_pev(iEntitypev_renderamt255.0);

    
set_entity_anim(iEntityiSequence);

    return 
iEntity;
}

public 
Create_ExplosionRing(iPlayer)
{
    new 
iEntity engfunc(EngFunc_CreateNamedEntitygl_iszAllocString_InfoTarget);
    if(!
iEntity) return FM_NULLENT;

    new 
FloatflGameTime get_gametime();
    new 
FloatvecOrigin[3]; get_position_for_summoner(iPlayervecOrigin, -25.0);

    
vecOrigin[2] -= 25.0;

    
engfunc(EngFunc_SetModeliEntityENTITY_RING_MODEL);
    
engfunc(EngFunc_SetOriginiEntityvecOrigin);

    
set_pev_string(iEntitypev_classnamegl_iszAllocString_ExplosionRing)
    
set_pev(iEntitypev_solidSOLID_NOT);
    
set_pev(iEntitypev_movetypeMOVETYPE_NONE);
    
set_pev(iEntitypev_owneriPlayer);
    
set_pev(iEntitypev_iuser40);
    
set_pev(iEntitypev_nextthinkflGameTime 24/30.0);

    
set_pev(iEntitypev_rendermodekRenderTransAdd);
    
set_pev(iEntitypev_renderamt255.0);

    
set_entity_anim(iEntity0);

    return 
iEntity;
}

/* ~ [ Stock's ] ~ */
stock set_summoner_state(iPlayeriSummonerState)
{
    if(!
IsUserHasSummoner(iPlayer)) return;
    
    static 
iEntityiEntity fm_find_ent_by_owner(-1ENTITY_SUMMONER_CLASSNAMEiPlayer);
    if(
pev_valid(iEntity))
    {
        if(
iSummonerState == SUMMONER_DISAPPEAR)
        {
            
reset_bit(gl_iBitUserHasSummoneriPlayer);

            
set_pev(iEntitypev_iSumStateiSummonerState);
            
set_pev(iEntitypev_nextthinkget_gametime() + 0.1);

            
iEntity fm_find_ent_by_owner(-1ENTITY_RING_CLASSNAMEiPlayer);
            if(
pev_valid(iEntity))
                
set_pev(iEntitypev_flagsFL_KILLME);

            return;
        }

        switch(
pev(iEntitypev_iSumState))
        {
            case 
SUMMONER_SPAWNSUMMONER_SLASH_HITSUMMONER_STAB_FIRESUMMONER_SLASH_ENDSUMMONER_STAB_END: return;
            default:
            {
                if(
iSummonerState == SUMMONER_SLASH || iSummonerState == SUMMONER_STAB)
                {
                    new 
FloatvecEntOrigin[3]; pev(iEntitypev_originvecEntOrigin);
                    new 
FloatvecOrigin[3]; pev(iPlayerpev_originvecOrigin);

                    if(
get_distance_f(vecOriginvecEntOrigin) > 50.0)
                    {
                        new 
FloatvecOrigin[3]; get_position_for_summoner(iPlayervecOrigin, -25.0);

                        
engfunc(EngFunc_SetOriginiEntityvecOrigin);
                    }
                }

                
set_pev(iEntitypev_iSumStateiSummonerState);
            }
        }
    }
}

stock set_entity_anim(iEntityiSequence)
{
    
set_pev(iEntitypev_frame1.0);
    
set_pev(iEntitypev_framerate1.0);
    
set_pev(iEntitypev_animtimeget_gametime());
    
set_pev(iEntitypev_sequenceiSequence);
}

stock is_wall_between_points(iPlayeriEntity)
{
    if(!
is_user_alive(iEntity))
        return 
0;

    new 
iTrace create_tr2();
    new 
FloatflStart[3], FloatvecEnd[3], FloatvecEndPos[3];

    
pev(iPlayerpev_originflStart);
    
pev(iEntitypev_originvecEnd);

    
engfunc(EngFunc_TraceLineflStartvecEndIGNORE_MONSTERSiPlayeriTrace);
    
get_tr2(iTraceTR_vecEndPosvecEndPos);

    
free_tr2(iTrace);

    return 
xs_vec_equal(vecEndvecEndPos);
}

stock UTIL_SendWeaponAnim(iPlayeriAnim)
{
    
set_pev(iPlayerpev_weaponanimiAnim);

    
message_begin(MSG_ONESVC_WEAPONANIM_iPlayer);
    
write_byte(iAnim);
    
write_byte(0);
    
message_end();
}

stock UTIL_PlayerAnimation(iPlayerszAnim[])
{
    new 
iAnimDesiredFloatflFrameRateFloatflGroundSpeedboolbLoops;
        
    if((
iAnimDesired lookup_sequence(iPlayerszAnimflFrameRatebLoopsflGroundSpeed)) == -1)
        
iAnimDesired 0;
    
    new 
FloatflGameTime get_gametime();

    
set_entity_anim(iPlayeriAnimDesired);
    
    
set_pdata_int(iPlayerm_fSequenceLoopsbLoopslinux_diff_animating);
    
set_pdata_int(iPlayerm_fSequenceFinished0linux_diff_animating);
    
    
set_pdata_float(iPlayerm_flFrameRateflFrameRatelinux_diff_animating);
    
set_pdata_float(iPlayerm_flGroundSpeedflGroundSpeedlinux_diff_animating);
    
set_pdata_float(iPlayerm_flLastEventCheckflGameTime linux_diff_animating);
    
    
set_pdata_int(iPlayerm_ActivityACT_RANGE_ATTACK1linux_diff_player);
    
set_pdata_int(iPlayerm_IdealActivityACT_RANGE_ATTACK1linux_diff_player);
    
set_pdata_float(iPlayerm_flLastAttackTimeflGameTime linux_diff_player);
}

stock UTIL_DrawAttachmentBeam(iEntity, const szSpriteName[], FloatvecStart[3], FloatflNextThink)
{
    if(
global_get(glb_maxEntities) - engfunc(EngFunc_NumberOfEntities) < 100) return FM_NULLENT;
    
    static 
iBeamiBeam Beam_Create(szSpriteNameENTITY_BEAM_WIDTH);
    if(
pev_valid(iBeam) != PDATA_SAFE) return FM_NULLENT;
    
    
Beam_PointEntInit(iBeamvecStartiEntity);
    
Beam_SetBrightness(iBeamENTITY_BEAM_BRIGHTNESS);
    
Beam_SetColor(iBeamFloatENTITY_BEAM_COLOR);
    
Beam_SetFlags(iBeamBEAM_FSINE);
    
Beam_SetScrollRate(iBeamENTITY_BEAM_SCROLLRATE);
    
Beam_SetEndAttachment(iBeam1);

    
set_pev(iBeampev_classnameENTITY_BEAM_CLASSNAME);
    
set_pev(iBeampev_impulsegl_iszAllocString_BeamKey);
    
set_pev(iBeampev_owneriEntity);
    
set_pev(iBeampev_nextthinkget_gametime() + flNextThink);
    
    return 
iBeam;
}

stock UTIL_CreateExplosion(iEntityFloatvecOrigin[3], FloatvecUpiszModelIndexiScaleiFrameRateiFlags)
{
    
// https://github.com/baso88/SC_AngelScript/wiki/TE_EXPLOSION
    
if(!iEntity)
        
engfunc(EngFunc_MessageBeginMSG_PASSVC_TEMPENTITYvecOrigin0);
    else 
message_begin(MSG_ONE_UNRELIABLESVC_TEMPENTITY_iEntity);

    
write_byte(TE_EXPLOSION); // TE
    
engfunc(EngFunc_WriteCoordvecOrigin[0]); // Position X
    
engfunc(EngFunc_WriteCoordvecOrigin[1]); // Position Y
    
engfunc(EngFunc_WriteCoordvecOrigin[2] + vecUp); // Position Z
    
write_short(iszModelIndex); // Model Index
    
write_byte(iScale); // Scale
    
write_byte(iFrameRate); // Framerate
    
write_byte(iFlags); // Flags
    
message_end();
}

stock UTIL_FakeTraceLine(iPlayeriHitSoundFloatflDistanceFloatflDamageFloatflKnockBackFloatflSendAngles[], iSendAngles)
{
    
enum
    
{
        
SLASH_HIT_NONE 0,
        
SLASH_HIT_WORLD,
        
SLASH_HIT_ENTITY
    
};

    new 
FloatvecOrigin[3]; pev(iPlayerpev_originvecOrigin);
    new 
FloatvecAngles[3]; pev(iPlayerpev_v_anglevecAngles);
    new 
FloatvecViewOfs[3]; pev(iPlayerpev_view_ofsvecViewOfs);

    
vecOrigin[0] += vecViewOfs[0];
    
vecOrigin[1] += vecViewOfs[1];
    
vecOrigin[2] += vecViewOfs[2];
    
    new 
FloatvecForward[3], FloatvecRight[3], FloatvecUp[3];
    
engfunc(EngFunc_AngleVectorsvecAnglesvecForwardvecRightvecUp);
        
    new 
iTrace create_tr2();

    new 
FloatflTanFloatflMul;
    new 
iHitList[10], iHitCount 0;

    new 
FloatvecEnd[3];
    new 
FloatflFraction;
    new 
pHitpHitEntity SLASH_HIT_NONE;
    new 
iHitResult SLASH_HIT_NONE;

    for(new 
iiSendAnglesi++)
    {
        
flTan floattan(flSendAngles[i], degrees);

        
vecEnd[0] = (vecForward[0] * flDistance) + (vecRight[0] * flTan flDistance) + vecUp[0];
        
vecEnd[1] = (vecForward[1] * flDistance) + (vecRight[1] * flTan flDistance) + vecUp[1];
        
vecEnd[2] = (vecForward[2] * flDistance) + (vecRight[2] * flTan flDistance) + vecUp[2];
            
        
flMul = (flDistance/vector_length(vecEnd));
        
xs_vec_mul_scalar(vecEndflMulvecEnd);
        
xs_vec_add(vecEndvecOriginvecEnd);

        
engfunc(EngFunc_TraceLinevecOriginvecEndDONT_IGNORE_MONSTERSiPlayeriTrace);
        
get_tr2(iTraceTR_flFractionflFraction);

        if(
flFraction == 1.0)
        {
            
engfunc(EngFunc_TraceHullvecOriginvecEndHULL_HEADiPlayeriTrace);
            
get_tr2(iTraceTR_flFractionflFraction);
        
            
engfunc(EngFunc_TraceLinevecOriginvecEndDONT_IGNORE_MONSTERSiPlayeriTrace);
            
pHit get_tr2(iTraceTR_pHit);
        }
        else
        {
            
pHit get_tr2(iTraceTR_pHit);
        }

        if(
pHit == iPlayer) continue;

        static 
boolbStopbStop false;
        for(new 
iHit 0iHit iHitCountiHit++)
        {
            if(
iHitList[iHit] == pHit)
            {
                
bStop true;
                break;
            }
        }

        if(
bStop == true)
            continue;

        
iHitList[iHitCount] = pHit;
        
iHitCount++;

        if(
flFraction != 1.0)
        {
            if(!
iHitResultiHitResult SLASH_HIT_WORLD;
        }

        if(
pHit && pHitEntity != pHit)
        {
            if(
pev(pHitpev_solid) == SOLID_BSP && !(pev(pHitpev_spawnflags) & SF_BREAK_TRIGGER_ONLY))
            {
                
ExecuteHamB(Ham_TakeDamagepHitiPlayeriPlayerflDamageDMG_NEVERGIB DMG_CLUB);
            }
            else
            {
                
UTIL_FakeTraceAttack(pHitiPlayeriHitSound == -0flDamagevecForwardiTraceDMG_NEVERGIB DMG_CLUB);
                
UTIL_FakeKnockBack(pHitvecForwardflKnockBack);
            }

            
iHitResult SLASH_HIT_ENTITY;
            
pHitEntity pHit;
        }
    }

    
free_tr2(iTrace);

    if(
iHitSound != -1)
    {
        switch(
iHitResult)
        {
            case 
SLASH_HIT_WORLDemit_sound(iPlayerCHAN_WEAPONWEAPON_SOUNDS[8], VOL_NORMATTN_NORM0PITCH_NORM);
            case 
SLASH_HIT_ENTITYemit_sound(iPlayerCHAN_WEAPONWEAPON_SOUNDS[iHitSound], VOL_NORMATTN_NORM0PITCH_NORM);
        }
    }
}

stock UTIL_FakeTraceAttack(iVictimiAttackeriSummonerFloatflDamageFloatvecDirection[3], iTraceibitsDamageBits)
{
    static 
FloatflTakeDamagepev(iVictimpev_takedamageflTakeDamage);

    if(
flTakeDamage == DAMAGE_NO) return 0
    if(!(
is_user_alive(iVictim))) return 0;

    if(
is_user_connected(iVictim)) 
    {
        if(
get_pdata_int(iVictimm_iPlayerTeamlinux_diff_player) == get_pdata_int(iAttackerm_iPlayerTeamlinux_diff_player)) 
            return 
0;
    }

    static 
iHitgroupiHitgroup get_tr2(iTraceTR_iHitgroup);
    static 
FloatvecEndPos[3]; get_tr2(iTraceTR_vecEndPosvecEndPos);
    static 
iBloodColoriBloodColor ExecuteHamB(Ham_BloodColoriVictim);
    
    if(
iSummoner == 1)
        
set_pdata_int(iVictimm_LastHitGroupHIT_GENERIClinux_diff_player);
    else
    {
        
set_pdata_int(iVictimm_LastHitGroupiHitgrouplinux_diff_player);

        switch(
iHitgroup
        {
            case 
HIT_HEAD:                  flDamage *= 3.0;
            case 
HIT_LEFTARMHIT_RIGHTARMflDamage *= 0.75;
            case 
HIT_LEFTLEGHIT_RIGHTLEGflDamage *= 0.75;
            case 
HIT_STOMACH:               flDamage *= 1.5;
        }
    }
    
    
ExecuteHamB(Ham_TakeDamageiVictimiAttackeriAttackerflDamageibitsDamageBits);
    
    if(
zp_get_user_zombie(iVictim)) 
    {
        if(
iBloodColor != DONT_BLEED
        {
            
ExecuteHamB(Ham_TraceBleediVictimflDamagevecDirectioniTraceibitsDamageBits);
            
UTIL_BloodDrips(vecEndPosiBloodColorfloatround(flDamage));
        }
    }

    return 
1;
}

stock UTIL_FakeKnockBack(iVictimFloatvecDirection[3], FloatflKnockBack
{
    if(!(
is_user_alive(iVictim) && zp_get_user_zombie(iVictim))) return 0;

    
set_pdata_float(iVictimm_flPainShock1.0linux_diff_player);

    static 
FloatvecVelocity[3]; pev(iVictimpev_velocityvecVelocity);

    if(
pev(iVictimpev_flags) & FL_DUCKING
        
flKnockBack *= 0.7;

    
vecVelocity[0] = vecDirection[0] * flKnockBack;
    
vecVelocity[1] = vecDirection[1] * flKnockBack;
    
//vecVelocity[2] = 200.0;

    
set_pev(iVictimpev_velocityvecVelocity);
    
    return 
1;
}

stock UTIL_KnockBackFromCenter(iAttackeriVictimFloatflPower)
{
    new 
FloatvecOrigin[3], FloatvecVictimOrigin[3], FloatvecVelocity[3];

    
pev(iAttackerpev_originvecOrigin);
    
pev(iVictimpev_originvecVictimOrigin);
    
vecOrigin[2] = vecVictimOrigin[2] = 0.0;
    
    
xs_vec_sub(vecVictimOriginvecOriginvecVictimOrigin);
    new 
FloatfDistancefDistance xs_vec_len(vecVictimOrigin);
    
xs_vec_mul_scalar(vecVictimOriginfDistancevecVictimOrigin);
    
    
pev(iVictimpev_velocityvecVelocity);
    
xs_vec_mul_scalar(vecVictimOriginflPowervecVictimOrigin);
    
xs_vec_mul_scalar(vecVictimOrigin50.0vecVictimOrigin);
    
vecVictimOrigin[2] = xs_vec_len(vecVictimOrigin) * 0.15;
    
    if(
pev(iAttackerpev_flags) &~ FL_ONGROUND)
        
xs_vec_mul_scalar(vecVictimOrigin1.2vecVictimOrigin), vecVictimOrigin[2] *= 0.4;

    if(
xs_vec_len(vecVictimOrigin) > xs_vec_len(vecVelocity))
        
set_pev(iVictimpev_velocityvecVictimOrigin);

    
set_pdata_float(iVictimm_flPainShock1.0linux_diff_player);
}

public 
UTIL_BloodDrips(Float:vecOrigin[3], iColoriAmount)
{
    if(
iAmount 255iAmount 255;
    
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecOrigin0);
    
write_byte(TE_BLOODSPRITE);
    
engfunc(EngFunc_WriteCoordvecOrigin[0]);
    
engfunc(EngFunc_WriteCoordvecOrigin[1]);
    
engfunc(EngFunc_WriteCoordvecOrigin[2]);
    
write_short(gl_iszModelIndex_BloodSpray);
    
write_short(gl_iszModelIndex_BloodDrop);
    
write_byte(iColor);
    
write_byte(min(max(3iAmount 10), 16));
    
message_end();
}

stock UTIL_AmmoX(iPlayeriPrimaryAmmoIDiPrimaryAmmoAmount)
{
    
message_begin(MSG_ONEgl_iMsgID_AmmoX_iPlayer);
    
write_byte(iPrimaryAmmoID);
    
write_byte(iPrimaryAmmoAmount);
    
message_end();
}

stock UTIL_CurWeapon(iPlayeriActiveCSW_WEAPONiClip)
{
    
engfunc(EngFunc_MessageBeginMSG_ONEgl_iMsgID_CurWeapon, {000}, iPlayer);
    
write_byte(iActive);
    
write_byte(CSW_WEAPON);
    
write_byte(iClip);
    
message_end();
}

stock UTIL_WeaponList(iPlayer, const szWeaponName[], iPrimaryAmmoIDiAmmoMaxAmountiSecondaryAmmoIDiSecondaryAmmoMaxAmountiSlotIDiNumberInSlotiWeaponIDiFlags)
{
    
message_begin(MSG_ONEgl_iMsgID_WeaponList_iPlayer);
    
write_string(szWeaponName);
    
write_byte(iPrimaryAmmoID);
    
write_byte(iAmmoMaxAmount);
    
write_byte(iSecondaryAmmoID);
    
write_byte(iSecondaryAmmoMaxAmount);
    
write_byte(iSlotID);
    
write_byte(iNumberInSlot);
    
write_byte(iWeaponID);
    
write_byte(iFlags);
    
message_end();
}

stock UTIL_ScreenFade(iPlayeriDurationiHoldTimeiFlagsiRediGreeniBlueiAlphaiReliable 0)
{
    if(!
iPlayer)
        
message_begin(iReliable MSG_ALL MSG_BROADCASTgl_iMsgID_ScreenFade);
    else 
message_begin(iReliable MSG_ONE MSG_ONE_UNRELIABLEgl_iMsgID_ScreenFade_iPlayer);

    
write_short(iDuration);
    
write_short(iHoldTime);
    
write_short(iFlags);
    
write_byte(iRed);
    
write_byte(iGreen);
    
write_byte(iBlue);
    
write_byte(iAlpha);
    
message_end();
}

stock UTIL_PrecacheSoundsFromModel(const szModelPath[])
{
    new 
iFile;
    
    if((
iFile fopen(szModelPath"rt")))
    {
        new 
szSoundPath[64];
        
        new 
iNumSeqiSeqIndex;
        new 
iEventiNumEventsiEventIndex;
        
        
fseek(iFile164SEEK_SET);
        
fread(iFileiNumSeqBLOCK_INT);
        
fread(iFileiSeqIndexBLOCK_INT);
        
        for(new 
k0iNumSeqi++)
        {
            
fseek(iFileiSeqIndex 48 176 iSEEK_SET);
            
fread(iFileiNumEventsBLOCK_INT);
            
fread(iFileiEventIndexBLOCK_INT);
            
fseek(iFileiEventIndex 176 iSEEK_SET);
            
            for(
0iNumEventsk++)
            {
                
fseek(iFileiEventIndex 76 kSEEK_SET);
                
fread(iFileiEventBLOCK_INT);
                
fseek(iFile4SEEK_CUR);
                
                if(
iEvent != 5004)
                    continue;
                
                
fread_blocks(iFileszSoundPath64BLOCK_CHAR);
                
                if(
strlen(szSoundPath))
                {
                    
strtolower(szSoundPath);
                    
engfunc(EngFunc_PrecacheSoundszSoundPath);
                }
            }
        }
    }
    
    
fclose(iFile);
}

stock UTIL_PrecacheSpritesFromTxt(const szWeaponList[])
{
    new 
szTxtDir[64], szSprDir[64]; 
    new 
szFileData[128], szSprName[48], temp[1];

    
format(szTxtDircharsmax(szTxtDir), "sprites/%s.txt"szWeaponList);
    
engfunc(EngFunc_PrecacheGenericszTxtDir);

    new 
iFile fopen(szTxtDir"rb");
    while(
iFile && !feof(iFile)) 
    {
        
fgets(iFileszFileDatacharsmax(szFileData));
        
trim(szFileData);

        if(!
strlen(szFileData)) 
            continue;

        new 
pos containi(szFileData"640");    
            
        if(
pos == -1)
            continue;
            
        
format(szFileDatacharsmax(szFileData), "%s"szFileData[pos+3]);        
        
trim(szFileData);

        
strtok(szFileDataszSprNamecharsmax(szSprName), tempcharsmax(temp), ' '1);
        
trim(szSprName);
        
        
format(szSprDircharsmax(szSprDir), "sprites/%s.spr"szSprName);
        
engfunc(EngFunc_PrecacheGenericszSprDir);
    }

    if(
iFilefclose(iFile);
}

stock get_speed_vector(const FloatvecOrigin1[3], const FloatvecOrigin2[3], FloatflSpeedFloatvecVelocity[3]) 
{
    
vecVelocity[0] = vecOrigin2[0] - vecOrigin1[0]; 
    
vecVelocity[1] = vecOrigin2[1] - vecOrigin1[1]; 
    
vecVelocity[2] = vecOrigin2[2] - vecOrigin1[2]; 

    new 
FloatflNum floatsqroot(flSpeed flSpeed / (vecVelocity[0]*vecVelocity[0] + vecVelocity[1]*vecVelocity[1] + vecVelocity[2]*vecVelocity[2])) 

    
vecVelocity[0] *= flNum
    
vecVelocity[1] *= flNum
    
vecVelocity[2] *= flNum

    return 
1
}

stock strip_weapon(id,weapon[])
{
    if(!
equal(weapon,"weapon_",7)) return 0;

    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;

    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;

    if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);

    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));

    return 
1;
}

stock get_position_for_summoner(iPlayerFloatvecOrigin[3], FloatflForward)
{
    new 
FloatvecViewOfs[3], FloatvecAngles[3], FloatvecForward[3];

    
pev(iPlayerpev_originvecOrigin);
    
pev(iPlayerpev_view_ofsvecViewOfs);
    
pev(iPlayerpev_anglesvecAngles);
    
angle_vector(vecAnglesANGLEVECTOR_FORWARDvecForward);

    
vecOrigin[0] += vecViewOfs[0] + vecForward[0] * flForward;
    
vecOrigin[1] += vecViewOfs[1] + vecForward[1] * flForward;
    
vecOrigin[2] += ENTITY_SUMMONER_RAISED;

    return 
1;




All times are GMT -4. The time now is 17:13.

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