Converted Force Field Grenade

Zombies/Humans Extra-Items
User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

Re: Force Field Grenade

#21

Post by Raheem » 1 Year Ago

Here the one with effects, i added to it force grenade support:
    1. #include <zombie_escape>
    2.  
    3. native ze_have_shield_nade(id)
    4.  
    5. // Setting File
    6. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    7.  
    8. // Defines
    9. #define MODEL_MAX_LENGTH 64
    10. #define SOUND_MAX_LENGTH 64
    11. #define SPRITE_MAX_LENGTH 64
    12. #define TASK_FROST_REMOVE 200
    13. #define ID_FROST_REMOVE (taskid - TASK_FROST_REMOVE)
    14. #define TASK_FREEZE 2018
    15.  
    16. // Default Sounds
    17. new const szFrostGrenadeExplodeSound[][] =
    18. {
    19.     "warcraft3/frostnova.wav"
    20. }
    21.  
    22. new const szFrostGrenadePlayerSound[][] =
    23. {
    24.     "warcraft3/impalehit.wav"
    25. }
    26.  
    27. new const szFrostGrenadeBreakSound[][] =
    28. {
    29.     "warcraft3/impalelaunch1.wav"
    30. }
    31. new g_frostexp
    32. new g_frost_gibs
    33.  
    34. // Default Models
    35. new g_v_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/v_grenade_frost.mdl"
    36. new g_p_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/p_grenade_frost.mdl"
    37. new g_w_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/w_grenade_frost.mdl"
    38.  
    39. // Default Sprites
    40. new g_szGrenadeTrailSprite[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
    41. new g_szGrenadeRingSprite[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
    42. new g_szGrenadeGlassSprite[SPRITE_MAX_LENGTH] = "models/glassgibs.mdl"
    43.  
    44. // Dynamic Arrays
    45. new Array:g_szFrostGrenadeExplodeSound
    46. new Array:g_szFrostGrenadePlayerSound
    47. new Array:g_szFrostGrenadeBreakSound
    48.  
    49. // Forwards
    50. enum _:TOTAL_FORWARDS
    51. {
    52.     FW_USER_FREEZE_PRE = 0,
    53.     FW_USER_UNFROZEN
    54. }
    55.  
    56. new g_iForwards[TOTAL_FORWARDS]
    57. new g_iForwardReturn
    58.  
    59. // Variables
    60. new bool:g_bIsFrozen[33],
    61.     bool:g_bZombieReleased,
    62.     g_iFrozenRenderingFx[33],
    63.     Float:g_fFrozenRenderingColor[33][3],
    64.     g_iFrozenRenderingRender[33],
    65.     Float:g_fFrozenRenderingAmount[33],
    66.     g_iMaxClients
    67.  
    68. // Sprites
    69. new g_iTrailSpr,
    70.     g_iExplodeSpr,
    71.     g_iGlassSpr
    72.  
    73. // Cvar
    74. new g_pCvarFrostDuration,
    75.     g_pCvarFrostHudIcon,
    76.     g_pCvarFrozenDamage,
    77.     g_pCvarFrostRadius,
    78.     g_pCvarHitType
    79.  
    80. public plugin_init()
    81. {
    82.     register_plugin("[ZE] Frost Nade", ZE_VERSION, AUTHORS)
    83.    
    84.     // Hook Chains
    85.     RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    86.     RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
    87.     RegisterHookChain(RG_CBasePlayer_PreThink, "Fw_PreThink_Post", 1)
    88.    
    89.     // Events
    90.     register_event("HLTV", "New_Round", "a", "1=0", "2=0")
    91.    
    92.     // Hams
    93.     RegisterHam(Ham_Think, "grenade", "Fw_ThinkGrenade_Post", 1)   
    94.    
    95.     // Fakemeta
    96.     register_forward(FM_SetModel, "Fw_SetModel_Post", 1)
    97.    
    98.     // Forwards
    99.     g_iForwards[FW_USER_FREEZE_PRE] = CreateMultiForward("ze_frost_pre", ET_CONTINUE, FP_CELL)
    100.     g_iForwards[FW_USER_UNFROZEN] = CreateMultiForward("ze_frost_unfreeze", ET_IGNORE, FP_CELL)
    101.    
    102.     // Cvars
    103.     g_pCvarFrostDuration = register_cvar("ze_frost_duration", "3")
    104.     g_pCvarFrostHudIcon = register_cvar("ze_frost_hud_icon", "1")
    105.     g_pCvarFrozenDamage = register_cvar("ze_freeze_damage", "0")
    106.     g_pCvarFrostRadius = register_cvar("ze_freeze_radius", "240.0")
    107.     g_pCvarHitType = register_cvar("ze_freeze_hit_type", "0")
    108.    
    109.     // Static Values
    110.     g_iMaxClients = get_member_game(m_nMaxPlayers)
    111. }
    112.  
    113. public plugin_natives()
    114. {
    115.     register_native("ze_zombie_in_forst", "native_ze_zombie_in_forst", 1)
    116.     register_native("ze_set_frost_grenade", "native_ze_set_frost_grenade", 1)
    117. }
    118.  
    119. public native_ze_zombie_in_forst(id)
    120. {
    121.     if (!is_user_alive(id))
    122.     {
    123.         return -1
    124.     }
    125.    
    126.     return g_bIsFrozen[id]
    127. }
    128.  
    129. public native_ze_set_frost_grenade(id, set)
    130. {
    131.     if (!is_user_alive(id))
    132.     {
    133.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    134.         return -1;
    135.     }
    136.    
    137.     // Unfreeze
    138.     if (!set)
    139.     {
    140.         // Not frozen
    141.         if (!g_bIsFrozen[id])
    142.             return true
    143.        
    144.         // Remove freeze right away and stop the task
    145.         RemoveFreeze(id+TASK_FROST_REMOVE)
    146.         remove_task(id+TASK_FROST_REMOVE)
    147.         return true
    148.     }
    149.    
    150.     return set_freeze(id)
    151. }
    152.  
    153. public plugin_precache()
    154. {
    155.     // Initialize arrays
    156.     g_szFrostGrenadeExplodeSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    157.     g_szFrostGrenadePlayerSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    158.     g_szFrostGrenadeBreakSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    159.    
    160.     // Load from external file
    161.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
    162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
    164.    
    165.     // If we couldn't load custom sounds from file, use and save default ones
    166.    
    167.     new iIndex
    168.    
    169.     if (ArraySize(g_szFrostGrenadeExplodeSound) == 0)
    170.     {
    171.         for (iIndex = 0; iIndex < sizeof szFrostGrenadeExplodeSound; iIndex++)
    172.             ArrayPushString(g_szFrostGrenadeExplodeSound, szFrostGrenadeExplodeSound[iIndex])
    173.        
    174.         // Save to external file
    175.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
    176.     }
    177.    
    178.     if (ArraySize(g_szFrostGrenadePlayerSound) == 0)
    179.     {
    180.         for (iIndex = 0; iIndex < sizeof szFrostGrenadePlayerSound; iIndex++)
    181.             ArrayPushString(g_szFrostGrenadePlayerSound, szFrostGrenadePlayerSound[iIndex])
    182.        
    183.         // Save to external file
    184.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
    185.     }
    186.    
    187.     if (ArraySize(g_szFrostGrenadeBreakSound) == 0)
    188.     {
    189.         for (iIndex = 0; iIndex < sizeof szFrostGrenadeBreakSound; iIndex++)
    190.             ArrayPushString(g_szFrostGrenadeBreakSound, szFrostGrenadeBreakSound[iIndex])
    191.        
    192.         // Save to external file
    193.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
    194.     }
    195.    
    196.     // Load from external file, save if not found
    197.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel, charsmax(g_v_szFrostGrenadeModel)))
    198.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel)
    199.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel, charsmax(g_p_szFrostGrenadeModel)))
    200.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel)
    201.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel, charsmax(g_w_szFrostGrenadeModel)))
    202.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel)
    203.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite, charsmax(g_szGrenadeTrailSprite)))
    204.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite)
    205.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite, charsmax(g_szGrenadeRingSprite)))
    206.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite)
    207.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite, charsmax(g_szGrenadeGlassSprite)))
    208.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite)
    209.    
    210.     // Precache sounds
    211.    
    212.     new szSound[SOUND_MAX_LENGTH]
    213.    
    214.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeExplodeSound); iIndex++)
    215.     {
    216.         ArrayGetString(g_szFrostGrenadeExplodeSound, iIndex, szSound, charsmax(szSound))
    217.         precache_sound(szSound)
    218.     }
    219.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadePlayerSound); iIndex++)
    220.     {
    221.         ArrayGetString(g_szFrostGrenadePlayerSound, iIndex, szSound, charsmax(szSound))
    222.         precache_sound(szSound)
    223.     }
    224.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeBreakSound); iIndex++)
    225.     {
    226.         ArrayGetString(g_szFrostGrenadeBreakSound, iIndex, szSound, charsmax(szSound))
    227.         precache_sound(szSound)
    228.     }
    229.    
    230.     // Precache models
    231.     precache_model(g_v_szFrostGrenadeModel)
    232.     precache_model(g_p_szFrostGrenadeModel)
    233.     precache_model(g_w_szFrostGrenadeModel)
    234.    
    235.     // Precache sprites
    236.     g_iTrailSpr = precache_model(g_szGrenadeTrailSprite)
    237.     g_iExplodeSpr = precache_model(g_szGrenadeRingSprite)
    238.     g_iGlassSpr = precache_model(g_szGrenadeGlassSprite)
    239.     g_frostexp = precache_model("sprites/frost_kurukafa.spr")
    240.     g_frost_gibs = precache_model("sprites/frost_gib.spr")
    241. }
    242.  
    243. public ze_user_humanized(id)
    244. {
    245.     // Set custom grenade model
    246.     cs_set_player_view_model(id, CSW_FLASHBANG, g_v_szFrostGrenadeModel)
    247.     cs_set_player_weap_model(id, CSW_FLASHBANG, g_p_szFrostGrenadeModel)
    248.     cs_set_player_view_model(id, CSW_SMOKEGRENADE, g_v_szFrostGrenadeModel)
    249.     cs_set_player_weap_model(id, CSW_SMOKEGRENADE, g_p_szFrostGrenadeModel)
    250.    
    251.     // If frozen, remove freeze after player is cured
    252.     if (g_bIsFrozen[id])
    253.     {
    254.         // Update rendering values first
    255.         ApplyFrozenRendering(id)
    256.        
    257.         // Remove freeze right away and stop the task
    258.         RemoveFreeze(id+TASK_FROST_REMOVE)
    259.         remove_task(id+TASK_FROST_REMOVE)
    260.     }
    261. }
    262.  
    263. public Fw_PreThink_Post(id)
    264. {
    265.     if (!ze_is_user_zombie(id))
    266.         return
    267.  
    268.     if (g_bIsFrozen[id] && g_bZombieReleased)
    269.     {
    270.         // Stop and Freeze Zombie
    271.         set_entvar(id, var_velocity, Float:{0.0,0.0,0.0})
    272.         set_entvar(id, var_maxspeed, 1.0)
    273.         ApplyFrozenRendering(id)
    274.     }
    275. }
    276.  
    277. public client_disconnected(id)
    278. {
    279.     g_bIsFrozen[id] = false
    280.     remove_task(id+TASK_FROST_REMOVE)
    281. }
    282.  
    283. public New_Round()
    284. {
    285.     remove_task(TASK_FREEZE)
    286.     g_bZombieReleased = false
    287. }
    288.  
    289. public Fw_TraceAttack_Pre(iVictim, iAttacker)
    290. {
    291.     // Block damage while frozen
    292.     if ((get_pcvar_num(g_pCvarFrozenDamage) == 0) && g_bIsFrozen[iVictim])
    293.         return HC_SUPERCEDE
    294.    
    295.     return HC_CONTINUE
    296. }
    297.  
    298. public Fw_PlayerKilled_Post(iVictim)
    299. {
    300.     // Frozen player being killed
    301.     if (g_bIsFrozen[iVictim])
    302.     {
    303.         // Remove freeze right away and stop the task
    304.         RemoveFreeze(iVictim+TASK_FROST_REMOVE)
    305.         remove_task(iVictim+TASK_FROST_REMOVE)
    306.     }
    307. }
    308.  
    309. public ze_zombie_release()
    310. {
    311.     g_bZombieReleased = true
    312. }
    313.  
    314. public Fw_SetModel_Post(entity, const model[])
    315. {
    316.     if (ze_have_shield_nade(pev(entity, pev_owner)))
    317.         return FMRES_IGNORED
    318.    
    319.     // We don't care
    320.     if (strlen(model) < 8)
    321.         return FMRES_IGNORED
    322.    
    323.     // Get damage time of grenade
    324.     static Float:dmgtime
    325.     get_entvar(entity, var_dmgtime, dmgtime)
    326.    
    327.     // Grenade not yet thrown
    328.     if (dmgtime == 0.0)
    329.         return FMRES_IGNORED
    330.    
    331.     // Grenade's owner is zombie?
    332.     if (ze_is_user_zombie(get_entvar(entity, var_owner)))
    333.         return FMRES_IGNORED
    334.  
    335.     // Flashbang or Smoke
    336.     if ((model[9] == 'f' && model[10] == 'l') || (model[9] == 's' && model[10] == 'm'))
    337.     {
    338.         // Give it a glow
    339.         Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
    340.        
    341.         // And a colored trail
    342.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    343.         write_byte(TE_BEAMFOLLOW) // TE id
    344.         write_short(entity) // entity
    345.         write_short(g_iTrailSpr) // sprite
    346.         write_byte(10) // life
    347.         write_byte(10) // width
    348.         write_byte(0) // r
    349.         write_byte(100) // g
    350.         write_byte(200) // b
    351.         write_byte(200) // brightness
    352.         message_end()
    353.        
    354.         // Set grenade type on the thrown grenade entity
    355.         set_entvar(entity, var_flTimeStepSound, 3333.0)
    356.     }
    357.    
    358.     // Set w_ model
    359.     if (equali(model, "models/w_flashbang.mdl") || equali(model, "models/w_smokegrenade.mdl"))
    360.     {
    361.         engfunc(EngFunc_SetModel, entity, g_w_szFrostGrenadeModel)
    362.         return FMRES_SUPERCEDE
    363.     }
    364.    
    365.     return FMRES_IGNORED
    366. }
    367.  
    368. public Fw_ThinkGrenade_Post(entity)
    369. {
    370.     // Invalid entity
    371.     if (!pev_valid(entity))
    372.         return HAM_IGNORED
    373.    
    374.     // Get damage time of grenade
    375.     static Float:dmgtime
    376.     get_entvar(entity, var_dmgtime, dmgtime)
    377.    
    378.     // Check if it's time to go off
    379.     if (dmgtime > get_gametime())
    380.         return HAM_IGNORED
    381.    
    382.     // Check if it's one of our custom nades
    383.     switch (get_entvar(entity, var_flTimeStepSound))
    384.     {
    385.         case 3333.0: // Frost Grenade
    386.         {
    387.             frost_explode(entity)
    388.             return HAM_SUPERCEDE
    389.         }
    390.     }
    391.     return HAM_IGNORED
    392. }
    393.  
    394. // Frost Grenade Explosion
    395. frost_explode(ent)
    396. {
    397.     // Get origin
    398.     static Float:origin[3]
    399.     get_entvar(ent, var_origin, origin)
    400.    
    401.     // Make the explosion
    402.     create_blast3(origin)
    403.     message_begin (MSG_BROADCAST,SVC_TEMPENTITY)
    404.     write_byte( TE_SPRITETRAIL ) // Throws a shower of sprites or models
    405.     engfunc(EngFunc_WriteCoord, origin[ 0 ]) // start pos
    406.     engfunc(EngFunc_WriteCoord, origin[ 1 ])
    407.     engfunc(EngFunc_WriteCoord, origin[ 2 ] + 200.0)
    408.     engfunc(EngFunc_WriteCoord, origin[ 0 ]) // velocity
    409.     engfunc(EngFunc_WriteCoord, origin[ 1 ])
    410.     engfunc(EngFunc_WriteCoord, origin[ 2 ] + 30.0)
    411.     write_short(g_frost_gibs) // spr
    412.     write_byte(60) // (count)
    413.     write_byte(random_num(27,30)) // (life in 0.1's)
    414.     write_byte(2) // byte (scale in 0.1's)
    415.     write_byte(50) // (velocity along vector in 10's)
    416.     write_byte(10) // (randomness of velocity in 10's)
    417.     message_end()
    418.    
    419.     // Frost nade explode sound
    420.     static sound[SOUND_MAX_LENGTH]
    421.     ArrayGetString(g_szFrostGrenadeExplodeSound, random_num(0, ArraySize(g_szFrostGrenadeExplodeSound) - 1), sound, charsmax(sound))
    422.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    423.    
    424.     // Collisions
    425.     if (!get_pcvar_num(g_pCvarHitType))
    426.     {
    427.         new victim = -1
    428.        
    429.         while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, get_pcvar_float(g_pCvarFrostRadius))) != 0)
    430.         {
    431.             // Only effect alive zombies, If player not released yet don't freeze him
    432.             if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || !g_bZombieReleased)
    433.                 continue
    434.            
    435.             set_freeze(victim)
    436.         }
    437.     }
    438.     else
    439.     {
    440.         new Float:flNadeOrigin[3], Float:flVictimOrigin[3], Float:flDistance, tr = create_tr2(), Float:flFraction
    441.         get_entvar(ent, var_origin, flNadeOrigin)
    442.        
    443.         for(new iVictim = 1; iVictim <= g_iMaxClients; iVictim++)
    444.         {
    445.             if (!is_user_alive(iVictim) || !ze_is_user_zombie(iVictim) || !g_bZombieReleased)
    446.                 continue
    447.            
    448.             get_entvar(iVictim, var_origin, flVictimOrigin)
    449.            
    450.             // Get distance between nade and player
    451.             flDistance = vector_distance(flNadeOrigin, flVictimOrigin)
    452.            
    453.             if(flDistance > get_pcvar_float(g_pCvarFrostRadius))
    454.                 continue
    455.            
    456.             flNadeOrigin[2] += 2.0;
    457.             engfunc(EngFunc_TraceLine, flNadeOrigin, flVictimOrigin, DONT_IGNORE_MONSTERS, ent, tr);
    458.             flNadeOrigin[2] -= 2.0;
    459.            
    460.             get_tr2(tr, TR_flFraction, flFraction);
    461.            
    462.             if(flFraction != 1.0 && get_tr2(tr, TR_pHit) != iVictim)
    463.                 continue;
    464.            
    465.             set_freeze(iVictim)
    466.         }
    467.        
    468.         // Free the trace handler
    469.         free_tr2(tr);
    470.     }
    471.    
    472.     // Get rid of the grenade
    473.     engfunc(EngFunc_RemoveEntity, ent)
    474. }
    475.  
    476. set_freeze(victim)
    477. {
    478.     // Already frozen
    479.     if (g_bIsFrozen[victim])
    480.         return false
    481.    
    482.     // Allow other plugins to decide whether player should be frozen or not
    483.     ExecuteForward(g_iForwards[FW_USER_FREEZE_PRE], g_iForwardReturn, victim)
    484.    
    485.     if (g_iForwardReturn >= PLUGIN_HANDLED)
    486.     {
    487.         // Get player's origin
    488.         static origin2[3]
    489.         get_user_origin(victim, origin2)
    490.        
    491.         // Broken glass sound
    492.         static sound[SOUND_MAX_LENGTH]
    493.         ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
    494.         emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    495.        
    496.         // Glass shatter
    497.         message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
    498.         write_byte(TE_BREAKMODEL) // TE id
    499.         write_coord(origin2[0]) // x
    500.         write_coord(origin2[1]) // y
    501.         write_coord(origin2[2]+24) // z
    502.         write_coord(16) // size x
    503.         write_coord(16) // size y
    504.         write_coord(16) // size z
    505.         write_coord(random_num(-50, 50)) // velocity x
    506.         write_coord(random_num(-50, 50)) // velocity y
    507.         write_coord(25) // velocity z
    508.         write_byte(10) // random velocity
    509.         write_short(g_iGlassSpr) // model
    510.         write_byte(10) // count
    511.         write_byte(25) // life
    512.         write_byte(0x01) // flags
    513.         message_end()
    514.        
    515.         return false
    516.     }
    517.    
    518.     // Freeze icon?
    519.     if (get_pcvar_num(g_pCvarFrostHudIcon))
    520.     {
    521.         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, victim)
    522.         write_byte(0) // damage save
    523.         write_byte(0) // damage take
    524.         write_long(DMG_DROWN) // damage type - DMG_FREEZE
    525.         write_coord(0) // x
    526.         write_coord(0) // y
    527.         write_coord(0) // z
    528.         message_end()
    529.     }
    530.    
    531.     // Set frozen flag
    532.     g_bIsFrozen[victim] = true
    533.    
    534.     // Freeze sound
    535.     static sound[SOUND_MAX_LENGTH]
    536.     ArrayGetString(g_szFrostGrenadePlayerSound, random_num(0, ArraySize(g_szFrostGrenadePlayerSound) - 1), sound, charsmax(sound))
    537.     emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    538.    
    539.     // Add a blue tint to their screen
    540.     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, victim)
    541.     write_short(0) // duration
    542.     write_short(0) // hold time
    543.     write_short(0x0004) // fade type
    544.     write_byte(0) // red
    545.     write_byte(50) // green
    546.     write_byte(200) // blue
    547.     write_byte(100) // alpha
    548.     message_end()
    549.    
    550.     // Update player entity rendering
    551.     ApplyFrozenRendering(victim)
    552.    
    553.     // Set a task to remove the freeze
    554.     set_task(get_pcvar_float(g_pCvarFrostDuration), "RemoveFreeze", victim+TASK_FROST_REMOVE)
    555.     return true
    556. }
    557.  
    558. ApplyFrozenRendering(id)
    559. {
    560.     // Get current rendering
    561.     new rendering_fx = get_entvar(id, var_renderfx)
    562.     new Float:rendering_color[3]
    563.     get_entvar(id, var_rendercolor, rendering_color)
    564.     new rendering_render = get_entvar(id, var_rendermode)
    565.     new Float:rendering_amount
    566.     get_entvar(id, var_renderamt, rendering_amount)
    567.    
    568.     // Already set, no worries...
    569.     if (rendering_fx == kRenderFxGlowShell && rendering_color[0] == 0.0 && rendering_color[1] == 100.0
    570.         && rendering_color[2] == 200.0 && rendering_render == kRenderNormal && rendering_amount == 25.0)
    571.         return
    572.    
    573.     // Save player's old rendering
    574.     g_iFrozenRenderingFx[id] = get_entvar(id, var_renderfx)
    575.     get_entvar(id, var_rendercolor, g_fFrozenRenderingColor[id])
    576.     g_iFrozenRenderingRender[id] = get_entvar(id, var_rendermode)
    577.     get_entvar(id, var_renderamt, g_fFrozenRenderingAmount[id])
    578.    
    579.     // Light blue glow while frozen
    580.     Set_Rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
    581. }
    582.  
    583. // Remove freeze task
    584. public RemoveFreeze(taskid)
    585. {
    586.     // Remove frozen flag
    587.     g_bIsFrozen[ID_FROST_REMOVE] = false
    588.    
    589.     // Restore rendering
    590.     new iRed = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][0]),
    591.     iGreen = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][1]),
    592.     iBlue = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][2])
    593.  
    594.     Set_Rendering(ID_FROST_REMOVE, g_iFrozenRenderingFx[ID_FROST_REMOVE], iRed, iGreen, iBlue, g_iFrozenRenderingRender[ID_FROST_REMOVE], floatround(g_fFrozenRenderingAmount[ID_FROST_REMOVE]))
    595.  
    596.     // Gradually remove screen's blue tint
    597.     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, ID_FROST_REMOVE)
    598.     write_short((1<<12)) // duration
    599.     write_short(0) // hold time
    600.     write_short(0x0000) // fade type
    601.     write_byte(0) // red
    602.     write_byte(50) // green
    603.     write_byte(200) // blue
    604.     write_byte(100) // alpha
    605.     message_end()
    606.    
    607.     // Broken glass sound
    608.     static sound[SOUND_MAX_LENGTH]
    609.     ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
    610.     emit_sound(ID_FROST_REMOVE, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    611.    
    612.     // Get player's origin
    613.     static origin[3]
    614.     get_user_origin(ID_FROST_REMOVE, origin)
    615.    
    616.     // Glass shatter
    617.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    618.     write_byte(TE_BREAKMODEL) // TE id
    619.     write_coord(origin[0]) // x
    620.     write_coord(origin[1]) // y
    621.     write_coord(origin[2]+24) // z
    622.     write_coord(16) // size x
    623.     write_coord(16) // size y
    624.     write_coord(16) // size z
    625.     write_coord(random_num(-50, 50)) // velocity x
    626.     write_coord(random_num(-50, 50)) // velocity y
    627.     write_coord(25) // velocity z
    628.     write_byte(10) // random velocity
    629.     write_short(g_iGlassSpr) // model
    630.     write_byte(10) // count
    631.     write_byte(25) // life
    632.     write_byte(BREAK_GLASS) // flags
    633.     message_end()
    634.    
    635.     ExecuteForward(g_iForwards[FW_USER_UNFROZEN], g_iForwardReturn, ID_FROST_REMOVE)
    636. }
    637.  
    638. // Frost Grenade: Freeze Blast
    639. create_blast3(const Float:originF[3])
    640. {
    641.    
    642.     // Frost Sprite
    643.  
    644.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    645.     write_byte (TE_SPRITE) // TE ID
    646.     engfunc(EngFunc_WriteCoord, originF[0]) // Position X
    647.     engfunc(EngFunc_WriteCoord, originF[1]) // Y
    648.     engfunc(EngFunc_WriteCoord, originF[2] + 50.0) // Z
    649.     write_short(g_frostexp) // Sprite index
    650.     write_byte(20) // Size of sprite
    651.     write_byte(200) // Low For Light | More For Dark !
    652.     message_end()
    653.  
    654.    
    655.     // Smallest ring
    656.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    657.     write_byte(TE_BEAMCYLINDER) // TE id
    658.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    659.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    660.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    661.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    662.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    663.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
    664.     write_short(g_iExplodeSpr) // sprite
    665.     write_byte(0) // startframe
    666.     write_byte(0) // framerate
    667.     write_byte(4) // life
    668.     write_byte(60) // width
    669.     write_byte(0) // noise
    670.     write_byte(0) // red
    671.     write_byte(100) // green
    672.     write_byte(200) // blue
    673.     write_byte(200) // brightness
    674.     write_byte(0) // speed
    675.     message_end()
    676.    
    677.     // Medium ring
    678.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    679.     write_byte(TE_BEAMCYLINDER) // TE id
    680.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    681.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    682.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    683.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    684.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    685.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
    686.     write_short(g_iExplodeSpr) // sprite
    687.     write_byte(0) // startframe
    688.     write_byte(0) // framerate
    689.     write_byte(4) // life
    690.     write_byte(60) // width
    691.     write_byte(0) // noise
    692.     write_byte(0) // red
    693.     write_byte(100) // green
    694.     write_byte(200) // blue
    695.     write_byte(200) // brightness
    696.     write_byte(0) // speed
    697.     message_end()
    698.    
    699.     // Largest ring
    700.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    701.     write_byte(TE_BEAMCYLINDER) // TE id
    702.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    703.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    704.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    705.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    706.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    707.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
    708.     write_short(g_iExplodeSpr) // sprite
    709.     write_byte(0) // startframe
    710.     write_byte(0) // framerate
    711.     write_byte(4) // life
    712.     write_byte(60) // width
    713.     write_byte(0) // noise
    714.     write_byte(0) // red
    715.     write_byte(100) // green
    716.     write_byte(200) // blue
    717.     write_byte(200) // brightness
    718.     write_byte(0) // speed
    719.     message_end()
    720. }
I just added 3 lines:
    1.     if (ze_have_shield_nade(pev(entity, pev_owner)))
    2.         return FMRES_IGNORED
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#22

Post by Mark » 1 Year Ago

czirimbolo wrote:
1 Year Ago
Force field doesnt work with this: viewtopic.php?f=15&t=3445

something need to be changed in ze_frost.sma
I know thats why i said if you want to use grom nade update Fire and Freeze nade to the link above and remove force Field nade.

They are not going to work at the same time i tried to change them for 4 hours.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#23

Post by czirimbolo » 11 Months Ago

my force field and grom working fine together without this viewtopic.php?f=15&t=3445
Image

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#24

Post by Mark » 11 Months Ago

czirimbolo wrote:
11 Months Ago
my force field and grom working fine together without this viewtopic.php?f=15&t=3445
Well what did you do just put the grom above forcefeild?

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#25

Post by czirimbolo » 11 Months Ago

I think I have another ze_frost.sma improved by Raheem, here is my frost.sma:

Code: Select all

#include <zombie_escape>

native ze_have_shield_nade(id)

// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"

// Defines
#define MODEL_MAX_LENGTH 64
#define SOUND_MAX_LENGTH 64
#define SPRITE_MAX_LENGTH 64
#define TASK_FROST_REMOVE 200
#define ID_FROST_REMOVE (taskid - TASK_FROST_REMOVE)
#define TASK_FREEZE 2018

// Default Sounds
new const szFrostGrenadeExplodeSound[][] =
{ 
	"warcraft3/frostnova.wav"
}

new const szFrostGrenadePlayerSound[][] =
{ 
	"warcraft3/impalehit.wav"
}

new const szFrostGrenadeBreakSound[][] =
{
	"warcraft3/impalelaunch1.wav"
}

// Default Models
new g_v_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/v_grenade_frost.mdl"
new g_p_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/p_grenade_frost.mdl"
new g_w_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/w_grenade_frost.mdl"

// Default Sprites
new g_szGrenadeTrailSprite[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
new g_szGrenadeRingSprite[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
new g_szGrenadeGlassSprite[SPRITE_MAX_LENGTH] = "models/glassgibs.mdl"

// Dynamic Arrays
new Array:g_szFrostGrenadeExplodeSound
new Array:g_szFrostGrenadePlayerSound
new Array:g_szFrostGrenadeBreakSound

// Forwards
enum _:TOTAL_FORWARDS
{
	FW_USER_FREEZE_PRE = 0,
	FW_USER_UNFROZEN
}

new g_iForwards[TOTAL_FORWARDS]
new g_iForwardReturn

// Variables
new bool:g_bIsFrozen[33],
	bool:g_bZombieReleased,
	g_iFrozenRenderingFx[33],
	Float:g_fFrozenRenderingColor[33][3],
	g_iFrozenRenderingRender[33],
	Float:g_fFrozenRenderingAmount[33],
	g_iMaxClients

// Sprites
new g_iTrailSpr,
	g_iExplodeSpr,
	g_iGlassSpr

// Cvar
new g_pCvarFrostDuration, 
	g_pCvarFrostHudIcon,
	g_pCvarFrozenDamage,
	g_pCvarFrostRadius,
	g_pCvarHitType

public plugin_init()
{
	register_plugin("[ZE] Frost Nade", ZE_VERSION, AUTHORS)
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
	RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
	RegisterHookChain(RG_CBasePlayer_PreThink, "Fw_PreThink_Post", 1)
	
	// Events
	register_event("HLTV", "New_Round", "a", "1=0", "2=0")
	
	// Hams
	RegisterHam(Ham_Think, "grenade", "Fw_ThinkGrenade_Post", 1)	
	
	// Fakemeta
	register_forward(FM_SetModel, "Fw_SetModel_Post", 1)
	
	// Forwards
	g_iForwards[FW_USER_FREEZE_PRE] = CreateMultiForward("ze_frost_pre", ET_CONTINUE, FP_CELL)
	g_iForwards[FW_USER_UNFROZEN] = CreateMultiForward("ze_frost_unfreeze", ET_IGNORE, FP_CELL)
	
	// Cvars
	g_pCvarFrostDuration = register_cvar("ze_frost_duration", "3")
	g_pCvarFrostHudIcon = register_cvar("ze_frost_hud_icon", "1")
	g_pCvarFrozenDamage = register_cvar("ze_freeze_damage", "0")
	g_pCvarFrostRadius = register_cvar("ze_freeze_radius", "240.0")
	g_pCvarHitType = register_cvar("ze_freeze_hit_type", "0")
	
	// Static Values
	g_iMaxClients = get_member_game(m_nMaxPlayers)
}

public plugin_natives()
{
	register_native("ze_zombie_in_forst", "native_ze_zombie_in_forst", 1)
	register_native("ze_set_frost_grenade", "native_ze_set_frost_grenade", 1)
}

public native_ze_zombie_in_forst(id)
{
	if (!is_user_alive(id))
	{
		return -1
	}
	
	return g_bIsFrozen[id]
}

public native_ze_set_frost_grenade(id, set)
{
	if (!is_user_alive(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
		return -1;
	}
	
	// Unfreeze
	if (!set)
	{
		// Not frozen
		if (!g_bIsFrozen[id])
			return true
		
		// Remove freeze right away and stop the task
		RemoveFreeze(id+TASK_FROST_REMOVE)
		remove_task(id+TASK_FROST_REMOVE)
		return true
	}
	
	return set_freeze(id)
}

public plugin_precache()
{
	// Initialize arrays
	g_szFrostGrenadeExplodeSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_szFrostGrenadePlayerSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_szFrostGrenadeBreakSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	
	// Load from external file
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
	
	// If we couldn't load custom sounds from file, use and save default ones
	
	new iIndex
	
	if (ArraySize(g_szFrostGrenadeExplodeSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadeExplodeSound; iIndex++)
			ArrayPushString(g_szFrostGrenadeExplodeSound, szFrostGrenadeExplodeSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
	}
	
	if (ArraySize(g_szFrostGrenadePlayerSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadePlayerSound; iIndex++)
			ArrayPushString(g_szFrostGrenadePlayerSound, szFrostGrenadePlayerSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
	}
	
	if (ArraySize(g_szFrostGrenadeBreakSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadeBreakSound; iIndex++)
			ArrayPushString(g_szFrostGrenadeBreakSound, szFrostGrenadeBreakSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
	}
	
	// Load from external file, save if not found
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel, charsmax(g_v_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel, charsmax(g_p_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel, charsmax(g_w_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite, charsmax(g_szGrenadeTrailSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite, charsmax(g_szGrenadeRingSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite, charsmax(g_szGrenadeGlassSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite)
	
	// Precache sounds
	
	new szSound[SOUND_MAX_LENGTH]
	
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeExplodeSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadeExplodeSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadePlayerSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadePlayerSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeBreakSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadeBreakSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	
	// Precache models
	precache_model(g_v_szFrostGrenadeModel)
	precache_model(g_p_szFrostGrenadeModel)
	precache_model(g_w_szFrostGrenadeModel)
	
	// Precache sprites
	g_iTrailSpr = precache_model(g_szGrenadeTrailSprite)
	g_iExplodeSpr = precache_model(g_szGrenadeRingSprite)
	g_iGlassSpr = precache_model(g_szGrenadeGlassSprite)
}

public ze_user_humanized(id)
{
	// Set custom grenade model
	cs_set_player_view_model(id, CSW_FLASHBANG, g_v_szFrostGrenadeModel)
	cs_set_player_weap_model(id, CSW_FLASHBANG, g_p_szFrostGrenadeModel)
	cs_set_player_view_model(id, CSW_SMOKEGRENADE, g_v_szFrostGrenadeModel)
	cs_set_player_weap_model(id, CSW_SMOKEGRENADE, g_p_szFrostGrenadeModel)
	
	// If frozen, remove freeze after player is cured
	if (g_bIsFrozen[id])
	{
		// Update rendering values first
		ApplyFrozenRendering(id)
		
		// Remove freeze right away and stop the task
		RemoveFreeze(id+TASK_FROST_REMOVE)
		remove_task(id+TASK_FROST_REMOVE)
	}
}

public Fw_PreThink_Post(id)
{
	if (!ze_is_user_zombie(id))
		return

	if (g_bIsFrozen[id] && g_bZombieReleased)
	{
		// Stop and Freeze Zombie
		set_entvar(id, var_velocity, Float:{0.0,0.0,0.0})
		set_entvar(id, var_maxspeed, 1.0)
		ApplyFrozenRendering(id)
	}
}

public client_disconnected(id)
{
	g_bIsFrozen[id] = false
	remove_task(id+TASK_FROST_REMOVE)
}

public New_Round()
{
	remove_task(TASK_FREEZE)
	g_bZombieReleased = false
	
	// Set w_ models for grenades on ground
	new szModel[32], iEntity = -1;

	while((iEntity = rg_find_ent_by_class( iEntity, "armoury_entity")))
	{
		get_entvar(iEntity, var_model, szModel, charsmax(szModel))
		
		if (equali(szModel, "models/w_flashbang.mdl") || equali(szModel, "models/w_smokegrenade.mdl"))
		{
			engfunc(EngFunc_SetModel, iEntity, g_w_szFrostGrenadeModel)
		}
	}
}

public Fw_TraceAttack_Pre(iVictim, iAttacker)
{
	// Block damage while frozen
	if ((get_pcvar_num(g_pCvarFrozenDamage) == 0) && g_bIsFrozen[iVictim])
		return HC_SUPERCEDE
	
	return HC_CONTINUE
}

public Fw_PlayerKilled_Post(iVictim)
{
	// Frozen player being killed
	if (g_bIsFrozen[iVictim])
	{
		// Remove freeze right away and stop the task
		RemoveFreeze(iVictim+TASK_FROST_REMOVE)
		remove_task(iVictim+TASK_FROST_REMOVE)
	}
}

public ze_zombie_release()
{
	g_bZombieReleased = true
}

public Fw_SetModel_Post(entity, const model[])
{
	if (ze_have_shield_nade(pev(entity, pev_owner)))
		return FMRES_IGNORED
	
	// We don't care
	if (strlen(model) < 8)
		return FMRES_IGNORED
	
	// Get damage time of grenade
	static Float:dmgtime
	get_entvar(entity, var_dmgtime, dmgtime)
	
	// Grenade not yet thrown
	if (dmgtime == 0.0)
		return FMRES_IGNORED
	
	// Grenade's owner is zombie?
	if (ze_is_user_zombie(get_entvar(entity, var_owner)))
		return FMRES_IGNORED

	// Flashbang or Smoke
	if ((model[9] == 'f' && model[10] == 'l') || (model[9] == 's' && model[10] == 'm'))
	{
		// Give it a glow
		Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
		
		// And a colored trail
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMFOLLOW) // TE id
		write_short(entity) // entity
		write_short(g_iTrailSpr) // sprite
		write_byte(10) // life
		write_byte(10) // width
		write_byte(0) // r
		write_byte(100) // g
		write_byte(200) // b
		write_byte(200) // brightness
		message_end()
		
		// Set grenade type on the thrown grenade entity
		set_entvar(entity, var_flTimeStepSound, 3333.0)
	}
	
	// Set w_ model
	if (equali(model, "models/w_flashbang.mdl") || equali(model, "models/w_smokegrenade.mdl"))
	{
		engfunc(EngFunc_SetModel, entity, g_w_szFrostGrenadeModel)
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public Fw_ThinkGrenade_Post(entity)
{
	// Invalid entity
	if (!pev_valid(entity))
		return HAM_IGNORED
	
	// Get damage time of grenade
	static Float:dmgtime
	get_entvar(entity, var_dmgtime, dmgtime)
	
	// Check if it's time to go off
	if (dmgtime > get_gametime())
		return HAM_IGNORED
	
	// Check if it's one of our custom nades
	switch (get_entvar(entity, var_flTimeStepSound))
	{
		case 3333.0: // Frost Grenade
		{
			frost_explode(entity)
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

// Frost Grenade Explosion
frost_explode(ent)
{
	// Get origin
	static Float:origin[3]
	get_entvar(ent, var_origin, origin)
	
	// Make the explosion
	create_blast3(origin)
	
	// Frost nade explode sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadeExplodeSound, random_num(0, ArraySize(g_szFrostGrenadeExplodeSound) - 1), sound, charsmax(sound))
	emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Collisions
	if (!get_pcvar_num(g_pCvarHitType))
	{
		new victim = -1
		
		while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, get_pcvar_float(g_pCvarFrostRadius))) != 0)
		{
			// Only effect alive zombies, If player not released yet don't freeze him
			if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || !g_bZombieReleased)
				continue
			
			set_freeze(victim)
		}
	}
	else
	{
		new Float:flNadeOrigin[3], Float:flVictimOrigin[3], Float:flDistance, tr = create_tr2(), Float:flFraction
		get_entvar(ent, var_origin, flNadeOrigin)
		
		for(new iVictim = 1; iVictim <= g_iMaxClients; iVictim++)
		{
			if (!is_user_alive(iVictim) || !ze_is_user_zombie(iVictim) || !g_bZombieReleased)
				continue
			
			get_entvar(iVictim, var_origin, flVictimOrigin)
			
			// Get distance between nade and player
			flDistance = vector_distance(flNadeOrigin, flVictimOrigin)
			
			if(flDistance > get_pcvar_float(g_pCvarFrostRadius))
				continue
			
			flNadeOrigin[2] += 2.0;
			engfunc(EngFunc_TraceLine, flNadeOrigin, flVictimOrigin, DONT_IGNORE_MONSTERS, ent, tr);
			flNadeOrigin[2] -= 2.0;
			
			get_tr2(tr, TR_flFraction, flFraction);
			
			if(flFraction != 1.0 && get_tr2(tr, TR_pHit) != iVictim)
				continue;
			
			set_freeze(iVictim)
		}
		
		// Free the trace handler
		free_tr2(tr);
	}
	
	// Get rid of the grenade
	engfunc(EngFunc_RemoveEntity, ent)
}

set_freeze(victim)
{
	// Already frozen
	if (g_bIsFrozen[victim])
		return false
	
	// Allow other plugins to decide whether player should be frozen or not
	ExecuteForward(g_iForwards[FW_USER_FREEZE_PRE], g_iForwardReturn, victim)
	
	if (g_iForwardReturn >= PLUGIN_HANDLED)
	{
		// Get player's origin
		static origin2[3]
		get_user_origin(victim, origin2)
		
		// Broken glass sound
		static sound[SOUND_MAX_LENGTH]
		ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
		emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
		
		// Glass shatter
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
		write_byte(TE_BREAKMODEL) // TE id
		write_coord(origin2[0]) // x
		write_coord(origin2[1]) // y
		write_coord(origin2[2]+24) // z
		write_coord(16) // size x
		write_coord(16) // size y
		write_coord(16) // size z
		write_coord(random_num(-50, 50)) // velocity x
		write_coord(random_num(-50, 50)) // velocity y
		write_coord(25) // velocity z
		write_byte(10) // random velocity
		write_short(g_iGlassSpr) // model
		write_byte(10) // count
		write_byte(25) // life
		write_byte(0x01) // flags
		message_end()
		
		return false
	}
	
	// Freeze icon?
	if (get_pcvar_num(g_pCvarFrostHudIcon))
	{
		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, victim)
		write_byte(0) // damage save
		write_byte(0) // damage take
		write_long(DMG_DROWN) // damage type - DMG_FREEZE
		write_coord(0) // x
		write_coord(0) // y
		write_coord(0) // z
		message_end()
	}
	
	// Set frozen flag
	g_bIsFrozen[victim] = true
	
	// Freeze sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadePlayerSound, random_num(0, ArraySize(g_szFrostGrenadePlayerSound) - 1), sound, charsmax(sound))
	emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Add a blue tint to their screen
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, victim)
	write_short(0) // duration
	write_short(0) // hold time
	write_short(0x0004) // fade type
	write_byte(0) // red
	write_byte(50) // green
	write_byte(200) // blue
	write_byte(100) // alpha
	message_end()
	
	// Update player entity rendering
	ApplyFrozenRendering(victim)
	
	// Set a task to remove the freeze
	set_task(get_pcvar_float(g_pCvarFrostDuration), "RemoveFreeze", victim+TASK_FROST_REMOVE)
	return true
}

ApplyFrozenRendering(id)
{
	// Get current rendering
	new rendering_fx = get_entvar(id, var_renderfx)
	new Float:rendering_color[3]
	get_entvar(id, var_rendercolor, rendering_color)
	new rendering_render = get_entvar(id, var_rendermode)
	new Float:rendering_amount
	get_entvar(id, var_renderamt, rendering_amount)
	
	// Already set, no worries...
	if (rendering_fx == kRenderFxGlowShell && rendering_color[0] == 0.0 && rendering_color[1] == 100.0
		&& rendering_color[2] == 200.0 && rendering_render == kRenderNormal && rendering_amount == 25.0)
		return
	
	// Save player's old rendering
	g_iFrozenRenderingFx[id] = get_entvar(id, var_renderfx)
	get_entvar(id, var_rendercolor, g_fFrozenRenderingColor[id])
	g_iFrozenRenderingRender[id] = get_entvar(id, var_rendermode)
	get_entvar(id, var_renderamt, g_fFrozenRenderingAmount[id])
	
	// Light blue glow while frozen
	Set_Rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
}

// Remove freeze task
public RemoveFreeze(taskid)
{
	// Remove frozen flag
	g_bIsFrozen[ID_FROST_REMOVE] = false
	
	// Restore rendering
	new iRed = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][0]),
	iGreen = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][1]),
	iBlue = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][2])

	Set_Rendering(ID_FROST_REMOVE, g_iFrozenRenderingFx[ID_FROST_REMOVE], iRed, iGreen, iBlue, g_iFrozenRenderingRender[ID_FROST_REMOVE], floatround(g_fFrozenRenderingAmount[ID_FROST_REMOVE]))

	// Gradually remove screen's blue tint
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, ID_FROST_REMOVE)
	write_short((1<<12)) // duration
	write_short(0) // 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()
	
	// Broken glass sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
	emit_sound(ID_FROST_REMOVE, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Get player's origin
	static origin[3]
	get_user_origin(ID_FROST_REMOVE, origin)
	
	// Glass shatter
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_BREAKMODEL) // TE id
	write_coord(origin[0]) // x
	write_coord(origin[1]) // y
	write_coord(origin[2]+24) // z
	write_coord(16) // size x
	write_coord(16) // size y
	write_coord(16) // size z
	write_coord(random_num(-50, 50)) // velocity x
	write_coord(random_num(-50, 50)) // velocity y
	write_coord(25) // velocity z
	write_byte(10) // random velocity
	write_short(g_iGlassSpr) // model
	write_byte(10) // count
	write_byte(25) // life
	write_byte(BREAK_GLASS) // flags
	message_end()
	
	ExecuteForward(g_iForwards[FW_USER_UNFROZEN], g_iForwardReturn, ID_FROST_REMOVE)
}

// Frost Grenade: Freeze Blast
create_blast3(const Float:originF[3])
{
	// Smallest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Medium ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Largest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
}
Image

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#26

Post by Mark » 11 Months Ago

czirimbolo wrote:
11 Months Ago
I think I have another ze_frost.sma improved by Raheem, here is my frost.sma:

Code: Select all

#include <zombie_escape>

native ze_have_shield_nade(id)

// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"

// Defines
#define MODEL_MAX_LENGTH 64
#define SOUND_MAX_LENGTH 64
#define SPRITE_MAX_LENGTH 64
#define TASK_FROST_REMOVE 200
#define ID_FROST_REMOVE (taskid - TASK_FROST_REMOVE)
#define TASK_FREEZE 2018

// Default Sounds
new const szFrostGrenadeExplodeSound[][] =
{ 
	"warcraft3/frostnova.wav"
}

new const szFrostGrenadePlayerSound[][] =
{ 
	"warcraft3/impalehit.wav"
}

new const szFrostGrenadeBreakSound[][] =
{
	"warcraft3/impalelaunch1.wav"
}

// Default Models
new g_v_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/v_grenade_frost.mdl"
new g_p_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/p_grenade_frost.mdl"
new g_w_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/w_grenade_frost.mdl"

// Default Sprites
new g_szGrenadeTrailSprite[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
new g_szGrenadeRingSprite[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
new g_szGrenadeGlassSprite[SPRITE_MAX_LENGTH] = "models/glassgibs.mdl"

// Dynamic Arrays
new Array:g_szFrostGrenadeExplodeSound
new Array:g_szFrostGrenadePlayerSound
new Array:g_szFrostGrenadeBreakSound

// Forwards
enum _:TOTAL_FORWARDS
{
	FW_USER_FREEZE_PRE = 0,
	FW_USER_UNFROZEN
}

new g_iForwards[TOTAL_FORWARDS]
new g_iForwardReturn

// Variables
new bool:g_bIsFrozen[33],
	bool:g_bZombieReleased,
	g_iFrozenRenderingFx[33],
	Float:g_fFrozenRenderingColor[33][3],
	g_iFrozenRenderingRender[33],
	Float:g_fFrozenRenderingAmount[33],
	g_iMaxClients

// Sprites
new g_iTrailSpr,
	g_iExplodeSpr,
	g_iGlassSpr

// Cvar
new g_pCvarFrostDuration, 
	g_pCvarFrostHudIcon,
	g_pCvarFrozenDamage,
	g_pCvarFrostRadius,
	g_pCvarHitType

public plugin_init()
{
	register_plugin("[ZE] Frost Nade", ZE_VERSION, AUTHORS)
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
	RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
	RegisterHookChain(RG_CBasePlayer_PreThink, "Fw_PreThink_Post", 1)
	
	// Events
	register_event("HLTV", "New_Round", "a", "1=0", "2=0")
	
	// Hams
	RegisterHam(Ham_Think, "grenade", "Fw_ThinkGrenade_Post", 1)	
	
	// Fakemeta
	register_forward(FM_SetModel, "Fw_SetModel_Post", 1)
	
	// Forwards
	g_iForwards[FW_USER_FREEZE_PRE] = CreateMultiForward("ze_frost_pre", ET_CONTINUE, FP_CELL)
	g_iForwards[FW_USER_UNFROZEN] = CreateMultiForward("ze_frost_unfreeze", ET_IGNORE, FP_CELL)
	
	// Cvars
	g_pCvarFrostDuration = register_cvar("ze_frost_duration", "3")
	g_pCvarFrostHudIcon = register_cvar("ze_frost_hud_icon", "1")
	g_pCvarFrozenDamage = register_cvar("ze_freeze_damage", "0")
	g_pCvarFrostRadius = register_cvar("ze_freeze_radius", "240.0")
	g_pCvarHitType = register_cvar("ze_freeze_hit_type", "0")
	
	// Static Values
	g_iMaxClients = get_member_game(m_nMaxPlayers)
}

public plugin_natives()
{
	register_native("ze_zombie_in_forst", "native_ze_zombie_in_forst", 1)
	register_native("ze_set_frost_grenade", "native_ze_set_frost_grenade", 1)
}

public native_ze_zombie_in_forst(id)
{
	if (!is_user_alive(id))
	{
		return -1
	}
	
	return g_bIsFrozen[id]
}

public native_ze_set_frost_grenade(id, set)
{
	if (!is_user_alive(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
		return -1;
	}
	
	// Unfreeze
	if (!set)
	{
		// Not frozen
		if (!g_bIsFrozen[id])
			return true
		
		// Remove freeze right away and stop the task
		RemoveFreeze(id+TASK_FROST_REMOVE)
		remove_task(id+TASK_FROST_REMOVE)
		return true
	}
	
	return set_freeze(id)
}

public plugin_precache()
{
	// Initialize arrays
	g_szFrostGrenadeExplodeSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_szFrostGrenadePlayerSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_szFrostGrenadeBreakSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
	
	// Load from external file
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
	amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
	
	// If we couldn't load custom sounds from file, use and save default ones
	
	new iIndex
	
	if (ArraySize(g_szFrostGrenadeExplodeSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadeExplodeSound; iIndex++)
			ArrayPushString(g_szFrostGrenadeExplodeSound, szFrostGrenadeExplodeSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
	}
	
	if (ArraySize(g_szFrostGrenadePlayerSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadePlayerSound; iIndex++)
			ArrayPushString(g_szFrostGrenadePlayerSound, szFrostGrenadePlayerSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
	}
	
	if (ArraySize(g_szFrostGrenadeBreakSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szFrostGrenadeBreakSound; iIndex++)
			ArrayPushString(g_szFrostGrenadeBreakSound, szFrostGrenadeBreakSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
	}
	
	// Load from external file, save if not found
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel, charsmax(g_v_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel, charsmax(g_p_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel, charsmax(g_w_szFrostGrenadeModel)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite, charsmax(g_szGrenadeTrailSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite, charsmax(g_szGrenadeRingSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite)
	if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite, charsmax(g_szGrenadeGlassSprite)))
		amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite)
	
	// Precache sounds
	
	new szSound[SOUND_MAX_LENGTH]
	
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeExplodeSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadeExplodeSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadePlayerSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadePlayerSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeBreakSound); iIndex++)
	{
		ArrayGetString(g_szFrostGrenadeBreakSound, iIndex, szSound, charsmax(szSound))
		precache_sound(szSound)
	}
	
	// Precache models
	precache_model(g_v_szFrostGrenadeModel)
	precache_model(g_p_szFrostGrenadeModel)
	precache_model(g_w_szFrostGrenadeModel)
	
	// Precache sprites
	g_iTrailSpr = precache_model(g_szGrenadeTrailSprite)
	g_iExplodeSpr = precache_model(g_szGrenadeRingSprite)
	g_iGlassSpr = precache_model(g_szGrenadeGlassSprite)
}

public ze_user_humanized(id)
{
	// Set custom grenade model
	cs_set_player_view_model(id, CSW_FLASHBANG, g_v_szFrostGrenadeModel)
	cs_set_player_weap_model(id, CSW_FLASHBANG, g_p_szFrostGrenadeModel)
	cs_set_player_view_model(id, CSW_SMOKEGRENADE, g_v_szFrostGrenadeModel)
	cs_set_player_weap_model(id, CSW_SMOKEGRENADE, g_p_szFrostGrenadeModel)
	
	// If frozen, remove freeze after player is cured
	if (g_bIsFrozen[id])
	{
		// Update rendering values first
		ApplyFrozenRendering(id)
		
		// Remove freeze right away and stop the task
		RemoveFreeze(id+TASK_FROST_REMOVE)
		remove_task(id+TASK_FROST_REMOVE)
	}
}

public Fw_PreThink_Post(id)
{
	if (!ze_is_user_zombie(id))
		return

	if (g_bIsFrozen[id] && g_bZombieReleased)
	{
		// Stop and Freeze Zombie
		set_entvar(id, var_velocity, Float:{0.0,0.0,0.0})
		set_entvar(id, var_maxspeed, 1.0)
		ApplyFrozenRendering(id)
	}
}

public client_disconnected(id)
{
	g_bIsFrozen[id] = false
	remove_task(id+TASK_FROST_REMOVE)
}

public New_Round()
{
	remove_task(TASK_FREEZE)
	g_bZombieReleased = false
	
	// Set w_ models for grenades on ground
	new szModel[32], iEntity = -1;

	while((iEntity = rg_find_ent_by_class( iEntity, "armoury_entity")))
	{
		get_entvar(iEntity, var_model, szModel, charsmax(szModel))
		
		if (equali(szModel, "models/w_flashbang.mdl") || equali(szModel, "models/w_smokegrenade.mdl"))
		{
			engfunc(EngFunc_SetModel, iEntity, g_w_szFrostGrenadeModel)
		}
	}
}

public Fw_TraceAttack_Pre(iVictim, iAttacker)
{
	// Block damage while frozen
	if ((get_pcvar_num(g_pCvarFrozenDamage) == 0) && g_bIsFrozen[iVictim])
		return HC_SUPERCEDE
	
	return HC_CONTINUE
}

public Fw_PlayerKilled_Post(iVictim)
{
	// Frozen player being killed
	if (g_bIsFrozen[iVictim])
	{
		// Remove freeze right away and stop the task
		RemoveFreeze(iVictim+TASK_FROST_REMOVE)
		remove_task(iVictim+TASK_FROST_REMOVE)
	}
}

public ze_zombie_release()
{
	g_bZombieReleased = true
}

public Fw_SetModel_Post(entity, const model[])
{
	if (ze_have_shield_nade(pev(entity, pev_owner)))
		return FMRES_IGNORED
	
	// We don't care
	if (strlen(model) < 8)
		return FMRES_IGNORED
	
	// Get damage time of grenade
	static Float:dmgtime
	get_entvar(entity, var_dmgtime, dmgtime)
	
	// Grenade not yet thrown
	if (dmgtime == 0.0)
		return FMRES_IGNORED
	
	// Grenade's owner is zombie?
	if (ze_is_user_zombie(get_entvar(entity, var_owner)))
		return FMRES_IGNORED

	// Flashbang or Smoke
	if ((model[9] == 'f' && model[10] == 'l') || (model[9] == 's' && model[10] == 'm'))
	{
		// Give it a glow
		Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
		
		// And a colored trail
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
		write_byte(TE_BEAMFOLLOW) // TE id
		write_short(entity) // entity
		write_short(g_iTrailSpr) // sprite
		write_byte(10) // life
		write_byte(10) // width
		write_byte(0) // r
		write_byte(100) // g
		write_byte(200) // b
		write_byte(200) // brightness
		message_end()
		
		// Set grenade type on the thrown grenade entity
		set_entvar(entity, var_flTimeStepSound, 3333.0)
	}
	
	// Set w_ model
	if (equali(model, "models/w_flashbang.mdl") || equali(model, "models/w_smokegrenade.mdl"))
	{
		engfunc(EngFunc_SetModel, entity, g_w_szFrostGrenadeModel)
		return FMRES_SUPERCEDE
	}
	
	return FMRES_IGNORED
}

public Fw_ThinkGrenade_Post(entity)
{
	// Invalid entity
	if (!pev_valid(entity))
		return HAM_IGNORED
	
	// Get damage time of grenade
	static Float:dmgtime
	get_entvar(entity, var_dmgtime, dmgtime)
	
	// Check if it's time to go off
	if (dmgtime > get_gametime())
		return HAM_IGNORED
	
	// Check if it's one of our custom nades
	switch (get_entvar(entity, var_flTimeStepSound))
	{
		case 3333.0: // Frost Grenade
		{
			frost_explode(entity)
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

// Frost Grenade Explosion
frost_explode(ent)
{
	// Get origin
	static Float:origin[3]
	get_entvar(ent, var_origin, origin)
	
	// Make the explosion
	create_blast3(origin)
	
	// Frost nade explode sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadeExplodeSound, random_num(0, ArraySize(g_szFrostGrenadeExplodeSound) - 1), sound, charsmax(sound))
	emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Collisions
	if (!get_pcvar_num(g_pCvarHitType))
	{
		new victim = -1
		
		while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, get_pcvar_float(g_pCvarFrostRadius))) != 0)
		{
			// Only effect alive zombies, If player not released yet don't freeze him
			if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || !g_bZombieReleased)
				continue
			
			set_freeze(victim)
		}
	}
	else
	{
		new Float:flNadeOrigin[3], Float:flVictimOrigin[3], Float:flDistance, tr = create_tr2(), Float:flFraction
		get_entvar(ent, var_origin, flNadeOrigin)
		
		for(new iVictim = 1; iVictim <= g_iMaxClients; iVictim++)
		{
			if (!is_user_alive(iVictim) || !ze_is_user_zombie(iVictim) || !g_bZombieReleased)
				continue
			
			get_entvar(iVictim, var_origin, flVictimOrigin)
			
			// Get distance between nade and player
			flDistance = vector_distance(flNadeOrigin, flVictimOrigin)
			
			if(flDistance > get_pcvar_float(g_pCvarFrostRadius))
				continue
			
			flNadeOrigin[2] += 2.0;
			engfunc(EngFunc_TraceLine, flNadeOrigin, flVictimOrigin, DONT_IGNORE_MONSTERS, ent, tr);
			flNadeOrigin[2] -= 2.0;
			
			get_tr2(tr, TR_flFraction, flFraction);
			
			if(flFraction != 1.0 && get_tr2(tr, TR_pHit) != iVictim)
				continue;
			
			set_freeze(iVictim)
		}
		
		// Free the trace handler
		free_tr2(tr);
	}
	
	// Get rid of the grenade
	engfunc(EngFunc_RemoveEntity, ent)
}

set_freeze(victim)
{
	// Already frozen
	if (g_bIsFrozen[victim])
		return false
	
	// Allow other plugins to decide whether player should be frozen or not
	ExecuteForward(g_iForwards[FW_USER_FREEZE_PRE], g_iForwardReturn, victim)
	
	if (g_iForwardReturn >= PLUGIN_HANDLED)
	{
		// Get player's origin
		static origin2[3]
		get_user_origin(victim, origin2)
		
		// Broken glass sound
		static sound[SOUND_MAX_LENGTH]
		ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
		emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
		
		// Glass shatter
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
		write_byte(TE_BREAKMODEL) // TE id
		write_coord(origin2[0]) // x
		write_coord(origin2[1]) // y
		write_coord(origin2[2]+24) // z
		write_coord(16) // size x
		write_coord(16) // size y
		write_coord(16) // size z
		write_coord(random_num(-50, 50)) // velocity x
		write_coord(random_num(-50, 50)) // velocity y
		write_coord(25) // velocity z
		write_byte(10) // random velocity
		write_short(g_iGlassSpr) // model
		write_byte(10) // count
		write_byte(25) // life
		write_byte(0x01) // flags
		message_end()
		
		return false
	}
	
	// Freeze icon?
	if (get_pcvar_num(g_pCvarFrostHudIcon))
	{
		message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, victim)
		write_byte(0) // damage save
		write_byte(0) // damage take
		write_long(DMG_DROWN) // damage type - DMG_FREEZE
		write_coord(0) // x
		write_coord(0) // y
		write_coord(0) // z
		message_end()
	}
	
	// Set frozen flag
	g_bIsFrozen[victim] = true
	
	// Freeze sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadePlayerSound, random_num(0, ArraySize(g_szFrostGrenadePlayerSound) - 1), sound, charsmax(sound))
	emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Add a blue tint to their screen
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, victim)
	write_short(0) // duration
	write_short(0) // hold time
	write_short(0x0004) // fade type
	write_byte(0) // red
	write_byte(50) // green
	write_byte(200) // blue
	write_byte(100) // alpha
	message_end()
	
	// Update player entity rendering
	ApplyFrozenRendering(victim)
	
	// Set a task to remove the freeze
	set_task(get_pcvar_float(g_pCvarFrostDuration), "RemoveFreeze", victim+TASK_FROST_REMOVE)
	return true
}

ApplyFrozenRendering(id)
{
	// Get current rendering
	new rendering_fx = get_entvar(id, var_renderfx)
	new Float:rendering_color[3]
	get_entvar(id, var_rendercolor, rendering_color)
	new rendering_render = get_entvar(id, var_rendermode)
	new Float:rendering_amount
	get_entvar(id, var_renderamt, rendering_amount)
	
	// Already set, no worries...
	if (rendering_fx == kRenderFxGlowShell && rendering_color[0] == 0.0 && rendering_color[1] == 100.0
		&& rendering_color[2] == 200.0 && rendering_render == kRenderNormal && rendering_amount == 25.0)
		return
	
	// Save player's old rendering
	g_iFrozenRenderingFx[id] = get_entvar(id, var_renderfx)
	get_entvar(id, var_rendercolor, g_fFrozenRenderingColor[id])
	g_iFrozenRenderingRender[id] = get_entvar(id, var_rendermode)
	get_entvar(id, var_renderamt, g_fFrozenRenderingAmount[id])
	
	// Light blue glow while frozen
	Set_Rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
}

// Remove freeze task
public RemoveFreeze(taskid)
{
	// Remove frozen flag
	g_bIsFrozen[ID_FROST_REMOVE] = false
	
	// Restore rendering
	new iRed = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][0]),
	iGreen = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][1]),
	iBlue = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][2])

	Set_Rendering(ID_FROST_REMOVE, g_iFrozenRenderingFx[ID_FROST_REMOVE], iRed, iGreen, iBlue, g_iFrozenRenderingRender[ID_FROST_REMOVE], floatround(g_fFrozenRenderingAmount[ID_FROST_REMOVE]))

	// Gradually remove screen's blue tint
	message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, ID_FROST_REMOVE)
	write_short((1<<12)) // duration
	write_short(0) // 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()
	
	// Broken glass sound
	static sound[SOUND_MAX_LENGTH]
	ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
	emit_sound(ID_FROST_REMOVE, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	
	// Get player's origin
	static origin[3]
	get_user_origin(ID_FROST_REMOVE, origin)
	
	// Glass shatter
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_BREAKMODEL) // TE id
	write_coord(origin[0]) // x
	write_coord(origin[1]) // y
	write_coord(origin[2]+24) // z
	write_coord(16) // size x
	write_coord(16) // size y
	write_coord(16) // size z
	write_coord(random_num(-50, 50)) // velocity x
	write_coord(random_num(-50, 50)) // velocity y
	write_coord(25) // velocity z
	write_byte(10) // random velocity
	write_short(g_iGlassSpr) // model
	write_byte(10) // count
	write_byte(25) // life
	write_byte(BREAK_GLASS) // flags
	message_end()
	
	ExecuteForward(g_iForwards[FW_USER_UNFROZEN], g_iForwardReturn, ID_FROST_REMOVE)
}

// Frost Grenade: Freeze Blast
create_blast3(const Float:originF[3])
{
	// Smallest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Medium ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
	
	// Largest ring
	engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
	write_byte(TE_BEAMCYLINDER) // TE id
	engfunc(EngFunc_WriteCoord, originF[0]) // x
	engfunc(EngFunc_WriteCoord, originF[1]) // y
	engfunc(EngFunc_WriteCoord, originF[2]) // z
	engfunc(EngFunc_WriteCoord, originF[0]) // x axis
	engfunc(EngFunc_WriteCoord, originF[1]) // y axis
	engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
	write_short(g_iExplodeSpr) // 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(100) // green
	write_byte(200) // blue
	write_byte(200) // brightness
	write_byte(0) // speed
	message_end()
}
Ok so you used this and put grom above forceshield good!

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 525
Joined: 2 Years Ago
Has thanked: 19 times
Been thanked: 1 time
Contact:

#27

Post by czirimbolo » 11 Months Ago

Yes and its working good, without those effects with skulls.
Image

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#28

Post by Raheem » 11 Months Ago

Use ze_frost.sma in this post viewtopic.php?p=8581#p8581 and the skulls effect will works fine.

WHY I DID IT..
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#29

Post by Mark » 11 Months Ago

Raheem wrote:
11 Months Ago
Use ze_frost.sma in this post viewtopic.php?p=8581#p8581 and the skulls effect will works fine.

WHY I DID IT..
Already fixed it your late

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#30

Post by Raheem » 11 Months Ago

Raheem wrote:
1 Year Ago
Here the one with effects, i added to it force grenade support:
    1. #include <zombie_escape>
    2.  
    3. native ze_have_shield_nade(id)
    4.  
    5. // Setting File
    6. new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
    7.  
    8. // Defines
    9. #define MODEL_MAX_LENGTH 64
    10. #define SOUND_MAX_LENGTH 64
    11. #define SPRITE_MAX_LENGTH 64
    12. #define TASK_FROST_REMOVE 200
    13. #define ID_FROST_REMOVE (taskid - TASK_FROST_REMOVE)
    14. #define TASK_FREEZE 2018
    15.  
    16. // Default Sounds
    17. new const szFrostGrenadeExplodeSound[][] =
    18. {
    19.     "warcraft3/frostnova.wav"
    20. }
    21.  
    22. new const szFrostGrenadePlayerSound[][] =
    23. {
    24.     "warcraft3/impalehit.wav"
    25. }
    26.  
    27. new const szFrostGrenadeBreakSound[][] =
    28. {
    29.     "warcraft3/impalelaunch1.wav"
    30. }
    31. new g_frostexp
    32. new g_frost_gibs
    33.  
    34. // Default Models
    35. new g_v_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/v_grenade_frost.mdl"
    36. new g_p_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/p_grenade_frost.mdl"
    37. new g_w_szFrostGrenadeModel[MODEL_MAX_LENGTH] = "models/zombie_escape/w_grenade_frost.mdl"
    38.  
    39. // Default Sprites
    40. new g_szGrenadeTrailSprite[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
    41. new g_szGrenadeRingSprite[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
    42. new g_szGrenadeGlassSprite[SPRITE_MAX_LENGTH] = "models/glassgibs.mdl"
    43.  
    44. // Dynamic Arrays
    45. new Array:g_szFrostGrenadeExplodeSound
    46. new Array:g_szFrostGrenadePlayerSound
    47. new Array:g_szFrostGrenadeBreakSound
    48.  
    49. // Forwards
    50. enum _:TOTAL_FORWARDS
    51. {
    52.     FW_USER_FREEZE_PRE = 0,
    53.     FW_USER_UNFROZEN
    54. }
    55.  
    56. new g_iForwards[TOTAL_FORWARDS]
    57. new g_iForwardReturn
    58.  
    59. // Variables
    60. new bool:g_bIsFrozen[33],
    61.     bool:g_bZombieReleased,
    62.     g_iFrozenRenderingFx[33],
    63.     Float:g_fFrozenRenderingColor[33][3],
    64.     g_iFrozenRenderingRender[33],
    65.     Float:g_fFrozenRenderingAmount[33],
    66.     g_iMaxClients
    67.  
    68. // Sprites
    69. new g_iTrailSpr,
    70.     g_iExplodeSpr,
    71.     g_iGlassSpr
    72.  
    73. // Cvar
    74. new g_pCvarFrostDuration,
    75.     g_pCvarFrostHudIcon,
    76.     g_pCvarFrozenDamage,
    77.     g_pCvarFrostRadius,
    78.     g_pCvarHitType
    79.  
    80. public plugin_init()
    81. {
    82.     register_plugin("[ZE] Frost Nade", ZE_VERSION, AUTHORS)
    83.    
    84.     // Hook Chains
    85.     RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    86.     RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
    87.     RegisterHookChain(RG_CBasePlayer_PreThink, "Fw_PreThink_Post", 1)
    88.    
    89.     // Events
    90.     register_event("HLTV", "New_Round", "a", "1=0", "2=0")
    91.    
    92.     // Hams
    93.     RegisterHam(Ham_Think, "grenade", "Fw_ThinkGrenade_Post", 1)   
    94.    
    95.     // Fakemeta
    96.     register_forward(FM_SetModel, "Fw_SetModel_Post", 1)
    97.    
    98.     // Forwards
    99.     g_iForwards[FW_USER_FREEZE_PRE] = CreateMultiForward("ze_frost_pre", ET_CONTINUE, FP_CELL)
    100.     g_iForwards[FW_USER_UNFROZEN] = CreateMultiForward("ze_frost_unfreeze", ET_IGNORE, FP_CELL)
    101.    
    102.     // Cvars
    103.     g_pCvarFrostDuration = register_cvar("ze_frost_duration", "3")
    104.     g_pCvarFrostHudIcon = register_cvar("ze_frost_hud_icon", "1")
    105.     g_pCvarFrozenDamage = register_cvar("ze_freeze_damage", "0")
    106.     g_pCvarFrostRadius = register_cvar("ze_freeze_radius", "240.0")
    107.     g_pCvarHitType = register_cvar("ze_freeze_hit_type", "0")
    108.    
    109.     // Static Values
    110.     g_iMaxClients = get_member_game(m_nMaxPlayers)
    111. }
    112.  
    113. public plugin_natives()
    114. {
    115.     register_native("ze_zombie_in_forst", "native_ze_zombie_in_forst", 1)
    116.     register_native("ze_set_frost_grenade", "native_ze_set_frost_grenade", 1)
    117. }
    118.  
    119. public native_ze_zombie_in_forst(id)
    120. {
    121.     if (!is_user_alive(id))
    122.     {
    123.         return -1
    124.     }
    125.    
    126.     return g_bIsFrozen[id]
    127. }
    128.  
    129. public native_ze_set_frost_grenade(id, set)
    130. {
    131.     if (!is_user_alive(id))
    132.     {
    133.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
    134.         return -1;
    135.     }
    136.    
    137.     // Unfreeze
    138.     if (!set)
    139.     {
    140.         // Not frozen
    141.         if (!g_bIsFrozen[id])
    142.             return true
    143.        
    144.         // Remove freeze right away and stop the task
    145.         RemoveFreeze(id+TASK_FROST_REMOVE)
    146.         remove_task(id+TASK_FROST_REMOVE)
    147.         return true
    148.     }
    149.    
    150.     return set_freeze(id)
    151. }
    152.  
    153. public plugin_precache()
    154. {
    155.     // Initialize arrays
    156.     g_szFrostGrenadeExplodeSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    157.     g_szFrostGrenadePlayerSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    158.     g_szFrostGrenadeBreakSound = ArrayCreate(SOUND_MAX_LENGTH, 1)
    159.    
    160.     // Load from external file
    161.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
    162.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
    163.     amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
    164.    
    165.     // If we couldn't load custom sounds from file, use and save default ones
    166.    
    167.     new iIndex
    168.    
    169.     if (ArraySize(g_szFrostGrenadeExplodeSound) == 0)
    170.     {
    171.         for (iIndex = 0; iIndex < sizeof szFrostGrenadeExplodeSound; iIndex++)
    172.             ArrayPushString(g_szFrostGrenadeExplodeSound, szFrostGrenadeExplodeSound[iIndex])
    173.        
    174.         // Save to external file
    175.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE EXPLODE", g_szFrostGrenadeExplodeSound)
    176.     }
    177.    
    178.     if (ArraySize(g_szFrostGrenadePlayerSound) == 0)
    179.     {
    180.         for (iIndex = 0; iIndex < sizeof szFrostGrenadePlayerSound; iIndex++)
    181.             ArrayPushString(g_szFrostGrenadePlayerSound, szFrostGrenadePlayerSound[iIndex])
    182.        
    183.         // Save to external file
    184.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE PLAYER", g_szFrostGrenadePlayerSound)
    185.     }
    186.    
    187.     if (ArraySize(g_szFrostGrenadeBreakSound) == 0)
    188.     {
    189.         for (iIndex = 0; iIndex < sizeof szFrostGrenadeBreakSound; iIndex++)
    190.             ArrayPushString(g_szFrostGrenadeBreakSound, szFrostGrenadeBreakSound[iIndex])
    191.        
    192.         // Save to external file
    193.         amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Sounds", "FROST GRENADE BREAK", g_szFrostGrenadeBreakSound)
    194.     }
    195.    
    196.     // Load from external file, save if not found
    197.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel, charsmax(g_v_szFrostGrenadeModel)))
    198.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "V_GRENADE FROST", g_v_szFrostGrenadeModel)
    199.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel, charsmax(g_p_szFrostGrenadeModel)))
    200.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "P_GRENADE FROST", g_p_szFrostGrenadeModel)
    201.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel, charsmax(g_w_szFrostGrenadeModel)))
    202.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Weapon Models", "W_GRENADE FROST", g_w_szFrostGrenadeModel)
    203.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite, charsmax(g_szGrenadeTrailSprite)))
    204.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "TRAIL", g_szGrenadeTrailSprite)
    205.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite, charsmax(g_szGrenadeRingSprite)))
    206.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "RING", g_szGrenadeRingSprite)
    207.     if (!amx_load_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite, charsmax(g_szGrenadeGlassSprite)))
    208.         amx_save_setting_string(ZE_SETTING_RESOURCES, "Grenade Sprites", "GLASS", g_szGrenadeGlassSprite)
    209.    
    210.     // Precache sounds
    211.    
    212.     new szSound[SOUND_MAX_LENGTH]
    213.    
    214.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeExplodeSound); iIndex++)
    215.     {
    216.         ArrayGetString(g_szFrostGrenadeExplodeSound, iIndex, szSound, charsmax(szSound))
    217.         precache_sound(szSound)
    218.     }
    219.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadePlayerSound); iIndex++)
    220.     {
    221.         ArrayGetString(g_szFrostGrenadePlayerSound, iIndex, szSound, charsmax(szSound))
    222.         precache_sound(szSound)
    223.     }
    224.     for (iIndex = 0; iIndex < ArraySize(g_szFrostGrenadeBreakSound); iIndex++)
    225.     {
    226.         ArrayGetString(g_szFrostGrenadeBreakSound, iIndex, szSound, charsmax(szSound))
    227.         precache_sound(szSound)
    228.     }
    229.    
    230.     // Precache models
    231.     precache_model(g_v_szFrostGrenadeModel)
    232.     precache_model(g_p_szFrostGrenadeModel)
    233.     precache_model(g_w_szFrostGrenadeModel)
    234.    
    235.     // Precache sprites
    236.     g_iTrailSpr = precache_model(g_szGrenadeTrailSprite)
    237.     g_iExplodeSpr = precache_model(g_szGrenadeRingSprite)
    238.     g_iGlassSpr = precache_model(g_szGrenadeGlassSprite)
    239.     g_frostexp = precache_model("sprites/frost_kurukafa.spr")
    240.     g_frost_gibs = precache_model("sprites/frost_gib.spr")
    241. }
    242.  
    243. public ze_user_humanized(id)
    244. {
    245.     // Set custom grenade model
    246.     cs_set_player_view_model(id, CSW_FLASHBANG, g_v_szFrostGrenadeModel)
    247.     cs_set_player_weap_model(id, CSW_FLASHBANG, g_p_szFrostGrenadeModel)
    248.     cs_set_player_view_model(id, CSW_SMOKEGRENADE, g_v_szFrostGrenadeModel)
    249.     cs_set_player_weap_model(id, CSW_SMOKEGRENADE, g_p_szFrostGrenadeModel)
    250.    
    251.     // If frozen, remove freeze after player is cured
    252.     if (g_bIsFrozen[id])
    253.     {
    254.         // Update rendering values first
    255.         ApplyFrozenRendering(id)
    256.        
    257.         // Remove freeze right away and stop the task
    258.         RemoveFreeze(id+TASK_FROST_REMOVE)
    259.         remove_task(id+TASK_FROST_REMOVE)
    260.     }
    261. }
    262.  
    263. public Fw_PreThink_Post(id)
    264. {
    265.     if (!ze_is_user_zombie(id))
    266.         return
    267.  
    268.     if (g_bIsFrozen[id] && g_bZombieReleased)
    269.     {
    270.         // Stop and Freeze Zombie
    271.         set_entvar(id, var_velocity, Float:{0.0,0.0,0.0})
    272.         set_entvar(id, var_maxspeed, 1.0)
    273.         ApplyFrozenRendering(id)
    274.     }
    275. }
    276.  
    277. public client_disconnected(id)
    278. {
    279.     g_bIsFrozen[id] = false
    280.     remove_task(id+TASK_FROST_REMOVE)
    281. }
    282.  
    283. public New_Round()
    284. {
    285.     remove_task(TASK_FREEZE)
    286.     g_bZombieReleased = false
    287. }
    288.  
    289. public Fw_TraceAttack_Pre(iVictim, iAttacker)
    290. {
    291.     // Block damage while frozen
    292.     if ((get_pcvar_num(g_pCvarFrozenDamage) == 0) && g_bIsFrozen[iVictim])
    293.         return HC_SUPERCEDE
    294.    
    295.     return HC_CONTINUE
    296. }
    297.  
    298. public Fw_PlayerKilled_Post(iVictim)
    299. {
    300.     // Frozen player being killed
    301.     if (g_bIsFrozen[iVictim])
    302.     {
    303.         // Remove freeze right away and stop the task
    304.         RemoveFreeze(iVictim+TASK_FROST_REMOVE)
    305.         remove_task(iVictim+TASK_FROST_REMOVE)
    306.     }
    307. }
    308.  
    309. public ze_zombie_release()
    310. {
    311.     g_bZombieReleased = true
    312. }
    313.  
    314. public Fw_SetModel_Post(entity, const model[])
    315. {
    316.     if (ze_have_shield_nade(pev(entity, pev_owner)))
    317.         return FMRES_IGNORED
    318.    
    319.     // We don't care
    320.     if (strlen(model) < 8)
    321.         return FMRES_IGNORED
    322.    
    323.     // Get damage time of grenade
    324.     static Float:dmgtime
    325.     get_entvar(entity, var_dmgtime, dmgtime)
    326.    
    327.     // Grenade not yet thrown
    328.     if (dmgtime == 0.0)
    329.         return FMRES_IGNORED
    330.    
    331.     // Grenade's owner is zombie?
    332.     if (ze_is_user_zombie(get_entvar(entity, var_owner)))
    333.         return FMRES_IGNORED
    334.  
    335.     // Flashbang or Smoke
    336.     if ((model[9] == 'f' && model[10] == 'l') || (model[9] == 's' && model[10] == 'm'))
    337.     {
    338.         // Give it a glow
    339.         Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
    340.        
    341.         // And a colored trail
    342.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    343.         write_byte(TE_BEAMFOLLOW) // TE id
    344.         write_short(entity) // entity
    345.         write_short(g_iTrailSpr) // sprite
    346.         write_byte(10) // life
    347.         write_byte(10) // width
    348.         write_byte(0) // r
    349.         write_byte(100) // g
    350.         write_byte(200) // b
    351.         write_byte(200) // brightness
    352.         message_end()
    353.        
    354.         // Set grenade type on the thrown grenade entity
    355.         set_entvar(entity, var_flTimeStepSound, 3333.0)
    356.     }
    357.    
    358.     // Set w_ model
    359.     if (equali(model, "models/w_flashbang.mdl") || equali(model, "models/w_smokegrenade.mdl"))
    360.     {
    361.         engfunc(EngFunc_SetModel, entity, g_w_szFrostGrenadeModel)
    362.         return FMRES_SUPERCEDE
    363.     }
    364.    
    365.     return FMRES_IGNORED
    366. }
    367.  
    368. public Fw_ThinkGrenade_Post(entity)
    369. {
    370.     // Invalid entity
    371.     if (!pev_valid(entity))
    372.         return HAM_IGNORED
    373.    
    374.     // Get damage time of grenade
    375.     static Float:dmgtime
    376.     get_entvar(entity, var_dmgtime, dmgtime)
    377.    
    378.     // Check if it's time to go off
    379.     if (dmgtime > get_gametime())
    380.         return HAM_IGNORED
    381.    
    382.     // Check if it's one of our custom nades
    383.     switch (get_entvar(entity, var_flTimeStepSound))
    384.     {
    385.         case 3333.0: // Frost Grenade
    386.         {
    387.             frost_explode(entity)
    388.             return HAM_SUPERCEDE
    389.         }
    390.     }
    391.     return HAM_IGNORED
    392. }
    393.  
    394. // Frost Grenade Explosion
    395. frost_explode(ent)
    396. {
    397.     // Get origin
    398.     static Float:origin[3]
    399.     get_entvar(ent, var_origin, origin)
    400.    
    401.     // Make the explosion
    402.     create_blast3(origin)
    403.     message_begin (MSG_BROADCAST,SVC_TEMPENTITY)
    404.     write_byte( TE_SPRITETRAIL ) // Throws a shower of sprites or models
    405.     engfunc(EngFunc_WriteCoord, origin[ 0 ]) // start pos
    406.     engfunc(EngFunc_WriteCoord, origin[ 1 ])
    407.     engfunc(EngFunc_WriteCoord, origin[ 2 ] + 200.0)
    408.     engfunc(EngFunc_WriteCoord, origin[ 0 ]) // velocity
    409.     engfunc(EngFunc_WriteCoord, origin[ 1 ])
    410.     engfunc(EngFunc_WriteCoord, origin[ 2 ] + 30.0)
    411.     write_short(g_frost_gibs) // spr
    412.     write_byte(60) // (count)
    413.     write_byte(random_num(27,30)) // (life in 0.1's)
    414.     write_byte(2) // byte (scale in 0.1's)
    415.     write_byte(50) // (velocity along vector in 10's)
    416.     write_byte(10) // (randomness of velocity in 10's)
    417.     message_end()
    418.    
    419.     // Frost nade explode sound
    420.     static sound[SOUND_MAX_LENGTH]
    421.     ArrayGetString(g_szFrostGrenadeExplodeSound, random_num(0, ArraySize(g_szFrostGrenadeExplodeSound) - 1), sound, charsmax(sound))
    422.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    423.    
    424.     // Collisions
    425.     if (!get_pcvar_num(g_pCvarHitType))
    426.     {
    427.         new victim = -1
    428.        
    429.         while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, get_pcvar_float(g_pCvarFrostRadius))) != 0)
    430.         {
    431.             // Only effect alive zombies, If player not released yet don't freeze him
    432.             if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || !g_bZombieReleased)
    433.                 continue
    434.            
    435.             set_freeze(victim)
    436.         }
    437.     }
    438.     else
    439.     {
    440.         new Float:flNadeOrigin[3], Float:flVictimOrigin[3], Float:flDistance, tr = create_tr2(), Float:flFraction
    441.         get_entvar(ent, var_origin, flNadeOrigin)
    442.        
    443.         for(new iVictim = 1; iVictim <= g_iMaxClients; iVictim++)
    444.         {
    445.             if (!is_user_alive(iVictim) || !ze_is_user_zombie(iVictim) || !g_bZombieReleased)
    446.                 continue
    447.            
    448.             get_entvar(iVictim, var_origin, flVictimOrigin)
    449.            
    450.             // Get distance between nade and player
    451.             flDistance = vector_distance(flNadeOrigin, flVictimOrigin)
    452.            
    453.             if(flDistance > get_pcvar_float(g_pCvarFrostRadius))
    454.                 continue
    455.            
    456.             flNadeOrigin[2] += 2.0;
    457.             engfunc(EngFunc_TraceLine, flNadeOrigin, flVictimOrigin, DONT_IGNORE_MONSTERS, ent, tr);
    458.             flNadeOrigin[2] -= 2.0;
    459.            
    460.             get_tr2(tr, TR_flFraction, flFraction);
    461.            
    462.             if(flFraction != 1.0 && get_tr2(tr, TR_pHit) != iVictim)
    463.                 continue;
    464.            
    465.             set_freeze(iVictim)
    466.         }
    467.        
    468.         // Free the trace handler
    469.         free_tr2(tr);
    470.     }
    471.    
    472.     // Get rid of the grenade
    473.     engfunc(EngFunc_RemoveEntity, ent)
    474. }
    475.  
    476. set_freeze(victim)
    477. {
    478.     // Already frozen
    479.     if (g_bIsFrozen[victim])
    480.         return false
    481.    
    482.     // Allow other plugins to decide whether player should be frozen or not
    483.     ExecuteForward(g_iForwards[FW_USER_FREEZE_PRE], g_iForwardReturn, victim)
    484.    
    485.     if (g_iForwardReturn >= PLUGIN_HANDLED)
    486.     {
    487.         // Get player's origin
    488.         static origin2[3]
    489.         get_user_origin(victim, origin2)
    490.        
    491.         // Broken glass sound
    492.         static sound[SOUND_MAX_LENGTH]
    493.         ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
    494.         emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    495.        
    496.         // Glass shatter
    497.         message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
    498.         write_byte(TE_BREAKMODEL) // TE id
    499.         write_coord(origin2[0]) // x
    500.         write_coord(origin2[1]) // y
    501.         write_coord(origin2[2]+24) // z
    502.         write_coord(16) // size x
    503.         write_coord(16) // size y
    504.         write_coord(16) // size z
    505.         write_coord(random_num(-50, 50)) // velocity x
    506.         write_coord(random_num(-50, 50)) // velocity y
    507.         write_coord(25) // velocity z
    508.         write_byte(10) // random velocity
    509.         write_short(g_iGlassSpr) // model
    510.         write_byte(10) // count
    511.         write_byte(25) // life
    512.         write_byte(0x01) // flags
    513.         message_end()
    514.        
    515.         return false
    516.     }
    517.    
    518.     // Freeze icon?
    519.     if (get_pcvar_num(g_pCvarFrostHudIcon))
    520.     {
    521.         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, victim)
    522.         write_byte(0) // damage save
    523.         write_byte(0) // damage take
    524.         write_long(DMG_DROWN) // damage type - DMG_FREEZE
    525.         write_coord(0) // x
    526.         write_coord(0) // y
    527.         write_coord(0) // z
    528.         message_end()
    529.     }
    530.    
    531.     // Set frozen flag
    532.     g_bIsFrozen[victim] = true
    533.    
    534.     // Freeze sound
    535.     static sound[SOUND_MAX_LENGTH]
    536.     ArrayGetString(g_szFrostGrenadePlayerSound, random_num(0, ArraySize(g_szFrostGrenadePlayerSound) - 1), sound, charsmax(sound))
    537.     emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    538.    
    539.     // Add a blue tint to their screen
    540.     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, victim)
    541.     write_short(0) // duration
    542.     write_short(0) // hold time
    543.     write_short(0x0004) // fade type
    544.     write_byte(0) // red
    545.     write_byte(50) // green
    546.     write_byte(200) // blue
    547.     write_byte(100) // alpha
    548.     message_end()
    549.    
    550.     // Update player entity rendering
    551.     ApplyFrozenRendering(victim)
    552.    
    553.     // Set a task to remove the freeze
    554.     set_task(get_pcvar_float(g_pCvarFrostDuration), "RemoveFreeze", victim+TASK_FROST_REMOVE)
    555.     return true
    556. }
    557.  
    558. ApplyFrozenRendering(id)
    559. {
    560.     // Get current rendering
    561.     new rendering_fx = get_entvar(id, var_renderfx)
    562.     new Float:rendering_color[3]
    563.     get_entvar(id, var_rendercolor, rendering_color)
    564.     new rendering_render = get_entvar(id, var_rendermode)
    565.     new Float:rendering_amount
    566.     get_entvar(id, var_renderamt, rendering_amount)
    567.    
    568.     // Already set, no worries...
    569.     if (rendering_fx == kRenderFxGlowShell && rendering_color[0] == 0.0 && rendering_color[1] == 100.0
    570.         && rendering_color[2] == 200.0 && rendering_render == kRenderNormal && rendering_amount == 25.0)
    571.         return
    572.    
    573.     // Save player's old rendering
    574.     g_iFrozenRenderingFx[id] = get_entvar(id, var_renderfx)
    575.     get_entvar(id, var_rendercolor, g_fFrozenRenderingColor[id])
    576.     g_iFrozenRenderingRender[id] = get_entvar(id, var_rendermode)
    577.     get_entvar(id, var_renderamt, g_fFrozenRenderingAmount[id])
    578.    
    579.     // Light blue glow while frozen
    580.     Set_Rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
    581. }
    582.  
    583. // Remove freeze task
    584. public RemoveFreeze(taskid)
    585. {
    586.     // Remove frozen flag
    587.     g_bIsFrozen[ID_FROST_REMOVE] = false
    588.    
    589.     // Restore rendering
    590.     new iRed = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][0]),
    591.     iGreen = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][1]),
    592.     iBlue = floatround(g_fFrozenRenderingColor[ID_FROST_REMOVE][2])
    593.  
    594.     Set_Rendering(ID_FROST_REMOVE, g_iFrozenRenderingFx[ID_FROST_REMOVE], iRed, iGreen, iBlue, g_iFrozenRenderingRender[ID_FROST_REMOVE], floatround(g_fFrozenRenderingAmount[ID_FROST_REMOVE]))
    595.  
    596.     // Gradually remove screen's blue tint
    597.     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, ID_FROST_REMOVE)
    598.     write_short((1<<12)) // duration
    599.     write_short(0) // hold time
    600.     write_short(0x0000) // fade type
    601.     write_byte(0) // red
    602.     write_byte(50) // green
    603.     write_byte(200) // blue
    604.     write_byte(100) // alpha
    605.     message_end()
    606.    
    607.     // Broken glass sound
    608.     static sound[SOUND_MAX_LENGTH]
    609.     ArrayGetString(g_szFrostGrenadeBreakSound, random_num(0, ArraySize(g_szFrostGrenadeBreakSound) - 1), sound, charsmax(sound))
    610.     emit_sound(ID_FROST_REMOVE, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    611.    
    612.     // Get player's origin
    613.     static origin[3]
    614.     get_user_origin(ID_FROST_REMOVE, origin)
    615.    
    616.     // Glass shatter
    617.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
    618.     write_byte(TE_BREAKMODEL) // TE id
    619.     write_coord(origin[0]) // x
    620.     write_coord(origin[1]) // y
    621.     write_coord(origin[2]+24) // z
    622.     write_coord(16) // size x
    623.     write_coord(16) // size y
    624.     write_coord(16) // size z
    625.     write_coord(random_num(-50, 50)) // velocity x
    626.     write_coord(random_num(-50, 50)) // velocity y
    627.     write_coord(25) // velocity z
    628.     write_byte(10) // random velocity
    629.     write_short(g_iGlassSpr) // model
    630.     write_byte(10) // count
    631.     write_byte(25) // life
    632.     write_byte(BREAK_GLASS) // flags
    633.     message_end()
    634.    
    635.     ExecuteForward(g_iForwards[FW_USER_UNFROZEN], g_iForwardReturn, ID_FROST_REMOVE)
    636. }
    637.  
    638. // Frost Grenade: Freeze Blast
    639. create_blast3(const Float:originF[3])
    640. {
    641.    
    642.     // Frost Sprite
    643.  
    644.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    645.     write_byte (TE_SPRITE) // TE ID
    646.     engfunc(EngFunc_WriteCoord, originF[0]) // Position X
    647.     engfunc(EngFunc_WriteCoord, originF[1]) // Y
    648.     engfunc(EngFunc_WriteCoord, originF[2] + 50.0) // Z
    649.     write_short(g_frostexp) // Sprite index
    650.     write_byte(20) // Size of sprite
    651.     write_byte(200) // Low For Light | More For Dark !
    652.     message_end()
    653.  
    654.    
    655.     // Smallest ring
    656.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    657.     write_byte(TE_BEAMCYLINDER) // TE id
    658.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    659.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    660.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    661.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    662.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    663.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
    664.     write_short(g_iExplodeSpr) // sprite
    665.     write_byte(0) // startframe
    666.     write_byte(0) // framerate
    667.     write_byte(4) // life
    668.     write_byte(60) // width
    669.     write_byte(0) // noise
    670.     write_byte(0) // red
    671.     write_byte(100) // green
    672.     write_byte(200) // blue
    673.     write_byte(200) // brightness
    674.     write_byte(0) // speed
    675.     message_end()
    676.    
    677.     // Medium ring
    678.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    679.     write_byte(TE_BEAMCYLINDER) // TE id
    680.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    681.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    682.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    683.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    684.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    685.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
    686.     write_short(g_iExplodeSpr) // sprite
    687.     write_byte(0) // startframe
    688.     write_byte(0) // framerate
    689.     write_byte(4) // life
    690.     write_byte(60) // width
    691.     write_byte(0) // noise
    692.     write_byte(0) // red
    693.     write_byte(100) // green
    694.     write_byte(200) // blue
    695.     write_byte(200) // brightness
    696.     write_byte(0) // speed
    697.     message_end()
    698.    
    699.     // Largest ring
    700.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    701.     write_byte(TE_BEAMCYLINDER) // TE id
    702.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    703.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    704.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    705.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    706.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    707.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
    708.     write_short(g_iExplodeSpr) // sprite
    709.     write_byte(0) // startframe
    710.     write_byte(0) // framerate
    711.     write_byte(4) // life
    712.     write_byte(60) // width
    713.     write_byte(0) // noise
    714.     write_byte(0) // red
    715.     write_byte(100) // green
    716.     write_byte(200) // blue
    717.     write_byte(200) // brightness
    718.     write_byte(0) // speed
    719.     message_end()
    720. }
I just added 3 lines:
    1.     if (ze_have_shield_nade(pev(entity, pev_owner)))
    2.         return FMRES_IGNORED
I published it early but you both don't check it.
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests