Jump to content
Sign in to follow this  
hridaysabz

Help with Artillery Script

Recommended Posts

Hey guys! Back.

I'm writing my first script(apart from the ones I get all over the internet)

and it's something like this:

hazler doArtilleryFire [[getMarkerPos "_targets"], "_roundtype", _chances]
?!Alive hazler : exit

Variables:

_roundtype = [32Rnd_155mm_Mo_shells, 6Rnd_155mm_Mo_smoke, 2Rnd_155mm_Mo_guided, 2Rnd_155mm_Mo_LG, 6Rnd_155mm_Mo_mine, 2Rnd_155mm_Mo_Cluster, 6Rnd_155mm_Mo_AT_mine] call BIS_fnc_selectRandom;
_targets = [getmarkerpos "hit1", getmarkerpos "hit2", getmarkerpos "hit3", getmarkerpos "hit4", getmarkerpos "hit5", getmarkerpos "hit6"] call BIS_fnc_selectRandom;
_chances = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] call BIS_fnc_selectRandom;

Now what i'm looking for is a simple line that will repeat this script until my Varsuk(hazler) is not alive.

I've tried repeating it through a trigger but since units walk through it and are meant to pass to the other side, this doesn't work. Any ideas?

Edited by Hridaysabz

Share this post


Link to post
Share on other sites

hi, what you need is a while/do loop:

while {alive hazler} do {
   hazler doArtilleryFire [[getMarkerPos "_targets"], "_roundtype", _chances];

   sleep 60; // wait for 60 seconds
};

also, you can use the random function, especally for your chance variable:

_chances = random 10;

Edited by Zigomarvin

Share this post


Link to post
Share on other sites

Thanks a bunch, but I don't really know why the Varsuk doesn't fire, would you happen to know?

Share this post


Link to post
Share on other sites

did you checked the target position ? here's the doArtilleryFire description : Orders a unit to reload defined magazine commence fire burst on the given position (silently). Maybe there is no fire animation

Share this post


Link to post
Share on other sites

I have the markers set, but the Varsuk doesn't fire. I put this in another world and still no luck.

---------- Post added at 14:17 ---------- Previous post was at 12:29 ----------

Can somebody Help me with this problem? It's just basic code but it's frustrating from activating.

Share this post


Link to post
Share on other sites

the T100 Varsuk is a MBT, not mobil artillery, Opfor arty is 2S9 Sochor. Also, be sure the target position is far enough. for me it works.

i've noticed a mistake in the script i gave you, in your original script, your chance var is between 1 and 10 round.

// return between 0 and 10
_chances = random 10;

// return between 1 and 10
_chances = 1 + (random 9);

Share this post


Link to post
Share on other sites

I don't know, how whole script looks together (it is important to see that too), but from I can see:

1. Very first code looks wrong: looks like SQS syntax used, while SQF should be.

2. If _targets is random position from array: [getmarkerpos "hit1", getmarkerpos "hit2", getmarkerpos "hit3", getmarkerpos "hit4", getmarkerpos "hit5", getmarkerpos "hit6"], then instead of [getMarkerPos "_targets"] should be just _targets.

3. If _roundtype is random magazine name chosen from: [32Rnd_155mm_Mo_shells, 6Rnd_155mm_Mo_smoke, 2Rnd_155mm_Mo_guided, 2Rnd_155mm_Mo_LG, 6Rnd_155mm_Mo_mine, 2Rnd_155mm_Mo_Cluster, 6Rnd_155mm_Mo_AT_mine] then instead: "_roundtype" should be: _roundtype, but see p. 5.

4.

_chances = random 10; 

is not valid, as this must be non-negative integer (unless doArtilleryFire command handles fractional numbers), instead may be:

_chances = ceil (random 10); 

(integers from 1 to 10)

5. _roundtype array is wrong, each magazine name should be between "" (string).

Share this post


Link to post
Share on other sites

^ noticed what Ryd said so was re-writing it:

//null = [hazler] execVM "arty2.sqf";

_arty = _this select 0; 

_roundType = ["32Rnd_155mm_Mo_shells","2Rnd_155mm_Mo_guided","2Rnd_155mm_Mo_guided","6Rnd_155mm_Mo_mine","2Rnd_155mm_Mo_Cluster","6Rnd_155mm_Mo_smoke","2Rnd_155mm_Mo_LG","6Rnd_155mm_Mo_AT_mine"] call BIS_fnc_selectRandom;
_target = ["hit1","hit2","hit3","hit4","hit5","hit6"] call BIS_fnc_selectRandom;
_rnds = getNumber (configfile >> "CfgMagazines" >> _roundType >> "count");
_chances = ceil(random _rnds);

hint str _roundtype + str _target + str _chances;

while {alive _arty} do {
_tgtPos = getMarkerPos _target;
_arty commandArtilleryFire [_tgtPos, _roundtype, _chances];
_t = _arty getArtilleryETA [_tgtPos,_roundtype];
sleep _t;
_arty addMagazine [_roundtype, 1];
};  

Note - the vehicle has limited ammo eg only x4 "2Rnd_155mm_Mo_guided" - so will stop firing after 4 shots with that ammo type, so I added a reload. It will also pause to reload as the magazine only has 2 rounds. In effect you are asking it to fire more rounds than are in the magazine. So also got the magazine contents and used that for _chances.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites
the T100 Varsuk is a MBT, not mobil artillery, Opfor arty is 2S9 Sochor. Also, be sure the target position is far enough. for me it works.

i've noticed a mistake in the script i gave you, in your original script, your chance var is between 1 and 10 round.

// return between 0 and 10
_chances = random 10;

// return between 1 and 10
_chances = 1 + (random 9);

Damn, my bad. Sorry.

Share this post


Link to post
Share on other sites

I'm going to try this out when i get home, couple o' hours. Will let you guys know, thanks.

Share this post


Link to post
Share on other sites

---------- Post added at 01:46 ---------- Previous post was at 01:36 ----------

Seems to be working fine with Ryd and Mattari's code. Thank you, everyone.

Until I see you again!

P.S: I'll see you in 2 hours again when i'm completely stumped and need to come running back to the forums.

Edited by Hridaysabz
No idea.

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  

×