Jump to content
Sign in to follow this  
yoannis1995

IA mortars random target

Recommended Posts

Hi,

I'd like to make IA mortars firing on random positions in a defined area (like in a marker), but I've got no clue how to do that ?! I know there are scripts to simulate artillery firing in a zone but I'd like real IAs firing and not "fake" artillery...

Thanks in advance ! :)

Share this post


Link to post
Share on other sites

look at Rarek's Invade and Annex 2 code. in the file /sm/priorityTargets.sqf around line ~180-250

he is gettting a random playableUnits not in a vehicle as target and radius of 80 meters random, going down to be more precise every shot, simulating error and trial from the mortar team.

Share this post


Link to post
Share on other sites

Ok, thanks ! I'll try that :)

---------- Post added at 01:49 AM ---------- Previous post was at 01:21 AM ----------

I've tried a quick script and it seems to be working fine :)

Here's the script

//Variables
_unit = _this select 0;
_target = _this select 1;
while {alive gunner _unit} do {
_rounds=round(random 2);
_time=round(random 15);
_randomPos = [[[getPos _target, 100]]] call BIS_fnc_randomPos;
_unit commandArtilleryFire [_randomPos, "8Rnd_82mm_Mo_shells", _rounds];
sleep _time;
};
if (!alive gunner _unit) exitWith {};

Edited by yoannis1995

Share this post


Link to post
Share on other sites

that look like the most straight forward way to do it.

in Rarek script he was turning the mortar vehicle toward the (random) position of target first. I don't know if it is a must, or just esthetic. (I can tell it makes the gunner moving and a little less easy to shoot though, cause in his mission, you have to shoot them)

happy to see that you have something to build on. :-)

regards,

Holo.

Share this post


Link to post
Share on other sites
that look like the most straight forward way to do it.

in Rarek script he was turning the mortar vehicle toward the (random) position of target first. I don't know if it is a must, or just esthetic. (I can tell it makes the gunner moving and a little less easy to shoot though, cause in his mission, you have to shoot them)

happy to see that you have something to build on. :-)

regards,

Holo.

Yeah in my mission too you're supposed to shoot at them but anyway when they fire on the position they will turn toward the position automaticly so I don't see how it changes anything ?!

---------- Post added at 12:19 PM ---------- Previous post was at 11:44 AM ----------

I've done another script where one IA is not assign as gunner of a mortar yet so I've go to move him in at some point of the mission so I use that:

if (alive mor3) then {
mor3 assignAsGunner mortar3;
[mor3] orderGetIn true;
} else {
if (alive mor4) then {
mor4 assignAsGunner mortar3;
[mor4] orderGetIn true;};
};

where mortar3 is the empty mortar and mor3 and mor4 are the 2 possible gunners.

Then I'm calling that script:

_unit = _this select 0;
_target = _this select 1;
if (alive mor3) then {
waitUntil {gunner _unit == mor3};
} else {
if (alive mor4) then {
waitUntil {gunner _unit == mor4};};};
while {alive gunner _unit} do {
_rounds=round(random 2);
_time=(round(random 15))+5;
_randomPos = [[[getPos _target, 200]]] call BIS_fnc_randomPos;
_unit commandArtilleryFire [_randomPos, "8Rnd_82mm_Mo_shells", _rounds];
sleep _time;
if (!alive gunner _unit) exitWith {};

So the IA gets in the mortar but doesn't fire any rounds... And I can't find the problem...

Any ideas ?!

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  

×