add_hp_down_trigger - ryzom/ryzomcore GitHub Wiki


title: Add HP Down Trigger description: published: true date: 2023-03-12T14:04:40.301Z tags: editor: markdown dateCreated: 2023-03-12T14:04:37.134Z

addHpDownTrigger

The addHpDownTrigger native AI script function registers a trigger on HP decreases. Whenever the HP level of a bot downcrosses the threshold, it triggers the specified user event or script function. Several triggers can be registered on the same group, even with the same threshold and event.

Syntax

()addHpDownTrigger(threshold: f, user_event_n: f) // addHpDownTrigger_ff_
()addHpDownTrigger(threshold: f, callback: s) // addHpDownTrigger_fs_

Arguments

  • threshold (float): The HP threshold that triggers the event or function.

()addHpDownTrigger(f, f)

  • user_event_n (float): The user event number to trigger.

()addHpDownTrigger(f, s)

  • callback (string): The name of the script function to call.

Examples

Trigger user event

()addHpDownTrigger(0.5, 5);

This example code registers a trigger that will trigger user event 5 when the HP level of a bot downcrosses 0.5.

Call script function

()addHpDownTrigger(0.5, "onHPDecrease");

This example code registers a trigger that will call the "onHPDecrease" script function when the HP level of a bot downcrosses 0.5.

⚠️ **GitHub.com Fallback** ⚠️