Jump to content
padi

Randomized virtual artillery fire

Recommended Posts

Hi,

 

while working on my campaign I came to one mission needing an artillery bombardment on a village with two locations in the village that shouldn´t be destroyed, one of those shouldn´t even be damaged.

And it should be randomized where the fire lands to make the mission replayable and make the whole work of reacting to different outcomes worth it...

 

Sadly I realized over the last week that I didn´t have the knowledge to get it work and also the things I have researched haven´t been fitting.

 

Could anyone help me with that?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

There's a handy function called BIS_fnc_fireSupportVirtual you can use to call the artillery bombardment. You can easily randomize any of the parameters inside.

 

If you want to really randomize the location where the artillery can land, you can use BIS_fnc_randomPos or BIS_fnc_findSafePos to get a target location. Alternatively, you can place several empty system markers on pre-defined locations where the artillery could fire. I'll give you an example script using each method below:

Example with BIS_fnc_randomPos

  1. Get the coordinates of the center of your village, or place an empty system marker (I will use an empty marker).
  2. Name the system marker something like TAG_artilleryCenter;
  3. Place two triggers (if you want them to be invisible), or two area markers covering the two locations you want to be safe from artillery (I will use triggers).
  4. Name each trigger or area marker something like TAG_safeZone_1 and TAG_safeZone_2.
  5. Run the following code whenever you want an artillery strike:
_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 5; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 10; // Set how many rounds will be fired
_TAG_artilleryDelay = [1,2]; // Set the minimum and maximum delay between rounds in seconds

_TAG_selectedPos = [[[getMarkerPos "TAG_artilleryCenter", _TAG_artilleryRadius]], ["water", TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos; // Get random position in a circle centered on TAG_artilleryCenter marker, within a predefined radius (100 meters in this example), excluding the two safe zones and water

[_TAG_selectedPos, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual; // Fire artillery with defined parameters

 

Example with BIS_fnc_findSafePos

  1. Get the coordinates of the center of your village, or place an empty system marker (I will use an empty marker).
  2. Name the system marker something like TAG_artilleryCenter;
  3. Place two triggers (if you want them to be invisible), or two area markers covering the two locations you want to be safe from artillery (I will use triggers).
  4. Name each trigger or area marker something like TAG_safeZone_1 and TAG_safeZone_2.
  5. Run the following code whenever you want an artillery strike:
_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 5; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 10; // Set how many rounds will be fired
_TAG_artilleryDelay = [1,2]; // Set the minimum and maximum delay between rounds in seconds

_TAG_selectedPos = [getMarkerPos "TAG_artilleryCenter", 0, _TAG_artilleryRadius, 0, 0, 0, 0, [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_findSafePos; // Get random position in a circle centered on TAG_artilleryCenter marker, within a predefined radius (100 meters in this example), excluding the two safe zones and water

_TAG_selectedPos pushBack 0;

[_TAG_selectedPos, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual; // Fire artillery with defined parameters


Example with pre-defined empty markers

  1. Place several empty system markers on locations you want to be possibly hit by artillery.
  2. Name the system markers something like TAG_artilleryTarget_1, TAG_artilleryTarget_2, TAG_artilleryTarget_3, and so on.
  3. Run the following code whenever you want an artillery strike:
_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 5; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 10; // Set how many rounds will be fired
_TAG_artilleryDelay = [1,2]; // Set the minimum and maximum delay between rounds in seconds

_TAG_selectedPos = getMarkerPos selectRandom ["TAG_artilleryTarget_1", "TAG_artilleryTarget_2", "TAG_artilleryTarget_3"]; // Select a random target marker and get its position. Add as many target markers as you have placed in the editor

[_TAG_selectedPos, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual; // Fire artillery with defined parameters

 

______________________________________

You can naturally randomize the artillery radii, spreads, rounds, and delays using the random command as well, or you can make them parameters and change them whenever you call the scripts.

Each code snippet should also be placed in a script file in your mission directory, called something like artilleryStrike.sqf and executed like so:

nul = [] execVM "artilleryStrike.sqf";

 

Hope this helps!

  • Like 5

Share this post


Link to post
Share on other sites

Thank you @alpha993,

I will try it tomorrow and give. you feedback how it works.

You are great👍🏻

  • Like 1

Share this post


Link to post
Share on other sites

This is nearly exactly what I needed, thank you again!

 

The only thing I need to improve is that the rounds should fall all over the village (excluding the safezones) and not only in one spot.

But I think that I could archieve this by playing with the radii of the artillery fire and calling it multiple times again or having multiple firing centres all over the village...

 

I will try that and report back.

Share this post


Link to post
Share on other sites

Hi @alpha993 and sorry that it took a littlebit longer, reallife got in the way🙈
 

I expanded it a littlebit and now it works really good for my demands.

 

This is the code for it:

_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 50; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artillerySpread2 = 15; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 20; // Set how many rounds will be fired
_TAG_artilleryDelay = 5; // Set the minimum and maximum delay between rounds in seconds

//1
_TAG_selectedPos1 = [[[getMarkerPos "TAG_artilleryCenter1", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos2 = [[[getMarkerPos "TAG_artilleryCenter1", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos3 = [[[getMarkerPos "TAG_artilleryCenter1", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos4 = [[[getMarkerPos "TAG_artilleryCenter1", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos5 = [[[getMarkerPos "TAG_artilleryCenter1", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos1, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos2, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos3, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos4, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos5, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;

//2
_TAG_selectedPos6 = [[[getMarkerPos "TAG_artilleryCenter2", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos7 = [[[getMarkerPos "TAG_artilleryCenter2", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos8 = [[[getMarkerPos "TAG_artilleryCenter2", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos9 = [[[getMarkerPos "TAG_artilleryCenter2", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos10 = [[[getMarkerPos "TAG_artilleryCenter2", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos6, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos7, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos8, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos9, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos10, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;

//3
_TAG_selectedPos11 = [[[getMarkerPos "TAG_artilleryCenter3", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos12 = [[[getMarkerPos "TAG_artilleryCenter3", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos13 = [[[getMarkerPos "TAG_artilleryCenter3", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos14 = [[[getMarkerPos "TAG_artilleryCenter3", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos15 = [[[getMarkerPos "TAG_artilleryCenter3", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos11, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos12, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos13, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos14, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos15, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;

//4
_TAG_selectedPos16 = [[[getMarkerPos "TAG_artilleryCenter4", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos17 = [[[getMarkerPos "TAG_artilleryCenter4", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos18 = [[[getMarkerPos "TAG_artilleryCenter4", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos19 = [[[getMarkerPos "TAG_artilleryCenter4", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos20 = [[[getMarkerPos "TAG_artilleryCenter4", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos16, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos17, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos18, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos19, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos20, "Sh_82mm_AMOS", _TAG_artillerySpread2, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;

//5
_TAG_selectedPos21 = [[[getMarkerPos "TAG_artilleryCenter5", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos22 = [[[getMarkerPos "TAG_artilleryCenter5", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos23 = [[[getMarkerPos "TAG_artilleryCenter5", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos24 = [[[getMarkerPos "TAG_artilleryCenter5", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos25 = [[[getMarkerPos "TAG_artilleryCenter5", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos21, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos22, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos23, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos24, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos25, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;

//6
_TAG_selectedPos26 = [[[getMarkerPos "TAG_artilleryCenter6", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos27 = [[[getMarkerPos "TAG_artilleryCenter6", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos28 = [[[getMarkerPos "TAG_artilleryCenter6", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos29 = [[[getMarkerPos "TAG_artilleryCenter6", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
_TAG_selectedPos30 = [[[getMarkerPos "TAG_artilleryCenter6", _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;

[_TAG_selectedPos26, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos27, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos28, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos29, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
sleep 0.5;
[_TAG_selectedPos30, "Sh_82mm_AMOS", _TAG_artillerySpread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;

I expanded it to 30 different locations in total within 6 different zones with 20 rounds each.

Also I implemented a second spread value for the zones near my safezone to protect them more and at the same time spread the impacts out at the other areas.

So it now is nearly guaranteed that the village will be hit hard, but the player and his commander (the safezones are for them) survive in every one of my 20 tests and I didn´t know which defense area gets hit and maybe even destroyed.

 

Do you want to have the finished mission which uses this script send to so you could play it?

 

Kind regards

 

Padi

  • Like 2

Share this post


Link to post
Share on other sites

Glad to hear it's working for you!

 

I'm always happy to play new missions, so send away! 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

it will take a few more days until I could send you the mission, I added a plot twist that needs to be completed and I also forgot that a german localization didn't cut it for you, so english localization is incoming.

Share this post


Link to post
Share on other sites

The mission is currently in translating, it should come in the next days.

If the translating of the other missions is finished by then you will get not only one but three missions😀

Another question:

Do you know how to save the destruction level of a town so in the next mission the town is exactly in the state it was in the last mission?

Share this post


Link to post
Share on other sites
On 3/1/2022 at 3:43 AM, padi said:

I also forgot that a german localization didn't cut it for you, so english localization is incoming.

 

I'm actually German so I don't mind playing it in German lol.

 

On 3/10/2022 at 7:20 AM, padi said:

Do you know how to save the destruction level of a town so in the next mission the town is exactly in the state it was in the last mission?

 

I'm really busy with law school atm, so I can't give you a concrete example, but I would suggest something similar to the following process:

  1. In your first mission, use the nearObjects command to get an array of the town's buildings.
  2. Get the damage value for each item in the array.
  3. Make a nested array with each building and its respective damage value so it looks something like [ [House_1, 0.4], [House_2, 0.7], [House_3, 1] ].
  4. Store the nested array into your profile namespace using profileNamespace setVariable ["myTownState", TAG_nestedArray]; and then saveProfileNamespace. (there is also the saveVar command if your missions are part of a campaign file).
  5. In your next mission, load your nested array using profileNamespace getVariable "myTownState";
  6. Then use a forEach loop to run through each element of the array, and use setDamage on each house with its corresponding damage value at mission start.

Hope this helps!

 

Share this post


Link to post
Share on other sites

You can condense that code quite a lot, seeing as it's all the same except marker and spread...

Spoiler

_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 50; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artillerySpread2 = 15; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 20; // Set how many rounds will be fired
_TAG_artilleryDelay = 5; // Set the minimum and maximum delay between rounds in seconds

{
	_x params[ "_marker", "_spread" ];
	
	for "_i" from 1 to 5 do {
		_TAG_selectedPos = [[[getMarkerPos _marker, _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
		[_TAG_selectedPos, "Sh_82mm_AMOS", _spread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
		sleep 0.5;
	};
	
}forEach [
	[ "TAG_artilleryCenter1", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter2", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter3", _TAG_artillerySpread2 ], 
	[ "TAG_artilleryCenter4", _TAG_artillerySpread2 ], 
	[ "TAG_artilleryCenter5", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter6", _TAG_artillerySpread ]
];

 

 

  • Like 2

Share this post


Link to post
Share on other sites
10 hours ago, alpha993 said:

 

I'm actually German so I don't mind playing it in German lol.

 

Okay, then I´m sending you the three missions now👍

Share this post


Link to post
Share on other sites
11 hours ago, alpha993 said:

I'm really busy with law school atm, so I can't give you a concrete example, but I would suggest something similar to the following process:

  1. In your first mission, use the nearObjects command to get an array of the town's buildings.
  2. Get the damage value for each item in the array.
  3. Make a nested array with each building and its respective damage value so it looks something like [ [House_1, 0.4], [House_2, 0.7], [House_3, 1] ].
  4. Store the nested array into your profile namespace using profileNamespace setVariable ["myTownState", TAG_nestedArray]; and then saveProfileNamespace. (there is also the saveVar command if your missions are part of a campaign file).
  5. In your next mission, load your nested array using profileNamespace getVariable "myTownState";
  6. Then use a forEach loop to run through each element of the array, and use setDamage on each house with its corresponding damage value at mission start.

Hope this helps!

Thank you, I will try it out.

 

I wish you much success for the law school.

Share this post


Link to post
Share on other sites
5 hours ago, Larrow said:

You can condense that code quite a lot, seeing as it's all the same except marker and spread...

  Reveal hidden contents


_TAG_artilleryRadius = 100; // Set village radius in meters
_TAG_artillerySpread = 50; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artillerySpread2 = 15; // Set artillery spread radius (the accuracy of the rounds, in essence)
_TAG_artilleryRounds = 20; // Set how many rounds will be fired
_TAG_artilleryDelay = 5; // Set the minimum and maximum delay between rounds in seconds

{
	_x params[ "_marker", "_spread" ];
	
	for "_i" from 1 to 5 do {
		_TAG_selectedPos = [[[getMarkerPos _marker, _TAG_artilleryRadius]], [TAG_safeZone_1, TAG_safeZone_2]] call BIS_fnc_randomPos;
		[_TAG_selectedPos, "Sh_82mm_AMOS", _spread, _TAG_artilleryRounds, _TAG_artilleryDelay] spawn BIS_fnc_fireSupportVirtual;
		sleep 0.5;
	};
	
}forEach [
	[ "TAG_artilleryCenter1", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter2", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter3", _TAG_artillerySpread2 ], 
	[ "TAG_artilleryCenter4", _TAG_artillerySpread2 ], 
	[ "TAG_artilleryCenter5", _TAG_artillerySpread ], 
	[ "TAG_artilleryCenter6", _TAG_artillerySpread ]
];

 

 

Thank you very much for this shortening of the code, I didn´t knew of that possibility.

Share this post


Link to post
Share on other sites

Hey @padi,

Would you mind sending me the mission? I'd love to give this a try for some stuff I'm working on. I'm an English speaker, but I don't care too much about the language peice, as long as I can understand how it's built. Thanks!

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

×