GetItems, GetInventoryObject, etc.

Post » Sat Mar 05, 2011 8:51 am

OK, here's an explanation of the topic. I have a mod that automatically equips a new weapon when the previous one is about to break. It uses Player.GetItems 33 to get a list of all the weapons in a player's inventory, and then after anolyzing each weapon (for health, etc.), it then equips the "best" weapon according to some logic I've added.

Here's the problem. Let's say I have two of the exact same weapons, like 2 Daedric Daggers. If the first one breaks, the second one is invisible to the script, apparently because GetItems, GetInventoryObject, and all other such commands only look for unique objects in the inventory.

Is there any way to have my script point to that second instance of the Daedric Dagger, perhaps through using GetItemCount or something of that nature? Thanks in advance - I've been trying to figure this out for a while.

A section of the script:
Spoiler

Variables definition--
probevalue = http://forums.bethsoft.com/index.php?/topic/1104247-getitems-getinventoryobject-etc/gold value of the best selection in inventory. This is continuously updated as the player's weapon inventory is walked through.
allowedweapon = stores whether a given weapon is allowed, given other requirements (for example, if the player is using a shield then disallow 2-handed weapons). Simple 1 or 0.
Obj = ObjectID of the currently equipped weapon
Probe = Object ID of the weapon under consideration
Final = ObjectID of the final selection for weapon to equip

let clothing := player.GetItems 33 ;20 = armor, 22 = clothes, 33 = weapon
let final := 0
let probevalue := -1
ForEach item <- clothing
let probe := item["Value"]
let tempa := GetWeaponType probe
let ObjTtlHP := GetObjectHealth probe
let ObjCurHP := 0 ;needed in case this is a broken weapon and is unequipped quickly
Player.Equipitem2NS probe
let ObjCurHP := Player.GetEquippedCurrentHealth WeaponSlot
Player.UnequipitemNS probe
let Percentage := ObjCurHP / ObjTtlHP
if eval (allowedweapon[tempa]) > 0 && Percentage >= 0.01 ;don't try to equip a damaged weapon!
let tempa := allowedweapon[tempa]
If probevalue <= (GetFullGoldValue probe) * tempa ;find highest value weapon of right type
let probevalue := (GetFullGoldValue probe) * tempa
let final := probe
endif
endif
loop
if final > 0
if player.IsWeaponOut == 1
set rdyWpn to GetControl 8
Tapkey rdyWpn ;this sheathes the weapon temporarily
let alert := 1
else
let alert := 0
Endif
player.UnequipitemNS Obj
player.EquipItem2NS final

User avatar
claire ley
 
Posts: 3454
Joined: Fri Aug 04, 2006 7:48 pm

Post » Sat Mar 05, 2011 5:04 am

Wait for 0019.
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Sat Mar 05, 2011 11:50 am

OK, I can wait. :)
User avatar
Kelvin Diaz
 
Posts: 3214
Joined: Mon May 14, 2007 5:16 pm


Return to IV - Oblivion