talk_to - ryzom/ryzomcore GitHub Wiki
title: Talk To description: Add a contextual menu entry for a player to talk to an NPC published: true date: 2026-03-14T00:00:00.000Z tags: editor: markdown dateCreated: 2023-03-16T22:30:34.974Z
The talkTo native AI script function adds an entry to the NPC's right-click contextual menu allowing a player to interact with the NPC. When the player clicks the menu entry, user events are triggered on the specified callback group, allowing the AI script to respond (e.g. give a reward, start a dialog, etc.).
This function can only be called from a
player_target_npcevent handler. The player and NPC entity IDs are read from the current group's event parameters. {.is-warning}
()talkTo(missionText: s, groupToNotify: c)- missionText (string): The text that will appear in the NPC's contextual menu entry.
- groupToNotify (context): The NPC group that will receive user events when the player interacts. Obtain with context().
The following user events are triggered on groupToNotify:
| Event | When |
|---|---|
user_event_1 |
Triggered when the menu is presented to the player |
user_event_3 |
Triggered after the player clicks the menu entry and talks to the NPC |
The event parameters (accessible via getEventParam) contain the player and NPC entity IDs at indices 0 and 1. These are needed by functions like giveReward that operate on the interacting player.
- The NPC turns to face the player
- A
CGiveItemRequestMsgwith an empty item list is sent to EGS (this is a workaround since there's no dedicated "talk" message type) - EGS presents the contextual menu to the player
- When the player clicks the entry, EGS triggers the user events back on the callback group
// In a player_target_npc event handler:
($playerEid)getCurrentPlayerEid();
(@myGroup)context();
()talkTo("Talk to this NPC", @myGroup);Then handle the response in user_event_3:
// In a user_event_3 handler on the same group:
// The player has clicked the menu entry
(@myGroup)context();
()giveReward("Reward!", "Rare!", "Full!", "No points!", @myGroup);- giveReward - Give a Ring scenario reward after a talk interaction
- receiveMissionItems - Request items from a player via contextual menu
- giveMissionItems - Give items to a player via contextual menu
- context - Get a group context reference
Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (talkTo_sc_)