Created
April 17, 2017 17:08
-
-
Save BrettNordin/5c64b4cbc7431b48277f4bdccf09a3bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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