The receiveMissionItems native AI script function adds a contextual menu entry to an NPC that allows a player to give mission items to the NPC. EGS checks whether the player has the required items and triggers different user events depending on the outcome.
This function can only be called from a
player_target_npcevent handler. It only works on R2 shards for R2 plot items.
()receiveMissionItems(missionItems: s, missionText: s, groupToNotify: c)
"sheet_id:quantity;sheet_id:quantity;...". Example: "toto.sitem:2;tata.sitem:1"The missionItems string is a semicolon-separated list of item entries. Each entry is a sheet ID and quantity separated by a colon:
sheet_id_1:quantity_1;sheet_id_2:quantity_2;sheet_id_3:quantity_3
All sheet IDs must be valid .sitem sheet names and all quantities must be greater than 0.
The following user events are triggered on groupToNotify:
| Event | When |
|---|---|
user_event_1 |
The player has the requested items in their inventory |
user_event_2 |
The player does not have the requested items |
user_event_3 |
The player has given the items to the NPC (items transferred) |
CGiveItemRequestMsg is sent to EGS with the item listuser_event_1 is triggered and the menu entry is shownuser_event_2 is triggereduser_event_3 is triggered// In a player_target_npc event handler:
(@myGroup)context();
()receiveMissionItems("quest_item_a.sitem:1;quest_item_b.sitem:3", "Give the quest items", @myGroup);
Handle the responses:
// user_event_1: player has the items
()npcSay(0, "say", "Ah, you have what I need!");
// user_event_2: player doesn't have the items
()npcSay(0, "say", "Come back when you have the items.");
// user_event_3: items were given
()npcSay(0, "say", "Thank you! Here is your reward.");
(@myGroup)context();
()giveReward("Reward!", "Rare!", "Full!", "No points!", @myGroup);
Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (receiveMissionItems_ssc_)