Author Topic: Two Conversation Checks  (Read 352 times)

Legacy_Kingdom_Of_Hearts

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Two Conversation Checks
« on: November 05, 2013, 08:38:50 pm »


                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 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Two Conversation Checks
« Reply #1 on: November 05, 2013, 10:14:45 pm »


               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?
               
               

               
            

Legacy_Kingdom_Of_Hearts

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Two Conversation Checks
« Reply #2 on: November 05, 2013, 10:15:56 pm »


               All right. A conversation is triggering this text, yes.
               
               

               
            

Legacy_Kingdom_Of_Hearts

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Two Conversation Checks
« Reply #3 on: November 05, 2013, 10:45:29 pm »


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

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Two Conversation Checks
« Reply #4 on: November 06, 2013, 01:31:01 am »


               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.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Two Conversation Checks
« Reply #5 on: November 06, 2013, 08:14:15 am »


               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");
}
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Two Conversation Checks
« Reply #6 on: November 06, 2013, 09:25:42 pm »


               Well, mine is clearly better because I used += and they didn't.

Or something.