About: NPC takes more than one of the same item from a PC   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

What you need to do is loop through every item in the PC's inventory looking for your item, and perform an action on each one you find. Two functions make it easy to loop through the whole inventory: GetFirstItemInInventory and GetNextItemInInventory. Here's an example of how to use them to reward a PC for every item they have with the tag "goblin_ear":

AttributesValues
rdfs:label
  • NPC takes more than one of the same item from a PC
  • NPC takes more than one of the same item from a pc
rdfs:comment
  • What you need to do is loop through every item in the PC's inventory looking for your item, and perform an action on each one you find. Two functions make it easy to loop through the whole inventory: GetFirstItemInInventory and GetNextItemInInventory. Here's an example of how to use them to reward a PC for every item they have with the tag "goblin_ear":
dcterms:subject
abstract
  • What you need to do is loop through every item in the PC's inventory looking for your item, and perform an action on each one you find. Two functions make it easy to loop through the whole inventory: GetFirstItemInInventory and GetNextItemInInventory. Here's an example of how to use them to reward a PC for every item they have with the tag "goblin_ear": // This script goes in the "Actions Taken" tab of a // conversation. It will reward the PC 10 gold and // 10 XP for every item they possess with the tag // "goblin_ear". void main() { // First, get the PC being spoken to object oPC = GetPCSpeaker(); // Now, find the first item in that PC's inventory object oItem = GetFirstItemInInventory(oPC); // Start the loop. The next statement says to // stay in the loop until "oItem" no longer points // to a valid object. This will happen as soon as // we've looped through every one of the PC's items. while (GetIsObjectValid(oItem)) { // Check the tag on the current item if (GetTag(oItem) == "goblin_ear") { // Statements within these brackets will // be run for each item that matches the // "goblin_ear" tag. // The next two lines give the rewards: // 10 gold and 10 XP. GiveGoldToCreature(oPC, 10); GiveXPToCreature(oPC, 10); // Now take the ear from the PC. Note that // this doesn't really take the ear and give // it to the NPC; it just destroys it. Why // do NPCs give money for these things, // anyway? Who wants a bunch of rotting ears // in their pockets? DestroyObject(oItem); } // Now move on to the next item oItem = GetNextItemInInventory(oPC); } // End while loop } // End script
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software