Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#define PLUGIN "[ZP] Class: Hunter"
#define VERSION "1.2.2"
#define AUTHOR "YKH =]"
new const zclass_name[] = { "Hunter" }
new const zclass_info[] = { "Moka Leap" }
new const zclass_model[] = { "Hunter" }
new const zclass_clawmodel[] = { "models/v_Hunter_knife.mdl" }
const zclass_health = 200
const zclass_speed = 310
const Float:zclass_gravity = 0.8
const Float:zclass_knockback = 3.0
new g_attack_hit[][] =
{
"Sounds/L4D/Hunter_Hit-01.wav",
"Sounds/L4D/Hunter_Hit-02.wav",
"Sounds/L4D/Hunter_Hit-01.wav",
"Sounds/L4D/Hunter_Hit-02.wav",
"Sounds/L4D/Hunter_Hit-01.wav",
"Sounds/L4D/Hunter_Hit-03.wav"
}
new g_impacts[][] =
{
"Sounds/L4D/HunterFlesh_Impact-01.wav",
"Sounds/L4D/HunterFlesh_Impact-02.wav",
"Sounds/L4D/HunterFlesh_Impact-01.wav"
}
new g_attack_swipe[][] =
{
"Sounds/L4D/Hunter-swipe-1.wav",
"Sounds/L4D/Hunter-swipe-2.wav",
"Sounds/L4D/Hunter-swipe-1.wav"
}
new Hunter1_attack[][] =
{
"Sounds/L4D/Hunter-01.wav",
"Sounds/L4D/Hunter_Attack-01.wav",
}
new Hunter1_pain[][] =
{
"Sounds/L4D/Hunter_Pain-01.wav",
"Sounds/L4D/Hunter_Pain-02.wav",
"Sounds/L4D/Hunter_Pain-04.wav"
}
new g_zclass_LongJump, g_LongJump_force, g_LongJump_height, cvar_cooldown
new Float:g_lastleaptime[33] // time leap was last used
public plugin_init()
{
register_cvar("zp_zclass_leap_zombie",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
g_LongJump_force = register_cvar("zp_zclass_leap_force", "600")
g_LongJump_height = register_cvar("zp_zclass_leap_height", "245")
cvar_cooldown = register_cvar("zp_leap_cooldown", "1.5")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_EmitSound, "fw_EmitSound")
}
public plugin_init2() {
cvar_primattack = register_cvar("Hunter_Snds","1")
RegisterHam(Ham_TakeDamage, "player", "fwHamTakeDamage", 1)
//register_event("CurWeapon", "eCurWeapon", "be", "1!0")
RegisterHam(Ham_Player_PostThink, "player", "bacon_prethink", 1)
register_forward(FM_EmitSound, "fwd_emitsound")
}
public client_putinserver(id)
{
g_zombie[id] = false
}
public plugin_natives() {
register_native("hunter_take_damage","native_take_damage")
}
public native_take_damage(id) {
fwHamTakeDamage(get_param(1), get_param_f(2), get_param(3))
}
public eCurWeapon(id) {
if (get_gametime() > g_old_pa[id]) {
primaryattack(id)
g_old_pa[id] = get_gametime()+2.5;
}
}
public primaryattack(id) if (is_user_alive(id)) {
if (get_gametime() > g_old_pa[id]) {
if (is_user_zombie(id)) {
switch(g_zclass[id]) {
case 0: {
engfunc(EngFunc_EmitSound, id, CHAN_VOICE, Hunter1_attack[_random(id, sizeof Hunter1_attack)], 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
}
g_old_pa[id] = get_gametime()+0.5;
}
}
public fwHamTakeDamage(iPlayer, Float:health, damagebits) {
if (is_user_alive(iPlayer)) {
if (is_user_zombie(iPlayer) == 1) {
g_mode[iPlayer] = 1
switch(g_class[iPlayer]) {
case 0: {
engfunc(EngFunc_EmitSound, iPlayer, CHAN_BODY, Hunter1_pain[_random(iPlayer, sizeof Hunter1_pain)], 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
}
}
return HAM_IGNORED
}
public plugin_precache()
{
g_zclass_LongJump = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
for(new i = 0; i < sizeof g_attack_hit; i++)
precache_sound(g_attack_hit[i])
for(new i = 0; i < sizeof g_attack_swipe; i++)
precache_sound(g_attack_swipe[i])
for(new i = 0; i < sizeof Hunter1_attack; i++)
precache_sound(Hunter1_attack[i])
for(new i = 0; i < sizeof Hunter1_pain; i++)
precache_sound(Hunter1_pain[i])
}
public zp_user_infected_post(player, infector)
{
if (zp_get_user_zombie_class(player) == g_zclass_LongJump)
{
client_print(player, print_chat, "[ZP] Duck and press E to use leap !")
}
return PLUGIN_CONTINUE
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return
if (allowed_LongJump(id))
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
velocity[2] = get_pcvar_float(g_LongJump_height)
set_pev(id, pev_velocity, velocity)
// Set the current leap time
g_lastleaptime[id] = get_gametime()
}
}
public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
{
if(!is_user_connected(id) )
return FMRES_IGNORED
if (is_user_zombie(id)) {
g_players[id] = get_gametime() + 1.0;
//client_print(0,print_chat,"sample %s", sample)
if (sample[0] == 'z' && sample[1] == 'm')
return FMRES_IGNORED
if(sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
{
if(sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't' || sample[14] == 's' && sample[15] == 't' && sample[16] == 'a')
{
if(sample[17] == 'w' && sample[18] == 'a' && sample[19] == 'l') {
emit_sound(id, CHAN_WEAPON, g_attack_swipe[_random(id, sizeof g_attack_swipe)], volume, attn, flag, pitch)
} else {
emit_sound(id, CHAN_WEAPON, g_attack_hit[_random(id, sizeof g_attack_hit)], volume, attn, flag, pitch)
}
return FMRES_SUPERCEDE
}
}
}
//player/bhit_flesh-2.wav
if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i')
{
emit_sound(id, channel, g_impacts[_random(id, sizeof g_impacts)], volume, attn, flag, pitch)
return FMRES_SUPERCEDE
}
}
allowed_LongJump(id)
{
if (!zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
return false
if (zp_get_user_zombie_class(id) != g_zclass_LongJump)
return false
if (!((pev(id, pev_flags) & FL_ONGROUND) && (pev(id, pev_flags) & FL_DUCKING)) || fm_get_speed(id) < 10)
return false
static buttons
buttons = pev(id, pev_button)
// Not doing a longjump (added bot support)
if (!(buttons & IN_USE) && !is_user_bot(id))
return false
// Get cooldown cvar
static Float:cooldown
cooldown = get_pcvar_float(cvar_cooldown)
// Cooldown not over yet
if (get_gametime() - g_lastleaptime[id] < cooldown)
return false
return true
}