Skip to content

Commit

Permalink
Fix death cam height and rare duplicate weapon error
Browse files Browse the repository at this point in the history
Prevent duplicate weapon error when player dies with same weapon in
hands and on back
  • Loading branch information
ebayShopper committed Dec 5, 2017
1 parent 5269f90 commit 1e01536
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
23 changes: 12 additions & 11 deletions SQF/dayz_code/compile/fn_dropItem.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
private ["_amount","_item","_pos","_nearByPile","_holder","_type"];
private ["_amount","_item","_pos","_manualPos","_nearByPile","_holder","_type"];

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

//Lets get the location of the player in the world
_pos = player modeltoWorld PILE_OFFSET;

//Check if a holder is close by the player.
_nearByPile= nearestObjects [_pos, ["WeaponHolder","WeaponHolderBase"],PILE_SEARCH_RADIUS];

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

//check to make sure the player can see the selected weapon holder.
_objects = lineIntersectsWith [(_holder modeltoWorld PILE_OFFSET), _pos, player, _holder, true];

//Can you see the current selected weapon holder
if ((count _objects) > 0) then {
//Unable to see the current selected weapon holder within the radius lets create a new one.
_holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
if (!_manualPos) then {
//check to make sure the player can see the selected weapon holder.
_objects = lineIntersectsWith [(_holder modeltoWorld PILE_OFFSET), _pos, player, _holder, true];

//Can you see the current selected weapon holder
if (count _objects > 0) then {
//Unable to see the current selected weapon holder within the radius lets create a new one.
_holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
};
};
};

Expand Down
15 changes: 10 additions & 5 deletions SQF/dayz_code/compile/player_death.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (typeName (_this select 0) == "ARRAY") then {
_killed = false;
};

_deathPos = getPos _body;
_deathPos = getPosATL _body;
_playerID = getPlayerUID player;

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

if (!_killed) then {
Expand All @@ -34,7 +34,12 @@ if (!_killed) then {
};

if (dayz_onBack != "") then {
_body addWeapon dayz_onBack;
if (dayz_onBack in weapons _body) then {
//Prevent duplicate weapon error
[dayz_onBack,2,1,[_deathPos select 0,_deathPos select 1,0]] call fn_dropItem;
} else {
_body addWeapon dayz_onBack;
};
};

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

if (!isNull _source) then {
if (!isNull _body) then {
_distance = round (_body distance _source);
_distance = round (_deathPos distance _source);
};

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

waitUntil {camCommitted _camera};
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, 15];
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, (_deathPos select 2) + 15];
_camera camCommit 4;
uiSleep 5;

Expand Down

0 comments on commit 1e01536

Please sign in to comment.