Cleanup player_switchModel

This commit is contained in:
ebaydayz
2016-03-21 20:25:01 -04:00
parent e2e6e79394
commit cc64d2e7fb
4 changed files with 122 additions and 218 deletions

View File

@@ -10,12 +10,12 @@ player removeEventHandler ["HandleDamage",mydamage_eh1];
player removeEventHandler ["Killed",mydamage_eh3];
player removeEventHandler ["Fired",mydamage_eh2];
_updates = player getVariable["updatePlayer",[false,false,false,false,false]];
_updates = player getVariable ["updatePlayer",[false,false,false,false,false]];
_updates set [0,true];
player setVariable["updatePlayer",_updates,true];
player setVariable ["updatePlayer",_updates,true];
dayz_unsaved = true;
//Logout
_humanity = player getVariable["humanity",0];
_humanity = player getVariable ["humanity",0];
_medical = player call player_sumMedical;
_worldspace = [round(direction player),getPosATL player];
_zombieKills = player getVariable ["zombieKills",0];
@@ -24,6 +24,7 @@ _humanKills = player getVariable ["humanKills",0];
_banditKills = player getVariable ["banditKills",0];
_achievements = player getVariable ["Achievements",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
_friendlies = player getVariable ["friendlies",[]];
_tagSetting = player getVariable ["DZE_display_name",false];
//Switch
_switch = _model spawn player_switchModel;
@@ -33,24 +34,24 @@ waitUntil { scriptDone _switch };
//set medical values
if (count _medical > 0) then {
player setVariable["USEC_isDead",(_medical select 0),true];
player setVariable["NORRN_unconscious",(_medical select 1), true];
player setVariable["USEC_infected",(_medical select 2),true];
player setVariable["USEC_injured",(_medical select 3),true];
player setVariable["USEC_inPain",(_medical select 4),true];
player setVariable["USEC_isCardiac",(_medical select 5),true];
player setVariable["USEC_lowBlood",(_medical select 6),true];
player setVariable["USEC_BloodQty",(_medical select 7),true];
player setVariable["unconsciousTime",(_medical select 10),true];
player setVariable["blood_type",(_medical select 11),true];
player setVariable["rh_factor",(_medical select 12),true];
player setVariable["messing",(_medical select 13),true];
player setVariable["blood_testdone",(_medical select 14),true];
player setVariable ["USEC_isDead",(_medical select 0),true];
player setVariable ["NORRN_unconscious",(_medical select 1), true];
player setVariable ["USEC_infected",(_medical select 2),true];
player setVariable ["USEC_injured",(_medical select 3),true];
player setVariable ["USEC_inPain",(_medical select 4),true];
player setVariable ["USEC_isCardiac",(_medical select 5),true];
player setVariable ["USEC_lowBlood",(_medical select 6),true];
player setVariable ["USEC_BloodQty",(_medical select 7),true];
player setVariable ["unconsciousTime",(_medical select 10),true];
player setVariable ["blood_type",(_medical select 11),true];
player setVariable ["rh_factor",(_medical select 12),true];
player setVariable ["messing",(_medical select 13),true];
player setVariable ["blood_testdone",(_medical select 14),true];
//Add Wounds
{
//diag_log format ["loop _x:1 wound:%2",_x, (USEC_typeOfWounds select _forEachIndex)];
player setVariable["hit_"+_x,true,true];
player setVariable ["hit_"+_x,true,true];
PVDZ_hlt_Bleed = [player, _x, 1];
publicVariable "PVDZ_hlt_Bleed";
} forEach (_medical select 8);
@@ -70,15 +71,16 @@ if (count _medical > 0) then {
};
//General Stats
player setVariable["humanity",_humanity,true];
player setVariable["zombieKills",_zombieKills,true];
player setVariable["headShots",_headShots,true];
player setVariable["humanKills",_humanKills,true];
player setVariable["banditKills",_banditKills,true];
player setVariable["characterID",_charID,true];
player setVariable["worldspace",_worldspace];
player setVariable["Achievements",_achievements];
player setVariable["friendlies",_friendlies,true];
player setVariable ["humanity",_humanity,true];
player setVariable ["zombieKills",_zombieKills,true];
player setVariable ["headShots",_headShots,true];
player setVariable ["humanKills",_humanKills,true];
player setVariable ["banditKills",_banditKills,true];
player setVariable ["characterID",_charID,true];
player setVariable ["worldspace",_worldspace];
player setVariable ["Achievements",_achievements];
player setVariable ["friendlies",_friendlies,true];
player setVariable ["DZE_display_name",_tagSetting,true];
PVDZ_serverStoreVar = [player,"Achievements",_achievements];
publicVariableServer "PVDZ_serverStoreVar";

View File

@@ -3,50 +3,38 @@
*/
if (DZE_ActionInProgress) exitWith {cutText [localize "str_epoch_player_13","PLAIN DOWN"];};
DZE_ActionInProgress = true;
_obj = _this;
_ownerID = _obj getVariable["CharacterID","0"];
_objectID = _obj getVariable["ObjectID","0"];
_objectUID = _obj getVariable["ObjectUID","0"];
_pickup = false;
_packobj = getText (configFile >> "CfgVehicles" >> typeOf _obj >> "pack");
_activatingPlayer = player;
_packobj = getText (configFile >> "CfgVehicles" >> typeOf _obj >> "pack");
player playActionNow "Medic";
player removeAction s_player_packtent;
s_player_packtent = -1;
player removeAction s_player_packtentinfected;
s_player_packtentinfected = -1;
if (_objectID == "0" && _objectUID == "0") exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; cutText [localize "str_epoch_player_14","PLAIN DOWN"];};
if (_ownerID != dayz_characterID) exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; cutText [localize "str_fail_tent_pack", "PLAIN DOWN"];};
_alreadyPacking = _obj getVariable["packing",0];
if (_alreadyPacking == 1) exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; s_player_packtentinfected = -1; cutText [format[(localize "str_player_beingpacked")] , "PLAIN DOWN"]};
_campitems = ["IC_DomeTent","IC_Tent"];
if (_ownerID == dayz_characterID or (typeOf _obj in _campitems)) then { _pickup = true; };
_campItems = ["IC_DomeTent","IC_Tent"];
if (_ownerID == dayz_characterID or (typeOf _obj in _campItems)) then { _pickup = true; };
if (_pickup) then {
_alreadyPacking = _obj getVariable["packing",0];
if (_alreadyPacking == 1) exitWith {cutText [format [localize "str_player_beingpacked"],"PLAIN DOWN"]; DZE_ActionInProgress = false;};
_obj setVariable["packing",1];
_dir = direction _obj;
_pos = getposATL _obj;
_dis=20;
_sfx = "tentpack";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] call player_alertZombies;
_pos = getPosATL _obj;
[player,"tentpack",0,false,20] call dayz_zombieSpeak;
[player,20,true,getPosATL player] call player_alertZombies;
uiSleep 3;
//place tent (local)
_bag = createVehicle [_packobj,_pos,[], 0, "CAN_COLLIDE"];
_bag setdir _dir;
_bag = createVehicle [_packobj, _pos, [], 0, "CAN_COLLIDE"];
_bag setDir _dir;
player reveal _bag;
_holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
@@ -55,14 +43,10 @@ if (_pickup) then {
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
//["PVDZ_obj_Delete",[_objectID,_objectUID]] call callRpcProcedure;
_activatingPlayer = player;
PVDZ_obj_Destroy = [_objectID,_objectUID, _activatingPlayer];
PVDZ_obj_Destroy = [_objectID,_objectUID,_activatingPlayer];
publicVariableServer "PVDZ_obj_Destroy";
if (isServer) then {
PVDZ_obj_Destroy call server_deleteObj;
};
if (isServer) then {PVDZ_obj_Destroy call server_deleteObj;};
deleteVehicle _obj;
//Add weapons
@@ -70,31 +54,30 @@ if (_pickup) then {
_objWpnQty = _weapons select 1;
_countr = 0;
{
_holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
_holder addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
} count _objWpnTypes;
//Add Magazines
_objWpnTypes = _magazines select 0;
_objWpnQty = _magazines select 1;
_countr = 0;
{
_holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
_holder addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
} count _objWpnTypes;
//Add Backpacks
_objWpnTypes = _backpacks select 0;
_objWpnQty = _backpacks select 1;
_countr = 0;
{
_holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
_holder addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
} count _objWpnTypes;
cutText [localize "str_success_tent_pack", "PLAIN DOWN"];
} else {
cutText [localize "str_fail_tent_pack", "PLAIN DOWN"];
};
s_player_packtent = -1;
DZE_ActionInProgress = false;

View File

@@ -1,62 +1,44 @@
//private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_backpackWpnTypes","_backpackWpnQtys","_countr","_backpackmagTypes","_backpackmagQtys","_display","_createSafePos","_wpnType","_ismelee","_rndx","_rndy"];
private ["_class","_position","_dir","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_currentWpn","_muzzles","_display","_oldUnit","_newUnit","_backpackWpnTypes","_backpackWpnQtys","_countr","_createSafePos","_rndx","_rndy","_isWeapon","_idc","_switchUnit","_tagSetting","_countMags","_group"];
private ["_class","_position","_dir","_currentAnim","_currentCamera","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_currentWpn","_muzzles","_display","_oldUnit","_newUnit","_oldBackpack","_backpackWpnTypes","_backpackWpnQtys","_countr","_backpackmagTypes","_backpackmagQtys","_backpackmag","_createSafePos","_rndx","_rndy","_playerObjName","_wpnType","_ismelee"];
_class = _this;
_tagSetting = player getVariable["DZE_display_name",false];
disableSerialization;
//Old location system causes issues with players getting damaged during movement.
//_position = getPosATL player;
//New system testing needed.
_position = player modeltoWorld [0,0,0];
_dir = getDir player;
_currentAnim = animationState player;
//_currentCamera = cameraView;
//Get PlayerID
_playerUID = [player] call FNC_GetPlayerUID;
_playerUID = [player] call FNC_GetPlayerUID;
//BackUp Weapons and Mags
_weapons = weapons player;
_countMags = call player_countMagazines;
_magazines = _countMags select 0;
_weapons = weapons player;
_magazines = call player_countMagazines; //magazines player;
if ((_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0)) exitWith {cutText [localize "str_actions_switchmodel_fail", "PLAIN DOWN"]};
if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [localize "str_actions_switchmodel_fail", "PLAIN DOWN"]};
_primweapon = primaryWeapon player;
_secweapon = secondaryWeapon player;
if (!(_primweapon in _weapons) && _primweapon != "") then {
_weapons set [count _weapons, _primweapon];
};
//if ( count _magazines == 0 ) exitWith {cutText ["can't count magazines!", "PLAIN DOWN"]};
_primweapon = primaryWeapon player;
_secweapon = secondaryWeapon player;
//Checks
if(!(_primweapon in _weapons) && _primweapon != "") then {
_weapons set [(count _weapons), _primweapon];
};
if(!(_secweapon in _weapons) && _secweapon != "") then {
_weapons set [(count _weapons), _secweapon];
};
// if(count _magazines == 0) then {
// _magazines = magazines player;
// };
if (!(_secweapon in _weapons) && _secweapon != "") then {
_weapons set [count _weapons, _secweapon];
};
//BackUp Backpack
dayz_myBackpack = unitBackpack player;
_newBackpackType = (typeOf dayz_myBackpack);
if(_newBackpackType != "") then {
_newBackpackType = typeOf dayz_myBackpack;
if (_newBackpackType != "") then {
_backpackWpn = getWeaponCargo unitBackpack player;
_backpackMag = _countMags select 1;
_backpackMag = getMagazineCargo unitBackpack player;
};
//Get Muzzle
_currentWpn = currentWeapon player;
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
_currentWpn = currentMuzzle player;
};
if (count _muzzles > 1) then {_currentWpn = currentMuzzle player;};
//Debug Message
// diag_log "Attempting to switch model";
@@ -66,14 +48,14 @@ if (count _muzzles > 1) then {
// diag_log (str(_backpackMag));
//Secure Player for Transformation
//player setPosATL dayz_spawnPos;
//player setPosATL dayz_spawnPos;
//Prevent client crash...
_display = findDisplay 106;
_display closeDisplay 0;
//Prevent client crash
_display = findDisplay 106;
_display closeDisplay 0;
//BackUp Player Object
_oldUnit = player;
_oldUnit = player;
/***********************************/
//DONT USE player AFTER THIS POINT
@@ -83,148 +65,103 @@ if (count _muzzles > 1) then {
//[player] joinSilent grpNull;
_group = createGroup west;
_newUnit = _group createUnit [_class,getMarkerPos "respawn_west",[],0,"NONE"];
_newUnit setDir _dir;
{_newUnit removeMagazine _x;} count magazines _newUnit;
removeAllWeapons _newUnit;
_newUnit setVariable ["DZE_display_name", _tagSetting, true];
//Clear New Character
{_newUnit removeMagazine _x;} count magazines _newUnit;
removeAllWeapons _newUnit;
//Equip New Charactar
//Equip New Character
{
if (typeName _x == "ARRAY") then {if ((count _x) > 0) then {_newUnit addMagazine [(_x select 0), (_x select 1)]; }; } else { _newUnit addMagazine _x; };
if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x };
} count _magazines;
{
_newUnit addWeapon _x;
} count _weapons;
{_newUnit addWeapon _x;} count _weapons;
//Check && Compare it
if(str(_weapons) != str(weapons _newUnit)) then {
//Check and Compare it
if (str(_weapons) != str(weapons _newUnit)) then {
//Get Differecnce
{
_weapons = _weapons - [_x];
} count (weapons _newUnit);
{_weapons = _weapons - [_x];} count (weapons _newUnit);
//Add the Missing
{
_newUnit addWeapon _x;
} count _weapons;
{_newUnit addWeapon _x;} count _weapons;
};
if(_primweapon != (primaryWeapon _newUnit)) then {
_newUnit addWeapon _primweapon;
};
if (_primweapon == "MeleeCrowbar") then {
_newUnit addMagazine 'Crowbar_Swing';
};
if (_primweapon == "MeleeSledge") then {
_newUnit addMagazine 'Sledge_Swing';
};
if (_primweapon == "MeleeHatchet_DZE") then {
_newUnit addMagazine 'Hatchet_Swing';
};
if (_primweapon == "MeleeMachete") then {
_newUnit addMagazine 'Machete_swing';
};
if (_primweapon == "MeleeFishingPole") then {
_newUnit addMagazine 'Fishing_Swing';
if (_primweapon != (primaryWeapon _newUnit)) then {
_newUnit addWeapon _primweapon;
};
if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
_newUnit addWeapon _secweapon;
if (_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
_newUnit addWeapon _secweapon;
};
//Add and Fill BackPack
if (!isNil "_newBackpackType") then {
if (_newBackpackType != "") then {
_newUnit addBackpack _newBackpackType;
//_oldBackpack = dayz_myBackpack;
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 {uiSleep 0.001;};
["1"] call gearDialog_create;
if (gear_done) then {uiSleep 0.001;};
//magazines
_countr = 0;
{
if ((typeName _x) != "STRING") then {
_isWeapon = (isClass(configFile >> "CfgWeapons" >> (_x select 0)));
} else {
_isWeapon = (isClass(configFile >> "CfgWeapons" >> _x));
};
if (!_isWeapon) then {
_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];
};
};
} count _backpackMag;
(findDisplay 106) closeDisplay 0;
if (gear_done) then {uiSleep 0.001; disableUserInput false;};
_countr = 0;
{
(unitBackpack player) addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
dayz_myBackpack addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
_countr = _countr + 1;
} count _backpackWpnTypes;
_backpackmagTypes = [];
_backpackmagQtys = [];
if (count _backpackmag > 0) then {
_backpackmagTypes = _backpackMag select 0;
_backpackmagQtys = _backpackMag select 1;
};
_countr = 0;
{
dayz_myBackpack addmagazineCargoGlobal [_x,(_backpackmagQtys select _countr)];
_countr = _countr + 1;
} count _backpackmagTypes;
};
};
//Debug Message
//diag_log "Swichtable Unit Created. Equipment:";
//diag_log str(weapons _newUnit);
//diag_log str(magazines _newUnit);
//diag_log str(getWeaponCargo unitBackpack _newUnit);
//diag_log str(getMagazineCargo unitBackpack _newUnit);
diag_log "Swichtable Unit Created. Equipment:";
diag_log str(weapons _newUnit);
diag_log str(magazines _newUnit);
diag_log str(getWeaponCargo unitBackpack _newUnit);
diag_log str(getMagazineCargo unitBackpack _newUnit);
//Make New Unit Playable (1 of these 3 commands causes crashes with gear dialog open)
//_oldUnit setPosATL [_position select 0 + cos(_dir) * 2, _position select 1 + sin(_dir) * 2, _position select 2];
addSwitchableUnit _newUnit;
setPlayable _newUnit;
selectPlayer _newUnit;
//_oldUnit setPosATL [_position select 0 + cos(_dir) * 2, _position select 1 + sin(_dir) * 2, _position select 2];
addSwitchableUnit _newUnit;
setPlayable _newUnit;
selectPlayer _newUnit;
//Switch the units
//_createSafePos = [(getMarkerPos "respawn_west"), 2, 100, 0, 1, 20, 0] call BIS_fnc_findSafePos;
_createSafePos = getMarkerPos "respawn_west";
_rndx = floor(random 100);
_rndy = floor(random 100);
_oldUnit setPosATL [(_createSafePos select 0) + _rndx, (_createSafePos select 1) + _rndy, 0];
_newUnit setPosATL _position;
//_createSafePos = [(getMarkerPos "respawn_west"), 2, 100, 0, 1, 20, 0] call BIS_fnc_findSafePos;
_createSafePos = getMarkerPos "respawn_west";
_rndx = floor(random 100);
_rndy = floor(random 100);
_oldUnit setPosATL [(_createSafePos select 0) + _rndx, (_createSafePos select 1) + _rndy, 0];
_newUnit setPosATL _position;
//Clear and delete old Unit
removeAllWeapons _oldUnit;
{_oldUnit removeMagazine _x;} forEach magazines _oldUnit;
if !(isNull _oldUnit) then {deleteVehicle _oldUnit;};
removeAllWeapons _oldUnit;
{_oldUnit removeMagazine _x;} count magazines _oldUnit;
if !(isNull _oldUnit) then {deleteVehicle _oldUnit;};
// player switchCamera = _currentCamera;
if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
[objNull, player, rSwitchMove,_currentAnim] call RE;
//dayz_originalPlayer attachTo [_newUnit];
player disableConversation true;
if (_tagSetting) then {
DZE_ForceNameTags = true;
};
if (_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
[objNull, player, rSwitchMove, _currentAnim] call RE;
//dayz_originalPlayer attachTo [_newUnit];
player disableConversation true;
// _playerUID=getPlayerUID player;
// _playerObjName = format["player%1",_playerUID];
// call compile format["%1 = player;",_playerObjName];
// publicVariable _playerObjName;
//melee check
call dayz_meleeMagazineCheck;
//reveal all near objects.
{player reveal _x} count (nearestObjects [getPosATL player,["AllVehicles","WeaponHolder","Land_A_tent","BuiltItems","ModularItems","DZE_Base_Object"],75]);
//All is arbitrary and will need to be changed to ["AllVehicles","WeaponHolder","Land_A_tent"] ++ others (stashes etc.)
call dayz_meleeMagazineCheck;
{player reveal _x} count (nearestObjects [getPosATL player,["AllVehicles","WeaponHolder","Land_A_tent","BuiltItems","ModularItems","DZE_Base_Object"],75]);

View File

@@ -302,15 +302,6 @@
<French>Le pliage de la tente est déjà en cours.</French>
<Czech>Balení stanu již probíhá.</Czech>
</Key>
<Key ID="STR_EPOCH_PLAYER_14">
<English>Tent not setup yet.</English>
<German>Zeltaufbau noch nicht möglich.</German>
<Russian>Палатка ещё не установлена.</Russian>
<!-- <Spanish></Spanish> -->
<Dutch>Tent is nog niet opgezet.</Dutch>
<French>La tente n'est pas encore installée.</French>
<Czech>Stan není ještě postaven.</Czech>
</Key>
<Key ID="STR_EPOCH_PLAYER_15">
<English>That is already being packed.</English>
<German>Das ist schon gepackt.</German>
@@ -329,15 +320,6 @@
<French>Impossible d'empaqueter lorsque d'autres joueurs sont proches.</French>
<Czech>Nelze zabalit, jestliže je jiný hráč poblíž.</Czech>
</Key>
<Key ID="STR_EPOCH_PLAYER_17">
<English>can't count magazines!</English>
<German>Magazine können nicht gezählt werden!</German>
<!-- <Russian></Russian> -->
<!-- <Spanish></Spanish> -->
<Dutch>kan de magazijnen niet tellen</Dutch>
<French>Ne peut pas compter les munitions!</French>
<Czech>nelze spočítat zásoby</Czech>
</Key>
<Key ID="STR_EPOCH_PLAYER_18">
<English>You must have RawMeat</English>
<German>Sie müssen rohes Fleisch besitzen</German>