Jump to content
Sign in to follow this  
SturerEmil84

A really simple "mortar- fire" script

Recommended Posts

Hey guys,

 

after a load of tries I finally decided to ask for some help... :dummy:

I'd really love to have a "simple - to- use" mortar fire script.

 

Nothing too fancy, just spawn a mortar- bombardement (81mm at best xD) with "x" shells around a "y" radius on target "z".

This is what I tried to use:

/*////////////////////////////////////

Script by J.Shock

Open to editing and public use!!!

I do ask that this header remain with
the script.

*////////////////////////////////////


/*
To use the Simple Mortar Script (SMS):

1. Put down a marker and name it.

2. Alter the following call line to suit your needs, default values defined below:
	
null = ["A", 100, false, 1, 15, 5, 300] execVM "scripts\arty.sqf";
			
			1 - Your marker's name (default is empty string, "")
			2 - Radius around marker for bombardment (default is 100m)
			3 - Use smoke rounds instead of HE (default false)
			4 - Number of bombardments (default 1)
			5 - Number of rounds (default 10)
			6 - Time before bombardment starts after script call (default 5 seconds)
			7 - If more than 1 bombardment, as defined by argument #4
				time between each bombardment (default 300 seconds, 5 minutes)

3. Enjoy the Show!
*/

_marker = [_this, 0, "", [""]] call BIS_fnc_param;
_radius = [_this, 1, 100, [0]] call BIS_fnc_param;
_useSmk = [_this, 2, false, [true]] call BIS_fnc_param;
_iter = [_this, 3, 1, [0]] call BIS_fnc_param;
_numRounds = [_this, 4, 10, [0]] call BIS_fnc_param;
_startTime = [_this, 5, 5, [0]] call BIS_fnc_param;
_timeBetween = [_this, 6, 30, [0]] call BIS_fnc_param;


if (isServer) then {

if (_startTime > 0) then {
sleep _startTime;
};

	for "_i" from 0 to _iter step 1 do

	{
		if (_useSmk) then {
			for "_s" from 0 to (_numRounds) step 1 do
			{
				_pos = [[[(getMarkerPos _marker), _radius]], "ground", ["water", "out"], {}] call BIS_fnc_randomPos;
				_smkRnd = createVehicle ["SmokeShellArty", _pos, [], 0, "NONE"];
				sleep 5;
			};
			
		} else {
		
			for "_m" from 0 to (_numRounds) step 1 do
			{
				_pos = [[[(getMarkerPos _marker), _radius]], "ground", ["water", "out"], {}] call BIS_fnc_randomPos;
				_mrtRnd = createVehicle ["M_Mo_82mm_AT_LG", _pos, [], 0, "NONE"];
				sleep 5;
			};
		};
		
	if (_iter > 1) then {	
	sleep _timeBetween;
	};
	
	};

};

much thanks to J.Shock...

 

Now to my problem, when using this script, I get an error in line 65, saying that my _pos variabel is undefined.

I made a marker called A and used following call line in a trigger thats working...

null = ["A", 100, false, 1, 15, 5, 300] execVM "scripts\arty.sqf";

 

I'm pretty sure my mistake is hidden in that line:

_mrtRnd = createVehicle ["M_Mo_82mm_AT_LG", _pos, [], 0, "NONE"];    

 

Please help!!!

... and thanks in advance.

 

Share this post


Link to post
Share on other sites

Think the problem is with the parameters sent to BIS_fnc_randomPos. It should only have up to 3 (optional) parameters but the script you linked has 4.

 

Could you try changing the following lines in the script from:

_pos = [[[(getMarkerPos _marker), _radius]], "ground", ["water", "out"], {}] call BIS_fnc_randomPos;

To:

_pos = [[[(getMarkerPos _marker), _radius]]] call BIS_fnc_randomPos;

Reason for omission of:

  • "ground": biki says you can either have a position or tags but not both.
  •  ["water, "out"]: done by default.
  • {}: done by default
  • Like 2

Share this post


Link to post
Share on other sites
_pos = [[[(getMarkerPos _marker), _radius]], "ground", ["water", "out"], {}] call BIS_fnc_randomPos;


This causes onscreen function error for me "[BIS_fnc_randomPos] Type string, expected array on index 1". Didn't get the same error?

Share this post


Link to post
Share on other sites

 

13 minutes ago, SturerEmil84 said:

I did get this error... maybe read the thread first???


Why so rude? The error you indicated is not the same:
 

17 hours ago, SturerEmil84 said:

saying that my _pos variabel is undefined.

Share this post


Link to post
Share on other sites

Sorry man ... I was still a bit sleepy and thought you talked about the same error we discussed here, because the line you quoted in your post was the old, wrong one...

 

Change it to:

_pos = [[[(getMarkerPos _marker), _radius]]] call BIS_fnc_randomPos;

Then it definetly bombards your marker :don16:

Share this post


Link to post
Share on other sites

@SturerEmil84

Cool!

 

@killzone_kid 

Just to further clarify, OP runs 2 lines of code back to back so that's probably why their post reports the error as _pos variable is undefined. The root cause of the error as you've correctly observed is the same one we've fixed: number and type of parameters sent to BIS_fnc_randomPos is incorrect.

Spoiler

Old, broken code


_pos = [[[(getMarkerPos _marker), _radius]], "ground", ["water", "out"], {}] call BIS_fnc_randomPos;
_mrtRnd = createVehicle ["M_Mo_82mm_AT_LG", _pos, [], 0, "NONE"];

 

 

Share this post


Link to post
Share on other sites

Index error is the function error, it is scripted message at the bottom of the screen. Undefined var is script error, black and white message middle of the screen. The is no way one can cancel another.

Share this post


Link to post
Share on other sites
9 minutes ago, killzone_kid said:

Index error is the function error, it is scripted message at the bottom of the screen. Undefined var is script error, black and white message middle of the screen. The is no way one can cancel another.

Good catch, I did not realize function errors show up differently. I'm sure OP got both the function and script error but just mentioned the script error.

Share this post


Link to post
Share on other sites

I must admit I havn't realized the function error...

Can't run game at the moment to check.

 

Are you running your game with CBA installed killzone?

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  

×