Raised This Month: $ Target: $400
 0% 

[ZP] Regeneration: some bugs


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Freddy2304
Junior Member
Join Date: Dec 2006
Old 06-05-2010 , 13:53   [ZP] Regeneration: some bugs
Reply With Quote #1

(I've posted it here because I think the bugs have nothing to do with ZP)
First of all, I edited this regeneration plugin because the regeneration was caused by every single hit (10 hits = 10x 10hp/sec - now fixed).
But there is an other bug: when you die during regeneration, you will spawn with 0 hp next round.

Original code:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>

new g_Statusg_Timeg_Amountg_ZombiePlagueg_Nemesisg_FirstZombieg_LastZombie;

public 
plugin_init()
{
    
register_plugin("ZP: Regeneration""1.2 Final Fixed""hleV");

    
g_Status register_cvar("zp_regeneration""1");
    
g_Time register_cvar("zp_regen_time""1");
    
g_Amount register_cvar("zp_regen_amount""10");
    
g_Nemesis register_cvar("zp_regen_nemesis""1");
    
g_FirstZombie register_cvar("zp_regen_firstzombie""1");
    
g_LastZombie register_cvar("zp_regen_lastzombie""1");

    
register_event("Damage""SetRegeneration""be""2>0");

    
g_ZombiePlague get_cvar_pointer("zp_on");
}

public 
SetRegeneration(Client)
{
    if (!
g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client) || !zp_get_user_zombie(Client))
        return;

    new 
Health get_user_health(Client);

    if (
Health 1)
        return;

    if (!
get_pcvar_num(g_Nemesis) && zp_get_user_nemesis(Client))
        return;

    if (!
get_pcvar_num(g_FirstZombie) && zp_get_user_first_zombie(Client))
        return;

    if (!
get_pcvar_num(g_LastZombie) && zp_get_user_last_zombie(Client))
        return;
    
    if (
damagetype DMG_FALL)
        return;
    
    
remove_task(Client);
    
    if (
get_user_health(Client) < zp_get_zombie_maxhealth(Client))
        
set_task(get_pcvar_float(g_Time), "Regenerate"Client__"b");
}

public 
Regenerate(Client)
{
    if (!
g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client))
        return;

    new 
Health get_user_health(Client);

    if (
Health 1)
        return;

    new 
NeededHealth zp_get_zombie_maxhealth(Client) - Health;

    if (
NeededHealth <= get_pcvar_num(g_Amount))
    {
        
set_pev(Clientpev_healthHealth float(NeededHealth));
        
remove_task(Client);

        return;
    }

    
set_pev(Clientpev_healthHealth get_pcvar_float(g_Amount));

My version (maybe i included too much but that's not the point):
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <hamsandwich>
#include <fun>
#include <fakemeta_util>

new g_Statusg_Timeg_Amountg_ZombiePlagueg_Nemesisg_FirstZombieg_LastZombie;
//new g_Delay

public plugin_init()
{
    
register_plugin("ZP: Regeneration""1.2 Final Fixed""hleV");
    
RegisterHam(Ham_TakeDamage"player""bacon_takedamage_player");
    
    
g_Status register_cvar("zp_regeneration""1");
    
g_Time register_cvar("zp_regen_time""1");
    
//g_Delay = register_cvar("zp_regen_delay", "2");
    
g_Amount register_cvar("zp_regen_amount""10");
    
g_Nemesis register_cvar("zp_regen_nemesis""1");
    
g_FirstZombie register_cvar("zp_regen_firstzombie""1");
    
g_LastZombie register_cvar("zp_regen_lastzombie""1");

    
//register_event("Damage", "SetRegeneration", "be", "2>0");
    
    
g_ZombiePlague get_cvar_pointer("zp_on");
}

/*
public SetRegeneration(Client)
{
    if (!g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client) || !zp_get_user_zombie(Client))
        return;

    new Health = get_user_health(Client);

    if (Health < 1)
        return;

    if (!get_pcvar_num(g_Nemesis) && zp_get_user_nemesis(Client))
        return;

    if (!get_pcvar_num(g_FirstZombie) && zp_get_user_first_zombie(Client))
        return;

    if (!get_pcvar_num(g_LastZombie) && zp_get_user_last_zombie(Client))
        return;

    if (get_user_health(Client) < zp_get_zombie_maxhealth(Client) && !task_exists(Client, 0))
        set_task(get_pcvar_float(g_Time), "Regenerate", Client, _, _, "b");
}
*/

public bacon_takedamage_player(victiminflictorattackerFloat:damagedamagetype)
{
    if (!
g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(victim) || !is_user_alive(victim) || !zp_get_user_zombie(victim))
        return;

    new 
Health get_user_health(victim);

    if (
Health 1)
        return;

    if (!
get_pcvar_num(g_Nemesis) && zp_get_user_nemesis(victim))
        return;

    if (!
get_pcvar_num(g_FirstZombie) && zp_get_user_first_zombie(victim))
        return;

    if (!
get_pcvar_num(g_LastZombie) && zp_get_user_last_zombie(victim))
        return;
        
    if (
damagetype DMG_FALL)
        return;
    
    
remove_task(victim);
        
    if (
get_user_health(victim) < zp_get_zombie_maxhealth(victim) && !task_exists(victim0))
        
set_task(get_pcvar_float(g_Time), "Regenerate"victim__"b");
}

public 
Regenerate(Client)
{
    if (!
g_ZombiePlague || !get_pcvar_num(g_Status) || !is_user_connected(Client) || !is_user_alive(Client))
        return;

    new 
Health get_user_health(Client);

    if (
Health 1)
        return;

    new 
NeededHealth zp_get_zombie_maxhealth(Client) - Health;

    if (
NeededHealth <= get_pcvar_num(g_Amount))
    {
        
//set_pev(Client, pev_health, Health + float(NeededHealth));
        //set_user_health(Client, Health + NeededHealth);
        
fm_set_user_health(ClientHealth NeededHealth);
        
remove_task(Client);

        return;
    }

    
//set_pev(Client, pev_health, Health + get_pcvar_float(g_Amount));
    //set_user_health(Client, Health + get_pcvar_num(g_Amount));
    
fm_set_user_health(ClientHealth get_pcvar_num(g_Amount));

As you can see, I tried several methods to set the health but each of them had bugs.
e.g.
PHP Code:
// 0hp after respawn
set_pev(Clientpev_healthHealth float(NeededHealth));

// player dies after respawn when he was killed while regeneration was activ the round before
set_user_health(ClientHealth NeededHealth);

// same thing here
fm_set_user_health(ClientHealth NeededHealth); 
I already used the search function but I couldn't find an answer.

And another request:
Can someone add a delay before regeneration starts. I really don't know how to do that.
e.g.
zombie got damage -> 2 seconds without damage -> regeneration starts

Thank you in advance
Freddy2304
Freddy2304 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode