/*
[ZP] FROST AWP.
Это полностью переделаный плагин M4A1 FROST Под Авп
Автор: Deprkid
Что будет добавлено в будущем:
* Личная иконка оружия
* Исрпавлен трейсер пули (голубой след после выстрела)
* Эффект убийства? (куски)
* Прицел как в m95 tiger
Возможности:
* Выдача оружие через консоль командой frosta
* Удобная выдача оружие через натив
* Если что-то будет не работать пишите помогу ВК: vk.com/daynkid83yo
* вы это прочли? можете стереть все что сверху
*/
#include <amxmodx>
#include <zombieplague>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <fun>
#if AMXX_VERSION_NUM < 183
#include <dhudmessage>
#endif
#define write_coord_fl(%1) engfunc(EngFunc_WriteCoord, %1)
#define message_begin_fl(%1,%2,%3,%4) engfunc(EngFunc_MessageBegin, %1, %2, %3, %4)
new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
new const V_AWP_MODEL[] = "models/deprkid/v_frostawpq.mdl"
new const P_AWP_MODEL[] = "models/deprkid/p_frostawpq.mdl"
new const W_AWP_MODEL[] = "models/deprkid/w_frostawp.mdl"
new const W_OLD_AWP_MODEL[] = "models/w_awp.mdl"
new const ICE_MODEL[] = "models/deprkid/icecube_frozen.mdl"
new const MODEL_GLASSGIBS[] = "models/glassgibs.mdl"
new const SOUND_UNFROZEN[] = "debris/glass3.wav"
new const WEAPON_NAME[] = "Frost AWP" // Название оружие в магазине
const WEAPON_COST = 0 // Цена оружия в магазине
new const WEAPON_NATIVE[] = "zp_give_user_frostawp"; // Натив на выдачу оружия
enum _:Sprites
{
SPRITE_FROST,
SPRITE_FROST2,
SPRITE_FLAKE
}
new g_iSprites[Sprites]
new g_iItemID, g_iAWPFrostSpr, g_iMsgScreenFade, g_iMaxPlayers, g_iHudSync, g_iSpriteLaser, g_iGlassGibs, g_iFreezeDmg, g_fFrostTime, g_iDmgMultiplier, g_iStatusIcon
new bool:g_bHasFrostAWP[33], g_bIsFrozen[33]
new g_iDmg[33]
public plugin_init()
{
register_plugin("[ZP] Extra Item: Frost AWP", "1.1", "deprkid")
// Cvars
g_fFrostTime = register_cvar("zp_frost_awp_time", "2.0") // Freeze Time. It's Float you can make it 0.5
g_iFreezeDmg = register_cvar("zp_freezing_awp_damage", "15000") // Damage Requried So Zombie got Frozen
g_iDmgMultiplier = register_cvar("zp_multiplier_awp_damage", "25") // Multiplie Weapon Damage
// Message IDS
g_iHudSync = CreateHudSyncObj()
g_iMsgScreenFade = get_user_msgid("ScreenFade")
g_iStatusIcon = get_user_msgid("StatusIcon")
// Server Max Slots
g_iMaxPlayers = get_maxplayers()
g_iItemID = zp_register_extra_item(WEAPON_NAME, WEAPON_COST, ZP_TEAM_HUMAN); // Закоментируйте если не надо чтобы AWP продавалось в магазине
// Events
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_event("WeapPickup","CheckModel","b","1=19")
register_event("CurWeapon","CurrentWeapon","be","1=1")
register_event("DeathMsg", "EventDeathMsg", "a")
// Forwards
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_SetModel, "fw_SetModel")
// Hams
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHam(Ham_TraceAttack, "player", "TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "worldspawn", "TraceAttack", 1)
RegisterHam(Ham_Item_AddToPlayer, "weapon_awp", "fw_FrostAWPAddToPlayer")
register_clcmd("frosta", "get_frost")
}
public plugin_precache()
{
// Models
precache_model(V_AWP_MODEL)
precache_model(P_AWP_MODEL)
precache_model(W_AWP_MODEL)
precache_model(ICE_MODEL)
g_iGlassGibs = precache_model(MODEL_GLASSGIBS)
// Sounds
precache_sound("warcraft3/impalehit.wav")
precache_sound(SOUND_UNFROZEN)
// Sprites
g_iAWPFrostSpr = precache_model("sprites/shockwave.spr")
g_iSpriteLaser = precache_model( "sprites/Newlightning.spr")
g_iSprites[SPRITE_FROST] = precache_model("sprites/frostexp_1.spr");
g_iSprites[SPRITE_FROST2] = precache_model("sprites/frostexp_2.spr");
g_iSprites[SPRITE_FLAKE] = precache_model("sprites/snowflake_1.spr");
}
public get_frost(id)
{
{
give_frost_awp(id)
}
}
public client_putinserver(id)
{
g_bHasFrostAWP[id] = false
g_bIsFrozen[id] = false
}
public client_disconnect(id)
{
g_bHasFrostAWP[id] = false
g_bIsFrozen[id] = false
RemoveEntity(id)
}
public plugin_natives()
{
register_native(WEAPON_NATIVE, "give_frost_awp", 1);
}
public native_give_weapon_add(id)
{
give_frost_awp(id)
}
public zp_extra_item_selected(player, itemid)
{
if (itemid == g_iItemID)
{
g_bHasFrostAWP[player] = true
ham_strip_weapon(player, "weapon_awp")
give_item(player, "weapon_awp")
cs_set_user_bpammo(player, CSW_AWP, 30)
new sName[32]
get_user_name(player, sName, 31)
ColorPrint(player, "^1Вы получили Frost AWP")
}
}
public give_frost_awp(player)
{
g_bHasFrostAWP[player] = true
ham_strip_weapon(player, "weapon_awp")
give_item(player, "weapon_awp")
cs_set_user_bpammo(player, CSW_AWP, 30)
new sName[32]
get_user_name(player, sName, 31)
ColorPrint(player, "^1Вы получили Frost AWP")
}
public TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
if(!is_user_alive(iAttacker))
return
if(get_user_weapon(iAttacker) != CSW_AWP || !g_bHasFrostAWP[iAttacker])
return
set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 2.0, 1.0, 1.0, -1)
ShowSyncHudMsg(iAttacker, g_iHudSync, "Урона до заморозки^n%d/%d", g_iDmg[iAttacker], get_pcvar_num(g_iFreezeDmg))
new vec2[3]
get_user_origin(iAttacker, vec2, 3)
make_beam(iAttacker, vec2, g_iSpriteLaser, 0, 50, 200, 200)
}
public zp_user_infected_post(infected, infector)
{
if (g_bHasFrostAWP[infected])
{
g_bHasFrostAWP[infected] = false
}
}
public zp_user_humanized_post(id)
{
g_bHasFrostAWP[id] = false
g_iDmg[id] = 0
RemoveEntity(id)
}
public event_round_start()
{
for (new i = 1; i <= g_iMaxPlayers; i++)
{
g_bHasFrostAWP[i] = false
g_bIsFrozen[i] = false
g_iDmg[i] = 0
if(is_user_alive(i))
{
Remove_Rendering(i)
}
}
}
public EventDeathMsg()
{
new iVictim = read_data(2)
RemoveEntity(iVictim)
Remove_Rendering(iVictim)
g_bIsFrozen[iVictim] = false
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if(!is_user_connected(victim) || !is_user_connected(attacker) || zp_get_user_nemesis(victim) || attacker == victim || !attacker)
return HAM_IGNORED
if(g_bIsFrozen[victim])
return HAM_SUPERCEDE
if(g_bHasFrostAWP[attacker] && (get_user_weapon(attacker) == CSW_AWP))
SetHamParamFloat(4, damage * get_pcvar_num(g_iDmgMultiplier))
// For Frost Effect Ring
static Float:originF[3]
pev(victim, pev_origin, originF)
// For Frost Effect Sound
static originF2[3]
get_user_origin(victim, originF2)
if((get_user_weapon(attacker) == CSW_AWP) && g_bHasFrostAWP[attacker])
{
g_iDmg[attacker] += (floatround(damage) * get_pcvar_num(g_iDmgMultiplier))
}
if((g_iDmg[attacker] >= get_pcvar_num(g_iFreezeDmg)) && (get_user_weapon(attacker) == CSW_AWP) && g_bHasFrostAWP[attacker])
{
new sName[32]
get_user_name(victim, sName, charsmax(sName))
FrostEffect(victim)
FrostEffectRing(originF)
FrostEffectSound(originF2)
g_iDmg[attacker] = 0
set_dhudmessage(34, 138, 255, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5)
show_dhudmessage(attacker, "%s Был заморожен!", sName)
}
return HAM_IGNORED
}
public CheckModel(id)
{
if(zp_get_user_survivor(id))
return PLUGIN_HANDLED
if (is_user_alive(id))
{
set_pev(id, pev_viewmodel2, V_AWP_MODEL)
set_pev(id, pev_weaponmodel2, P_AWP_MODEL)
}
return PLUGIN_HANDLED
}
public CurrentWeapon(id)
{
if ((get_user_weapon(id) == CSW_AWP) && g_bHasFrostAWP[id] == true)
{
CheckModel(id)
}
else
{
ClearSyncHud(id, g_iHudSync)
}
return PLUGIN_HANDLED
}
public FrostEffect(id)
{
// Only effect alive unfrozen zombies
if (!is_user_alive(id) || !zp_get_user_zombie(id) || g_bIsFrozen[id])
return
message_begin(MSG_ONE_UNRELIABLE, g_iMsgScreenFade, _, id)
write_short(4096*1) // duration
write_short(4096*1) // hold time
write_short(0x0000) // fade type
write_byte(0) // red
write_byte(50) // green
write_byte(200) // blue
write_byte(100) // alpha
message_end()
message_begin(MSG_ONE, g_iStatusIcon, {0,0,0}, id)
write_byte(1) // Status [0=Hide, 1=Show, 2=Flash]
write_string("dmg_cold") // Sprite Name
write_byte(000) // Red
write_byte(206) // Green
write_byte(209) // Blue
message_end()
new ent = create_entity("info_target")
UTIL_Explosion(id, g_iSprites[SPRITE_FROST], 40, 30, 4)
UTIL_Explosion(id, g_iSprites[SPRITE_FROST2], 20, 30, 4)
UTIL_SpriteTrail(id, g_iSprites[SPRITE_FLAKE], 30, 3, 2, 30, 0)
new Float:iOrigin[3]
entity_get_vector(id, EV_VEC_origin, iOrigin)
set_pev(ent, pev_body, 1)
entity_set_model(ent, ICE_MODEL)
iOrigin[2] -= 35
entity_set_origin(ent, iOrigin)
set_pev(ent, pev_owner, id)
set_rendering(ent, kRenderFxNone, 255, 255, 255, kRenderTransAdd, 255)
entity_set_string(ent, EV_SZ_classname, "ent_frozen")
entity_set_int(ent, EV_INT_solid, 2)
new Float: iOriginNew[3]
entity_get_vector(id, EV_VEC_origin, iOriginNew)
set_user_rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
g_bIsFrozen[id] = true
set_task(get_pcvar_float(g_fFrostTime), "RemoveFrost", id) // Time to Remove Frost Effect
}
public fw_PlayerPreThink(id)
{
// Not alive or Not Zombie
if (!is_user_alive(id) || !g_bIsFrozen[id])
return
// Stop motion
set_pev(id, pev_velocity, Float:{0.0,0.0,0.0})
set_user_maxspeed(id, 1.0)
// Stop Moving Mouse
set_pev(id , pev_v_angle , Float:{0.0,0.0,0.0})
set_pev(id , pev_fixangle , 1)
}
// Frost Effect Sound
public FrostEffectSound(iOrigin[3])
{
new Entity = create_entity("info_target")
new Float:flOrigin[3]
IVecFVec(iOrigin, flOrigin)
entity_set_origin(Entity, flOrigin)
emit_sound(Entity, CHAN_WEAPON, "warcraft3/impalehit.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
remove_entity(Entity)
}
UTIL_Explosion(iEnt, iSprite, iScale, iFramerate, Flags)
{
new Float:vOrigin[3]
pev(iEnt, pev_origin, vOrigin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_EXPLOSION)
engfunc(EngFunc_WriteCoord, vOrigin[0])
engfunc(EngFunc_WriteCoord, vOrigin[1])
engfunc(EngFunc_WriteCoord, vOrigin[2])
write_short(iSprite)
write_byte(iScale)
write_byte(iFramerate)
write_byte(Flags)
message_end()
}
UTIL_SpriteTrail(iEnt, iSprite, iCount, iLife, iScale, iVelocity, iVary)
{
new Float:vOrigin[3]
pev(iEnt, pev_origin, vOrigin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_SPRITETRAIL)
engfunc(EngFunc_WriteCoord, vOrigin[0])
engfunc(EngFunc_WriteCoord, vOrigin[1])
engfunc(EngFunc_WriteCoord, vOrigin[2] + 100)
engfunc(EngFunc_WriteCoord, vOrigin[0] + random_float( -200.0, 200.0 ))
engfunc(EngFunc_WriteCoord, vOrigin[1] + random_float( -200.0, 200.0 ))
engfunc(EngFunc_WriteCoord, vOrigin[2])
write_short(iSprite)
write_byte(iCount)
write_byte(iLife)
write_byte(iScale)
write_byte(iVelocity)
write_byte(iVary)
message_end()
}
// Frost Effect Ring
FrostEffectRing(const Float:originF3[3])
{
// Largest ring
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF3, 0)
write_byte(TE_BEAMCYLINDER) // TE id
engfunc(EngFunc_WriteCoord, originF3[0]) // x
engfunc(EngFunc_WriteCoord, originF3[1]) // y
engfunc(EngFunc_WriteCoord, originF3[2]) // z
engfunc(EngFunc_WriteCoord, originF3[0]) // x axis
engfunc(EngFunc_WriteCoord, originF3[1]) // y axis
engfunc(EngFunc_WriteCoord, originF3[2]+100.0) // z axis
write_short(g_iAWPFrostSpr) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(4) // life
write_byte(60) // width
write_byte(0) // noise
write_byte(0) // red
write_byte(191) // green
write_byte(255) // blue
write_byte(240) // brightness
write_byte(0) // speed
message_end()
}
public RemoveFrost(id)
{
// Not alive or not frozen anymore
if (!is_user_alive(id) || !g_bIsFrozen[id])
return
// Unfreeze
g_bIsFrozen[id] = false;
set_task(0.1, "remove_jibs", id)
// Rest Player Speed
ExecuteHamB(Ham_Player_ResetMaxSpeed, id)
Remove_Rendering(id)
RemoveStatusIcon(id)
}
public remove_jibs(id)
{
RemoveEntity(id)
new Float:origin[3]
pev(id,pev_origin,origin)
message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0)
write_byte(TE_IMPLOSION)
write_coord_fl(origin[0]) // x
write_coord_fl(origin[1]) // y
write_coord_fl(origin[2] + 8.0) // z
write_byte(64) // radius
write_byte(10) // count
write_byte(3) // duration
message_end()
message_begin_fl(MSG_PVS,SVC_TEMPENTITY,origin,0)
write_byte(TE_SPARKS)
write_coord_fl(origin[0]) // x
write_coord_fl(origin[1]) // y
write_coord_fl(origin[2]) // z
message_end()
message_begin_fl(MSG_PAS,SVC_TEMPENTITY,origin,0)
write_byte(TE_BREAKMODEL)
write_coord_fl(origin[0]) // x
write_coord_fl(origin[1]) // y
write_coord_fl(origin[2] + 24.0) // z
write_coord_fl(16.0) // size x
write_coord_fl(16.0) // size y
write_coord_fl(16.0) // size z
write_coord(random_num(-50,50)) // velocity x
write_coord(random_num(-50,50)) // velocity y
write_coord_fl(25.0) // velocity z
write_byte(10) // random velocity
write_short(g_iGlassGibs) // model
write_byte(10) // count
write_byte(25) // life
write_byte(0x01) // flags
message_end()
emit_sound(0,CHAN_ITEM,SOUND_UNFROZEN,VOL_NORM,ATTN_NORM,0,PITCH_LOW)
}
stock ColorPrint(const id, const input[], any: ...)
{
new count = 1, players[32]
static msg[192]
vformat(msg, 191, input, 3)
replace_all(msg, 191, "!g", "^4")
replace_all(msg, 191, "!y", "^1")
replace_all(msg, 191, "!t", "^3")
replace_all(msg, 191, "!t2", "^0")
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()
}
}
}
}
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
if(!wEnt) return 0
if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0
ExecuteHamB(Ham_Item_Kill,wEnt)
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId))
return 1
}
make_beam(id, const origin[3], sprite, red, green, blue, alpha)
{
//BEAMENTPOINTS
message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
write_byte (TE_BEAMENTPOINT)
write_short(id | 0x1000)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(sprite) // sprite
write_byte(1) // framestart
write_byte(5) // framerate
write_byte(2) // life
write_byte(20) // width
write_byte(0) // noise
write_byte(red) // r, g, b
write_byte(green) // r, g, b
write_byte(blue) // r, g, b
write_byte(alpha) // brightness
write_byte(150) // speed
message_end()
}
public RemoveStatusIcon(id)
{
// Remove Status Icon
message_begin(MSG_ONE, g_iStatusIcon, {0,0,0}, id)
write_byte(0) // Status [0=Hide, 1=Show, 2=Flash]
write_string("dmg_cold") // Sprite Name
message_end()
}
public fw_SetModel(entity, model[])
{
if(!is_valid_ent(entity))
return FMRES_IGNORED
if(!equali(model, W_OLD_AWP_MODEL))
return FMRES_IGNORED
new className[33]
entity_get_string(entity, EV_SZ_classname, className, 32)
static iOwner, iStoredAWPID
iOwner = entity_get_edict(entity, EV_ENT_owner)
// Get drop weapon index (Frost AWP) to use in fw_FrostAWPAddToPlayer forward
iStoredAWPID = find_ent_by_owner(-1, "weapon_awp", entity)
if(g_bHasFrostAWP[iOwner] && is_valid_ent(iStoredAWPID))
{
entity_set_int(iStoredAWPID, EV_INT_impulse, 1997)
g_bHasFrostAWP[iOwner] = false
entity_set_model(entity, W_AWP_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public fw_FrostAWPAddToPlayer(FrostAWP, id)
{
// Make sure that this is AWP
if(is_valid_ent(FrostAWP) && is_user_connected(id) && entity_get_int(FrostAWP, EV_INT_impulse) == 1997)
{
// Update Var
g_bHasFrostAWP[id] = true
// Reset weapon options
entity_set_int(FrostAWP, EV_INT_impulse, 0)
return HAM_HANDLED
}
return HAM_IGNORED
}
stock Remove_Rendering(id)
{
set_user_rendering(id, kRenderFxNone, 255, 255, 255, kRenderNormal, 16)
}
public RemoveEntity(id)
{
if(!is_user_connected(id))
return
new iEnt = find_ent_by_owner(-1, "ent_frozen", id);
if(pev_valid(iEnt))
remove_entity(iEnt)
}