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

giveReward

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 talkTo interaction callback. {.is-info}

Syntax

()giveReward(rewardText: s, rareRewardText: s, inventoryFullText: s, notEnoughPointsText: s, groupToNotify: c)

Arguments

  • 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.

Prerequisites

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.

How It Works

  1. The function retrieves the player and NPC entity IDs from the event parameters
  2. The NPC turns to face the player
  3. A giveRewardMessage is sent to EGS via the R2 module interface
  4. EGS looks up the current Ring scenario's session level
  5. EGS calls CRingRewardPoints::generateReward() to produce a reward item
  6. One of the four text strings is sent to the player as a system message, depending on the result:
    • grr_ok: Regular reward generated - displays rewardText
    • grr_ok_rare: Rare reward generated - displays rareRewardText
    • grr_no_place: Inventory full - displays inventoryFullText
    • grr_no_points: Not enough points - displays notEnoughPointsText

Example

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
);

Typical Usage Pattern

// 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);

See also

Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (giveReward_ssssc_), ryzom/server/src/entities_game_service/modules/character_control.cpp (giveRewardMessage)

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