GMS_RC/@GMS/addons/GMS/Compiles/Vehicles/fn_revealNearbyPlayers.sqf

55 lines
1.6 KiB
Plaintext
Raw Normal View History

2023-09-23 14:05:31 +00:00
/*
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\x\addons\GMS\Compiles\Init\GMS_defines.hpp"
2023-09-23 14:05:31 +00:00
params["_vehicle","_searchRadius","_detectionOdds"];
private["_player","_detectionOdds","_nearbyPlayers","_knowsAbout","_cansee","_knowledgeGained"];
2023-10-21 11:42:13 +00:00
_nearbyPlayers = [getPosATL _vehicle, _vehicle getVariable["GMS_vehicleSearchRange",500]] call GMSCore_fnc_nearestPlayers;
2023-09-23 14:05:31 +00:00
switch GMS_revealMode do {
case "detailed": {
private["_crew"];
_crew = crew _vehicle;
if !(_crew isequalto []) then {
{
if (random(1) < _detectionOdds) then {
_player = _x;
{
_cansee = [objNull, "VIEW"] checkVisibility [eyePos _x, getPosATL _player];
if (_cansee > 0) then {
_knowledgeGained = _cansee;
}
else {
_knowledgeGained = _x knowsAbout _player;
if (_knowledgeGained == 0) then {_knowledgeGained = 0.1};
};
_x reveal[_player,_knowledgeGained];
}forEach _crew;
};
}forEach _nearbyPlayers;
};
};
case "basic": {
{
_player = _x;
if (random(1) < _detectionOdds) then {
_knowsAbout = (_vehicle) knowsAbout _player;
if (_knowsAbout > 0) then {
_knowledgeGained = _knowsAbout;
}
else {
_knowledgeGained = (_searchRadius - (_x distance _vehicle))/_searchRadius;
};
_x reveal[_player, _knowledgeGained];
};
}forEach _nearbyPlayers;
};
};