Advertisement
crywolfy

zp50_grenade_frost.sma

Aug 19th, 2014
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.43 KB | None | 0 0
  1.  
  2. #include <amxmodx>
  3. #include <fun>
  4. #include <fakemeta>
  5. #include <hamsandwich>
  6.  
  7. // Default sounds
  8. new const sound_grenade_frost_explode[][] = { "warcraft3/frostnova.wav" }
  9. new const sound_grenade_frost_player[][] = { "warcraft3/impalehit.wav" }
  10. new const sound_grenade_frost_break[][] = { "warcraft3/impalelaunch1.wav" }
  11.  
  12. #define MODEL_MAX_LENGTH 64
  13. #define SOUND_MAX_LENGTH 64
  14. #define SPRITE_MAX_LENGTH 64
  15.  
  16. // Sprites
  17. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  18. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  19. new g_sprite_grenade_glass[SPRITE_MAX_LENGTH] = "models/glassgibs.mdl"
  20.  
  21. new Array:g_sound_grenade_frost_explode
  22. new Array:g_sound_grenade_frost_player
  23. new Array:g_sound_grenade_frost_break
  24.  
  25. #define GRAVITY_HIGH 999999.9
  26. #define GRAVITY_NONE 0.000001
  27.  
  28. #define TASK_FROST_REMOVE 100
  29. #define ID_FROST_REMOVE (taskid - TASK_FROST_REMOVE)
  30.  
  31. #define MAXPLAYERS 32
  32.  
  33. #define flag_get(%1,%2) (%1 & (1 << (%2 & 31)))
  34. #define flag_get_boolean(%1,%2) (flag_get(%1,%2) ? true : false)
  35. #define flag_set(%1,%2) %1 |= (1 << (%2 & 31))
  36. #define flag_unset(%1,%2) %1 &= ~(1 << (%2 & 31))
  37.  
  38. // Hack to be able to use Ham_Player_ResetMaxSpeed (by joaquimandrade)
  39. new Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
  40.  
  41. // Explosion radius for custom grenades
  42. const Float:NADE_EXPLOSION_RADIUS = 240.0
  43.  
  44. // HACK: pev_ field used to store custom nade types and their values
  45. const PEV_NADE_TYPE = pev_flTimeStepSound
  46. const NADE_TYPE_FROST = 3333
  47.  
  48. // Some constants
  49. const UNIT_SECOND = (1<<12)
  50. const BREAK_GLASS = 0x01
  51. const FFADE_IN = 0x0000
  52. const FFADE_STAYOUT = 0x0004
  53.  
  54. // Custom Forwards
  55. enum _:TOTAL_FORWARDS
  56. {
  57.     FW_USER_FREEZE_PRE = 0,
  58.     FW_USER_UNFROZEN
  59. }
  60.  
  61. new g_Forwards[TOTAL_FORWARDS]
  62. new g_ForwardResult
  63.  
  64. new g_IsFrozen
  65. new Float:g_FrozenGravity[MAXPLAYERS+1]
  66. new g_FrozenRenderingFx[MAXPLAYERS+1]
  67. new Float:g_FrozenRenderingColor[MAXPLAYERS+1][3]
  68. new g_FrozenRenderingRender[MAXPLAYERS+1]
  69. new Float:g_FrozenRenderingAmount[MAXPLAYERS+1]
  70.  
  71. new g_MsgDamage, g_MsgScreenFade
  72. new g_trailSpr, g_exploSpr, g_glassSpr
  73.  
  74. new cvar_grenade_frost_duration, cvar_grenade_frost_hudicon
  75.  
  76. public plugin_init()
  77. {
  78.     register_plugin("[ZP] Grenade: Frost", "0.0.1", "ZP Dev Team")
  79.    
  80.     RegisterHam(Ham_Player_ResetMaxSpeed, "player", "fw_ResetMaxSpeed_Post", 1)
  81.     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  82.     RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack")
  83.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  84.     register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  85.     register_forward(FM_SetModel, "fw_SetModel")
  86.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  87.    
  88.     g_MsgDamage = get_user_msgid("Damage")
  89.     g_MsgScreenFade = get_user_msgid("ScreenFade")
  90.    
  91.     cvar_grenade_frost_duration = register_cvar("zp_grenade_frost_duration", "3")
  92.     cvar_grenade_frost_hudicon = register_cvar("zp_grenade_frost_hudicon", "1")
  93.    
  94.     g_Forwards[FW_USER_FREEZE_PRE] = CreateMultiForward("zp_fw_grenade_frost_pre", ET_CONTINUE, FP_CELL)
  95.     g_Forwards[FW_USER_UNFROZEN] = CreateMultiForward("zp_fw_grenade_frost_unfreeze", ET_IGNORE, FP_CELL)
  96. }
  97.  
  98. public plugin_natives()
  99. {
  100.     register_library("zp50_grenade_frost")
  101.     register_native("zp_grenade_frost_get", "native_grenade_frost_get")
  102.     register_native("zp_grenade_frost_set", "native_grenade_frost_set")
  103. }
  104.  
  105. public native_grenade_frost_get(plugin_id, num_params)
  106. {
  107.     new id = get_param(1)
  108.    
  109.     if (!is_user_alive(id))
  110.     {
  111.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  112.         return false;
  113.     }
  114.    
  115.     return flag_get_boolean(g_IsFrozen, id);
  116. }
  117.  
  118. public native_grenade_frost_set(plugin_id, num_params)
  119. {
  120.     new id = get_param(1)
  121.    
  122.     if (!is_user_alive(id))
  123.     {
  124.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  125.         return false;
  126.     }
  127.    
  128.     new set = get_param(2)
  129.    
  130.     // Unfreeze
  131.     if (!set)
  132.     {
  133.         // Not frozen
  134.         if (!flag_get(g_IsFrozen, id))
  135.             return true;
  136.        
  137.         // Remove freeze right away and stop the task
  138.         remove_freeze(id+TASK_FROST_REMOVE)
  139.         remove_task(id+TASK_FROST_REMOVE)
  140.         return true;
  141.     }
  142.    
  143.     return set_freeze(id);
  144. }
  145.  
  146. public plugin_precache()
  147. {
  148.     // Initialize arrays
  149.     g_sound_grenade_frost_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  150.     g_sound_grenade_frost_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  151.     g_sound_grenade_frost_break = ArrayCreate(SOUND_MAX_LENGTH, 1)
  152.    
  153.     // If we couldn't load custom sounds from file, use and save default ones
  154.     new index
  155.     if (ArraySize(g_sound_grenade_frost_explode) == 0)
  156.     {
  157.         for (index = 0; index < sizeof sound_grenade_frost_explode; index++)
  158.             ArrayPushString(g_sound_grenade_frost_explode, sound_grenade_frost_explode[index])
  159.     }
  160.     if (ArraySize(g_sound_grenade_frost_player) == 0)
  161.     {
  162.         for (index = 0; index < sizeof sound_grenade_frost_player; index++)
  163.             ArrayPushString(g_sound_grenade_frost_player, sound_grenade_frost_player[index])
  164.     }
  165.     if (ArraySize(g_sound_grenade_frost_break) == 0)
  166.     {
  167.         for (index = 0; index < sizeof sound_grenade_frost_break; index++)
  168.             ArrayPushString(g_sound_grenade_frost_break, sound_grenade_frost_break[index])
  169.     }
  170.    
  171.     // Precache sounds
  172.     new sound[SOUND_MAX_LENGTH]
  173.     for (index = 0; index < ArraySize(g_sound_grenade_frost_explode); index++)
  174.     {
  175.         ArrayGetString(g_sound_grenade_frost_explode, index, sound, charsmax(sound))
  176.         precache_sound(sound)
  177.     }
  178.     for (index = 0; index < ArraySize(g_sound_grenade_frost_player); index++)
  179.     {
  180.         ArrayGetString(g_sound_grenade_frost_player, index, sound, charsmax(sound))
  181.         precache_sound(sound)
  182.     }
  183.     for (index = 0; index < ArraySize(g_sound_grenade_frost_break); index++)
  184.     {
  185.         ArrayGetString(g_sound_grenade_frost_break, index, sound, charsmax(sound))
  186.         precache_sound(sound)
  187.     }
  188.    
  189.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  190.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  191.     g_glassSpr = precache_model(g_sprite_grenade_glass)
  192. }
  193.  
  194. public client_disconnect(id)
  195. {
  196.     flag_unset(g_IsFrozen, id)
  197.     remove_task(id+TASK_FROST_REMOVE)
  198. }
  199.  
  200. public fw_ResetMaxSpeed_Post(id)
  201. {
  202.     // Dead or not frozen
  203.     if (!is_user_alive(id) || !flag_get(g_IsFrozen, id))
  204.         return;
  205.    
  206.     // Prevent from moving
  207.     set_user_maxspeed(id, 1.0)
  208. }
  209.  
  210. // Ham Trace Attack Forward
  211. public fw_TraceAttack(victim, attacker)
  212. {
  213.     // Non-player damage or self damage
  214.     if (victim == attacker || !is_user_alive(attacker))
  215.         return HAM_IGNORED;
  216.    
  217.     // Block damage while frozen, as it makes killing zombies too easy
  218.     if (flag_get(g_IsFrozen, victim))
  219.         return HAM_SUPERCEDE;
  220.    
  221.     return HAM_IGNORED;
  222. }
  223.  
  224. // Ham Take Damage Forward (needed to block explosion damage too)
  225. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  226. {
  227.     // Non-player damage or self damage
  228.     if (victim == attacker || !is_user_alive(attacker))
  229.         return HAM_IGNORED;
  230.    
  231.     // Block damage while frozen, as it makes killing zombies too easy
  232.     if (flag_get(g_IsFrozen, victim))
  233.         return HAM_SUPERCEDE;
  234.    
  235.     return HAM_IGNORED;
  236. }
  237.  
  238. // Ham Player Killed Forward
  239. public fw_PlayerKilled(victim, attacker, shouldgib)
  240. {
  241.     // Frozen player being killed (usually caused by a 3rd party plugin, e.g. lasermines)
  242.     if (flag_get(g_IsFrozen, victim))
  243.     {
  244.         // Remove freeze right away and stop the task
  245.         remove_freeze(victim+TASK_FROST_REMOVE)
  246.         remove_task(victim+TASK_FROST_REMOVE)
  247.     }
  248. }
  249.  
  250. // Forward Player PreThink
  251. public fw_PlayerPreThink(id)
  252. {
  253.     // Not alive or not frozen
  254.     if (!is_user_alive(id) || !flag_get(g_IsFrozen, id))
  255.         return;
  256.    
  257.     // Stop motion
  258.     set_pev(id, pev_velocity, Float:{0.0,0.0,0.0})
  259. }
  260.  
  261. // Forward Set Model
  262. public fw_SetModel(entity, const model[])
  263. {
  264.     // We don't care
  265.     if (strlen(model) < 8)
  266.         return;
  267.    
  268.     // Narrow down our matches a bit
  269.     if (model[7] != 'w' || model[8] != '_')
  270.         return;
  271.    
  272.     // Get damage time of grenade
  273.     static Float:dmgtime
  274.     pev(entity, pev_dmgtime, dmgtime)
  275.    
  276.     // Grenade not yet thrown
  277.     if (dmgtime == 0.0)
  278.         return;
  279.    
  280.     // Flashbang
  281.     if (model[9] == 'f' && model[10] == 'l')
  282.     {
  283.         // Give it a glow
  284.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
  285.        
  286.         // And a colored trail
  287.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  288.         write_byte(TE_BEAMFOLLOW) // TE id
  289.         write_short(entity) // entity
  290.         write_short(g_trailSpr) // sprite
  291.         write_byte(10) // life
  292.         write_byte(10) // width
  293.         write_byte(0) // r
  294.         write_byte(100) // g
  295.         write_byte(200) // b
  296.         write_byte(200) // brightness
  297.         message_end()
  298.        
  299.         // Set grenade type on the thrown grenade entity
  300.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FROST)
  301.     }
  302. }
  303.  
  304. // Ham Grenade Think Forward
  305. public fw_ThinkGrenade(entity)
  306. {
  307.     // Invalid entity
  308.     if (!pev_valid(entity)) return HAM_IGNORED;
  309.    
  310.     // Get damage time of grenade
  311.     static Float:dmgtime
  312.     pev(entity, pev_dmgtime, dmgtime)
  313.    
  314.     // Check if it's time to go off
  315.     if (dmgtime > get_gametime())
  316.         return HAM_IGNORED;
  317.    
  318.     // Check if it's one of our custom nades
  319.     switch (pev(entity, PEV_NADE_TYPE))
  320.     {
  321.         case NADE_TYPE_FROST: // Frost Grenade
  322.         {
  323.             frost_explode(entity)
  324.             return HAM_SUPERCEDE;
  325.         }
  326.     }
  327.    
  328.     return HAM_IGNORED;
  329. }
  330.  
  331. // Frost Grenade Explosion
  332. frost_explode(ent)
  333. {
  334.     // Get origin
  335.     static Float:origin[3]
  336.     pev(ent, pev_origin, origin)
  337.    
  338.     // Make the explosion
  339.     create_blast3(origin)
  340.    
  341.     // Frost nade explode sound
  342.     static sound[SOUND_MAX_LENGTH]
  343.     ArrayGetString(g_sound_grenade_frost_explode, random_num(0, ArraySize(g_sound_grenade_frost_explode) - 1), sound, charsmax(sound))
  344.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  345.    
  346.     // Collisions
  347.     new victim = -1
  348.    
  349.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  350.     {
  351.         // Only effect alive zombies
  352.         if (!is_user_alive(victim))
  353.             continue;
  354.        
  355.         set_freeze(victim)
  356.     }
  357.    
  358.     // Get rid of the grenade
  359.     engfunc(EngFunc_RemoveEntity, ent)
  360. }
  361.  
  362. set_freeze(victim)
  363. {
  364.     // Already frozen
  365.     if (flag_get(g_IsFrozen, victim))
  366.         return false;
  367.    
  368.     // Allow other plugins to decide whether player should be frozen or not
  369.     ExecuteForward(g_Forwards[FW_USER_FREEZE_PRE], g_ForwardResult, victim)
  370.     if (g_ForwardResult >= PLUGIN_HANDLED)
  371.     {
  372.         // Get player's origin
  373.         static origin2[3]
  374.         get_user_origin(victim, origin2)
  375.        
  376.         // Broken glass sound
  377.         static sound[SOUND_MAX_LENGTH]
  378.         ArrayGetString(g_sound_grenade_frost_break, random_num(0, ArraySize(g_sound_grenade_frost_break) - 1), sound, charsmax(sound))
  379.         emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  380.        
  381.         // Glass shatter
  382.         message_begin(MSG_PVS, SVC_TEMPENTITY, origin2)
  383.         write_byte(TE_BREAKMODEL) // TE id
  384.         write_coord(origin2[0]) // x
  385.         write_coord(origin2[1]) // y
  386.         write_coord(origin2[2]+24) // z
  387.         write_coord(16) // size x
  388.         write_coord(16) // size y
  389.         write_coord(16) // size z
  390.         write_coord(random_num(-50, 50)) // velocity x
  391.         write_coord(random_num(-50, 50)) // velocity y
  392.         write_coord(25) // velocity z
  393.         write_byte(10) // random velocity
  394.         write_short(g_glassSpr) // model
  395.         write_byte(10) // count
  396.         write_byte(25) // life
  397.         write_byte(BREAK_GLASS) // flags
  398.         message_end()
  399.        
  400.         return false;
  401.     }
  402.    
  403.     // Freeze icon?
  404.     if (get_pcvar_num(cvar_grenade_frost_hudicon))
  405.     {
  406.         message_begin(MSG_ONE_UNRELIABLE, g_MsgDamage, _, victim)
  407.         write_byte(0) // damage save
  408.         write_byte(0) // damage take
  409.         write_long(DMG_DROWN) // damage type - DMG_FREEZE
  410.         write_coord(0) // x
  411.         write_coord(0) // y
  412.         write_coord(0) // z
  413.         message_end()
  414.     }
  415.    
  416.     // Set frozen flag
  417.     flag_set(g_IsFrozen, victim)
  418.    
  419.     // Freeze sound
  420.     static sound[SOUND_MAX_LENGTH]
  421.     ArrayGetString(g_sound_grenade_frost_player, random_num(0, ArraySize(g_sound_grenade_frost_player) - 1), sound, charsmax(sound))
  422.     emit_sound(victim, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  423.    
  424.     // Add a blue tint to their screen
  425.     message_begin(MSG_ONE, g_MsgScreenFade, _, victim)
  426.     write_short(0) // duration
  427.     write_short(0) // hold time
  428.     write_short(FFADE_STAYOUT) // fade type
  429.     write_byte(0) // red
  430.     write_byte(50) // green
  431.     write_byte(200) // blue
  432.     write_byte(100) // alpha
  433.     message_end()
  434.    
  435.     // Update player entity rendering
  436.     ApplyFrozenRendering(victim)
  437.    
  438.     // Block gravity
  439.     ApplyFrozenGravity(victim)
  440.    
  441.     // Update player's maxspeed
  442.     ExecuteHamB(Ham_Player_ResetMaxSpeed, victim)
  443.    
  444.     // Set a task to remove the freeze
  445.     set_task(get_pcvar_float(cvar_grenade_frost_duration), "remove_freeze", victim+TASK_FROST_REMOVE)
  446.     return true;
  447. }
  448.  
  449. ApplyFrozenGravity(id)
  450. {
  451.     // Get current gravity
  452.     new Float:gravity = get_user_gravity(id)
  453.    
  454.     // Already set, no worries...
  455.     if (gravity == GRAVITY_HIGH || gravity == GRAVITY_NONE)
  456.         return;
  457.    
  458.     // Save player's old gravity
  459.     g_FrozenGravity[id] = gravity
  460.    
  461.     // Prevent from jumping
  462.     if (pev(id, pev_flags) & FL_ONGROUND)
  463.         set_user_gravity(id, GRAVITY_HIGH) // set really high
  464.     else
  465.         set_user_gravity(id, GRAVITY_NONE) // no gravity
  466. }
  467.  
  468. ApplyFrozenRendering(id)
  469. {
  470.     // Get current rendering
  471.     new rendering_fx = pev(id, pev_renderfx)
  472.     new Float:rendering_color[3]
  473.     pev(id, pev_rendercolor, rendering_color)
  474.     new rendering_render = pev(id, pev_rendermode)
  475.     new Float:rendering_amount
  476.     pev(id, pev_renderamt, rendering_amount)
  477.    
  478.     // Already set, no worries...
  479.     if (rendering_fx == kRenderFxGlowShell && rendering_color[0] == 0.0 && rendering_color[1] == 100.0
  480.         && rendering_color[2] == 200.0 && rendering_render == kRenderNormal && rendering_amount == 25.0)
  481.         return;
  482.    
  483.     // Save player's old rendering 
  484.     g_FrozenRenderingFx[id] = pev(id, pev_renderfx)
  485.     pev(id, pev_rendercolor, g_FrozenRenderingColor[id])
  486.     g_FrozenRenderingRender[id] = pev(id, pev_rendermode)
  487.     pev(id, pev_renderamt, g_FrozenRenderingAmount[id])
  488.    
  489.     // Light blue glow while frozen
  490.     fm_set_rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  491. }
  492.  
  493. // Remove freeze task
  494. public remove_freeze(taskid)
  495. {
  496.     // Remove frozen flag
  497.     flag_unset(g_IsFrozen, ID_FROST_REMOVE)
  498.    
  499.     // Restore gravity
  500.     set_pev(ID_FROST_REMOVE, pev_gravity, g_FrozenGravity[ID_FROST_REMOVE])
  501.    
  502.     // Update player's maxspeed
  503.     ExecuteHamB(Ham_Player_ResetMaxSpeed, ID_FROST_REMOVE)
  504.    
  505.     // Restore rendering
  506.     fm_set_rendering_float(ID_FROST_REMOVE, g_FrozenRenderingFx[ID_FROST_REMOVE], g_FrozenRenderingColor[ID_FROST_REMOVE], g_FrozenRenderingRender[ID_FROST_REMOVE], g_FrozenRenderingAmount[ID_FROST_REMOVE])
  507.    
  508.     // Gradually remove screen's blue tint
  509.     message_begin(MSG_ONE, g_MsgScreenFade, _, ID_FROST_REMOVE)
  510.     write_short(UNIT_SECOND) // duration
  511.     write_short(0) // hold time
  512.     write_short(FFADE_IN) // fade type
  513.     write_byte(0) // red
  514.     write_byte(50) // green
  515.     write_byte(200) // blue
  516.     write_byte(100) // alpha
  517.     message_end()
  518.    
  519.     // Broken glass sound
  520.     static sound[SOUND_MAX_LENGTH]
  521.     ArrayGetString(g_sound_grenade_frost_break, random_num(0, ArraySize(g_sound_grenade_frost_break) - 1), sound, charsmax(sound))
  522.     emit_sound(ID_FROST_REMOVE, CHAN_BODY, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  523.    
  524.     // Get player's origin
  525.     static origin[3]
  526.     get_user_origin(ID_FROST_REMOVE, origin)
  527.    
  528.     // Glass shatter
  529.     message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  530.     write_byte(TE_BREAKMODEL) // TE id
  531.     write_coord(origin[0]) // x
  532.     write_coord(origin[1]) // y
  533.     write_coord(origin[2]+24) // z
  534.     write_coord(16) // size x
  535.     write_coord(16) // size y
  536.     write_coord(16) // size z
  537.     write_coord(random_num(-50, 50)) // velocity x
  538.     write_coord(random_num(-50, 50)) // velocity y
  539.     write_coord(25) // velocity z
  540.     write_byte(10) // random velocity
  541.     write_short(g_glassSpr) // model
  542.     write_byte(10) // count
  543.     write_byte(25) // life
  544.     write_byte(BREAK_GLASS) // flags
  545.     message_end()
  546.    
  547.     ExecuteForward(g_Forwards[FW_USER_UNFROZEN], g_ForwardResult, ID_FROST_REMOVE)
  548. }
  549.  
  550. // Frost Grenade: Freeze Blast
  551. create_blast3(const Float:originF[3])
  552. {
  553.     // Smallest ring
  554.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  555.     write_byte(TE_BEAMCYLINDER) // TE id
  556.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  557.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  558.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  559.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  560.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  561.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  562.     write_short(g_exploSpr) // sprite
  563.     write_byte(0) // startframe
  564.     write_byte(0) // framerate
  565.     write_byte(4) // life
  566.     write_byte(60) // width
  567.     write_byte(0) // noise
  568.     write_byte(0) // red
  569.     write_byte(100) // green
  570.     write_byte(200) // blue
  571.     write_byte(200) // brightness
  572.     write_byte(0) // speed
  573.     message_end()
  574.    
  575.     // Medium ring
  576.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  577.     write_byte(TE_BEAMCYLINDER) // TE id
  578.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  579.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  580.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  581.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  582.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  583.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  584.     write_short(g_exploSpr) // sprite
  585.     write_byte(0) // startframe
  586.     write_byte(0) // framerate
  587.     write_byte(4) // life
  588.     write_byte(60) // width
  589.     write_byte(0) // noise
  590.     write_byte(0) // red
  591.     write_byte(100) // green
  592.     write_byte(200) // blue
  593.     write_byte(200) // brightness
  594.     write_byte(0) // speed
  595.     message_end()
  596.    
  597.     // Largest ring
  598.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  599.     write_byte(TE_BEAMCYLINDER) // TE id
  600.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  601.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  602.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  603.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  604.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  605.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  606.     write_short(g_exploSpr) // sprite
  607.     write_byte(0) // startframe
  608.     write_byte(0) // framerate
  609.     write_byte(4) // life
  610.     write_byte(60) // width
  611.     write_byte(0) // noise
  612.     write_byte(0) // red
  613.     write_byte(100) // green
  614.     write_byte(200) // blue
  615.     write_byte(200) // brightness
  616.     write_byte(0) // speed
  617.     message_end()
  618. }
  619.  
  620. // Set entity's rendering type (from fakemeta_util)
  621. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  622. {
  623.     static Float:color[3]
  624.     color[0] = float(r)
  625.     color[1] = float(g)
  626.     color[2] = float(b)
  627.    
  628.     set_pev(entity, pev_renderfx, fx)
  629.     set_pev(entity, pev_rendercolor, color)
  630.     set_pev(entity, pev_rendermode, render)
  631.     set_pev(entity, pev_renderamt, float(amount))
  632. }
  633.  
  634. // Set entity's rendering type (float parameters version)
  635. stock fm_set_rendering_float(entity, fx = kRenderFxNone, Float:color[3], render = kRenderNormal, Float:amount = 16.0)
  636. {
  637.     set_pev(entity, pev_renderfx, fx)
  638.     set_pev(entity, pev_rendercolor, color)
  639.     set_pev(entity, pev_rendermode, render)
  640.     set_pev(entity, pev_renderamt, amount)
  641. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement