-
Notifications
You must be signed in to change notification settings - Fork 16
Adding A Support
This will show how to configure a callable support with the shop. It is not a terribly complicated process and just requires a few minor additions to a few files.
Headers\descriptionEXT\supports.hpp
-
Headers\descriptionEXT\GUI\shopGUICommonDefines.hpp
(optional)
-
Headers\descriptionEXT\supportDefines.hpp
(optional)
Functions\Supports\fn_callingForSupportMaster.sqf
Here we are going to come up with a classname and the text (that shows up in the shop) for the support item.
- Open
Headers\descriptionEXT\supportDefines.hpp
- Find a spot to define your stuff in the file; you can just go to the bottom if you don't care about being neat.
- Come up with a shorthand means of referring to your support. Here, I will just use
MY_SUPPORT
. (SEE NOTE 1) You will want two#define
s for the text and the class such as below.
#define MY_SUPPORT_CLASS
#define MY_SUPPORT_TEXT
- Now add the actual text to these entries. Remember, the TEXT is what will show up in the shop. DO NOT put quotations around the class name as this is not a string.
#define MY_SUPPORT_CLASS mySupport_commMenu
#define MY_SUPPORT_TEXT "My - Support"
- Open
Headers\descriptionEXT\supports.hpp
- Create a class for your support. If you made a
#define
in the previous section, use that in place of a class name. Also have the class inherit from thebasicSupport_baseClass
like below.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
};
- Now we will add in the required properties to the class:
3a. Add price
which is how much it will cost in the shop.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
};
3b. Add category
which determines what section in the shop that the item will be under. This will be a STRING entry. (SEE NOTE 2)
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
category = OTHER_CATEGORY;
};
3c. Add the text
property which will be what the item's name is in the shop. This will be a STRING. If you created a #define
for the TEXT in the step above, use it here.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
category = OTHER_CATEGORY;
text = MY_SUPPORT_TEXT;
};
3d. Add in the expression
property. All expression properties should be the #define
CALL_SUPPORT_MASTER
followed by the class name of the class.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
category = OTHER_CATEGORY;
text = MY_SUPPORT_TEXT;
expression = CALL_SUPPORT_MASTER(MY_SUPPORT_CLASS);
};
3e. (optional) Lastly, you can add an property for the for the image icon that will show up in the player's support menu after purchasing. You can find several included image paths defined at the top of the current file.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
category = OTHER_CATEGORY;
text = MY_SUPPORT_TEXT;
expression = CALL_SUPPORT_MASTER(MY_SUPPORT_CLASS);
icon = CALL_ICON;
};
- (optional) There is one more config property that you may find useful to your class. If you want to only allow certain supports when a mod is loaded, use the
patch
property. This string is to be a class that will show up in theCfgPatches
config when the mod is loaded. Leaving it as an empty string (or not defining the property) assumes that the support should always be available and is vanilla compatible.
class MY_SUPPORT_CLASS : basicSupport_baseClass
{
price = 1;
category = OTHER_CATEGORY;
text = MY_SUPPORT_TEXT;
expression = CALL_SUPPORT_MASTER(MY_SUPPORT_CLASS);
icon = CALL_ICON;
patch = "3denEnhanced"; // now it will only work if 3denEnhanced is loaded
};
- As of
0.9.0
, if you are adding an artillery support, ensure that you add theammoType
property. This is simply the ammo's classname from the configCfgAmmo
. Here's and example from SOG PF:
// 105 arty
class ARTILLERY_STRIKE_105MM_AB_CLASS : ARTILLERY_STRIKE_155MM_HE_CLASS
{
price = 900;
text = ARTILLERY_STRIKE_105MM_AB_TEXT;
expression = CALL_SUPPORT_MASTER(ARTILLERY_STRIKE_105MM_AB_CLASS);
ammoType = "vn_shell_105mm_m1_ab_ammo";
patch = "data_f_vietnam";
};
- Open
Functions\Supports\fn_callingForSupportMaster.sqf
. - Add in an
if () exitWith {};
statement for your support class. Include the#define
ofCHECK_SUPPORT_CLASS
along with your class name you made above in the condition. Place the code you want to execute when a player calls for the support inside this.
if (CHECK_SUPPORT_CLASS(MY_SUPPORT_CLASS)) exitWith {
// my support stuff happens here
};
- The parameters for the file are:
0: _caller <OBJECT> - The player calling for support
1: _targetPosition <ARRAY> - The position (AGLS) at which the call is being made
(where the player is looking or if in the map, the position where their cursor is)
2: _supportClass <STRING> - The class as defined in the CfgCommunicationMenu
- A couple notes about some useful #defines in the file:
4a. ADD_SUPPORT_BACK
- This will automatically add the called support back into the player's support menu inventory. Supports are ALWAYS removed when called. If say another condition is not met for the support, you can use this to stop players losing it. Here's an example:
if (CHECK_SUPPORT_CLASS(MY_SUPPORT_CLASS)) exitWith {
if (thisBoolIsTrue) then {
// proceed with my support
} else {
// do not proceed with my support
ADD_SUPPORT_BACK // this never needs a ";"
hint "The bool wasn't true so no damage done, here's your support back";
};
};
4b. CHECK_POSITION
- The check position defines ensures that the player passed a valid position for the support. E.g. if they are calling in something that you want the position for, this will make sure that they aren't looking up at the sky when they call it in, therefore giving you an incorrect position. This will automatically exit the scope it's in and use ADD_SUPPORT_BACK
. It also informs the player that they need a valid position for the support.
if (CHECK_SUPPORT_CLASS(MY_SUPPORT_CLASS)) exitWith {
CHECK_POSITION // will exitWith and not continue down if position is invalid
if (thisBoolIsTrue) then {
// proceed with my support
} else {
// do not proceed with my support
ADD_SUPPORT_BACK // this never needs a ";"
hint "The bool wasn't true so no damage done, here's your support back";
};
};
- You are of course free to ignore my naming scheme and come up with something else. These defines are for convenience sake.
- Shop categories are taken straight from the config. What this means is that you can put any string into the
category
section and it will be added to the shop. To create a new#define
category or to see the already defined ones, go toHeaders\descriptionEXT\GUI\shopGUICommonDefines.hpp
.