FANDOM



NPC Check's for more than 1 of the same item in a PC's

A simple way to check for Items in a "Text Appeares When" script mode is to use the GetNumItems(). This is a bit easier than going threw the Inventory and "counting" each item.

This need to be in the "Text Appeares When" Script node of the Text line you want to appeare to the PC if he/she has the correct amount of said Item. Change "ITEM_TAG" to that of the Item you are looking for and set nMarkCount to the number of items you want.

#include "nw_i0_plot"
int StartingConditional()
{
    //check inventory of oPC for oQuestItem and get iNumItems
    string sMark = "ITEM_TAG";
    int nMarkCount = 2;
    object oMark = GetObjectByTag(sMark);
    if(GetNumItems(GetPCSpeaker(),sMark) >= nMarkCount)
        return TRUE;
    return FALSE;
}

If you want to take the Items in the "Action Taken" node of the next Text node. We can use TakeNumItems().

Place this script in the "Actions Taken" of the next NPC response. Again change "ITEM_TAG" to that of the Item your looking for and set nMarkCount to the number of Items to take.

#include "nw_i0_plot"
void main()
{
    string sMark = "ITEM_TAG"; // Enter tag of your Item
    object oMark = GetObjectByTag(sMark);
    int nMarkCount = 2; // Change to num Items you want
    if(GetNumItems(GetPCSpeaker(),sMark) >= nMarkCount)
        {
        TakeNumItems(GetPCSpeaker(),sMark,nMarkCount);
        // Uncomment the following line to Give the PC an Item Also
        // CreateItemOnObject("item_ResRef",GetPCSpeaker(),1);
        }
}


Sample Conversation

+Root
-NPC: "I see you have 2 Items" [Text appeares When script]
---PC: "Yes I do"
-----NPC:"Thanks" [Actions Taken]
-NPC: "I need you to get 2 Items"
---PC: "Ok, Beright back"

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.