hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.28. 04:39



Jelenlévő felhasználók

Jelenleg 249 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 249 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 4 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Fertőző gránát!
HozzászólásElküldve: 2017.10.18. 12:15 
Offline
Tud valamit

Csatlakozott: 2016.12.25. 12:43
Hozzászólások: 129
Megköszönt másnak: 35 alkalommal
Megköszönték neki: 4 alkalommal
Üdv!

Olyan segítség kellene hogy van ez a fertőző gránát, és azt kellene meg oldani hogy ha már van a kezibe gránát akkor rá tudja venni a többit is, mert most a pluginba úgy van hogy ha meg veszem, akkor többet nem enged, csak ha el dobtam. Előre thx
  1. /*================================================================================
  2.    
  3.     ---------------------------------
  4.     -*- [ZP] Item: Infection Bomb -*-
  5.     ---------------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #define ITEM_NAME "Infection Bomb"
  13. #define ITEM_COST 20
  14.  
  15. #include <amxmodx>
  16. #include <fun>
  17. #include <fakemeta>
  18. #include <hamsandwich>
  19. #include <amx_settings_api>
  20. #include <cs_weap_models_api>
  21. #include <zp50_items>
  22. #include <zp50_gamemodes>
  23.  
  24. // Settings file
  25. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  26.  
  27. // Default sounds
  28. new const sound_grenade_infect_explode[][] = { "zombie_plague/grenade_infect.wav" }
  29. new const sound_grenade_infect_player[][] = { "scientist/scream20.wav" , "scientist/scream22.wav" , "scientist/scream05.wav" }
  30.  
  31. #define MODEL_MAX_LENGTH 64
  32. #define SOUND_MAX_LENGTH 64
  33. #define SPRITE_MAX_LENGTH 64
  34.  
  35. // Models
  36. new g_model_grenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/v_grenade_infect.mdl"
  37.  
  38. // Sprites
  39. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  40. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  41.  
  42. new Array:g_sound_grenade_infect_explode
  43. new Array:g_sound_grenade_infect_player
  44.  
  45. // Explosion radius for custom grenades
  46. const Float:NADE_EXPLOSION_RADIUS = 240.0
  47.  
  48. // HACK: pev_ field used to store custom nade types and their values
  49. const PEV_NADE_TYPE = pev_flTimeStepSound
  50. const NADE_TYPE_INFECTION = 1111
  51.  
  52. new g_trailSpr, g_exploSpr
  53.  
  54. new g_ItemID
  55. new g_GameModeInfectionID
  56. new g_GameModeMultiID
  57. new g_InfectionBombCounter, cvar_infection_bomb_round_limit
  58.  
  59. public plugin_init()
  60. {
  61.     register_plugin("[ZP] Item: Infection Bomb", ZP_VERSION_STRING, "ZP Dev Team")
  62.    
  63.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  64.    
  65.     register_forward(FM_SetModel, "fw_SetModel")
  66.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  67.    
  68.     g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
  69.     cvar_infection_bomb_round_limit = register_cvar("zp_infection_bomb_round_limit", "3")
  70. }
  71.  
  72. public plugin_precache()
  73. {
  74.     // Initialize arrays
  75.     g_sound_grenade_infect_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  76.     g_sound_grenade_infect_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  77.    
  78.     // Load from external file
  79.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  80.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  81.    
  82.     // If we couldn't load custom sounds from file, use and save default ones
  83.     new index
  84.     if (ArraySize(g_sound_grenade_infect_explode) == 0)
  85.     {
  86.         for (index = 0; index < sizeof sound_grenade_infect_explode; index++)
  87.             ArrayPushString(g_sound_grenade_infect_explode, sound_grenade_infect_explode[index])
  88.        
  89.         // Save to external file
  90.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  91.     }
  92.     if (ArraySize(g_sound_grenade_infect_player) == 0)
  93.     {
  94.         for (index = 0; index < sizeof sound_grenade_infect_player; index++)
  95.             ArrayPushString(g_sound_grenade_infect_player, sound_grenade_infect_player[index])
  96.        
  97.         // Save to external file
  98.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  99.     }
  100.    
  101.     // Load from external file, save if not found
  102.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect, charsmax(g_model_grenade_infect)))
  103.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  104.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail)))
  105.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail)
  106.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring, charsmax(g_sprite_grenade_ring)))
  107.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring)
  108.    
  109.     // Precache sounds
  110.     new sound[SOUND_MAX_LENGTH]
  111.     for (index = 0; index < ArraySize(g_sound_grenade_infect_explode); index++)
  112.     {
  113.         ArrayGetString(g_sound_grenade_infect_explode, index, sound, charsmax(sound))
  114.         precache_sound(sound)
  115.     }
  116.     for (index = 0; index < ArraySize(g_sound_grenade_infect_player); index++)
  117.     {
  118.         ArrayGetString(g_sound_grenade_infect_player, index, sound, charsmax(sound))
  119.         precache_sound(sound)
  120.     }
  121.    
  122.     // Precache models
  123.     precache_model(g_model_grenade_infect)
  124.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  125.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  126. }
  127.  
  128. public plugin_cfg()
  129. {
  130.     g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
  131.     g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
  132. }
  133.  
  134. public event_round_start()
  135. {
  136.     g_InfectionBombCounter = 0
  137. }
  138.  
  139. public zp_fw_items_select_pre(id, itemid, ignorecost)
  140. {
  141.     // This is not our item
  142.     if (itemid != g_ItemID)
  143.         return ZP_ITEM_AVAILABLE;
  144.    
  145.     // Infection bomb only available during infection modes
  146.     new current_mode = zp_gamemodes_get_current()
  147.     if (current_mode != g_GameModeInfectionID && current_mode != g_GameModeMultiID)
  148.         return ZP_ITEM_DONT_SHOW;
  149.    
  150.     // Infection bomb only available to zombies
  151.     if (!zp_core_is_zombie(id))
  152.         return ZP_ITEM_DONT_SHOW;
  153.    
  154.     // Display remaining item count for this round
  155.     static text[32]
  156.     formatex(text, charsmax(text), "[%d/%d]", g_InfectionBombCounter, get_pcvar_num(cvar_infection_bomb_round_limit))
  157.     zp_items_menu_text_add(text)
  158.    
  159.     // Reached infection bomb limit for this round
  160.     if (g_InfectionBombCounter >= get_pcvar_num(cvar_infection_bomb_round_limit))
  161.         return ZP_ITEM_NOT_AVAILABLE;
  162.    
  163.     // Player already owns infection bomb
  164.     if (user_has_weapon(id, CSW_HEGRENADE))
  165.         return ZP_ITEM_NOT_AVAILABLE;
  166.    
  167.     return ZP_ITEM_AVAILABLE;
  168. }
  169.  
  170. public zp_fw_items_select_post(id, itemid, ignorecost)
  171. {
  172.     // This is not our item
  173.     if (itemid != g_ItemID)
  174.         return;
  175.    
  176.     // Give infection bomb
  177.     give_item(id, "weapon_hegrenade")
  178.     g_InfectionBombCounter++
  179. }
  180.  
  181. public zp_fw_core_cure(id, attacker)
  182. {
  183.     // Remove custom grenade model
  184.     cs_reset_player_view_model(id, CSW_HEGRENADE)
  185. }
  186.  
  187. public zp_fw_core_infect_post(id, attacker)
  188. {
  189.     // Set custom grenade model
  190.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_grenade_infect)
  191. }
  192.  
  193. // Forward Set Model
  194. public fw_SetModel(entity, const model[])
  195. {
  196.     // We don't care
  197.     if (strlen(model) < 8)
  198.         return;
  199.    
  200.     // Narrow down our matches a bit
  201.     if (model[7] != 'w' || model[8] != '_')
  202.         return;
  203.    
  204.     // Get damage time of grenade
  205.     static Float:dmgtime
  206.     pev(entity, pev_dmgtime, dmgtime)
  207.    
  208.     // Grenade not yet thrown
  209.     if (dmgtime == 0.0)
  210.         return;
  211.    
  212.     // Grenade's owner isn't zombie?
  213.     if (!zp_core_is_zombie(pev(entity, pev_owner)))
  214.         return;
  215.    
  216.     // HE Grenade
  217.     if (model[9] == 'h' && model[10] == 'e')
  218.     {
  219.         // Give it a glow
  220.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  221.        
  222.         // And a colored trail
  223.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  224.         write_byte(TE_BEAMFOLLOW) // TE id
  225.         write_short(entity) // entity
  226.         write_short(g_trailSpr) // sprite
  227.         write_byte(10) // life
  228.         write_byte(10) // width
  229.         write_byte(0) // r
  230.         write_byte(200) // g
  231.         write_byte(0) // b
  232.         write_byte(200) // brightness
  233.         message_end()
  234.        
  235.         // Set grenade type on the thrown grenade entity
  236.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  237.     }
  238. }
  239.  
  240. // Ham Grenade Think Forward
  241. public fw_ThinkGrenade(entity)
  242. {
  243.     // Invalid entity
  244.     if (!pev_valid(entity)) return HAM_IGNORED;
  245.    
  246.     // Get damage time of grenade
  247.     static Float:dmgtime
  248.     pev(entity, pev_dmgtime, dmgtime)
  249.    
  250.     // Check if it's time to go off
  251.     if (dmgtime > get_gametime())
  252.         return HAM_IGNORED;
  253.    
  254.     // Check if it's one of our custom nades
  255.     switch (pev(entity, PEV_NADE_TYPE))
  256.     {
  257.         case NADE_TYPE_INFECTION: // Infection Bomb
  258.         {
  259.             infection_explode(entity)
  260.             return HAM_SUPERCEDE;
  261.         }
  262.     }
  263.    
  264.     return HAM_IGNORED;
  265. }
  266.  
  267. // Infection Bomb Explosion
  268. infection_explode(ent)
  269. {
  270.     // Round ended
  271.     if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
  272.     {
  273.         // Get rid of the grenade
  274.         engfunc(EngFunc_RemoveEntity, ent)
  275.         return;
  276.     }
  277.    
  278.     // Get origin
  279.     static Float:origin[3]
  280.     pev(ent, pev_origin, origin)
  281.    
  282.     // Make the explosion
  283.     create_blast(origin)
  284.    
  285.     // Infection nade explode sound
  286.     static sound[SOUND_MAX_LENGTH]
  287.     ArrayGetString(g_sound_grenade_infect_explode, random_num(0, ArraySize(g_sound_grenade_infect_explode) - 1), sound, charsmax(sound))
  288.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  289.    
  290.     // Get attacker
  291.     new attacker = pev(ent, pev_owner)
  292.    
  293.     // Infection bomb owner disconnected or not zombie anymore?
  294.     if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
  295.     {
  296.         // Get rid of the grenade
  297.         engfunc(EngFunc_RemoveEntity, ent)
  298.         return;
  299.     }
  300.    
  301.     // Collisions
  302.     new victim = -1
  303.    
  304.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  305.     {
  306.         // Only effect alive humans
  307.         if (!is_user_alive(victim) || zp_core_is_zombie(victim))
  308.             continue;
  309.        
  310.         // Last human is killed
  311.         if (zp_core_get_human_count() == 1)
  312.         {
  313.             ExecuteHamB(Ham_Killed, victim, attacker, 0)
  314.             continue;
  315.         }
  316.        
  317.         // Turn into zombie
  318.         zp_core_infect(victim, attacker)
  319.        
  320.         // Victim's sound
  321.         ArrayGetString(g_sound_grenade_infect_player, random_num(0, ArraySize(g_sound_grenade_infect_player) - 1), sound, charsmax(sound))
  322.         emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  323.     }
  324.    
  325.     // Get rid of the grenade
  326.     engfunc(EngFunc_RemoveEntity, ent)
  327. }
  328.  
  329. // Infection Bomb: Green Blast
  330. create_blast(const Float:origin[3])
  331. {
  332.     // Smallest ring
  333.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  334.     write_byte(TE_BEAMCYLINDER) // TE id
  335.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  336.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  337.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  338.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  339.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  340.     engfunc(EngFunc_WriteCoord, origin[2]+385.0) // z axis
  341.     write_short(g_exploSpr) // sprite
  342.     write_byte(0) // startframe
  343.     write_byte(0) // framerate
  344.     write_byte(4) // life
  345.     write_byte(60) // width
  346.     write_byte(0) // noise
  347.     write_byte(0) // red
  348.     write_byte(200) // green
  349.     write_byte(0) // blue
  350.     write_byte(200) // brightness
  351.     write_byte(0) // speed
  352.     message_end()
  353.    
  354.     // Medium ring
  355.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  356.     write_byte(TE_BEAMCYLINDER) // TE id
  357.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  358.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  359.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  360.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  361.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  362.     engfunc(EngFunc_WriteCoord, origin[2]+470.0) // z axis
  363.     write_short(g_exploSpr) // sprite
  364.     write_byte(0) // startframe
  365.     write_byte(0) // framerate
  366.     write_byte(4) // life
  367.     write_byte(60) // width
  368.     write_byte(0) // noise
  369.     write_byte(0) // red
  370.     write_byte(200) // green
  371.     write_byte(0) // blue
  372.     write_byte(200) // brightness
  373.     write_byte(0) // speed
  374.     message_end()
  375.    
  376.     // Largest ring
  377.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  378.     write_byte(TE_BEAMCYLINDER) // TE id
  379.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  380.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  381.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  382.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  383.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  384.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  385.     write_short(g_exploSpr) // sprite
  386.     write_byte(0) // startframe
  387.     write_byte(0) // framerate
  388.     write_byte(4) // life
  389.     write_byte(60) // width
  390.     write_byte(0) // noise
  391.     write_byte(0) // red
  392.     write_byte(200) // green
  393.     write_byte(0) // blue
  394.     write_byte(200) // brightness
  395.     write_byte(0) // speed
  396.     message_end()
  397. }
  398.  
  399. // Set entity's rendering type (from fakemeta_util)
  400. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  401. {
  402.     static Float:color[3]
  403.     color[0] = float(r)
  404.     color[1] = float(g)
  405.     color[2] = float(b)
  406.    
  407.     set_pev(entity, pev_renderfx, fx)
  408.     set_pev(entity, pev_rendercolor, color)
  409.     set_pev(entity, pev_rendermode, render)
  410.     set_pev(entity, pev_renderamt, float(amount))
  411. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Fertőző gránát!
HozzászólásElküldve: 2017.10.18. 15:34 
Offline
Jómunkásember
Avatar

Csatlakozott: 2016.02.10. 12:46
Hozzászólások: 429
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 157 alkalommal
Üdv. Próbáld meg törölni ezt:
  1. // Player already owns infection bomb
  2.     if (user_has_weapon(id, CSW_HEGRENADE))
  3.         return ZP_ITEM_NOT_AVAILABLE;

163. sorban megtalálod.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Fertőző gránát!
HozzászólásElküldve: 2017.10.18. 22:40 
Offline
Tud valamit

Csatlakozott: 2016.12.25. 12:43
Hozzászólások: 129
Megköszönt másnak: 35 alkalommal
Megköszönték neki: 4 alkalommal
Dooz írta:
Üdv. Próbáld meg törölni ezt:
  1. // Player already owns infection bomb
  2.     if (user_has_weapon(id, CSW_HEGRENADE))
  3.         return ZP_ITEM_NOT_AVAILABLE;

163. sorban megtalálod.

Már próbáltam és nem jó. Akkor meg nem add gránátot :D


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Fertőző gránát!
HozzászólásElküldve: 2017.12.02. 08:40 
Offline
Tud valamit
Avatar

Csatlakozott: 2017.08.28. 14:00
Hozzászólások: 106
Megköszönt másnak: 5 alkalommal
Megköszönték neki: 14 alkalommal
Szia, tessék..:)

  1. /*================================================================================
  2.    
  3.     ---------------------------------
  4.     -*- [ZP] Item: Infection Bomb -*-
  5.     ---------------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #define ITEM_NAME "Infection Bomb"
  13. #define ITEM_COST 20
  14.  
  15. #include <amxmodx>
  16. #include <fun>
  17. #include <fakemeta>
  18. #include <hamsandwich>
  19. #include <amx_settings_api>
  20. #include <cs_weap_models_api>
  21. #include <zp50_items>
  22. #include <zp50_gamemodes>
  23.  
  24. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  25.  
  26. new const sound_grenade_infect_explode[][] = { "zombie_plague/grenade_infect.wav" }
  27. new const sound_grenade_infect_player[][] = { "scientist/scream20.wav" , "scientist/scream22.wav" , "scientist/scream05.wav" }
  28.  
  29. #define MODEL_MAX_LENGTH 64
  30. #define SOUND_MAX_LENGTH 64
  31. #define SPRITE_MAX_LENGTH 64
  32. #define TE_EXPLOSION 3
  33.  
  34. new g_InfectionSpr
  35. new g_model_grenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/v_grenade_infect.mdl"
  36.  
  37. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  38. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  39.  
  40. new Array:g_sound_grenade_infect_explode
  41. new Array:g_sound_grenade_infect_player
  42.  
  43. // Explosion radius for custom grenades
  44. const Float:NADE_EXPLOSION_RADIUS = 240.0
  45.  
  46. // HACK: pev_ field used to store custom nade types and their values
  47. const PEV_NADE_TYPE = pev_flTimeStepSound
  48. const NADE_TYPE_INFECTION = 1111
  49.  
  50. new g_trailSpr, g_exploSpr
  51.  
  52. new g_ItemID
  53. new g_GameModeInfectionID
  54. new g_GameModeMultiID
  55. new g_InfectionBombCounter[33], cvar_infection_bomb_round_limit
  56.  
  57. public plugin_init()
  58. {
  59.     register_plugin("[ZP] Item: Infection Bomb", ZP_VERSION_STRING, "ZP Dev Team")
  60.    
  61.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  62.    
  63.     register_forward(FM_SetModel, "fw_SetModel")
  64.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  65.    
  66.     g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
  67.     cvar_infection_bomb_round_limit = register_cvar("zp_infection_bomb_round_limit", "3")
  68. }
  69.  
  70. public plugin_precache()
  71. {
  72.     // Initialize arrays
  73.     g_sound_grenade_infect_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  74.     g_sound_grenade_infect_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  75.    
  76.     // Load from external file
  77.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  78.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  79.    
  80.     // If we couldn't load custom sounds from file, use and save default ones
  81.     new index
  82.     if (ArraySize(g_sound_grenade_infect_explode) == 0)
  83.     {
  84.         for (index = 0; index < sizeof sound_grenade_infect_explode; index++)
  85.             ArrayPushString(g_sound_grenade_infect_explode, sound_grenade_infect_explode[index])
  86.        
  87.         // Save to external file
  88.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  89.     }
  90.     if (ArraySize(g_sound_grenade_infect_player) == 0)
  91.     {
  92.         for (index = 0; index < sizeof sound_grenade_infect_player; index++)
  93.             ArrayPushString(g_sound_grenade_infect_player, sound_grenade_infect_player[index])
  94.        
  95.         // Save to external file
  96.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  97.     }
  98.    
  99.     // Load from external file, save if not found
  100.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect, charsmax(g_model_grenade_infect)))
  101.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  102.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail)))
  103.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail)
  104.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring, charsmax(g_sprite_grenade_ring)))
  105.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring)
  106.    
  107.     // Precache sounds
  108.     new sound[SOUND_MAX_LENGTH]
  109.     for (index = 0; index < ArraySize(g_sound_grenade_infect_explode); index++)
  110.     {
  111.         ArrayGetString(g_sound_grenade_infect_explode, index, sound, charsmax(sound))
  112.         precache_sound(sound)
  113.     }
  114.     for (index = 0; index < ArraySize(g_sound_grenade_infect_player); index++)
  115.     {
  116.         ArrayGetString(g_sound_grenade_infect_player, index, sound, charsmax(sound))
  117.         precache_sound(sound)
  118.     }
  119.    
  120.     // Precache models
  121.     precache_model(g_model_grenade_infect)
  122.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  123.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  124.     g_InfectionSpr = precache_model("sprites/green.spr")
  125. }
  126.  
  127. public plugin_cfg()
  128. {
  129.     g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
  130.     g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
  131. }
  132.  
  133. public event_round_start()
  134. {
  135.         new Jatekos[32], szam,id;
  136.         get_players( Jatekos, szam );
  137.        
  138.         for( new i; i < szam; i++ ){
  139.          id=Jatekos[i]
  140.          g_InfectionBombCounter[id] = 0
  141.            
  142.         }
  143.  
  144.  
  145.    
  146.    
  147. }
  148.  
  149. public zp_fw_items_select_pre(id, itemid, ignorecost)
  150. {
  151.     // This is not our item
  152.     if (itemid != g_ItemID)
  153.         return ZP_ITEM_AVAILABLE;
  154.    
  155.     // Infection bomb only available during infection modes
  156.     new current_mode = zp_gamemodes_get_current()
  157.     if (current_mode != g_GameModeInfectionID && current_mode != g_GameModeMultiID)
  158.         return ZP_ITEM_DONT_SHOW;
  159.    
  160.     // Infection bomb only available to zombies
  161.     if (!zp_core_is_zombie(id))
  162.         return ZP_ITEM_DONT_SHOW;
  163.    
  164.     // Display remaining item count for this round
  165.     static text[32]
  166.     formatex(text, charsmax(text), "[%d/%d]", g_InfectionBombCounter[id], get_pcvar_num(cvar_infection_bomb_round_limit))
  167.     zp_items_menu_text_add(text)
  168.    
  169.     // Reached infection bomb limit for this round
  170.     if (g_InfectionBombCounter[id] >= get_pcvar_num(cvar_infection_bomb_round_limit))
  171.         return ZP_ITEM_NOT_AVAILABLE;
  172.    
  173.     // Player already owns infection bomb
  174.     if (user_has_weapon(id, CSW_HEGRENADE))
  175.         return ZP_ITEM_NOT_AVAILABLE;
  176.    
  177.     return ZP_ITEM_AVAILABLE;
  178. }
  179.  
  180. public zp_fw_items_select_post(id, itemid, ignorecost)
  181. {
  182.     // This is not our item
  183.     if (itemid != g_ItemID)
  184.         return;
  185.    
  186.     // Give infection bomb
  187.     give_item(id, "weapon_hegrenade")
  188.     g_InfectionBombCounter[id]++
  189. }
  190.  
  191. public zp_fw_core_cure(id, attacker)
  192. {
  193.     // Remove custom grenade model
  194.     cs_reset_player_view_model(id, CSW_HEGRENADE)
  195. }
  196.  
  197. public zp_fw_core_infect_post(id, attacker)
  198. {
  199.     // Set custom grenade model
  200.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_grenade_infect)
  201. }
  202.  
  203. // Forward Set Model
  204. public fw_SetModel(entity, const model[])
  205. {
  206.     // We don't care
  207.     if (strlen(model) < 8)
  208.         return;
  209.    
  210.     // Narrow down our matches a bit
  211.     if (model[7] != 'w' || model[8] != '_')
  212.         return;
  213.    
  214.     // Get damage time of grenade
  215.     static Float:dmgtime
  216.     pev(entity, pev_dmgtime, dmgtime)
  217.    
  218.     // Grenade not yet thrown
  219.     if (dmgtime == 0.0)
  220.         return;
  221.    
  222.     // Grenade's owner isn't zombie?
  223.     if (!zp_core_is_zombie(pev(entity, pev_owner)))
  224.         return;
  225.    
  226.     // HE Grenade
  227.     if (model[9] == 'h' && model[10] == 'e')
  228.     {
  229.         // Give it a glow
  230.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  231.        
  232.         // And a colored trail
  233.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  234.         write_byte(TE_BEAMFOLLOW) // TE id
  235.         write_short(entity) // entity
  236.         write_short(g_trailSpr) // sprite
  237.         write_byte(10) // life
  238.         write_byte(10) // width
  239.         write_byte(0) // r
  240.         write_byte(200) // g
  241.         write_byte(0) // b
  242.         write_byte(200) // brightness
  243.         message_end()
  244.        
  245.         // Set grenade type on the thrown grenade entity
  246.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  247.     }
  248. }
  249.  
  250. // Ham Grenade Think Forward
  251. public fw_ThinkGrenade(entity)
  252. {
  253.     // Invalid entity
  254.     if (!pev_valid(entity)) return HAM_IGNORED;
  255.    
  256.     // Get damage time of grenade
  257.     static Float:dmgtime
  258.     pev(entity, pev_dmgtime, dmgtime)
  259.    
  260.     // Check if it's time to go off
  261.     if (dmgtime > get_gametime())
  262.         return HAM_IGNORED;
  263.    
  264.     // Check if it's one of our custom nades
  265.     switch (pev(entity, PEV_NADE_TYPE))
  266.     {
  267.         case NADE_TYPE_INFECTION: // Infection Bomb
  268.         {
  269.             infection_explode(entity)
  270.             return HAM_SUPERCEDE;
  271.         }
  272.     }
  273.    
  274.     return HAM_IGNORED;
  275. }
  276.  
  277. // Infection Bomb Explosion
  278. infection_explode(ent)
  279. {
  280.     // Round ended
  281.     if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
  282.     {
  283.         // Get rid of the grenade
  284.         engfunc(EngFunc_RemoveEntity, ent)
  285.         return;
  286.     }
  287.    
  288.     // Get origin
  289.     static Float:origin[3]
  290.     pev(ent, pev_origin, origin)
  291.    
  292.     // Make the explosion
  293.     create_blast(origin)
  294.    
  295.     // Infection nade explode sound
  296.     static sound[SOUND_MAX_LENGTH]
  297.     ArrayGetString(g_sound_grenade_infect_explode, random_num(0, ArraySize(g_sound_grenade_infect_explode) - 1), sound, charsmax(sound))
  298.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  299.    
  300.     // Get attacker
  301.     new attacker = pev(ent, pev_owner)
  302.    
  303.     // Infection bomb owner disconnected or not zombie anymore?
  304.     if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
  305.     {
  306.         // Get rid of the grenade
  307.         engfunc(EngFunc_RemoveEntity, ent)
  308.         return;
  309.     }
  310.    
  311.     // Collisions
  312.     new victim = -1
  313.    
  314.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  315.     {
  316.         // Only effect alive humans
  317.         if (!is_user_alive(victim) || zp_core_is_zombie(victim))
  318.             continue;
  319.        
  320.         // Last human is killed
  321.         if (zp_core_get_human_count() == 1)
  322.         {
  323.             ExecuteHamB(Ham_Killed, victim, attacker, 0)
  324.             continue;
  325.         }
  326.        
  327.         // Turn into zombie
  328.         zp_core_infect(victim, attacker)
  329.        
  330.         // Victim's sound
  331.         ArrayGetString(g_sound_grenade_infect_player, random_num(0, ArraySize(g_sound_grenade_infect_player) - 1), sound, charsmax(sound))
  332.         emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  333.     }
  334.    
  335.     // Get rid of the grenade
  336.     engfunc(EngFunc_RemoveEntity, ent)
  337. }
  338.  
  339. // Infection Bomb: Green Blast
  340. create_blast(const Float:origin[3])
  341. {
  342.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  343.     write_byte(TE_EXPLOSION); // TE_EXPLOSION
  344.     write_coord(floatround(origin[0])); // origin x
  345.     write_coord(floatround(origin[1])); // origin y
  346.     write_coord(floatround(origin[2] + 50.0)); // origin z
  347.     write_short(g_InfectionSpr); // sprites
  348.     write_byte(25); // scale in 0.1's
  349.     write_byte(10); // framerate
  350.     write_byte(14); // flags
  351.     message_end(); // message end
  352.    
  353.     // Smallest ring
  354.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  355.     write_byte(TE_BEAMCYLINDER) // TE id
  356.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  357.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  358.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  359.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  360.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  361.     engfunc(EngFunc_WriteCoord, origin[2]+385.0) // z axis
  362.     write_short(g_exploSpr) // sprite
  363.     write_byte(0) // startframe
  364.     write_byte(0) // framerate
  365.     write_byte(4) // life
  366.     write_byte(60) // width
  367.     write_byte(0) // noise
  368.     write_byte(0) // red
  369.     write_byte(200) // green
  370.     write_byte(0) // blue
  371.     write_byte(200) // brightness
  372.     write_byte(0) // speed
  373.     message_end()
  374.    
  375.     // Medium ring
  376.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  377.     write_byte(TE_BEAMCYLINDER) // TE id
  378.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  379.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  380.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  381.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  382.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  383.     engfunc(EngFunc_WriteCoord, origin[2]+470.0) // z axis
  384.     write_short(g_exploSpr) // sprite
  385.     write_byte(0) // startframe
  386.     write_byte(0) // framerate
  387.     write_byte(4) // life
  388.     write_byte(60) // width
  389.     write_byte(0) // noise
  390.     write_byte(0) // red
  391.     write_byte(200) // green
  392.     write_byte(0) // blue
  393.     write_byte(200) // brightness
  394.     write_byte(0) // speed
  395.     message_end()
  396.    
  397.     // Largest ring
  398.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  399.     write_byte(TE_BEAMCYLINDER) // TE id
  400.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  401.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  402.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  403.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  404.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  405.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  406.     write_short(g_exploSpr) // sprite
  407.     write_byte(0) // startframe
  408.     write_byte(0) // framerate
  409.     write_byte(4) // life
  410.     write_byte(60) // width
  411.     write_byte(0) // noise
  412.     write_byte(0) // red
  413.     write_byte(200) // green
  414.     write_byte(0) // blue
  415.     write_byte(200) // brightness
  416.     write_byte(0) // speed
  417.     message_end()
  418. }
  419.  
  420. // Set entity's rendering type (from fakemeta_util)
  421. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  422. {
  423.     static Float:color[3]
  424.     color[0] = float(r)
  425.     color[1] = float(g)
  426.     color[2] = float(b)
  427.    
  428.     set_pev(entity, pev_renderfx, fx)
  429.     set_pev(entity, pev_rendercolor, color)
  430.     set_pev(entity, pev_rendermode, render)
  431.     set_pev(entity, pev_renderamt, float(amount))
  432. }

_________________
Kép


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 4 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 21 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole