// Undefine for Zombie Plague 5.0 support.
// #define _ZP50
// Don't touch this line, lol.
// #define _DEBUG
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zp_level_system>
#if defined _DEBUG
#define _DEBUG_CMD "say /cartblue"
#else
#if !defined _ZP50
#tryinclude <zombieplague>
#else
#tryinclude <zp50_core>
#tryinclude <zp50_items>
#endif
#endif
#include <xs>
#define PLUGIN "[ZP] Extra: Cart Blue"
#define VERSION "1.0"
#define AUTHOR "KORD_12.7"
#pragma semicolon 1
// Main
#define WEAPON_REFERANCE "weapon_m4a1"
#define WEAPON_NAME_C "weapon_cartbluec_aghlru"
#define WEAPON_NAME_S "weapon_cartblues_aghlru"
#define WEAPON_MAX_CLIP 30
#define WEAPON_DEFAULT_AMMO 90
#define WEAPON_FOV_ZOOM 20
#define WEAPON_MAX_SPEED 230.0
#define WEAPON_MULTIPLIER_DAMAGE 1.8
#define WEAPON_TIME_NEXT_IDLE 5.46
#define WEAPON_TIME_NEXT_ATTACK_C 0.0955
#define WEAPON_TIME_NEXT_ATTACK_S 0.25
#define WEAPON_TIME_DELAY_DEPLOY 1.0
#define WEAPON_TIME_DELAY_RELOAD 3.46
#define WEAPON_TIME_DELAY_SWITCH 4.83
// Extra
#define ZP_ITEM_NAME "Cart Blue"
#define ZP_ITEM_COST 15
// Models
#define MODEL_WORLD "models/aghlru/w_cartblue.mdl"
#define MODEL_VIEW "models/aghlru/v_cartblue.mdl"
#define MODEL_PLAYER "models/aghlru/p_cartblue.mdl"
#define MODEL_SHELL "models/rshell.mdl"
// Sounds
#define SOUND_FIRE_C "weapons/cartblue_l.wav"
#define SOUND_FIRE_S "weapons/cartblue_h.wav"
// Sprites
#define WEAPON_HUD_SPR_C "sprites/aghlru/cartblue.spr"
#define WEAPON_HUD_SPR_S "sprites/aghlru/sniper_cartblue.spr"
#define WEAPON_HUD_TXT_C "sprites/weapon_cartbluec_aghlru.txt"
#define WEAPON_HUD_TXT_S "sprites/weapon_cartblues_aghlru.txt"
// Animation
#define ANIM_EXTENSION "carbine"
// Animation sequences
enum
{
ANIM_IDLE,
ANIM_RELOAD,
ANIM_DRAW,
ANIM_SHOOT_1,
ANIM_SHOOT_2,
ANIM_CHANGE,
ANIM_IDLE_EX,
ANIM_RELOAD_EX,
ANIM_DRAW_EX,
ANIM_SHOOT_1_EX,
ANIM_SHOOT_2_EX,
ANIM_CHANGE_EX
};
#define SET_MODEL(%0,%1) engfunc(EngFunc_SetModel, %0, %1)
#define SET_ORIGIN(%0,%1) engfunc(EngFunc_SetOrigin, %0, %1)
#define PRECACHE_MODEL(%0) engfunc(EngFunc_PrecacheModel, %0)
#define PRECACHE_SOUND(%0) engfunc(EngFunc_PrecacheSound, %0)
#define PRECACHE_GENERIC(%0) engfunc(EngFunc_PrecacheGeneric, %0)
#define PRECACHE_MODEL2(%0) PrecacheSoundsFromModel(%0)
// Linux extra offsets
#define extra_offset_weapon 4
#define extra_offset_player 5
// CWeaponBox
#define m_rgpPlayerItems_CWeaponBox 34
// CBasePlayerItem
#define m_pPlayer 41
#define m_pNext 42
#define m_iId 43
// CBasePlayerWeapon
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
#define m_flTimeWeaponIdle 48
#define m_iPrimaryAmmoType 49
#define m_iClip 51
#define m_fInReload 54
#define m_fInSpecialReload 55
#define m_iDirection 60
#define m_flLastFire 63
#define m_iShotsFired 64
// CBaseMonster
#define m_flNextAttack 83
// CBasePlayer
#define m_iHideHUD 361
#define m_iFOV 363
#define m_rgpPlayerItems_CBasePlayer 367
#define m_pActiveItem 373
#define m_rgAmmo_CBasePlayer 376
#define m_szAnimExtention 492
// Redefines
#define m_flApplyMode m_flLastFire
#define m_iCurrentMode m_fInSpecialReload
#define LVL_COUNT 10
new g_iItemID;
new g_iszWeaponKey;
new g_iForwardDecalIndex;
new MsgSayText;
#define CSW_DUMMY 2
#define MSG_WEAPONLIST 78
#define _CALLFUNC(%0,%1,%2) \
\
Weapon_On%0 \
( \
%1, \
%2, \
\
get_pdata_int(%1, m_iClip, extra_offset_weapon), \
GetAmmoInventory(%2, PrimaryAmmoIndex(%1)), \
get_pdata_int(%1, m_iCurrentMode, extra_offset_weapon) \
)
#define STATEMENT_FALLBACK(%0,%1,%2) public %0()<>{return %1;} public %0()<%2>{return %1;}
#define MESSAGE_BEGIN(%0,%1,%2,%3) engfunc(EngFunc_MessageBegin, %0, %1, %2, %3)
#define MESSAGE_END() message_end()
#define WRITE_ANGLE(%0) engfunc(EngFunc_WriteAngle, %0)
#define WRITE_BYTE(%0) write_byte(%0)
#define WRITE_COORD(%0) engfunc(EngFunc_WriteCoord, %0)
#define WRITE_STRING(%0) write_string(%0)
#define WRITE_SHORT(%0) write_short(%0)
#define MDLL_Spawn(%0) dllfunc(DLLFunc_Spawn, %0)
#define MDLL_Touch(%0,%1) dllfunc(DLLFunc_Touch, %0, %1)
#define IsValidPev(%0) (pev_valid(%0) == 2)
#define IsCustomItem(%0) (pev(%0, pev_impulse) == g_iszWeaponKey)
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
RegisterHam(Ham_Spawn, "weaponbox", "HamHook_Weaponbox_Spawn_Post", true);
RegisterHam(Ham_TraceAttack, "func_breakable", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "hostage_entity", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "info_target", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_TraceAttack, "player", "HamHook_Entity_TraceAttack", false);
RegisterHam(Ham_Item_Deploy, WEAPON_REFERANCE, "HamHook_Item_Deploy_Post", true);
RegisterHam(Ham_Item_Holster, WEAPON_REFERANCE, "HamHook_Item_Holster", false);
RegisterHam(Ham_Item_AddToPlayer, WEAPON_REFERANCE, "HamHook_Item_AddToPlayer_Post", true);
RegisterHam(Ham_Item_PostFrame, WEAPON_REFERANCE, "HamHook_Item_PostFrame", false);
RegisterHam(Ham_CS_Item_GetMaxSpeed, WEAPON_REFERANCE, "HamHook_Item_GetMaxSpeed", false);
RegisterHam(Ham_Weapon_Reload, WEAPON_REFERANCE, "HamHook_Item_Reload", false);
RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_REFERANCE, "HamHook_Item_WeaponIdle", false);
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_REFERANCE, "HamHook_Item_PrimaryAttack", false);
register_forward(FM_SetModel, "FakeMeta_SetModel", false);
register_forward(FM_TraceLine, "FakeMeta_TraceLine_Post", true);
register_forward(FM_PlaybackEvent, "FakeMeta_PlaybackEvent", false);
register_forward(FM_UpdateClientData, "FakeMeta_UpdateClientData_Post", true);
register_message(get_user_msgid("DeathMsg"), "MsgHook_Death");
register_message(get_user_msgid("CurWeapon"), "MsgHook_CurWeapon");
MsgSayText = get_user_msgid("SayText");
unregister_forward(FM_DecalIndex, g_iForwardDecalIndex, true);
g_iItemID = zp_register_extra_item(ZP_ITEM_NAME, ZP_ITEM_COST, ZP_TEAM_HUMAN);
}
public plugin_precache()
{
Weapon_OnPrecache();
g_iszWeaponKey = engfunc(EngFunc_AllocString, WEAPON_NAME_C);
g_iForwardDecalIndex = register_forward(FM_DecalIndex, "FakeMeta_DecalIndex_Post", true);
register_clcmd(WEAPON_NAME_C, "Cmd_WeaponSelect");
register_clcmd(WEAPON_NAME_S, "Cmd_WeaponSelectEx");
register_message(MSG_WEAPONLIST, /*get_user_msgid("WeaponList"),*/ "MsgHook_WeaponList");
}
#if defined _DEBUG
ExtraItem_Register()
{
register_clcmd(_DEBUG_CMD, "Cmd_WeaponGive");
}
public Cmd_WeaponGive(const iPlayer)
{
Weapon_Give(iPlayer);
}
#else
#if !defined _ZP50
public zp_extra_item_selected(id, itemid)
{
if(itemid == g_iItemID)
{
if(zp_level(id) >= LVL_COUNT)
{
Weapon_Give(id);
}
else
{
zp_colored_print(id, "^x01[^x04ZP^x01] Вы не достигли ^x04%d ^x01уровня!", LVL_COUNT);
return ZP_PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
#else
public zp_fw_items_select_pre(id, itemid, ignorecost)
{
if (itemid != g_iItemID)
{
return ZP_ITEM_AVAILABLE;
}
if (zp_core_is_zombie(id))
{
return ZP_ITEM_DONT_SHOW;
}
return ZP_ITEM_AVAILABLE;
}
public zp_fw_items_select_post(id, itemid, ignorecost)
{
if (itemid == g_iItemID)
{
Weapon_Give(id);
}
}
#endif
#endif