Is there a way to get the closest encounter?

I am writing a scrip that sets the closest encounter to active. I have a bunch of areas with portal at the exit, and there is 1 encounter in each of these areas. When the player leaves, I want to set that encounter as active, but I don’t want to write a unique script for each area, I’d rather have 1 that gets the closest encounter and sets it active. I already know how to set an encounter to active, I just need a way to grab the closest encounter.

There’s an OBJECT_TYPE_* constant for encounters. :thinking:

Try using GetNearestObject(OBJECT_TYPE_ENCOUNTER);

1 Like