Kohdi Posted August 10, 2012 Share Posted August 10, 2012 (edited) Hey all, I'm working with a supposedly-simple script which would run every time an actor loads, checks if he has certain items in his inventory, and if so, equips those items. Here's what I've got - Scriptname KohdiVeraEquipScript extends Actor Armor Property VeraArmorProperty Auto Armor Property VeraBootsProperty Auto Armor Property VeraGauntletsProperty Auto Bool Property silent Auto Event OnLoad() if (!Self.IsDead() && !Self.IsDisabled()) if (VeraArmorProperty != none) Self.EquipItem(VeraArmorProperty, silent) EndIf if(VeraGauntletsProperty != none) Self.EquipItem(VeraGauntletsProperty, silent) EndIf if(VeraBootsProperty != none) Self.EquipItem(VeraBootsProperty, silent) EndIf EndIf EndEvent (The armor properties are linked up to their respective unique items) (I have also tried setting the conditions to "== true" with no luck) This works well enough when the items are in the actor's inventory, but if the items are not (as you can tell from the script, the items are pieces of armor), the actor ends up naked even if there are suitable replacements in his inventory. It is of note that this only happens when the actor, a follower, has been dismissed and spends time away from the player, but on normal interior-to-exterior cell changes everything works fine. This is more of an aesthetic thing but I would appreciate any pointers you may have, as this is one of the last things I need to do before updating one of my mods. Thanks for any and all replies! Edited August 10, 2012 by Kohdi Link to comment Share on other sites More sharing options...
MTichenor Posted August 11, 2012 Share Posted August 11, 2012 Your current version only checks to make sure the Armor Property has been properly set (isn't an invalid armor). You need to check to make sure the actor actually has that specific piece of armor in their inventory as well. Here's some example code: Scriptname KohdiVeraEquipScript extends Actor Armor Property VeraArmorProperty Auto Armor Property VeraBootsProperty Auto Armor Property VeraGauntletsProperty Auto Bool Property silent Auto Event OnLoad() if (!Self.IsDead() && !Self.IsDisabled()) if (VeraArmorProperty != none && Self.GetItemCount( VeraArmorProperty ) > 0 ) Self.EquipItem(VeraArmorProperty, silent) EndIf if(VeraGauntletsProperty != none && Self.GetItemCount( VeraGauntletsProperty ) > 0 ) Self.EquipItem(VeraGauntletsProperty, silent) EndIf if(VeraBootsProperty != none && Self.GetItemCount( VeraBootsProperty ) > 0 ) Self.EquipItem(VeraBootsProperty, silent) EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
Kohdi Posted August 11, 2012 Author Share Posted August 11, 2012 Thanks for that, I guess the script is no good if I don't give it the right conditions. ;) I think I've figured out my "nakedness" problem as well, though not the solution. I haven't set that actor with a default outfit (nor do I want to), but Skyrim's backwards system won't auto-equip whatever armor/clothes are in the actor's inventory, it needs to be "told" to do it. I don't know who thought this was a necessary change to make over Oblivion, it's just a redundant complication. Anyway, is there a way to make a general "auto equip" script that would work like Oblivion's system, in that it would check the actor's inventory for the best gear of each type (weapon, armor, gauntlets, boots, etc.) and equip it on loading (like my script above) without referencing a specific item? I think if this could be done it would both fix my problem and remove the need for the script I posted here. Again, thanks for any help! Link to comment Share on other sites More sharing options...
Kohdi Posted August 28, 2012 Author Share Posted August 28, 2012 Okay, resurrecting an old topic here but my problem is still pretty similar. I've decided to scrap the script above because it was only treating the symptom, not the root problem. I needed a script to check the actor for armor/clothes when the cell is loaded, then equip those items in the usual fashion (greater rating/cost before lesser). I realized that the mannequins in player homes already do this, and so with (a lot) of modification I've trimmed down what I think are the relevant events and functions. Sadly, my npc is still loading naked even with a full set of armor and some clothes in his inventory. Here's what I've got (apologies for the length, be glad I didn't take it to all 50-some armor slots) - Scriptname KohdiVeraAutoEquipScript extends Actor Import Utility Form Property ArmorSlot01 auto hidden Form Property ArmorSlot02 auto hidden Form Property ArmorSlot03 auto hidden Form Property ArmorSlot04 auto hidden Form Property ArmorSlot05 auto hidden Form Property ArmorSlot06 auto hidden Form Property ArmorSlot07 auto hidden Form Property ArmorSlot08 auto hidden Form Property ArmorSlot09 auto hidden Form Property ArmorSlot10 auto hidden Form Property EmptySlot auto hidden EVENT OnCellLoad() Wait(0.25) EquipCurrentArmor() EndEVENT Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if (akBaseItem as Armor) AddToArmorSlot(akBaseItem) self.EquipItem(akBaseItem) endif EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if (akBaseObject as Armor) RemoveFromArmorSlot(akBaseObject) endif endEvent Function EquipCurrentArmor() if (ArmorSlot01 != EmptySlot) self.EquipItem(ArmorSlot01) endif if (ArmorSlot02 != EmptySlot) self.EquipItem(ArmorSlot02) endif if (ArmorSlot03 != EmptySlot) self.EquipItem(ArmorSlot03) endif if (ArmorSlot04 != EmptySlot) self.EquipItem(ArmorSlot04) endif if (ArmorSlot05 != EmptySlot) self.EquipItem(ArmorSlot05) endif if (ArmorSlot06 != EmptySlot) self.EquipItem(ArmorSlot06) endif if (ArmorSlot07 != EmptySlot) self.EquipItem(ArmorSlot07) endif if (ArmorSlot08 != EmptySlot) self.EquipItem(ArmorSlot08) endif if (ArmorSlot09 != EmptySlot) self.EquipItem(ArmorSlot09) endif if (ArmorSlot10 != EmptySlot) self.EquipItem(ArmorSlot10) endif endFunction Function AddToArmorSlot(Form akBaseItem) bool FoundEmptySlot = FALSE if (ArmorSlot01 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot01 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot02 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot02 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot03 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot03 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot04 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot04 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot05 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot05 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot06 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot06 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot07 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot07 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot08 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot08 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot09 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot09 = akBaseItem FoundEmptySlot = TRUE endif if (ArmorSlot10 == EmptySlot) && (FoundEmptySlot == FALSE) ArmorSlot10 = akBaseItem FoundEmptySlot = TRUE endif FoundEmptySlot = FALSE endFunction Function RemoveFromArmorSlot(Form akBaseItem) bool FoundMatchingSlot = FALSE if (ArmorSlot01 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot01 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot02 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot02 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot03 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot03 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot04 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot04 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot05 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot05 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot06 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot06 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot07 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot07 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot08 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot08 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot09 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot09 = EmptySlot FoundMatchingSlot = TRUE endif if (ArmorSlot10 == akBaseItem) && (FoundMatchingSlot == FALSE) ArmorSlot10 = EmptySlot FoundMatchingSlot = TRUE endif endFunction I realize it may look redundant or garbled, but keep in mind that I'm not entirely sure what some of it is doing. From what I can tell, the problem is arising from all the ArmorSlotXX properties not being defined, either well enough or at all. I've modeled this after the script on the mannequins with the applicable property applied, an INT called MannSlot (no chuckles) which I can't make heads or tails of, unless it's supposed to contain all the information for the armor slots. If someone can educate me on what I'm missing, what parts of that script are still relevant, or anything else, I'd be extremely grateful. This particular script has been biting my heels for far too long. Link to comment Share on other sites More sharing options...
Recommended Posts