GetItemCount misbehaving?

Post » Sun Nov 18, 2012 9:17 am

I noticed something curious about GetItemCount when testing different approaches to keeping tabs on how many bows, arrows, swords, and other stuff like that a follower is carrying.

It seems to me, that GetItemCount might not register the starting inventory of an actor, but can it really be so?

I tested this by starting a fresh new game with nothing but the following script attached to Sven/Faendal after exiting the Helgen cave, in order to keep track of their inventory:
Spoiler
ScriptName InventoryCheck extends ActorKeyword Property VendorItemArrow  autoKeyword Property VendorItemWeapon autoKeyword Property WeapTypeBow	  autoKeyword Property WeapTypeSword    autoKeyword Property WeapTypeDagger   autoEVENT OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    CheckInventory()endEVENTEVENT OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)    CheckInventory()endEVENTFUNCTION CheckInventory()    string S = "Inventory check:"    S = S + "\nArrows  " + Self.GetItemCount(VendorItemArrow)    S = S + "\nWeapons " + Self.GetItemCount(VendorItemWeapon)    S = S + "\nBows    " + Self.GetItemCount(WeapTypeBow)    S = S + "\nSwords  " + Self.GetItemCount(WeapTypeSword)    S = S + "\nDaggers " + Self.GetItemCount(WeapTypeDagger)    debug.MessageBox(S)endFUNCTION

At no time did it register anything but zero on all displayed items, until I enlisted one of them as a follower, and then it displayed correctly the bow and 12 arrows provided by the DialogueFollower quest. And any additional items I manually hand to them correctly change the numbers. But Faendal's initial bow and 12 arrows, or the dagger that both NPCs initially have never registered. If I trade the dagger away from them, the script shows a count of -1 for that category.

I find it hard to believe, that this can really be the case, and I hope some mistake on my side could explain it, but...

I would very much appreciate it, if somebody could try to replicate the effect.
User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm

Post » Sun Nov 18, 2012 5:03 pm

I used getitemcount on a wolf with a coin added in the CK, along other obect. I checked with getitemcount if the wolf has one or more coins to move his inventory to another NPC (it was needed to give her some items instead of making her start with them). The other NPC receives her equipment correctly, which would have not happen should getitemcount had not register the wolf's initial coin number.

EDIT: I see that you are using keywords as arguments for getitemcount. I didn't even knew it was possible, but anyway, it could have something to do with this.

EDIT2: Another difference I see between how I use getitemcount in the mentioned script and how you do here, is that a gold coin can't be equipped, while all the objects you are checking can.
User avatar
Emily Jeffs
 
Posts: 3335
Joined: Thu Nov 02, 2006 10:27 pm

Post » Sun Nov 18, 2012 6:35 am

Curious. I wonder, if the fact that my test script looks for keywords rather than items might make a difference.

Based on the Wiki, it should work:
Syntax
int Function GetItemCount(Form akItem) native

Parameters
akItem: The item to look for in this reference's inventory.
- If a reference, will look for just that particular reference.
- If a base object (like armor or a weapon), it will count the how many instances of that base object are in the container
- If a form list, it will count how many of each item in the form list is in the container and sum it all up
- If a keyword, it will count how many items with that keyword are in the container

EDIT2: Another difference I see between how I use getitemcount in the mentioned script and how you do here, is that a gold coin can't be equipped, while all the objects you are checking can.
That is true, but I have never observed any correlation with that, and it would not explain -1 for a dagger, just sitting in the inventory and then removed.

In fact, I have used this approach extremely successfully and totally without a hitch to deal with follower bows as per http://www.gamesas.com/topic/1401795-how-to-repair-the-companion-using-wrong-bow/page__view__findpost__p__21361588. Apparently the reason why it has worked well for me is, that I have only enlisted followers from housecarls, who have no initial bows or arrows. And in that case it has apparently worked perfectly (although it probably causes quite a lot of inventory activity) completely regardless of whether or not any of the items have been equipped, and whether or not they have been marked as "playable". I only noticed this issue when I tried to have a look at other followers, and other items, such as housecarl swords, in which case it became immediately obvious that something was amiss.

Anyway, I could understand it, if the function skipped items, based on whatever logic there might be to do so. But a function that is supposed to count items coming up with a negative result on an empty inventory (after the initial item has been removed), is something I find just ludicrous. :smile:
User avatar
Agnieszka Bak
 
Posts: 3540
Joined: Fri Jun 16, 2006 4:15 pm

Post » Sun Nov 18, 2012 4:06 am

To double check the issue about items that can be equipped, I redid my test while including VendorItemKey among the keywords to check. No dice, after I removed Sven's house key, he now holds -1 keys, according to GetItemCount(VendorItemKey).

Well, I am pretty frustrated by this, and I guess, that if I can't count on item counts being correct, it is about time for me to cool it off and go back to Morrowind for a change. :smile:

I was just hoping, that somebody might be able to give a reinforcing second opinion, that this could be a bug, so I might dare to properly report it. The issue seems so silly, that as long as it is just me, I can't overcome the doubt myself, that something might be borked in my game, in my PC, or between my ears.

Edit:
Actually, after some reflection, I decided I am so frustrated and tired with Skyrim, that I would like to take a long break from the forums, starting immediately. For that purpose, I think I will ask a moderator to close this thread for purely personal reasons, so I won't feel the urge to have to come by and see if there might be something I would feel the obligation to respond to. Sorry about that, I don't wish to suppress discussion of the issue, but as far as I am concerned, there is no reason why it couldn't continue elsewhere, if there is a need for it.
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Sun Nov 18, 2012 3:24 pm

Close requested.
User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm


Return to V - Skyrim