From a1618e0dcfe5be983f5ce4502ec6e2e99b87126e Mon Sep 17 00:00:00 2001 From: worldwidesorrow Date: Thu, 9 Jan 2020 16:52:06 -0600 Subject: [PATCH] Update insert.sqf Replace switch do block with call scope using if exitWith statements. The most common spawned item is a magazine class so it is placed at the top. --- SQF/dayz_code/loot/insert.sqf | 51 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/SQF/dayz_code/loot/insert.sqf b/SQF/dayz_code/loot/insert.sqf index 0115fb434..c0cec3819 100644 --- a/SQF/dayz_code/loot/insert.sqf +++ b/SQF/dayz_code/loot/insert.sqf @@ -11,46 +11,43 @@ Author: Foxy */ -#include "\z\addons\dayz_code\util\debug.hpp" #include "Loot.hpp" -if (!local (_this select 0)) exitWith -{ - diag_log format ["ERROR: Loot_Insert unit must be local. (%1)", _this select 0]; +private ["_unit","_group","_count","_type","_item"]; + +_unit = _this select 0; +_group = _this select 1; +_count = _this select 2; + +// Prevent loot spawning on non-local zombies - this check is needed if the server is running safezones that delete zombies. +if (!local _unit) exitWith { + diag_log format ["ERROR: Loot_Insert unit must be local. (%1)", _unit]; }; { - switch (_x select 0) do - { - case Loot_WEAPON: - { - (_this select 0) addWeapon (_x select 1); - - Debug_Assert(typeName (_x select 1) == typeName "" && { (_x select 1) != "" }); - //Debug_Log(String_Format2("DEBUG: Loot_Insert Weapon: %1 Unit: %2", _x select 1, _this select 0)); - }; - - case Loot_MAGAZINE: - { - private "_item"; - _item = _x select 1; + _type = _x select 0; + _item = _x select 1; + + call { + if (_type == Loot_MAGAZINE) exitWith { if (dayz_classicBloodBagSystem && _item in dayz_typedBags) then { - if (_item in ["bloodTester","bloodBagAPOS","bloodBagABPOS"]) then { // reduce ItemBloodBag output slightly since typed bags spawn in bulk + if (_item in ["emptyBloodBag","bloodTester","bloodBagAPOS","bloodBagABPOS"]) then { // reduce ItemBloodBag output slightly since typed bags spawn in bulk _item = ["ItemBandage","ItemPainkiller","ItemMorphine","ItemHeatPack","ItemAntibacterialWipe"] call BIS_fnc_selectRandom; } else { _item = "ItemBloodbag"; }; }; - (_this select 0) addMagazine _item; + _unit addMagazine _item; }; - case Loot_BACKPACK: - { - if (!isNull unitBackpack (_this select 0)) then - { - (_this select 0) addBackpack (_x select 1); + if (_type == Loot_WEAPON) exitWith { + _unit addWeapon _item; + }; + + if (_type == Loot_BACKPACK) exitWith { + if (!isNull unitBackpack _unit) then { + _unit addBackpack _item; }; }; }; -} count Loot_Select(_this select 1, _this select 2); -//foreach ([_this select 1, _this select 2] call loot_select); \ No newline at end of file +} count Loot_Select(_group,_count);