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.
()giveReward(rewardText: s, rareRewardText: s, inventoryFullText: s, notEnoughPointsText: s, groupToNotify: c)
This function reads the player and NPC entity IDs from the current group's event parameters:
getEventParamString(0) must contain the player character entity IDgetEventParamString(1) must contain the NPC entity IDThese 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.
giveRewardMessage is sent to EGS via the R2 module interfaceCRingRewardPoints::generateReward() to produce a reward itemgrr_ok: Regular reward generated - displays rewardTextgrr_ok_rare: Rare reward generated - displays rareRewardTextgrr_no_place: Inventory full - displays inventoryFullTextgrr_no_points: Not enough points - displays notEnoughPointsTextThis 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);
Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (giveReward_ssssc_), ryzom/server/src/entities_game_service/modules/character_control.cpp (giveRewardMessage)