I also have a problem with critters wearing armor in worldmap_init I put .AddItem( PID_LEATHER_JACKET, 1, 1, SLOT_ARMOR ) under the critter id that I wanted to wear it and it worked but i did it for the caravan guards and unity patrol ncr etc.. and they don't wear the armors I wanted them to wear instead they put the items in the inventory why is it doing this it works for some critters?
Figured this one out.
In worldmap_init when the critters are initialized, it'll have their script defined as well. For NPC groups like Raiders, etc... it'll have "encounter_npc@_NpcInit", or something similar.
Go to encounter_npc.fos, find this part, and add in the "favorite armor" sections. Or just copypasta this...
void _NpcInit( Critter& npc, bool firstTime )
{
uint bt = npc.Stat[ ST_BODY_TYPE ];
if( bt >= BT_MEN && bt <= BT_GHOUL )
{
npc.SetEvent( CRITTER_EVENT_MESSAGE, "_NpcMessage" );
npc.SetEvent( CRITTER_EVENT_DEAD, "_NpcDead" );
npc.SetEvent( CRITTER_EVENT_SMTH_DEAD, "_NpcSmthDead" );
npc.SetEvent( CRITTER_EVENT_SMTH_USE_SKILL, "_NpcSmthUseSkill" );
npc.SetEvent( CRITTER_EVENT_PLANE_END, "_NpcPlaneEnd" );
npc.SetEvent( CRITTER_EVENT_STEALING, "_NpcStealing" );
npc.SetEvent( CRITTER_EVENT_SMTH_USE_ITEM, "_NpcSmthUseItem" );
npc.SetEvent( CRITTER_EVENT_SMTH_DROP_ITEM, "_NpcSmthDropItem" );
Item@[] items;
npc.GetItems( -1, items );
bool favrtAmmoSet = false;
bool favrtWpnSet = false;
bool favArmor = false;
for( uint i = 0, j = items.length(); i < j; i++ )
{
SetDeterioration( items[ i ], Random( 80, 95 ) );
if( items[ i ].GetType() == ITEM_TYPE_WEAPON && !favrtWpnSet )
{
npc.SetFavoriteItem( SLOT_HAND1, items[ i ].GetProtoId() );
favrtWpnSet = true;
}
}
for( uint i = 0, j = items.length(); i < j; i++ )
{
SetDeterioration( items[ i ], Random( 60, 85 ) );
if( items[ i ].GetType() == ITEM_TYPE_ARMOR && !favArmor )
{
npc.SetFavoriteItem( SLOT_ARMOR, items[ i ].GetProtoId() );
favArmor = true;
}
}
}
}
I haven't exactly figured out how to make it drop to their inventory slot on death, but I'm working on it.
This will at least make them WEAR the armor, and not take it off the second they get the chance.