reworked mineral node harvesting

Can only use sledge hammer only to harvest nodes
seperated loot tables per mineral nodes
chance to loot on first strike 1 in 3
This commit is contained in:
vbawol 2017-10-16 11:02:03 -05:00
parent 144db2b065
commit 853586def5
9 changed files with 308 additions and 93 deletions

View File

@ -17,7 +17,7 @@ private ["_currentPos","_found","_foundIndex","_getWorldTypes","_object","_objec
//[[[end]]] //[[[end]]]
if ((diag_tickTime - EPOCH_lastMineRocks) >= 2) then { if ((diag_tickTime - EPOCH_lastMineRocks) >= 2) then {
EPOCH_lastMineRocks = diag_tickTime; EPOCH_lastMineRocks = diag_tickTime;
if (random 1 < 0.16) then { if (random 1 < 0.33) then {
_currentPos = player modelToWorld[0, 5, 0]; _currentPos = player modelToWorld[0, 5, 0];
if !(surfaceIsWater _currentPos) then { if !(surfaceIsWater _currentPos) then {
@ -30,21 +30,19 @@ if ((diag_tickTime - EPOCH_lastMineRocks) >= 2) then {
_found = false; _found = false;
_foundIndex = -1; _foundIndex = -1;
{ {
_worldTypes = ["rock","cinder","wreck"]; _worldTypes = ["rock","cinder","wreck","ore"];
_getWorldTypes = [_x, _worldTypes] call EPOCH_worldObjectType; _getWorldTypes = [_x, _worldTypes] call EPOCH_worldObjectType;
{ {
if (_getWorldTypes param [_worldTypes find _x, false]) exitWith { if (_getWorldTypes param [_worldTypes find _x, false]) exitWith {
_found = true; _found = true;
_foundIndex = _forEachIndex - 1; _foundIndex = _forEachIndex;
}; };
} forEach _worldTypes; } forEach _worldTypes;
if (_found)exitWith{_object = _x}; if (_found)exitWith{_object = _x};
}foreach _objects; }foreach _objects;
if (!isNull _object) then { if (!isNull _object && {alive _object}) then {
if (alive _object) then {
[_object, _foundIndex, player, Epoch_personalToken] remoteExec ["EPOCH_server_mineRocks",2]; [_object, _foundIndex, player, Epoch_personalToken] remoteExec ["EPOCH_server_mineRocks",2];
}; };
}; };
};
}; };

View File

@ -1,4 +1,7 @@
class CfgWorldInteractions { class CfgWorldInteractions {
class Ore {
ore = 1;
};
class Water { class Water {
water = 1; water = 1;
}; };
@ -792,4 +795,9 @@ class CfgWorldInteractions {
class Land_chz_zibk_3 : Wrecks {}; class Land_chz_zibk_3 : Wrecks {};
class Land_chz_zibk_4 : Wrecks {}; class Land_chz_zibk_4 : Wrecks {};
class Land_fishing_boat : Wrecks {}; class Land_fishing_boat : Wrecks {};
// ore classes
class MineralDepositCopper_EPOCH : Ore {};
class MineralDepositGold_EPOCH : Ore {};
class MineralDepositSilver_EPOCH : Ore {};
class mineral_p3d : Ore {};
}; };

View File

@ -13,48 +13,47 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_mineRocks.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_mineRocks.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_item","_lootables","_nearbyWH","_payout","_payoutQty","_posWH","_selectedPayout"]; private ["_config","_posWH","_selectedConfig"];
//[[[end]]] //[[[end]]]
params ["_object","_index","_player",["_token","",[""]] ]; params ["_object","_index","_player",["_token","",[""]] ];
if !([_player, _token] call EPOCH_server_getPToken) exitWith{}; if !([_player, _token] call EPOCH_server_getPToken) exitWith{};
if (alive _object) then { // make sure object still exists and is proper object type and alive.
if (_object isEqualType objNull && {!(isNull _object)} && {alive _object}) then {
_posWH = getPosATL _player; _posWH = getPosATL _player;
_posWH set[2, 0]; _posWH set[2, 0];
// defaults // define loot table class
_selectedPayout = ["ItemRock", 4]; _selectedConfig = typeOf _object;
// Not Rock if (_selectedConfig isEqualTo "") then {
if (_index >= 0) then { // handle simple/terrain objects
_selectedPayout = ["ItemScraps", 2]; (getModelInfo _object) params [["_modelName",""]];
if (_index == 0) then { if (!isnil "_modelName") then {
_selectedPayout = ["CinderBlocks", 1]; // replace spaces and periods with underscores
_selectedConfig = (_modelName splitString " .") joinString "_";
}; };
} else {
_lootables = [["PartOre", 2], ["ItemRock", 4]];
_selectedPayout = selectRandom _lootables;
}; };
_payout = _selectedPayout select 0; _config = configFile >> "CfgMainTable" >> _selectedConfig;
_payoutQty = _selectedPayout select 1; if !(isClass(_config)) then {
// allow override with generic loot classes if object class is not in CfgMainTable
switch (_index) do {
case 0: { _selectedConfig = "Rock" };
case 1: { _selectedConfig = "Cinder" };
case 2: { _selectedConfig = "Wreck" };
case 3: { _selectedConfig = "Ore" };
};
};
if (isSimpleObject _object) then { if (isSimpleObject _object) then {
// just remove for now, object will respawn on restart. // just remove for now, object will respawn on restart.
deleteVehicle _object; deleteVehicle _object;
} else { } else {
_object setdamage ((damage _object) + (1/_payoutQty)) min 1; _object setdamage 1;
}; };
_nearbyWH = nearestObjects[_posWH, ["groundWeaponHolder"], 2]; // output loot
if !(_nearbyWH isEqualTo[]) then { [objNull, _selectedConfig, false, _posWH] call EPOCH_serverLootObject;
_posWH = getPosATL(_nearbyWH select 0);
(_nearbyWH select 0) addMagazineCargoGlobal[_payout, _payoutQty];
} else {
_item = createVehicle["groundWeaponHolder", _posWH, [], 0, "CAN_COLLIDE"];
_item setPosATL _posWH;
_item addMagazineCargoGlobal[_payout, _payoutQty];
};
}; };
true true

View File

@ -27,6 +27,7 @@ if !(EPOCH_forcedLootSpawnTable isEqualTo "") then {
_randomizeMagazineAmmoCount = ["CfgEpochClient", "randomizeMagazineAmmoCount", true] call EPOCH_fnc_returnConfigEntryV2; _randomizeMagazineAmmoCount = ["CfgEpochClient", "randomizeMagazineAmmoCount", true] call EPOCH_fnc_returnConfigEntryV2;
if (isnull _object && !(_pos isequalto [])) then { if (isnull _object && !(_pos isequalto [])) then {
_object = createVehicle ["groundWeaponHolder",_pos,[],0,"CAN_COLLIDE"]; _object = createVehicle ["groundWeaponHolder",_pos,[],0,"CAN_COLLIDE"];
_object setPosATL _pos;
}; };
if !(isNull _object) then{ if !(isNull _object) then{
_lootTable = ["CfgMainTable", _type, "tables"] call EPOCH_fnc_weightedArray; _lootTable = ["CfgMainTable", _type, "tables"] call EPOCH_fnc_weightedArray;

View File

@ -20,6 +20,25 @@ class CfgLootTable
{ { "WoodLog_EPOCH", "magazine" }, 1 } { { "WoodLog_EPOCH", "magazine" }, 1 }
}; };
}; };
class Rock
{
items[] = {
{ { "PartOre", "magazine" }, 1 },
{ { "ItemRock", "magazine" }, 2 }
};
};
class Cinder
{
items[] = {
{ { "CinderBlocks", "magazine" }, 1 }
};
};
class Wreck
{
items[] = {
{ { "ItemScraps", "magazine" }, 1 }
};
};
class Bush class Bush
{ {
items[] = { items[] = {
@ -777,6 +796,33 @@ class CfgLootTable
{ { "PartOre", "magazine" }, 35 } { { "PartOre", "magazine" }, 35 }
}; };
}; };
class CopperMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 30 },
{ { "PartOre", "magazine" }, 35 }
};
};
class SilverMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 35 },
{ { "PartOre", "magazine" }, 30 }
};
};
class GoldMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 20 },
{ { "PartOreGold", "magazine" }, 35 },
{ { "PartOreSilver", "magazine" }, 20 },
{ { "PartOre", "magazine" }, 25 }
};
};
class Food class Food
{ {
items[] = { items[] = {

View File

@ -20,6 +20,25 @@ class CfgLootTable_CUP
{ { "WoodLog_EPOCH", "magazine" }, 1 } { { "WoodLog_EPOCH", "magazine" }, 1 }
}; };
}; };
class Rock
{
items[] = {
{ { "PartOre", "magazine" }, 1 },
{ { "ItemRock", "magazine" }, 2 }
};
};
class Cinder
{
items[] = {
{ { "CinderBlocks", "magazine" }, 1 }
};
};
class Wreck
{
items[] = {
{ { "ItemScraps", "magazine" }, 1 }
};
};
class Bush class Bush
{ {
items[] = { items[] = {
@ -1340,6 +1359,33 @@ class CfgLootTable_CUP
{ { "PartOre", "magazine" }, 35 } { { "PartOre", "magazine" }, 35 }
}; };
}; };
class CopperMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 30 },
{ { "PartOre", "magazine" }, 35 }
};
};
class SilverMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 35 },
{ { "PartOre", "magazine" }, 30 }
};
};
class GoldMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 20 },
{ { "PartOreGold", "magazine" }, 35 },
{ { "PartOreSilver", "magazine" }, 20 },
{ { "PartOre", "magazine" }, 25 }
};
};
class Food class Food
{ {
items[] = { items[] = {

View File

@ -20,6 +20,25 @@ class CfgLootTable_MAD
{ { "WoodLog_EPOCH", "magazine" }, 1 } { { "WoodLog_EPOCH", "magazine" }, 1 }
}; };
}; };
class Rock
{
items[] = {
{ { "PartOre", "magazine" }, 1 },
{ { "ItemRock", "magazine" }, 2 }
};
};
class Cinder
{
items[] = {
{ { "CinderBlocks", "magazine" }, 1 }
};
};
class Wreck
{
items[] = {
{ { "ItemScraps", "magazine" }, 1 }
};
};
class Bush class Bush
{ {
items[] = { items[] = {
@ -782,6 +801,33 @@ class CfgLootTable_MAD
{ { "PartOre", "magazine" }, 35 } { { "PartOre", "magazine" }, 35 }
}; };
}; };
class CopperMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 30 },
{ { "PartOre", "magazine" }, 35 }
};
};
class SilverMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 35 },
{ { "PartOre", "magazine" }, 30 }
};
};
class GoldMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 20 },
{ { "PartOreGold", "magazine" }, 35 },
{ { "PartOreSilver", "magazine" }, 20 },
{ { "PartOre", "magazine" }, 25 }
};
};
class Food class Food
{ {
items[] = { items[] = {

View File

@ -20,6 +20,25 @@ class CfgLootTable_MADCUP
{ { "WoodLog_EPOCH", "magazine" }, 1 } { { "WoodLog_EPOCH", "magazine" }, 1 }
}; };
}; };
class Rock
{
items[] = {
{ { "PartOre", "magazine" }, 1 },
{ { "ItemRock", "magazine" }, 2 }
};
};
class Cinder
{
items[] = {
{ { "CinderBlocks", "magazine" }, 1 }
};
};
class Wreck
{
items[] = {
{ { "ItemScraps", "magazine" }, 1 }
};
};
class Bush class Bush
{ {
items[] = { items[] = {
@ -1345,6 +1364,33 @@ class CfgLootTable_MADCUP
{ { "PartOre", "magazine" }, 35 } { { "PartOre", "magazine" }, 35 }
}; };
}; };
class CopperMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 30 },
{ { "PartOre", "magazine" }, 35 }
};
};
class SilverMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 15 },
{ { "PartOreGold", "magazine" }, 20 },
{ { "PartOreSilver", "magazine" }, 35 },
{ { "PartOre", "magazine" }, 30 }
};
};
class GoldMine
{
items[] = {
{ { "Gems", "CfgLootTable" }, 20 },
{ { "PartOreGold", "magazine" }, 35 },
{ { "PartOreSilver", "magazine" }, 20 },
{ { "PartOre", "magazine" }, 25 }
};
};
class Food class Food
{ {
items[] = { items[] = {

View File

@ -28,6 +28,34 @@ class CfgMainTable
LootMax = 6; LootMax = 6;
tables[] = { "Tree" }; tables[] = { "Tree" };
}; };
class Rock : Default
{
chance = 1;
lootMin = 3;
LootMax = 6;
tables[] = { "Rock" };
};
class Ore : Default
{
chance = 1;
lootMin = 3;
LootMax = 6;
tables[] = { "Mine" };
};
class Cinder : Default
{
chance = 1;
lootMin = 3;
LootMax = 6;
tables[] = { "Cinder" };
};
class Wreck : Default
{
chance = 1;
lootMin = 3;
LootMax = 6;
tables[] = { "Wreck" };
};
class Bush : Default class Bush : Default
{ {
chance = 1; chance = 1;
@ -230,27 +258,24 @@ class CfgMainTable
lootMin = 3; lootMin = 3;
LootMax = 6; LootMax = 6;
tables[] = { "Shipwreck" }; tables[] = { "Shipwreck" };
antagonists[] = {
{ "GreatWhite", 1 }
};
}; };
class MineralDepositCopper_EPOCH : Default class MineralDepositCopper_EPOCH : Default
{ {
lootMin = 5; lootMin = 5;
LootMax = 10; LootMax = 10;
tables[] = { "Mine" }; tables[] = { "CopperMine" };
}; };
class MineralDepositGold_EPOCH : Default class MineralDepositGold_EPOCH : Default
{ {
lootMin = 5; lootMin = 5;
LootMax = 10; LootMax = 10;
tables[] = { "Mine" }; tables[] = { "GoldMine" };
}; };
class MineralDepositSilver_EPOCH : Default class MineralDepositSilver_EPOCH : Default
{ {
lootMin = 5; lootMin = 5;
LootMax = 10; LootMax = 10;
tables[] = { "Mine" }; tables[] = { "SilverMine" };
}; };
class Shelf_EPOCH : Default class Shelf_EPOCH : Default
{ {