Jump to content
Sign in to follow this  
Inkompetent

Mortar shoots... nothing?

Recommended Posts

Greetings.

My issue is that I have got a mortar battery in a mission of mine, that fires nothing. It fires, but the rounds ever impact. Doing removeAllWeapons on the mortar, and adding a ARTY_8Rnd_82mmHE_2B14 magazine didn't help either.

I've got an Insurgent mortar (mortar1) synced to an artillery logic (ins_mortar).

The fire mission is declared as fireMission = ["IMMEDIATE", "HE", 0, 1]; and _mortarTgtPos is the getPosASL coordinates of a unit.

All debug messages shows, the marker is correctly placed on target, the mortar does fire an HE round as indicated by ARTY_AMMO, but no round ever impacts, no error messages. What have I done wrong?

fireArty.sqf

#define __debug true

_mortarTgtPos = _this select 0;

if (__debug) then { player sideChat "Executing fireArty.sqf" };

if ([ins_mortar, _mortarTgtPos, fireMission select 1] call BIS_ARTY_F_PosInRange) then
{
[ins_mortar, _mortarTgtPos, fireMission] spawn BIS_ARTY_F_ExecuteTemplateMission;
hint "mortar1: Firing.";
_mrk = createMarker ["MortarTarget", _mortarTgtPos];
_mrk setMarkerColor "ColorBlack";
_mrk setMarkerShape "ICON";
_mrk setMarkerType "mil_objective";

waitUntil {ins_mortar getVariable "ARTY_ONMISSION"};
if (__debug) then { player sideChat "mortar1 is on a mission" };
if (__debug) then { player sideChat format["ammo used: %1", ins_mortar getVariable "ARTY_AMMO"] };
waitUntil {ins_mortar getVariable "ARTY_COMPLETE"};
if (__debug) then { player sideChat "mortar1 has finished fire mission" };
waitUntil {ins_mortar getVariable "ARTY_SPLASH"};
if (__debug) then { player sideChat "mortar1 about to splash!" };

sleep 10;

deleteMarker _mrk;
}
else
{
hint "mortar1: Target out of range";
};

if (__debug) then { player sideChat "Exiting fireArty.sqf" };

Edited by Inkompetent
Solved!

Share this post


Link to post
Share on other sites

Pasted your code into mortar.sqf. Placed Insurgent mortar, named to mortar1. Placed Artillery module, named to ins_mortar. Synced them. Placed man, named to dude. Made a radio trigger with:

fireMission = ["IMMEDIATE", "HE", 0, 1]; nul = [getposasl dude] execvm "mortar.sqf";

Worked nicely.

Share this post


Link to post
Share on other sites

Thanks for the test, shk. But it seems to be quite a strange problem.

Even if I hard-code the script-call in aimArty.sqf to:

nul = [getPosASL alpha3_2] execVM "s\fireArty.sqf";

...it fails to end with impacting grenades, although it does fire. Doesn't matter if I use execVM or spawn, or if I rename the script handle. Same result. Giving aimArty.sqf a unique handle doesn't help either.

However if I do the exact same execution from a radio trigger it works like a charm.

Share this post


Link to post
Share on other sites

Nopes. It is not the range and there's clear line of sight from the mortar to the target. If I execute the fireArty.sqf through a radio trigger it does exactly what it should. If I try to execute fireArty.sqf from aimArty.sqf in the exact same way as from the radio trigger, then I get no impacts.

Share this post


Link to post
Share on other sites

In the script version, how you are you running them? With radio triggers it will take a bit before you activate them, thus the module has time to initialize. With script, it might ran too early.

Edit: And no, I can't explain why it would fire, but not create the incoming rounds. Hmm, have you tried non-spawn vs spawn modes?

Share this post


Link to post
Share on other sites

The aimArty.sqf script is usually executed from the artillery logic's init line, which can't happen before the arty logic is initialized, so that part is safely done. Although I have tried to start it through radio triggers to see if it'd have any effect, but no change through doing that.

And if you mean to try to use spawn mode on the artillery shells I haven't tried that. Was hoping to get it to work otherwise, but I guess it could be good for bug-testing.

---------- Post added at 07:35 PM ---------- Previous post was at 07:30 PM ----------

Problem solved!

I had bad naming of the setDispersion function for the artillery, and since the old name no longer was initialized anywhere the dispersion was Nil.

Odd though that the artillery module didn't complain about that, but at least I found the problem. :D

So many hours and so many odd lines of code... Oh, well. At least I've learned to initialize variables with dynamic names ^^

For example with lines like the below, for those who are curious:

call compile format ["_fireMission%1=nil", _n];

call compile format ["_fireMission%1=%2", _n, "[_mortarTgtPos] execVM 's\fireArty.sqf'"];

Edited by Inkompetent

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  

×