AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved HP Bar (https://forums.alliedmods.net/showthread.php?t=325520)

MayroN 06-25-2020 21:11

HP Bar
 
There is a bar ( Health) Sprite that counts health from the end
In this section of the code produces Health from the beginning
How do I set the countdown from the end?
Thanks
PHP Code:

    if(HEALTH_BOSS < (cso_boss_health 1000.0))
    {
        
set_pev(y_hpbarpev_frame100.0)
    } else {
        
set_pev(y_hpbarpev_frame0.0 + ((((cso_boss_health 1000.0) - ) * 100) / HEALTH_BOSS))
    } 


AnimalMonster 06-26-2020 08:46

Re: HP Bar
 
Sorry but i don't really know.....
maybe try to inverse them??
PHP Code:

if(HEALTH_BOSS < (cso_boss_health 1000.0))
    {
        
set_pev(y_hpbarpev_frame0.0 + ((((cso_boss_health 1000.0) - ) * 100) / HEALTH_BOSS))
    } else {
        
set_pev(y_hpbarpev_frame100.0)
    } 


supertrio17 06-26-2020 08:49

Re: HP Bar
 
Can you share the whole plugin with us?

MayroN 06-26-2020 17:30

Re: HP Bar
 
The solution was this
PHP Code:

set_pev(y_hpbarpev_frame0.0 + ((((cso_boss_health 1000.0) - ) * 100) / HEALTH_BOSS)) 

>>>
PHP Code:

set_pev(y_hpbarpev_frame100.0 - ((((cso_boss_health 1000.0) - ) * 100.0) / HEALTH_BOSS)) 


MayroN 06-28-2020 20:29

Re: HP Bar
 
I'll ask again here.How to get rid of sharp jerks of the sprite with the movement of Entity here?
PHP Code:

public create_phobos()
{
    new 
ent create_entity("info_target")

        if(!
is_valid_ent(ent))
          return;


    
y_think ent
    
static Float:Origin[3]
    
Origin[0] = y_spawn_points[0]
    
Origin[1] = y_spawn_points[1]
    
Origin[2] = y_spawn_points[2]
    
entity_set_origin(entOrigin)
    
entity_set_float(entEV_FL_takedamage1.0)
    
entity_set_float(entEV_FL_healthnpc_healthpoints 1000.0)
    
entity_set_string(entEV_SZ_classname"npc_phobos")
    
entity_set_model(entnpc_mdl)
    
entity_set_int(entEV_INT_solidSOLID_BBOX)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_PUSHSTEP)
    new 
Float:maxs[3] = {25.050.0200.0}
    new 
Float:mins[3] = {-25.0, -50.0, -35.0}
    
entity_set_size(entminsmaxs)
    
entity_set_int(entEV_INT_modelindexy_npc_mdl)
    
anim(ent5)
    
set_task(0.1"phobos_done"ent+npc_start_think)            // Phobos prepare time
    
if(!y_start_npc)
    {
        
y_start_npc 1
        RegisterHamFromEntity
(Ham_TakeDamageent"phobos_take_damage"1)
    }
    for(new 
0get_maxplayers(); i++)
    {
        if(
is_user_alive(i) && entity_range(enti) <= 400)
        {

        }
    }
    
y_hpbar create_entity("env_sprite")
    
set_pev(y_hpbarpev_scale0.2)
    
set_pev(y_hpbarpev_ownerent)
    
engfunc(EngFunc_SetModely_hpbarhp_spr)    
    
set_task(0.1"phobos_ready"ent+npc_restart__"b")
    
set_task(random_float(7.015.0), "punish"npc_ability)
}

public 
phobos_ready(ent)
{
    
ent -= npc_restart
    
if(!pev_valid(ent))
    {
        
remove_task(ent+npc_restart)
        return
    }
    static 
Float:Origin[3], Float:phobos_health
    pev
(entpev_originOrigin)
    
Origin[2] += 270.0    
    engfunc
(EngFunc_SetOriginy_hpbarOrigin)
    
pev(entpev_healthphobos_health)
    if(
npc_healthpoints < (phobos_health 1000.0))
    {
        
set_pev(y_hpbarpev_frame100.0)
    }
    else
    {
        
set_pev(y_hpbarpev_frame100.0 - ((((phobos_health 1000.0) - ) * 100) / npc_healthpoints))
    }        



AnimalMonster 06-29-2020 22:38

Re: HP Bar
 
Quote:

Originally Posted by MayroN (Post 2707725)
I'll ask again here.How to get rid of sharp jerks of the sprite with the movement of Entity here?
PHP Code:

public create_phobos()
{
    new 
ent create_entity("info_target")

        if(!
is_valid_ent(ent))
          return;


    
y_think ent
    
static Float:Origin[3]
    
Origin[0] = y_spawn_points[0]
    
Origin[1] = y_spawn_points[1]
    
Origin[2] = y_spawn_points[2]
    
entity_set_origin(entOrigin)
    
entity_set_float(entEV_FL_takedamage1.0)
    
entity_set_float(entEV_FL_healthnpc_healthpoints 1000.0)
    
entity_set_string(entEV_SZ_classname"npc_phobos")
    
entity_set_model(entnpc_mdl)
    
entity_set_int(entEV_INT_solidSOLID_BBOX)
    
entity_set_int(entEV_INT_movetypeMOVETYPE_PUSHSTEP)
    new 
Float:maxs[3] = {25.050.0200.0}
    new 
Float:mins[3] = {-25.0, -50.0, -35.0}
    
entity_set_size(entminsmaxs)
    
entity_set_int(entEV_INT_modelindexy_npc_mdl)
    
anim(ent5)
    
set_task(0.1"phobos_done"ent+npc_start_think)            // Phobos prepare time
    
if(!y_start_npc)
    {
        
y_start_npc 1
        RegisterHamFromEntity
(Ham_TakeDamageent"phobos_take_damage"1)
    }
    for(new 
0get_maxplayers(); i++)
    {
        if(
is_user_alive(i) && entity_range(enti) <= 400)
        {

        }
    }
    
y_hpbar create_entity("env_sprite")
    
set_pev(y_hpbarpev_scale0.2)
    
set_pev(y_hpbarpev_ownerent)
    
engfunc(EngFunc_SetModely_hpbarhp_spr)    
    
set_task(0.1"phobos_ready"ent+npc_restart__"b")
    
set_task(random_float(7.015.0), "punish"npc_ability)
}

public 
phobos_ready(ent)
{
    
ent -= npc_restart
    
if(!pev_valid(ent))
    {
        
remove_task(ent+npc_restart)
        return
    }
    static 
Float:Origin[3], Float:phobos_health
    pev
(entpev_originOrigin)
    
Origin[2] += 270.0    
    engfunc
(EngFunc_SetOriginy_hpbarOrigin)
    
pev(entpev_healthphobos_health)
    if(
npc_healthpoints < (phobos_health 1000.0))
    {
        
set_pev(y_hpbarpev_frame100.0)
    }
    else
    {
        
set_pev(y_hpbarpev_frame100.0 - ((((phobos_health 1000.0) - ) * 100) / npc_healthpoints))
    }        



I don't really know but you can edit the spirite if there are some sharp thing you don t wanna see:)
#idon'treallyknow


All times are GMT -4. The time now is 10:48.

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