2015-05-10 16:21:18 +00:00
|
|
|
/*
|
|
|
|
* Author: Bohemia Interactive
|
|
|
|
* Module function for spawning projectiles
|
|
|
|
* Used by Curator artillery modules etc
|
2015-05-11 15:02:24 +00:00
|
|
|
* Edited to remove radio warning and add ballistics support
|
2015-05-10 16:21:18 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-05-18 11:56:31 +00:00
|
|
|
* 0: The module logic <LOGIC>
|
|
|
|
* 1: units <ARRAY>
|
|
|
|
* 2: activated <BOOL>
|
2015-05-10 16:21:18 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2016-11-15 12:07:48 +00:00
|
|
|
* None
|
2015-05-10 16:21:18 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [LOGIC, [bob, kevin], true] call ace_zeus_fnc_bi_moduleProjectile
|
|
|
|
*
|
2015-05-10 16:21:18 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-05-11 16:08:25 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-12-10 18:29:38 +00:00
|
|
|
_logic = _this select 0;
|
|
|
|
_units = _this select 1;
|
|
|
|
_activated = _this select 2;
|
2015-05-10 16:17:17 +00:00
|
|
|
|
|
|
|
if ({local _x} count (objectcurators _logic) > 0) then {
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Reveal the circle to curators
|
|
|
|
_logic hideobject false;
|
|
|
|
_logic setpos position _logic;
|
2015-05-10 16:17:17 +00:00
|
|
|
};
|
2017-12-10 18:29:38 +00:00
|
|
|
if !(isserver) exitwith {};
|
2015-05-10 16:17:17 +00:00
|
|
|
|
|
|
|
if (_activated) then {
|
2017-12-10 18:29:38 +00:00
|
|
|
_ammo = _logic getvariable ["type",gettext (configfile >> "cfgvehicles" >> typeof _logic >> "ammo")];
|
2015-05-10 16:21:18 +00:00
|
|
|
if (_ammo != "") then {
|
2017-12-10 18:29:38 +00:00
|
|
|
_cfgAmmo = configfile >> "cfgammo" >> _ammo;
|
|
|
|
//if !(isclass _cfgAmmo) exitwith {["CfgAmmo class '%1' not found.",_ammo] call bis_fnc_error;};
|
|
|
|
// It seems BI broke this part...
|
|
|
|
// _dirVar = _fnc_scriptname + typeof _logic;
|
|
|
|
// _logic setdir (missionnamespace getvariable [_dirVar,direction _logic]); //--- Restore custom direction
|
2015-05-10 16:21:18 +00:00
|
|
|
_pos = getposatl _logic;
|
|
|
|
_posAmmo = +_pos;
|
|
|
|
_posAmmo set [2,0];
|
|
|
|
_dir = direction _logic;
|
2017-12-10 18:29:38 +00:00
|
|
|
_simulation = tolower gettext (configfile >> "cfgammo" >> _ammo >> "simulation");
|
2015-05-10 16:21:18 +00:00
|
|
|
_altitude = 0;
|
|
|
|
_velocity = [];
|
|
|
|
_attach = false;
|
|
|
|
_radio = "";
|
|
|
|
_delay = 60;
|
|
|
|
_sound = "";
|
|
|
|
_soundSourceClass = "";
|
|
|
|
_hint = [];
|
|
|
|
_shakeStrength = 0;
|
|
|
|
_shakeRadius = 0;
|
|
|
|
switch (_simulation) do {
|
|
|
|
case "shotshell": {
|
|
|
|
_altitude = 1000;
|
|
|
|
_velocity = [0,0,-100];
|
|
|
|
_radio = "SentGenIncoming";
|
|
|
|
_sounds = if (getnumber (_cfgAmmo >> "hit") < 200) then {["mortar1","mortar2"]} else {["shell1","shell2","shell3","shell4"]};
|
2015-11-29 15:33:25 +00:00
|
|
|
_sound = selectRandom _sounds;
|
2015-05-10 16:21:18 +00:00
|
|
|
_hint = ["Curator","PlaceOrdnance"];
|
|
|
|
_shakeStrength = 0.01;
|
|
|
|
_shakeRadius = 300;
|
|
|
|
};
|
|
|
|
case "shotsubmunitions": {
|
|
|
|
_posAmmo = [_posAmmo,500,_dir + 180] call bis_fnc_relpos;
|
|
|
|
_altitude = 1000 - ((getterrainheightasl _posAmmo) - (getterrainheightasl _pos));
|
|
|
|
_posAmmo set [2,_altitude];
|
|
|
|
_velocity = [sin _dir * 68,cos _dir * 68,-100];
|
|
|
|
_radio = "SentGenIncoming";
|
|
|
|
_hint = ["Curator","PlaceOrdnance"];
|
|
|
|
_shakeStrength = 0.02;
|
|
|
|
_shakeRadius = 500;
|
|
|
|
};
|
|
|
|
case "shotilluminating": {
|
|
|
|
_altitude = 66;
|
|
|
|
_velocity = [wind select 0,wind select 1,30];
|
|
|
|
_sound = "SN_Flare_Fired_4";
|
|
|
|
_soundSourceClass = "SoundFlareLoop_F";
|
|
|
|
};
|
|
|
|
case "shotnvgmarker";
|
|
|
|
case "shotsmokex": {
|
|
|
|
_altitude = 0;
|
|
|
|
_velocity = [0,0,0];
|
|
|
|
_attach = true;
|
|
|
|
};
|
|
|
|
default {["Ammo simulation '%1' is not supported",_simulation] call bis_fnc_error;};
|
|
|
|
};
|
|
|
|
_fnc_playRadio = {
|
|
|
|
if (_radio != "") then {
|
|
|
|
_entities = (getposatl _logic) nearentities ["All",100];
|
|
|
|
_sides = [];
|
|
|
|
{
|
|
|
|
if (isplayer _x) then {
|
|
|
|
_side = side group _x;
|
|
|
|
if (_side in [east,west,resistance,civilian]) then {
|
|
|
|
//--- Play radio (only if it wasn't played recently)
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime > _x getVariable ["BIS_fnc_moduleProjectile_radio",-_delay]) then {
|
2015-05-10 16:21:18 +00:00
|
|
|
[[_side,_radio,"side"],"bis_fnc_sayMessage",_x] call bis_fnc_mp;
|
2016-03-02 10:01:39 +00:00
|
|
|
_x setVariable ["BIS_fnc_moduleProjectile_radio",CBA_missionTime + _delay];
|
2015-05-10 16:21:18 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2017-12-10 18:29:38 +00:00
|
|
|
} foreach _entities;
|
2015-05-10 16:21:18 +00:00
|
|
|
};
|
|
|
|
};
|
2017-12-10 18:29:38 +00:00
|
|
|
if (count _hint > 0 && {count objectcurators _logic > 0}) then {
|
2015-05-10 16:21:18 +00:00
|
|
|
[[_hint,nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",objectcurators _logic] call bis_fnc_mp;
|
|
|
|
};
|
|
|
|
if (count _velocity == 3) then {
|
2017-12-10 18:29:38 +00:00
|
|
|
_altitude = (_logic getvariable ["altitude",_altitude]) call bis_fnc_parsenumber;
|
|
|
|
_radio = _logic getvariable ["radio",_radio];
|
2015-05-10 16:21:18 +00:00
|
|
|
|
|
|
|
//--- Create projectile
|
|
|
|
_posAmmo set [2,_altitude];
|
|
|
|
_projectile = createvehicle [_ammo,_posAmmo,[],0,"none"];
|
|
|
|
_projectile setpos _posAmmo;
|
|
|
|
_projectile setvelocity _velocity;
|
|
|
|
if (_attach) then {_projectile attachto [_logic,[0,0,_altitude]];};
|
|
|
|
|
2017-12-10 18:29:38 +00:00
|
|
|
// Added by ace_zeus for ace_frag compatibility
|
2015-11-30 16:22:16 +00:00
|
|
|
if (!isNil QEFUNC(frag,addPfhRound)) then {
|
2015-06-19 03:43:49 +00:00
|
|
|
[objNull, _ammo, _projectile, true] call EFUNC(frag,addPfhRound);
|
2015-05-10 16:21:18 +00:00
|
|
|
};
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Play sound
|
|
|
|
if (_sound != "") then {[[_logic,_sound,"say3D"],"bis_fnc_sayMessage"] call bis_fnc_mp;};
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Create sound source
|
|
|
|
_soundSource = if (_soundSourceClass != "") then {createSoundSource [_soundSourceClass,_pos,[],0]} else {objnull};
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-06-08 17:18:40 +00:00
|
|
|
// Added by ace_zeus to toggle ordnance radio message
|
2015-05-11 18:04:04 +00:00
|
|
|
if (GVAR(radioOrdnance)) then {
|
2015-05-11 15:23:46 +00:00
|
|
|
//--- Play radio warning
|
|
|
|
[] call _fnc_playRadio;
|
|
|
|
};
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Update
|
|
|
|
if (_attach) then {
|
2017-12-10 18:29:38 +00:00
|
|
|
waituntil {
|
2015-05-10 16:21:18 +00:00
|
|
|
_soundSource setposatl getposatl _projectile;
|
|
|
|
sleep 1;
|
|
|
|
isnull _projectile || isnull _logic
|
|
|
|
};
|
|
|
|
} else {
|
2017-12-10 18:29:38 +00:00
|
|
|
waituntil {
|
2015-05-10 16:21:18 +00:00
|
|
|
_soundSource setposatl getposatl _projectile;
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
if (getposatl _logic distance _pos > 0 || direction _logic != _dir) then {
|
|
|
|
_posNew = getposasl _logic;
|
|
|
|
_dirDiff = direction _logic - _dir;
|
|
|
|
_posNew = [_posNew,[getposasl _projectile,_pos] call bis_fnc_distance2d,direction _logic + 180] call bis_fnc_relpos;
|
|
|
|
_posNew set [2,getposasl _projectile select 2];
|
|
|
|
_projectile setvelocity ([velocity _projectile,-_dirDiff] call bis_fnc_rotatevector2d);
|
|
|
|
_projectile setposasl _posNew;
|
|
|
|
_pos = getposatl _logic;
|
|
|
|
_dir = direction _logic;
|
2017-12-10 18:29:38 +00:00
|
|
|
missionnamespace setvariable [_dirVar,_dir];
|
2015-05-10 16:21:18 +00:00
|
|
|
};
|
|
|
|
sleep 0.1;
|
|
|
|
isnull _projectile || isnull _logic
|
|
|
|
};
|
|
|
|
};
|
|
|
|
deletevehicle _projectile;
|
|
|
|
deletevehicle _soundSource;
|
|
|
|
if (count objectcurators _logic > 0) then {
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Delete curator spawned logic
|
|
|
|
if (_shakeStrength > 0) then {
|
|
|
|
if (_simulation == "shotsubmunitions") then {sleep 0.5;};
|
|
|
|
[[_shakeStrength,0.7,[position _logic,_shakeRadius]],"bis_fnc_shakeCuratorCamera"] call bis_fnc_mp;
|
|
|
|
};
|
|
|
|
deletevehicle _logic;
|
|
|
|
} else {
|
2015-05-10 16:17:17 +00:00
|
|
|
|
2015-05-10 16:21:18 +00:00
|
|
|
//--- Repeat to achieve permanent effect
|
2017-12-10 18:29:38 +00:00
|
|
|
_repeat = _logic getvariable ["repeat",0] > 0;
|
2015-05-10 16:21:18 +00:00
|
|
|
if (_repeat) then {
|
|
|
|
[_logic,_units,_activated] call bis_fnc_moduleprojectile;
|
|
|
|
} else {
|
|
|
|
deletevehicle _logic;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
deletevehicle _logic;
|
|
|
|
};
|
|
|
|
} else {
|
2017-12-10 18:29:38 +00:00
|
|
|
["Cannot create projectile, 'ammo' config attribute is missing in %1",typeof _logic] call bis_fnc_error;
|
2015-05-10 16:21:18 +00:00
|
|
|
};
|
2015-05-11 17:06:01 +00:00
|
|
|
};
|