#include <ze_vip>
#include <fakemeta_util>
#include <cstrike>
#define CSW_WEAPON_BASE CSW_P90
#define CSW_NEW_WEAPON "weapon_lycanthrope"
#define CSW_OLD_WEAPON "weapon_p90"
#define WEAPON_KEY 9299292
#define OLD_WEAPON "models/w_p90.mdl"
#define is_user_valid(%1) (is_user_alive(%1) && !is_user_bot(%1) && !is_user_hltv(%1) && is_user_connected(%1))
new const Weapon_Models[][] = { "models/Premuim_ZE/v_lycanthrope.mdl", "models/Premuim_ZE/p_lycanthrope.mdl", "models/Premuim_ZE/w_lycanthrope.mdl" }
new const Weapon_Sounds[][] = { "weapons/sg552-shot1.wav", "weapons/sg552-shot2.wav", "weapons/buffsg552_draw.wav", "weapons/buffsg552_idle.wav", "weapons/buffsg552_reload.wav", "weapons/buffsg552_reload_AF.wav" }
new const Weapon_Sprites[][] = { "sprites/weapon_lycanthrope.txt", "sprites/640hud148.spr" }
new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
new bool:g_Hasscope[33], g_hasZoom[33]
new Cvar_scope_Recoil, Cvar_scope_DMG, Cvar_scope_Clip, Cvar_scope_Ammo, Cvar_scope_Speed
new Float:cl_pushangle[33][3], g_Eventscope, g_scope_TmpClip[33], g_IsInPrimaryAttack, g_Shock
public plugin_natives()
{
register_native("ze_give_lycanthrope_vip", "native_ze_give_lycanthrope_vip", 1)
}
public native_ze_give_lycanthrope_vip(id)
{
if (!is_user_connected(id))
return -1
Givescope(id)
return true
}
public plugin_precache()
{
for(new g = 0; g < sizeof(Weapon_Models); g++)
precache_model(Weapon_Models[g])
for(new h = 0; h < sizeof(Weapon_Sounds); h++)
precache_sound(Weapon_Sounds[h])
for(new t = 0; t < sizeof(Weapon_Sprites); t++)
precache_generic(Weapon_Sprites[t])
g_Shock = precache_model("sprites/lycanthrope_hit.spr")
register_clcmd(CSW_NEW_WEAPON, "hook")
register_forward(FM_PrecacheEvent, "Fw_Precache_Event", 1)
}
public hook(id)
{
engclient_cmd(id, CSW_OLD_WEAPON)
return PLUGIN_HANDLED
}
public plugin_init()
{
register_plugin("[ZE] Extra Item: Lycanthrope", "1.0", "Jack GamePlay")
// Events & Messages
register_message(get_user_msgid("DeathMsg"), "DeathMsg")
register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
register_event("HLTV", "New_Round", "a", "1=0", "2=0")
// Forwards
register_forward(FM_SetModel, "Fw_Set_Model", 1)
register_forward(FM_PlaybackEvent, "Fw_Playback_Event")
register_forward(FM_UpdateClientData, "Fw_Update_Clientdata", 1)
register_forward(FM_CmdStart, "Fw_CmdStart")
// Hook Chains
RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_Take_DMG")
// Hams
RegisterHam(Ham_Weapon_PrimaryAttack, CSW_OLD_WEAPON, "Fw_PrimaryAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, CSW_OLD_WEAPON, "Fw_PrimaryAttack_Post", 1)
RegisterHam(Ham_Item_AddToPlayer, CSW_OLD_WEAPON, "Fw_AddToPlayer")
RegisterHam(Ham_Weapon_Reload, CSW_OLD_WEAPON, "Fw_Reload")
RegisterHam(Ham_Weapon_Reload, CSW_OLD_WEAPON, "Fw_Reload_Post", 1)
RegisterHam(Ham_Spawn, "player", "Fw_Spawn", 1)
RegisterHam(Ham_TraceAttack, "worldspawn", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_breakable", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_wall", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door_rotating", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_plat", "Fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_rotating", "Fw_TraceAttack", 1)
RegisterHam(Ham_Use, "func_tank", "Fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tankmortar", "Fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tankrocket", "Fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tanklaser", "Fw_UseStationary_Post", 1)
RegisterHam(Ham_Item_Deploy, CSW_OLD_WEAPON, "Fw_Item_Deploy_Post", 1)
// Cvars
Cvar_scope_Recoil = register_cvar("ze_scope_recoil", "1.0")
Cvar_scope_DMG = register_cvar("ze_scope_damage", "6")
Cvar_scope_Clip = register_cvar("ze_scope_clip", "30")
Cvar_scope_Ammo = register_cvar("ze_scope_ammo", "150")
Cvar_scope_Speed = register_cvar("ze_scope_speed", "4.5")
}
public Fw_Item_Deploy_Post(weapon_ent)
{
new id = get_pdata_cbase(weapon_ent, 41, 4)
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
CurrentWeapon(id)
}
public Fw_UseStationary_Post(entity, caller, activator, use_type)
{
if (use_type == 0 && is_user_valid(caller))
{
CurrentWeapon(caller)
}
}
public Fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
if(!is_user_valid(iAttacker))
return
static Float:flEnd[3]
get_tr2(ptr, TR_vecEndPos, flEnd)
if(get_user_weapon(iAttacker) == CSW_WEAPON_BASE && g_Hasscope[iAttacker])
{
if(iEnt)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_DECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
write_short(iEnt)
message_end()
}
else
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GUNSHOTDECAL)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_short(iAttacker)
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flEnd, 0)
write_byte(TE_SPRITE)
engfunc(EngFunc_WriteCoord, flEnd[0])
engfunc(EngFunc_WriteCoord, flEnd[1])
engfunc(EngFunc_WriteCoord, flEnd[2])
write_short(g_Shock)
write_byte(5)
write_byte(150)
message_end()
}
}
public Fw_Spawn(id)
{
if(!is_user_valid(id))
return
Remove_scope(id)
}
public New_Round()
{
for(new i = 0; i < get_member_game(m_nMaxPlayers); i++)
{
if(!is_user_valid(i) || !g_Hasscope[i])
continue
Remove_scope(i)
}
}
public Fw_Reload_Post(weapon_entity)
{
new id = pev(weapon_entity, pev_owner)
if (!is_user_valid(id) || ze_is_user_zombie(id) || g_scope_TmpClip[id] == -1)
return HAM_IGNORED
if(g_Hasscope[id])
{
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
set_pdata_int(weapon_entity, 51, g_scope_TmpClip[id], 4)
set_pdata_float(weapon_entity, 48, 3.0, 4)
set_pdata_float(id, 83, 3.0, 5)
set_pdata_int(weapon_entity, 54, 1, 4)
UTIL_weapon_anim(id, weapon_entity, 1)
}
return HAM_IGNORED
}
public Fw_Reload(weapon_entity)
{
new id = pev(weapon_entity, pev_owner)
if (!is_user_valid(id) || ze_is_user_zombie(id))
return HAM_IGNORED
static iClipExtra
if(g_Hasscope[id])
{
iClipExtra = get_pcvar_num(Cvar_scope_Clip)
}
g_scope_TmpClip[id] = -1
new iBpAmmo = cs_get_user_bpammo(id, CSW_WEAPON_BASE)
new iClip = get_pdata_int(weapon_entity, 51, 4)
if (iBpAmmo <= 0 || iClip >= iClipExtra)
return HAM_SUPERCEDE
g_scope_TmpClip[id] = iClip
return HAM_IGNORED
}
public Fw_AddToPlayer(ent, id)
{
if(!is_valid_ent(ent) || !is_user_valid(id) || ze_is_user_zombie(id))
return HAM_IGNORED
if(entity_get_int(ent, EV_INT_impulse) == WEAPON_KEY)
{
g_Hasscope[id] = true
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
entity_set_int(ent, EV_INT_impulse, 0)
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, id)
write_string(CSW_NEW_WEAPON)
write_byte(7)
write_byte(100)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(8)
write_byte(CSW_WEAPON_BASE)
write_byte(0)
message_end()
return HAM_HANDLED
}
else
{
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, id)
write_string(CSW_OLD_WEAPON)
write_byte(7)
write_byte(100)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(8)
write_byte(CSW_WEAPON_BASE)
write_byte(0)
message_end()
}
return HAM_IGNORED
}
public Fw_Precache_Event(type, const name[])
{
if(equal("events/p90.sc", name))
{
g_Eventscope = get_orig_retval()
}
}
public Fw_Update_Clientdata(id, sendweapons, cd_handle)
{
if(!is_user_valid(id))
return
if(get_user_weapon(id) == CSW_WEAPON_BASE && g_Hasscope[id])
{
set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001)
}
}
public Fw_Playback_Event(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
if(!is_user_valid(invoker) || !g_IsInPrimaryAttack)
return
if(eventid == g_Eventscope && get_user_weapon(invoker) == CSW_WEAPON_BASE && g_Hasscope[invoker])
{
engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
UTIL_weapon_anim(invoker, eventid, random_num(3, 5))
emit_sound(invoker, CHAN_WEAPON, Weapon_Sounds[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
public ze_user_humanized(id)
{
if(!is_user_valid(id))
return
Remove_scope(id)
}
public ze_user_infected(id, infector)
{
if(!is_user_valid(id))
return
Remove_scope(id)
}
public Fw_PrimaryAttack(Weapon)
{
g_IsInPrimaryAttack = 0
new szClip, szAmmo, id
id = get_pdata_cbase(Weapon, 41, 4)
get_user_weapon(id, szClip, szAmmo)
if(!is_user_valid(id) || ze_is_user_zombie(id))
return
g_IsInPrimaryAttack = 1
if(g_Hasscope[id])
{
if (!cs_get_weapon_ammo(Weapon))
return
new Float:push[3]
pev(id, pev_punchangle, push)
xs_vec_sub(push, cl_pushangle[id], push)
xs_vec_mul_scalar(push, get_pcvar_float(Cvar_scope_Recoil), push)
xs_vec_add(push, cl_pushangle[id], push)
set_pev(id, pev_punchangle, push)
UTIL_weapon_anim(id, Weapon, random_num(3, 5))
emit_sound(id, CHAN_WEAPON, Weapon_Sounds[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
public Fw_CmdStart(id, handle)
{
if(!is_user_valid(id) || ze_is_user_zombie(id))
return
if((get_uc(handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2))
{
if(get_user_weapon(id) == CSW_WEAPON_BASE && g_Hasscope[id] && !g_hasZoom[id])
{
g_hasZoom[id] = true
cs_set_user_zoom(id, CS_SET_FIRST_ZOOM, 0)
}
else if(get_user_weapon(id) == CSW_WEAPON_BASE && g_Hasscope[id] && g_hasZoom[id])
{
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
}
}
}
public Fw_Take_DMG(Victim, Inflictor, Attacker, Float:Damage, DamageType)
{
if(!is_user_valid(Victim) || !is_user_valid(Attacker) ||ze_is_user_zombie(Attacker))
return
if(get_user_weapon(Attacker) == CSW_WEAPON_BASE && g_Hasscope[Attacker])
{
SetHamParamFloat(4, Damage * get_pcvar_float(Cvar_scope_DMG))
}
}
public Fw_PrimaryAttack_Post(Weapon)
{
g_IsInPrimaryAttack = 0
new szClip, szAmmo, id
id = get_pdata_cbase(Weapon, 41, 4)
get_user_weapon(id, szClip, szAmmo)
if(!is_user_valid(id) || ze_is_user_zombie(id))
return
if(g_Hasscope[id])
{
if (!cs_get_weapon_ammo(Weapon))
return
new Float:push[3]
pev(id, pev_punchangle, push)
xs_vec_sub(push, cl_pushangle[id], push)
xs_vec_mul_scalar(push, get_pcvar_float(Cvar_scope_Recoil), push)
xs_vec_add(push, cl_pushangle[id], push)
set_pev(id, pev_punchangle, push)
UTIL_weapon_anim(id, Weapon, random_num(3, 5))
emit_sound(id, CHAN_WEAPON, Weapon_Sounds[random_num(0, 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
}
public Fw_Set_Model(entity, model[])
{
if(!pev_valid(entity) || !equal(model, OLD_WEAPON))
return FMRES_IGNORED
static szClassName[33], id
id = pev(entity, pev_owner)
pev(entity, pev_classname, szClassName, charsmax(szClassName))
if(!equal(szClassName, "weaponbox"))
return FMRES_IGNORED
if(g_Hasscope[id] && pev_valid(fm_find_ent_by_owner(-1, CSW_OLD_WEAPON, entity)))
{
g_Hasscope[id] = false
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
set_pev(fm_find_ent_by_owner(-1, CSW_OLD_WEAPON, entity), pev_impulse, WEAPON_KEY)
engfunc(EngFunc_SetModel, entity, Weapon_Models[2])
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public CurrentWeapon(id)
{
if(!is_user_valid(id))
return
if(get_user_weapon(id) == CSW_WEAPON_BASE && g_Hasscope[id])
{
if(g_hasZoom[id])
{
cs_set_player_view_model(id, CSW_WEAPON_BASE, "")
}
else if(!g_hasZoom[id])
{
cs_set_player_view_model(id, CSW_WEAPON_BASE, Weapon_Models[0])
}
cs_set_player_weap_model(id, CSW_WEAPON_BASE, Weapon_Models[1])
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, id)
write_string(CSW_NEW_WEAPON)
write_byte(7)
write_byte(100)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(8)
write_byte(CSW_WEAPON_BASE)
write_byte(0)
message_end()
static Float:iSpeed; iSpeed = get_pcvar_float(Cvar_scope_Speed)
static Ent; Ent = find_ent_by_owner(-1, CSW_OLD_WEAPON, id)
if(Ent)
{
static Float:Delay; Delay = get_pdata_float( Ent, 46, 4) * iSpeed
if (Delay > 0.0)
{
set_pdata_float(Ent, 46, Delay, 4)
}
}
}
}
public DeathMsg(msg_id, msg_dest, id)
{
static szTruncatedWeapon[33], iAttacker, iVictim
get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
iAttacker = get_msg_arg_int(1)
iVictim = get_msg_arg_int(2)
if(!is_user_valid(iAttacker) || iAttacker == iVictim) return
if(equal(szTruncatedWeapon, "p90") && get_user_weapon(iAttacker) == CSW_WEAPON_BASE && g_Hasscope[iAttacker])
{
set_msg_arg_string(4, "lycanthrope")
}
}
public Givescope(id)
{
drop_weapons(id, 1)
new wep = rg_give_item(id, CSW_OLD_WEAPON)
if (wep > 0)
{
cs_set_weapon_ammo(wep, get_pcvar_num(Cvar_scope_Clip))
cs_set_user_bpammo(id, CSW_WEAPON_BASE, get_pcvar_num(Cvar_scope_Ammo))
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, id)
write_string(CSW_NEW_WEAPON)
write_byte(7)
write_byte(100)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(8)
write_byte(CSW_WEAPON_BASE)
write_byte(0)
message_end()
}
g_Hasscope[id] = true
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_RESET_ZOOM, 0)
UTIL_weapon_anim(id, CSW_WEAPON_BASE, 2)
ze_colored_print(id, "!tYou bought Lycanthrope!y.")
}
public Remove_scope(id)
{
if(!is_user_valid(id))
return
g_Hasscope[id] = false
g_hasZoom[id] = false
cs_set_user_zoom(id, CS_SET_NO_ZOOM, 0)
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, id)
write_string(CSW_OLD_WEAPON)
write_byte(7)
write_byte(100)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(8)
write_byte(CSW_WEAPON_BASE)
write_byte(0)
message_end()
cs_reset_player_view_model(id, CSW_WEAPON_BASE)
cs_reset_player_weap_model(id, CSW_WEAPON_BASE)
}
UTIL_weapon_anim(index, entity, sequence = 0)
{
set_pev(index, pev_weaponanim, sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, index)
write_byte(sequence)
write_byte(pev(entity, pev_body))
message_end()
}
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_MAC10)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
engclient_cmd(id, "drop", wname)
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1036{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/