Nades Effect ZP 4.3

Unpaid Requests, Public Plugins
Post Reply
Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

Nades Effect ZP 4.3

#1

Post by Templaso » 4 years ago

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

Here are the sprites: https://www.mediafire.com/file/uuu9vl4b ... s.rar/file

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 4 years ago

He who fails to plan is planning to fail

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#3

Post by Templaso » 4 years ago

Yes but this are different effects

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 4 years ago

Use any of the ones i posted, and you will need only to change the sprites inside the plugin. You can use sprite viewer to see which ones should be replaced.
He who fails to plan is planning to fail

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#5

Post by Raheem » 4 years ago

Try:
He who fails to plan is planning to fail

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#6

Post by Templaso » 4 years ago

So i need to remove ze_frost and ze_fire and put that new plugin for both?

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#7

Post by Templaso » 4 years ago

In that new effect it s saying something about flare effect

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#8

Post by Raheem » 4 years ago

No just install the plugin i posted, let me know what the problem you faced.
He who fails to plan is planning to fail

Templaso
Senior Member
Senior Member
Romania
Posts: 119
Joined: 5 years ago
Location: Bucharest
Contact:

#9

Post by Templaso » 4 years ago

It worked i edit and fire and work

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 9 guests