/*================================================================================
-----------------------------------
-*- [ZP] Class: Zombie: Classic -*-
-----------------------------------
This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
================================================================================*/
#include <amxmodx>
#include <reapi>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_class_zombie>
// Classic Zombie Attributes
new const zombieclass1_name[] = "Classic Zombie"
new const zombieclass1_info[] = "=Balanced="
new const zombieclass1_models[][] = { "dog_r" }
new const zombieclass1_clawmodels[][] = { "models/zombie_plague/v_knife_zombie.mdl" }
const zombieclass1_health = 1800
const Float:zombieclass1_speed = 0.75
const Float:zombieclass1_gravity = 1.0
const Float:zombieclass1_knockback = 1.0
new g_ZombieClassID;
enum ePlayerData {
Float:ePlayerData_flLastAttack,
}
new g_PlayerData[MAX_PLAYERS + 1][ePlayerData];
public plugin_precache()
{
register_plugin("[ZP] Class: Zombie: Classic", ZP_VERSION_STRING, "ZP Dev Team")
new index
g_ZombieClassID = zp_class_zombie_register(zombieclass1_name, zombieclass1_info, zombieclass1_health, zombieclass1_speed, zombieclass1_gravity)
zp_class_zombie_register_kb(g_ZombieClassID, zombieclass1_knockback)
for (index = 0; index < sizeof zombieclass1_models; index++)
zp_class_zombie_register_model(g_ZombieClassID, zombieclass1_models[index])
for (index = 0; index < sizeof zombieclass1_clawmodels; index++)
zp_class_zombie_register_claw(g_ZombieClassID, zombieclass1_clawmodels[index])
}
public plugin_init()
{
RegisterHookChain(RG_CBasePlayer_SetAnimation, "fw_PlayerAnimation", false);
RegisterHam(Ham_CS_Weapon_SendWeaponAnim, "weapon_knife", "fw_CS_SendAnim_Post", true);
}
enum /*knife_e*/
{
KNIFE_IDLE,
KNIFE_ATTACK1HIT,
KNIFE_ATTACK2HIT,
KNIFE_DRAW,
KNIFE_STABHIT,
KNIFE_STABMISS,
KNIFE_MIDATTACK1HIT,
KNIFE_MIDATTACK2HIT,
};
/*** Ставим метку о том, что будем ломать аниму и заслыаем нашу ***/
public fw_CS_SendAnim_Post(iWeapon, iAnim, skiplocal, body) {
new id = get_member(iWeapon, m_pPlayer);
if (zp_core_is_zombie(id) && zp_class_zombie_get_current(id) == g_ZombieClassID) {
switch (iAnim) {
case KNIFE_ATTACK1HIT, KNIFE_ATTACK2HIT, KNIFE_STABHIT, KNIFE_STABMISS, KNIFE_MIDATTACK1HIT, KNIFE_MIDATTACK2HIT: {
new Float:fGameTime; fGameTime = get_gametime();
g_PlayerData[id][ePlayerData_flLastAttack] = fGameTime + 0.75; // Это время на которое будет ломаться стандартная анима
// UTIL_PlayerAnimation(id, "ref_shoot_knife", .fFrame = 0.0, .flGametime = fGameTime, .fFrameRate = 1.0);
RequestFrame("@DelayedRequestAnim", id);
// server_print("1");
}
}
}
}
/*** Не поспеваем отправлять в гане, отправляем на некст фрейме иначе не работает. Ну или отправлять в самом playerAnim хукчейне (вызывается каждый кадр btw) ***/
@DelayedRequestAnim(id)
{
if (is_user_alive(id) && zp_core_is_zombie(id) && zp_class_zombie_get_current(id) == g_ZombieClassID) {
UTIL_PlayerAnimation(id, "ref_shoot_knife", .fFrame = 0.0, .flGametime = 0.0, .fFrameRate = 1.0);
}
}
/*** Модельиндекс нужен 100%, иначе будет искать в дефолтной models/player.mdl */
// public zp_fw_core_infect_post(id){
// if (zp_class_zombie_get_current(id) == g_ZombieClassID) {
// rg_set_user_model(id, zombieclass1_models[0], true);
// }
// }
/*** Брякаем стандартную аниму ***/
public fw_PlayerAnimation(id, PLAYER_ANIM:iAnimation)
{
static Float:fGameTime; fGameTime = get_gametime();
switch (iAnimation) {
case PLAYER_IDLE, PLAYER_WALK, PLAYER_JUMP: {
// client_print(id, print_center, "Idle");
if (g_PlayerData[id][ePlayerData_flLastAttack] > fGameTime) {
// server_print("2");
// UTIL_PlayerAnimation(id, "ref_shoot_knife", .fFrame = 0.0, .flGametime = fGameTime, .fFrameRate = 1.0);
return HC_BREAK;
}
}
// case PLAYER_WALK: {
// client_print(id, print_center, "Walk");
// }
// case PLAYER_JUMP: {
// client_print(id, print_center, "Jump");
// }
// case PLAYER_SUPERJUMP: client_print(id, print_center, "SuperJump");
// case PLAYER_DIE: client_print(id, print_center, "Die");
// case PLAYER_ATTACK1: client_print(id, print_center, "Attack1");
// case PLAYER_ATTACK2: client_print(id, print_center, "Attack2");
// case PLAYER_FLINCH: client_print(id, print_center, "Flinch");
// case PLAYER_LARGE_FLINCH: client_print(id, print_center, "LargeFlinch");
// case PLAYER_RELOAD: client_print(id, print_center, "Reload");
// case PLAYER_HOLDBOMB: client_print(id, print_center, "HoldBomb");
default: {
}
}
return HC_CONTINUE;
}
stock UTIL_PlayerAnimation(pPlayer, const szAnimation[], Float:fFrame = 0.0, Float:flGametime = 0.0, Float:fFrameRate = 1.0) // Спасибо большое KORD_12.7
{
new iAnimDesired, Float:flFrameRate, Float:flGroundSpeed, bool:bLoops;
if((iAnimDesired = lookup_sequence(pPlayer, szAnimation, flFrameRate, bLoops, flGroundSpeed)) == -1) {
server_print("anim not found %s", szAnimation);
iAnimDesired = 0;
}
// new Float:flGametime;
if(flGametime == 0.0) flGametime = get_gametime();
set_entvar(pPlayer, var_frame, fFrame);
set_entvar(pPlayer, var_framerate, fFrameRate);
set_entvar(pPlayer, var_animtime, flGametime);
set_entvar(pPlayer, var_sequence, iAnimDesired);
set_entvar(pPlayer, var_gaitsequence, iAnimDesired);
set_member(pPlayer, m_fSequenceLoops, bLoops);
set_member(pPlayer, m_fSequenceFinished, 0);
set_member(pPlayer, m_flFrameRate, flFrameRate);
set_member(pPlayer, m_flGroundSpeed, flGroundSpeed);
set_member(pPlayer, m_flLastEventCheck, flGametime);
set_member(pPlayer, m_Activity, ACT_RANGE_ATTACK1); // текущая анимация
set_member(pPlayer, m_IdealActivity, ACT_RANGE_ATTACK1); // будущая анимация
#define m_flLastAttackTime 220
#define linux_diff_player 5
set_pdata_float(pPlayer, m_flLastAttackTime, flGametime, linux_diff_player);
}
}