Hi, I encountered this while modding. In the function PlayerBase::CalculateVisibilityForAI the script checks whether an attachment (to the player) is a clothing item, which tests that the config class inherits from `Clothing_Base` (equivalent to `IsKindOf("Clothing_Base")). If this is true, the if statement (marked below as "ohno") is executed and the EntityAI is cast to a `ClothingBase`, which is a script class. If an item is only defined in config, this will fail and cause a NULL dereference on the line marked as "OH NO".
```
void CalculateVisibilityForAI()
{
const int VISIBILITY_SLOTS_COUNT = 10;
int attcount = GetInventory().AttachmentCount();
float sumVisibility = 0;
float countVisibility = 0;
float visibilityMean = 0;
if (attcount > 0)
{
for (int att = 0; att < attcount; att++)
{
EntityAI attachment = GetInventory().GetAttachmentFromIndex(att);
if (attachment.IsClothing()) // uhoh!
{
ClothingBase clothing;
Class.CastTo(clothing, attachment);
sumVisibility += clothing.GetItemVisibility(); // OH NO
countVisibility++;
}
}
visibilityMean = (sumVisibility + (VISIBILITY_SLOTS_COUNT - countVisibility)) / VISIBILITY_SLOTS_COUNT;
SetVisibilityCoef(visibilityMean);
}
else
{
visibilityMean = 1;
SetVisibilityCoef(visibilityMean);
}
}
```
The fix is as simple as defining a script class for the item that inherits from `ClothingBase`, but the above code would be more robust if it was modified to be like below:
```
ClothingBase clothing;
if (Class.CastTo(clothing, attachment)) {
sumVisibility += clothing.GetItemVisibility(); // it's fine now
countVisibility++;
}
```