Spearhead 1944 Map Vote UI: Difference between revisions
m (→Example Scenario: Link template usage) |
|||
Line 159: | Line 159: | ||
= Example Scenario = | = Example Scenario = | ||
{{Link/External|link=https:// | {{Link/External|link=https://drive.google.com/drive/folders/1A0gSMkaNi7Xx7FadH8D9TKrIbFC3UTaz|text=Download}} | ||
[[Category: Spearhead 1944]] | [[Category: Spearhead 1944]] |
Latest revision as of 11:51, 6 September 2024
The Spearhead 1944 CDLC introduces an unique way to allow for scenario customization based on player choice - the voting UI.
It is shown after the regular briefing phase but before the mission is meant to start. Therefore you can make the players with their voting influence the mission setup or flow of the mission considerably this way.
It can be utilized in various ways - anything you can imagine. Like:
- Different start positions to choose from
- Different loadouts
- Alternative tasks/mission goals
- Different type of friendly support
System features:
- Autogenerated UI for up to six voting options
- Each group with playable units can have its own vote, or multiple groups can vote together on a set of choices
- Supports images, title and description
- Customizable voting timer
- Singleplayer and multiplayer compatible
- Easy to set up
Configuration
Placing Map Markers
In order for the vote UI to know the locations of your voting positions, we will use markers. In our example we call them start_n where n is going to be a number from 1 to 2 to create two voting options. The number of markers defines how many voting options will be available. Up to six voting options are supported e.g. start_1, start_2, ..., start_6 Place the markers where the voting options should appear on the map.
Adding the UI Code
The code for the voting logic runs on all machines, client, hosted server and dedicated server. Thus, best place to execute it is from within the init.sqf.
init.sqf
Function Parameters
Syntax
Parameters
- _prefix: String - Prefix of all voting markers e.g. start_1, start_2, ..., start_6, optional, default "player_spawn_"
- _condition: Code - Condition that must be true for given player in order to see the vote, optional, default {[[true]]}
- _completionCondition: Code - Condition that must be true for the voting to be considered done, optional, default {[[time]] > 1}
- _clientCode: Code - Code that is executed on the client when the voting has finished and for JIP player, optional, default {params ["_prefix", "_marker", "_conditionResult"];}
- _completionCode: Code - Code that is executed on the server when the voting has finished, optional, default {params ["_prefix", "_marker"];}
- _updateSelectionCode: Code - Code that is executed on the client when the voting selection changes, optional, default {params ["_prefix", "_winningMarkers", "_allMarkers"];}
- _hoverCandidateCode: Code - Code that is executed on the client when hovering over the voting option, optional, default {params ["_marker", "_hover", "_conditionResult", ["_cleanup", false]];}
- _groupIcons: Array - Vote textures used for the map voting markers, optional, default ["selector_selectedFriendly", "selector_selectedEnemy", "selector_selectedFriendly", "selector_selectedEnemy"] //TODO: What is this exactly?
- _groupIconParams: Array - Vote colors used for the map voting markers, optional, default [[VOTE_UI_COLOUR_DEFAULT_RGBA], [VOTE_UI_COLOUR_VOTED_RGBA], [0.7, 0.7, 0.7, 0], [0.5, 1, 0.5, 0]] //TODO: What is this exactly?
- _cfgOrbat: Array of arrays - CfgORBAT parameters used to fill map voting markers, optional, default []
- _defaultSelection: String - Marker name that is selected by default, optional, default ""
- _uiData: Array of arrays - Data to fill the UI, optional, default []
- _timer: Boolean, Code, Number, String - Voting timer setting, optional, default []
- When Boolean - ???
- When Code - First number in array will be used
- When Number - Value is used as timer
- When String - A missionNamespace variable with given name is begin looked up for a valid value
- _uiFadeOutCondition: Code - Condition to fade out the voting UI, optional, default {missionNamespace getVariable [QGVAR(array), []] isEqualTo []}
- _waitForPlayers: Boolean - Should UI wait for players, default false
Debugging
Extended logging is available if SPE_MapVote_Debug is set to true. The variable should be set to true for both server and clients to fully understand what is happening.
After Voting
After the voting has finished and the winner was evaluated, the result of the vote is saved into SPE_MissionUtilityFunctions_MapVote_Start_Marker. This variable holds the marker name of the voting option that has won. We can now use that result to adjust our scenario accordingly. For example we can move players around, hide certain compositions, change loadouts or enemy presence.