#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <dhudmessage>
#include <cstrike>
#include <fun>
#include <xs>
#include <zombieplague>
/*============================================================================================*/
new const zclass_name[] = "Hunter Zombie"
new const zclass_info[] = "[ Sprint ]"
new const zclass_model[] = "sc_hunter"
new const zclass_clawmodel[] = "v_claws_hunter.mdl"
const zclass_health = 3100
const zclass_speed = 235
const Float:zclass_gravity = 0.79
const Float:zclass_knockback = 0.43
/*============================================================================================*/
// Scream ring color R G B
const Float:fastrun_time = 2.5
const Float:fastrun_timewait = 15.0
const Float:fastrun_speed = 1000.0
const fastrun_fov = 110
const glow_red = 255
const glow_green = 0
const glow_blue = 0
new const sound_fastrun_start[] = "blackcat_sc/hunter/ability.wav"
new const sound_fastrun_heartbeat[][] = { "blackcat_sc/hunter/ability_idle.wav" }
new const sound_fastrun_end[][] = { "blackcat_sc/nemesis/idle.wav" }
#define MAXPLAYERS 33
// Variables
new g_cooldown[33]
// Arrays
new g_iPlayerTaskTimes[33]
// Some constants
const FFADE_IN = 0x0000
const GIB_NEVER = 0
const UNIT_SECOND = (1<<12)
const TASK_SCREAM = 37729
const TASK_SCREAMDMG = 48289
const NADE_TYPE_JUMP = 6666
const NADE_TYPE_CONC = 7777
// Plug info.
#define PLUG_VERSION "0.2"
#define PLUG_AUTH "meTaLiCroSS"
// Macros
#define zp_get_grenade_type(%1) (entity_get_int(%1, EV_INT_flTimeStepSound))
#define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && is_user_alive(%1))
#define is_user_valid_connected(%1) (1 <= %1 <= g_maxplayers && is_user_alive(%1))
new zclassid_hunter
new g_fastrun[33]
new g_msgSetFOV
// Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
enum (+= 100) {
TASK_FASTRUN = 2000,
TASK_FASTRUN_HEARTBEAT,
TASK_COOLDOWN
}
#define ID_FASTRUN (taskid - TASK_FASTRUN)
#define ID_FASTRUN_HEARTBEAT (taskid - TASK_FASTRUN_HEARTBEAT)
#define ID_COOLDOWN (taskid - TASK_COOLDOWN)
new h_playername[33][32]
const FFADE_IN = 0x0000
const FFADE_STAYOUT = 0x0004
const UNIT_SECOND = (1<<12)
#define DAMAGE 2.0
const Max_Traps = 6
const OFFSET_flNextPrimaryAttack = 46
const OFFSET_flNextSecondaryAttack = 47
const OFFSET_flTimeWeaponIdle = 48
const OFFSET_LINUX_WEAPONS = 4
new g_maxplayers
new g_msgBarTime
new const sound_sleep[] = "blackcat_sc/big/ability.wav"
public plugin_init()
{
register_forward(FM_CmdStart, "fw_CmdStart")
register_forward(FM_StartFrame, "fw_StartFrame")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_Touch, "fw_Touch")
register_forward(FM_Think, "fw_Think")
register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
RegisterHam(Ham_TakeDamage, "player", "ham_takedamage")
RegisterHam(Ham_TakeDamage, "func_breakable", "ham_takedamage")
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
g_msgBarTime = get_user_msgid("BarTime")
g_msgSetFOV = get_user_msgid("SetFOV")
g_maxplayers = get_maxplayers()
register_clcmd("drop", "use_ability_one")
register_impulse(100, "cmd_fastrun")
register_dictionary("hunter_zombie.txt")
register_dictionary("zombie_plague.txt")
}
public plugin_precache()
{
precache_sound(sound_sleep)
new i
for(i = 0; i < sizeof sound_fastrun_heartbeat; i++ )
precache_sound(sound_fastrun_heartbeat[i]);
for(i = 0; i < sizeof sound_fastrun_end; i++ )
precache_sound(sound_fastrun_end[i]);
precache_sound(sound_fastrun_start)
zclassid_hunter = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
public zp_user_infected_post(id, infector, nema)
{
if(zp_get_user_zombie_class(id) == zclassid_hunter)
{
g_fastrun[id] = 0
print(id, "^x04[ZP]^x01 %L", id, "HUNTER_ABILITY_INFO")
}
g_cooldown[id] = 0
}
/* //////////////////////////////////////////// */
public zp_user_humanized_post(id)
{
g_fastrun[id] = 0
if(g_fastrun[id])
{
message_begin(MSG_ONE, g_msgSetFOV, {0,0,0}, id)
write_byte(90)
message_end()
}
g_iPlayerTaskTimes[id] = 0
}
public zp_round_ended(winteam)
{
// Make a loop
static id
for(id = 1; id <= g_maxplayers; id++)
{
// Valid connected
if(is_user_connected(id))
{
// Remove mainly tasks
remove_task(id+TASK_COOLDOWN)
}
}
}
public client_disconnect(id)
{
remove_task(id+TASK_FASTRUN)
remove_task(id+TASK_FASTRUN_HEARTBEAT)
remove_task(id+TASK_COOLDOWN)
}
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
set_pev(entity, pev_renderfx, fx);
set_pev(entity, pev_rendercolor, RenderColor);
set_pev(entity, pev_rendermode, render);
set_pev(entity, pev_renderamt, float(amount));
return 1;
}
stock fm_find_ent_by_class(index, const classname[])
{
return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
}
stock PlaySound(id, const sound[])
{
if (equal(sound[strlen(sound)-4], ".mp3"))
client_cmd(id, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(id, "spk ^"%s^"", sound)
}
stock user_screen_shake(id, amplitude = 4, duration = 2, frequency = 10)
{
message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
write_short((1<<12)*amplitude)
write_short((1<<12)*duration)
write_short((1<<12)*frequency)
message_end()
}
stock show_user_taskbar(id, time)
{
message_begin(MSG_ONE_UNRELIABLE, g_msgBarTime, _, id)
write_short(time)
message_end()
}
stock show_user_sprite(id, const sprite_index)
{
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_PLAYERATTACHMENT)
write_byte(id)
write_coord(45)
write_short(sprite_index)
write_short(32767)
message_end()
}
stock clear_user_sprite(id)
{
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_KILLPLAYERATTACHMENTS)
write_byte(id)
message_end()
}
stock bool:fm_is_point_visible(index, const Float:point[3], ignoremonsters = 1)
{
new Float:start[3], Float:dest[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, dest);
xs_vec_add(start, dest, start);
engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (fraction == 1.0)
return true;
get_tr2(0, TR_vecEndPos, dest);
if ((dest[0] == point[0]) && (dest[1] == point[1]) && (dest[2] == point[2]))
return true;
return false;
}
stock create_user_sprite(id, const Float:originF[3], sprite_index, scale)
{
message_begin(MSG_ONE, SVC_TEMPENTITY, _, id)
write_byte(TE_SPRITE)
engfunc(EngFunc_WriteCoord, originF[0])
engfunc(EngFunc_WriteCoord, originF[1])
engfunc(EngFunc_WriteCoord, originF[2])
write_short(sprite_index)
write_byte(scale)
write_byte(200)
message_end()
}
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && (pev(entity, pev_owner) != owner)) {}
return entity;
}
stock Float:get_weapon_next_pri_attack(entity)
{
return get_pdata_float(entity, OFFSET_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS)
}
stock set_weapon_next_pri_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flNextPrimaryAttack, time, OFFSET_LINUX_WEAPONS)
}
stock Float:get_weapon_next_sec_attack(entity)
{
return get_pdata_float(entity, OFFSET_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS)
}
stock set_weapon_next_sec_attack(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flNextSecondaryAttack, time, OFFSET_LINUX_WEAPONS)
}
stock Float:get_weapon_idle_time(entity)
{
return get_pdata_float(entity, OFFSET_flTimeWeaponIdle, OFFSET_LINUX_WEAPONS)
}
stock set_weapon_idle_time(entity, Float:time)
{
set_pdata_float(entity, OFFSET_flTimeWeaponIdle, time, OFFSET_LINUX_WEAPONS)
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
public client_putinserver(id)
{
get_user_name(id, h_playername[id], charsmax(h_playername[]))
}
public cmd_fastrun(id) {
if (!is_user_connected(id) || !is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_zombie_class(id) != zclassid_hunter)
return PLUGIN_CONTINUE
if(g_fastrun[id] || g_cooldown[id])
return PLUGIN_CONTINUE
g_fastrun[id] = 1
set_pev(id, pev_maxspeed, fastrun_speed)
set_task(fastrun_time, "sprint_remove", id+TASK_FASTRUN)
set_task(2.0, "sprint_sound", id+TASK_FASTRUN_HEARTBEAT, _, _, "b")
set_user_rendering(id, kRenderFxGlowShell, glow_red, glow_green, glow_blue, kRenderNormal, 0)
// Glow Effect
message_begin(MSG_ONE, g_msgSetFOV, {0,0,0}, id)
write_byte(fastrun_fov)
message_end()
// FOV Effect
message_begin(MSG_ONE,get_user_msgid("ScreenFade"), _, id)
write_short(7007)
write_short(7007)
write_short(0x0000)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(125)
message_end()
// Red Screen
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id)
write_short((1<<12)*6) // amplitude
write_short((1<<12)*6) // duration
write_short((1<<12)*10) // frequency
message_end()
// Shake Screen
emit_sound(id, CHAN_VOICE, sound_fastrun_start, 1.0, ATTN_NORM, 0, PITCH_NORM)
// Sound Sprint
return PLUGIN_HANDLED
}
public sprint_remove(taskid) {
if(!zp_get_user_zombie(ID_FASTRUN) || zp_get_user_zombie_class(ID_FASTRUN) != zclassid_hunter || zp_get_user_nemesis(ID_FASTRUN)) {
remove_task(ID_FASTRUN+TASK_FASTRUN)
return
}
g_fastrun[ID_FASTRUN] = 0
ExecuteHamB(Ham_Player_ResetMaxSpeed, ID_FASTRUN)
set_user_rendering(ID_FASTRUN)
message_begin(MSG_ONE, g_msgSetFOV, {0,0,0}, ID_FASTRUN)
write_byte(90)
message_end()
g_cooldown[ID_FASTRUN] = floatround(fastrun_timewait)
set_task(1.0, "ShowHUD", ID_FASTRUN+TASK_COOLDOWN, _, _, "b")
}
public sprint_sound(taskid) {
if(!zp_get_user_zombie(ID_FASTRUN_HEARTBEAT) || zp_get_user_zombie_class(ID_FASTRUN_HEARTBEAT) != zclassid_hunter || zp_get_user_nemesis(ID_FASTRUN_HEARTBEAT)) {
remove_task(ID_FASTRUN_HEARTBEAT+TASK_FASTRUN_HEARTBEAT)
return;
}
if (g_fastrun[ID_FASTRUN_HEARTBEAT])
emit_sound(ID_FASTRUN_HEARTBEAT, CHAN_VOICE, sound_fastrun_heartbeat[random_num(0, sizeof sound_fastrun_heartbeat - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
else {
emit_sound(ID_FASTRUN_HEARTBEAT, CHAN_VOICE, sound_fastrun_end[random_num(0, sizeof sound_fastrun_end - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_task(ID_FASTRUN_HEARTBEAT+TASK_FASTRUN_HEARTBEAT)
}
}
public zp_user_unfrozen(id) {
if(!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != zclassid_hunter || !g_fastrun[id] || zp_get_user_nemesis(id))
return
set_user_rendering(id, kRenderFxGlowShell, glow_red, glow_green, glow_blue, kRenderNormal, 0)
}
public ShowHUD(taskid){
new id = ID_COOLDOWN
g_cooldown[id]--
if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id))
{
remove_task(id+TASK_COOLDOWN)
return
}
if(!g_cooldown[id])
{
if(zp_get_user_zombie_class(id) == zclassid_hunter)
{
print(id, "^x04[ZP]^x01 %L", id, "HUNTER_ABILITY_READY")
}
remove_task(id+TASK_COOLDOWN)
return
}
set_dhudmessage(200, 200, 0, -1.0, 0.86, 0, 1.0, 1.1, 0.0, 0.0, false)
show_dhudmessage(id, "%L", id, "ABILITY_COOLDOWN", g_cooldown[id])
}
stock print(const id, const input[], any:...)
{
new iCount = 1, iPlayers[32]
static szMsg[191]
vformat(szMsg, charsmax(szMsg), input, 3)
replace_all(szMsg, 190, "!g", "^4") // green txt
replace_all(szMsg, 190, "!y", "^1") // orange txt
replace_all(szMsg, 190, "!t", "^3")
replace_all(szMsg, 190, "^x04", "^4") // green txt
replace_all(szMsg, 190, "^x01", "^1") // orange txt
replace_all(szMsg, 190, "^x03", "^3") // team txt
replace_all(szMsg, 190, "^x00", "^0") // team txt
if(id) iPlayers[0] = id
else get_players(iPlayers, iCount, "ch")
for (new i = 0; i < iCount; i++)
{
if (is_user_connected(iPlayers[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i])
write_byte(iPlayers[i])
write_string(szMsg)
message_end()
}
}
}