mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Fix ammo refill when switching skins and ...
- allow player to switch with backpack on. - player_countmagazines now returns backpack magazines with ammo count. Do with this as you like. - Make sure dead players do not have to wait the abort (after the 5 seconds). - Update changelog
This commit is contained in:
@@ -1,25 +1,20 @@
|
||||
private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_playerObjName","_wpnType","_ismelee","_tagSetting"];
|
||||
_class = _this;
|
||||
private ["_weapons","_backpackWpn","_backpackMag","_currentWpn","_backpackWpnTypes","_backpackWpnQtys","_countr","_class","_position","_dir","_currentAnim","_tagSetting","_playerUID","_countMags","_magazines","_primweapon","_secweapon","_newBackpackType","_muzzles","_oldUnit","_group","_newUnit","_playerObjName","_wpnType","_ismelee"];
|
||||
|
||||
_class = _this;
|
||||
_position = getPosATL player;
|
||||
_dir = getDir player;
|
||||
_currentAnim = animationState player;
|
||||
|
||||
_tagSetting = player getVariable["DZE_display_name",false];
|
||||
|
||||
//Get PlayerID
|
||||
_playerUID = getPlayerUID player;
|
||||
|
||||
//BackUp Weapons and Mags
|
||||
_weapons = weapons player;
|
||||
_magazines = call player_countmagazines; //magazines player;
|
||||
_countMags = call player_countMagazines;
|
||||
_magazines = _countMags select 0;
|
||||
|
||||
if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]};
|
||||
if ((_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]};
|
||||
|
||||
_primweapon = primaryWeapon player;
|
||||
_secweapon = secondaryWeapon player;
|
||||
|
||||
//Checks
|
||||
if(!(_primweapon in _weapons) && _primweapon != "") then {
|
||||
_weapons = _weapons + [_primweapon];
|
||||
};
|
||||
@@ -28,6 +23,14 @@ if(!(_secweapon in _weapons) && _secweapon != "") then {
|
||||
_weapons = _weapons + [_secweapon];
|
||||
};
|
||||
|
||||
//BackUp Backpack
|
||||
dayz_myBackpack = unitBackpack player;
|
||||
_newBackpackType = (typeOf dayz_myBackpack);
|
||||
if(_newBackpackType != "") then {
|
||||
_backpackWpn = getWeaponCargo unitBackpack player;
|
||||
_backpackMag = _countMags select 1;
|
||||
};
|
||||
|
||||
//Get Muzzle
|
||||
_currentWpn = currentWeapon player;
|
||||
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
|
||||
@@ -40,13 +43,12 @@ player setPosATL dayz_spawnPos;
|
||||
|
||||
//BackUp Player Object
|
||||
_oldUnit = player;
|
||||
|
||||
|
||||
/**********************************/
|
||||
//DONT USE player AFTER THIS POINT//
|
||||
/**********************************/
|
||||
|
||||
//Create New Character
|
||||
//[player] joinSilent grpNull;
|
||||
_group = createGroup west;
|
||||
_newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"];
|
||||
|
||||
@@ -59,9 +61,9 @@ removeAllWeapons _newUnit;
|
||||
|
||||
//Equip New Charactar
|
||||
{
|
||||
if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x };
|
||||
if (typeName _x == "ARRAY") then {if ((count _x) > 0) then {_newUnit addMagazine [(_x select 0), (_x select 1)]; }; } else { _newUnit addMagazine _x; };
|
||||
} forEach _magazines;
|
||||
|
||||
|
||||
{
|
||||
_newUnit addWeapon _x;
|
||||
} forEach _weapons;
|
||||
@@ -78,11 +80,10 @@ if(str(_weapons) != str(weapons _newUnit)) then {
|
||||
_newUnit addWeapon _x;
|
||||
} forEach _weapons;
|
||||
};
|
||||
|
||||
|
||||
if(_primweapon != (primaryWeapon _newUnit)) then {
|
||||
_newUnit addWeapon _primweapon;
|
||||
};
|
||||
|
||||
if (_primweapon == "MeleeCrowbar") then {
|
||||
_newUnit addMagazine 'crowbar_swing';
|
||||
};
|
||||
@@ -102,25 +103,53 @@ if (_primweapon == "MeleeFishingPole") then {
|
||||
if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
|
||||
_newUnit addWeapon _secweapon;
|
||||
};
|
||||
|
||||
//Make New Unit Playable
|
||||
addSwitchableUnit _newUnit;
|
||||
setPlayable _newUnit;
|
||||
selectPlayer _newUnit;
|
||||
|
||||
//Clear and delete old Unit
|
||||
removeAllWeapons _oldUnit;
|
||||
{_oldUnit removeMagazine _x;} forEach magazines _oldUnit;
|
||||
|
||||
deleteVehicle _oldUnit;
|
||||
|
||||
//Move player inside
|
||||
|
||||
if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
|
||||
_switchUnit = {
|
||||
addSwitchableUnit _newUnit;
|
||||
setPlayable _newUnit;
|
||||
selectPlayer _newUnit;
|
||||
removeAllWeapons _oldUnit;
|
||||
{_oldUnit removeMagazine _x;} forEach magazines _oldUnit;
|
||||
deleteVehicle _oldUnit;
|
||||
if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
|
||||
};
|
||||
//Add and Fill BackPack
|
||||
if (!isNil "_newBackpackType") then {
|
||||
if (_newBackpackType != "") then {
|
||||
_newUnit addBackpack _newBackpackType;
|
||||
dayz_myBackpack = unitBackpack _newUnit;
|
||||
//Weapons
|
||||
_backpackWpnTypes = [];
|
||||
_backpackWpnQtys = [];
|
||||
if (count _backpackWpn > 0) then {
|
||||
_backpackWpnTypes = _backpackWpn select 0;
|
||||
_backpackWpnQtys = _backpackWpn select 1;
|
||||
};
|
||||
[] call _switchUnit;
|
||||
if (gear_done) then {sleep 0.001;};
|
||||
["1"] call gearDialog_create;
|
||||
//magazines
|
||||
_countr = 0;
|
||||
{
|
||||
_countr = _countr + 1;
|
||||
if ((typeName _x) != "STRING") then {
|
||||
(unitBackpack player) addMagazineCargoGlobal [(_x select 0), 1];
|
||||
_idc = 4999 + _countr;
|
||||
_idc setIDCAmmoCount (_x select 1);
|
||||
} else {
|
||||
(unitBackpack player) addMagazineCargoGlobal [_x, 1];
|
||||
};
|
||||
} forEach _backpackMag;
|
||||
(findDisplay 106) closeDisplay 0;
|
||||
_countr = 0;
|
||||
{
|
||||
(unitBackpack player) addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
|
||||
_countr = _countr + 1;
|
||||
} forEach _backpackWpnTypes;
|
||||
} else { [] call _switchUnit; };
|
||||
} else { [] call _switchUnit; };
|
||||
[objNull, player, rSwitchMove,_currentAnim] call RE;
|
||||
//dayz_originalPlayer attachTo [_newUnit];
|
||||
player disableConversation true;
|
||||
|
||||
|
||||
//player setVariable ["bodyName",dayz_playerName,true]; //Outcommit (Issue #991) - Also removed in DayZ Mod 1.8
|
||||
|
||||
if (_tagSetting) then {
|
||||
@@ -131,13 +160,13 @@ _playerUID = getPlayerUID player;
|
||||
_playerObjName = format["PVDZE_player%1",_playerUID];
|
||||
call compile format["%1 = player;",_playerObjName];
|
||||
publicVariableServer _playerObjName; //Outcommit in DayZ 1.8 No clue for what this is - Skaronator
|
||||
|
||||
|
||||
//melee check
|
||||
_wpnType = primaryWeapon player;
|
||||
_ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));
|
||||
if (_ismelee == "true") then {
|
||||
call dayz_meleeMagazineCheck;
|
||||
};
|
||||
|
||||
|
||||
//reveal the same objects we do on login
|
||||
{player reveal _x} forEach (nearestObjects [getPosATL player, dayz_reveal, 50]);
|
||||
Reference in New Issue
Block a user