Jump to content
gc8

Artillery min & max range

Recommended Posts

Hi

Does anybody know how to get minimum and maximum range for artillery? i have been going through the configs but didnt find any variables regarding ranges.

 

I know the inRangeOfArtillery command but it only returns true/false and not the actual ranges

 

thanks

 

Share this post


Link to post
Share on other sites

Can use the command and placing objects to determine.

(sorry, just don't know  ) ).

Share this post


Link to post
Share on other sites

Can use the command and placing objects to determine.

(sorry, just don't know  ) ).

 

maybe but that would take time to do it for all artillery (and all ammo types) in game so I'm gonna leave that as last resort.

Share this post


Link to post
Share on other sites

Use physics formulas.

ArmA is considered a 'realistic' game for a reason and so IRL physics formulas will work.

Share this post


Link to post
Share on other sites

Use physics formulas.

ArmA is considered a 'realistic' game for a reason and so IRL physics formulas will work.

 

i don't have the math skills to do that. I think counting that is pretty difficult math because you have take in consideration even the cannons angle etc. :)

 

man if BIS would just give us min and max script commands.....

Share this post


Link to post
Share on other sites

You could just find the approximate limits by gradually decreasing/increasing the position you input to inRangeOfArtillery and check when it changes from false to true.

 

And there isn't even any fixed ranges, since they depend on the positions of the shooter and the target.

Share this post


Link to post
Share on other sites

You could just find the approximate limits by gradually decreasing/increasing the position you input to inRangeOfArtillery and check when it changes from false to true.

 

And there isn't even any fixed ranges, since they depend on the positions of the shooter and the target.

 

Good point. the min&max probably depends also on the height of the artillery and target. so finding out those ranges with inRangeOfArtillery probably is useless.

Share this post


Link to post
Share on other sites

Good point. the min&max probably depends also on the height of the artillery and target. so finding out those ranges with inRangeOfArtillery probably is useless.

Yeah, I meant the altitude difference. But I think that is what the inRangeOfArtillery takes into consideration. I guess.

Share this post


Link to post
Share on other sites

 

You can just place artillery, take control and watch in " ballistic calculator " )

Share this post


Link to post
Share on other sites

I made a script that calculates the ballpark min and max ranges for any given artillery piece. I know this is over 4 years late but if anyone will benefit from this then it's worth it.

 

By changing the values of the 3 local variables, you can calculate the min and max ranges for your artillery piece.

them being:

<Variable name>  Variable name of the unit,

<Integer>  Array index of the ammunition you want to use for the ranges, found easily from the unit's ammunition array with the command 'magazines <your unit>'

<Integer>  How much can it throw off by. (i.e real max range is 2125m, with and increment of 50m, the script will give you a max range of 2100m, or with it being the minimum range, it will give you a minimum range of 2150m)

 

I advice you to keep the _Increment at under 100m. At 200m I had it calculate the absolute maximum range for an artillery piece and it probably can't even shoot that far with doArtilleryFire. Needs more testing tho.

The script informs the ranges in the SystemChat, but this can easily be changed to any other form.

 

Script:

//Manually change these values for your usage

_Vehicle = 'Variable name of the artillery unit';  

_MagazineSlot = 'Magazines array index for the ammunition (you can find it by counting down from the units magazines, i.e (hint str magazines <your unit> ) and count from 0 to what you want)';

_Increment = 'Increments at which the script will check if the range is at min or max (basically the accuracy of the values you get for the ranges with how much it can throw off)';

 

//Code:

_MaxRange = -1;

_MinRange = -1;

_Position = getPosASL _Vehicle;

while{_MaxRange < 0}

do{

    _Test = _Position inRangeOfArtillery[[_Vehicle], ((magazines _Vehicle) select _MagazineSlot)];

    if(_Test && _MinRange < 0) then {_MinRange = _Position distance _Vehicle;};

    if(!_Test && _MinRange >= 0) then {_MaxRange = _Position distance _Vehicle;};

    _Position = [

        (_Position select 0) + _Increment,

        (_Position select 1),

        (_Position select 2)

    ];

};

_MaxRange = _MaxRange - (_MaxRange%_Increment) - _Increment;

_MinRange = _MinRange - (_MinRange%_Increment) + _Increment;

systemChat format["max range = %1", _MaxRange];

systemChat format["min range = %1", _MinRange];

  • Like 1

Share this post


Link to post
Share on other sites

try it wih agent unit onboard - not working - I made the same logic for my script and discover this bug due to optimise cpu usage on mission (command for test range working only with normal units (not agents) as crew/gunner), here is my version of this:

 

params ["_gun"];

    private _MINrange = 50;
    private _MAXrange = 2000;
    private _mains = [];
    private _mag = "";

//------------------------------------------------------------------------------
{
    private _wrange = _MINrange;
    private _rangeMIN = _MINrange;
    private _rangeMAX = _MAXrange;
    private _inrangex = false;
    private _index = _foreachindex;
    private _countammo = ((magazinesAmmo _gun)#_index)#1;
    if ((_countammo > 0) && ((_x #0) in (getArtilleryAmmo [_gun]))) then {
//search for minimal range
        while {!(_inrangex)} do {
            _dumytarget = _GUN getpos [_wrange,0];
            if !(_dumytarget inRangeOfArtillery [[_gun], (_x #0)]) then {
                _wrange = _wrange + 100;
            }else {
                _inrangex = true;_rangeMIN = _wrange;
            };
        };
//search for maximal range
        while {_inrangex} do {
            _dumytarget = _GUN getpos [_wrange,0];
            if (_dumytarget inRangeOfArtillery [[_gun], (_x #0)]) then {
                _wrange = _wrange + 100;
            }else {
                _inrangex = false;_rangeMAX = _wrange;
            };
        };
        _mains pushBackunique [(_x #0),[_rangeMIN,_rangeMAX]];
        //systemchat format ["%1",[(_x #0),[_rangeMIN,_rangeMAX]]];sleep 3;
    };
}foreach (magazinesAmmo _gun);

 

if (_mains isnotequalto []) then {
_choose = [_mains, [], {(_x#1)#1}, "ASCEND"] call BIS_fnc_sortBy;
_mag = tolower ((_choose#0)#0);
_MINrange = ((_choose#0)#1)#0;
_MAXrange = ((_choose#0)#1)#1;
};
 

Share this post


Link to post
Share on other sites

I ended up placing empty arty on ground, and activating computer. It has min max. Still havnt found the script thats telling the computer what the min max is, but it does have min max in computer screen.

Share this post


Link to post
Share on other sites

this works always beacouse use dummy AI to calculate ranges first line is for use this script copied and saved to file arty.sqf: just send coordinates by for example:       gunname setvariable ["target",[1000,2345,0],true];

 

//[gunname] execvm "arty.sqf";

params ["_gun"];

waituntil {sleep 5; !(alive _gun) || (getArtilleryAmmo [_gun] isnotequalto [])};
if !(alive _gun) exitwith {};

private _dummyUnit = objnull;
private _gunner = (gunner _gun);
if (isAgent teamMember _gunner) then {moveout _gunner};
if (isnull (gunner _gun)) then {
    _grp = createGroup CIVILIAN;
    _dummyUnit = _grp createUnit ["C_UAV_AI_F", getpos _gun, [], 0, "CAN_COLLIDE"];
    _dummyUnit moveingunner _gun;
};

    private _targets = [];
    private _targetsarray = [];
    private _time = time;
    private _mytarget = objnull;
    private _MINrange = 0;
    private _MAXrange = 100000;
    private _mains = [];
    private _mag = "";

//------------------------------------------------------------------------------
{
    private _rangeMIN = _MINrange;
    private _inrangex = false;
//search for minimal range
        while {!(_inrangex) && (_rangeMIN < 5000) && (alive _gun)} do {
            _dumytarget = _GUN getpos [_rangeMIN,random 360];
            if !(_dumytarget inRangeOfArtillery [[_gun], _x]) then {
                _rangeMIN = _rangeMIN + 100;
            }else {_inrangex = true};
            //systemchat format ["range %1, target %2",_wrange,_dumytarget];sleep 0.5;
        };

//search for maximal range
            _inrangex = false;
    private _rangeMAX = _MAXrange;
        while {!(_inrangex) && (_rangeMAX > _rangeMIN) && (alive _gun)} do {
            _dumytarget = _GUN getpos [_rangeMAX,random 360];
            if !(_dumytarget inRangeOfArtillery [[_gun], _x]) then {
                _rangeMAX = _rangeMAX - 100;
            }else {_inrangex = true};
        };
        _mains pushBackunique [_x,[_rangeMIN,_rangeMAX]];
        //systemchat format ["%1",[(_x #0),[_rangeMIN,_rangeMAX]]];sleep 1;
}foreach (getArtilleryAmmo [_gun]);

//hint format ["%1",_mains];

if (_mains isnotequalto []) then {
_choose = [_mains, [], {(_x#1)#2}, "DESCEND"] call BIS_fnc_sortBy;
_mag = tolower ((_choose#0)#0);
_MINrange = ((_choose#0)#1)#0;
_MAXrange = ((_choose#0)#1)#1;
};

//systemchat format ["%1",[_mag,[_MINrange,_MAXrange]]];

if !(isnull _dummyUnit) then {deletevehicle _dummyUnit};
_gunner moveingunner _gun;


sleep random 5;
//systemchat format["gun started %1, alive %2",_gun,(alive _gun)];
//-------------------------------------------------------------------------------

while {(alive _gun)} do {

    //systemchat format["loop run on %1",_gun];

    waituntil {sleep 10;(canfire _gun) && (alive (gunner _gun)) && ({(gunner _gun) in (units group _x)} count allplayers == 0)};

        //systemchat format ["vehicle %1",vehicle _gun];

        //if ((gunner _gun) checkAIFeature "PATH") then {{(gunner _gun) disableAI _x}foreach ["PATH","AUTOTARGET","AIMINGERROR","AUTOCOMBAT","MINEDETECTION","SUPPRESSION"]};

        if (((side _gun) isequalto WEST) && ({(_x#0) isequalto _gun} count artileryunitsW == 0)) then {artileryunitsW pushbackunique [_gun,_MINrange,_MAXrange]};
        if (((side _gun) isequalto EAST) && ({(_x#0) isequalto _gun} count artileryunitsE == 0)) then {artileryunitsE pushbackunique [_gun,_MINrange,_MAXrange]};
        if (((side _gun) isequalto INDEPENDENT) && ({(_x#0) isequalto _gun} count artileryunitsI == 0)) then {artileryunitsI pushbackunique [_gun,_MINrange,_MAXrange]};

/*    }else {
        if (((side _gun) isnotequalto WEST) && ({(_x#0) isequalto _gun} count artileryunitsW > 0)) then {artileryunitsW = artileryunitsW - [_gun,_MINrange,_MAXrange]};
        if (((side _gun) isnotequalto EAST) && ({(_x#0) isequalto _gun} count artileryunitsE > 0)) then {artileryunitsE = artileryunitsE - [_gun,_MINrange,_MAXrange]};
        if (((side _gun) isnotequalto INDEPENDENT) && ({(_x#0) isequalto _gun} count artileryunitsI > 0)) then {artileryunitsI = artileryunitsI - [_gun,_MINrange,_MAXrange]};
    };*/

    if (((_gun getvariable ["target",[]]) isnotequalto []) && (unitReady _gun)) then {

            private _targetposition = (_gun getvariable ["target",[]]);
            _inrange = false;
            _mains = [];
                    {
                        if (_targetposition inRangeOfArtillery [[_gun], (_x #0)]) exitwith {_mains pushBackunique (_x #0);_inrange = true};
                    }foreach (magazinesAmmo _gun);

            if ((_inrange) && (canfire _gun) && (magazinesAmmo _gun findIf {((_x#1) > 0) && ((_x#0) in _mains)} != -1)) then {
                                _index = magazinesAmmo _gun findIf {((_x#1) > 0) && ((_x#0) in _mains)};
                                _main = ((magazinesAmmo _gun) # _index) #0;
                                _count = ((magazinesAmmo _gun) # _index) #1;

                                _weapon = (weapons _gun)#0;
                                    {
                                        //systemchat format ["mag %1, compare %2, weapon %3",_mag, (tolower (_x#0)),(_gun weaponsTurret (_x#1))#0];sleep 2;
                                        if (_mag isequalto (tolower (_x#0))) exitwith {_weapon = (_gun weaponsTurret (_x#1))#0};
                                    } foreach (magazinesAllTurrets _gun);
                                    _reloadtime = getnumber(configfile >> "CfgWeapons" >> _weapon >> "reloadTime");

                                //systemchat format ["gun %1 fire %2 at pos %3",_gun,_main,_targetposition];
                                _count = (selectrandom [1,2,3]);
                                dostop _gun;
                                _gun commandArtilleryFire [_targetposition, _main, _count];//cursortarget commandArtilleryFire [getpos player, "rhs_mag_3of56_10", 2]
                                _magazynki = count magazinesAmmo _gun;
                                sleep ((_count*_reloadtime)+_reloadtime);
                                _gun setvariable ["target",[],true];
                                _gun domove (getpos _gun);
                                //hint format ["magazynek %1 zuzyty",_main];
                                if (count (magazinesAmmo _gun) < 1) then {systemchat "ammo out"};
            };
    };

};

systemchat format["manage scrpt %1 ended, alive %2",_gun,(alive _gun)];

  • Like 1

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

×