Hi , i want to check if current victim health (gondor health) is lower than (main health / 2) and also (/3) , however as you can see below i made it work , but it's not efficient , hope that you give me an efficient way of checking victim health.
Code:
new g_gondor_health = 1600 // an example
Code:
public On_Player_Take_Damage(victim, inflictor, attacker, Float:dmg, dmgbits)
{
if (attacker == victim)
return HAM_IGNORED
if (check_user_class(g_gondar_class , victim))
{
check_health(victim) // checking victim (gondor) health
}
return HAM_HANDLED
}
Code:
check_health(index)
{
new current_health
current_health = get_user_health(index)
if ((g_gondar_health / 2) >= current_health)
{
set_user_maxspeed(index , 450.0)
set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,155)
message_begin(MSG_ALL,iconstatus,{0,0,0},index)
write_byte(1) // status (0=hide, 1=show, 2=flash)
write_string("dmg_poison") // sprite name
write_byte(255) // red
write_byte(255) // green
write_byte(0) // blue
message_end()
}
if((g_gondar_health / 3) >= current_health)
{
set_user_maxspeed(index , 800.0)
set_user_rendering(index, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha,55)
message_begin(MSG_ALL,iconstatus,{0,0,0},index)
write_byte(1) // status (0=hide, 1=show, 2=flash)
write_string("dmg_poison") // sprite name
write_byte(255) // red
write_byte(0) // green
write_byte(0) // blue
message_end()
}
}