From 8bf363c6c648345ac9b41b7b06d6c883236ed028 Mon Sep 17 00:00:00 2001 From: AsFoxy Date: Sun, 29 Nov 2015 16:13:06 +0200 Subject: [PATCH 1/2] Updated utils --- .../Configs/CfgVehicles/CrashSite.hpp | 4 +- SQF/dayz_code/loot/spawn.sqf | 2 +- SQF/dayz_code/util/Vector.hpp | 10 +++-- SQF/dayz_code/util/vector.sqf | 38 ++++++++++++++++++- .../compile/server_spawnCrashSites.sqf | 2 +- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/SQF/dayz_code/Configs/CfgVehicles/CrashSite.hpp b/SQF/dayz_code/Configs/CfgVehicles/CrashSite.hpp index 19edfac5..7f6122f7 100644 --- a/SQF/dayz_code/Configs/CfgVehicles/CrashSite.hpp +++ b/SQF/dayz_code/Configs/CfgVehicles/CrashSite.hpp @@ -25,7 +25,7 @@ class CrashSite_RU : CrashSite { scope = public; model = "\z\addons\dayz_communityassets\crashsite\mi8\mi8_ru.p3d"; - lootParams[] = {{0.6, -4.5, 0}, -7, 2.5, 5, 7}; + lootParams[] = {{0.6, -4.5, 0}, 7, 2.5, 5, 7}; }; class CrashSite_UN : CrashSite_RU @@ -46,5 +46,5 @@ class CrashSite_EU : CrashSite { scope = public; model = "\z\addons\dayz_communityassets\crashsite\hc3\hc3.p3d"; - lootParams[] = {{-0.4, -0.5, 0}, -4, 2.5, 7.5, 7}; + lootParams[] = {{-0.4, -0.5, 0}, 4, 2.5, 7.5, 7}; }; \ No newline at end of file diff --git a/SQF/dayz_code/loot/spawn.sqf b/SQF/dayz_code/loot/spawn.sqf index adb6a857..8c7b8496 100644 --- a/SQF/dayz_code/loot/spawn.sqf +++ b/SQF/dayz_code/loot/spawn.sqf @@ -91,7 +91,7 @@ switch (_lootInfo select 0) do _b = boundingBox _vehicle; _b = ((_b select 1) select 1) - ((_b select 0) select 1); - _d = Vector_Rotate(Vector_NORTH, random 360); + _d = Vector_Rotate2D(Vector_NORTH, random 360); _p = Vector_Subtract(_this select 1, Vector_Multiply_Fast(_d, _b)); _p = Vector_SetZ(_p, Vector_Z(_p) + Vector_Z(getPosATL _vehicle)); diff --git a/SQF/dayz_code/util/Vector.hpp b/SQF/dayz_code/util/Vector.hpp index 29efd202..93af4bd5 100644 --- a/SQF/dayz_code/util/Vector.hpp +++ b/SQF/dayz_code/util/Vector.hpp @@ -76,8 +76,12 @@ Author: Foxy #define Vector_FromDir(deg) ((deg) call dz_fn_vector_fromDir) #define Vector_FromDir_Fast(deg) [sin (deg), cos (deg), 0] -//Rotates the vector horizontally by the specified angle in degrees -#define Vector_Rotate(v, deg) ([v, deg] call dz_fn_vector_rotate) -#define Vector_Rotate_Fast(v, deg) [Vector_X(v) * cos (deg) - Vector_Y(v) * sin (deg), Vector_X(v) * sin (deg) + Vector_Y(v) * cos (deg), Vector_Z(v)] +//Rotates the vector around the global Z (up) axis by the specified angle in degrees +#define Vector_Rotate2D(v, deg) ([v, deg] call dz_fn_vector_rotate2d) +#define Vector_Rotate2D_Fast(v, deg) [Vector_X(v) * cos -(deg) - Vector_Y(v) * sin -(deg), Vector_X(v) * sin -(deg) + Vector_Y(v) * cos -(deg), Vector_Z(v)] + +//Rotates the vector around the specified axis by the specified angle in degrees, in three dimensions. +#define Vector_Rotate3D(v, u, deg) ([v, u, deg] call dz_fn_vector_rotate3d) +#define Vector_Rotate3D_Fast(v, u, deg) [((v)select0)*(((u)select0)^2*(1-cos(deg))+cos(deg))+((v)select1)*(((u)select0)*((u)select1)*(1-cos(deg))-((u)select2)*sin(deg))+((v)select2)*(((u)select0)*((u)select2)*(1-cos(deg))+((u)select1)*sin(deg)),((v)select0)*(((u)select1)*((u)select0)*(1-cos(deg))+((u)select2)*sin(deg))+((v)select1)*(((u)select1)^2*(1-cos(deg))+cos(deg))+((v)select2)*(((u)select1)*((u)select2)*(1-cos(deg))-((u)select0)*sin(deg)),((v)select0)*(((u)select2)*((u)select0)*(1-cos(deg))-((u)select1)*sin(deg))+((v)select1)*(((u)select2)*((u)select1)*(1-cos(deg))+((u)select0)*sin(deg))+((v)select2)*(((u)select2)^2*(1-cos(deg))+cos(deg))] #endif \ No newline at end of file diff --git a/SQF/dayz_code/util/vector.sqf b/SQF/dayz_code/util/vector.sqf index 7c17b052..bbf54bf0 100644 --- a/SQF/dayz_code/util/vector.sqf +++ b/SQF/dayz_code/util/vector.sqf @@ -14,4 +14,40 @@ dz_fn_vector_divide = { Vector_Divide_Fast(P0, P1); }; dz_fn_vector_angle = { Vector_Angle_Fast(P0, P1); }; dz_fn_vector_normalize = { Vector_Normalize_Fast(_this); }; dz_fn_vector_fromDir = { Vector_FromDir_Fast(_this); }; -dz_fn_vector_rotate = { Vector_Rotate_Fast(P0, P1); }; \ No newline at end of file +dz_fn_vector_rotate2d = { Vector_Rotate2D_Fast(P0, P1); }; + +dz_fn_vector_rotate3d = +{ + #define VX (_this select 0 select 0) + #define VY (_this select 0 select 1) + #define VZ (_this select 0 select 2) + #define UX (_this select 1 select 0) + #define UY (_this select 1 select 1) + #define UZ (_this select 1 select 2) + + private ["_sin", "_cos", "_icos"]; + _sin = sin (_this select 2); + _cos = cos (_this select 2); + _icos = 1 - _cos; + + [ + VX * ( UX ^ 2 * _icos + _cos ) + + VY * ( UX * UY * _icos - UZ * _sin ) + + VZ * ( UX * UZ * _icos + UY * _sin ) + , + VX * ( UY * UX * _icos + UZ * _sin ) + + VY * ( UY ^ 2 * _icos + _cos ) + + VZ * ( UY * UZ * _icos - UX * _sin ) + , + VX * ( UZ * UX * _icos - UY * _sin ) + + VY * ( UZ * UY * _icos + UX * _sin ) + + VZ * ( UZ ^ 2 * _icos + _cos ) + ] + + #undef VX + #undef VY + #undef VZ + #undef UX + #undef UY + #undef UZ +}; \ No newline at end of file diff --git a/SQF/dayz_server/compile/server_spawnCrashSites.sqf b/SQF/dayz_server/compile/server_spawnCrashSites.sqf index 81ad3941..37f906f3 100644 --- a/SQF/dayz_server/compile/server_spawnCrashSites.sqf +++ b/SQF/dayz_server/compile/server_spawnCrashSites.sqf @@ -84,7 +84,7 @@ _spawnCrashSite = _mag = random (_lootParams select 4); _lootPos = [((_lootParams select 2) + _mag) * sin _dir, ((_lootParams select 3) + _mag) * cos _dir, 0]; _lootPos = Vector_Add(_lootPos, _lootParams select 0); - _lootPos = Vector_Rotate(_lootPos, _lootParams select 1); + _lootPos = Vector_Rotate2D(_lootPos, _lootParams select 1); _lootPos = _vehicle modelToWorld _lootPos; _lootPos set [2, 0]; From 911f4390e1eeab62690537248607e963696200c0 Mon Sep 17 00:00:00 2001 From: AsFoxy Date: Sun, 29 Nov 2015 16:13:22 +0200 Subject: [PATCH 2/2] Updated loot --- SQF/dayz_code/Configs/CfgLoot/Buildings/Military.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SQF/dayz_code/Configs/CfgLoot/Buildings/Military.hpp b/SQF/dayz_code/Configs/CfgLoot/Buildings/Military.hpp index eca93335..d280302d 100644 --- a/SQF/dayz_code/Configs/CfgLoot/Buildings/Military.hpp +++ b/SQF/dayz_code/Configs/CfgLoot/Buildings/Military.hpp @@ -11,7 +11,7 @@ class Military : Default "z_new_worker3", "z_new_worker4" }; - lootChance = 0.2; + lootChance = 0.4; lootGroup = Military; }; @@ -26,7 +26,7 @@ class MilitarySpecial : Military "z_new_worker3", "z_new_worker4" }; - lootChance = 0.1; + lootChance = 0.4; lootGroup = MilitarySpecial; };