Skip to content
squigz edited this page Aug 24, 2022 · 2 revisions

Note that I'm figuring these things out as I go. There's likely to be some incorrect info here. You've been warned.

Adding new mission parameters

tl;dr
stringtable.xml
<Key ID="STR_PARAM_BLUFOR_DEFENDERS">
    <Original>BLUFOR defenders in owned sectors</Original>
    You can include translations like so:
    <French>Défenseurs BLUFOR dans les secteurs capturés</French>
</Key>
ui/mission_params.hpp
class BluforDefenders {
    title = $STR_PARAM_BLUFOR_DEFENDERS;
    values[] = {1, 0};
    texts[] = {$STR_PARAMS_ENABLED, $STR_PARAMS_DISABLED};
    default = 1;
};
scripts/shared/fetch_params.sqf
GET_PARAM_BOOL(GRLIB_blufor_defenders, "BluforDefenders", 1);

1) Add a new entry to stringtable.xml

  • The text in <Original> will be shown to the user on the parameter selection screen
<Key ID="STR_PARAM_<param name>">
    <Original>Full version of the parameter name</Original>
    You can include translations like so:
    <French> ... </French>
</Key>
Example:
<Key ID="STR_PARAM_BLUFOR_DEFENDERS">
    <Original>BLUFOR defenders in owned sectors</Original>
    <!-- You can include translations like so -->
    <French>Défenseurs BLUFOR dans les secteurs capturés</French>
</Key>

2) Define the parameter in ui/mission_params.hpp

  • The title is the ID you provided in stringtable.xml
  • The class name is what you'll use to retrieve the parameter value in the next step
  • This is where you define the options & default values. Parameters are added in the order they're listed, so add new ones near related parameters
class ParamClass {
    title = $STR_PARAM_<param name>;
    values[] = {1, 0};
    texts[] = {$STR_PARAMS_ENABLED, $STR_PARAMS_DISABLED};
    default = 1;
};
Example:
class BluforDefenders {
    title = $STR_PARAM_BLUFOR_DEFENDERS;
    values[] = {1, 0};
    texts[] = {$STR_PARAMS_ENABLED, $STR_PARAMS_DISABLED};
    default = 1;
};
The 'texts' array is what's shown on the parameter selection screen; The 'values' array is what scripts/functions/etc receive
  • So if the player chooses x1.5 for this parameter, 5 is what scripts/functions/etc would receive
class ResourcesMultiplier {
    title = $STR_PARAMS_RESOURCESMULTIPLIER;
    values[] = {0, 1, 2, 3, 4, 5, 6, 7};
    texts[] = {"x0.25", "x0.5", "x0.75", "x1", "x1.25","x1.5","x2","x3"};
    default = 3;
};
Parameters are separated into categories with a space & a category header like this
class Spacer1 {
    title = "";
    values[] = {""};
    texts[] = {""};
    default = "";
};
class ReviveOptions {
    title = $STR_PARAMS_REVIVEOPTIONS;
    values[] = {""};
    texts[] = {""};
    default = "";
};

3) Retrieve the parameter in scripts/shared/fetch_params.sqf

  • This is where parameter values are retrieved and stored for later use by scripts/functions/etc
  • variable is what scripts/functions/etc will use to retrieve the parameter value
  • param name is the same as ParamClass from ui/mission_params.hpp
// Use GET_PARAM_BOOL for simple 1/0 params
GET_PARAM_BOOL(<variable>, <param name>, 1);

// Use GET_PARAM for anything more complex
GET_PARAM(<variable>, <param name>, 3);