staged work

This commit is contained in:
Glowbal 2015-04-20 22:48:11 +02:00
parent 2a945df150
commit 7b790ffb1a
6 changed files with 245 additions and 51 deletions

View File

@ -3,7 +3,7 @@
#ifdef DEBUG_MODE_FULL
GVAR(traceFrags) = true;
#endif
// player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
private ["_params", "_initialData", "_hpData", "_roundType", "_round", "_object", "_caliber", "_explosive",
"_idh", "_alive", "_exit", "_vm", "_velocity", "_unitDir", "_oldVelocity", "_curVelocity", "_diff", "_polar",
"_pos", "_spallPos", "_i", "_pos1", "_pos2", "_blah", "_data", "_spallPolar", "_c", "_warn", "_m", "_k",
@ -40,7 +40,7 @@ if(!alive _round && (_initialData select 6) == 1) then {
};
if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
// player sideChat format["BBBB"];
// ACE_player sideChat format["BBBB"];
_exit = false;
_vm = 1;
_velocity = _initialData select 5;
@ -51,10 +51,10 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
if(alive _round) then {
_diff = _velocity vectorDiff (velocity _round);
_polar = _diff call CBA_fnc_vect2polar;
// player sideChat format["polar: %1", _polar];
// ACE_player sideChat format["polar: %1", _polar];
if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then {
if(_caliber < 2.5) then {
// player sideChat format["exit!"];
// ACE_player sideChat format["exit!"];
_exit = true;
} else {
_vm = 1-(_curVelocity/_oldVelocity);
@ -83,7 +83,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
// NOU_TRACES set[(count NOU_TRACES), _data];
if(!lineIntersects [_pos1, _pos2]) exitWith {
// player sideChat format["FOUND!"];
// ACE_player sideChat format["FOUND!"];
_spallPos = _pos2;
};
};
@ -91,7 +91,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_spallPolar = _velocity call CBA_fnc_vect2polar;
if(_explosive > 0) then {
// player sideChat format["EXPLOSIVE!"];
// ACE_player sideChat format["EXPLOSIVE!"];
_warn = false;
_c = getNumber(configFile >> "CfgAmmo" >> _roundType >> "ACE_frag_CHARGE");
if(_c == 0) then { _c = 1; _warn = true;};
@ -137,7 +137,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if(GVAR(traceFrags)) then {
[player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
[ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
};
};
_spread = 5+(random 5);
@ -158,7 +158,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if(GVAR(traceFrags)) then {
[player, _fragment, [1,0,0,1]] call FUNC(addTrack);
[ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack);
};
};
};

View File

@ -11,10 +11,10 @@ if(_round in GVAR(blackList)) exitWith {
};
_doFragTrack = false;
if(_gun == player) then {
if(_gun == ACE_player) then {
_doFragTrack = true;
} else {
if((gunner _gun) == player) then {
if((gunner _gun) == ACE_player) then {
_doFragTrack = true;
} else {
if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then {
@ -28,14 +28,14 @@ if(_doSpall) then {
GVAR(spallHPData) = [];
};
if(GVAR(spallIsTrackingCount) > 5) then {
// player sideChat "LIMT!";
// ACE_player sideChat "LIMT!";
_doSpall = false;
} else {
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1;
};
};
// player sideChat format["c: %1", GVAR(spallIsTrackingCount)];
[player, _round, [1,0,0,1]] call nou_fnc_addTrack;
// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)];
[ACE_player, _round, [1,0,0,1]] call FUNC(addTrack);
if(_doFragTrack && alive _round) then {
GVAR(trackedObjects) pushBack _round;
_spallTrack = [];
@ -44,5 +44,5 @@ if(_doFragTrack && alive _round) then {
if(_doSpall) then {
[_round, 2, _spallTrack, _spallTrackID] call FUNC(spallTrack);
};
// player sideChat "WTF2";
// ACE_player sideChat "WTF2";
};

View File

@ -108,8 +108,8 @@ _fragArcs = [];
_fragArcs set[360, 0];
#ifdef DEBUG_MODE_FULL
player sideChat format["_fragRange: %1", _fragRange];
player sideChat format["_objects: %1", _objects];
ACE_player sideChat format["_fragRange: %1", _fragRange];
ACE_player sideChat format["_objects: %1", _objects];
#endif
_doRandom = false;
if(_isArmed && (count _objects) > 0) then {
@ -176,7 +176,7 @@ if(_isArmed && (count _objects) > 0) then {
GVAR(traceFrags) = true;
#endif
if(GVAR(traceFrags)) then {
[player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
};
_fragCount = _fragCount + 1;
_currentCount = _currentCount + 1;
@ -217,14 +217,14 @@ if(_isArmed && (count _objects) > 0) then {
GVAR(traceFrags) = true;
#endif
if(GVAR(traceFrags)) then {
[player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack);
[ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack);
};
_fragCount = _fragCount + 1;
};
};
};
// #ifdef DEBUG_MODE_FULL
// player sideChat format["total frags: %1", GVAR(TOTALFRAGS)];
// player sideChat format["tracks: %1", (count GVAR(trackedObjects))];
// ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)];
// ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))];
// #endif
// _endTime = diag_tickTime;

View File

@ -3,6 +3,8 @@
ADDON = false;
PREP(moduleInit);
PREP(bi_moduleProjectile);
GVAR(moduleInitCollection) = [];
ADDON = true;

View File

@ -23,6 +23,9 @@ class CfgVehicles {
init = QUOTE(_this call DFUNC(moduleInit));
};
};
class ModuleOrdnance_F: Module_F {
function = "ace_modules_fnc_bi_moduleProjectile";
};
};
#include "CfgEventHandlers.hpp"

View File

@ -0,0 +1,189 @@
/*
* Author: Bohemia Interactive
* Module function for spawning projectiles
* Used by Curator artillery modules etc
*
* Arguments:
* 0: The logic object <OBJECT>
*
* Return Value:
* nil
*
* Public: No
*/
_fnc_scriptNameParentTemp = if !(isnil '_fnc_scriptName') then {_fnc_scriptName} else {'BIS_fnc_moduleProjectile'};
private ['_fnc_scriptNameParent'];
_fnc_scriptNameParent = _fnc_scriptNameParentTemp;
_fnc_scriptNameParentTemp = nil;
private ['_fnc_scriptName'];
_fnc_scriptName = 'BIS_fnc_moduleProjectile';
scriptname _fnc_scriptName;
private ["_logic", "_units", "_activated"];
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if ({local _x} count (objectcurators _logic) > 0) then {
//--- Reveal the circle to curators
_logic hideobject false;
_logic setpos position _logic;
};
if !(isserver) exitwith {};
if (_activated) then {
_ammo = _logic getvariable ["type",gettext (configfile >> "cfgvehicles" >> typeof _logic >> "ammo")];
if (_ammo != "") then {
_cfgAmmo = configfile >> "cfgammo" >> _ammo;
//if !(isclass _cfgAmmo) exitwith {["CfgAmmo class '%1' not found.",_ammo] call bis_fnc_error;};
_dirVar = _fnc_scriptname + typeof _logic;
_logic setdir (missionnamespace getvariable [_dirVar,direction _logic]); //--- Restore custom direction
_pos = getposatl _logic;
_posAmmo = +_pos;
_posAmmo set [2,0];
_dir = direction _logic;
_simulation = tolower gettext (configfile >> "cfgammo" >> _ammo >> "simulation");
_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"]};
_sound = _sounds call bis_fnc_selectrandom;
_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)
if (time > _x getvariable ["BIS_fnc_moduleProjectile_radio",-_delay]) then {
[[_side,_radio,"side"],"bis_fnc_sayMessage",_x] call bis_fnc_mp;
_x setvariable ["BIS_fnc_moduleProjectile_radio",time + _delay];
};
};
};
} foreach _entities;
};
};
if (count _hint > 0) then {
[[_hint,nil,nil,nil,nil,nil,nil,true],"bis_fnc_advHint",objectcurators _logic] call bis_fnc_mp;
};
if (count _velocity == 3) then {
_altitude = (_logic getvariable ["altitude",_altitude]) call bis_fnc_parsenumber;
_radio = _logic getvariable ["radio",_radio];
//--- 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]];};
// This is our addition to this function
[ACE_player, "", "", "", _ammo, "", _projectile] call ace_frag_fnc_fired;
//--- Play sound
if (_sound != "") then {[[_logic,_sound,"say3D"],"bis_fnc_sayMessage"] call bis_fnc_mp;};
//--- Create sound source
_soundSource = if (_soundSourceClass != "") then {createSoundSource [_soundSourceClass,_pos,[],0]} else {objnull};
//--- Play radio warning
[] call _fnc_playRadio;
//--- Update
if (_attach) then {
waituntil {
_soundSource setposatl getposatl _projectile;
sleep 1;
isnull _projectile || isnull _logic
};
} else {
waituntil {
_soundSource setposatl getposatl _projectile;
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;
missionnamespace setvariable [_dirVar,_dir];
};
sleep 0.1;
isnull _projectile || isnull _logic
};
};
deletevehicle _projectile;
deletevehicle _soundSource;
if (count objectcurators _logic > 0) then {
//--- 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 {
//--- Repeat to achieve permanent effect
_repeat = _logic getvariable ["repeat",0] > 0;
if (_repeat) then {
[_logic,_units,_activated] call bis_fnc_moduleprojectile;
} else {
deletevehicle _logic;
};
};
} else {
deletevehicle _logic;
};
} else {
["Cannot create projectile, 'ammo' config attribute is missing in %1",typeof _logic] call bis_fnc_error;
};
};