mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-04 07:12:55 +03:00
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:
@@ -750,6 +750,7 @@ class Land_A_Crane_02b : Industrial
|
|||||||
{
|
{
|
||||||
maxRoaming = 0;
|
maxRoaming = 0;
|
||||||
lootChance = 0.4;
|
lootChance = 0.4;
|
||||||
|
fixWaterPos = 1;
|
||||||
lootPos[] =
|
lootPos[] =
|
||||||
{
|
{
|
||||||
{-3.4707,-0.149414,-6.06299},
|
{-3.4707,-0.149414,-6.06299},
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ class CfgLoot
|
|||||||
zombieChance = 0.2;
|
zombieChance = 0.2;
|
||||||
minRoaming = 0;
|
minRoaming = 0;
|
||||||
maxRoaming = 2;
|
maxRoaming = 2;
|
||||||
|
fixWaterPos = 0; // Add fixWaterPos = 1; to the building class that have floating loot if the building is over water.
|
||||||
|
|
||||||
zombieClass[] =
|
zombieClass[] =
|
||||||
{
|
{
|
||||||
// "zZombie_Base",
|
// "zZombie_Base",
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ Parameters:
|
|||||||
obj - building to spawn loot at
|
obj - building to spawn loot at
|
||||||
type - classname of building
|
type - classname of building
|
||||||
config - building configs (type, loot chance, loot positions. loot refresh timer)
|
config - building configs (type, loot chance, loot positions. loot refresh timer)
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
[building,classname,_config] call building_spawnLoot;
|
[building,classname,_config] call building_spawnLoot;
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
Foxy
|
Foxy
|
||||||
*/
|
*/
|
||||||
@@ -16,7 +16,7 @@ Author:
|
|||||||
#include "\z\addons\dayz_code\util\Vector.hpp"
|
#include "\z\addons\dayz_code\util\Vector.hpp"
|
||||||
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
||||||
|
|
||||||
private ["_vectorUp","_type","_config","_lootChance","_lootPos","_lootGroup","_worldPos","_existingPile","_loot","_group","_smallGroup"];
|
private ["_vectorUp","_obj","_config","_lootChance","_lootPos","_lootGroup","_worldPos","_group","_smallGroup","_type"];
|
||||||
|
|
||||||
_obj = _this select 0;
|
_obj = _this select 0;
|
||||||
_type = _this select 1;
|
_type = _this select 1;
|
||||||
@@ -44,7 +44,7 @@ if (_group in ["Military","MilitaryIndustrial"]) then {
|
|||||||
//Get the world position of the spawn position
|
//Get the world position of the spawn position
|
||||||
_worldPos = _obj modelToWorld _x;
|
_worldPos = _obj modelToWorld _x;
|
||||||
_worldPos set [2, 0 max (_worldPos select 2)];
|
_worldPos set [2, 0 max (_worldPos select 2)];
|
||||||
|
|
||||||
//Delete existing lootpiles within 1m of spawn location
|
//Delete existing lootpiles within 1m of spawn location
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
@@ -52,7 +52,7 @@ if (_group in ["Military","MilitaryIndustrial"]) then {
|
|||||||
} count (_worldPos nearObjects ["ReammoBox", 1]);
|
} count (_worldPos nearObjects ["ReammoBox", 1]);
|
||||||
|
|
||||||
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then {
|
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then {
|
||||||
Loot_SpawnGroup(_lootGroup, _worldPos);
|
Loot_SpawnGroup(_lootGroup, _worldPos, _type);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
foreach _lootPos;
|
foreach _lootPos;
|
||||||
@@ -63,13 +63,13 @@ foreach _lootPos;
|
|||||||
|
|
||||||
if (isArray (_config >> "lootPosSmall")) then {
|
if (isArray (_config >> "lootPosSmall")) then {
|
||||||
_lootPos = getArray (_config >> "lootPosSmall");
|
_lootPos = getArray (_config >> "lootPosSmall");
|
||||||
|
|
||||||
if (!isNil "_smallGroup") then {
|
if (!isNil "_smallGroup") then {
|
||||||
_lootGroup = Loot_GetGroup(_smallGroup);
|
_lootGroup = Loot_GetGroup(_smallGroup);
|
||||||
} else {
|
} else {
|
||||||
_lootGroup = Loot_GetGroup((_group) + "Small");
|
_lootGroup = Loot_GetGroup((_group) + "Small");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_lootGroup >= 1) then {
|
if (_lootGroup >= 1) then {
|
||||||
_lootPos = [_lootPos,5] call fn_shuffleArray;
|
_lootPos = [_lootPos,5] call fn_shuffleArray;
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ if (isArray (_config >> "lootPosSmall")) then {
|
|||||||
} count (_worldPos nearObjects ["ReammoBox", 1]);
|
} count (_worldPos nearObjects ["ReammoBox", 1]);
|
||||||
|
|
||||||
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then {
|
if (_lootChance > random 1 && {dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders}) then {
|
||||||
Loot_SpawnGroup(_lootGroup, _worldPos);
|
Loot_SpawnGroup(_lootGroup, _worldPos, _type);
|
||||||
};
|
};
|
||||||
} foreach _lootPos;
|
} foreach _lootPos;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
#define Loot_GetGroup(name) (dz_loot_groups find (name))
|
#define Loot_GetGroup(name) (dz_loot_groups find (name))
|
||||||
#define Loot_Select(group, count) ([group, count] call dz_fn_loot_select)
|
#define Loot_Select(group, count) ([group, count] call dz_fn_loot_select)
|
||||||
#define Loot_SelectSingle(group) (Loot_Select(group, 1) select 0)
|
#define Loot_SelectSingle(group) (Loot_Select(group, 1) select 0)
|
||||||
#define Loot_Spawn(def, loc) ([def, loc] call dz_fn_loot_spawn)
|
#define Loot_Spawn(def, loc, class) ([def, loc, class] call dz_fn_loot_spawn)
|
||||||
#define Loot_SpawnGroup(group, loc) ([group, loc] call dz_fn_loot_spawnGroup)
|
#define Loot_SpawnGroup(group, loc, class) ([group, loc, class] call dz_fn_loot_spawnGroup)
|
||||||
#define Loot_Insert(unit, group, count) ([unit, group, count] call dz_fn_loot_insert)
|
#define Loot_Insert(unit, group, count) ([unit, group, count] call dz_fn_loot_insert)
|
||||||
#define Loot_InsertCargo(object, group, count) ([object, group, count] call dz_fn_loot_insertCargo)
|
#define Loot_InsertCargo(object, group, count) ([object, group, count] call dz_fn_loot_insertCargo)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if (isServer) then {
|
|||||||
|
|
||||||
#include "\z\addons\dayz_code\Configs\CfgLoot\LootDefines.hpp"
|
#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_groups = [];
|
||||||
dz_loot_weighted = [];
|
dz_loot_weighted = [];
|
||||||
@@ -23,41 +23,42 @@ for "_i" from 0 to (count _cfgGroups) - 1 do {
|
|||||||
|
|
||||||
_cfg = _cfgGroups select _i;
|
_cfg = _cfgGroups select _i;
|
||||||
dz_loot_groups set [_i, configName _cfg];
|
dz_loot_groups set [_i, configName _cfg];
|
||||||
|
|
||||||
_lootGroup = getArray _cfg;
|
_lootGroup = getArray _cfg;
|
||||||
_weighted = [];
|
_weighted = [];
|
||||||
_count = 0;
|
_count = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Round the weight just in case somebody doesn't use a whole number.
|
// Round the weight just in case somebody doesn't use a whole number.
|
||||||
_weight = round(_x select 1);
|
_weight = round(_x select 1);
|
||||||
|
|
||||||
//Remove weight from _x
|
//Remove weight from _x
|
||||||
for "_j" from 1 to (count _x) - 2 do { _x set [_j, _x select (_j + 1)]; };
|
for "_j" from 1 to (count _x) - 2 do { _x set [_j, _x select (_j + 1)]; };
|
||||||
_x resize ((count _x) - 1);
|
_x resize ((count _x) - 1);
|
||||||
|
|
||||||
// Add resized group array to definitions array
|
// Add resized group array to definitions array
|
||||||
_index = count dz_loot_definitions;
|
_index = count dz_loot_definitions;
|
||||||
dz_loot_definitions set [_index, _x];
|
dz_loot_definitions set [_index, _x];
|
||||||
|
|
||||||
// Build weighted array for the group
|
// Build weighted array for the group
|
||||||
for "_j" from _count to (_count + _weight - 1) do {
|
for "_j" from _count to (_count + _weight - 1) do {
|
||||||
_weighted set [_j, _index];
|
_weighted set [_j, _index];
|
||||||
};
|
};
|
||||||
|
|
||||||
_count = _count + _weight;
|
_count = _count + _weight;
|
||||||
} count _lootGroup;
|
} count _lootGroup;
|
||||||
|
|
||||||
dz_loot_weighted set [_i, _weighted];
|
dz_loot_weighted set [_i, _weighted];
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
if !((_x select 0) in [0,2,3,5,6]) then { // skip types other than listed below
|
_type = _x select 0;
|
||||||
switch (_x select 0) do {
|
if !(_type in [0,2,3,5,6]) then { // skip types other than listed below
|
||||||
case Loot_GROUP: { _x set [1, dz_loot_groups find (_x select 1)]; };
|
call {
|
||||||
case Loot_PILE: { _x set [1, dz_loot_groups find (_x select 1)]; };
|
if (_type == Loot_GROUP) exitwith { _x set [1, dz_loot_groups find (_x select 1)]; };
|
||||||
case Loot_CONTAINER: { _x set [2, dz_loot_groups find (_x select 2)]; };
|
if (_type == Loot_PILE) exitwith { _x set [1, dz_loot_groups find (_x select 1)]; };
|
||||||
case Loot_CUSTOM: { _x set [1, compile (_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;
|
} count dz_loot_definitions;
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ Author:
|
|||||||
#define INCREMENT_WEAPON_HOLDERS dayz_currentWeaponHolders = dayz_currentWeaponHolders + 1;
|
#define INCREMENT_WEAPON_HOLDERS dayz_currentWeaponHolders = dayz_currentWeaponHolders + 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private ["_item","_isWater","_type","_lootInfo","_vehicle","_spawnCount","_magazines"];
|
private ["_item","_isWater","_type","_lootInfo","_vehicle","_spawnCount","_magazines","_fixWaterSpawn"];
|
||||||
|
|
||||||
_lootInfo = _this select 0;
|
_lootInfo = _this select 0;
|
||||||
_pos = _this select 1;
|
_pos = _this select 1;
|
||||||
|
_class = ["",_this select 2] select (count _this > 2);
|
||||||
_type = _lootInfo select 0;
|
_type = _lootInfo select 0;
|
||||||
_item = _lootInfo select 1;
|
_item = _lootInfo select 1;
|
||||||
_isWater = surfaceIsWater _pos;
|
_isWater = surfaceIsWater _pos;
|
||||||
@@ -45,8 +46,13 @@ call {
|
|||||||
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
||||||
_vehicle addMagazineCargoGlobal [_item, 1];
|
_vehicle addMagazineCargoGlobal [_item, 1];
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
@@ -59,8 +65,13 @@ call {
|
|||||||
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
||||||
_vehicle addWeaponCargoGlobal [_item, 1];
|
_vehicle addWeaponCargoGlobal [_item, 1];
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
@@ -82,8 +93,13 @@ call {
|
|||||||
// Fix floating backpacks by lowering z coordinate by .15 meters.
|
// Fix floating backpacks by lowering z coordinate by .15 meters.
|
||||||
_pos set [2, ((_pos select 2) - .15)];
|
_pos set [2, ((_pos select 2) - .15)];
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
@@ -95,11 +111,17 @@ call {
|
|||||||
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
_vehicle = "WeaponHolder" createVehicle [0,0,0];
|
||||||
Loot_InsertCargo(_vehicle, _item, _spawnCount);
|
Loot_InsertCargo(_vehicle, _item, _spawnCount);
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
INCREMENT_WEAPON_HOLDERS
|
INCREMENT_WEAPON_HOLDERS
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,8 +130,13 @@ call {
|
|||||||
_vehicle = _item createVehicle [0,0,0];
|
_vehicle = _item createVehicle [0,0,0];
|
||||||
_vehicle setDir random 360;
|
_vehicle setDir random 360;
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
@@ -124,11 +151,17 @@ call {
|
|||||||
Loot_InsertCargo(_vehicle, _lootInfo select 2, _spawnCount);
|
Loot_InsertCargo(_vehicle, _lootInfo select 2, _spawnCount);
|
||||||
_vehicle setDir random 360;
|
_vehicle setDir random 360;
|
||||||
|
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
INCREMENT_WEAPON_HOLDERS
|
INCREMENT_WEAPON_HOLDERS
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,8 +171,13 @@ call {
|
|||||||
if ((typeName _vehicle) != "OBJECT") exitWith {};
|
if ((typeName _vehicle) != "OBJECT") exitWith {};
|
||||||
|
|
||||||
if (!isNull _vehicle) then {
|
if (!isNull _vehicle) then {
|
||||||
if (_isWater) then {
|
if (_isWater) then {
|
||||||
_vehicle setPos (_pos);
|
_fixWaterSpawn = getNumber(missionconfigFile >> "CfgLoot" >> "Buildings" >> _class >> "fixWaterPos");
|
||||||
|
if (_fixWaterSpawn == 1) then {
|
||||||
|
_vehicle setPosASL (_pos);
|
||||||
|
} else {
|
||||||
|
_vehicle setPos (_pos);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
_vehicle setPosATL (_pos);
|
_vehicle setPosATL (_pos);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Spawns randomly selected loot from given group.
|
|||||||
Parameters:
|
Parameters:
|
||||||
integer Loot group index in dayz_lootGroups
|
integer Loot group index in dayz_lootGroups
|
||||||
vector Spawn position relative to world
|
vector Spawn position relative to world
|
||||||
|
class Classname of the object
|
||||||
|
|
||||||
Return value:
|
Return value:
|
||||||
object Spawned vehicle.
|
object Spawned vehicle.
|
||||||
@@ -14,5 +15,5 @@ Author:
|
|||||||
|
|
||||||
#include "Loot.hpp"
|
#include "Loot.hpp"
|
||||||
|
|
||||||
Loot_Spawn(Loot_Select(_this select 0, 1) select 0, _this select 1);
|
Loot_Spawn(Loot_Select(_this select 0, 1) select 0, _this select 1, _this select 2);
|
||||||
//[([_this select 0, 1] call loot_select) select 0, _this select 1] call loot_spawn
|
//[([_this select 0, 1] call loot_select) select 0, _this select 1, _this select 2] call loot_spawn
|
||||||
Reference in New Issue
Block a user