Partly fix floating loot

This commit fixes partly the floating loot issue. The whole problem is not fixable. It is a problem with different components. The main point is that the position can be half water and half not. The second is the building collision and the collision of the loot object. Normally setPosATL should do its work but the object moves on the placement. Adding a special handling for buildings that are mostly over water did the best job so far.
With fixWaterPos = 1; in the building class which has those floating loot problems, the position gets converted to ASL which is better over water but not always. Some loot objects are still floating a bit but I could reach all of them. It is a way better as before.
This commit is contained in:
AirwavesMan
2020-09-15 19:55:17 +02:00
parent 7f86b09f4c
commit 89bca2c94b
7 changed files with 84 additions and 41 deletions

View File

@@ -11,7 +11,7 @@ if (isServer) then {
#include "\z\addons\dayz_code\Configs\CfgLoot\LootDefines.hpp"
private ["_cfgGroups","_cfg","_lootGroup","_weight","_weighted","_index","_count"];
private ["_cfgGroups","_cfg","_lootGroup","_weight","_weighted","_index","_count","_type"];
dz_loot_groups = [];
dz_loot_weighted = [];
@@ -23,41 +23,42 @@ for "_i" from 0 to (count _cfgGroups) - 1 do {
_cfg = _cfgGroups select _i;
dz_loot_groups set [_i, configName _cfg];
_lootGroup = getArray _cfg;
_weighted = [];
_count = 0;
{
// Round the weight just in case somebody doesn't use a whole number.
_weight = round(_x select 1);
//Remove weight from _x
for "_j" from 1 to (count _x) - 2 do { _x set [_j, _x select (_j + 1)]; };
_x resize ((count _x) - 1);
// Add resized group array to definitions array
_index = count dz_loot_definitions;
dz_loot_definitions set [_index, _x];
// Build weighted array for the group
for "_j" from _count to (_count + _weight - 1) do {
_weighted set [_j, _index];
};
_count = _count + _weight;
} count _lootGroup;
dz_loot_weighted set [_i, _weighted];
};
{
if !((_x select 0) in [0,2,3,5,6]) then { // skip types other than listed below
switch (_x select 0) do {
case Loot_GROUP: { _x set [1, dz_loot_groups find (_x select 1)]; };
case Loot_PILE: { _x set [1, dz_loot_groups find (_x select 1)]; };
case Loot_CONTAINER: { _x set [2, dz_loot_groups find (_x select 2)]; };
case Loot_CUSTOM: { _x set [1, compile (_x select 1)]; };
_type = _x select 0;
if !(_type in [0,2,3,5,6]) then { // skip types other than listed below
call {
if (_type == Loot_GROUP) exitwith { _x set [1, dz_loot_groups find (_x select 1)]; };
if (_type == Loot_PILE) exitwith { _x set [1, dz_loot_groups find (_x select 1)]; };
if (_type == Loot_CONTAINER) exitwith { _x set [2, dz_loot_groups find (_x select 2)]; };
if (_type == Loot_CUSTOM) exitwith { _x set [1, compile (_x select 1)]; };
};
};
} count dz_loot_definitions;