mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 12:12:34 +03:00
Update vanilla player_breakin.sqf
Vanilla commits:63aaf07a30b074e7d847fb3f69a69a416cc5dcf1b6c0dd584939a3d45965
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
private ["_brokein","_isOk","_hasSledgeHammer","_gps","_vars","_hasToolbox","_hasCrowbar","_limit","_proceed","_counter",
|
||||
"_dis","_sfx","_roll","_finished","_isGate","_values"];
|
||||
"_dis","_end","_msg","_sfx","_roll","_finished","_isGate","_values","_crowBarChance","_sledgeChance","_breakinChance"];
|
||||
|
||||
_target = _this select 3;
|
||||
_pos = getPos _target;
|
||||
@@ -7,16 +7,21 @@ _isWoodenGate = (typeOf cursorTarget) in ["WoodenGate_2","WoodenGate_3","WoodenG
|
||||
_isMetalGate = (typeOf cursorTarget) in ["MetalGate_2","MetalGate_3","MetalGate_4"];
|
||||
_limit = 2 + round(random 3);
|
||||
|
||||
if (_target getVariable ["actionInProgress",false]) exitWith { "Action is already underway" call dayz_rollingMessages;};
|
||||
_target setVariable ["actionInProgress",true,true];
|
||||
|
||||
_hasSledgeHammer = "ItemSledge" in items player;
|
||||
_hasCrowbar = "ItemCrowbar" in items player;
|
||||
|
||||
if (!_hasSledgeHammer) exitWith {
|
||||
localize "STR_BLD_BREAKIN_NEED_SLEDGE" call dayz_rollingMessages;
|
||||
_target setVariable ["actionInProgress",false,true];
|
||||
uiSleep 1;
|
||||
};
|
||||
|
||||
if (!_hasCrowbar) exitWith {
|
||||
localize "STR_BLD_BREAKIN_NEED_CROWBAR" call dayz_rollingMessages;
|
||||
_target setVariable ["actionInProgress",false,true];
|
||||
uiSleep 1;
|
||||
};
|
||||
|
||||
@@ -24,17 +29,26 @@ _isOk = true;
|
||||
_proceed = false;
|
||||
_counter = 0;
|
||||
_brokein = false;
|
||||
_msg = "";
|
||||
_end = false;
|
||||
|
||||
//[ChanceToBreakin,SledgeChance,CowbarChance]
|
||||
_values = switch (1==1) do {
|
||||
case (_isWoodenGate): { [0.04,0.30,0.20] };
|
||||
case (_isMetalGate): { [0.02,0.60,0.40] };
|
||||
case (_isWoodenGate): { [0.07,0.30,0.20] };
|
||||
case (_isMetalGate): { [0.03,0.15,0.10] };
|
||||
default { [] };
|
||||
};
|
||||
|
||||
if ( (count _values) == 0 ) exitwith {};
|
||||
if ( (count _values) == 0 ) exitwith { _target setVariable ["actionInProgress",false,true]; };
|
||||
|
||||
//Move breakin chance outside the loop we only test for breakin at the very end of _limit
|
||||
_breakinChance = [(_values select 0)] call fn_chance;
|
||||
|
||||
while {_isOk} do {
|
||||
//check chance, for a maximum amount of 5 loops allowing 5 possiable chances to breakin we also now divide the max chance by the amount of trys.
|
||||
_sledgeChance = [((_values select 1) / _limit)] call fn_chance;
|
||||
_crowBarChance = [((_values select 2) / _limit)] call fn_chance;
|
||||
|
||||
//Check if we have the tools to start
|
||||
_hasSledgeHammer = "ItemSledge" in items player;
|
||||
_hasCrowbar = "ItemCrowbar" in items player;
|
||||
@@ -60,45 +74,32 @@ while {_isOk} do {
|
||||
//Run animation loop
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
|
||||
//Interrupt and end
|
||||
if(!_finished) exitWith {
|
||||
_isOk = false;
|
||||
_proceed = false;
|
||||
};
|
||||
|
||||
//Everything happened as it should
|
||||
if(_finished) then {
|
||||
//Add to Counter
|
||||
_counter = _counter + 1;
|
||||
} else {
|
||||
_isOk = false;
|
||||
_proceed = false;
|
||||
_sledgeChance = false;
|
||||
_crowBarChance = false;
|
||||
};
|
||||
|
||||
//some debug
|
||||
diag_log format["breakinChance: %1(%7%9), sledgeChance: %2(%5%9), crowBarChance: %3(%6%9), Attempt: %8 of %4",_breakinChance,_sledgeChance,_crowBarChance,_limit,(((_values select 1) / _limit) * 100),(((_values select 2) / _limit) * 100),(((_values select 0) / _limit) * 100),_counter,"%"];
|
||||
|
||||
|
||||
//Chances to damage tools
|
||||
if (dayz_toolBreaking && (_sledgeChance or _crowBarChance)) exitWith { _proceed = false; };
|
||||
|
||||
//End when _counter hits _limit decide if the breakin has been successful
|
||||
if(_counter == _limit) exitWith {
|
||||
//start chance to gain access.
|
||||
if ([(_values select 0)] call fn_chance) then {
|
||||
_isOk = false;
|
||||
if (_breakinChance) then {
|
||||
_proceed = true;
|
||||
_brokein = true;
|
||||
_target setVariable ["isOpen", "1", true];
|
||||
};
|
||||
};
|
||||
|
||||
if (dayz_toolBreaking) then {
|
||||
//Chances to damage tools
|
||||
if ([(_values select 1)] call fn_chance) then {
|
||||
player removeWeapon "ItemSledge";
|
||||
player addMagazine "ItemSledgeHandle";
|
||||
player addMagazine "ItemSledgeHead";
|
||||
|
||||
localize "STR_BLD_BREAKIN_BROKEN_SLEDGE" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if ([(_values select 2)] call fn_chance) then {
|
||||
player removeWeapon "ItemCrowbar";
|
||||
player addWeapon "ItemCrowbarBent";
|
||||
|
||||
localize "STR_BLD_BREAKIN_BENT_CROWBAR" call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
if(_counter == _limit) exitWith {
|
||||
//stop loop
|
||||
_isOk = false;
|
||||
//Set Done var
|
||||
@@ -108,27 +109,66 @@ while {_isOk} do {
|
||||
format [localize "STR_BLD_BREAKIN", _counter,_limit] call dayz_rollingMessages;
|
||||
uiSleep 0.03;
|
||||
};
|
||||
//End Loop
|
||||
|
||||
//Tool issues
|
||||
if (isnil "_proceed") exitwith {};
|
||||
if (isnil "_proceed") then {
|
||||
_proceed = false;
|
||||
_sledgeChance = false;
|
||||
_crowBarChance = false;
|
||||
};
|
||||
|
||||
if (_proceed) then {
|
||||
//Completed but no success.
|
||||
if (!_brokein) then {
|
||||
PVDZ_Server_LogIt = format["BROKEINFAILED: Player %1 Broke into Failed %2 at %3 chances:%4,%5",player, (typeof _target), (mapGridPosition _pos) , _sledgeChance, _crowBarChance];
|
||||
|
||||
_msg = "STR_BLD_BREAKIN_COMPLETE_FAIL";
|
||||
} else {
|
||||
//Completed and successful
|
||||
//Unlock gate
|
||||
_target setVariable ["isOpen", "1", true];
|
||||
//Open Gate.
|
||||
_target animate ["DoorR", 1];
|
||||
_target animate ["DoorL", 1];
|
||||
|
||||
|
||||
PVDZ_Server_LogIt = format["BROKEINSUCCESSFUL: Player %1 Broke into %2 at %3",player, (typeof _target), (mapGridPosition _pos)];
|
||||
|
||||
_msg = "STR_BLD_BREAKIN_COMPLETE";
|
||||
};
|
||||
//Send info to server for admins
|
||||
publicVariableServer "PVDZ_Server_LogIt";
|
||||
};
|
||||
|
||||
//Interrupted for some reason
|
||||
if (!_proceed) then {
|
||||
localize "STR_BLD_BREAKIN_CANCELLED" call dayz_rollingMessages;
|
||||
|
||||
if (_sledgeChance && dayz_toolBreaking) then {
|
||||
player removeWeapon "ItemSledge";
|
||||
player addMagazine "ItemSledgeHandle";
|
||||
player addMagazine "ItemSledgeHead";
|
||||
|
||||
_msg = "STR_BLD_BREAKIN_BROKEN_SLEDGE";
|
||||
};
|
||||
|
||||
if (_crowBarChance && dayz_toolBreaking) then {
|
||||
player removeWeapon "ItemCrowbar";
|
||||
player addWeapon "ItemCrowbarBent";
|
||||
|
||||
_msg = "STR_BLD_BREAKIN_BENT_CROWBAR";
|
||||
};
|
||||
|
||||
if (!_crowBarChance and !_sledgeChance) then {
|
||||
_msg = "STR_BLD_BREAKIN_CANCELLED";
|
||||
};
|
||||
};
|
||||
|
||||
// Working-Factor for chopping wood.
|
||||
//Reset action switch
|
||||
_target setVariable ["actionInProgress",false,true];
|
||||
|
||||
// Working-Factor.
|
||||
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
||||
|
||||
//Completed but no success.
|
||||
if (_proceed and !_brokein) then {
|
||||
localize "STR_BLD_BREAKIN_COMPLETE_FAIL" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
//Completed and successful
|
||||
if (_proceed and _brokein) then {
|
||||
localize "STR_BLD_BREAKIN_COMPLETE" call dayz_rollingMessages;
|
||||
|
||||
//Open Gate.
|
||||
_target animate ["DoorR", 1];
|
||||
_target animate ["DoorL", 1];
|
||||
};
|
||||
//Send info to player
|
||||
localize _msg call dayz_rollingMessages;
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
private ["_dis","_sfx","_breaking","_countOut","_counter","_isOk","_proceed","_finished","_itemOut","_tree","_distance2d"];
|
||||
private ["_dis","_sfx","_breaking","_countOut","_counter","_isOk","_proceed","_finished","_itemOut","_tree","_distance2d","_chanceResult"];
|
||||
|
||||
call gear_ui_init;
|
||||
closeDialog 1;
|
||||
@@ -25,6 +25,9 @@ if (!isNull _tree) then {
|
||||
_isOk = true;
|
||||
_proceed = false;
|
||||
|
||||
//check chance before loop, for a maximum amount of 5 loops allowing 5 possiable chances
|
||||
_chanceResult = dayz_HarvestingChance call fn_chance;
|
||||
|
||||
while {_isOk} do {
|
||||
//setup alert and speak
|
||||
_dis=20;
|
||||
@@ -43,7 +46,7 @@ if (!isNull _tree) then {
|
||||
if (_finished) then {
|
||||
["Working",0,[50,10,5,0]] call dayz_NutritionSystem;
|
||||
_breaking = false;
|
||||
if (dayz_toolBreaking && {[0.09] call fn_chance}) then {
|
||||
if (dayz_toolBreaking && _chanceResult) then {
|
||||
_breaking = true;
|
||||
if ("MeleeHatchet" in weapons player) then {
|
||||
player removeWeapon "MeleeHatchet";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
private ["_item","_dis","_sfx","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut"];
|
||||
private ["_mineChance","_item","_dis","_sfx","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut"];
|
||||
|
||||
_item = _this;
|
||||
call gear_ui_init;
|
||||
@@ -26,6 +26,9 @@ if (!isNull _findNearestRock) then {
|
||||
_isOk = true;
|
||||
_proceed = false;
|
||||
|
||||
//check chance before loop, for a maximum amount of 5 loops allowing 5 possiable chances
|
||||
_mineChance = dayz_HarvestingChance call fn_chance;
|
||||
|
||||
while {_isOk} do {
|
||||
//setup alert and speak
|
||||
_dis=20;
|
||||
@@ -44,7 +47,7 @@ if (!isNull _findNearestRock) then {
|
||||
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
||||
|
||||
_breaking = false;
|
||||
if (dayz_toolBreaking && {[0.09] call fn_chance}) then {
|
||||
if (dayz_toolBreaking && _mineChance) then {
|
||||
_breaking = true;
|
||||
if ("MeleePickaxe" in weapons player) then {
|
||||
player removeWeapon "MeleePickaxe";
|
||||
|
||||
@@ -10,6 +10,6 @@ _return = [0.25] call fn_chance; // will return TRUE 25% of the time
|
||||
*************************************************************/
|
||||
private ["_result"];
|
||||
|
||||
if ((_this select 0) > (random 1)) then {_result = true;} else {_result = false;};
|
||||
_result = if (((_this select 0) * 100) > floor(random 100)) then { true } else { false };
|
||||
|
||||
_result
|
||||
|
||||
@@ -524,6 +524,8 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
|
||||
_isLockableGate = _typeOfCursorTarget in ["WoodenGate_2","WoodenGate_3","WoodenGate_4","MetalGate_2","MetalGate_3","MetalGate_4"];
|
||||
_isUnlocked = _cursorTarget getVariable ["isOpen","0"] == "1";
|
||||
|
||||
_isActionInProgress = _cursorTarget getVariable ["actionInProgress",false];
|
||||
|
||||
//Allow the gates to be opened when not locked by anyone
|
||||
_isOpen = ((_cursorTarget animationPhase "DoorL") == 1) || ((_cursorTarget animationPhase "DoorR") == 1);
|
||||
_isClosed = ((_cursorTarget animationPhase "DoorL") == 0) || ((_cursorTarget animationPhase "DoorR") == 0);
|
||||
@@ -597,7 +599,7 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
|
||||
s_player_lockhouse = -1;
|
||||
};
|
||||
//Break In
|
||||
if ((_isHouse or _isLockableGate) && (_ownerPID != _uid) && !_isUnlocked) then {
|
||||
if ((_isHouse or _isLockableGate) && (_ownerPID != _uid) && !_isUnlocked && !_isActionInProgress) then {
|
||||
if (s_player_breakinhouse < 0) then {
|
||||
s_player_breakinhouse = player addAction [localize "STR_BLD_ACTIONS_BREAKIN", "\z\addons\dayz_code\actions\player_breakin.sqf",_cursorTarget, 1, true, true];
|
||||
};
|
||||
|
||||
@@ -198,9 +198,7 @@ if (isServer) then {
|
||||
};
|
||||
|
||||
/*"PVDZ_Server_LogIt" addPublicVariableEventHandler {
|
||||
_unitSending = _this select 0;
|
||||
_info = _this select 1;
|
||||
|
||||
diag_log format["WARNING: %1",_info];
|
||||
};*/
|
||||
|
||||
|
||||
@@ -590,6 +590,7 @@ if (!isDedicated) then {
|
||||
|
||||
//player special variables
|
||||
dayz_bloodBagHumanity = 300;
|
||||
dayz_HarvestingChance = [0.09];
|
||||
dayz_lastCheckBit = 0;
|
||||
dayz_lastDamageSourceNull = false;
|
||||
dayz_lastDamageSource = "none";
|
||||
|
||||
Reference in New Issue
Block a user