Epoch/Sources/epoch_code/compile/EPOCH_mineRocks.sqf

49 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-12-07 16:24:52 +00:00
/*
Author: Aaron Clark - EpochMod.com
Contributors:
Description:
Request mine rocks and scrap metal
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
2016-06-13 16:54:19 +00:00
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/EPOCH_mineRocks.sqf
2015-12-07 16:24:52 +00:00
*/
2016-09-01 00:29:08 +00:00
//[[[cog import generate_private_arrays ]]]
private ["_currentPos","_found","_foundIndex","_getWorldTypes","_object","_objects","_worldTypes"];
2016-09-01 00:29:08 +00:00
//[[[end]]]
2015-09-14 20:55:36 +00:00
if ((diag_tickTime - EPOCH_lastMineRocks) >= 2) then {
EPOCH_lastMineRocks = diag_tickTime;
if (random 1 < 0.33) then {
2015-09-14 20:55:36 +00:00
_currentPos = player modelToWorld[0, 5, 0];
if !(surfaceIsWater _currentPos) then {
_currentPos = ATLtoASL _currentPos;
};
_objects = lineIntersectsWith[eyePos player, _currentPos, player, objNull, true];
_object = objNull;
_found = false;
_foundIndex = -1;
{
_worldTypes = ["rock","cinder","wreck","ore"];
_getWorldTypes = [_x, _worldTypes] call EPOCH_worldObjectType;
{
if (_getWorldTypes param [_worldTypes find _x, false]) exitWith {
_found = true;
_foundIndex = _forEachIndex;
};
} forEach _worldTypes;
2015-09-14 20:55:36 +00:00
if (_found)exitWith{_object = _x};
}foreach _objects;
if (!isNull _object && {alive _object}) then {
[_object, _foundIndex, player, Epoch_personalToken] remoteExec ["EPOCH_server_mineRocks",2];
2015-09-14 20:55:36 +00:00
};
};
};