gc8 977 Posted April 14, 2020 Hi I want to make a scouting mission where player must find enemy base but I don't know what is the best approach for this. I could use simple distance check to see if player is near enough but there could be a hill blocking the line of sight. And I could use line intersect such as checkVisibility but that would probably have to be checked against every object in the base to see if player sees something. So I'm bit out of ideas, what would be the best way of doing this? thx! Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 Hi Gc8, This might be a possible way. I haven't tested this as I'm on my laptop so it may need some tweaking Making use of screenToWorld, which gets the in-game coordinates of the location where the player is looking, you can then compare this to see if it is in the area (InArea) covered by the marker. For the base, create a marker (in this case I've called my marker BaseMarker) or trigger that covers the designated area. This can either be done via script or placed in-game (you should be able to make the marker transparent or just place a trigger that covers the area). You can then use a waitUntil command similar to the following: systemChat "Find the base!"; waitUntil {(screenToWorld [0.5, 0.5]) inArea "BaseMarker"}; systemChat "You found the base!"; Please let me know if you have any luck with this! And if you have any questions Thanks Chewz 1 Share this post Link to post Share on other sites
POLPOX 778 Posted April 14, 2020 My stupid idea I always take is this: onEachFrame { _dist = (positionCameraToWorld [0,0,0] distance basePos); systemChat str ((positionCameraToWorld [0,0,_dist] distance basePos)/_dist); }; Smaller number = camera center is closer. Of course try not to use onEachFrame for actual work, this is just for temporary debugging. 2 1 Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 9 minutes ago, POLPOX said: My stupid idea I always take is this: onEachFrame { _dist = (positionCameraToWorld [0,0,0] distance basePos); systemChat str ((positionCameraToWorld [0,0,_dist] distance basePos)/_dist); }; Smaller number = camera center is closer. Of course try not to use onEachFrame for actual work, this is just for temporary debugging. Nice solution POLPOX 🙂 Share this post Link to post Share on other sites
gc8 977 Posted April 14, 2020 Thanks for the nice solutions guys! :) will use those 1 Share this post Link to post Share on other sites
7erra 629 Posted April 14, 2020 There is also checkVisibility Share this post Link to post Share on other sites
Alert23 215 Posted April 14, 2020 I also had to do something similar like this once, i used something like this: if (!lineIntersects [eyepos player, getPosATL Base] && [getposATL player,getdir player,45, getposATL Base] call BIS_fnc_inAngleSector && (player distance Base) < 30) then {}; Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 3 hours ago, 7erra said: There is also checkVisibility The problem with this I believe is the fact you can only check one position rather than a base area, but good suggestion! Share this post Link to post Share on other sites
atmo 29 Posted April 14, 2020 Also, worldToScreen would work I guess (^^ @Chewz ) Just test the base position and see if it's on the screen. I wonder which is the fastest method? Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 2 hours ago, atmo said: Also, worldToScreen would work I guess (^^ @Chewz ) Just test the base position and see if it's on the screen. I wonder which is the fastest method? Good suggestion @atmo I imagine worldToScreen would be definitely better for checking one specific location (such as a specific building in the base, or the entrances), in a similar way to checkVisibility, but I think it would be extremely hard to do an efficient in area check for like a designated area defined by a trigger (such as an area with a 100m radius). It depends on the requirements! It would be certainly quicker if you only needed to check lets say for 1 house or a checkpoint, but would be very hard for checking an area (unless you have an idea as to how this may work?) ScreenToWorld allows you to check an entire area but with the compromise that you have to physically look at the base area rather than it just being within your field of view / peripheral vision I'm not sure, what do you think? Chewz Share this post Link to post Share on other sites
atmo 29 Posted April 14, 2020 I might try to find out as I have so much time in isolation..... I am interested in this because of this topic.. not just trolling.. but that said, I have five days in work from tomorrow, so next week! Atmo 1 Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 8 minutes ago, atmo said: I might try to find out as I have so much time in isolation..... I am interested in this because of this topic.. not just trolling.. but that said, I have five days in work from tomorrow, so next week! Atmo It'll be interesting to see. The script you linked looks very cool by the way! I've never seen a concept like that before I guess one downside of my method of not using checkVisibility is the impact of weather, as checkVisibility can be impacted by fog etc which TankBuster mentioned in your post, which is very cool! This could be included however; you simply include it in the waitUntil to ensure that you have line of sight and it is visible even after taking into account weather impacts. I'll be intrigued to see if you'll be able to get it to work though, and if there's a noticeable performance difference. Thanks Chewz Share this post Link to post Share on other sites
thy_ 152 Posted March 3, 2023 Not a solid solution but to prevent terrain from blocking the unit view, I check with this down below. Works for my purposes 75-80% percent. // CAREFUL: This command is CPU intensive on the engine, be careful with its use. while { true } do { private _checkVisual = terrainIntersect [(getPosATL (leader grp1)), (getPosATL YOURBASE)]; sleep 5; }; 1 Share this post Link to post Share on other sites
Play3r 147 Posted March 7, 2023 (edited) Try this : just change it to fit your needs.. if ( cameraView == "GUNNER" && { cursorObject == TheTarget } ) then { if ( currentWeapon player isKindOf [ "Binocular", configFile >> "CfgWeapons" ] ) then { true } else { if !( player weaponAccessories currentWeapon player select 2 isEqualTo "" ) then { _scope = player weaponAccessories currentWeapon player select 2; _opticRangedCfg = (" isArray( _x >> 'discreteDistance' ) && { count getArray( _x >> 'discreteDistance' ) > 1 } " configClasses( configFile >> "CfgWeapons" >> _scope >> "ItemInfo" >> "OpticsModes" )) select 0; _opticRanges = getArray( _opticRangedCfg >> "discreteDistance" ); _opticLowerRange = selectMin _opticRanges; _opticUpperRange = selectMax _opticRanges; _currentOpticZeroing = currentZeroing player; if ( _currentOpticZeroing >= _opticLowerRange && _currentOpticZeroing <= _opticUpperRange ) then { true } else { false }; } else { false }; }; }; I don't know how to set SQF in this forum, but i guess you will work it out 🙂 you have to use a scope or some kind of Binocular. Edited March 7, 2023 by Play3r Share this post Link to post Share on other sites
Harzach 2517 Posted March 7, 2023 2 hours ago, Play3r said: I don't know how to set SQF in this forum _hasFoundTarget = if ( cameraView == "GUNNER" && { cursorObject == TheTarget } ) then { if ( currentWeapon player isKindOf [ "Binocular", configFile >> "CfgWeapons" ] ) then { true }else{ if !( player weaponAccessories currentWeapon player select 2 isEqualTo "" ) then { _scope = player weaponAccessories currentWeapon player select 2; _opticRangedCfg = (" isArray( _x >> 'discreteDistance' ) && { count getArray( _x >> 'discreteDistance' ) > 1 } " configClasses( configFile >> "CfgWeapons" >> _scope >> "ItemInfo" >> "OpticsModes" )) select 0; _opticRanges = getArray( _opticRangedCfg >> "discreteDistance" ); _opticLowerRange = selectMin _opticRanges; _opticUpperRange = selectMax _opticRanges; _currentOpticZeroing = currentZeroing player; if ( _currentOpticZeroing >= _opticLowerRange && _currentOpticZeroing <= _opticUpperRange ) then { true }else{ false }; }else{ false }; }; }; 1 1 Share this post Link to post Share on other sites