Replace forEach with Count

Use count where you do not need _forEachIndex variable, it's quicker
than forEach.
This commit is contained in:
icomrade
2014-05-27 15:37:57 -04:00
parent 91d246e64e
commit e54b9983dd
210 changed files with 890 additions and 890 deletions

View File

@@ -28,7 +28,7 @@ while {r_doLoop} do {
if (_isMedic) then {
_started = true;
};
if (_started and !_isMedic) then {
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};
@@ -54,7 +54,7 @@ if (_finished) then {
_display closeDisplay 0;
};
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
//Self Healing
_id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medBandaged.sqf";
dayz_sourceBleeding = objNull;
@@ -65,7 +65,7 @@ if (_finished) then {
[player,20] call player_humanityChange;
};
{_unit setVariable[_x,false,true];} forEach USEC_woundHit;
{_unit setVariable[_x,false,true];} count USEC_woundHit;
_unit setVariable ["USEC_injured",false,true];
};

View File

@@ -3,7 +3,7 @@
// Functions
// Added pvEH - scripts modified to remove the need for sending long strings via setVehicleInit to reduce network traffic and JIP load - 04072010
// Added pvEH - scripts modified to remove the need for sending long strings via setVehicleInit to reduce network traffic && JIP load - 04072010
// INCLUDE REQUIRED GAME CODES
#include "\ca\editor\Data\Scripts\dikCodes.h"
@@ -32,7 +32,7 @@ while {true} do {
_id = [dayz_sourceBleeding,"bled"] spawn player_death;
};
if ((r_player_blood <= 3000) and !r_player_unconscious) then {
if ((r_player_blood <= 3000) && !r_player_unconscious) then {
_rnd = random 100;
if (_rnd > 99) then {
[player,((random 0.1) + 0.2)] call fnc_usec_damageUnconscious;
@@ -40,13 +40,13 @@ while {true} do {
};
//Handle Unconscious player
if ((r_player_unconscious) and (!r_player_handler1)) then {
if ((r_player_unconscious) && (!r_player_handler1)) then {
//localize "CLIENT: Start Unconscious Function";
[] spawn fnc_usec_unconscious;
};
//Handle player bleeding
if ((r_player_injured) and (!r_player_handler)) then {
if ((r_player_injured) && (!r_player_handler)) then {
r_player_handler = true;
sleep 1;
//localize "CLIENT: Start Player Bleeding";
@@ -55,7 +55,7 @@ while {true} do {
};
//Handle player infection
if ((r_player_infected) and (!r_player_handler)) then {
if ((r_player_infected) && (!r_player_handler)) then {
r_player_handler = true;
sleep 1;
[] spawn fnc_med_publicBlood;
@@ -81,7 +81,7 @@ while {true} do {
};
sleep 0.5;
_lowBlood = player getVariable ["USEC_lowBlood", false];
if ((r_player_blood < r_player_bloodTotal) and !_lowBlood) then {
if ((r_player_blood < r_player_bloodTotal) && !_lowBlood) then {
player setVariable["USEC_lowBlood",true,true];
};
};

View File

@@ -27,7 +27,7 @@ while {r_doLoop} do {
if (_isMedic) then {
_started = true;
};
if (_started and !_isMedic) then {
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};
@@ -52,7 +52,7 @@ if (_finished) then {
_display closeDisplay 0;
};
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
//Self Healing
_id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medMorphine.sqf";
} else {

View File

@@ -24,7 +24,7 @@ if(_num_removed == 1) then {
player playActionNow "Gear";
};
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
//Self Healing
_id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medPainkiller.sqf";
} else {

View File

@@ -4,7 +4,7 @@ private ["_unit"];
_unit = _this select 0;
_unit switchMove "AmovPpneMstpSnonWnonDnon_healed";
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
r_player_unconscious = false;
r_player_injured = false;
};

View File

@@ -5,7 +5,7 @@ _array = _this; //_this select 0;
_unit = _array select 0;
_medic = _array select 1;
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
r_player_injured = false;
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5;
r_player_handler = false;

View File

@@ -5,7 +5,7 @@ _array = _this; //_this select 0;
_unit = _array select 0;
_medic = _array select 1;
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
r_fracture_legs = false;
r_fracture_arms = false;
_unit setHit["legs",0];

View File

@@ -5,7 +5,7 @@ _array = _this; //_this select 0;
_unit = _array select 0;
_medic = _array select 1;
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
r_player_inpain = false;
R3F_TIRED_Accumulator = 0;
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5;

View File

@@ -23,7 +23,7 @@ while {r_doLoop} do {
if (_isMedic) then {
_started = true;
};
if (_started and !_isMedic) then {
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};

View File

@@ -39,7 +39,7 @@ fnc_usec_damageUnconscious = {
_unit = _this select 0;
_damage = _this select 1;
_inVehicle = (vehicle _unit != _unit);
if ((_unit == player) or (vehicle player != player)) then {
if ((_unit == player) || (vehicle player != player)) then {
r_player_timeout = round((((random 2) max 0.1) * _damage) * 20);
r_player_unconscious = true;
player setVariable["medForceUpdate",true,true];
@@ -50,7 +50,7 @@ fnc_usec_damageUnconscious = {
private["_veh","_unit"];
_veh = vehicle _this;
_unit = _this;
waitUntil{(((([_veh] call FNC_GetPos) select 2 < 1) and (speed _veh < 1)) or (!r_player_unconscious))};
waitUntil{(((([_veh] call FNC_GetPos) select 2 < 1) && (speed _veh < 1)) || (!r_player_unconscious))};
if (r_player_unconscious) then {
_unit action ["eject", _veh];
waitUntil{((vehicle _this) != _this)};
@@ -84,10 +84,10 @@ fnc_usec_damageType = {
_damage = _this select 0;
_ammo = _this select 1;
_type = 0;
if ((_ammo isKindof "Grenade") or (_ammo isKindof "ShellBase") or (_ammo isKindof "TimeBombCore") or (_ammo isKindof "BombCore") or (_ammo isKindof "MissileCore") or (_ammo isKindof "RocketCore") or (_ammo isKindof "FuelExplosion") or (_ammo isKindof "GrenadeBase")) then {
if ((_ammo isKindof "Grenade") || (_ammo isKindof "ShellBase") || (_ammo isKindof "TimeBombCore") || (_ammo isKindof "BombCore") || (_ammo isKindof "MissileCore") || (_ammo isKindof "RocketCore") || (_ammo isKindof "FuelExplosion") || (_ammo isKindof "GrenadeBase")) then {
_type = 1;
};
if ((_ammo isKindof "B_127x107_Ball") or (_ammo isKindof "B_127x99_Ball")) then {
if ((_ammo isKindof "B_127x107_Ball") || (_ammo isKindof "B_127x99_Ball")) then {
_type = 2;
};
if (_ammo isKindof "Melee") then {
@@ -115,8 +115,8 @@ fnc_usec_medic_removeActions = {
_obj = _x;
{
_obj removeAction _x;
} forEach r_player_actions;
} forEach r_action_targets;
} count r_player_actions;
} count r_action_targets;
r_player_actions = [];
r_action_targets = [];
};
@@ -124,12 +124,12 @@ fnc_usec_medic_removeActions = {
fnc_usec_self_removeActions = {
{
player removeAction _x;
} forEach r_self_actions;
} count r_self_actions;
r_self_actions = [];
};
fnc_med_publicBlood = {
while {(r_player_injured or r_player_infected) and r_player_blood > 0} do {
while {(r_player_injured || r_player_infected) && r_player_blood > 0} do {
player setVariable["USEC_BloodQty",r_player_blood,true];
player setVariable["medForceUpdate",true];
sleep 5;
@@ -146,11 +146,11 @@ fnc_usec_playerBleed = {
while {r_player_injured} do {
_bleedPerSec = 30;
// If kneeling or crawling reduce bleeding
if (dayz_isKneeling and !r_player_unconscious) then{
// If kneeling || crawling reduce bleeding
if (dayz_isKneeling && !r_player_unconscious) then{
_bleedPerSec = 15;
};
if (dayz_isCrawling and !r_player_unconscious) then{
if (dayz_isCrawling && !r_player_unconscious) then{
_bleedPerSec = 7.5;
};
@@ -163,7 +163,7 @@ fnc_usec_playerBleed = {
r_player_injured = false;
_id = [player,player] execVM "\z\addons\dayz_code\medical\publicEH\medBandaged.sqf";
dayz_sourceBleeding = objNull;
{player setVariable[_x,false,true];} forEach USEC_woundHit;
{player setVariable[_x,false,true];} count USEC_woundHit;
player setVariable ["USEC_injured",false,true];
};
sleep 1;
@@ -228,7 +228,7 @@ fnc_usec_damageBleed = {
sleep 5;
while {((_unit getVariable["USEC_injured",true]) and (alive _unit))} do {
while {((_unit getVariable["USEC_injured",true]) && (alive _unit))} do {
scopeName "loop";
if (vehicle _unit != _unit) then {
BreakOut "loop";

View File

@@ -29,7 +29,7 @@ while {r_doLoop} do {
if (_isMedic) then {
_started = true;
};
if (_started and !_isMedic) then {
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};