- Status
- Offline
- Joined
- Mar 3, 2026
- Messages
- 692
- Reaction score
- 457
Stop wasting time iterating through five different entity lists just to find a stray infected or a specific loot pile.
If you are working on an internal project for DayZ, there is a much cleaner way to handle spatial queries. Instead of the traditional manual loops, you can leverage the engine's built-in CGame::GetObjectsAtPosition3D. This native method is significantly more efficient for proximity-based checks.
Prerequisites
The Enfusion Native
DayZ's engine provides a native function that collects objects within a specified radius and dumps them into an array. It's the same logic the game uses for physics and proximity triggers.
Required Structs
To properly navigate the returned data, you need to map the Enfusion engine's array and weak pointer structures. Note the header padding and the reference counting logic.
Usage & Filtering
Once you have your structs aligned, calling the native is straightforward. In this example, we're scanning a 500m radius. Be aware that this returns everything—including static meshes like trees, roads, and fences.
Technical Notes
Because this method returns environmental objects (roads, buildings), it is incredibly powerful for advanced features like auto-pathing or calculating complex line-of-sight checks without manually rebuilding the world state. However, keep an eye on performance; iterating 12,000 objects every frame will tank your FPS if your IsKindOf checks or rendering logic isn't optimized.
Drop a comment if you've found a more reliable way to filter static meshes out of the results without excessive overhead.
If you are working on an internal project for DayZ, there is a much cleaner way to handle spatial queries. Instead of the traditional manual loops, you can leverage the engine's built-in CGame::GetObjectsAtPosition3D. This native method is significantly more efficient for proximity-based checks.
Prerequisites
- This is for internal development only. If you are trying to do this externally, look elsewhere.
- You must be comfortable with IDA. You need to locate the strings and signatures yourself.
- Do not ask for offsets or signatures in the thread—if you can't find them, you shouldn't be using this anyway.
The Enfusion Native
DayZ's engine provides a native function that collects objects within a specified radius and dumps them into an array. It's the same logic the game uses for physics and proximity triggers.
Code:
// Engine Prototype
// proto native void GetObjectsAtPosition3D(vector pos, float radius, out array<Object> objects, out array<CargoBase> proxyCargos);
// Implementation Hook
static METHOD_ARGS(void, CGame, GetObjectsAtPosition3D, (enf::vector* pos, float radius, enf::array<enf::Object>* objects, enf::array<enf::Object>* cargo), nullptr, pos, radius, objects, cargo);
Required Structs
To properly navigate the returned data, you need to map the Enfusion engine's array and weak pointer structures. Note the header padding and the reference counting logic.
Code:
template <typename T>
struct array
{
uint8_t _header[0x28];
WeakPtr<T>** data;
int32_t capacity; // Engine cap is usually 20479
int32_t count;
uint8_t _tail[8];
};
template <typename T>
class WeakPtr
{
public:
void* vtable;
int32_t refcount;
int32_t _pad;
T* instance;
T* get() const
{
if (!utils::IsValidPointer(const_cast<WeakPtr*>(this))) return nullptr;
if (!utils::IsValidPointer(instance)) return nullptr;
return instance;
}
T* operator->() const { return get(); }
explicit operator bool() const { return get() != nullptr; }
};
Usage & Filtering
Once you have your structs aligned, calling the native is straightforward. In this example, we're scanning a 500m radius. Be aware that this returns everything—including static meshes like trees, roads, and fences.
Code:
static enf::array<enf::Object> objs = {};
static enf::array<enf::Object> cargo = {}; // CargoBase*
const auto& position = g::localPlayer->GetPosition_Internal();
// 500m radius can return ~12k objects depending on the area
enf::CGame::GetObjectsAtPosition3D(&position, 500.0f, &objs, &cargo);
for (int i = 0; i < objs.count; ++i)
{
const auto& tracker = objs.data[i];
const auto& object = tracker->get();
if (!utils::IsValidPointer(object))
continue;
// Filter for infected, players, or loot
if (object->IsKindOf(enf::DayZInfected::Class()))
renderInfected(object);
}
Technical Notes
Because this method returns environmental objects (roads, buildings), it is incredibly powerful for advanced features like auto-pathing or calculating complex line-of-sight checks without manually rebuilding the world state. However, keep an eye on performance; iterating 12,000 objects every frame will tank your FPS if your IsKindOf checks or rendering logic isn't optimized.
Drop a comment if you've found a more reliable way to filter static meshes out of the results without excessive overhead.