mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 12:12:34 +03:00
Update mining stones for better stone detection
Made by @Victor-the-Cleaner
This commit is contained in:
@@ -1,40 +1,66 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Mine Stone
|
||||||
|
//
|
||||||
|
// Updated by: Victor the Cleaner
|
||||||
|
// Date: January 2022
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
|
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
|
||||||
dayz_actionInProgress = true;
|
dayz_actionInProgress = true;
|
||||||
|
|
||||||
private ["_mineChance","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut","_weapons"];
|
|
||||||
|
|
||||||
_item = _this;
|
|
||||||
call gear_ui_init;
|
call gear_ui_init;
|
||||||
closeDialog 1;
|
closeDialog 1;
|
||||||
|
|
||||||
// allowed rocks list move this later
|
local _pos1 = eyePos player; // ASL line start
|
||||||
_rocks = ["r2_boulder1.p3d","r2_boulder2.p3d","r2_rock1.p3d","r2_rock2.p3d","r2_rocktower.p3d","r2_rockwall.p3d","r2_stone.p3d"];
|
local _line = ATLToASL screenToWorld [0.5,0.5]; // ASL terminus
|
||||||
_findNearestRock = objNull;
|
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;
|
_rocks = lineIntersectsWith [_pos1, _x, player, objNull, true]; // detect objects
|
||||||
// Exit since we found a rock
|
_model = "";
|
||||||
if (_objName in _rocks) exitWith { _findNearestRock = _x; };
|
|
||||||
} foreach nearestObjects [getPosATL player, [], 8];
|
|
||||||
|
|
||||||
|
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 {
|
if (!_found) then { // if none found, try the old method
|
||||||
_countOut = 2 + floor(random 3);
|
{
|
||||||
|
_model = _x call fn_getModelName;
|
||||||
|
if (_model in DZE_rocks) exitWith {_found = true;};
|
||||||
|
} forEach nearestObjects [getPosATL player, [], 8];
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_found) then {
|
||||||
|
|
||||||
|
local _countOut = 2 + floor(random 4);
|
||||||
|
|
||||||
// Start stone mining loop
|
// Start stone mining loop
|
||||||
_counter = 0;
|
local _counter = 0;
|
||||||
_isOk = true;
|
local _isOk = true;
|
||||||
_proceed = false;
|
local _proceed = false;
|
||||||
|
|
||||||
//check chance before loop, for a maximum amount of 5 loops allowing 5 possiable chances
|
// check chance before loop, for a maximum amount of 5 loops allowing 5 possible chances
|
||||||
_mineChance = dayz_HarvestingChance call fn_chance;
|
local _mineChance = dayz_HarvestingChance call fn_chance;
|
||||||
|
|
||||||
while {_isOk} do {
|
while {_isOk} do {
|
||||||
//[player,(getPosATL player),20,"minestone"] spawn fnc_alertZombies;
|
[player,(getPosATL player),50,"minestone"] spawn fnc_alertZombies;
|
||||||
|
|
||||||
_finished = ["Medic",1] call fn_loopAction;
|
local _finished = ["Medic",1] call fn_loopAction;
|
||||||
_weapons = weapons player;
|
local _weapons = weapons player;
|
||||||
_weapons set [count _weapons,dayz_onBack];
|
|
||||||
|
|
||||||
// Make sure player did not drop pickaxe
|
// Make sure player did not drop pickaxe
|
||||||
if (!_finished || !("ItemPickaxe" in _weapons)) exitWith {
|
if (!_finished || !("ItemPickaxe" in _weapons)) exitWith {
|
||||||
@@ -42,25 +68,26 @@ if (!isNull _findNearestRock) then {
|
|||||||
_proceed = false;
|
_proceed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local _breaking = false;
|
||||||
|
|
||||||
if (_finished) then {
|
if (_finished) then {
|
||||||
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
|
||||||
|
|
||||||
_breaking = false;
|
|
||||||
if (dayz_toolBreaking && _mineChance) then {
|
if (dayz_toolBreaking && _mineChance) then {
|
||||||
_breaking = true;
|
_breaking = true;
|
||||||
if ("ItemPickaxe" in weapons player) then {
|
|
||||||
|
if ("ItemPickaxe" in _weapons) then {
|
||||||
player removeWeapon "ItemPickaxe";
|
player removeWeapon "ItemPickaxe";
|
||||||
};
|
};
|
||||||
if (!("ItemPickaxeBroken" in weapons player)) then {
|
if !("ItemPickaxeBroken" in _weapons) then {
|
||||||
player addWeapon "ItemPickaxeBroken";
|
player addWeapon "ItemPickaxeBroken";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
_counter = _counter + 1;
|
// Drop item to ground
|
||||||
_itemOut = "ItemStone";
|
["ItemStone",1,1] call fn_dropItem; // item, magazine, amount
|
||||||
|
|
||||||
//Drop Item to ground
|
_counter = _counter + 1;
|
||||||
[_itemOut,1,1] call fn_dropItem;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((_counter >= _countOut) || _breaking) exitWith {
|
if ((_counter >= _countOut) || _breaking) exitWith {
|
||||||
|
|||||||
@@ -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_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_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_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
|
// 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
|
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