Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
More porting from ACE
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Jun 8, 2016
1 parent 7a592bc commit ead660b
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 236 deletions.
190 changes: 41 additions & 149 deletions addons/field_rations/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class CfgVehicles {


class ACE_Module;
class ACE_field_rations_module: ACE_Module {
class GVAR(module): ACE_Module {
scope = 2;
author = ECSTRING(common,ACETeam);
category = "ACE";
category = "ACEX";
displayName = CSTRING(moduleName);
//icon = "\ace\ace_main\data\ace_basic_module.paa";
function = QFUNC(moduleSettings);
Expand All @@ -43,157 +43,49 @@ class CfgVehicles {
};

class NATO_Box_Base;
class acex_field_rations_all: NATO_Box_Base {
class GVAR(box): NATO_Box_Base {
scope = 2;
accuracy = 1000;
displayName = "[ACE] Field Rations [All]";
model = "\A3\weapons_F\AmmoBoxes\AmmoBox_F";
author = ECSTRING(common,ACETeam);
class TransportWeapons {
class ace_waterbottle {
weapon = "ace_waterbottle";
count = 20;
};
class _xx_ace_canteen {
weapon = "ace_canteen";
count = 20;
};
class _xx_ace_MRE_LambC {
weapon = "ace_MRE_LambC";
count = 10;
};
class _xx_ace_MRE_Rice {
weapon = "ace_MRE_Rice";
count = 10;
};
class _xx_ace_MRE_CreamTomatoSoup {
weapon = "ace_MRE_CreamTomatoSoup";
count = 10;
};
class _xx_ace_MRE_CreamChickenSoup {
weapon = "ace_MRE_CreamChickenSoup";
count = 10;
};
class _xx_ace_MRE_ChickenTikkaMassala {
weapon = "ace_MRE_ChickenTikkaMassala";
count = 10;
};
class _xx_ace_MRE_SteakVegetables {
weapon = "ace_MRE_SteakVegetables";
count = 10;
};
class _xx_ace_MRE_MeatballsPasta {
weapon = "ace_MRE_MeatballsPasta";
count = 10;
};
class _xx_ace_MRE_ChickenHerbDumplings {
weapon = "ace_MRE_ChickenHerbDumplings";
count = 10;
};
class _xx_ace_Humanitarian_Ration {
weapon = "ace_Humanitarian_Ration";
count = 10;
};
class _xx_ace_US_MRE_ChiliBeans {
weapon = "ace_US_MRE_ChiliBeans";
count = 10;
};
class _xx_ace_US_MRE_ChickenFajita {
weapon = "ace_US_MRE_ChickenFajita";
count = 10;
};
class _xx_ace_US_MRE_ChickenNoodles {
weapon = "ace_US_MRE_ChickenNoodles";
count = 10;
};
class _xx_ace_US_MRE_PorkSausageGravy {
weapon = "ace_US_MRE_PorkSausageGravy";
count = 10;
};
class _xx_ace_US_MRE_MedChicen {
weapon = "ace_US_MRE_MedChicen";
count = 10;
};
class _xx_ace_US_MRE_BeefRoastVeggies {
weapon = "ace_US_MRE_BeefRoastVeggies";
count = 10;
};
class _xx_ace_US_MRE_BeefBrisket {
weapon = "ace_US_MRE_BeefBrisket";
count = 10;
};
class _xx_ace_US_MRE_MeatballMarinara {
weapon = "ace_US_MRE_MeatballMarinara";
count = 10;
};
class _xx_ace_US_MRE_BeefStew {
weapon = "ace_US_MRE_BeefStew";
count = 10;
};
class _xx_ace_US_MRE_ChiliMacaroni {
weapon = "ace_US_MRE_ChiliMacaroni";
count = 10;
};
class _xx_ace_US_MRE_VegetableLasagna {
weapon = "ace_US_MRE_VegetableLasagna";
count = 10;
};
class _xx_ace_US_MRE_SpicyPennePasta {
weapon = "ace_US_MRE_SpicyPennePasta";
count = 10;
};
class _xx_ace_US_MRE_CheeseTortellini {
weapon = "ace_US_MRE_CheeseTortellini";
count = 10;
};
class _xx_ace_US_MRE_Ratatouille {
weapon = "ace_US_MRE_Ratatouille";
count = 10;
};
class _xx_ace_US_MRE_MexicanStyleChickenStew {
weapon = "ace_US_MRE_MexicanStyleChickenStew";
count = 10;
};
class _xx_ace_US_MRE_PorkRib {
weapon = "ace_US_MRE_PorkRib";
count = 10;
};
class _xx_ace_US_MRE_MapleSausage {
weapon = "ace_US_MRE_MapleSausage";
count = 10;
};
class _xx_ace_US_MRE_BeefRavioli {
weapon = "ace_US_MRE_BeefRavioli";
count = 10;
};
class _xx_ace_US_MRE_SloppyJoe {
weapon = "ace_US_MRE_SloppyJoe";
count = 10;
};
class _xx_ace_US_MRE_SpaghettiMeatSauce {
weapon = "ace_US_MRE_SpaghettiMeatSauce";
count = 10;
};
class _xx_ace_US_MRE_LemonPepperTuna {
weapon = "ace_US_MRE_LemonPepperTuna";
count = 10;
};
class _xx_ace_US_MRE_AsianBeefStrips {
weapon = "ace_US_MRE_AsianBeefStrips";
count = 10;
};
class _xx_ace_US_MRE_ChickenPestoPasta {
weapon = "ace_US_MRE_ChickenPestoPasta";
count = 10;
};
class _xx_ace_US_MRE_SouthwestStyleBeefBlackBeans {
weapon = "ace_US_MRE_SouthwestStyleBeefBlackBeans";
count = 10;
};
class _xx_ace_mre_c_ration {
weapon = "ace_mre_c_ration";
count = 10;
};
class TransportItems {
MACRO_ADDITEM(ace_waterbottle,20);
MACRO_ADDITEM(ace_canteen,20);
MACRO_ADDITEM(ace_MRE_LambC,10);
MACRO_ADDITEM(ace_MRE_Rice,10);
MACRO_ADDITEM(ace_MRE_CreamTomatoSoup,10);
MACRO_ADDITEM(ace_MRE_CreamChickenSoup,10);
MACRO_ADDITEM(ace_MRE_ChickenTikkaMassala,10);
MACRO_ADDITEM(ace_MRE_SteakVegetables,10);
MACRO_ADDITEM(ace_MRE_MeatballsPasta,10);
MACRO_ADDITEM(ace_MRE_ChickenHerbDumplings,10);
MACRO_ADDITEM(ace_Humanitarian_Ration,10);
MACRO_ADDITEM(ace_US_MRE_ChiliBeans,10);
MACRO_ADDITEM(ace_US_MRE_ChickenFajita,10);
MACRO_ADDITEM(ace_US_MRE_ChickenNoodles,10);
MACRO_ADDITEM(ace_US_MRE_PorkSausageGravy,10);
MACRO_ADDITEM(ace_US_MRE_MedChicen,10);
MACRO_ADDITEM(ace_US_MRE_BeefRoastVeggies,10);
MACRO_ADDITEM(ace_US_MRE_BeefBrisket,10);
MACRO_ADDITEM(ace_US_MRE_MeatballMarinara,10);
MACRO_ADDITEM(ace_US_MRE_BeefStew,10);
MACRO_ADDITEM(ace_US_MRE_ChiliMacaroni,10);
MACRO_ADDITEM(ace_US_MRE_VegetableLasagna,10);
MACRO_ADDITEM(ace_US_MRE_SpicyPennePasta,10);
MACRO_ADDITEM(ace_US_MRE_CheeseTortellini,10);
MACRO_ADDITEM(ace_US_MRE_Ratatouille,10);
MACRO_ADDITEM(ace_US_MRE_MexicanStyleChickenStew,10);
MACRO_ADDITEM(ace_US_MRE_PorkRib,10);
MACRO_ADDITEM(ace_US_MRE_MapleSausage,10);
MACRO_ADDITEM(ace_US_MRE_BeefRavioli,10);
MACRO_ADDITEM(ace_US_MRE_SloppyJoe,10);
MACRO_ADDITEM(ace_US_MRE_SpaghettiMeatSauce,10);
MACRO_ADDITEM(ace_US_MRE_LemonPepperTuna,10);
MACRO_ADDITEM(ace_US_MRE_AsianBeefStrips,10);
MACRO_ADDITEM(ace_US_MRE_ChickenPestoPasta,10);
MACRO_ADDITEM(ace_US_MRE_SouthwestStyleBeefBlackBeans,10);
MACRO_ADDITEM(ace_mre_c_ration,10);
};
};
};
};
12 changes: 7 additions & 5 deletions addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

if !(hasInterface) exitWith {};

["SettingsInitialized", {
["ace_settingsInitialized", {
TRACE_3("ace_settingsInitialized eh",GVAR(systemEnabled),GVAR(timeWithoutWater),GVAR(timeWithoutFood));

//If not enabled, dont't add PFEH or actions
if (!GVAR(systemEnabled)) exitWith {};

Expand All @@ -15,13 +17,13 @@ if !(hasInterface) exitWith {};

[] call FUNC(addRefillActionsToObjects);

[{_this call DFUNC(updateFieldRations)}, 10, [ACE_time, (ACE_time + 60)]] call CBA_fnc_addPerFrameHandler;
[FUNC(updateFieldRations), 10, [CBA_missionTime, (CBA_missionTime + 60)]] call CBA_fnc_addPerFrameHandler;

["interactMenuClosed", {
["ace_interactMenuClosed", {
if (GVAR(hudInteractionHover)) then {
GVAR(hudInteractionHover) = false;
[3] call FUNC(showOverlay);
};
}] call ace_common_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;

}] call ace_common_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;
7 changes: 4 additions & 3 deletions addons/field_rations/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

class CfgPatches {
class ADDON {
units[] = {"ACE_field_rations_module"};
units[] = {QGVAR(module), GVAR(box)};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interact_menu"};
author[] = {"Glowbal", "PabstMirror"};
authorUrl = "https://github.com/acemod/ACE3";
authors[] = {"Glowbal", "PabstMirror"};
author = ACECSTRING(common,ACETeam);
url = ACECSTRING(main,URL);
VERSION_CONFIG;
};
};
Expand Down
22 changes: 11 additions & 11 deletions addons/field_rations/functions/fnc_actionConsumeItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ TRACE_2("params",_player,_itemClassname);

if (!(_this call FUNC(canConsumeItem))) exitWith {TRACE_1("canConsumeItem check failed", _this);};

local _cfg = ConfigFile >> "CfgWeapons" >> _itemClassname;
private _cfg = ConfigFile >> "CfgWeapons" >> _itemClassname;

local _consumeTime = getNumber (_cfg >> QGVAR(consumeTime));
local _displayName = getText (_cfg >> "displayName");
local _hungerRestored = getNumber (_cfg >> QGVAR(isEatable));
local _thirstRestored = getNumber (_cfg >> QGVAR(isDrinkable));
local _replacementItem = getText (_cfg >> QGVAR(replacementItem));
private _consumeTime = getNumber (_cfg >> QGVAR(consumeTime));
private _displayName = getText (_cfg >> "displayName");
private _hungerRestored = getNumber (_cfg >> QGVAR(isEatable));
private _thirstRestored = getNumber (_cfg >> QGVAR(isDrinkable));
private _replacementItem = getText (_cfg >> QGVAR(replacementItem));

local _progressBarText = if (_hungerRestored > 0) then {
private _progressBarText = if (_hungerRestored > 0) then {
format [localize LSTRING(EatingX), _displayName];
} else {
format [localize LSTRING(DrinkingX), _displayName];
};

local _onFinish = {
private _onFinish = {
(_this select 0) params ["", "_player", "_itemClassname", "_hungerRestored", "_thirstRestored", "_replacementItem"];
TRACE_4("Consume Finish",_itemClassname,_hungerRestored,_thirstRestored,_replacementItem);

Expand All @@ -46,16 +46,16 @@ local _onFinish = {
};

if (_hungerRestored > 0) then {
local _currentLevel = _player getvariable [QGVAR(hungerStatus), 100];
private _currentLevel = _player getvariable [QGVAR(hungerStatus), 100];
_player setvariable [QGVAR(hungerStatus), ((_currentLevel + _hungerRestored) min 100)];
};
if (_thirstRestored > 0) then {
local _currentLevel = _player getvariable [QGVAR(thirstStatus), 100];
private _currentLevel = _player getvariable [QGVAR(thirstStatus), 100];
_player setvariable [QGVAR(thirstStatus), ((_currentLevel + _thirstRestored) min 100)];
};
};

local _onFailure = {
private _onFailure = {
TRACE_1("Consume Interrupted", _this);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
params ["_waterSource", "_player", "_originalItem"];

// Prepare all info necessary for completing the action
local _onRefillItem = getText (configFile >> "CfgWeapons" >> _originalItem >> QGVAR(onRefill));
private _onRefillItem = getText (configFile >> "CfgWeapons" >> _originalItem >> QGVAR(onRefill));
if (_onRefillItem == "") exitwith {ACE_LOGERROR_1("No onRefill string", _originalItem);};

local _progressBarText = localize LSTRING(Refilling);
private _progressBarText = localize LSTRING(Refilling);

local _onFinish = {
private _onFinish = {
(_this select 0) params ["_waterSource", "_player", "_oldItem", "_onRefillItem"];
TRACE_3("Refil Finish",_player,_oldItem,_onRefillItem);

Expand All @@ -34,7 +34,7 @@ local _onFinish = {
[_player, _onRefillItem] call ace_common_fnc_addToInventory;
};

local _onFailure = {
private _onFailure = {
TRACE_1("Refil Interrupted", _this);
};

Expand Down
16 changes: 8 additions & 8 deletions addons/field_rations/functions/fnc_addRefillActionsToObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
#include "script_component.hpp"

//Function to get the refil actiosn for all water containers:
local _fncGetChildren = {
private _fncGetChildren = {
params ["", "_player"];

local _actions = [];
private _actions = [];
{
local _cfg = configFile >> "CfgWeapons" >> _x;
private _cfg = configFile >> "CfgWeapons" >> _x;

// Construct the children actions. Every item that we can refill, will receive a refill action.
if ((isClass _cfg) && {(getText (_cfg >> QGVAR(onRefill))) != ""}) then {
local _displayName = getText (_cfg >> "displayName");
local _picture = getText (_cfg >> "picture");
local _actionText = format [localize LSTRING(RefillX), _displayName];
local _action = [_x, _actionText, _picture, {_this call FUNC(actionRefillFromWaterSource)}, {_this call FUNC(canRefillFromWaterSource)}, {}, _x] call ace_interact_menu_fnc_createAction;
private _displayName = getText (_cfg >> "displayName");
private _picture = getText (_cfg >> "picture");
private _actionText = format [localize LSTRING(RefillX), _displayName];
private _action = [_x, _actionText, _picture, {_this call FUNC(actionRefillFromWaterSource)}, {_this call FUNC(canRefillFromWaterSource)}, {}, _x] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _player];
};
} forEach (items _player);
Expand All @@ -39,7 +39,7 @@ local _fncGetChildren = {
{
_x params ["_classname", ["_tapLocation", [0,0,0]]];

local _cfg = configFile >> "CfgVehicles" >> _classname;
private _cfg = configFile >> "CfgVehicles" >> _classname;
TRACE_3("Adding refil action", (isClass _cfg), _classname, _tapLocation);

if (isClass _cfg) then {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

params ["_waterSource", "_player", "_itemClassname"];

local _cfg = configFile >> "CfgWeapons" >> _itemClassname;
private _cfg = configFile >> "CfgWeapons" >> _itemClassname;

([_player, _waterSource, []] call ace_common_fnc_canInteractWith)
&& ((getText (_cfg >> QGVAR(onRefill))) != "")
Loading

0 comments on commit ead660b

Please sign in to comment.