hlmod.hu
https://hlmod.hu/

[ZP] Class: Regeneration
https://hlmod.hu/viewtopic.php?f=9&t=2300
Oldal: 1 / 1

Szerző:  Halfx [2011.07.13. 12:56 ]
Hozzászólás témája:  [ZP] Class: Regeneration

Hali!

Újból a segítségetek szeretném kérni, méghozzá egy Zombi fajnál, aminek a képessége az lenne, hogy 2 másodpercenként növekedjen az élete 25-el.. növekszik is, de viszont nem 2 másodpercenként és nem is csak 25-öt, hanem szinte egyből tele lesz újból az élete.

Előre is köszönöm a segítségetek! :)

Kód:
/*==========================================================================
/
/            [ZP] Class : Zombie Regeneration
/                 ( Passive zombie skill )
/                  by The_Thing
/
/
/   Description :
/
/         This is another zombie class only this zombie are allowed to heal him self after certain time of amount he will be healing.
/         All can change by cvars.
/
/
/
/   Cvars :
/
/         zp_zclass_regen <1|0> - On or off, default is 1
/         zp_regen_time   "2"   - After how much seconds will be healing, default is after 2 seconds.
/         zp_regen_amount "25"  - How much HP you will gain in healing process, default is 25 hp in 2 seconds.
/
/
/
/   Credits :
/
/         hleV - For his created plugin.
/
/
/
/   Changelog :
/
/         06/11/2008 - v1.0 - First release
/
*/

#include <amxmodx>
#include <fakemeta>
#include <zombieplague>


new g_zclass_regen_toggle, g_time, g_amount

new const zclass8_name[] = { "Regeneralodos zombi" }
new const zclass8_info[] = { "HP regeneralodas" }
new const zclass8_model[] = { "zombie_source" }
new const zclass8_clawmodel[] = { "v_knife_zombie.mdl" }
const zclass8_health = 2700
const zclass8_speed = 300
const Float:zclass8_gravity = 1.0
const Float:zclass8_knockback = 1.25

new g_zclass_Regen

public plugin_init()
{
   g_zclass_regen_toggle = register_cvar("zp_zclass_regen", "1")
   g_time = register_cvar("zp_regen_time", "2")
   g_amount = register_cvar("zp_regen_amount", "25")
   
   register_event("Damage", "SetRegeneration", "be", "2>0")
}

public plugin_precache()
{
   register_plugin("[ZP] Zclass : Zombie Regenerator", "1.0", "The_Thing")
   
   g_zclass_Regen = zp_register_zombie_class(zclass8_name, zclass8_info, zclass8_model, zclass8_clawmodel, zclass8_health, zclass8_speed, zclass8_gravity, zclass8_knockback)
}

public SetRegeneration(player)
{
   if (!get_pcvar_num(g_zclass_regen_toggle) || !is_user_alive(player) || !zp_get_user_zombie(player))
   return PLUGIN_CONTINUE
   
   if (zp_get_user_zombie_class(player) != g_zclass_Regen)
   return PLUGIN_CONTINUE
   
   if (get_user_health(player) < zp_get_zombie_maxhealth(player))
      set_task(get_pcvar_float(g_time), "Regenerate", player, _, _, "b")
   
   return PLUGIN_CONTINUE
}

public Regenerate(player)
{
   if (!get_pcvar_num(g_zclass_regen_toggle) || !is_user_alive(player) || !zp_get_user_zombie(player))
   return PLUGIN_CONTINUE
   
   if (zp_get_user_zombie_class(player) != g_zclass_Regen)
   return PLUGIN_CONTINUE
   
   new regen_health = get_user_health(player)
   new max_health = zp_get_zombie_maxhealth(player) - regen_health
   
   if (max_health <= get_pcvar_num(g_amount))
   {
      set_pev(player, pev_health, regen_health + float(max_health))
      remove_task(player)
   }
   
   set_pev(player, pev_health, regen_health + get_pcvar_float(g_amount))
   
   return PLUGIN_CONTINUE
}

public zp_user_infected_post(player, infector)
{
   if (zp_get_user_zombie_class(infector) == g_zclass_Regen)
   {   
      new regen_health = get_user_health(player)
      new max_health = zp_get_zombie_maxhealth(player) - regen_health
   
      if (max_health <= get_pcvar_num(g_amount))
      {
         set_pev(infector, pev_health, regen_health + float(max_health))
         remove_task(infector)
         
         return PLUGIN_CONTINUE
      }
   
      set_pev(infector, pev_health, regen_health + get_pcvar_float(g_amount))
   }
   return PLUGIN_CONTINUE
}

Szerző:  CheeseDave [2011.07.13. 14:37 ]
Hozzászólás témája:  Re: [ZP] Class: Regeneration

A 25-ös lépekedéseket azért megteszi? Tehát ok hogy gyorsan nő, de a mennyiség megfelelő?

Az időzítéssel itt lesz hiba:

set_task(get_pcvar_float(g_time), "Regenerate", player, _, _, "b")

Próbálj a cvar-nak nagyobb értéket adni:
zp_regen_time 5.0

Szerző:  Metal [2011.07.14. 11:57 ]
Hozzászólás témája:  Re: [ZP] Class: Regeneration

Az a gond ezzel, hogy minden találatkor elkezdi regenerálni, pontosabban, minden találat után 25 HPt kap. Ergo ha gyorsan meglövöd 2*, akkor 2 mp után már +50ben lesz. AHoz hogy működjön, én átírnám teljesen, eleve futtatnék egy állandó taskot, ami önmagát hívja meg, idre. Ha nem megy, jelezd és megírom.

Szerző:  Halfx [2011.07.14. 12:50 ]
Hozzászólás témája:  Re: [ZP] Class: Regeneration

Köszi a segítséget, de ugyan úgy semmi. :/

Ha megkérhetlek, akkor írd meg nekem légyszi! ^^

Köszönöm! ;)

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/