Skip to content

Commit

Permalink
Merge pull request #3125 from acemod/privatekeywordcleanup
Browse files Browse the repository at this point in the history
Code cleanup 1.54, 2
  • Loading branch information
commy2 committed Jan 6, 2016
2 parents 0bc5403 + de13518 commit 39156e1
Show file tree
Hide file tree
Showing 37 changed files with 277 additions and 328 deletions.
13 changes: 3 additions & 10 deletions addons/backpacks/functions/fnc_backpackOpened.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,17 @@
params ["_target", "_backpack"];

// do cam shake if the target is the player
if ([_target] call EFUNC(common,isPlayer)) then {
if (_target call EFUNC(common,isPlayer)) then {
addCamShake [4, 0.5, 5];
};

// play a zipper sound effect
private ["_sounds", "_position"];

_sounds = [
/*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss",
"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWrflDnon_medic.wss",
"a3\sounds_f\characters\ingame\AinvPpneMstpSlayWpstDnon_medic.wss",
"a3\sounds_f\characters\ingame\AinvPpneMstpSlayWrflDnon_medic.wss"*/

private _sounds = [
QUOTE(PATHTO_R(sounds\zip_in.wav)),
QUOTE(PATHTO_R(sounds\zip_out.wav))
];

_position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3"));
private _position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3"));

playSound3D [
_sounds select floor random count _sounds,
Expand Down
5 changes: 2 additions & 3 deletions addons/backpacks/functions/fnc_isBackpack.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
*/
#include "script_component.hpp"

params ["_backpack"];
params [["_backpack", objNull, [objNull]]];

if (_backpack isEqualType objNull) then {
_backpack = typeOf _backpack;
};

private "_config";
_config = configFile >> "CfgVehicles" >> _backpack;
private _config = configFile >> "CfgVehicles" >> _backpack;

getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} // return
5 changes: 2 additions & 3 deletions addons/backpacks/functions/fnc_onOpenInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
params ["_unit", "_backpack"];

// exit if the target is not a real backpack, i.e. parachute, static weapon bag etc.
if !([_backpack] call FUNC(isBackpack)) exitWith {false};
if !(_backpack call FUNC(isBackpack)) exitWith {false};

// get the unit that wears the backpack object
private "_target";
_target = objectParent _backpack;
private _target = objectParent _backpack;

if (isNull _target) exitWith {false};

Expand Down
16 changes: 6 additions & 10 deletions addons/disposable/functions/fnc_replaceATWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
params ["_unit", "_weapon", "", "", "", "", "_projectile"];
TRACE_3("params",_unit,_weapon,_projectile);

if ((!local _unit) || {_weapon != (secondaryWeapon _unit)}) exitWith {};
if (!local _unit || {_weapon != secondaryWeapon _unit}) exitWith {};

private ["_replacementTube", "_items"];
_replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
private _replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit


//Save array of items attached to launcher
_items = secondaryWeaponItems _unit;
private _items = secondaryWeaponItems _unit;
//Replace the orginal weapon with the 'usedTube' weapon
_unit addWeapon _replacementTube;
//Makes sure the used tube is still equiped
Expand All @@ -55,12 +53,10 @@ if !([_unit] call EFUNC(common,isPlayer)) then {
[_idPFH] call CBA_fnc_removePerFrameHandler;

//If (tube is dropped) OR (is dead) OR (is player) just exit
if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {};

private ["_items", "_container"];
if (secondaryWeapon _unit != _tube || {!alive _unit} || {[_unit] call EFUNC(common,isPlayer)}) exitWith {};

// _items = secondaryWeaponItems _unit;
_container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
//private _items = secondaryWeaponItems _unit;
private _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
_container setPosAsl (getPosAsl _unit);
_container addWeaponCargoGlobal [_tube, 1];

Expand Down
19 changes: 8 additions & 11 deletions addons/disposable/functions/fnc_takeLoadedATWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@ TRACE_1("params",_unit);

if (!local _unit) exitWith {};

private ["_launcher", "_config"];

_launcher = secondaryWeapon _unit;
_config = configFile >> "CfgWeapons" >> _launcher;
private _launcher = secondaryWeapon _unit;
private _config = configFile >> "CfgWeapons" >> _launcher;

if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then {
private ["_magazine", "_isLauncherSelected", "_didAdd"];

_magazine = getArray (_config >> "magazines") select 0;

_isLauncherSelected = currentWeapon _unit == _launcher;
private _magazine = getArray (_config >> "magazines") select 0;
private _isLauncherSelected = currentWeapon _unit == _launcher;

_unit removeMagazines _magazine;

if (backpack _unit == "") then {
_unit addBackpack "ACE_FakeBackpack";
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
private _didAdd = _magazine in magazines _unit;
_unit addWeapon _launcher;

if (!_didAdd) then {
TRACE_1("Failed To Add Disposable Magazine Normally, doing backup method (no backpack)",_unit);
_unit addSecondaryWeaponItem _magazine;
Expand All @@ -48,8 +44,9 @@ if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber
} else {
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
private _didAdd = _magazine in magazines _unit;
_unit addWeapon _launcher;

if (!_didAdd) then {
TRACE_2("Failed To Add Disposable Magazine Normally, doing backup method",_unit,(backpack _unit));
_unit addSecondaryWeaponItem _magazine;
Expand Down
10 changes: 4 additions & 6 deletions addons/disposable/functions/fnc_updateInventoryDisplay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ _player removeMagazines "ACE_FiredMissileDummy";

if (isNull _display) exitWith {};

private ["_launcher", "_control", "_config"];

_launcher = secondaryWeapon _player;
private _launcher = secondaryWeapon _player;

if (_launcher == "" || {getText (configFile >> "CfgWeapons" >> _launcher >> "ACE_UsedTube") == ""}) then {
_control = _display displayCtrl 627;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine";
private _control = _display displayCtrl 627;
private _config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;

Expand All @@ -39,7 +37,7 @@ if (_launcher == "" || {getText (configFile >> "CfgWeapons" >> _launcher >> "ACE
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
} else {
_control = _display displayCtrl 627;
private _control = _display displayCtrl 627;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;

Expand Down
3 changes: 1 addition & 2 deletions addons/grenades/functions/fnc_flare.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

params ["_projectile", "_color", "_intensity", "_timeToLive"];

private "_light";
_light = "#lightpoint" createVehicleLocal position _projectile;
private _light = "#lightpoint" createVehicleLocal position _projectile;

_light setLightColor _color;
_light setLightAmbient _color;
Expand Down
21 changes: 10 additions & 11 deletions addons/grenades/functions/fnc_flashbangExplosionEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

params ["_grenade"];

private ["_affected", "_strength", "_posGrenade", "_eyePos", "_losCount", "_eyeDir", "_dirToUnitVector", "_angleDiff", "_light"];

_affected = _grenade nearEntities ["CAManBase", 20];
private _affected = _grenade nearEntities ["CAManBase", 20];

{
if (local _x && {alive _x}) then {

_strength = 1 - ((_x distance _grenade) min 15) / 15;
private _strength = 1 - ((_x distance _grenade) min 15) / 15;

TRACE_3("FlashBangEffect Start",_x,(_x distance _grenade),_strength);

Expand All @@ -47,12 +45,12 @@ _affected = _grenade nearEntities ["CAManBase", 20];
} else {
//Do effects for player
// is there line of sight to the grenade?
_posGrenade = getPosASL _grenade;
_eyePos = eyePos ACE_player; //PositionASL
private _posGrenade = getPosASL _grenade;
private _eyePos = eyePos ACE_player; //PositionASL
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground

//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
_losCount = {
private _losCount = {
!lineIntersects [_posGrenade vectorAdd _x, _eyePos, _grenade, ACE_player]
} count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]];

Expand All @@ -68,9 +66,9 @@ _affected = _grenade nearEntities ["CAManBase", 20];

// account for people looking away by slightly
// reducing the effect for visual effects.
_eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
_dirToUnitVector = _eyePos vectorFromTo _posGrenade;
_angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
private _eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
private _dirToUnitVector = _eyePos vectorFromTo _posGrenade;
private _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);

// from 0-45deg, full effect
if (_angleDiff > 45) then {
Expand All @@ -85,7 +83,8 @@ _affected = _grenade nearEntities ["CAManBase", 20];
};

// create flash to illuminate environment
_light = "#lightpoint" createVehicleLocal (getPos _grenade);
private _light = "#lightpoint" createVehicleLocal getPos _grenade;

_light setLightBrightness 200;
_light setLightAmbient [1,1,1];
_light setLightColor [1,1,1];
Expand Down
2 changes: 1 addition & 1 deletion addons/grenades/functions/fnc_flashbangThrownFuze.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ params ["_projectile"];
if (alive _projectile) then {
playSound3D ["A3\Sounds_F\weapons\Explosion\explosion_mine_1.wss", _projectile, false, getPosASL _projectile, 5, 1.2, 400];

private _affected = _projectile nearEntities ["CAManBase", 20];
private _affected = _projectile nearEntities ["CAManBase", 50];

["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent);
};
18 changes: 8 additions & 10 deletions addons/grenades/functions/fnc_nextMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
*/
#include "script_component.hpp"

private ["_mode", "_hint"];

_mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0];
private _mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0];

if (_mode == 4) then {
_mode = 0;
Expand All @@ -30,13 +28,13 @@ if (_mode == 3) then {
_mode = 4;
};

_hint = [
localize LSTRING(NormalThrow),
localize LSTRING(HighThrow),
localize LSTRING(PreciseThrow),
localize LSTRING(RollGrenade),
localize LSTRING(DropGrenade)
] select _mode;
private _hint = localize ([
LSTRING(NormalThrow),
LSTRING(HighThrow),
LSTRING(PreciseThrow),
LSTRING(RollGrenade),
LSTRING(DropGrenade)
] select _mode);

[_hint] call EFUNC(common,displayTextStructured);

Expand Down
26 changes: 11 additions & 15 deletions addons/grenades/functions/fnc_throwGrenade.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,33 @@ if (isNull _projectile) then {
_projectile = nearestObject [_unit, _ammo];
};

private _config = configFile >> "CfgAmmo" >> _ammo;

// handle special grenades
if (local _unit) then {
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(flashbang)) == 1) then {
private "_fuzeTime";
_fuzeTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosionTime");
if (getNumber (_config >> QGVAR(flashbang)) == 1) then {
private _fuzeTime = getNumber (_config >> "explosionTime");

[FUNC(flashbangThrownFuze), [_projectile], _fuzeTime, 0] call EFUNC(common,waitAndExecute);
};
};

if (getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(flare)) == 1) then {
private ["_fuzeTime", "_timeToLive", "_color", "_intensity"];

_fuzeTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosionTime");
_timeToLive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "timeToLive");
_color = getArray (configFile >> "CfgAmmo" >> _ammo >> QGVAR(color));
_intensity = _color select 3;
_color resize 3;
if (getNumber (_config >> QGVAR(flare)) == 1) then {
private _fuzeTime = getNumber (_config >> "explosionTime");
private _timeToLive = getNumber (_config >> "timeToLive");
private _color = getArray (_config >> QGVAR(color));
private _intensity = _color deleteAt 3;

[FUNC(flare), [_projectile, _color, _intensity, _timeToLive], _fuzeTime, 0] call EFUNC(common,waitAndExecute);
};

// handle throw modes
if (_unit != ACE_player) exitWith {};

private "_mode";
_mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0];
private _mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0];

if (_mode != 0) then {
private "_velocity";
_velocity = velocity _projectile;
private _velocity = velocity _projectile;

switch (_mode) do {
//high throw
Expand Down
1 change: 1 addition & 0 deletions addons/hitreactions/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
ADDON = false;

PREP(fallDown);
PREP(getRandomAnimation);

ADDON = true;
Loading

0 comments on commit 39156e1

Please sign in to comment.