AI Scripting Native Functions Reference

Spawn / Despawn

spawn__

Spawns the current group.

Arguments: ->

()spawn(); // spawn group.

despawn_f_

Depawns the current group. If the group does not despawn immediately it will wait until it is idle, e.g. not fighting or fleeing, to despawn.

Arguments: f(Immediately)->

Parameters:

[in]
Immediately0 or 1, with 1 indicating an immediate despawn
()despawn(0); // despawn group.
()despawn(1); // immediately despawn the group.

 

Event Handler Creation

addHpUpTrigger_ff_

Registers a trigger on HP increases. Whenever the HP level of a bot crosses the threshold upwards it will trigger the specified user event. The threshold is a factor of the total HP. Several triggers can be registered on the same group, even with the same threshold and event.

Arguments: f(Threshold),f(user_event_n)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
user_event_nthe user event to trigger
()addHpUpTrigger(0.5, 4); // emit user event 4 if a bot increases HP by 50%

 

addHpDownTrigger_ff_

Registers a trigger on HP decreases. Whenever the HP level of a bot crosses the threshold downwards it will trigger the specified user event. The threshold is a factor of the total HP. Several triggers can be registered on the same group, even with the same threshold and event.

Arguments: f(Threshold),f(user_event_n)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
user_event_nthe user event to trigger
()addHpUpTrigger(0.5, 5); // emit user event 5 if a bot decreases HP by 50%

 

delHpUpTrigger_ff_

Unregisters a trigger on HP increases for any triggers matching both the Threshold and user_event_n parameters.

Arguments: f(Threshold),f(user_event_n)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
user_event_nthe user event to trigger
()delHpUpTrigger(0.5, 4);

 

delHpDownTrigger_ff_

Unregisters a trigger on HP decreases for any triggers matching both the Threshold and user_event_n parameters.

Arguments: f(Threshold),f(user_event_n)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
user_event_nthe user event to trigger
()delHpDownTrigger(0.5, 4);

 

addHpUpTrigger_fs_

Registers a trigger on HP increases. Whenever the HP level of a bot crosses the threshold upwards it will trigger the specified script function. The threshold is a factor of the total HP. Several triggers can be registered on the same group, even with the same threshold and function.

Arguments: f(Threshold),s(Callback)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
Callbackthe script callback to trigger
()addHpUpTrigger(0.5, "onHPIncrease"); // call script function onHPIncrease if a bot increases HP by 50%

 

addHpDownTrigger_fs_

Registers a trigger on HP decreases. Whenever the HP level of a bot crosses the threshold downwards it will trigger the specified script function. The threshold is a factor of the total HP. Several triggers can be registered on the same group, even with the same threshold and function.

Arguments: f(Threshold),s(Callback)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
Callbackthe script callback to trigger
()addHpUpTrigger(0.5, "onHPDecrease"); // call script function onHPDecrease if a bot decreases HP by 50%

 

delHpUpTrigger_fs_

Unregisters a trigger on HP increases for any triggers matching both the Threshold and Callback parameters.

Arguments: f(Threshold),s(Callback)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
Callbackthe script callback to be triggered
()delHpUpTrigger(0.5, "onHPIncrease");

 

delHpDownTrigger_fs_

Unregisters a trigger on HP decreases for any triggers matching both the Threshold and Callback parameters.

Arguments: f(Threshold),s(Callback)->

Parameters:

[in]
Thresholdthe HP threshold factor
[in]
Callbackthe user event to trigger
()delHpDownTrigger(0.5, "onHPDecrease");

addNamedEntityListener_ssf_

Associates a listener with a named entity property. Whenever that field changes the specified user event is triggered. Valid property names are:

  • state
  • param1
  • param2

The name of the entity cannot be listened to because it cannot change. Several listeners (even with the same parameters) can be associated to each property. 

Arguments: s(Name),s(Property),f(user_event_n)->

Parameters:

[in]
Namethe name of the named entity to listen to
[in]
Propertythe property of the named entity to listen to
[in]
user_event_nthe user event to trigger
 ()addNamedEventListener("Invasion", "state", 6);