Skip to content

Commit 1e01536

Browse files
committed
Fix death cam height and rare duplicate weapon error
Prevent duplicate weapon error when player dies with same weapon in hands and on back
1 parent 5269f90 commit 1e01536

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

SQF/dayz_code/compile/fn_dropItem.sqf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
private ["_amount","_item","_pos","_nearByPile","_holder","_type"];
1+
private ["_amount","_item","_pos","_manualPos","_nearByPile","_holder","_type"];
22

33
//Radius to search for holder
44
#define PILE_SEARCH_RADIUS 2
@@ -8,11 +8,10 @@ private ["_amount","_item","_pos","_nearByPile","_holder","_type"];
88
_item = _this select 0;
99
_type = _this select 1;
1010
_amount = _this select 2;
11+
_manualPos = count _this > 3;
12+
_pos = if (_manualPos) then {_this select 3} else {player modeltoWorld PILE_OFFSET};
1113
_holder = objNull;
1214

13-
//Lets get the location of the player in the world
14-
_pos = player modeltoWorld PILE_OFFSET;
15-
1615
//Check if a holder is close by the player.
1716
_nearByPile= nearestObjects [_pos, ["WeaponHolder","WeaponHolderBase"],PILE_SEARCH_RADIUS];
1817

@@ -23,13 +22,15 @@ if (count _nearByPile == 0) then {
2322
//Found a near by weapon holder lets select it.
2423
_holder = _nearByPile select 0;
2524

26-
//check to make sure the player can see the selected weapon holder.
27-
_objects = lineIntersectsWith [(_holder modeltoWorld PILE_OFFSET), _pos, player, _holder, true];
28-
29-
//Can you see the current selected weapon holder
30-
if ((count _objects) > 0) then {
31-
//Unable to see the current selected weapon holder within the radius lets create a new one.
32-
_holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
25+
if (!_manualPos) then {
26+
//check to make sure the player can see the selected weapon holder.
27+
_objects = lineIntersectsWith [(_holder modeltoWorld PILE_OFFSET), _pos, player, _holder, true];
28+
29+
//Can you see the current selected weapon holder
30+
if (count _objects > 0) then {
31+
//Unable to see the current selected weapon holder within the radius lets create a new one.
32+
_holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
33+
};
3334
};
3435
};
3536

SQF/dayz_code/compile/player_death.sqf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (typeName (_this select 0) == "ARRAY") then {
1616
_killed = false;
1717
};
1818

19-
_deathPos = getPos _body;
19+
_deathPos = getPosATL _body;
2020
_playerID = getPlayerUID player;
2121

2222
//Switch view to camera so player does not see debug plains at respawn_west
@@ -25,7 +25,7 @@ _camera camSetDir 0;
2525
_camera camSetFOV 1;
2626
_camera cameraEffect ["Internal","TOP"];
2727
_camera camSetTarget _deathPos;
28-
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, 5];
28+
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, (_deathPos select 2) + 5];
2929
_camera camCommit 0;
3030

3131
if (!_killed) then {
@@ -34,7 +34,12 @@ if (!_killed) then {
3434
};
3535

3636
if (dayz_onBack != "") then {
37-
_body addWeapon dayz_onBack;
37+
if (dayz_onBack in weapons _body) then {
38+
//Prevent duplicate weapon error
39+
[dayz_onBack,2,1,[_deathPos select 0,_deathPos select 1,0]] call fn_dropItem;
40+
} else {
41+
_body addWeapon dayz_onBack;
42+
};
3843
};
3944

4045
//Get killer information immediately. Weapon, distance or vehicle can change in seconds.
@@ -53,7 +58,7 @@ _ammo = if (count _this > 2) then {_this select 2} else {""};
5358

5459
if (!isNull _source) then {
5560
if (!isNull _body) then {
56-
_distance = round (_body distance _source);
61+
_distance = round (_deathPos distance _source);
5762
};
5863

5964
_sourceVehicleType = typeOf (vehicle _source);
@@ -175,7 +180,7 @@ if ((_body == (vehicle _body)) && {_animState != "deadstate" && {_animCheck != "
175180
_deathPos = _this select 2;
176181

177182
waitUntil {camCommitted _camera};
178-
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, 15];
183+
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, (_deathPos select 2) + 15];
179184
_camera camCommit 4;
180185
uiSleep 5;
181186

0 commit comments

Comments
 (0)