#include <amxmodx>
#include <hamsandwich>
#include <fun>
#include <zombieplague>
#include <zp_addons>
#define DHUD
#if !defined DHUD
new g_MsgSync;
#endif
#define semicolon 1
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame;
#define SKILL_SPEED_COMMAND "radio1" // Key 'Z'
#define SKILL_SPEED_BONUS 440.0
#define SKILL_SPEED_STATIC 0.0
#define SKILL_SPEED_TIME 6.0
#define SKILL_SPEED_TASKID 100
new const SpeedSoundStart[] = "skills/skill_speed_start.wav";
new const SpeedSoundEnd[] = "skills/skill_speed_end.wav";
#define SKILL_INVISIBLE_COMMAND "radio2" // Key 'X'
#define SKILL_INVISIBLE_TIME 6.0
#define SKILL_INVISIBLE_TASKID 200
new const InvisibleSoundStart[] = "skills/skill_invisible_start.wav";
new const InvisibleSoundEnd[] = "skills/skill_invisible_end.wav";
new bool:use_skill_speed[33];
new bool:use_skill_invisible[33];
new bool:active_skill_speed[33];
new bool:active_skill_invisible[33];
new TrailSpriteID;
new bool:g_FreezeTime;
public plugin_init()
{
register_plugin("[ZPA]: Skill human", "1.0b", "Felix_Font");
register_clcmd(SKILL_SPEED_COMMAND, "ActivateSkill_Speed");
register_clcmd(SKILL_INVISIBLE_COMMAND, "ActivateSkill_Invisible");
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
register_logevent("logevent_round_start", 2, "1=Round_Start"); // Freeze time end
RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1);
#if !defined DHUD
g_MsgSync = CreateHudSyncObj();
#endif
set_task(1.0, "ShowHud", 0, _, _, "b");
}
public plugin_precache()
{
TrailSpriteID = precache_model("sprites/3dmflaora.spr");
precache_sound(SpeedSoundStart);
precache_sound(SpeedSoundEnd);
precache_sound(InvisibleSoundStart);
precache_sound(InvisibleSoundEnd);
}
public event_round_start()
{
g_FreezeTime = true;
for(new id = 1; id <= 32; id++) if(is_user_connected(id)) ResetPlayerLimit(id);
}
public logevent_round_start()
{
if(task_exists(1)) remove_task(1);
set_task(2.0, "ActivateSkills", 1);
}
public plugin_natives()
{
register_native("zp_use_human_skills_invisible", "native_use_invisible", 1)
}
public native_use_invisible(id)
{
return get_user_skill_invisible(id);
}
public ActivateSkills() g_FreezeTime = false;
public client_putinserver(id) ResetPlayerLimit(id);
public zp_user_humanized_pre(id) ResetPlayerLimit(id);
public zp_user_infected_pre(id) ResetPlayerLimit(id);
public ActivateSkill_Speed(id)
{
if(g_FreezeTime || !is_user_alive(id) || zp_get_user_zombie(id) || zp_get_user_survivor(id) || use_skill_speed[id] == true || active_skill_invisible[id] == true) return PLUGIN_CONTINUE;
new skill_time = floatround(SKILL_SPEED_TIME, floatround_floor);
use_skill_speed[id] = true;
active_skill_speed[id] = true;
emit_sound(id, CHAN_VOICE, SpeedSoundStart, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
ScreenFadeMessage(id, skill_time, {0, 255, 0, 30});
TrailMessage(id, (skill_time-1));
ScreenShakeMessage(id);
ExecuteHamB(Ham_Player_ResetMaxSpeed, id);
set_task(SKILL_SPEED_TIME, "DeActivateSkill_Speed", id+SKILL_SPEED_TASKID);
return PLUGIN_HANDLED;
}
public DeActivateSkill_Speed(taskid)
{
new id = (taskid-SKILL_SPEED_TASKID);
if(!is_user_connected(id)) return;
active_skill_speed[id] = false;
emit_sound(id, CHAN_VOICE, SpeedSoundEnd, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
DeleteTrailMessage(id);
ExecuteHamB(Ham_Player_ResetMaxSpeed, id);
}
public ActivateSkill_Invisible(id)
{
if(g_FreezeTime || !is_user_alive(id) || zp_get_user_zombie(id) || zp_get_user_survivor(id) || use_skill_invisible[id] == true || active_skill_speed[id] == true) return PLUGIN_CONTINUE;
use_skill_invisible[id] = true;
active_skill_invisible[id] = true;
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)-
emit_sound(id, CHAN_VOICE, InvisibleSoundStart, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
ScreenFadeMessage(id, floatround(SKILL_INVISIBLE_TIME, floatround_floor), {211, 211, 211, 30});
set_task(SKILL_INVISIBLE_TIME, "DeActivateSkill_Invisible", id+SKILL_INVISIBLE_TASKID);
return PLUGIN_HANDLED;
}
public DeActivateSkill_Invisible(taskid)
{
new id = (taskid-SKILL_INVISIBLE_TASKID);
if(!is_user_connected(id)) return;
active_skill_invisible[id] = false;
emit_sound(id, CHAN_VOICE, InvisibleSoundEnd, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
set_user_rendering(id);
}
public get_user_skill_invisible(id)
{
return use_skill_invisible[id];
}
public ShowHud()
{
if(g_FreezeTime) return;
new players[32];
new count, i, id;
get_players(players, count, "ach");
for(i = 0; i < count; i++)
{
id = players[i];
if(zp_get_user_zombie(id)) continue;
if(zp_get_user_survivor(id)) continue;
if(use_skill_speed[id] == true && use_skill_invisible[id] == true) continue;
ShowSyncHud(id);
}
}
public ShowSyncHud(id)
{
if(use_skill_speed[id] == false && use_skill_invisible[id] == false) ShowHudMessage(id, "[Способности]^n[Z - Ускорение]^n[X - Невидимка]");
else if(use_skill_speed[id] == false) ShowHudMessage(id, "[Способности]^n[Z - Ускорение]");
else if(use_skill_invisible[id] == false) ShowHudMessage(id, "[Способности]^n[X - Невидимка]");
}
ShowHudMessage(id, text[])
{
#if !defined DHUD
set_hudmessage(0, 255, 0, 1.0, 0.70, 0, 0.0, 1.0);
ShowSyncHudMsg(id, g_MsgSync, text);
#else
set_dhudmessage(0, 255, 0, 1.0, 0.70, 0, 0.0, 1.0);
show_dhudmessage(id, text);
#endif
}
public fw_ResetMaxSpeed_Post(id)
{
if(g_FreezeTime || !is_user_alive(id) || active_skill_speed[id] == false) return;
RemoveSpeedLimit(id);
if(SKILL_SPEED_STATIC == 0.0) set_user_maxspeed(id, (get_user_maxspeed(id)+SKILL_SPEED_BONUS));
else set_user_maxspeed(id, SKILL_SPEED_STATIC);
}
ResetPlayerLimit(id)
{
use_skill_speed[id] = false;
use_skill_invisible[id] = false;
if(active_skill_speed[id] == true)
{
remove_task(id+SKILL_SPEED_TASKID);
active_skill_speed[id] = false;
if(is_user_connected(id))
{
ScreenFadeMessage(id, 1, {0, 0, 0, 0});
DeleteTrailMessage(id);
ExecuteHamB(Ham_Player_ResetMaxSpeed, id);
}
}
if(active_skill_invisible[id] == true)
{
remove_task(id+SKILL_INVISIBLE_TASKID);
active_skill_invisible[id] = false;
if(is_user_connected(id))
{
ScreenFadeMessage(id, 1, {0, 0, 0, 0});
set_user_rendering(id);
}
}
}
RemoveSpeedLimit(id)
{
client_cmd(id,"cl_forwardspeed 1000");
client_cmd(id,"cl_backspeed 1000");
client_cmd(id,"cl_sidespeed 1000");
}
TrailMessage(id, seconds)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(TE_BEAMFOLLOW);
write_short(id);
write_short(TrailSpriteID);
write_byte(seconds);
write_byte(20);
write_byte(0);
write_byte(255);
write_byte(0);
write_byte(200);
message_end();
}
DeleteTrailMessage(id)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99) // TE_KILLBEAM
write_short(id)
message_end()
}
ScreenFadeMessage(id, seconds, color[4])
{
static g_msgScreenFade;
if(!g_msgScreenFade) g_msgScreenFade = get_user_msgid("ScreenFade");
message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, id);
write_short((1<<12)*seconds);
write_short((1<<12)*seconds);
write_short(0x0000); // FRADE_IN
write_byte(color[0]);
write_byte(color[1]);
write_byte(color[2]);
write_byte(color[3]);
message_end();
}
ScreenShakeMessage(id)
{
static g_msgScreenShake;
if(!g_msgScreenShake) g_msgScreenShake = get_user_msgid("ScreenShake");
message_begin(MSG_ONE, g_msgScreenShake, {0,0,0}, id);
write_short(1<<12);
write_short(1<<14) ;
write_short(1<<14);
message_end();
}