QuidProQuoBrute Posted January 5, 2013 Share Posted January 5, 2013 I've made a full companion in the GECK , but I was curious if there is a way for the NPC to use an item (sunglasses) when outdoors, and not when inside a little different, would it be possible to adjust what hours they use an item? (during sunlight) Link to comment Share on other sites More sharing options...
dangman4ever Posted January 5, 2013 Share Posted January 5, 2013 Probably would involve a script or two of some sorts. Maybe check out the scripts for those in-game perks that only work at certain times and a places. Link to comment Share on other sites More sharing options...
jazzisparis Posted January 5, 2013 Share Posted January 5, 2013 Add this code to your companion's script, inside a GameMode block: if YourCompanionRef.IsInInterior || (GetCurrentTime > 19) || (GetCurrentTime < 7) if YourCompanionRef.GetEquipped YourGlassesID YourCompanionRef.UnequipItem YourGlassesID 1 endif elseif YourCompanionRef.GetEquipped YourGlassesID elseif YourCompanionRef.GetItemCount YourGlassesID YourCompanionRef.EquipItem YourGlassesID endif Link to comment Share on other sites More sharing options...
Xaranth Posted January 5, 2013 Share Posted January 5, 2013 I suspect that Jazz's script would make a mess if there was any advantage to equipping the sunglasses. The companion would keep trying to equip them and the script would keep removing them. I would change it to remove the sunglasses from the inventory entirely. Like so: short sGlassesCount set sGlassesCount to YourCompanionRef.getItemCount YourGlassesID if YourCompanionRef.IsInInterior || (GetCurrentTime > 19) || (GetCurrentTime < 7) if YourCompanionRef.GetEquipped YourGlassesID YourCompanionRef.RemoveItem YourGlassesID sGlassesCount endif elseif YourCompanionRef.GetEquipped YourGlassesID elseif YourCompanionRef.getItemCount YourGlassesID >= 1 YourCompanionRef.equipItem YourGlassesID else YourCompanionRef.addItem YourGlassesID 1 YourCompanionRef.equipItem YourGlassesID endif Link to comment Share on other sites More sharing options...
jazzisparis Posted January 5, 2013 Share Posted January 5, 2013 Xaranth, Notice that the NoEquipFlag is set: YourCompanionRef.UnequipItem YourGlassesID 1 That means the actor will not be able to re-equip the item again until EquipItem is called on the same ID. Unless the game-engine overrides it with companions, what you describe should not happen. Link to comment Share on other sites More sharing options...
Xaranth Posted January 5, 2013 Share Posted January 5, 2013 Oooh. Learned something new. i actually neither saw nor recognized that particular flag. Useful! I stand corrected. +1 Link to comment Share on other sites More sharing options...
llamaRCA Posted January 5, 2013 Share Posted January 5, 2013 Xaranth, Notice that the NoEquipFlag is set: YourCompanionRef.UnequipItem YourGlassesID 1 That means the actor will not be able to re-equip the item again until EquipItem is called on the same ID. Unless the game-engine overrides it with companions, what you describe should not happen. Actually, the equipitem flag can fail with companions and clothing/armor. When players give them clothing items for the same slot with better DT and/or enchantments a companion may equip the other items over it regardless of the flag. I don't know if it will always happen in every body slot, but it happens in the body slot (or at least it happened routinely in the body slot for me). This isn't true with weapons, the equipitem flag holds an inferior weapon in place for a companion. But since the flag doesn't reliably hold clothing/armor in place, I think additional scripting to do that would be a good idea if it was important to never have that item change out. Edit: Oops I answered this backwards. You were highlighting Unequip. Well, that's not necessarily reliable either. Either way you should expect to need some kind of reinforcement to get the appropriate behavior with companions, armor/clothing and equip/unequip and their flags. Link to comment Share on other sites More sharing options...
jazzisparis Posted January 5, 2013 Share Posted January 5, 2013 (edited) Curious, I went on and tested, and it appears to be working properly with the EyeGlasses slot (I made sure there was no silent infinite loop). However, for obvious reasons, it would probably be wise to first verify there was no equipped item already occupying this slot: if YourCompanionRef.IsInInterior || (GetCurrentTime > 19) || (GetCurrentTime < 7) if YourCompanionRef.GetEquipped YourGlassesID YourCompanionRef.UnequipItem YourGlassesID 1 endif elseif YourCompanionRef.GetEquippedObject 11 elseif YourCompanionRef.GetItemCount YourGlassesID YourCompanionRef.EquipItem YourGlassesID endif GetEquippedObject would require NVSE, but that's no big a deal. Edited January 5, 2013 by jazzisparis Link to comment Share on other sites More sharing options...
QuidProQuoBrute Posted January 7, 2013 Author Share Posted January 7, 2013 either of these require NVSE? i can't for some reason get them to save. I changed the companionREF and glasses ID, but with no luck Link to comment Share on other sites More sharing options...
Xaranth Posted January 7, 2013 Share Posted January 7, 2013 Oh, yeah, GetEquippedObject is an NVSE function. Link to comment Share on other sites More sharing options...
Recommended Posts