Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private["_spawnRadius","_minimumDistanceToTraderZones","_minimumDistanceToTerritories","_lootLifeTime","_buildings","_buildingNetIdsToSpawnLootIn","_building","_lastTimeSentToServer"];
if !(alive player) exitWith {false};
if !((vehicle player) isEqualTo player) exitWith {false};
_spawnRadius = getNumber (missionConfigFile >> "CfgExileLootSettings" >> "spawnRadius");
_minimumDistanceToTraderZones = getNumber (missionConfigFile >> "CfgExileLootSettings" >> "minimumDistanceToTraderZones");
_minimumDistanceToTerritories = getNumber (missionConfigFile >> "CfgExileLootSettings" >> "minimumDistanceToTerritories");
_lootLifeTime = 500;
_buildings = player nearObjects ["Building", _spawnRadius];
_buildingNetIdsToSpawnLootIn = [];
{
_building = _x;
try
{
if (isObjectHidden _building) throw false;
_lastTimeSentToServer = _building getVariable ["ExileLastLootRequestedAt", -99999];
if ((time - _lastTimeSentToServer) < _lootLifeTime) throw false;
if (_minimumDistanceToTraderZones > 0) then
{
if ([_building, _minimumDistanceToTraderZones] call ExileClient_util_world_isTraderZoneInRange) then
{
throw false;
};
};
if (_minimumDistanceToTerritories > 0) then
{
if ([_building, _minimumDistanceToTerritories] call ExileClient_util_world_isTerritoryInRange) then
{
throw false;
};
};
_buildingNetIdsToSpawnLootIn pushBack (netId _building);
_building setVariable ["ExileLastLootRequestedAt", time];
}
catch
{
};
}
forEach _buildings;
if ((count _buildingNetIdsToSpawnLootIn) > 0) then
{
["spawnLootRequest", [_buildingNetIdsToSpawnLootIn]] call ExileClient_system_network_send;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.