mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Update mining stones for better stone detection
Made by @Victor-the-Cleaner
This commit is contained in:
@@ -1,83 +1,110 @@
|
||||
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Mine Stone
|
||||
//
|
||||
// Updated by: Victor the Cleaner
|
||||
// Date: January 2022
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
private ["_mineChance","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut","_weapons"];
|
||||
|
||||
_item = _this;
|
||||
call gear_ui_init;
|
||||
closeDialog 1;
|
||||
|
||||
// allowed rocks list move this later
|
||||
_rocks = ["r2_boulder1.p3d","r2_boulder2.p3d","r2_rock1.p3d","r2_rock2.p3d","r2_rocktower.p3d","r2_rockwall.p3d","r2_stone.p3d"];
|
||||
_findNearestRock = objNull;
|
||||
local _pos1 = eyePos player; // ASL line start
|
||||
local _line = ATLToASL screenToWorld [0.5,0.5]; // ASL terminus
|
||||
local _dist = 4;
|
||||
local _vec1 = [_pos1, _line] call BIS_fnc_vectorFromXToY; // sight vector
|
||||
local _vec2 = [_vec1, _dist] call BIS_fnc_vectorMultiply; // extend line-of-sight
|
||||
local _pos2 = [_pos1, _vec2] call BIS_fnc_vectorAdd; // ASL line stop
|
||||
local _pos3 = +_pos2;
|
||||
local _pos4 = +_pos1;
|
||||
local _found = false;
|
||||
local _rocks = [];
|
||||
local _model = "";
|
||||
|
||||
_pos3 set [2, (_pos3 select 2) - _dist]; // player is looking over low rock
|
||||
_pos4 set [2, (_pos4 select 2) - _dist]; // player is directly above rock
|
||||
|
||||
{
|
||||
_objName = _x call fn_getModelName;
|
||||
// Exit since we found a rock
|
||||
if (_objName in _rocks) exitWith { _findNearestRock = _x; };
|
||||
} foreach nearestObjects [getPosATL player, [], 8];
|
||||
_rocks = lineIntersectsWith [_pos1, _x, player, objNull, true]; // detect objects
|
||||
_model = "";
|
||||
|
||||
if (count _rocks > 0) then {
|
||||
_model = (_rocks call BIS_fnc_arrayPop) call fn_getModelName; // get model name of nearest target
|
||||
};
|
||||
if (_model in DZE_rocks) exitWith {_found = true;}; // found one
|
||||
} forEach [_pos2, _pos3, _pos4];
|
||||
|
||||
if (!isNull _findNearestRock) then {
|
||||
_countOut = 2 + floor(random 3);
|
||||
if (!_found) then { // if none found, try the old method
|
||||
{
|
||||
_model = _x call fn_getModelName;
|
||||
if (_model in DZE_rocks) exitWith {_found = true;};
|
||||
} forEach nearestObjects [getPosATL player, [], 8];
|
||||
};
|
||||
|
||||
// Start stone mining loop
|
||||
_counter = 0;
|
||||
_isOk = true;
|
||||
_proceed = false;
|
||||
if (_found) then {
|
||||
|
||||
//check chance before loop, for a maximum amount of 5 loops allowing 5 possiable chances
|
||||
_mineChance = dayz_HarvestingChance call fn_chance;
|
||||
local _countOut = 2 + floor(random 4);
|
||||
|
||||
while {_isOk} do {
|
||||
//[player,(getPosATL player),20,"minestone"] spawn fnc_alertZombies;
|
||||
// Start stone mining loop
|
||||
local _counter = 0;
|
||||
local _isOk = true;
|
||||
local _proceed = false;
|
||||
|
||||
_finished = ["Medic",1] call fn_loopAction;
|
||||
_weapons = weapons player;
|
||||
_weapons set [count _weapons,dayz_onBack];
|
||||
// check chance before loop, for a maximum amount of 5 loops allowing 5 possible chances
|
||||
local _mineChance = dayz_HarvestingChance call fn_chance;
|
||||
|
||||
//Make sure player did not drop pickaxe
|
||||
if (!_finished || !("ItemPickaxe" in _weapons)) exitWith {
|
||||
_isOk = false;
|
||||
_proceed = false;
|
||||
};
|
||||
while {_isOk} do {
|
||||
[player,(getPosATL player),50,"minestone"] spawn fnc_alertZombies;
|
||||
|
||||
if (_finished) then {
|
||||
local _finished = ["Medic",1] call fn_loopAction;
|
||||
local _weapons = weapons player;
|
||||
|
||||
// Make sure player did not drop pickaxe
|
||||
if (!_finished || !("ItemPickaxe" in _weapons)) exitWith {
|
||||
_isOk = false;
|
||||
_proceed = false;
|
||||
};
|
||||
|
||||
local _breaking = false;
|
||||
|
||||
if (_finished) then {
|
||||
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
||||
|
||||
_breaking = false;
|
||||
if (dayz_toolBreaking && _mineChance) then {
|
||||
_breaking = true;
|
||||
if ("ItemPickaxe" in weapons player) then {
|
||||
_breaking = true;
|
||||
|
||||
if ("ItemPickaxe" in _weapons) then {
|
||||
player removeWeapon "ItemPickaxe";
|
||||
};
|
||||
if (!("ItemPickaxeBroken" in weapons player)) then {
|
||||
player addWeapon "ItemPickaxeBroken";
|
||||
};
|
||||
};
|
||||
if !("ItemPickaxeBroken" in _weapons) then {
|
||||
player addWeapon "ItemPickaxeBroken";
|
||||
};
|
||||
};
|
||||
|
||||
_counter = _counter + 1;
|
||||
_itemOut = "ItemStone";
|
||||
// Drop item to ground
|
||||
["ItemStone",1,1] call fn_dropItem; // item, magazine, amount
|
||||
|
||||
//Drop Item to ground
|
||||
[_itemOut,1,1] call fn_dropItem;
|
||||
};
|
||||
_counter = _counter + 1;
|
||||
};
|
||||
|
||||
if ((_counter >= _countOut) || _breaking) exitWith {
|
||||
if (_breaking) then {
|
||||
localize "str_PickAxeHandleBreaks" call dayz_rollingMessages;
|
||||
} else {
|
||||
if ((_counter >= _countOut) || _breaking) exitWith {
|
||||
if (_breaking) then {
|
||||
localize "str_PickAxeHandleBreaks" call dayz_rollingMessages;
|
||||
} else {
|
||||
localize "str_mining_finished" call dayz_rollingMessages;
|
||||
};
|
||||
_isOk = false;
|
||||
_proceed = true;
|
||||
};
|
||||
format[localize "str_mining_progress", _counter,(_countOut - _counter)] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
_isOk = false;
|
||||
_proceed = true;
|
||||
};
|
||||
format[localize "str_mining_progress", _counter, (_countOut - _counter)] call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
if (!_proceed) then {
|
||||
localize "str_mining_canceled" call dayz_rollingMessages;
|
||||
};
|
||||
if (!_proceed) then {
|
||||
localize "str_mining_canceled" call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
localize "str_mining_no_rocks" call dayz_rollingMessages;
|
||||
};
|
||||
|
||||
@@ -304,6 +304,7 @@ if (!isDedicated) then {
|
||||
DZE_maintainRange = (DZE_PlotPole select 0) + 0.1; // Default: maintain building objects within plot radius + 0.1 meters.
|
||||
DZE_modularDoors = ["Land_DZE_WoodDoor","Land_DZE_LargeWoodDoor","Land_DZE_GarageWoodDoor","CinderWallDoor_DZ","CinderWallDoorSmall_DZ","WoodenGate_foundation_DZ","WoodenGate_1_DZ","WoodenGate_2_DZ","WoodenGate_3_DZ","WoodenGate_4_DZ","Land_DZE_WoodGate","Land_DZE_WoodOpenTopGarageDoor","CinderGate_DZ","CinderGarageOpenTop_DZ","CinderDoorHatch_DZ","Door_DZ","Concrete_Bunker_DZ","Metal_Drawbridge_DZ"];
|
||||
DZE_refundStorageItemContents = ["GunRack_DZ","GunRack2_DZ","WoodCrate_DZ","WoodCrate2_DZ","StorageCrate_DZ","CamoStorageCrate_DZ","OutHouse_DZ","StorageShed_DZ","StorageShed2_DZ","Wooden_shed_DZ","Wooden_shed2_DZ","WoodShack_DZ","WoodShack2_DZ","Advanced_WorkBench_DZ","StashSmall","StashSmall1","StashSmall2","StashSmall3","StashSmall4","StashMedium","StashMedium1","StashMedium2","StashMedium3","StashMedium4","Generator_DZ","M240Nest_DZ","CookTripod_DZ","Stoneoven_DZ","Commode_DZ","Wardrobe_DZ","Fridge_DZ","Washing_Machine_DZ","Server_Rack_DZ","ATM_DZ","Armchair_DZ","Sofa_DZ","Arcade_DZ","Vendmachine1_DZ","Vendmachine2_DZ"]; // array of non-lockable storage objects that will refund their contents when the object is removed
|
||||
DZE_rocks = ["r2_boulder1.p3d","r2_boulder2.p3d","r2_rock1.p3d","r2_rock2.p3d","r2_rocktower.p3d","r2_rockwall.p3d","r2_stone.p3d"];
|
||||
|
||||
// Helper Colors Require Reformatting
|
||||
DZE_NoRefundTexture = [0, format["#(argb,8,8,3)color(1.00,0.00,0.00,%1,ca)", (DZE_NoRefundTransparency max 0.1)] ]; // red
|
||||
|
||||
Reference in New Issue
Block a user