Jump to content
Sign in to follow this  
calo_mir

Getting longer range units to attack from set positions

Recommended Posts

I've made a vague attempt to create a scenario involving a marksman/sniper character going insane and attacking a village (Strelka). The problem I'm having is that I can't work out how to get the attacker to stay on the north east hill and take shots at civilian targets in the town - he always runs down the hill and attempts to engage from 50 meters or so. He's about 200 meters away on the hill - well in range for his chosen weapon (M24).

Is there some way I can get him to stay in one place to attack (but not lock him in place - I'd like him to move and find cover if fired on)?

The problem seems to stem from the fact that I need to tell him explicitly to attack as civilian units are "friendlies" - he won't just engage them at will.

Share this post


Link to post
Share on other sites

Not sure disableai works in arma2. Try making a high ranking enemy character with a probability of presence of 0%, and group him to the civilians. This will glitch them into being the side of the officer.

You could also try

sniper dostop true

sniper dotarget civ

sniper dofire civ

although I'm not sure if stopping him will prevent him from doing this

Share this post


Link to post
Share on other sites

I find the snipers are next to useless even with dotaget,dofire.

I place some Enemy units a good distance away and a sniper, He was looking at them but wouldn't open fire until I started shooting them with my standard riffle. He only shot one.

The next test was with civs, he wouldn't open fire but never moved closer either.

I kept bringing them closer and closer until he eventually shot them with his pistol.

How stupid is that.

Share this post


Link to post
Share on other sites

I kept bringing them closer and closer until he eventually shot them with his pistol.

How stupid is that.

Yeah, I've seen that exact behaviour.

He ran down the hill, into town and up the west road in order to shoot a target from about 20 meters with his pistol.

---------- Post added at 11:29 PM ---------- Previous post was at 11:27 PM ----------

Not sure disableai works in arma2. Try making a high ranking enemy character with a probability of presence of 0%, and group him to the civilians. This will glitch them into being the side of the officer.

Hehe, sounds like a nice hack. I'll add that to the list.

---------- Post added at 11:31 PM ---------- Previous post was at 11:29 PM ----------

sniper dostop true

sniper dotarget civ

sniper dofire civ

Maybe something similar to:

{ sniper dostop; sniper dotarget _x; sniper dofire _x; } forEach nearestObjects [sniper, ["civilian"], 200];

Share this post


Link to post
Share on other sites

The odd thing is if your I'm on the opposite side to the sniper he seems a lot keener to shoot me.

Share this post


Link to post
Share on other sites

Unless the AI has at least some kind of prior knowledge, he will not see you even if he looks directly at you if you're further than 175m. This seems to be true on all AI skill and difficulty levels (that is, for infantry VS infantry).

Share this post


Link to post
Share on other sites

Got it working. :)

First place the Functions module on your map.

Then place 6 random civilians named c1 - c6.

Finally place your sniper (named sn1) on your hill and put this as his init:

this setUnitPos "DOWN";this disableAI "MOVE";this addEventHandler ["firednear", "sn1 enableAI ""MOVE"""];null = [] execVM "snipe.sqf";

That'll make him stay prone and fire until someone fires within 60m of him, at which point he'll be able to move.

snipe.sqf is as follows:

_targets = [c1,c2,c3,c4,c5,c6]; // list of target objects
_count = count _targets;

while {_count > 0} do {

sleep 5;
_idx = _targets call BIS_fnc_randomIndex;
_target = _targets select _idx;

sn1 sidechat format["Next target is: %1",_target];

while {alive _target} do {
	sn1 doTarget _target;
	sn1 doFire _target;
};
_targets = [_targets, _idx] call BIS_fnc_removeIndex;
_count = count _targets; 
hint format["%1 left...",_count];
};

sn1 enableAI "MOVE;

He'll call out randomly selected targets that are left and snipe each one in turn. Once all 6 are dead he can move again.

Share this post


Link to post
Share on other sites

Thank you very much!

Out of interest, does the "firednear" handler mean somebody fired a weapon near him or does it mean a shot landed near him?

---------- Post added at 12:11 AM ---------- Previous post was at 12:08 AM ----------

Unless the AI has at least some kind of prior knowledge, he will not see you even if he looks directly at you if you're further than 175m. This seems to be true on all AI skill and difficulty levels (that is, for infantry VS infantry).

That's a shame. Is the limit hardcoded in the engine?

Share this post


Link to post
Share on other sites

Shot near him only, there are eventhandlers for hit and damaged, but not 'shot at'.

Share this post


Link to post
Share on other sites

kylania's solution looks great. The only thing I might add is the "reveal" command. "Revealing" enemy units to the sniper might give him enough information to start shooting on his own.

Share this post


Link to post
Share on other sites

Anything that helps is welcome but the problem needs fixing, I don't remember this problem in OFP.

The other thing is that as a player you can snipe at the enemy all day long and never don't often return fire.

Share this post


Link to post
Share on other sites

That's a shame. Is the limit hardcoded in the engine?

You can work around this by using one of the many ways to reveal the target to the shooter (ex: via a script that modifies the knowsabout value) which should work at any range.

Share this post


Link to post
Share on other sites

I have something that works with some pretty severe limitations. I'll dump it on here soon, time permitting.

Share this post


Link to post
Share on other sites
Got it working. :)

First place the Functions module on your map.

Then place 6 random civilians named c1 - c6.

Finally place your sniper (named sn1) on your hill and put this as his init:

this setUnitPos "DOWN";this disableAI "MOVE";this addEventHandler ["firednear", "sn1 enableAI ""MOVE"""];null = [] execVM "snipe.sqf";

That'll make him stay prone and fire until someone fires within 60m of him, at which point he'll be able to move.

snipe.sqf is as follows:

_targets = [c1,c2,c3,c4,c5,c6]; // list of target objects
_count = count _targets;

while {_count > 0} do {

sleep 5;
_idx = _targets call BIS_fnc_randomIndex;
_target = _targets select _idx;

sn1 sidechat format["Next target is: %1",_target];

while {alive _target} do {
	sn1 doTarget _target;
	sn1 doFire _target;
};
_targets = [_targets, _idx] call BIS_fnc_removeIndex;
_count = count _targets; 
hint format["%1 left...",_count];
};

sn1 enableAI "MOVE;

He'll call out randomly selected targets that are left and snipe each one in turn. Once all 6 are dead he can move again.

kylania,

I'm not sure what's going on but I can't get this to work. I have an enemy sniper(set as independent and set to BLUFOR enemy) on top of a building. I'm trying to get him to use this script against some ACE US Army Officers(c1-c6) but the enemy sniper never fires.

Could you make a quick example mission for this so I can look at it that way?

Share this post


Link to post
Share on other sites

Can someone explain the firednear stuff ?

I try to make a mission where the player is a sniper and should kill his target from great distance. Problem, if he misses the enemys dont react good. so if a shot lands near the they should run away.

Share this post


Link to post
Share on other sites

you guys are confused. FiredNear doesn't fire if someone is shot at/under fire, but:

Triggered when a weapon is fired somewhere near the unit or vehicle.

It is also triggered if the unit itself is firing.

Thus it doesn't make any sense to use this event handler for this sniper scenario. Unfortunately this ev doesn't work like that, resp. an event handler that would do so would be welcome very much (I faild in exactly the same way with a throw-smoke-if-fired-near-script... haha).

Share this post


Link to post
Share on other sites

Totally agree on that wish. The game seems to have it already, since it is able to determine when to give players blurred vision from nearby impacting rounds.

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  

×