Raised This Month: $51 Target: $400
 12% 

hp regeneration


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-15-2020 , 21:41   hp regeneration
Reply With Quote #1

i tried to edit a zp zombie class to base builder and the hp does not regenerate, any idea why?

PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <basebuilder>

#define TASK_REGENERATION     134926
#define TASK_BLOCK_REGEN     151718
#define ID_REGEN         (taskid - TASK_REGENERATION)
#define ID_BLOCK_REGEN         (taskid - TASK_BLOCK_REGEN)

new g_endroundg_maxplayersg_connected[33], g_alive[33], g_zombie[33], g_blockregen[33], g_maxhealth[33]
new 
cvar_regen_maxcvar_regen_addcvar_regen_intervalcvar_regen_dmgdelay
new chaceRegenAddFloat:chaceRegenMaxFloat:chaceRegenIntervalFloat:chaceRegenDmgDelay
new gMsgScreenFadeg_hamczbotscvar_botquota
new const sound_regen[] = "zombie_plague/zombi_heal.wav"

#define is_user_valid_connected(%1) (1 <= %1 <= g_maxplayers && g_connected[%1])
#define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && g_alive[%1])
#define is_user_valid_zombie(%1) (1 <= %1 <= g_maxplayers && g_zombie[%1])
#define is_user_valid_blockregen(%1) (1 <= %1 <= g_maxplayers && g_blockregen[%1])

new const zclass_name[] = { "Witch Zombie" }
new const 
zclass_info[] = { "\y[Regeneration]" }
new const 
zclass_model[] = { "hs_witch" }
new const 
zclass_clawmodel[] = { "hs_v_witch" }
const 
zclass_health 3000
const zclass_speed 285
const Float:zclass_gravity 1.0
const Float:zclass_knockback 0.25

public plugin_precache()
{
    
precache_sound(sound_regen)
}

public 
plugin_init()
{
    
register_plugin("[BB] Zombie Class: Witch""1.0""witch.")
    
zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
    
RegisterHam(Ham_Spawn"player""ham_spawn_post"1)
    
RegisterHam(Ham_Killed"player""ham_player_killed")
    
RegisterHam(Ham_TakeDamage"player""ham_take_damage")
    
    
cvar_regen_max register_cvar("zp_regen_max""1.0")
    
cvar_regen_add register_cvar("zp_regen_add""250")
    
cvar_regen_interval register_cvar("zp_regen_interval""1.0")
    
cvar_regen_dmgdelay register_cvar("zp_regen_dmg_delay""5")
    
    
cvar_botquota get_cvar_pointer("bot_quota")
    
    
g_maxplayers get_maxplayers()
    
gMsgScreenFade get_user_msgid("ScreenFade")
}

public 
client_putinserver(id)
{
    
g_connected[id] = true
    g_zombie
[id] = false
    
    
if (is_user_bot(id) && !g_hamczbots && cvar_botquotaset_task(0.1"register_ham_czbots"id);    
}

public 
register_ham_czbots(id)
{
    if (
g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))
        return;
    
    
RegisterHamFromEntity(Ham_Spawnid"ham_spawn_post"1)
    
RegisterHamFromEntity(Ham_Killedid"ham_player_killed")
    
RegisterHamFromEntity(Ham_TakeDamageid"ham_take_damage")    
    
    
g_hamczbots true
    
    
if (is_user_alive(id)) ham_spawn_post(id);
}

public 
client_disconnect(id)
{
    
g_connected[id] = false
    g_alive
[id] = false
}

public 
event_round_start()
{
    
g_endround false
    
    chaceRegenMax 
get_pcvar_float(cvar_regen_max)
    
chaceRegenAdd get_pcvar_num(cvar_regen_add)
    
chaceRegenInterval get_pcvar_float(cvar_regen_interval)
    
chaceRegenDmgDelay get_pcvar_float(cvar_regen_dmgdelay)    
}

public 
zp_round_ended()
{
    
g_endround true
}

public 
ham_spawn_post(id)
{
    if(!
is_user_alive(id)) return;
    
    
g_alive[id] = true
    
    
if(zp_get_user_zombie(id))
    {
        
g_zombie[id] = true
    
}
    else 
g_zombie[id] = false
}

public 
ham_player_killed(victimattackershouldgib)
{
    
g_alive[victim] = false
}

public 
ham_take_damage(iVictimiInflictoriAttackerFloat:fDamageiDmgBits)
{
    if(
is_user_valid_connected(iVictim) && is_user_valid_alive(iVictim) && is_user_valid_zombie(iVictim))
    {    
        
g_blockregen[iVictim] = true
        
        remove_task
(iVictim+TASK_BLOCK_REGEN)
        
set_task(chaceRegenDmgDelay"RemoveBlockRegen"iVictim+TASK_BLOCK_REGEN)
    }
}

public 
zp_user_humanized_post(id)
{
    
g_zombie[id] = false
}

public 
RemoveBlockRegen(taskid)
{
    
g_blockregen[ID_BLOCK_REGEN] = false
    
    remove_task
(ID_BLOCK_REGEN+TASK_REGENERATION)
    
set_task(chaceRegenInterval"RegenHpProcess"ID_BLOCK_REGEN+TASK_REGENERATION)
}

public 
RegenHpProcess(taskid)
{
    if(
g_endround) return;
    
    if(!
is_user_valid_blockregen(ID_REGEN) && is_user_valid_alive(ID_REGEN) && is_user_valid_zombie(ID_REGEN))
    {
        if(
g_maxhealth[ID_REGEN] != -1)
        {
            new 
iMaxRegen floatround(g_maxhealth[ID_REGEN] * chaceRegenMax)
            new 
iCurHealth get_user_health(ID_REGEN)
            if (
iCurHealth iMaxRegen)
            {
                new 
iNewHealth iCurHealth chaceRegenAdd
                
if(iNewHealth iMaxRegenset_user_health(ID_REGENiMaxRegen);
                else 
set_user_health(ID_REGENiNewHealth);
                
                
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade, {000}, ID_REGEN)
                
write_short(1<<10)
                
write_short(1<<10)
                
write_short(0x0000)
                
write_byte(0)
                
write_byte(200)
                
write_byte(0)
                
write_byte(50)
                
message_end()
                
                
client_cmd(ID_REGEN"spk %s"sound_regen);
                
                
set_task(chaceRegenInterval"RegenHpProcess"ID_REGEN+TASK_REGENERATION)
            }
        }
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Old 03-16-2020, 02:58
+ARUKARI-
This message has been deleted by +ARUKARI-. Reason: miss code
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 03-16-2020 , 08:12   Re: hp regeneration
Reply With Quote #2

Do you need this?




PHP Code:
#include <amxmodx>
#include <amxconst>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Health Regenerator"
#define VERSION "0.1"
#define AUTHOR "Aoi.Kagase"

#define TASK_REGENERATION    134926
#define TASKID_REGEN          id+TASK_REGENERATION
#define UID_REGEN             id-TASK_REGENERATION

new gCEnable;
new 
gCHeal;
new 
gCSeconds;
new 
gCMaxHealth;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
gCEnable    register_cvar("amx_regen_enable",        "1");
    
gCHeal        register_cvar("amx_regen_heal",         "2");
    
gCSeconds   register_cvar("amx_regen_seconds",     "0.2");
    
gCMaxHealth register_cvar("amx_regen_maxhealth",     "100.0");

    
RegisterHam(Ham_TakeDamage"player""take_damage");

    return 
PLUGIN_HANDLED;
}

public 
client_disconnected(id)
{
    if (
task_exists(TASKID_REGEN))
        
remove_task(TASKID_REGEN);

    return 
PLUGIN_HANDLED;
}


stock bool:fm_is_user_alive(id)
{
    return (
pev(id,pev_deadflag) == DEAD_NO); 
}

stock fm_set_user_health(idFloat:health)    
{
    
health set_pev(idpev_healthhealth) : user_kill(id1);
}

stock Float:fm_get_user_health(id)
{
    new 
Float:health;
    
pev(idpev_healthhealth);
    return 
health;
}

public 
Regeneration(id)
{
    if (
get_pcvar_num(gCEnable) == 0)
        return 
PLUGIN_CONTINUE;

    if (
fm_is_user_alive(UID_REGEN))
    {
        new 
Float:health    Float:fm_get_user_health(UID_REGEN);
        new 
Float:heal       Float:get_pcvar_float(gCHeal);
        new 
Float:maxhealth Float:get_pcvar_float(gCMaxHealth);

        new 
Float:newHealth Float:(health heal);
        if(
floatround(newHealth) <= floatround(maxhealth))
        {
            
client_print(UID_REGENprint_chat"[DEBUG] Regenerate %f/%f"newHealthmaxhealth);
            
fm_set_user_health(UID_REGENnewHealth);
        }
        else
        {
            
client_print(UID_REGENprint_chat"[DEBUG] Regenerate END. %f/%f"newHealthmaxhealth);
            if (
task_exists(id))
                
remove_task(id);
        }
    }
    return 
PLUGIN_CONTINUE;


public 
take_damage(victiminflictorattackerFloat:damagebits)
{
    
client_print(victimprint_chat"[DEBUG] Regenerator START.");
    new 
Float:gensec Float:get_pcvar_num(gCSeconds);
    
set_task(gensec"Regeneration", (victim TASK_REGENERATION), ""0"b"0);

Health calculations must be done on Float type.
__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 03-18-2020 at 06:56.
+ARUKARI- is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-16-2020 , 10:49   Re: hp regeneration
Reply With Quote #3

not really, i want a zombie class for basebuilder which has hp regeneration, like in 3 seconds, you got +200hp, i found some on google and tried to edited but didnt worked, take a look.

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


new g_zclass_regen_toggleg_timeg_amount

new const zclass8_name[] = { "Witch Zombie" }
new const 
zclass8_info[] = { "\y[Regeneration]" }
new const 
zclass8_model[] = { "hs_witch" }
new const 
zclass8_clawmodel[] = { "hs_v_witch" }
const 
zclass8_health 3500
const zclass8_speed 285
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""100")
    
    
register_event("Damage""SetRegeneration""be""2>0")
}

public 
plugin_precache()
{
    
register_plugin("[BB] Zombie Class: Witch""1.0""nutu.")
    
    
g_zclass_Regen zp_register_zombie_class(zclass8_namezclass8_infozclass8_modelzclass8_clawmodelzclass8_healthzclass8_speedzclass8_gravityzclass8_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(playerpev_healthregen_health float(max_health))
        
remove_task(player)
    }
    
    
set_pev(playerpev_healthregen_health get_pcvar_float(g_amount))
    
    return 
PLUGIN_CONTINUE
}

public 
zp_user_infected_post(playerinfector)
{
    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(infectorpev_healthregen_health float(max_health))
            
remove_task(infector)
            
            return 
PLUGIN_CONTINUE
        
}
    
        
set_pev(infectorpev_healthregen_health get_pcvar_float(g_amount))
    }
    return 
PLUGIN_CONTINUE

If i remplace include zp with bb it will not work, since natives come from zp
any idea how or where could i find a source for that? have searched almost all night for one :]
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 03-17-2020 , 08:53   Re: hp regeneration
Reply With Quote #4

i tried basebuilder.
https://imgur.com/Kixi76J

https://imgur.com/4lUSW3i


PHP Code:
public ham_take_damage(iVictimiInflictoriAttackerFloat:fDamageiDmgBits)
{
    if(
is_user_valid_connected(iVictim) && is_user_valid_alive(iVictim) && is_user_valid_zombie(iVictim))
    {
        
// if (!g_regening[iVictim] )
        
if (!is_user_bot(iVictim))
        {
            
client_print(iVictimprint_chat"[DEBUG] Regenerator START.");
            
client_print(iVictimprint_chat"[DEBUG] Regenerator %f"chaceRegenDmgDelay);

            
// g_regening[iVictim] = true;
            // delay interval
            
g_blockregen[iVictim] = get_gametime() + chaceRegenDmgDelay;

            
set_task(chaceRegenInterval"RegenHpProcess", (iVictim TASK_REGENERATION), ""0"b"0);
        }
    }
}

public 
RegenHpProcess(taskid)
{
    if (
g_endround
        return 
PLUGIN_CONTINUE;
    
    if (
get_gametime() < g_blockregen[ID_REGEN])
        return 
PLUGIN_CONTINUE;
    
    if(
is_user_valid_alive(ID_REGEN) && is_user_valid_zombie(ID_REGEN))
    {
        
// zclass_health => exists get function?
        
new Float:iMaxRegen  zclass_health chaceRegenMax;
        new 
Float:iCurHealth fm_get_user_health(ID_REGEN);
        
        
client_print(ID_REGENprint_chat"[DEBUG] Regenerate %f/%f"iCurHealthiMaxRegen);
        
        if (
iCurHealth iMaxRegen)
        {
            new 
Float:iNewHealth iCurHealth chaceRegenAdd
            
if(iNewHealth iMaxRegen
                
fm_set_user_health(ID_REGENiMaxRegen);
            else
                
fm_set_user_health(ID_REGENiNewHealth);
            
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade, {000}, ID_REGEN)
            
write_short(1<<10)
            
write_short(1<<10)
            
write_short(0x0000)
            
write_byte(0)
            
write_byte(200)
            
write_byte(0)
            
write_byte(50)
            
message_end()
                
            
client_cmd(ID_REGEN"spk %s"sound_regen);
        } else {
            
remove_task(taskid);
        }
    }
    return 
PLUGIN_CONTINUE;

__________________
GitHub
SteamWishlist

六四天安門事件

Last edited by +ARUKARI-; 03-18-2020 at 06:58.
+ARUKARI- is offline
Reply



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 00:59.


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