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,11 +3,11 @@
#ifdef DEBUG_MODE_FULL
GVAR(traceFrags) = true;
#endif
// 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",
"_gC", "_shellType", "_fragPower", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect",
// 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",
"_gC", "_shellType", "_fragPower", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect",
"_fragment"];
@ -40,21 +40,21 @@ 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;
_oldVelocity = _velocity call BIS_fnc_magnitude;
_curVelocity = (velocity _round) call BIS_fnc_magnitude;
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);
@ -78,20 +78,20 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
];
// _blah = [_object, "FIRE"] intersect [_object worldToModel (ASLtoATL _pos1), _object worldToModel (ASLtoATL _pos2)];
// diag_log text format["b: %1", _blah];
// _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]];
// NOU_TRACES set[(count NOU_TRACES), _data];
if(!lineIntersects [_pos1, _pos2]) exitWith {
// player sideChat format["FOUND!"];
// ACE_player sideChat format["FOUND!"];
_spallPos = _pos2;
};
};
if(!isNil "_spallPos") 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;};
@ -109,7 +109,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_fragPower = (((_m/_c)+_k)^-(1/2))*_gC;
_spallPolar set[0, _fragPower*0.66];
};
_fragTypes = [
"ACE_frag_spall_small", "ACE_frag_spall_small", "ACE_frag_spall_small",
"ACE_frag_spall_small","ACE_frag_spall_medium","ACE_frag_spall_medium","ACE_frag_spall_medium",
@ -117,7 +117,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
"ACE_frag_spall_huge"
];
// diag_log text format["SPALL POWER: %1", _spallPolar select 0];
_spread = 15+(random 25);
_spallCount = 5+(random 10);
@ -130,14 +130,14 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_dir = _dir % 360;
_vel = (_spallPolar select 0)*0.33*_vm;
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
_spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
_fragType = round (random ((count _fragTypes)-1));
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_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);
@ -151,14 +151,14 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_dir = _dir % 360;
_vel = (_spallPolar select 0)*0.55*_vm;
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
_spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
_fragType = round (random ((count _fragTypes)-1));
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_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

@ -9,14 +9,14 @@
if(!isServer) exitWith { };
// _startTime = diag_tickTime;
private ["_round", "_lastPos", "_lastVel", "_shellType", "_gun", "_fragTypes", "_warn", "_atlPos", "_isArmed",
"_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom",
"_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_target", "_boundingBox",
"_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir",
"_currentCount", "_count", "_vecVar", "_i", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount",
private ["_round", "_lastPos", "_lastVel", "_shellType", "_gun", "_fragTypes", "_warn", "_atlPos", "_isArmed",
"_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom",
"_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_target", "_boundingBox",
"_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir",
"_currentCount", "_count", "_vecVar", "_i", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount",
"_sectorSize", "_sectorOffset", "_randomDir"];
_round = _this select 0;
_lastPos = _this select 1;
_lastVel = _this select 2;
@ -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 {
@ -127,16 +127,16 @@ if(_isArmed && (count _objects) > 0) then {
_cubic = _bbX*_bbY*_bbZ;
if(_cubic > 1) then {
_doRandom = true;
_targetVel = (velocity _target);
_targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))];
_targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))];
_targetPos set[2, (_targetPos select 2)+_add];
_baseVec = _lastPos vectorFromTo _targetPos;
_dir = floor(_baseVec call CBA_fnc_vectDir);
_currentCount = _fragArcs select _dir;
if(isNil "_currentCount") then {
@ -153,18 +153,18 @@ if(_isArmed && (count _objects) > 0) then {
};
for "_i" from 1 to _count do {
_vec = +_baseVec;
_vec set[0, (_vec select 0)-(_vecVar/2)+(random _vecVar)];
_vec set[1, (_vec select 1)-(_vecVar/2)+(random _vecVar)];
_vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)];
_fp = (_fragPower-(random (_fragPowerRandom)));
_vel = [
(_vec select 0)*_fp,
(_vec select 1)*_fp,
(_vec select 2)*_fp
];
_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format["fp: %1 %2", _fp, typeOf _fragObj];
@ -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;
@ -198,15 +198,15 @@ if(_isArmed && (count _objects) > 0) then {
_sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
_randomDir = random(_sectorSize);
_vec = [cos(_sectorOffset + _randomDir), sin(_sectorOffset + _randomDir), sin(30 - (random 45))];
_fp = (_fragPower-(random (_fragPowerRandom)));
_vel = [
(_vec select 0)*_fp,
(_vec select 1)*_fp,
(_vec select 2)*_fp
];
_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragObj setPosASL _lastPos;
@ -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;
};
};