VN_ms_fnc_waypoint_doArtilleryFire

From Savage Game Design Wiki
Revision as of 21:14, 20 January 2021 by Lou Montana (talk | contribs) (Text replacement - "]]; |p1n=" to "]] |p1n=")
Jump to navigation Jump to search
← back to Functions Introduced in S.O.G. Prairie Fire v1.00
by Wyqer, veteran29
Argument(s): n/a
Effect(s): unknown

Description

/*
    Author: Wyqer, veteran29
    Date: 2019-10-23
    Public: Yes

    Description:
        Tells the unit to do cone shaped artillery barrage.

    Parameter(s):
        _vehicle
        _pos
        _rounds
        _magazine
        _precision

    Returns:
        Artillery fired [BOOL]
*/

// more steps equals closer impact points
#define OFFSET_STEPS    4

if (!canSuspend) exitWith {
    _this spawn (missionNamespace getVariable _fnc_scriptName);
};

params [
    "_vehicle",
    "_pos",
    ["_rounds", 5 + random 3],
    ["_magazine", ""],
    ["_precision", 55]
];

// determine used ammunition
private _vehicleArtilleryAmmo = getArtilleryAmmo [_vehicle];

if (_magazine == "" && count _vehicleArtilleryAmmo > 0) then {
    _magazine = _vehicleArtilleryAmmo select 0;
};

if (!(_pos inRangeOfArtillery [[_vehicle], _magazine])) exitWith {
    #ifdef VN_DEBUG
        systemChat format ["[VN_Artillery] %1 can not fire.", _vehicle];
    #endif
    false
};

#ifdef VN_DEBUG
    // systemChat format ["[VN_Artillery] Veh:%1, Rnds:%3, Mag:%4, Trgt:%2", _vehicle, _pos, _rounds, _magazine];

    private _m = format ["vn_artillery_target%1", _vehicle];
    deleteMarker _m; createMarker [_m, _pos];
    _m setMarkerType "mil_dot";
    _m setMarkerText "target";
    _m setMarkerColor "ColorGREEN";
#endif

// get direction to target
private _dirTo = _vehicle getDir _pos;
private _posOffset = 0;
// offset initial positon closer to shooter
_pos = _pos getPos [-1 * _precision, _dirTo];

for "_i" from 1 to _rounds do {

    // offseting position like this and shooting single should result in cone like shape
    private _target = _pos getPos [_posOffset + random _precision, _dirTo + (45 - random 90)];
    // increase offset
(Placeholder description extracted from the function header by LM_exportFunctionsToWiki.sqf)

Syntax

Syntax
[] call vn_ms_fnc_waypoint_doArtilleryFire
Return value
Nothing

Examples

Example 1
-