set_hp_scale - ryzom/ryzomcore GitHub Wiki


title: Set HP Scale description: published: true date: 2023-03-14T14:47:54.437Z tags: editor: markdown dateCreated: 2023-03-14T14:44:46.212Z

setHPScale

The setHPScale native AI script function sets the current HP level of each bot in the current group based on a given coefficient. The maximum HP of the bot is used to calculate the HP level to be set.

Syntax

setHPScale(coef: f)

Arguments

  • coef (float): The percentage of the bot's maximum HP that each bot will have after the function call. The coefficient must be in the range [0,1].

Examples

setHPScale(0.8);

This example code sets the current HP level of each bot in the current group to 80% of the bot's maximum HP.

Notes

The setHPScale function updates the current HP level of each bot in the group based on the given coefficient by sending the difference with the current HP. The HP difference is calculated using the following formula: maxHP * coef - currentHP.

If a bot is not spawned, the function will skip that bot.

See also

  • setHPLevel : Sets the current HP level of each bot in the current group to a specified value. The value is an absolute HP level rather than a percentage of the bot's maximum HP.
⚠️ **GitHub.com Fallback** ⚠️