2017-10-03 15:25:59 +00:00
|
|
|
/*
|
|
|
|
Garden Manager
|
|
|
|
by Aaron Clark - EpochMod.com
|
|
|
|
|
|
|
|
Improvements and or bugfixes and other contributions are welcome via the github:
|
|
|
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/GardenManager.sqf
|
|
|
|
*/
|
|
|
|
//[[[cog import generate_private_arrays ]]]
|
|
|
|
private ["_babies","_babyClasses","_cargo","_garden","_mature","_matureClasses","_modifiedGardens","_seedClasses","_seeds","_spoil","_teenClasses","_teens"];
|
|
|
|
//[[[end]]]
|
|
|
|
|
2017-10-03 15:26:51 +00:00
|
|
|
_seedClasses = ["SeedPacket_GoldenSeal","SeedPacket_Hemp","SeedPacket_Poppy","SeedPacket_Pumpkin","SeedPacket_Sunflower"];
|
2017-10-03 15:25:59 +00:00
|
|
|
_babyClasses = ["Sapling_GoldenSeal","Sapling_Hemp","Sapling_Poppy","Sapling_Pumpkin","Sapling_Sunflower"];
|
|
|
|
_teenClasses = ["SaplingTeen_GoldenSeal","SaplingTeen_Hemp","SaplingTeen_Poppy","SaplingTeen_Pumpkin","SaplingTeen_Sunflower"];
|
2018-04-20 13:12:39 +00:00
|
|
|
_matureClasses = ["Goldenseal","Hemp","Poppy","Pumpkin","Sunflower"];
|
2017-10-03 15:25:59 +00:00
|
|
|
_spoil = false;
|
|
|
|
|
2017-10-03 15:42:42 +00:00
|
|
|
// init var if not set
|
|
|
|
if (isNil "EPOCH_activeGardens") then {EPOCH_activeGardens = []};
|
|
|
|
// remove any null objects
|
|
|
|
EPOCH_activeGardens = EPOCH_activeGardens - [objNull];
|
|
|
|
|
2017-10-03 15:25:59 +00:00
|
|
|
_modifiedGardens = [];
|
|
|
|
{
|
|
|
|
_garden = _x;
|
|
|
|
_cargo = magazineCargo _x;
|
|
|
|
// find all seeds
|
2017-10-06 15:39:26 +00:00
|
|
|
_seeds = _cargo select {_x in _seedClasses};
|
2017-10-03 15:25:59 +00:00
|
|
|
// find all baby plants
|
2017-10-06 15:39:26 +00:00
|
|
|
_babies = _cargo select {_x in _babyClasses};
|
2017-10-03 15:25:59 +00:00
|
|
|
// find all teen plants
|
2017-10-06 15:39:26 +00:00
|
|
|
_teens = _cargo select {_x in _teenClasses};
|
2017-10-03 15:25:59 +00:00
|
|
|
// find all mature plants
|
2017-10-06 15:39:26 +00:00
|
|
|
_mature = _cargo select {_x in _matureClasses};
|
2017-10-03 15:25:59 +00:00
|
|
|
|
|
|
|
// normalize storage
|
|
|
|
clearWeaponCargoGlobal _x;
|
|
|
|
clearMagazineCargoGlobal _x;
|
|
|
|
clearBackpackCargoGlobal _x;
|
|
|
|
clearItemCargoGlobal _x;
|
|
|
|
|
|
|
|
// convert seeds to baby plants.
|
|
|
|
{
|
|
|
|
_garden addMagazineCargoGlobal [(_babyClasses param [_seedClasses find _x, _x]), 1];
|
|
|
|
} forEach _seeds;
|
|
|
|
|
|
|
|
// convert baby plants to teen
|
|
|
|
{
|
|
|
|
_garden addMagazineCargoGlobal [(_teenClasses param [_babyClasses find _x, _x]), 1];
|
|
|
|
} forEach _babies;
|
|
|
|
|
|
|
|
// convert teen plants to mature
|
|
|
|
{
|
|
|
|
_garden addMagazineCargoGlobal [(_matureClasses param [_teenClasses find _x, _x]), 1];
|
|
|
|
} forEach _teens;
|
|
|
|
|
|
|
|
// readd mature plants if spoil == false
|
|
|
|
if !(_spoil) then {
|
|
|
|
{
|
|
|
|
_garden addMagazineCargoGlobal [_x, 1];
|
|
|
|
} forEach _mature;
|
|
|
|
};
|
|
|
|
|
|
|
|
// push to temp array for save
|
|
|
|
if !((magazineCargo _garden) isEqualTo _cargo) then {
|
|
|
|
_modifiedGardens pushBack _garden;
|
|
|
|
};
|
|
|
|
|
2017-10-03 15:42:42 +00:00
|
|
|
} forEach EPOCH_activeGardens;
|
2017-10-03 15:25:59 +00:00
|
|
|
|
|
|
|
// force all modified gardens to save via queue
|
|
|
|
if !(_modifiedGardens isEqualTo []) then {
|
2017-10-11 13:31:23 +00:00
|
|
|
[_modifiedGardens] call EPOCH_server_save_vehicles;
|
2017-10-03 15:25:59 +00:00
|
|
|
};
|