give_reward - ryzom/ryzomcore GitHub Wiki
title: Give Reward description: Send a Ring scenario reward to a player published: true date: 2026-03-14T00:00:00.000Z tags: editor: markdown dateCreated: 2023-03-16T22:25:04.230Z
The giveReward native AI script function sends a reward message to EGS for a player interacting with an NPC in a Ring scenario. EGS generates a reward item based on the scenario's session level and Ring Reward Points, and sends the appropriate text message to the player.
This function is specific to the Ryzom Ring scenario system. It requires the player and NPC entity IDs to be available in the event parameters (indices 0 and 1), which is the case when called from a
talkTointeraction callback. {.is-info}
()giveReward(rewardText: s, rareRewardText: s, inventoryFullText: s, notEnoughPointsText: s, groupToNotify: c)- rewardText (string): The text displayed when the player receives a regular reward.
- rareRewardText (string): The text displayed when the player receives a rare reward.
- inventoryFullText (string): The text displayed when the player's inventory is full and the reward cannot be given.
- notEnoughPointsText (string): The text displayed when the player doesn't have enough Ring Reward Points.
- groupToNotify (context): A group context reference. This parameter is accepted but not currently used in the implementation. Pass the current group's context for forward compatibility.
This function reads the player and NPC entity IDs from the current group's event parameters:
-
getEventParamString(0)must contain the player character entity ID -
getEventParamString(1)must contain the NPC entity ID
These parameters are automatically set when the function is called within a talkTo interaction callback chain. Both the player and the NPC must be alive for the reward to be processed.
- The function retrieves the player and NPC entity IDs from the event parameters
- The NPC turns to face the player
- A
giveRewardMessageis sent to EGS via the R2 module interface - EGS looks up the current Ring scenario's session level
- EGS calls
CRingRewardPoints::generateReward()to produce a reward item - One of the four text strings is sent to the player as a system message, depending on the result:
-
grr_ok: Regular reward generated - displaysrewardText -
grr_ok_rare: Rare reward generated - displaysrareRewardText -
grr_no_place: Inventory full - displaysinventoryFullText -
grr_no_points: Not enough points - displaysnotEnoughPointsText
-
This example is used inside a talkTo interaction handler on a reward NPC:
// Get context for notification (required parameter, not currently used)
(@myGroup)context();
// Give the reward to the player currently interacting with this NPC
()giveReward(
"You received a reward!",
"You received a rare reward!",
"Your inventory is full, you cannot receive the reward.",
"You don't have enough points for a reward.",
@myGroup
);// Step 1: Set up the NPC to be talkable
()talkTo($playerEid, @myGroup);
// Step 2: In the user event triggered by talkTo, give the reward
// (this runs when the player actually clicks the NPC's context menu entry)
(@myGroup)context();
()giveReward("Reward!", "Rare reward!", "Inventory full.", "Not enough points.", @myGroup);- talkTo - Set up an NPC context menu entry for player interaction
- receiveMissionItems - Request items from a player
- giveMissionItems - Give items to a player
Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (giveReward_ssssc_), ryzom/server/src/entities_game_service/modules/character_control.cpp (giveRewardMessage)