Compiles.sqf cleanup

- Moved player_countMagazines to \compile\ folder
- Removed several unused and obsolete files
- Moved some epoch functions out of compiles.sqf into individual files
- Synced order and formatting with 1.8.7. Much easier to compare now.

Any changes I make to official DayZ Mod code and files I also submit as
a pull request to them.
This commit is contained in:
ebaydayz
2016-03-17 16:34:15 -04:00
parent 3113889a98
commit 6a6db58291
38 changed files with 494 additions and 1547 deletions

View File

@@ -0,0 +1,12 @@
// check if player in vehicle
private ["_noDriver","_vehicle","_inVehicle"];
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
if(_inVehicle) then {
_noDriver = ((_vehicle emptyPositions "driver") > 0);
if (_noDriver && (speed _vehicle) != 0) then {
player action [ "eject", _vehicle];
};
};

View File

@@ -0,0 +1,15 @@
_objInfo = toArray(str(_this));
_lenInfo = count _objInfo - 1;
_objName = [];
_i = 0;
// determine where the object name starts
{
if (58 == _objInfo select _i) exitWith {};
_i = _i + 1;
} count _objInfo;
_i = _i + 2; // skip the ": " part
for "_k" from _i to _lenInfo do {
_objName set [(count _objName), (_objInfo select _k)];
};
_objName = toLower(toString(_objName));
_objName

View File

@@ -0,0 +1,18 @@
private ["_notClosest","_playerDistance","_nearPlayers","_obj","_playerNear"];
if (!isNull _this) then {
_nearPlayers = _this nearEntities ["CAManBase", 12];
_playerNear = ({isPlayer _x} count _nearPlayers) > 1;
_notClosest = false;
if (_playerNear) then {
// check if another player is closer
_playerDistance = player distance _this;
{
if (_playerDistance > (_x distance _this)) exitWith { _notClosest = true; };
} count _nearPlayers;
};
} else {
_notClosest = false;
};
_notClosest

View File

@@ -0,0 +1,13 @@
_trade_total = 0;
{
_part_in_configClass = configFile >> "CfgMagazines" >> (_x select 0);
if (isClass (_part_in_configClass)) then {
_part_inWorth = (_part_in_configClass >> "worth");
if isNumber (_part_inWorth) then {
_trade_total = _trade_total + (getNumber(_part_inWorth) * (_x select 1));
};
};
} count _this;
//diag_log format["DEBUG TRADER ITEMCOST: %1", _this];
_trade_total

View File

@@ -1,4 +1,5 @@
// Made for DayZ Epoch by vbawol
// Made for DayZ Epoch by vbawol
// usage [["partinclassname",4]] call epoch_returnChange;
private ["_trade_total","_part_inWorth","_part_in_configClass","_total_currency","_part","_worth","_return_change","_total","_briefcase_100oz","_gold_10oz_a","_gold_10oz_b","_gold_10oz","_gold_1oz_a","_gold_1oz_b","_gold_1oz","_silver_10oz_a","_silver_10oz_b","_silver_10oz","_silver_1oz_a","_silver_1oz_b","_silver_1oz","_successful","_buyOrSell","_total_items"];
_successful = false;

View File

@@ -0,0 +1,14 @@
private ["_temp_keys","_temp_keys_names","_key_colors","_ownerKeyId","_ownerKeyName"];
_temp_keys = [];
_temp_keys_names = [];
// find available keys
_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
{
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
_ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
_ownerKeyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
_temp_keys_names set [_ownerKeyId,_ownerKeyName];
_temp_keys set [count _temp_keys,str(_ownerKeyId)];
};
} count (items player);
[_temp_keys,_temp_keys_names]

View File

@@ -0,0 +1,10 @@
// total currency
_total_currency = 0;
{
_part = (configFile >> "CfgMagazines" >> _x);
_worth = (_part >> "worth");
if isNumber (_worth) then {
_total_currency = _total_currency + getNumber(_worth);
};
} count (magazines player);
_total_currency

View File

@@ -0,0 +1,7 @@
private ["_items","_b"];
_items = _this;
_b = _items call player_checkItems;
if (_b) then {
_b = _items call player_removeItems;
};
_b

View File

@@ -1,21 +0,0 @@
scriptName "Functions\misc\fn_damageHandler.sqf";
/***********************************************************
PROCESS DAMAGE TO A UNIT
- Function
- [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler;
************************************************************/
private ["_unit","_hit","_damage","_total"];
_unit = _this select 0;
_hit = _this select 1;
_damage = _this select 2;
//_source = _this select 3;
//_ammo = _this select 4;
_total = _damage;
//diag_log ("DAMAGE VEH: " + typeof(_unit) + " / " + str(_hit) + " / " + str(_damage) + " / " + str(getDammage _unit));
if (local _unit) then {
_total = [_unit,_hit,_damage] call object_setHitServer;
};
_total

View File

@@ -1,35 +0,0 @@
private ["_unit1","_building","_relPos","_boundingBox","_min","_max","_myX","_myY","_myZ","_inside"];
_unit1 = _this select 0;
_building = _this select 1;
//_type = typeOf _building;
_relPos = _building worldToModel _unit1;
_boundingBox = boundingBox _building;
//diag_log ("DEBUG: Building: " + str(_building) );
//diag_log ("DEBUG: Building Type: " + str(_type) );
//diag_log ("DEBUG: BoundingBox: " + str(_boundingBox) );
_min = _boundingBox select 0;
_max = _boundingBox select 1;
//diag_log ("Min: " + str(_min) );
//diag_log ("Max: " + str(_max) );
_myX = _relPos select 0;
_myY = _relPos select 1;
_myZ = _relPos select 2;
//diag_log ("X: " + str(_myX) );
//diag_log ("Y: " + str(_myY) );
//diag_log ("Z: " + str(_myZ) );
if ((_myX > (_min select 0)) && (_myX < (_max select 0))) then {
if ((_myY > (_min select 1)) && (_myY < (_max select 1))) then {
if ((_myZ > (_min select 2)) && (_myZ < (_max select 2))) then {
_inside = true;
} else { _inside = false; };
} else { _inside = false; };
} else { _inside = false; };
//diag_log ("isinBuilding Check: " + str(_inside) );
_inside

View File

@@ -1,10 +1,10 @@
/*
Description:
Removes the items (magazines) from the player's inventory
&& performs a double check for the required items.
and performs a double check for the required items.
Parameter(s):
_this: <array> list of item names to be removed (can also be an sub-array with item name && quantity)
_this: <array> list of item names to be removed (can also be an sub-array with item name and quantity)
Returns:
Boolean (true if all items have been removed from the player's inventory)

View File

@@ -0,0 +1,16 @@
private ["_object","_version","_PID"];
_object = _this select 0;
_version = productVersion select 3;
if (DayZ_UseSteamID) then {
_PID = GetPlayerUID _object;
} else {
if (_version >= 125548) then {
_PID = call (compile "GetPlayerUIDOld _object");
} else {
_PID = GetPlayerUID _object;
diag_log format["Your game version, %1, is less than the required for the old UID system; using Steam ID system instead. Update to 1.63.125548 (or latest steam beta)", _version];
};
};
_PID

View File

@@ -0,0 +1,11 @@
private "_pos";
if (isNil {_this select 0}) exitWith {[0,0,0]};
_thingy = _this select 0;
_pos = getPosASL _thingy;
if !(surfaceIsWater _pos) then {
_pos = ASLToATL _pos;
};
_pos

View File

@@ -0,0 +1,11 @@
//DO NOT USE IF YOU NEED ANGLE COMPENSATION!!!!
private "_pos";
_thingy = _this select 0;
_pos = getPosASL _thingy;
if (surfaceIsWater _pos) then {
_thingy setPosASL _pos;
} else {
_thingy setPosATL (ASLToATL _pos);
};

View File

@@ -1,16 +0,0 @@
private ["_spawnveh","_position","_direction","_veh"];
{
_spawnveh = _x select 0;
_position = _x select 1;
_direction = _x select 2;
//diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
_veh = _spawnveh createVehicleLocal _position;
_veh enableSimulation false;
// Randomize placement a bit
_veh setDir _direction;
_veh setpos _position;
} count _this;

View File

@@ -1,9 +0,0 @@
private["_type","_tent","_pos"];
_type = _this select 0;
_pos = _this select 1;
_tent = nearestObject [_type,_pos];
if (!isNull _tent) then {
if (local _tent) then {deleteVehicle _tent};
};

View File

@@ -1,5 +1,5 @@
private ["_nearByObjects","_targetObject","_error","_range","_objects"];
//Object Array, Range, Error Message (@Skaronator)
_objects = _this select 0;
_range = _this select 1;
_error = _this select 2;

View File

@@ -1,5 +0,0 @@
private ["_unit"];
_unit = _this select 0;
if (local _unit) then {
deleteVehicle _unit;
};

View File

@@ -1,58 +1,70 @@
/*
count player magazines with ammo count
value = call player_countMagazines;
value = call player_countMagazines; //must be called from a spawned thread (|| use spawn)
return all player magazines with ammo count
Modified to save backpack magazine count by icomrade - Base for fix by Ziellos2k
*/
private ["_dialog","_created","_magazineArray"];
private ["_control","_item","_val","_max","_count","_magazineArray","_dialog"];
disableSerialization;
disableUserInput true;
_dialog = findDisplay 106;
_created = false;
_magazineArray = [[],[]];
_dialog = ["0"] call gearDialog_create;
if ((isNull _dialog) || (isNil "_dialog")) exitWith {disableUserInput false; (findDisplay 106) closeDisplay 0; closeDialog 0; _magazineArray};
if ( isNull _dialog ) then {
//startLoadingScreen [""];
createGearDialog [player, "RscDisplayGear"];
_dialog = findDisplay 106;
_created = true;
};
_magazineArray = [];
for "_i" from 109 to 120 do
{
//Main inventory
for "_i" from 109 to 120 do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
for "_i" from 122 to 129 do
{
//Pistol/secondary ammo
for "_i" from 122 to 129 do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
if ( _created ) then {
closeDialog 0;
//endLoadingScreen;
//backpack items
if ((typeOf (unitBackPack player)) != "") then {
_count = getNumber (configFile >> "CfgVehicles" >> (typeOf (unitBackpack Player)) >> "transportMaxMagazines");
ctrlActivate (_dialog displayCtrl 157);
if (gear_done) then {
waitUntil {ctrlShown (_dialog displayCtrl 159)};
uiSleep 0.001;
};
for "_i" from 5000 to (5000 + _count) do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
(_magazineArray select 1) set [count (_magazineArray select 1),[_item,_val]];
} else {
(_magazineArray select 1) set [count (_magazineArray select 1),_item];
};
};
};
};
disableUserInput false;
_magazineArray
(findDisplay 106) closeDisplay 0;
if (gear_done) then {uiSleep 0.001;};
_magazineArray

View File

@@ -1,49 +0,0 @@
private ["_objects"];
_objects = nearestObjects [player, dayz_updateObjects, 10];
{
//["PVDZE_veh_Update",[_x,"gear"]] call callRpcProcedure;
PVDZE_veh_Update = [_x,"gear"];
publicVariableServer "PVDZE_veh_Update";
} count _objects;
private["_dialog","_magazineArray","_control","_item","_val","_max"];
disableSerialization;
_dialog = _this select 0;
_magazineArray = [];
//Primary Mags
for "_i" from 109 to 120 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_item == "BoltSteel") then { _item = "WoodenArrow" };
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
};
};
};
//Secondary Mags
for "_i" from 122 to 129 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
};
};
};
dayz_unsaved = true;
dayz_Magazines = _magazineArray;

View File

@@ -1,3 +1,4 @@
//Trader ["Trader City Name",false,"enter"] - Trader City Name | Show Message | "enter" || "leave"
private ["_traderName","_showText","_enterORleave"];
_traderName = _this select 0;
_showText = _this select 1;

View File

@@ -1,222 +0,0 @@
private ["_iPos","_tQty","_qty","_index","_weights","_cntWeights","_canType","_item","_magQty","_mags","_item2","_itemTypes","_max","_iItem","_iClass","_radius","_uniq","_iPosZ"];
_iItem = _this select 0;
_iClass = _this select 1;
_iPos = _this select 2;
_radius = _this select 3;
_uniq = [];
_item = objNull;
_iPosZ = _iPos select 2;
if((isNil "_iPosZ") || {( _iPosZ < 0)}) then { _iPos = [_iPos select 0,_iPos select 1,0]; };
if (isNil "_iClass") exitWith {diag_log "_iClass isNil, exiting loot spawn!";};
switch (_iClass) do {
default {
_itemTypes = [];
if (DZE_MissionLootTable) then {
{
_itemTypes set [count _itemTypes, _x select 0]
} count getArray (missionConfigFile >> "cfgLoot" >> _iClass);
} else {
{
_itemTypes set [count _itemTypes, _x select 0]
} count getArray (configFile >> "cfgLoot" >> _iClass);
};
_qty = 0;
_max = ceil(random 2) + 1;
if (_iClass in ["trash","civilian","office","office2","food","generic","medical","hospital","military","militarypilot","policeman","hunter","worker"]) then {
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
while {_qty < _max} do {
_index = dayz_CLBase find _iClass;
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
// diag_log ("dayz_CLChances: "+str(dayz_CLChances));
_index = floor(random _cntWeights);
_index = _weights select _index;
//diag_log ("dayz_CLChances: "+str(_itemTypes));
_canType = _itemTypes select _index;
_tQty = round(random 1) + 1;
if (_canType in _uniq) then {
if (({_x in _uniq} count magazines _item) == 0) then { _tQty = 1; } else { _tQty = 0;};
if (_tQty == 0) then {diag_log(format["%1 Prevent any duplicate member %2 from family %3",__FILE__, _canType, _uniq]);};
};
if (_tQty > 0) then {
if (!(_canType in _uniq)) then {
_item addMagazineCargoGlobal [_canType,1];
_uniq set [count _uniq, _canType];
_qty = _qty + 1;
};
};
};
if ((_iItem != "") && (isClass(configFile >> "CfgWeapons" >> _iItem))) then {
_item addWeaponCargoGlobal [_iItem,1];
};
}
else {
// diag_log format["DEBUG dayz_CLBase: %1", dayz_CLBase];
_index = dayz_CLBase find _iClass;
if (_index > 0) then {
_weights = dayz_CLChances select _index;
//diag_log format["DEBUG dayz_CLChances: %1", dayz_CLChances];
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_item2 = _itemTypes select _index;
if ((_item2 != "") && (isClass(configFile >> "CfgWeapons" >> _item2))) then{
_item = createVehicle["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal[_item2, 1];
if ((count _mags) > 0) then{
if (_mags select 0 == "20Rnd_556x45_Stanag") then{ _mags set[0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36") then{ _mags set[0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36SD") then{ _mags set[0, "30Rnd_556x45_StanagSD"] };
if (!(_item2 in MeleeWeapons)) then{
_magQty = round(random 10);
if (_magQty > 3) then{
_item addMagazineCargoGlobal[(_mags select 0), (round(random 1) + 1)];
};
};
};
};
if ((_item2 != "") && (isClass(configFile >> "CfgMagazines" >> _item2))) then{
_item = createVehicle["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addMagazineCargoGlobal[_item2, 1];
};
if ((_item2 != "") && (isClass(configFile >> "CfgVehicles" >> _item2))) then{
_item = createVehicle[_item2, _iPos, [], _radius, "CAN_COLLIDE"];
};
};
};
};
case "single":
{
//Item is sigle, add 1 item from cfgloot
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(missionConfigFile >> "cfgLoot" >> _iItem);
}
else {
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(configFile >> "cfgLoot" >> _iItem);
};
_index = dayz_CLBase find _iItem;
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_canType = _itemTypes select _index;
_item addMagazineCargoGlobal [_canType,1];
};
case "backpack":
{
//Item is single backpack
_itemTypes = [];
if (DZE_MissionLootTable) then {
_itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0);
} else {
_itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0);
};
_index = dayz_CLBase find _iItem;
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_iItem = _itemTypes select _index;
_item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
};
case "cfglootweapon":
{
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(missionConfigFile >> "cfgLoot" >> _iItem);
}
else {
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(configFile >> "cfgLoot" >> _iItem);
};
_index = dayz_CLBase find _iItem;
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_iItem = _itemTypes select _index;
if (_iItem == "Chainsaw") then {
_iItem = ["ChainSaw","ChainSawB","ChainSawG","ChainSawP","ChainSawR"] call BIS_fnc_selectRandom;
};
//Item is a weapon, add it && a random quantity of magazines
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
if ((count _mags) > 0) then
{
if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] };
_item addMagazineCargoGlobal [(_mags select 0), (round(random 2))];
};
};
case "weapon":
{
//Item is a weapon, add it && a random quantity of magazines
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
_mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines");
if ((count _mags) > 0) then
{
if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] };
if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] };
if (!(_iItem in MeleeWeapons)) then {
_magQty = round(random 10);
if (_magQty > 3) then {
_item addMagazineCargoGlobal [(_mags select 0), (round(random 1) + 1)];
};
};
};
};
case "weaponnomags":
{
//Item is a weapon, && spawns no mags
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
};
case "magazine":
{
//Item is one magazine
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addMagazineCargoGlobal [_iItem,1];
};
case "object": {
_item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
if ((count _iPos) > 2) then {
_item setPosATL _iPos;
};
};
};
if (!isNull(_item)) then{
if ((count _iPos) > 2) then{
_item setPosATL _iPos;
};
};
_item

View File

@@ -1,124 +0,0 @@
private ["_iItem","_iClass","_iPos","_radius","_item","_itemTypes","_index","_weights","_cntWeights","_canType","_dateNow"];
_iItem = _this select 0;
_iClass = _this select 1;
//diag_log format["DEBUG spawn loot class: %1", _iClass];
_iPos = _this select 2;
_radius = _this select 3;
_item = objNull;
switch (_iClass) do
{
default
{
//Item is sigle, add 1 item from CfgLootSmall
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(missionConfigFile >> "CfgLootSmall" >> _iClass);
}
else {
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(configFile >> "CfgLootSmall" >> _iClass);
};
_index = dayzE_CLSBase find _iClass;
_weights = dayzE_CLSChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_canType = _itemTypes select _index;
_item addMagazineCargoGlobal [_canType,1];
};
case "single":
{
//Item is sigle, add 1 item from CfgLootSmall
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(missionConfigFile >> "CfgLootSmall" >> _iItem);
}
else {
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(configFile >> "CfgLootSmall" >> _iItem);
};
_index = dayzE_CLSBase find _iItem;
_weights = dayzE_CLSChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_canType = _itemTypes select _index;
_item addMagazineCargoGlobal [_canType,1];
};
case "cfglootweapon":
{
//Item is sigle, add 1 item from cfgloot
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(missionConfigFile >> "CfgLootSmall" >> _iItem);
}
else {
{
_itemTypes set[count _itemTypes, _x select 0]
} count getArray(configFile >> "CfgLootSmall" >> _iItem);
};
_index = dayzE_CLSBase find _iItem;
_weights = dayzE_CLSChances select _index;
_cntWeights = count _weights;
//diag_log("_itemTypes small:" + str(_itemTypes));
_index = floor(random _cntWeights);
_index = _weights select _index;
_iItem = _itemTypes select _index;
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
};
case "weapon":
{
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addWeaponCargoGlobal [_iItem,1];
};
case "magazine":
{
//Item is one magazine
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addMagazineCargoGlobal [_iItem,1];
};
case "weaponnomags":
{
//do nothing for now
};
case "backpack":
{
//do nothing for now
};
case "object":
{
//do nothing for now
};
};
if (!isNull(_item)) then{
if ((count _iPos) > 2) then{
_item setPosATL _iPos;
};
};
_item

View File

@@ -37,8 +37,8 @@ if (local _unit) then {
_unit setHit [_selection, _total];
if (!isServer) then {
PVDZ_veh_Save = [_unit,"damage"];
publicVariableServer "PVDZ_veh_Save";
PVDZE_veh_Update = [_unit,"damage"];
publicVariableServer "PVDZE_veh_Update";
} else {
[_unit, "damage"] call server_updateObject;
};
@@ -47,8 +47,8 @@ if (local _unit) then {
//if ( (count _this > 5) AND {(_this select 5)}) then {
// vehicle is not local to this client, ask the client which vehicle is local to set damage
//_this resize 5; // delete "broadcast" boolean
PVDZ_send = [_unit,"VehHandleDam",_this];
publicVariableServer "PVDZ_send";
PVDZE_send = [_unit,"VehHandleDam",_this];
publicVariableServer "PVDZE_send";
//};
};

View File

@@ -1,14 +1,24 @@
private["_unit","_hitPoints","_selection","_killer"];
_unit = _this select 0;
//_killer = _this select 1;
_killer = _this select 1;
_hitPoints = _unit call vehicle_getHitpoints;
{
_selection = getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "HitPoints" >> _x >> "name");
_unit setVariable [_selection, 1, true];
} count _hitPoints;
// ask server to set global damage to 1, save to the hive
if (local _unit) then {
if (isServer) then {
[_unit, "killed"] call server_updateObject;
if (isServer) then {
[_unit, "killed"] call server_updateObject;
} else {
if (DZE_Debug_Damage && ((!isPlayer _unit) || ((isPlayer _unit) && (vehicle _unit != _unit) && (_unit != _killer)))) then {
PVDZE_veh_Update = [_unit, "killed",_killer];
} else {
PVDZ_veh_Save = [_unit, "killed"];
publicVariableServer "PVDZ_veh_Save";
PVDZE_veh_Update = [_unit, "killed"];
};
publicVariableServer "PVDZE_veh_Update";
};
// everyone removes their EH for this vehicle

View File

@@ -1,43 +0,0 @@
/***********************************************************
ASSIGN DAMAGE TO A UNIT
- Function Vehicle_HandleDamage
- [unit, selectionName, damage, source, projectile] call Vehicle_HandleDamage;
************************************************************/
private["_unit","_selection","_strH","_total","_damage","_needUpdate"];
_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
if (_selection != "") then {
_strH = "hit_" + _selection;
} else {
_strH = "totalDmg";
};
if (_total >= 0.98) then {
_total = 1.0;
};
if (local _unit) then {
if (_total > 0) then {
_unit setVariable [_strH, _total, true];
_unit setHit [_selection, _total];
if (isServer) then {
[_unit, "damage"] call server_updateObject;
} else {
PVDZE_veh_Update = [_unit,"damage"];
publicVariableServer "PVDZE_veh_Update";
};
};
} else {
// vehicle is not local to this client, ask the client which vehicle is local to set damage
/* PVS/PVC - Skaronator */
PVDZE_send = [_unit,"VehHandleDam",_this];
publicVariableServer "PVDZE_send";
};
// all "HandleDamage event" functions should return the effective damage that the engine will record for that part
_total

View File

@@ -1,29 +0,0 @@
private["_unit","_hitPoints","_selection","_killer"];
_unit = _this select 0;
_killer = _this select 1;
_hitPoints = _unit call vehicle_getHitpoints;
{
_selection = getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "HitPoints" >> _x >> "name");
_unit setVariable [_selection, 1, true];
} count _hitPoints;
//["PVDZE_veh_Update",[_unit, "damage"]] call callRpcProcedure;
if (isServer) then {
[_unit, "killed"] call server_updateObject;
} else {
if (DZE_Debug_Damage && ((!isPlayer _unit) || ((isPlayer _unit) && (vehicle _unit != _unit) && (_unit != _killer)))) then {
PVDZE_veh_Update = [_unit, "killed",_killer];
_killerVeh = if (vehicle _killer != _killer) then { format["[KILLER IN VEHICLE %1 OF TYPE %2]", (vehicle _killer), (typeOf (vehicle _killer))]; } else {""};
_name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
} else {
PVDZE_veh_Update = [_unit, "killed"];
};
publicVariableServer "PVDZE_veh_Update";
};
_unit removeAllEventHandlers "HandleDamage";
_unit removeAllEventHandlers "Killed";
_unit removeAllEventHandlers "GetIn";
_unit removeAllEventHandlers "GetOut";