A good idea to give normalized health to the enemies?

Hi,

I would like to ask if there is a particular reason to give normalized health to the enemies for them to decide who to attack.

It does work while each units have the same maxHealth, but if I wanted to create variations in the units, like a unit that only have max 10 health, then it could cause problems.

An enemy getting normalized health from two friendly unit, one with 10/10hp, and the other with 90/100hp, would attack the one with 90hp thinking it has the lower health of the two.

Not sure if it is an error or if it is done for a particular reason (or if it is changed later in the course).

Thanks!

2 Likes

Welcome to the community @Jonathan_Lorenz

This is a good point. I don’t think units with variable health was in scope of Hugo’s plan.

1 Like

I return a “score” that gives a bit more weight to lower max health characters than higher max health characters.

public float AttackScore()
{
    float unitPerHealthPoint = 100/maxHealth;  //the higher the health, the lower this score will be
    return (maxHealth-currentHealth) * unitPerHealthPoint + unitPerHealthPoint;
}

So… if all targets have max health, the highest score will be returned by the unit with the lowest max health.
After that, more weight is given to the damage of lower max health characters than higher max health characters.

7 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms