Jump to content
Sign in to follow this  
ramsen

Reveal Units In Area To A Single Unit

Recommended Posts

hi all.

 

After 4 hours researching im left no option but to ask!

 

I want to reveal all units in a given area / distance to a SINGLE UNIT .(In this case a sniper)

 

Ive found lots of examples of revealing enemy to allies etc but not enemies to a single unit and then target them?

 

So far i can only get this to work for targeting a unit with a unit:

 

sniper1 doTarget muppet;

(This works well, as the sniper even fires at well over 600ms probably would go much further...)

 

But i want the sniper to know all enemy targets in a 1500m every x amount of seconds.

 

basically below is the jist of what i want:

 

(sniper1) snipers init field:

revealedunits = nearestObjects [sniper1, ["man"], 1500]; sniper1 doTarget revealedunits; sleep 60;

 

obviously code does not work! but I need something along the lines of:

 

>List all enemy in radius from sniper.

>Reveal those enemies to the sniper

>sniper target those enemies

>reset script after x amount of time

 

i would rather use a simple in-editor script if possible as I am not using .sqf at this time (or have ever used it?) but im open to change if needs must. Just point out where i would need to place the sqf's if you would.

 

thx. good night.

 

Share this post


Link to post
Share on other sites

Could be a bit over the head for a beginner:

In init.sqf:

TAG_fnc_sniperAutoReveal = {
	params ["_sniper"];

	_enemySides = [side _sniper] call BIS_fnc_enemySides;


	while {alive _sniper} do {
		sleep 5;
		_enemies = allUnits select {side _x in _enemySides AND getposasl _x distance getposasl _sniper <= 1500};
		
		{
		                                                                                                       
			_sniper reveal [_x,4];
		                                                                                                       
		} forEach _enemies;
	}
};

In snipers init field:

_snipe = [this] spawn TAG_fnc_sniperAutoReveal;

If you got any questions feel free to ask.

No need to add any doTarget or doFire stuff, since snipers using snipe rifles and scopes will engage up to 2km from what I've last tested, as long as they got line of sight.

 

Cheers

Share this post


Link to post
Share on other sites

Hi grumpy,

 

am a beginner but do know a little scripting all trial and error really but that script seems quite straight forward, more on your script a bit latter but first this is the experiment i am trying:

 

Overal experiment to make an enemy sniper fire at long range targets, snipers in my mission do nothing at the moment unless at short range or have ID the targets.

 

Difficulty settings: Custom setting - precision 0.40 skill 0.75

 

Test environment:

>On tanoa bala airstrip sniper (Named sniper) at one end with 100% skill and one single move wp just in front of him (Combat, Open fire, Full speed.)

>600ms on far end of bala aistrip i placed a single moving enemy VR guy (named muppet) also tried adding a moving csat soldier with him.

 

Test 1> At 600ms the sniper does not fire, nor see's the targets? just stands (or crouches, or goes prone)...same at 500ms and even 400ms for moving!

Test 2,3,4 > 300ms, 200ms, and 100ms he fires (over several tests between 2-5 seconds 2-6 shots per kill)

 

NON MOVING targets, he does not even fire at 200ms!!!??? only at 100ms so am very confused.

 

As for your script, i created a new notepad doc init.sqf (made sure the suffix was sqf not txt) and placed that in my test missions folder.

 

Im not sure if your code for the sniper init:

_snipe = [this] spawn TAG_fnc_sniperAutoReveal;

 

was meant to be?

 

_sniper = [this] spawn TAG_fnc_sniperAutoReveal;

 

I tried 5 tests using each.

 

I tried 10 tests with same params as above 600ms two targets moving.

 

only ONCE did the sniper actually engage and took down both targets at 600ms. (using:  _sniper = [this] spawn TAG_fnc_sniperAutoReveal;)

 

But all other 9 tests were failures.

 

p.s i need some confirmation that your script fires (e.g hint "Yep, grumpys great script is now rock and rolling!") ya know somink along them lines..

 

p.p.s also would be good if we could get AI spotters to use his binocs and actually locate targets for the sniper!... would be a start.

 

anyway the experiment continues... cheers.

 

 

 

Edited by ramsen
typos etc etc you know the drill

Share this post


Link to post
Share on other sites

The thing in front of the equal sign is just a handle, could be _tomato for all it matters.

Try this, added some debugging hints that you can later on disable to false in the first line:

TAG_fnc_sniperAutoReveal = {
	params ["_sniper",["_debug",true]];

	_enemySides = [side _sniper] call BIS_fnc_enemySides;

	if (_debug) then {hint "grumpys great script is now rock and rolling!"};

	sleep 5;

	while {alive _sniper} do {

		sleep 0.5;
		if (!alive _sniper) exitWith {};
		_enemies = allUnits select {side _x in _enemySides AND getposasl _x distance getposasl _sniper <= 1500};
		_target = assignedtarget _sniper;
		_dist = _sniper distance _target;
		_weap = getText (configfile >> "CfgWeapons" >> currentWeapon _sniper >> "displayName");
		_scope = getText (configfile >> "CfgWeapons" >> ((primaryWeaponItems _sniper) select 2) >> "displayName");

		_lineofsight = if (lineIntersects [eyepos _sniper,eyepos _target,_sniper,_target]) then {"No"} else {"Yes"};

		if (_target isequalto objnull) then {_dist = "N/A";_lineofsight = "No target"};

		if (_debug) then {hintSilent format ["Sniper %1. %2\n%3 - %4\n\nKnown enemies: %5\nTargeting: %6\nDistance: %7m\nLine of Sight: %8.",[_sniper,"displayNameShort"] call BIS_fnc_rankParams,name _sniper,_weap,_scope,_enemies,_target,_dist,_lineofsight]};

		{

			_sniper reveal [_x,4];

		} forEach _enemies;

	};

	if (_debug) then {hint "grumpys great script has stopped rocking and rolling!"};

};

_potatotomato = [this] spawn TAG_fnc_sniperAutoReveal;

You can copy all of it into the units init field if you want, it's just tidier to have the function defined in the init.sqf and just making a simple spawn in the units init field instead.

I'm getting roughed up really bad at around 650-700m.

Make sure the sniper has an appropriate weapon, srifle class works best, also give him an appropriate scope.

 

Cheers

Share this post


Link to post
Share on other sites

haha!! works perfectly! top man. I put the script in the snipers init as Ive done with all other stuff didn't know you could do that with these type of scripts.... _patatotomato lol 

 

+ The debug thing is mental loving that...

 

using 'B_T_Sniper_F' rifle M320 LRR .408 (LRPS scope)  I conducted 5 quite comical tests with moving + non moving targets and he sniped them al! i think its safe to say mr 'muppet' VR and CSAT soldier were definitely NOT laughing!.........cos their DEAD!!

 

i will copy that script save it somewhere cos i need to learn some of what you did there. I did retested without ur script, same params + an enemy VR (muppet) at 200ms not moving, sniper does NOT shoot?? surely the sniper can acquire a target at this range.... but anyway ur script is kind of like a 'spotter' for the sniper + is  great that he uses line of sight as well.

 

anyway that will do for now... well for this anyway, i will experiment with that.

 

I do have 2 other annoying simple probs > one is i cannot get 'thislist' to work for anything in trigger condition, usually i can sync trigger ownership to the units, but i really needed it the other day so if you know why please enlighten me! it used to work in arma 2?

 

Also can you add way-point via trigger activation like in the expression field of the spawn module e.g wp = (_this select 0) addWaypoint [(getMarkerPos "m1"),10];

This does not work within way-point or trigger activation, I have to use the doMove for units and Move for groups if I need to trigger movement (or use ton of way-points with hold / cycle etc etc) anyway just wondering.

 

thx again for your help.

Edited by ramsen
yep more typos and what not... ramsen is illiterate!

Share this post


Link to post
Share on other sites
14 minutes ago, ramsen said:

but anyway ur script is kind of like a 'spotter' for the sniper + is  great that he uses line of sight as well.

 

The snippet only shows the sniper where enemies are, everything else is vanilla arma AI.

 

 

 

15 minutes ago, ramsen said:

I do have 2 other annoying simple probs > one is i cannot get 'thislist' to work for anything in trigger condition, usually i can sync trigger ownership to the units, but i really needed it the other day so if you know why please enlighten me! it used to work in arma 2?

 

Also can you add way-point via trigger activation like in the expression field of the spawn module e.g wp = (_this select 0) addWaypoint [(getMarkerPos "m1"),10];

This does not work within way-point or trigger activation, I have to use the doMove for units and Move for groups if I need to trigger movement (or use ton of way-points with hold / cycle etc etc) anyway just wondering.

 

thx again for your help.

 

Make sure trigger detection is set to something, anybody, blufor, opfor, it will only activate if units of given side are inside the trigger area and in the triggers condition field you need to have "this".

About waypoints depends on what you want.

For simple patrols there's always BIS_fnc_taskPatrol or BIS_fnc_taskDefend.

 

Cheers

Share this post


Link to post
Share on other sites
3 minutes ago, Grumpy Old Man said:

The snippet only shows the sniper where enemies are, everything else is vanilla arma AI.

 

exactly, just like the snipers 'spotter team should do'. i will try adding the scrip to the spotter unit of the sniper team and see how that pans out.....

 

eventually maybe I could make the spotter use the binoculars and scan horizon every time your script fires (say every 60-120 seconds or so). apparently though making a unit use the binocs animation for more than half a second + scan the horizon with them requires a lot of scripting, but i found a few examples and threads on that subject so I will look into that when i learn a little more about scripts. for now this is great and does the trick.

 

20 minutes ago, Grumpy Old Man said:

in the triggers condition field you need to have "this".

 

of course i forgot the 'this'!! o.k created trig blufor activation present with a blufor fella noob1 + condition: this && noob1 in thislist. worked! then named him noob2 and trigger didnt fire as it shouldnt. yay! that had been annoying me for ages.

 

+ yep already use the patrol and task defend.... a bit too much actually!

 

anyway thx again for your help. ;)

  • Like 1

Share this post


Link to post
Share on other sites

O.k I am going to continue with sniper experiments but more so now with the 'spotter' unit.

 

Grumpys above' debug script' has shown me how the ai targets units and then attacks, follows, hunts down targets its aware of, also adding move waypoint allowed the sniper to hunt me down all over the map and chased me for over 1km! so maybe its a little too 'terminator' for what i would require but in the right direction. Adjusting the script by lowering the revealed units to around <=600 and running the script at longer intervals (sleep 120) allows a unit to escape but of course he 'knowsabout' ALL the targets in that area and so he shoots and shoot and shoots more until they are down, thus depleting the snipers ammo.

 

So now i know how the ai targets I now wish to try something a little different, but again my lack of scripting knowledge is holding me back, though when i look at grumpys script closely it is quite straight forward but im lost when i try create my own.

 

In a nutshell this is what my next experiment is:

 

Environment for experiment 2:

> Create one fixed sniper at end of bala airfield looking down entire runway prone init: this disableAI "MOVE"; this setCombatMode "YELLOW"; this setUnitPos "DOWN";

 

* Remember without grumpys script the sniper fails to shoot at anything past 200ms unless it has id / acquired the target.

 

> place enemy VR units at 100m intervals with init: this disableAI "MOVE"; this setUnitPos "UP" on all of them (or i can use 'this allowFleeing 0' but they still crouch)

> Place three spotters at 3 different points on airfield: init: this disableAI "MOVE"; this setCombatMode "BLUE"; (so they dont move or fire and kill the vr units themselves)

 

Script I require:

> spotters will aquire the targets

> Spotters upload their target info to the sniper!

 

thats it......ok its not gonna be simple is it....

 

Result

> Hopefully sniper shoots, killing all the spotters revealed targets....

 

I imagine the script would require use of 'knowsabout' and create an array of known units for each spotter and then 'reveal' those units/ arrays to the sniper. But i'm just not that advanced on scripting.

 

cheers.

 

p.s i have spent the whole day on this, lol, i swear i will have nightmares tonight of terminator snipers hunting me down mercilessly.....so yeah thx grumpy! ;D

Share this post


Link to post
Share on other sites

Okay, been testing my Spotter / Sniper script. No one replied to previous post so shall bump this post cos i still need HELP (Please).

 

I've managed to do two different ways of getting Spotters to locate and transfer targets to a sniper:

 

1) Is the basic way was to create a sniper looking over large area, grouped with two static (disable move and shoot) spotters looking over zones for targets, created targets moving across spotters paths and bingo, the sniper picked them off even at 1200m range.

 

2) I tried then an alternate way but can only do this with 'named' variable enemies at moment.

 

I create 2 CSAT VR targets "toast1" "toast2"

 

I create two NATO spotters "ray" and "purchase" operating on their own, not grouped with the sniper this time. (Again i set spotters not to shoot)

 

I then created the sniper "clemfandango".

 

The script i modified / edited (amateur i know...give me a break!)
 

Quote

 

TAG_fnc_sniperfandango = {
    params ["_sniper",["_debug",true]];

    if (_debug) then {hint "This is Clem Fandango, can you hear me?"};

    sleep 5;

    while {alive _sniper} do {

        sleep 0.5;
        if (!alive _sniper) exitWith {};

        if ((ray knowsAbout toast1) > 0) then (_sniper reveal toast1);
        if ((ray knowsAbout toast2) > 0) then (_sniper reveal toast2);
        if ((purchase knowsAbout toast1) > 0) then (_sniper reveal toast1);
        if ((purchase knowsAbout toast2) > 0) then (_sniper reveal toast2);

        _target = assignedtarget _sniper;
        _dist = _sniper distance _target;
        _weap = getText (configfile >> "CfgWeapons" >> currentWeapon _sniper >> "displayName");
        _scope = getText (configfile >> "CfgWeapons" >> ((primaryWeaponItems _sniper) select 2) >> "displayName");

        _lineofsight = if (lineIntersects [eyepos _sniper,eyepos _target,_sniper,_target]) then {"No"} else {"Yes"};

        if (_target isequalto objnull) then {_dist = "N/A";_lineofsight = "No target"};

        if (_debug) then {hintSilent format ["Sniper %1. %2\n%3 - %4\n\nKnown enemies: %5\nDistance: %6m\nLine of Sight: %7.",[_sniper,"displayNameShort"] call BIS_fnc_rankParams,name _sniper,_weap,_scope,_target,_dist,_lineofsight]};

        };

    if (_debug) then {hint "END"};

};

_fandango = [this] spawn TAG_fnc_sniperfandango;

 

 

The script 'works' to a degree, it seems only 'one' target and 'one' spotter can work at the same time (Once Clem kills one target he does not kill the other, same as the spotter - if ray spots the target purchase wont spot a target?? But this is prob just down to my dodgy scripting

 

So PLEASE help me on two points so i can learn more and finish my sniper team enhancement for good:

 

1) Help me with an improved script based on the above or suggest what i should change so it works correctly.

 

2) MOST IMPORTANT - How can i make the spotters reveal targets with no variables (such as non-named units or spawned units etc)

 

Ramsen out.

Edited by ramsen
cant spell for beans....when will i ever learn...seriously when?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×