Aller au contenu

Photo

Two Conversation Checks


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Kingdom_Of_Hearts

Kingdom_Of_Hearts
  • Members
  • 72 messages
 How do I find out as an integer values how many of an item oPC has? The only function that seems similiar is GetNumStackedItems..

Also! How do I make an on text appears if the PC is one of several alignments? (NG, CN, and LE for example sake)

Modifié par Kingdom_Of_Hearts, 05 novembre 2013 - 09:01 .


#2
MagicalMaster

MagicalMaster
  • Members
  • 2 000 messages
Loop through the inventory, check the tag of each item, and compare it to the tag of the item you're counting. GetNumStackedItems or GetItemStackSize should be used if you're dealing with items that can be stacked AFTER you've found the item via your loop in the first place.

What exactly is triggering the text? A conversation?

#3
Kingdom_Of_Hearts

Kingdom_Of_Hearts
  • Members
  • 72 messages
All right. A conversation is triggering this text, yes.

#4
Kingdom_Of_Hearts

Kingdom_Of_Hearts
  • Members
  • 72 messages
Can't seem to find a guide for scripting loops. I'm not too talented, any help?

#5
MagicalMaster

MagicalMaster
  • Members
  • 2 000 messages
This is a function -- if you put it in a library you can call it in any script you want to count the items in a creature's inventory.
// Counts the number of items with sTag that oCreature possesses
// Will NOT count items equipped
int CountItem(object oCreature, string sTag)
{
    // Tracker variable
    int nCount;

    // Loop through inventory
    object oItem = GetFirstItemInInventory(oCreature);
    while (GetIsObjectValid(oItem))
    {
        // Do the tags match?
        if (GetTag(oItem) == sTag)
        {
            // Increase the  tracker by the stack size
            nCount += GetItemStackSize(oItem);
        }
        oItem = GetNextItemInInventory(oCreature);
    }

    // Return the tracker
    return nCount;
}

So you'd run it by doing something like...
int x;
x = CountItem(oPC, "potion3");

x would then equal the number of items with the tag "potion3" -- and it doesn't matter if it's 10 separate potions or 10 stacked potions, it'll always equal 10.

#6
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
You could also just use the function already included in "nw_i0_plot".


#include "nw_i0_plot"
void main()
{
    object oPC = whatever;
    GetNumItems(oPC, "TagOfItem");
}

#7
MagicalMaster

MagicalMaster
  • Members
  • 2 000 messages
Well, mine is clearly better because I used += and they didn't.

Or something.