Помогите вписать функцию в плагин зомби класса

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
552
Реакции
49
Предупреждения
2
Помог
4 раз(а)
Всем доброго времени суток. Недавно я в плагине оружия AT4CS отыскал функцию "turn_to_target", она расшифровывается как "поворот к цели". Кто-нибудь подскажите пожалуйста, как можно вписать эту функию в зомби класс banchee, когда она будет выпускать мышей, то они должны при приближении поворачиваться к цели. Помогите кто-нибудь.

at4cs:
Код:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>
 
#define PLUGIN "[ZP] Extra Item: AT4CS"
#define VERSION "1.0"
#define AUTHOR "Dias"
 
#define weapon_at4cs "weapon_m249"
#define CSW_AT4CS CSW_M249
 
#define TASK_CHECKRELOAD 111112
#define TASK_RELOAD 111113
 
new g_at4cs
new g_had_at4cs[33], Float:g_lastfire[33], Float:g_lastaim[33], g_aiming[33],
g_smoke_id, g_spr_trail, g_spr_exp, is_reloading[33],
cvar_radius, cvar_maxdamage
 
new const v_model[] = "models/zombie_plague/v_at4ex.mdl"
new const p_model[] = "models/zombie_plague/p_at4ex.mdl"
new const w_model[] = "models/zombie_plague/w_at4ex.mdl"
new const s_model[] = "models/zombie_plague/s_rocket.mdl"
 
new const at4cs_sound[5][] = {
   "weapons/at4-1.wav", // Fire Sound
   "weapons/at4_clipin1.wav", // Clip in 1
   "weapons/at4_clipin2.wav", // Clip in 2
   "weapons/at4_clipin3.wav", // Clip in 3
   "weapons/at4_draw.wav"  // Draw
}
 
public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
    
   register_event("CurWeapon", "event_curweapon", "be", "1=1")
   register_event("HLTV", "event_newround", "a", "1=0", "2=0")
    
   register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
   register_forward(FM_CmdStart, "fw_CmdStart")
   register_forward(FM_SetModel, "fw_SetModel")
    
   register_think("at4ex_rocket", "fw_rocket_think")
   register_touch("at4ex_rocket", "*", "fw_rocket_touch")
    
   RegisterHam(Ham_Weapon_Reload, weapon_at4cs, "fw_WeaponReload")
   RegisterHam(Ham_Item_AddToPlayer, weapon_at4cs, "fw_AddToPlayer", 1)
    
   cvar_radius = register_cvar("zp_at4cs_radius", "300.0")
   cvar_maxdamage = register_cvar("zp_at4cs_maxdamage", "650.0")
    
   g_at4cs = zp_register_extra_item("AT4CS", 38, ZP_TEAM_HUMAN)
    
   register_clcmd("weapon_at4cs", "hook_weapon")
}
 
public hook_weapon(id)
{
   engclient_cmd(id, weapon_at4cs)
   return PLUGIN_HANDLED
}
 
public plugin_precache()
{
   engfunc(EngFunc_PrecacheModel, v_model)
   engfunc(EngFunc_PrecacheModel, p_model)
   engfunc(EngFunc_PrecacheModel, w_model)
   engfunc(EngFunc_PrecacheModel, s_model)
    
   engfunc(EngFunc_PrecacheGeneric, "sprites/weapon_at4cs.txt")
   engfunc(EngFunc_PrecacheGeneric, "sprites/at4cs.spr")   
    
   g_smoke_id = engfunc(EngFunc_PrecacheModel, "sprites/effects/rainsplash.spr")
   g_spr_trail = engfunc(EngFunc_PrecacheModel,"sprites/xbeam3.spr")
   g_spr_exp = engfunc(EngFunc_PrecacheModel,"sprites/zerogxplode.spr")
    
   for(new i = 0; i < sizeof(at4cs_sound); i++)
      engfunc(EngFunc_PrecacheSound, at4cs_sound[i])
}
 
public zp_extra_item_selected(id, itemid)
{
   if(itemid != g_at4cs)
      return PLUGIN_HANDLED
      
   g_had_at4cs[id] = 1
   is_reloading[id] = 0
   g_aiming[id] = 0
    
   fm_give_item(id, weapon_at4cs)
    
   static at4cs
   at4cs = fm_get_user_weapon_entity(id, CSW_AT4CS)
 
   cs_set_weapon_ammo(at4cs, 1)
   cs_set_user_bpammo(id, CSW_AT4CS, 10)
    
   return PLUGIN_CONTINUE
}
 
public zp_user_infected_post(id)
{
   g_had_at4cs[id] = 0
   is_reloading[id] = 0
   g_aiming[id] = 0
    
   remove_task(id+TASK_CHECKRELOAD)
   remove_task(id+TASK_RELOAD)   
}
 
public zp_user_humanized_post(id)
{
   g_had_at4cs[id] = 0
   is_reloading[id] = 0
   g_aiming[id] = 0 
    
   remove_task(id+TASK_CHECKRELOAD)
   remove_task(id+TASK_RELOAD)     
}
 
public event_newround()
{
   remove_entity_name("at4ex_rocket")
    
   for(new i = 0; i < get_maxplayers(); i++)
   {
      if(is_user_alive(i) && is_user_connected(i))
      {
         remove_task(i+TASK_CHECKRELOAD)
         remove_task(i+TASK_RELOAD)   
      }
   }
}
 
public event_curweapon(id)
{
   if(!is_user_alive(id) || !is_user_connected(id))
      return PLUGIN_HANDLED
      
   if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
      return PLUGIN_HANDLED
    
   if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
      return PLUGIN_HANDLED
      
   set_pev(id, pev_viewmodel2, v_model)
   set_pev(id, pev_weaponmodel2, p_model)
    
   return PLUGIN_CONTINUE
}
 
public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
{
   if(!is_user_alive(id) || !is_user_connected(id))
      return FMRES_IGNORED
      
   if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
      return FMRES_IGNORED
      
   if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
      return FMRES_IGNORED
      
   set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001) 
 
   return FMRES_HANDLED
}
 
public fw_AddToPlayer(ent, id)
{
   if(!is_valid_ent(ent) || !is_user_alive(id))
      return HAM_IGNORED
      
   if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
      return HAM_IGNORED
      
   if(entity_get_int(ent, EV_INT_impulse) == 61296)
   {
      g_had_at4cs[id] = 1
      entity_set_int(id, EV_INT_impulse, 0)
      
      return HAM_HANDLED
   }     
 
   if(g_had_at4cs[id])
   {
      message_begin(MSG_ONE, get_user_msgid("WeaponList"), _, id)
      write_string("weapon_at4cs");    // WeaponName
      write_byte(3)                  // PrimaryAmmoID
      write_byte(1)                  // PrimaryAmmoMaxAmount
      write_byte(-1)                   // SecondaryAmmoID
      write_byte(-1)                   // SecondaryAmmoMaxAmount
      write_byte(0)                    // SlotID (0...N)
      write_byte(4)                    // NumberInSlot (1...N)
      write_byte(CSW_AT4CS)            // WeaponID
      write_byte(0)                   // Flags
      message_end()
   }
    
   return HAM_HANDLED   
}
 
public fw_CmdStart(id, uc_handle, seed)
{
   if(!is_user_alive(id) || !is_user_connected(id))
      return FMRES_IGNORED
 
   if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
      return FMRES_IGNORED
      
   if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
      return FMRES_IGNORED
      
   static CurButton
   CurButton = get_uc(uc_handle, UC_Buttons)
    
   if(CurButton & IN_ATTACK)
   {
      static Float:CurTime
      CurTime = get_gametime()
      
      static at4cs
      at4cs = fm_find_ent_by_owner(-1, weapon_at4cs, id)     
      
      if(cs_get_weapon_ammo(at4cs) > 0 && !is_reloading[id])
      {
         if(CurTime - 4.5 > g_lastfire[id])
         {
            set_weapon_anim(id, 1)
            emit_sound(id, CHAN_WEAPON, at4cs_sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
            
            create_rocket(id)
            
            static Float:Punch_Angles[3]
            
            Punch_Angles[0] = -20.0
            Punch_Angles[1] = 0.0
            Punch_Angles[2] = 0.0
            
            set_pev(id, pev_punchangle, Punch_Angles)
            cs_set_weapon_ammo(at4cs, cs_get_weapon_ammo(at4cs) - 1)
            
            if(cs_get_weapon_ammo(at4cs) <= 0 && !is_reloading[id])
            {
               if(cs_get_user_bpammo(id, CSW_AT4CS) > 0)
               {
                  set_task(1.0, "at4cs_reload", id)
               }
            }
            
            if(cs_get_user_zoom(id))
               cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
            
            g_lastfire[id] = CurTime
         }
      } else {
         if(!is_reloading[id])
         {
            if(cs_get_user_bpammo(id, CSW_AT4CS) > 0)
            {
               if(CurTime - 1.0 > g_lastfire[id])
               {
                  at4cs_reload(id)
                  g_lastfire[id] = CurTime
               }
            }
         }
      }
   }
    
   if(CurButton & IN_ATTACK2)
   {
      static Float:CurTime
      CurTime = get_gametime()
      
      if((CurTime - 0.5 > g_lastaim[id]) && !is_reloading[id])
      {
         if(!g_aiming[id])
         {
            cs_set_user_zoom(id, CS_SET_FIRST_ZOOM, 1)
            g_aiming[id] = 1
         } else {
            cs_set_user_zoom(id, CS_RESET_ZOOM, 1)
            g_aiming[id] = 0
         }
          
         g_lastaim[id] = CurTime
      }
   }
    
   CurButton &= ~IN_ATTACK
   set_uc(uc_handle, UC_Buttons, CurButton)
    
   CurButton &= ~IN_RELOAD
   set_uc(uc_handle, UC_Buttons, CurButton)
 
   return FMRES_HANDLED
}
 
public fw_SetModel(ent, const model[])
{
   if(!is_valid_ent(ent))
      return FMRES_IGNORED
    
   static szClassName[33]
   entity_get_string(ent, EV_SZ_classname, szClassName, charsmax(szClassName))
    
   if(!equal(szClassName, "weaponbox"))
      return FMRES_IGNORED
    
   static iOwner
   iOwner = entity_get_edict(ent, EV_ENT_owner)
    
   if(equal(model, "models/w_m249.mdl"))
   {
      static at4cs
      at4cs = find_ent_by_owner(-1, "weapon_m249", ent)
      
      if(!is_valid_ent(at4cs))
         return FMRES_IGNORED;
      
      if(g_had_at4cs[iOwner])
      {
         entity_set_int(at4cs, EV_INT_impulse, 61296)
         g_had_at4cs[iOwner] = 0
         entity_set_model(ent, w_model)
          
         return FMRES_SUPERCEDE
      }
   }
    
   return FMRES_IGNORED
}
 
public at4cs_reload(id)
{
   if(is_reloading[id])
      return
    
   is_reloading[id] = 1
   set_weapon_anim(id, 3)
    
   set_task(0.1, "checking_reload", id+TASK_CHECKRELOAD, _, _, "b")
   set_task(4.0, "reload_complete", id+TASK_RELOAD)
}
 
public checking_reload(id)
{
   id -= TASK_CHECKRELOAD
    
   if(cs_get_user_zoom(id))
      cs_set_user_zoom(id, CS_RESET_ZOOM, 1)   
    
   if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
   {
      remove_task(id+TASK_CHECKRELOAD)
      remove_task(id+TASK_RELOAD)
      
      is_reloading[id] = 0
   }
}
 
public reload_complete(id)
{
   id -= TASK_RELOAD
    
   if(!is_reloading[id])
      return
      
   remove_task(id+TASK_CHECKRELOAD)   
      
   static at4cs
   at4cs = fm_find_ent_by_owner(-1, weapon_at4cs, id)   
    
   cs_set_weapon_ammo(at4cs, 1)
   cs_set_user_bpammo(id, CSW_AT4CS, cs_get_user_bpammo(id, CSW_AT4CS) - 1)
   is_reloading[id] = 0
}
 
public fw_WeaponReload(ent)
{
   static id
   id = pev(ent, pev_owner)
    
   if(!is_user_alive(id) || !is_user_connected(id))
      return HAM_IGNORED
      
   if(get_user_weapon(id) != CSW_AT4CS || !g_had_at4cs[id])
      return HAM_IGNORED
      
   if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
      return HAM_IGNORED   
      
   static Float:CurTime
   CurTime = get_gametime()     
      
   if(!is_reloading[id])
   {
      if(cs_get_user_bpammo(id, CSW_AT4CS) > 0)
      {
         if(CurTime - 1.0 > g_lastfire[id])
         {
            at4cs_reload(id)
            g_lastfire[id] = CurTime
         }
      }
   }   
      
   return HAM_SUPERCEDE
}
 
public create_rocket(id)
{
   new ent, Float:Origin[3], Float:Angles[3], Float:Velocity[3]
    
   ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
   engfunc(EngFunc_GetAttachment, id, 0, Origin, Angles)
   pev(id, pev_angles, Angles)
    
   set_pev(ent, pev_origin, Origin)
   set_pev(ent, pev_angles, Angles)
   set_pev(ent, pev_solid, 2)
   set_pev(ent, pev_movetype, 5)
   set_pev(ent, pev_classname, "at4ex_rocket")
   set_pev(ent, pev_owner, id)
   engfunc(EngFunc_SetModel, ent, s_model)
    
   set_pev(ent, pev_mins, {-1.0, -1.0, -1.0})
   set_pev(ent, pev_maxs, {1.0, 1.0, 1.0})
    
   velocity_by_aim(id, 1750, Velocity)
   set_pev(ent, pev_velocity, Velocity)
    
   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
   write_byte(TE_BEAMFOLLOW) // TE id
   write_short(ent) // entity:attachment to follow
   write_short(g_spr_trail) // sprite index
   write_byte(25) // life in 0.1's
   write_byte(2) // line width in 0.1's
   write_byte(255) // r
   write_byte(255) // g
   write_byte(255) // b
   write_byte(200) // brightness
   message_end()   
    
   set_pev(ent, pev_iuser4, 0)
   set_pev(ent, pev_nextthink, halflife_time() + 0.1)
}
 
public fw_rocket_think(ent)
{
   if(!pev_valid(ent))
      return
 
   static Float:Origin[3]
   pev(ent, pev_origin, Origin)
      
   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
   write_byte(TE_SPRITE)
   engfunc(EngFunc_WriteCoord, Origin[0])
   engfunc(EngFunc_WriteCoord, Origin[1])
   engfunc(EngFunc_WriteCoord, Origin[2])
   write_short(g_smoke_id)
   write_byte(2)
   write_byte(200)
   message_end()
    
   if(pev(ent, pev_iuser4) == 0)
   {
      static Victim
      Victim = FindClosesEnemy(ent)
      
      if(is_user_alive(Victim))
      {
         set_pev(ent, pev_iuser4, Victim)
      }
   } else {
      static Victim
      Victim = pev(ent, pev_iuser4)
      
      if(is_user_alive(Victim))
      {
         static Float:VicOrigin[3]
         pev(Victim, pev_origin, VicOrigin)
          
         turn_to_target(ent, Origin, Victim, VicOrigin)
         hook_ent(ent, Victim, 500.0)
      } else {
         set_pev(ent, pev_iuser4, 0)
      }
   }
      
   set_pev(ent, pev_nextthink, halflife_time() + 0.075)
}
 
public fw_rocket_touch(rocket, touch)
{
   if(!pev_valid(rocket))
      return 
      
   if(is_user_alive(touch) && pev(rocket, pev_owner) == touch)
      return
      
   static Float:Origin[3]
   pev(rocket, pev_origin, Origin)     
      
   message_begin(MSG_BROADCAST ,SVC_TEMPENTITY)
   write_byte(TE_EXPLOSION)
   engfunc(EngFunc_WriteCoord, Origin[0])
   engfunc(EngFunc_WriteCoord, Origin[1])
   engfunc(EngFunc_WriteCoord, Origin[2])
   write_short(g_spr_exp)   // sprite index
   write_byte(20)   // scale in 0.1's
   write_byte(30)   // framerate
   write_byte(0)   // flags
   message_end()
    
   static owner, iVictim
    
   iVictim = -1
   owner = pev(rocket, pev_owner)   
 
   while((iVictim = find_ent_in_sphere(iVictim, Origin, get_pcvar_float(cvar_radius))) != 0)
   {
      if((0 < iVictim < 32) && is_user_alive(iVictim)
      && iVictim != owner && zp_get_user_zombie(iVictim))
      {
         new Float:MaxDamage, Float:Damage
          
         MaxDamage = get_pcvar_float(cvar_maxdamage)
         Damage = random_float(MaxDamage - random_float(0.0, 100.0), MaxDamage + random_float(0.0, 100.0))
          
         ExecuteHam(Ham_TakeDamage, iVictim, 0, owner, 0, DMG_BULLET)
          
         static health
         health = get_user_health(iVictim)
            
         if(health - Damage >= 1)
         {
            fm_set_user_health(iVictim, health - floatround(Damage))
         }
         else
         {
            death_message(owner, iVictim, 1)
         }         
      }
   }   
    
   engfunc(EngFunc_RemoveEntity, rocket)
}
 
stock set_weapon_anim(id, anim)
{
   set_pev(id, pev_weaponanim, anim)
 
   message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
   write_byte(anim)
   write_byte(pev(id,pev_body))
   message_end()
}
 
stock death_message(Killer, Victim, ScoreBoard)
{
   // Block death msg
   set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
   ExecuteHamB(Ham_Killed, Victim, Killer, 2)
   set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
    
   // Death
   make_deathmsg(Killer, Victim, 0, "")
 
   // Update score board
   if (ScoreBoard)
   {
      message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
      write_byte(Killer) // id
      write_short(pev(Killer, pev_frags)) // frags
      write_short(cs_get_user_deaths(Killer)) // deaths
      write_short(0) // class?
      write_short(get_user_team(Killer)) // team
      message_end()
      
      message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
      write_byte(Victim) // id
      write_short(pev(Victim, pev_frags)) // frags
      write_short(cs_get_user_deaths(Victim)) // deaths
      write_short(0) // class?
      write_short(get_user_team(Victim)) // team
      message_end()
   }
}
 
stock FindClosesEnemy(entid)
{
   new Float:Dist
   new Float:maxdistance=300.0
   new indexid=0 
   for(new i=1;i<=get_maxplayers();i++){
      if(is_user_alive(i) && is_valid_ent(i) && can_see_fm(entid, i)
      && pev(entid, pev_owner) != i && cs_get_user_team(pev(entid, pev_owner)) != cs_get_user_team(i))
      {
         Dist = entity_range(entid, i)
         if(Dist <= maxdistance)
         {
            maxdistance=Dist
            indexid=i
            
            return indexid
         }
      }   
   }   
   return 0
}
 
stock bool:can_see_fm(entindex1, entindex2)
{
   if (!entindex1 || !entindex2)
      return false
 
   if (pev_valid(entindex1) && pev_valid(entindex1))
   {
      new flags = pev(entindex1, pev_flags)
      if (flags & EF_NODRAW || flags & FL_NOTARGET)
      {
         return false
      }
 
      new Float:lookerOrig[3]
      new Float:targetBaseOrig[3]
      new Float:targetOrig[3]
      new Float:temp[3]
 
      pev(entindex1, pev_origin, lookerOrig)
      pev(entindex1, pev_view_ofs, temp)
      lookerOrig[0] += temp[0]
      lookerOrig[1] += temp[1]
      lookerOrig[2] += temp[2]
 
      pev(entindex2, pev_origin, targetBaseOrig)
      pev(entindex2, pev_view_ofs, temp)
      targetOrig[0] = targetBaseOrig [0] + temp[0]
      targetOrig[1] = targetBaseOrig [1] + temp[1]
      targetOrig[2] = targetBaseOrig [2] + temp[2]
 
      engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the had of seen player
      if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
      {
         return false
      }
      else
      {
         new Float:flFraction
         get_tr2(0, TraceResult:TR_flFraction, flFraction)
         if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
         {
            return true
         }
         else
         {
            targetOrig[0] = targetBaseOrig [0]
            targetOrig[1] = targetBaseOrig [1]
            targetOrig[2] = targetBaseOrig [2]
            engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the body of seen player
            get_tr2(0, TraceResult:TR_flFraction, flFraction)
            if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
            {
               return true
            }
            else
            {
               targetOrig[0] = targetBaseOrig [0]
               targetOrig[1] = targetBaseOrig [1]
               targetOrig[2] = targetBaseOrig [2] - 17.0
               engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) //  checks the legs of seen player
               get_tr2(0, TraceResult:TR_flFraction, flFraction)
               if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
               {
                  return true
               }
            }
         }
      }
   }
   return false
}
 
stock turn_to_target(ent, Float:Ent_Origin[3], target, Float:Vic_Origin[3])
{
   if(target)
   {
      new Float:newAngle[3]
      entity_get_vector(ent, EV_VEC_angles, newAngle)
      new Float:x = Vic_Origin[0] - Ent_Origin[0]
      new Float:z = Vic_Origin[1] - Ent_Origin[1]
 
      new Float:radians = floatatan(z/x, radian)
      newAngle[1] = radians * (180 / 3.14)
      if (Vic_Origin[0] < Ent_Origin[0])
         newAngle[1] -= 180.0
        
      entity_set_vector(ent, EV_VEC_angles, newAngle)
   }
}
 
stock hook_ent(ent, victim, Float:speed)
{
   static Float:fl_Velocity[3]
   static Float:VicOrigin[3], Float:EntOrigin[3]
 
   pev(ent, pev_origin, EntOrigin)
   pev(victim, pev_origin, VicOrigin)
    
   static Float:distance_f
   distance_f = get_distance_f(EntOrigin, VicOrigin)
 
   if (distance_f > 10.0)
   {
      new Float:fl_Time = distance_f / speed
 
      fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
      fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
      fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
   } else
   {
      fl_Velocity[0] = 0.0
      fl_Velocity[1] = 0.0
      fl_Velocity[2] = 0.0
   }
 
   entity_set_vector(ent, EV_VEC_velocity, fl_Velocity)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1066\\ f0\\ fs16 \n\\ par }
*/
banchee:
Код:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>
 
#define PLUGIN "DJB Zombie Class Banchee"
#define VERSION "1.0.3"
#define AUTHOR "Csoldjb&wbyokomo"
#define ANIMATION_WITCH        "skill1_loop"     // Анимация платья
#define ANIMATION_WITCH_2      "ref_shoot_grenade"
#define linux_diff_weapon 4
#define linux_diff_player 5
 
new const zclass_name[] = "\wВедьма"
new const zclass_info[] = "\y[G|T]"
new const zclass_model[] = "witch_zombi_xman"
new const zclass_clawmodel[] = "v_knife_witch_zombi.mdl"
const zclass_health = 2600
const zclass_speed = 260
const Float:zclass_gravity = 0.81
const Float:zclass_knockback = 1.0
 
new const g_witch_Infect_Sound[][] =     
{   
    "warcraft3/zombie/witch/infect_01.wav" ,
    "warcraft3/zombie/witch/infect_02.wav"
}
new const pain_witch_sound[] = "warcraft3/zombie/witch/pain.wav"
new const death_witch_sound[] = "warcraft3/zombie/witch/die.wav"
 
new const SOUND_FIRE[] = "zombie_plague/zombi_banshee_pulling_fire.wav"
new const SOUND_BAT_HIT[] = "zombie_plague/zombi_banshee_laugh.wav"
new const SOUND_BAT_MISS[] = "zombie_plague/zombi_banshee_pulling_fail.wav"
new const SOUND_FIRE_CONFUSION[] = "zombie_plague/zombi_banshee_confusion_fire.wav"
new const SOUND_CONFUSION_HIT[] = "zombie_plague/zombi_banshee_confusion_keep.wav"
new const SOUND_CONFUSION_EXP[] = "zombie_plague/zombi_banshee_confusion_explosion.wav"
new const MODEL_BAT[] = "models/zombie_plague/bat_witch.mdl"
new const MODEL_BOMB[] = "models/zombie_plague/w_zombibomb.mdl"
new const BAT_CLASSNAME[] = "banchee_bat"
new const CONFUSION_CLASSNAME[] = "banchee_bomb"
new const FAKE_PLAYER_CLASSNAME[] = "fake_player"
new spr_skull, spr_confusion_exp, spr_confusion_icon, spr_confusion_trail
 
const Float:banchee_skull_bat_speed = 700.0
const Float:banchee_skull_bat_flytime = 3.5
const Float:banchee_skull_bat_catch_time = 4.5
const Float:banchee_skull_bat_catch_speed = 375.0
const Float:bat_timewait = 15.0
const Float:confusion_time = 12.0
 
new g_stop[33]
new g_bat_time[33]
new g_bat_stat[33]
new g_bat_enemy[33]
new Float:g_temp_speed[33]
new g_cooldown[33]
new g_owner_confusion[33]
new g_fake_ent[33]
new g_is_confusion[33]
 
new idclass_banchee
new g_maxplayers
new g_roundend
new g_msgSayText, g_msgScreenFade, g_msgScreenShake
new g_MsgSync
 
enum (+= 100)
{
   TASK_BOT_USE_SKILL = 2367,
   TASK_REMOVE_STAT,
   TASK_CONFUSION,
   TASK_SOUND,
   TASK_COOLDOWN,
   TASK_ABILITY
}
 
#define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)
#define ID_TASK_REMOVE_STAT (taskid - TASK_REMOVE_STAT)
#define ID_CONFUSION (taskid - TASK_CONFUSION)
#define ID_SOUND (taskid - TASK_SOUND)
 
const UNIT_SECOND = (1<<12)
const FFADE_IN = 0x0000
 
public plugin_precache()
{
    new i
    for(i = 0 ; i < sizeof g_witch_Infect_Sound ; i++) precache_sound(g_witch_Infect_Sound[i])
   precache_sound(pain_witch_sound[0])
   precache_sound(death_witch_sound[0])
   precache_sound(SOUND_FIRE)
   precache_sound(SOUND_BAT_HIT)
   precache_sound(SOUND_BAT_MISS)
   precache_sound(SOUND_FIRE_CONFUSION)
   precache_sound(SOUND_CONFUSION_HIT)
   precache_sound(SOUND_CONFUSION_EXP)
    
   precache_model(MODEL_BAT)
   precache_model(MODEL_BOMB)
    
   spr_skull = precache_model("sprites/ef_bat.spr")
   spr_confusion_exp = precache_model("sprites/zombiebomb_exp.spr")
   spr_confusion_icon = precache_model("sprites/confused.spr")
   spr_confusion_trail = precache_model("sprites/smoke.spr")
    
   idclass_banchee = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
 
public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
    
   register_event("HLTV", "EventHLTV", "a", "1=0", "2=0")
   register_event("DeathMsg", "EventDeath", "a")
   register_logevent("logevent_round_end", 2, "1=Round_End")
    
   register_impulse(201, "CmdSecondSkill")
    
   register_clcmd("drop", "cmd_bat")
    
   register_forward(FM_PlayerPreThink,"fw_PlayerPreThink")
   register_forward(FM_AddToFullPack, "fw_AddToFullPackPost", 1)
    
   RegisterHam(Ham_Touch,"info_target","EntityTouchPost",1)
   RegisterHam(Ham_Think,"info_target","EntityThink")
   RegisterHam(Ham_TakeDamage, "player", "CPlayer__TakeDamage");
    
   register_forward(FM_EmitSound, "fw_EmitSound");
    
   g_maxplayers = get_maxplayers()
   g_msgSayText = get_user_msgid("SayText")
   g_msgScreenFade = get_user_msgid("ScreenFade")
   g_msgScreenShake = get_user_msgid("ScreenShake")
}
 
public client_putinserver(id)
{
   reset_value_player(id)
}
 
public client_disconnect(id)
{
   reset_value_player(id)
}
 
public EventHLTV()
{
   g_roundend = 0
    
   RemoveAllFakePlayer()
    
   for(new id = 1; id <= g_maxplayers; id++)
   {
      if (!is_user_connected(id)) continue;
      
      remove_task(id+TASK_ABILITY)
       remove_task(id+TASK_COOLDOWN)
      reset_value_player(id)
   }
}
 
public logevent_round_end()
{
   g_roundend = 1
}
 
public EventDeath()
{
   new id = read_data(2)
    
   reset_value_player(id)
}
 
public zp_user_infected_post(id)
{
   reset_value_player(id)
    
   if(zp_get_user_nemesis(id)) return;
    
   if(zp_get_user_zombie_class(id) == idclass_banchee)
   {
       g_cooldown[id] = 0
      set_task(1.0, "Ability", id+TASK_ABILITY, _, _, "b")
    
       emit_sound(id, CHAN_VOICE, g_witch_Infect_Sound[random(sizeof g_witch_Infect_Sound)],  VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    
      if(is_user_bot(id))
      {
         set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
         return
      }
      
      zp_colored_print(id, "^x04[ZP]^x01 Your skill is^x04 Spawn Bat^x01. Cooldown^x04 %.1f ^x01seconds.", bat_timewait)
   }
}
 
public zp_user_humanized_post(id)
{
   reset_value_player(id)
   remove_task(id+TASK_ABILITY)
   remove_task(id+TASK_COOLDOWN)
}
 
public CmdSecondSkill(id)
{
   if(g_roundend) return PLUGIN_CONTINUE
    
   if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE
    
   if(zp_get_user_zombie_class(id) == idclass_banchee && !g_bat_time[id] && !g_cooldown[id])
   {
      g_bat_time[id] = 1
      
      g_cooldown[id] = 15
      set_task(1.0, "RemoveCooldown", id+TASK_COOLDOWN, _, _, "a",g_cooldown[id])
      
      FireConfusion(id)
      PlayWeaponAnimation(id, 7)
      UTIL_PlayerAnimation(id, ANIMATION_WITCH_2, 0.5)
      set_task(bat_timewait,"clear_stat",id+TASK_REMOVE_STAT)
      
      return PLUGIN_HANDLED
   }
 
   return PLUGIN_CONTINUE
}
 
public cmd_bat(id)
{
   if(g_roundend) return PLUGIN_CONTINUE
    
   if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE
    
   if(zp_get_user_zombie_class(id) == idclass_banchee && !g_bat_time[id] && !g_cooldown[id])
   {
      g_bat_time[id] = 1
      
      g_cooldown[id] = 15
      set_task(1.0, "RemoveCooldown", id+TASK_COOLDOWN, _, _, "a",g_cooldown[id])
      
      set_task(bat_timewait,"clear_stat",id+TASK_REMOVE_STAT)
      
      new ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
      
      if(!pev_valid(ent)) return PLUGIN_HANDLED
      
      new Float:vecAngle[3],Float:vecOrigin[3],Float:vecVelocity[3],Float:vecForward[3]
      fm_get_user_startpos(id,5.0,2.0,-1.0,vecOrigin)
      pev(id,pev_angles,vecAngle)
      
      engfunc(EngFunc_MakeVectors,vecAngle)
      global_get(glb_v_forward,vecForward)
      
      velocity_by_aim(id,floatround(banchee_skull_bat_speed),vecVelocity)
      
      set_pev(ent,pev_origin,vecOrigin)
      set_pev(ent,pev_angles,vecAngle)
      set_pev(ent,pev_classname,BAT_CLASSNAME)
      set_pev(ent,pev_movetype,MOVETYPE_FLY)
      set_pev(ent,pev_solid,SOLID_BBOX)
      engfunc(EngFunc_SetSize,ent,{-10.0,-10.0,0.0},{10.0,10.0,6.0})
      
      engfunc(EngFunc_SetModel,ent,MODEL_BAT)
      set_pev(ent,pev_animtime,get_gametime())
      set_pev(ent,pev_framerate,1.0)
      set_pev(ent,pev_owner,id)
      set_pev(ent,pev_velocity,vecVelocity)
      set_pev(ent,pev_nextthink,get_gametime()+banchee_skull_bat_flytime)
      emit_sound(ent, CHAN_WEAPON, SOUND_FIRE, 1.0, ATTN_NORM, 0, PITCH_NORM)
      emit_sound(ent, CHAN_VOICE, SOUND_BAT_HIT, 1.0, ATTN_NORM, 0, PITCH_NORM)
      
      g_stop[id] = ent
      
      pev(id, pev_maxspeed, g_temp_speed[id])
      set_pev(id,pev_maxspeed,0.1)
      PlayWeaponAnimation(id, 2)
      UTIL_PlayerAnimation(id, ANIMATION_WITCH, 0.5)
            pev(id, pev_maxspeed, g_temp_speed[id])
                set_pev(id,pev_maxspeed,0.1)
      
      return PLUGIN_HANDLED
   }
    
   return PLUGIN_CONTINUE
}
 
public Ability(taskid)
{
   new id = taskid - TASK_ABILITY
    
   if(is_user_alive(id))
   {
      if (g_cooldown[id] == 0)
      {
           set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
         ShowSyncHudMsg(id, g_MsgSync, "Летучие мыши - [G]^nСпособность готова!")
      }
   }
   else remove_task(id+TASK_ABILITY)
}
 
public RemoveCooldown(taskid)
{
   new id = taskid - TASK_COOLDOWN
    
   if(is_user_alive(id))
   {
      g_cooldown[id]--
      if (g_cooldown[id] == 0)
      {
          set_task(2.5, "Ability", id+TASK_ABILITY)
         remove_task(id+TASK_COOLDOWN)
      }
      set_hudmessage(200, 100, 0, -1.0, 0.12, 0, 1.0, 1.1, 0.0, 0.0, -1)
      ShowSyncHudMsg(id, g_MsgSync, "Летучие мыши - [G]^nПерезарядка: %d",g_cooldown[id])
   }
   else remove_task(id+TASK_COOLDOWN)
}
 
public fw_PlayerPreThink(id)
{
   if(!is_user_alive(id)) return FMRES_IGNORED
    
   if(g_bat_stat[id])
   {
      new owner = g_bat_enemy[id], Float:ownerorigin[3]
      pev(owner,pev_origin,ownerorigin)
      static Float:vec[3]
      aim_at_origin(id,ownerorigin,vec)
      engfunc(EngFunc_MakeVectors, vec)
      global_get(glb_v_forward, vec)
      vec[0] *= banchee_skull_bat_catch_speed
      vec[1] *= banchee_skull_bat_catch_speed
      vec[2] = 0.0
      set_pev(id,pev_velocity,vec)
   }
   if(g_stop[id]) set_pev(id,pev_maxspeed,0.1)
   return FMRES_IGNORED
}
 
public fw_AddToFullPackPost(es_handled, inte, ent, host, hostflags, player, pSet)
{
   if (!is_user_alive(host)) return FMRES_IGNORED;
    
   static iAttacker
   iAttacker = g_owner_confusion[host]
   if (!iAttacker || iAttacker == host || !is_user_alive(iAttacker)) return FMRES_IGNORED;
      
   if (ent == iAttacker)
   {
      set_es(es_handled, ES_RenderMode, kRenderTransAdd)
      set_es(es_handled, ES_RenderAmt, 0.0)
      
      new fake_ent = find_ent_by_owner(-1, FAKE_PLAYER_CLASSNAME, iAttacker)
      if(!fake_ent || !pev_valid(fake_ent))
      {
         fake_ent = CreateFakePlayer(iAttacker)
      }
          
      g_fake_ent[iAttacker] = fake_ent
   }
   else if (ent == g_fake_ent[iAttacker])
   {
      set_es(es_handled, ES_RenderMode, kRenderNormal)
      set_es(es_handled, ES_RenderAmt, 255.0)
      set_es(es_handled, ES_ModelIndex, pev(host, pev_modelindex))
   }
    
   return FMRES_IGNORED
}
 
public EntityThink(ent)
{
   if(!pev_valid(ent)) return HAM_IGNORED
    
   new classname[32]
   pev(ent,pev_classname,classname,31)
    
   if(equal(classname,BAT_CLASSNAME))
   {
      static Float:origin[3];
      pev(ent,pev_origin,origin);
      
      message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte(TE_EXPLOSION)
      write_coord(floatround(origin[0]))
      write_coord(floatround(origin[1]))
      write_coord(floatround(origin[2]))
      write_short(spr_skull)
      write_byte(40)
      write_byte(30)
      write_byte(14)
      message_end()
      
      emit_sound(ent, CHAN_WEAPON, SOUND_BAT_MISS, 1.0, ATTN_NORM, 0, PITCH_NORM)
      
      new owner = pev(ent, pev_owner)
      g_stop[owner] = 0
      set_pev(owner,pev_maxspeed,g_temp_speed[owner])
      
      engfunc(EngFunc_RemoveEntity,ent)
   }
    
   return HAM_IGNORED
}
 
public EntityTouchPost(ent,ptd)
{
   if(!pev_valid(ent)) return HAM_IGNORED
    
   new classname[32]
   pev(ent,pev_classname,classname,31)
    
   if(equal(classname,BAT_CLASSNAME))
   {
      if(!pev_valid(ptd))
      {
         static Float:origin[3];
         pev(ent,pev_origin,origin);
          
         message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
         write_byte(TE_EXPLOSION)
         write_coord(floatround(origin[0]))
         write_coord(floatround(origin[1]))
         write_coord(floatround(origin[2]))
         write_short(spr_skull)
         write_byte(40)
         write_byte(30)
         write_byte(14)
         message_end()
          
         emit_sound(ent, CHAN_WEAPON, SOUND_BAT_MISS, 1.0, ATTN_NORM, 0, PITCH_NORM)
          
         new owner = pev(ent, pev_owner)
         g_stop[owner] = 0
         set_pev(owner,pev_maxspeed,g_temp_speed[owner])
          
         engfunc(EngFunc_RemoveEntity,ent)
          
         return HAM_IGNORED
      }
      
      new owner = pev(ent,pev_owner)
      
      if(0 < ptd && ptd <= g_maxplayers && is_user_alive(ptd) && ptd != owner)
      {
         g_bat_enemy[ptd] = owner
          
         if(!zp_get_user_zombie(ptd)) (ptd, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 30)
          
         message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, ptd)
         write_short(UNIT_SECOND)
         write_short(0)
         write_short(FFADE_IN)
         write_byte(150)
         write_byte(150)
         write_byte(150)
         write_byte(150)
         message_end()
          
         emit_sound(owner, CHAN_VOICE, SOUND_BAT_HIT, 1.0, ATTN_NORM, 0, PITCH_NORM)
                  
         set_pev(ent,pev_nextthink,get_gametime()+banchee_skull_bat_catch_time)
         set_task(banchee_skull_bat_catch_time,"clear_stat2",ptd+TASK_REMOVE_STAT)
         set_pev(ent,pev_movetype,MOVETYPE_FOLLOW)
         set_pev(ent,pev_aiment,ptd)
          
         g_bat_stat[ptd] = 1
      }
   }
   else if(equal(classname,CONFUSION_CLASSNAME))
   {     
      ConfusionExplode(ent, ptd)
      
      return HAM_IGNORED
   }
    
   return HAM_IGNORED
}
 
public clear_stat(taskid)
{
   new id = ID_TASK_REMOVE_STAT
    
   g_bat_stat[id] = 0
   g_bat_time[id] = 0
    
   zp_colored_print(id, "^x04[ZP]^x01 Ваши способности^x04 'Мыши и Путанница'^x01 готовы!.")
}
 
public clear_stat2(idx)
{
   new id = idx-TASK_REMOVE_STAT
    
   g_bat_enemy[id] = 0
   g_bat_stat[id] = 0
}
 
public bot_use_skill(taskid)
{
   new id = ID_BOT_USE_SKILL
    
   if (!is_user_alive(id)) return;
    
   new skill = random_num(0,1)
   switch(skill)
   {
      case 0: cmd_bat(id)
      case 1: CmdSecondSkill(id)
   }
    
   set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
}
 
public ResetConfusion(taskid)
{
   g_owner_confusion[ID_CONFUSION] = 0
   g_is_confusion[ID_CONFUSION] = 0
    
   RemoveConfusionSprites(ID_CONFUSION)
}
 
public TaskConfusionSound(taskid)
{
   if(g_is_confusion[ID_SOUND]) emit_sound(ID_SOUND, CHAN_STREAM, SOUND_CONFUSION_HIT, 1.0, ATTN_NORM, 0, PITCH_NORM);
   else remove_task(taskid)
}
 
FireConfusion(id)
{
   new Float:vecAngle[3],Float:vecOrigin[3],Float:vecVelocity[3],Float:vecForward[3]
   new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
   fm_get_user_startpos(id,5.0,2.0,-1.0,vecOrigin)
   pev(id,pev_angles,vecAngle)
   engfunc(EngFunc_MakeVectors,vecAngle)
   global_get(glb_v_forward,vecForward)
   velocity_by_aim(id,800,vecVelocity)
   set_pev(ent,pev_origin,vecOrigin)
   set_pev(ent,pev_angles,vecAngle)
   set_pev(ent,pev_classname,CONFUSION_CLASSNAME)
   set_pev(ent,pev_movetype,MOVETYPE_BOUNCE)
   set_pev(ent,pev_solid,SOLID_BBOX)
   set_pev(ent,pev_gravity,1.0)
   set_pev(ent,pev_sequence,1) //add
   set_pev(ent,pev_animtime,get_gametime()) //add
   set_pev(ent,pev_framerate,1.0) //add
   engfunc(EngFunc_SetSize,ent,{-1.0,-1.0,-1.0},{1.0,1.0,1.0})
   engfunc(EngFunc_SetModel,ent,MODEL_BOMB)
   set_pev(ent,pev_owner,id)
   set_pev(ent,pev_velocity,vecVelocity)
    
   message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
   write_byte(TE_BEAMFOLLOW)
   write_short(ent)
   write_short(spr_confusion_trail)
   write_byte(5)
   write_byte(3)
   write_byte(189)
   write_byte(183)
   write_byte(107)
   write_byte(62)
   message_end()
    
   emit_sound(ent, CHAN_WEAPON, SOUND_FIRE_CONFUSION, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
 
ConfusionExplode(ent, victim)
{
   if(!pev_valid(ent)) return;
    
   static Float:Origin[3]
   pev(ent, pev_origin, Origin)
    
   message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
   write_byte(TE_EXPLOSION)
   write_coord(floatround(Origin[0]))
   write_coord(floatround(Origin[1]))
   write_coord(floatround(Origin[2]))
   write_short(spr_confusion_exp)
   write_byte(40)
   write_byte(30)
   write_byte(14)
   message_end()
      
   emit_sound(ent, CHAN_WEAPON, SOUND_CONFUSION_EXP, 1.0, ATTN_NORM, 0, PITCH_NORM)
    
   static owner; owner = pev(ent, pev_owner)
    
   if(is_user_alive(victim) && !zp_get_user_zombie(victim) && !g_is_confusion[victim])
   {
      g_owner_confusion[victim] = owner
      g_is_confusion[victim] = 1
      
      message_begin(MSG_ONE, g_msgScreenFade, _, victim)
      write_short(UNIT_SECOND)
      write_short(0)
      write_short(FFADE_IN)
      write_byte(189)
      write_byte(183)
      write_byte(107)
      write_byte (255)
      message_end()
 
      new shake[3]
      shake[0] = random_num(2,20)
      shake[1] = random_num(2,5)
      shake[2] = random_num(2,20)
      message_begin(MSG_ONE, g_msgScreenShake, _, victim)
      write_short(UNIT_SECOND*shake[0])
      write_short(UNIT_SECOND*shake[1])
      write_short(UNIT_SECOND*shake[2])
      message_end()
      
      emit_sound(victim, CHAN_STREAM, SOUND_CONFUSION_HIT, 1.0, ATTN_NORM, 0, PITCH_NORM)
      CreateConfusionSprites(victim)
      
      set_task(confusion_time, "ResetConfusion", victim+TASK_CONFUSION)
      set_task(2.0, "TaskConfusionSound", victim+TASK_SOUND, _, _, "b")
   }
    
   engfunc(EngFunc_RemoveEntity,ent)
}
 
fm_get_user_startpos(id,Float:forw,Float:right,Float:up,Float:vStart[])
{
   new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
   pev(id, pev_origin, vOrigin)
   pev(id, pev_v_angle, vAngle)
    
   engfunc(EngFunc_MakeVectors, vAngle)
    
   global_get(glb_v_forward, vForward)
   global_get(glb_v_right, vRight)
   global_get(glb_v_up, vUp)
    
   vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
   vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
   vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
}
 
aim_at_origin(id, Float:target[3], Float:angles[3])
{
   static Float:vec[3]
   pev(id,pev_origin,vec)
   vec[0] = target[0] - vec[0]
   vec[1] = target[1] - vec[1]
   vec[2] = target[2] - vec[2]
   engfunc(EngFunc_VecToAngles,vec,angles)
   angles[0] *= -1.0
   angles[2] = 0.0
}
 
PlayWeaponAnimation(id, animation)
{
   set_pev(id, pev_weaponanim, animation)
   message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id)
   write_byte(animation)
   write_byte(pev(id, pev_body))
   message_end()
}
 
CreateFakePlayer(id)
{
   new ent = create_entity("info_target")
   set_pev(ent, pev_classname, FAKE_PLAYER_CLASSNAME)
   set_pev(ent, pev_modelindex, pev(id, pev_modelindex))
   set_pev(ent, pev_movetype, MOVETYPE_FOLLOW)
   set_pev(ent, pev_solid, SOLID_NOT)
   set_pev(ent, pev_aiment, id)
   set_pev(ent, pev_owner, id)
   set_pev(ent, pev_rendermode, kRenderTransAdd)
   set_pev(ent, pev_renderamt, 0.0)
 
   return ent
}
 
CreateConfusionSprites(id)
{
   message_begin(MSG_ALL, SVC_TEMPENTITY)
   write_byte(TE_PLAYERATTACHMENT)
   write_byte(id)
   write_coord(35)
   write_short(spr_confusion_icon)
   write_short(999)
   message_end()
}
 
RemoveConfusionSprites(id)
{
   message_begin(MSG_ALL, SVC_TEMPENTITY)
   write_byte(TE_KILLPLAYERATTACHMENTS)
   write_byte(id)
   message_end()
}
 
RemoveAllFakePlayer()
{   
   new ent
   ent = find_ent_by_class(-1, FAKE_PLAYER_CLASSNAME)
    
   while(ent > 0)
   {
      remove_entity(ent)
      ent = find_ent_by_class(-1, FAKE_PLAYER_CLASSNAME)
   }
}
 
reset_value_player(id)
{
   if(g_is_confusion[id]) RemoveConfusionSprites(id);
    
   g_stop[id] = 0
   g_bat_time[id] = 0
   g_bat_stat[id] = 0
   g_bat_enemy[id] = 0
   g_cooldown[id] = 0
   g_owner_confusion[id] = 0
   g_fake_ent[id] = 0
   g_is_confusion[id] = 0
    
   remove_task(id+TASK_BOT_USE_SKILL)
   remove_task(id+TASK_REMOVE_STAT)
   remove_task(id+TASK_CONFUSION)
   remove_task(id+TASK_SOUND)
}
 
zp_colored_print(target, const message[], any:...)
{
   static buffer[512], i, argscount
   argscount = numargs()
    
   if (!target)
   {
      static player
      for (player = 1; player <= g_maxplayers; player++)
      {
         if (!is_user_connected(player))
            continue;
          
         static changed[5], changedcount
         changedcount = 0
          
         for (i = 2; i < argscount; i++)
         {
            if (getarg(i) == LANG_PLAYER)
            {
               setarg(i, 0, player)
               changed[changedcount] = i
               changedcount++
            }
         }
          
         vformat(buffer, charsmax(buffer), message, 3)
          
         message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
         write_byte(player)
         write_string(buffer)
         message_end()
          
         for (i = 0; i < changedcount; i++)
            setarg(changed[i], 0, LANG_PLAYER)
      }
   }
   else
   {
      vformat(buffer, charsmax(buffer), message, 3)
      
      message_begin(MSG_ONE, g_msgSayText, _, target)
      write_byte(target)
      write_string(buffer)
      message_end()
   }
    
}
 
public CPlayer__TakeDamage(id, iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamage)
{
    if (zp_get_user_zombie_class(id) == idclass_banchee && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && !zp_get_user_survivor(id))
   {
   emit_sound(id, CHAN_WEAPON, pain_witch_sound[0], 1.0, ATTN_NORM, 0, PITCH_LOW)
   }
}
 
public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
{
   if(!is_user_connected(id))
      return FMRES_HANDLED;
 
   if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
      return FMRES_SUPERCEDE;
 
 
   if(zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == idclass_banchee && !zp_get_user_nemesis(id))
   {
      if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
      {
      emit_sound(id, CHAN_WEAPON, death_witch_sound[0], 1.0, ATTN_NORM, 0, PITCH_LOW)
      }
   }
   return FMRES_IGNORED;
}
 
stock UTIL_PlayerAnimation(const iPlayer, const szAnim[], Float: flFramerate)
{
   new iAnimDesired, Float: flFrameRate, Float: flGroundSpeed, bool: bLoops;
        
   if((iAnimDesired = lookup_sequence(iPlayer, szAnim, flFrameRate, bLoops, flGroundSpeed)) == -1) iAnimDesired = 0;
  
   set_pev(iPlayer, pev_frame, 0.0);
   set_pev(iPlayer, pev_framerate, flFramerate);
   set_pev(iPlayer, pev_animtime, get_gametime());
   set_pev(iPlayer, pev_sequence, iAnimDesired);
      
   set_pdata_int(iPlayer, 40, bLoops, linux_diff_weapon);
   set_pdata_int(iPlayer, 39, 0, linux_diff_weapon);
      
   set_pdata_float(iPlayer, 36, flFrameRate, linux_diff_weapon);
   set_pdata_float(iPlayer, 37, flGroundSpeed, linux_diff_weapon);
   set_pdata_float(iPlayer, 38, get_gametime(), linux_diff_weapon);
      
   set_pdata_int(iPlayer, 73, 28, linux_diff_player);
   set_pdata_int(iPlayer, 74, 28, linux_diff_player);
   set_pdata_float(iPlayer, 220, get_gametime(), linux_diff_player);
}
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу