NPC
NPC Event Handling
In Ryzom Core NPCs can be scripted through a sophisticated event/action system. The system works by declaring an event to listen for and then assigning an action to that event. There are approximately 62 events and 36 actions available at your disposal but some actions, such as the code action allow you to write your action handlers in advanced AI scripting which provides a nearly unlimited number of potential actions. Below we we detail the various events and actions available to you. You can define an event handler at either the npc_zone/npc_route level or at the npc_group level.
Note |
---|
The "event" set_flags_on_dyn_zones erroneously appears as an event in World Editor and is in truth an unused, deprecated action. Do not use it. |
NPC Events
AI Event All Pets Arrived From Stable (not implemented)
- AI Event All Pets Gone To Stable (not implemented)
- AI Event All Team NPCs Present (not implemented)
- AI Event All Team Players Present (not implemented)
- AI Event Bot Begin Fight
- AI Event Bot Killed (not implemented)
- AI Event Bot Target Killed
- AI Event Destination Reached
- AI Event Destination Reached All
- AI Event EGS Up
- AI Event End Of State
- AI Event Escort Away
- AI Event Escort Back
- AI Event Group Attack End
- AI Event Group Despawned
- AI Event Group Eliminated
- AI Event Group Under Attack
- AI Event Other Team Enters View (not implemented)
- AI Event Other Team Meets Team (not implemented)
- AI Event Outpost Attacker Changed(not in use)
- AI Event Outpost Guild Ownership Begin(not in use)
- AI Event Outpost Guild Ownership End(not in use)
- AI Event Outpost Owner Changed(not in use)
- AI Event Outpost Peace State Begin(not in use)
- AI Event Outpost Peace State End(not in use)
- AI Event Outpost State Changed(not in use)
- AI Event Outpost Tribe Ownership Begin(not in use)
- AI Event Outpost Tribe Ownership End(not in use)
- AI Event Player Follow NPC
- AI Event Player Request Pause (not implemented)
- AI Event Player Request Pause End (not implemented)
- AI Event Player Target NPC
- AI Event Punctual State Timeout
- AI Event Route Blocked (not implemented)
- AI Event Route Blocked End (not implemented)
- AI Event Start of State
- AI Event State Timeout
- AI Event Team Attacked (not implemented)
- AI Event Team Attacked End (not implemented)
- AI Event Team Member Badly Hurt (not implemented)
- AI Event Team Member Killed (not implemented)
- AI Event Team Member LD (not implemented)
- AI Event Team Member Logout (not implemented)
- AI Event Team Pack Animal Hurt (not implemented)
- AI Event Team Pack Animal Killed (not implemented)
- AI Event Timer Triggered
- AI Event User Event
- AI Event Variable Changed (not implemented)
NPC Event Variables
In the NPC Event Actions section you'll find several actions which harness variables. In Ryzom Core there are two types of variables accessible through NPC Events: local and foreign. Local and Foreign variables are essentially the same thing with some differences in how they are retrieved or referred to in event actions.
Variables
Variables are members of the current group (npc_group) and are expressed with a 'v' followed by the variable id (0-3). Example : v0. Variables are useful for functionality such as global state in an event, coordinating actions across multiple events, etc. They're used because the variables declared within a code block do not exist outside of that code block's execution.
Info |
---|
All variables are floating point variables. |
Foreign Variables
Foreign variables are variables which come from another npc_group. If you have multiple groups of NPCs coordinating their actions this is a convenient way to share state and other data between the two groups.
They are expressed with the group name followed by a colon ':' then followed by a local variable identifier (v). Example: group_1:v2.
Warning |
---|
When attempting to access a foreign variable that variable's npc_group name must be globally unique. |
AI Scripting
The Ryzom Core AI system has a sophisticated custom scripting language that is used for scripting the various group states.
Please see the AI Scripting Overview for more information.
You can also get thorough documentation by going to AI Scripting Native Functions Reference.
Here's an example of a simple code block:
Code Block |
---|
(aggroSize)getAggorListSize(0);
// to much player are attacking the boss
if (aggoroSize > 10)
{
($player1)getAggroListElement(0);
($player2)getAggroListElement(1);
($player3)getAggroListElement(2);
// so the boss teleport 3 person from its aggro list at the end of the world
teleportPlayer($player1, 14233, 123123, 0, 0);
teleportPlayer($player2, 14233, 123123, 0, 0);
teleportPlayer($player2, 14233, 123123, 0, 0);
clearAggroList();
} |
In addition to code segments within AI actions you can also create AI script templates in World Editor using the script_rep and script nodes. It looks a little like this:
AI Script Rep Container in World Editor
AI Script Window for Script Rep