TakeFetchItem

From NWN Lexicon
Jump to: navigation, search



TakeFetchItem(object)

Removes the plot related item from a player's inventory. Calls GetFetchItem to determine which item to take.

void TakeFetchItem(
    object oPC
);

Parameters

oPC

The player to remove the item from.


Description

Gets the Tag name of the quest object from a local object called NW_J_FETCH_MYGLOBALS on the calling creature then searches the target's inventory and equipped items for any item with that as the returned Tag name and destroys it.



Remarks

Function can be found in nw_j_fetch.nss on line 178.

It seems these functions are centered around storing plot item related information on NPCs for simple fetch related quests. This particular function only utilizes 2 out of the 7 other functions available. All of these functions are relatively straight forward and easy to understand at a glance.

There are also other scripts of the exact same functions but work with "Artifacts" and "ComplexItems" instead of FetchItems. The scripts are identical but separated to make coding between them easier to understand and add functionality to later. See the "See Also" section for the other functions.


Requirements

#include " nw_j_fetch "

Version

1.22

Example

// OnSpawn of the NPC to give the quest out.
#include "NW_J_FETCH"
    SetGlobal(OBJECT_SELF,OBJECT_SELF);
    SetFetchItem("APPLE01");
    SetPlotTag("GATHER_APPLES"); //Matches Journal Entry that has experience to be rewarded for this quest
 
//Conversation Conditional of the NPC to reward the player for returning the item.
#include "NW_I0_PLOT"
#include "NW_J_FETCH"
 
int StartingConditional()
{
    if (PlayerHasFetchItem(GetPCSpeaker()) == TRUE)
    {
        ActionPauseConversation();
 
        //Destroy the apples from the players inventory.
        TakeFetchItem(GetPCSpeaker());
        RewardXP(GetPlotTag(),100,GetPCSpeaker());
 
        //Mark the quest as finished so we don't run it again for this player.
        SetLocalInt(GetModule(),GetPlotTag()+GetName(GetPCSpeaker()),1);
 
        ActionResumeConversation();
    }
    return FALSE;
}

See Also

functions: 

TakeStoryItem



 author: John Shuell, editor: Mistress