liberation resource

This commit is contained in:
jack77213 2020-03-03 10:46:14 +08:00
parent 9da35a4b6c
commit 4d69237660
Signed by: jack77213
GPG key ID: CA81AA7BB873B9F1
4 changed files with 115 additions and 0 deletions

1
resource/$PBOPREFIX$ Normal file
View file

@ -0,0 +1 @@
x\huashui\resource

28
resource/config.cpp Normal file
View file

@ -0,0 +1,28 @@
class CfgPatches
{
class hijack_server_resource
{
name = "Arma 3 Liberation Full Resource Map";
author = "jack77213";
url = "https://arma.huashui.cf";
requiredVersion = 1.92;
requiredAddons[] = {"A3_Functions_F"};
units[] = {};
weapons[] = {};
};
};
class CfgFunctions
{
class huashui
{
class resource
{
file = "x\huashui\resource";
class resource { postInit=1; };
class setresource {};
};
};
};

27
resource/fn_resource.sqf Normal file
View file

@ -0,0 +1,27 @@
[] spawn {
//if (!hasInterface) exitWith {};
if (!isServer) exitWith {};
//if (!isDedicated) exitWith {};
waitUntil {time > 0};
hijack_stop_resource = false;
waitUntil{!hijack_stop_resource};
[] spawn {
while {true} do {
waitUntil{!hijack_stop_resource};
waitUntil {please_recalculate};
please_recalculate = false;
sleep 0.4;
please_recalculate = false;
[] call huashui_fnc_setresource;
please_recalculate = false;
};
};
};

View file

@ -0,0 +1,59 @@
private _local_fob_resources = [];
private _local_supplies_global = 0;
private _local_ammo_global = 0;
private _local_fuel_global = 0;
private _local_heli_slots = 0;
private _local_plane_slots = 0;
private _local_infantry_cap = 50 * GRLIB_resources_multiplier;
{
private _fob_buildings = _x nearobjects (GRLIB_fob_range * 2);
private _storage_areas = _fob_buildings select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0};
private _heliSlots = {(typeOf _x) == KP_liberation_heli_slot_building;} count _fob_buildings;
private _planeSlots = {(typeOf _x) == KP_liberation_plane_slot_building;} count _fob_buildings;
private _hasAirBuilding = {(typeOf _x) == KP_liberation_air_vehicle_building;} count _fob_buildings;
if (_hasAirBuilding > 0) then {_hasAirBuilding = true;} else {_hasAirBuilding = false;};
private _hasRecBuilding = {(typeOf _x) == KP_liberation_recycle_building;} count _fob_buildings;
if (_hasRecBuilding > 0) then {_hasRecBuilding = true;} else {_hasRecBuilding = false;};
private _supplyValue = 0;
private _ammoValue = 0;
private _fuelValue = 0;
{
{
switch ((typeOf _x)) do {
case KP_liberation_supply_crate: {_supplyValue = _supplyValue + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_ammo_crate: {_ammoValue = _ammoValue + (_x getVariable ["KP_liberation_crate_value",0]);};
case KP_liberation_fuel_crate: {_fuelValue = _fuelValue + (_x getVariable ["KP_liberation_crate_value",0]);};
default {diag_log format ["[KP LIBERATION] [ERROR] Invalid object (%1) at storage area", (typeOf _x)];};
};
} forEach (attachedObjects _x);
} forEach _storage_areas;
_supplyValue = _supplyValue + 300;
_ammoValue = _ammoValue + 500;
_fuelValue = _fuelValue + 100;
_local_fob_resources pushBack [_x, _supplyValue, _ammoValue, _fuelValue, _hasAirBuilding, _hasRecBuilding];
_local_supplies_global = _local_supplies_global + _supplyValue;
_local_ammo_global = _local_ammo_global + _ammoValue;
_local_fuel_global = _local_fuel_global + _fuelValue;
_local_heli_slots = _local_heli_slots + _heliSlots;
_local_plane_slots = _local_plane_slots + _planeSlots;
} forEach GRLIB_all_fobs;
{
if ( _x in sectors_capture ) then {
_local_infantry_cap = _local_infantry_cap + (10 * GRLIB_resources_multiplier);
};
} foreach blufor_sectors;
KP_liberation_fob_resources = _local_fob_resources;
KP_liberation_supplies_global = _local_supplies_global;
KP_liberation_ammo_global = _local_ammo_global;
KP_liberation_fuel_global = _local_fuel_global;
KP_liberation_heli_slots = _local_heli_slots;
KP_liberation_plane_slots = _local_plane_slots;
infantry_cap = _local_infantry_cap;