functions - ryzom/ryzomcore GitHub Wiki


title: AI Script Function Reference description: published: true date: 2023-03-14T14:57:18.608Z tags: editor: markdown dateCreated: 2023-03-12T09:18:34.306Z

AI Script Functions

Reference list of native AI script functions.

Utility

Function Documentation Descriptio
(c)context() Context Returns the script context of the current or specified NPC group
()import(s) Import Import and execute a script defined in a script rep
()warning(s)
()warning(f)
()info(s)
()info(f)
()debug(s)
()debug(f)
Warning, Info, and Debug Log output messages to the AIS console during AI script execution
()break() Break Immediately stops the AIS (Not for production use)

Spawn and Despawn

Function Documentation Description
()spawn() Spawn Spawn the current group
()despawn(f) Despawn Despawn the current group
()spawnManager(s) Spawn Manager Spawns the specified NPC manager
()despawnManager(s) Despawn Manager Despawns an NPC manager

General Purpose Timers and Event Triggers

Function Documentation Description
()setEvent(f) Set Event Trigger a user event by ID between 0 and 9
()setTimer(f, f) Set Timer Starts a timer with ID between 0 and 3 and a specified trigger delay time
()timerSetRyzomDaytime(f, f, f) Timer Set Ryzom Daytime Sets a timer at a specified hour in Ryzom time and starts it
()timerDisable(f) Timer Disable Disable a timer
()timerSuspend(f) Timer Suspend Suspend a timer
()timerResume(f) Timer Resume Resume a timer
()timerAdd(f, f) Timer Add Extend a timer by adding a time delta
(f)timerIsEnabled(f) Timer Is Enabled Check if a timer is enabled
(f)timerIsSuspended(f) Timer Is Suspended Returns whether a timer is suspended or not

Behavioural Logic State

Function Documentation Description
(s)getStateName() Get State Name Returns the name of the group's current state
()postNextState(s) Post Next State Triggers a state change by posting the next state with the given name

Behaviour Activity Movement State

Function Documentation Description
()startWander(f) Start Wander Set activity to wander in current position
()startMoving(f, f, f) Start Moving Sets an activity to move a group to a specified position
()followPlayer(s, f) Follow Player Sets the AI activity to follow the given player with the specified radius
()moveToZone(s, s) Move To Zone Moves the current group from one zone to another
()waitInZone(s) Wait in Zone Makes the group wander in the specified zone
()stopMoving() Stop Moving Makes the group stop moving and stand at its current position
()wander() Wander Makes the group wander in the current npc state zone

Behaviour Actions

Function Documentation Description
()sitDown() Sit Down Make the group sit down
()standUp() Stand Up Make the group stand up
()emote(c, s, s)
()emote(s, s)
()emote(s)
Emote Launch an emote for a bot or a group of bots
()facing(f)
()facing(c, s, c, s)
Facing Make all NPCs in a group face a certain direction or make one NPC turn and face another NPC

Group Behaviour State Properties

Function Documentation Description
()setAggro(f, f) Set Aggro Set the aggro range and update period of the current group
()setCanAggro(f) Set Can Aggro Set whether a bot can aggro or not
()setAttackable(f) Set Attackable Set a group as attackable or non-attackable by bots and players
()setPlayerAttackable(f) Set Player Attackable Set whether a group is attackable by players or not
()setBotAttackable(f) Set Bot Attackable Set whether the group is attackable by bots or not
()setFactionAttackableAbove(s, f, f) Set Faction Attackable Above Set the attackable status of a group based on player faction fame threshold
()setFactionAttackableBelow(s, f, f) Set Faction Attackable Below Makes a group attackable by players with negative fame for a specific faction
()ignoreOffensiveActions(f) Ignore Offensive Actions Makes the bots of the group ignore offensive actions issued on them
()maxHitRange(f) Max Hit Range Sets the maximum hit range possible for players to hit a particular NPC group
()setMode(s) Set Mode Sets the mode of every bot of a group (e.g. "eat", "rest", ...)
()setActivity(s) Set Activity Sets the activity of the group to a specified value (e.g. "guard", "normal", "bandit", ...)
()setDespawnTime(f) Set Despawn Time Set the time before the current group is despawned
()setRespawnTime(f) Set Respawn Time Sets the time in game cycles before the current group being respawned
()setAutoSpawn(f) Set Auto Spawn Sets whether the current group should respawn automatically after despawn
()setFactionProp(s, s) Set Faction Prop Sets the faction, ennemyFaction, or friendFaction property of the group's faction profile
()setSheet(s) Set Sheet Change the sheet of a creature
()setClientSheet(s) Set Client Sheet Change the client sheet of a creature to affect its visual appearance

Stat Parameter Changes

Function Documentation Description
()setMaxHP(f, f) Set Max HP Sets the maximum HP level of all bots in the group
()setHPScale(f) Set HP Scale Sets the current HP level of each bot of a group based on a percentage of its max HP, which can be used to kill an NPC or fauna bot
()downScaleHP(f)
()upScaleHP(f)
()scaleHP(f)
Scale HP Modify the current HP of bots by scaling it down, restoring a percentage of missing HP, or scaling it up by a percentage of current HP
()setHPLevel(f) Set HP Level Adds a factor of their max HP to the current HP level of each bot in the group (Badly named function)
()addHP(f) Add HP Adds hit points to each bot in the group
()addHpUpTrigger(f, f)
()addHpUpTrigger(f, s)
Add HP Up Trigger Register a user event or script function to trigger when a bot's HP level increases and crosses a threshold
()delHpUpTrigger(f, f)
()delHpUpTrigger(f, s)
Delete HP Up Trigger Unregister a previously registered HP increase trigger
()addHpDownTrigger(f, f)
()addHpDownTrigger(f, s)
Add HP Down Trigger Register a user event or script function to trigger on HP decreases that cross a threshold
()delHpDownTrigger(f, f)
()delHpDownTrigger(f, s)
Delete HP Down Trigger Unregisters a trigger on HP decreases for a specified user event or script function

Fighting actions and stuff

Function Documentation Description
()aiAction(s) AI Action Triggers an AI action, such as attacking, healing, or casting spells, on the current target, defined by its sheet name
()aiActionSelf(s) AI Action Self Triggers an AI action, such as aura and self heal on the bot itself, defined by its sheet name

Teleport Functions

Function Documentation Description
()summonPlayer(f, s) Summon Player Summons a player to a bot by using the player's EntityId and the index of the bot
()teleportNear(f, f, f, c) Teleport Near Teleports a player to a specific location and sends notification user events of the teleportation to the specified NPC group
()teleportPlayer(s, f, f, f, f) Teleport Player Teleports a player to a specified position with a given heading

Ring Behaviour Actions

Function Documentation Description
()talkTo(s, c) Talk To Adds an entry to the NPC contextual menu allowing a player to talk to the NPC
()giveReward(s, s, s, s, c) Give Reward Send a reward to a player and notify the specified NPC group
()npcSay(s, s)
()npcSay(c, s, s)
NPC Say Make an NPC say a text in chat
()setPlayerController(s, s) Set Player Controller Make a player control a NPC
()clearPlayerController(s) Clear Player Controller Stops an NPC from being controlled by a player
()activateEasterEgg(f, f, f, s, f, f, f, f, s, s, s) Activate Easter Egg Activate an Easter Egg, a lootable item in a Ryzom Ring scenario
()deactivateEasterEgg(f, f, f) Deactivate Easter Egg Deactivates an Easter Egg that was spawned by a Ryzom Ring scenario
()receiveMissionItems(s, s, c) Receive Mission Items Allows a targeted NPC to request mission items from a player and trigger events accordingly
()giveMissionItems(s, s, c) Give Mission Items Add a contextual menu to a targeted NPC that proposes to give mission items to the player and triggers events accordingly

Weird Ring Stuff

Function Documentation Description
()dssMessage(f, s, s, s) DSS Message Calls the DSS function CAnimationModule::dssMessage
()setScenarioPoints(f, f) Set Scenario Points Calls the DSS function CAnimationModule::setScenarioPoints
()startScenarioTiming(f) Start Scenario Timing Calls the DSS function CAnimationModule::startScenarioTiming
()endScenarioTiming(f) End Scenario Timing Calls the DSS function CAnimationModule::endScenarioTiming
()dssStartAct(f, f) DSS Start Act Start the specified act of the scenario in a DSS session

Weird Event stuff

Function Documentation Description
()rename(s) Rename Changes the displayed name of all bots in a group
()vpx(s) VPX Sets the VisualPropertyA, VisualPropertyB, or VisualPropertyC bitfield value for a bot NPC
(f, f)getMidPos() Get Mid Pos Returns the position (x, y) of the current group
()setUrl(s, s) Set URL Sets the name and URL of an action in the bot's right-click context menu
()despawnBotByAlias(s) Despawn Bot by Alias Despawn a specific bot in the current NPC group by its alias
()setBotHPScaleByAlias(f, s) Set Bot HP Scale by Alias Sets the HP scale of a specific bot in the current group based on its alias

Variadic Phrase Translation

Function Documentation Description
()phraseBegin() Phrase Begin Clears the parameters stack used when creating a customized message via other phrase functions
()phrasePushValue(s, f) Phrase Push Value Push a numeric value onto the parameter stack used for creating customized messages
()phrasePushString(s, s) Phrase Push String Push a value as a string on the parameter stack
()phraseEndNpcMsg(f, s, s) Phrase End NPC Msg Send a message with parameters through a bot chat bubble
()phraseEndSystemMsg(f, s, s) Phrase End System Msg Send a message with parameters through a system broadcast message
()phraseEndEmoteMsg(f, s) Phrase End Emote Msg Send a custom emote message with parameters through a chat message
()setSimplePhrase(s, s) Set Simple Phrase Defines a new phrase ID with associated text

Player Info

Function Documentation Description
(s)getCurrentPlayerEid() Get Current Player Eid Gets the entity id of the player that is clicking on a bot
(f)isPlayerAlived(s) Is Player Alived Checks if a player is alive based on their entity ID
(f)getPlayerStat(s, s) Get Player Stat Retrieve a specific player stat given a player EntityId and the stat name
(f)getPlayerDistance(f, s) Get Player Distance Calculate the distance between a player and a bot in meters

EGS Player Info Query

Function Documentation Description
()queryEgs(s, s, c, f, s)
()queryEgs(s, s, s, c, f, s)
Query EGS Sends a query message to EGS to get information about a player, triggering a user event in response
(f)getEventParam(f)
(s)getEventParam(f)
Get Event Param Retrieves the content of a parameter received by an EGS ai_event message

Bot Info

Function Documentation Description
(s)getCurrentSpeakerEid() Get Current Speaker Eid Returns the entity ID of the bot on which the player is clicking
(s)getName(c) Get Name Retrieves the name of an NPC group
(f)getBotIndex(s) Get Bot Index Get the bot index in the group by its entity ID
(s)getBotEid(f) Get Bot Eid Get the bot's entity ID by its index in the group
(f)getBotIndexByName(s) Get Bot Index by Name Returns the index of a bot in a group by its name, or -1 if not found
(f)isBotAlived(f) Is Bot Alived Test if a specific bot in the current group is alive
(f)isAlived()
(f)isGroupAlived()
Is Alived Checks if a group is spawned and at least one bot is alive

Aggro List Functions

Function Documentation Description
()clearAggroList()
()clearAggroList(f)
Clear Aggro List Reset the aggro lists of a bot group
(f)getAggroListSize(f) Get Aggro List Size Returns the size of the aggro list of a bot
(s)getAggroListElement(f, f) Get Aggro List Element Retrieve the Entity ID of a player from the aggro list by bot and player index
(s)getCurrentPlayerAggroListTarget(f) Get Current Player Aggro List Target Returns the entity ID of the player with the most aggro in the aggro list of a bot
()setAggroListTarget(f, s) Set Aggro List Target Maximizes the aggro of a target from the aggro list of a bot
()setGroupAggroListTarget(s) Set Group Aggro List Target Maximizes the aggro of a target from the aggro list of one bot for the entire group
()setManagerAggroListTarget(s, s) Set Manager Aggro List Target Maximizes the aggro of a target of one bot to matching groups in the same NPC manager

Bot Chat Menu

Function Documentation Description
()addBotChat(s) Add Bot Chat Add an entry to the botchat menu of every bot in the group
()clearBotChat() Clear Bot Chat Remove all entries from the botchat menu of every bot of the group

Bot Profile Parameters

Function Documentation Description
()addProfileParameter(s)
()addProfileParameter(s, s)
()addProfileParameter(s, f)
Add Profile Parameter Add a profile parameter to the current group
()removeProfileParameter(s) Remove Profile Parameter Remove a profile parameter from the current group
()addPersistentProfileParameter(s)
()addPersistentProfileParameter(s, s)
()addPersistentProfileParameter(s, f)
Add Persistent Profile Parameter Adds a profile parameter to the current group
()removePersistentProfileParameter(s) Remove Persistent Profile Parameter Remove a profile parameter from the current group

Persistency Functions

Function Documentation Description
(s)dataGetVar(s)
(f)dataGetVar(s)
Data Get Var Retrieve the content of a script data variable
()dataSetVar(s, s)
()dataSetVar(s, f)
Data Set Var Change the content of a script data variable
()dataSave() Data Save Save all previously written script data variables to file (Not actually implemented)

Dynamic NPC Group Creation

Function Documentation Description
(c)newNpcChildGroup(s, s, s)
()newNpcChildGroup(s, s, s)
(c)newNpcChildGroup(s, s, s, f)
()newNpcChildGroup(s, s, s, f)
New NPC Child Group Creates a dynamic NPC group with a parent/children relation
(c)newNpcChildGroupPos(s, s, f, f)
()newNpcChildGroupPos(s, s, f, f)
(c)newNpcChildGroupPos(s, s, f, f, f)
()newNpcChildGroupPos(s, s, f, f, f)
New NPC Child Group Pos Create a dynamic NPC group with a parent/children relation based on the provided position
(c)newNpcChildGroupMl(s, s, s, f)
()newNpcChildGroupMl(s, s, s, f)
(c)newNpcChildGroupMl(s, s, s, f, f)
()newNpcChildGroupMl(s, s, s, f, f)
New NPC Child Group Multilevel Creates a multilevel dynamic NPC group with a parent/children relation
(c)newNpcChildGroupPosMl(s, s, f, f, f)
()newNpcChildGroupPosMl(s, s, f, f, f)
(c)newNpcChildGroupPosMl(s, s, f, f, f, f)
()newNpcChildGroupPosMl(s, s, f, f, f, f)
New NPC Child Group Pos Multilevel Create a multilevel dynamic NPC group with a parent/children relation based on the provided position

Primitive Lookup for Dynamic NPC Behaviour

Function Documentation Description
(s)getGroupTemplateWithFlags(s, s)
(s)getGroupTemplateWithFlags(s, s, s)
Get Group Template With Flags Get a randomly chosen group template name that matches specified flags
(s)getZoneWithFlags(s, s, s)
(s)getZoneWithFlags(s, s, s, s)
Get Zone With Flags Selects a zone based on a set of flags and returns the name of the selected zone
(s)getNeighbourZoneWithFlags(s, s, s)
(s)getNeighbourZoneWithFlags(s, s, s, s)
Get Neighbour Zone With Flags Returns the name of a zone matching the specified flags in the current or neighbouring cells
(s)getNearestZoneWithFlags(f, f, s, s)
(s)getNearestZoneWithFlags(f, f, s, s, s)
(s)getNearestZoneWithFlagsStrict(f, f, s, s)
(s)getNearestZoneWithFlagsStrict(f, f, s, s, s)
Get Nearest Zone With Flags Return the zone nearest to a specified point that matches a set of specified criteria, with or without considering the zone's free space

Named Entities

Function Documentation Description
()createNamedEntity(s) Create Named Entity Creates a named entity in the current AI service
()setNamedEntityProp(s, s, s)
()setNamedEntityPropCb(s, s, s)
Set Named Entity Prop Set a property of an existing named entity
(s)getNamedEntityProp(s, s) Get Named Entity Prop Returns the content of a named entity property
()destroyNamedEntity(s) Destroy Named Entity Destroy a named entity
()addNamedEntityListener(s, s, f)
()addNamedEntityListener(s, s, s)
Add Named Entity Listener Associates a user event or script function in the current NPC group to trigger when a named entity property changes
()delNamedEntityListener(s, s, f)
()delNamedEntityListener(s, s, s)
Delete Named Entity Listener Removes a listener in the current NPC group from a named entity property

Dynamic Zone Energy

Function Documentation Description
()setDynEnergy(s, f, f) Set Dyn Energy Set energy values on an index, on all groups matching the specified request
()copyDynEnergy(s, f, f) Copy Dyn Energy Copy energy values from one index to another on groups that match a specified request

Zone

Function Documentation Description
setZoneState(s, f) Set Zone State Sets the active state flag of a zone

Outpost

Function Documentation Description
(s)getOutpostStateName() Get Outpost State Name Returns the name of the current outpost state for a group that is in an outpost NPC manager
(f)isOutpostTribeOwner() Is Outpost Tribe Owner Returns whether the current outpost owner is a tribe or not
(f)isOutpostGuildOwner() Is Outpost Guild Owner Checks if the current outpost owner is a guild or not
()setOupostMode(s, s) Set Oupost Mode Sets the outpost mode of a group of NPCs based on the specified side and alias

Time and Date

Function Documentation Description
(s)getServerTime() Get Server Time Returns the current server time as a string in seconds since 1970
(s)getServerTimeStr() Get Server Time String Returns the server time as a debug string
(s)getRyzomDate() Get Ryzom Date Returns the Ryzom game cycle tick count
(s)getRyzomDateStr() Get Ryzom Date String Returns the current Ryzom date and time as a debug string

Math Functions

Function Documentation Description
(f)clamp(f, f, f) Clamp Restricts a value between two limits and returns the clamped value
(f)min(f, f) Min Returns the lowest of two values
(f)max(f, f) Max Returns the highest of two values
(f)rndm(f, f) Random Generates a random float value within the specified inclusive min and exclusive max bounds
(f)floor(f) Floor Returns the highest integer lower than or equal to a given real value
(f)ceil(f) Ceil Returns the lowest integer higher than or equal to an input value
(f)round(f) Round Rounds the input value to the nearest integer
(f)abs(f) Abs Returns the absolute value of the input value
(f)sin(f) Sin Returns the sinus of the input value
(f)asin(f) Asin Returns the arcsine of an input value
(f)sinh(f) Sinh Returns the hyperbolic sinus of an input value
(f)cos(f) Cos Returns the cosine of an input value
(f)acos(f) Acos Returns the arccosine of an input value
(f)cosh(f) Cosh Returns the hyperbolic cosine of the input value
(f)tan(f) Tan Returns the tangent of a given input value
(f)atan(f) Atan Returns the arctangent of the input value
(f)tanh(f) Tanh Returns the hyperbolic tangent of the input value
(f)sqrt(f) Sqrt Returns the square root of a given number
(f)exp(f) Exp Returns the exponent of the input value (i.e. e^x)
(f)pow(f, f) Pow Returns the result of a base raised to the power of an exponent

String Functions

Function Documentation Description
(f)strlen(s) Strlen Returns the length of a string
(s)substr(s, f, f) Substring Returns a substring of a given string starting at a specified index with a specified length
(f)strtof(s)
(f, f)strtof(s)
(f, f, f)strtof(s)
String to Float Convert a string to a float

NeL Variables

Function Documentation Description
()setNelVar(s, f)
()setNelVar(s, s)
Set NeL Variable Set the content of a NeL variable
(f)getNelVar(s)
(s)getNelVar(s)
Get NeL Variable Retrieves the content of a NeL variable
()delNelVar(s, f)
()delNelVar(s, s)
Delete NeL Variable Delete a NeL variable
()setGlobalNelVar(s, f)
()setGlobalNelVar(s, s)
Set Global NeL Variable Set the content of a NeL variable globally

Internal

Function Documentation Description
()loadFile(s) Load File Loads an AI script file, compiles it and interprets the code for the group (Not for production use)
()setHealer(f) Set Healer Sets the group as a healer (Not ready for production use)
()setConditionSuccess(f) Set Condition Success Set the success status of a dynamic_if condition (Internal behaviour)

See also

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