Jump to content

EquipItem & settlers reverting to default armor


Recommended Posts

Hi,

 

I'm made a script where I can set Armor (Form) containers and equip Settlers with the container that I select. Everything is working fine except that when I leave the settlement and come back that settlers revert to their default armor.

 

I read that this was a bug and it was fixed ???

 

Here is the line that equip the settler:

thisActor.EquipItem(thisArmor, true, true)

Is that bug fixed and am I doing something wrong?

Link to comment
Share on other sites

I generally create a holding cell and a temporary chest, move the stuff to the temporary chest, transfer the contents of the container, and then equip the items. For example

	while i < ActorsAll.Length
		WorkshopNPCScript theActor = ActorsAll[i] as WorkShopNPCScript
		; Remove all items from the NPC's inventory
		theActor.RemoveAllItems()
		; Add select items to the temporary container
		FO4_TemporaryChest01.AddItem(GaussRifle, 1, true)
		FO4_TemporaryChest01.AddItem(Ammo2mmEC, 5, true)
		FO4_TemporaryChest01.AddItem(Caps001, 100, true)
		FO4_TemporaryChest01.AddItem(Stimpak, 3, true)
		FO4_TemporaryChest01.RemoveAllItems(theActor, abKeepOwnership = false)
		theActor.EquipItem(GaussRifle, false, false)
		theActor.EquipItem(Ammo2mmEC, false, false)
		theActor.SetOutfit(FO4_CombatUniform01)
		i += 1
	EndWhile
Edited by pepperman35
Link to comment
Share on other sites

Thanks for your reply pepperman35.

 

I just tried removing all items in the settler inventory before the equipitem and same result. When I go somewhere else and come back to the settlement, the settlers reverted to the default outfit.

 

I read on this forum, that this bug affected the equipitem function but not the setoutfit function. But in my case, I use armor from different mod to dress the settlers, it's not an ouftit.

 

Maybe I'm doing something wrong because the equipitem abPreventRemoval is set to True.

Edited by F4ll0uta
Link to comment
Share on other sites

thanks lee3310,

 

Do you know a workaround ?

Sadly no (i don't know maybe others do). If you just want to equip a specific outfit to a settler, you can try setting it as "default" outfit so when the bug occurs, you won't notice any changes (untested).

 akActor.SetOutfit(Outfit akOutfit, bool abSleepOutfit = false)
Link to comment
Share on other sites

Not sure about this issue, but in my practice, if you add or remove armor or weapon from inventory by script it resets outfit to default.

I call it some NPC inventory protect system. Maybe it's really bug.

You can check it - equip some items with script, and then try using console add or remove armor (even if it not equipped) from NPC inventory. I'm sure it will reset it to default outfit.

Cure what i use (mostly it helps). Before additem or remove item to inventory call on NPC unequipitem (even if item not equipped) of this item. Help in most cases.

Usually helps not add items, but call equipitem, if item not in inventory. If item is removed and script try to return it back, usually helps other thing as drop this reference by drop() and then additem(self,1,true) - it adds back not item but sent dropped item reference back to inventory and it will likely not trigger outfit reset system. But this inventory is still vulnerable to console add remove items commands.

I will test outfit system for me.

So there is questions about it. I suppose outfit is formlist, so on it works all formlist functions?

Can i store default outfit formlist as script variable on NPC (maybe made this reference as essential)? So it will guaranties that every NPC what i touch have misc item in inventory with default outfit formlist. And every outfit is unique? Says i have 2 settlers and i need 2 different custom outfits. So i store different items in each settler inventory and keep there this NPC outfit?

Edited by Elsidia1
Link to comment
Share on other sites

 

So there is questions about it. I suppose outfit is formlist, so on it works all formlist functions?

 

 

Actually, Outfit is not a FormList and can not be used in functions which accepts FormList. But under the hood it is a list of forms

 

About initial problem described by F4ll0uta

As I understand the problem is resetting NPC clothes to default outfit after cell unload/load.

I would solve this problem by introducing magic effect that constantly applied to NPC and ensuring that necessary clothing elements are applied in OnEffectStart event.

The idea is based on the fact that magic effect script is finished when cell with this NPC is unloaded and started when cell is loaded. It usually works, but sometimes magic effect scripts are not finished, even if NPC (and cell) is unloaded. Seems like a engine bug. But it doesn't matter for your purposes.

Link to comment
Share on other sites

 

 

So there is questions about it. I suppose outfit is formlist, so on it works all formlist functions?

 

 

Actually, Outfit is not a FormList and can not be used in functions which accepts FormList. But under the hood it is a list of forms

 

About initial problem described by F4ll0uta

As I understand the problem is resetting NPC clothes to default outfit after cell unload/load.

I would solve this problem by introducing magic effect that constantly applied to NPC and ensuring that necessary clothing elements are applied in OnEffectStart event.

The idea is based on the fact that magic effect script is finished when cell with this NPC is unloaded and started when cell is loaded. It usually works, but sometimes magic effect scripts are not finished, even if NPC (and cell) is unloaded. Seems like a engine bug. But it doesn't matter for your purposes.

 

Sorry for off topic.

 

Then there is logical new questions. I check outfit script you given, but my c++ skill don't allow it understand. CK wiki have zero useful info. Ok not zero, but still crap. Is it possible add, find or remove armour form from loaded outfit F4SE getoutfit? Find is form with keyword are in outfit list? My simple idea is update NPC default outfit every time when equipped new item, so it always will restore back to actual equipment.

 

About OnEffectStart OnEffectFinish. As you know i actually work on mod, what count on it. And for NPC it works terribly wrong. Idea is that after effect is started and next equip unequip item, using trade menu (even vanilla) triggers OnEffectFinish from previous equipped item, even if item with effect not unequipped. So i solve this problem by start effect again. (using some voodoo FO4 skills)))

 

So if you relate your mod on that effect finish when cell is unloaded you need count this thing too.

 

Also for player this event not trigger. So it works as expected.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...