Closed Tappczan closed 6 years ago
Very difficult for me at this time considering the roadmap, that would be part of the Undercover Rework.
Any pull request regarding that is more than appreciated!
I've tried to wrap my head around how to implement this in the code. I'm not a coder or a script writer, I've only tinkered a little in the past with scripting in Operation Flashpoint and Arma 2, so my knowledge is limited. I think a way to get this working is to make a copy of the distanceUnits function and modyfing it by adding checkVisibility.
{ _spottedUnit = _x; if (captive _spottedUnit) then { [_spottedUnit,false] remoteExec ["setCaptive",_spottedUnit]; }; } forEach ([50,0,position _dog,"BLUFORSpawn"] call distanceUnits);
As I understand from the above code from guardDog.sqf, it finds all blufor units with the captive status in a 50m radius from the guard dog and set their status to false. I tried adding the checkVisiblity command:
{ _spottedUnit = _x; if ((captive _spottedUnit) AND ([objNull, "VIEW"] checkVisibility [eyePos _dog, eyePos _spottedUnit]>0)) then { [_spottedUnit,false] remoteExec ["setCaptive",_spottedUnit]; }; } forEach ([50,0,position _dog,"BLUFORSpawn"] call distanceUnits);
Now it would also take into account the visiblity (line of sight) between the guard dog and blufor units, but when for eg. one player would be spotted in this 50m radius, other players in that radius (which the dog couldn't directly see) would also lost their undercover status. So I think the best way is to modify the distanceUnits function:
params ["_distance","_mode","_ref","_varName"]; private _result = false;
if (_mode == 0) then{ _result = []; { if (_x getVariable [_varName,false]) then { if ((_x distance _ref < _distance) AND ([objNull, "VIEW"] checkVisibility [eyePos _ref, eyePos _x]>0)) then { _result pushBack _x; }; }; } forEach allUnits; }else{ {if ((_x getvariable [_varName,false]) and (_x distance _ref < _distance)) exitWith {_result = true}} count allUnits; };
_result
This could be a seperate function only for use of the guarddog.sqf script for name it like visibilityUnits or similar and use it in that script.
I used the eyepos position for the checks, because it returns mostly 0 or 1 values and some between values, when the unit is obstructed by for eg. bushes. Other postition checks lik GetPos, GetPosATL, GetPosASL gives various results and I'm not sure about them. The only flaw of the eyepos is that sometimes when the unit is in a vehicle, like a civilian hatchback, it sometimes returns 0 value.
OK, my method for visibility detection don't work, because eyePos and other postion commands requires a Object, not an array with objects:
17:43:59 Error in expression <AND ([objNull, "VIEW"] checkVisibility [eyePos _ref, eyePos _x]>0)) then {_resu> 17:43:59 Error position: <eyePos _ref, eyePos _x]>0)) then {_resu> 17:43:59 Error eyepos: Type Array, expected Object
I need somehow to check the visibility for all units in array, listed by the distanceUnits function.
{ _spottedUnit = _x; if (captive _spottedUnit) then { [_spottedUnit,false] remoteExec ["setCaptive",_spottedUnit]; }; } forEach ([50,0,position _dog,"BLUFORSpawn"] call distanceUnits);
Maybe like this? Going to check it today.
{ _spottedUnit = _x; if (captive _spottedUnit) then { [_spottedUnit,false] remoteExec ["setCaptive",_spottedUnit]; }; } forEach (([50,0,position _dog,"BLUFORSpawn"] call distanceUnits) AND ([objNull, "VIEW"] checkVisibility [eyePos _dog, eyePos _spottedUnit]>0));
Interesting attempt!
Im sorry to interrupt but... are you really trying to code a LOS detection script in the case of a DOG?????
I don't rely in LOS (which is implemented in some other scripts working perfectly) in the Dog Guard script because of obvious reasons.
I think the smoke cover script had a LOS snippet.
And yours should be this:
} forEach (([50,0,position _dog,"BLUFORSpawn"] call distanceUnits) select {([objNull, "VIEW"] checkVisibility [eyePos _dog, eyePos _x]>0))};
If you do this way an error you are using boolean commands instead of expected arrays will appear.
Thanks for the feedback Barbolani, but yeah... I tried to put the LOS check for the dog, because as I stated in my opening post, it was really annoying to be detected by the dog through buildings. I don't know how much resource intensive is the LOS check, but still I think it would be a nice addition. If not, I would still use it on my server when playing with friends.
Dogs SMELL, they detect you through buildings.
Anyway, you don't need LOS check for your purpose, you need knowsabout command use.
And dogs sights are very bad!!!
I consider this not relevant considering the amount of stuff that still have to be done :( thanks anyway for the hint!
Hello. Is it possible to make the guard dog detection based on actual line of sight, instead of just a simple 50m radius? Becasue sometimes it annoys me, that my undercover status (mostly in cities) is blown through buildings, because the guard dog happened to be on the other side of the building, completely unseen. I think it could be implemented with an additional line in the guardDog.sqf script, using the checkVisibility command. The script could check the 50m radius for any possible undercover players and then check the LOS between them.