Page MenuHomeFeedback Tracker

VicinityItemManager needs adjustment/fix
Acknowledged, UrgentPublic

Description

The implementation of how vicinity objects are being detected has been reworked and with that broke all existing mods that were using building inventories.

The first problem in RefreshVicinityItems(): If I read the function correctly, all Buildings are filtered out, and thus they will never show up in the inventory screen. It could be some other part but I suspect this from a first look:

if ( hit_object.IsBuilding() )
{
    //Print("!!!!!obstacle building: " + hit_object);
    is_obstructed = true;
}

Just because something is a building does not mean the process should be aborted. Remove the condition or perform a call to IsInventoryVisible() on the building to find out if it should be shown, or find any other way to include buildings into the vicinity items. Buildings can have inventories, and this function simply ignores that fact.

The second issue is, why are member variables created private... This makes this class unmoddable, and thus I can not even temporary fix it without doing a very hacky workaround ...

If there is not much time to address this, please roll back to the original vicinity item detection, cause that one worked just fine and did not break our mods.

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

rVn claimed this task.May 16 2019, 11:31 AM
rVn changed the task status from New to Need More Info.

It would help knowing what exactly are you trying to use this for, but from a quick test, overriding IsInventoryVisible() should make the building visible in vicinity, the snippet above deals with inventory being visible through walls

Buildings are not visible in the vicinity.

Normally all a building needs to do is have IsInventoryVisible() set to true, which is the case for my object. However, it is not returned from the vicinity container.

objects = VicinityItemManager.GetVicinityItems();

This code in VicinityContainer.c should return the building if it was recognized, but that is not the case. I have manually created a workaround to force the VicinityItemManager to add my building, and now it shows up. So the issue is 100% located somewhere in the VicinityItemManager.
Before the 1.03 update, everything was working fine with my building.

My workaround also leads me to believe that there is a logic issue within the filtering. Because the function to gather possible objects first work as intended.

static void Fix()
{
    auto objects_in_vicinity = new array< Object >;
    PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );

    GetGame().GetObjectsAtPosition3D( player.GetPosition(), FIX_VICINITY_DISTANCE, objects_in_vicinity, NULL );

    vector headingDirection = MiscGameplayFunctions.GetHeadingVector( player );
    DayZPlayerUtils.GetEntitiesInCone( player.GetPosition(), headingDirection, FIX_VICINITY_CONE_ANGLE, FIX_VICINITY_CONE_REACH_DISTANCE, FIX_CONE_HEIGHT_MIN, FIX_CONE_HEIGHT_MAX, objects_in_vicinity );

    foreach( auto obj : objects_in_vicinity )
    {
        if( obj.IsBuilding() ) AddVicinityItems( obj );
    }
}

I have narrowed the issue down with further testing. This filter prevents my object from beeing visible

if ( vector.DistanceSq( player.GetPosition(), object_in_cone.GetPosition() ) > FIX_VICINITY_CONE_REACH_DISTANCE * FIX_VICINITY_CONE_REACH_DISTANCE )
{
	if ( !object_in_cone.IsTransport() && !object_in_cone.CanUseConstruction() )
	{
		//Print("Distance ckeck pre: " + object_in_cone + " failed" );
		continue;
	}
}

As a temp fix, I have enabled CanUseConstruction() on my building, but that is not a permanent solution. My buildings are train wagons, and the distance seems to exceed the limit.

SCRIPT       : distanceSq: 7.24611
SCRIPT       : VICINITY_CONE_REACH_DISTANCE Sq: 4

Maybe it makes sense to adjust the check to also not apply to buildings ( isBuilding() )

rVn changed the task status from Need More Info to Acknowledged.May 16 2019, 3:27 PM
Unknown Object (User) added a subscriber: Unknown Object (User).May 17 2019, 4:04 PM
Unknown Object (User) added a comment.May 17 2019, 4:30 PM

Also, it does not show inventory in case if you create physics on the object using dBodyCreateDynamicEx and after 15 seconds that physics geometry will respawn/destroy itself so you can not open inventory of object any more