-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #621 from KillahPotatoes/v0.97S13-530
Side missions framework
- Loading branch information
Showing
35 changed files
with
1,472 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# KP Liberation Module Description | ||
|
||
## Misison Module | ||
This module provides an mission framework to register created missions. | ||
Also it provides a dialog which can start and abort sidemissions. | ||
|
||
### Dependencies | ||
* Init | ||
* Common | ||
* Permission | ||
|
||
### Consumed events | ||
**KPLIB_doLoad** (server side) | ||
Calls KPLIB_fnc_mission_loadData to process saved module data | ||
|
||
**KPLIB_doSave** (server side) | ||
Calls KPLIB_fnc_mission_saveData to add the module data to the save array | ||
|
||
**KPLIB_missionExec** (server side) | ||
Processes a mission start or abort dependent on the passed arguments | ||
|
||
**KPLIB_missionEnd** (server side) | ||
Calls KPLIB_fnc_mission_endMission to delete the ended mission from the running missions | ||
|
||
### Emitted events | ||
**KPLIB_missionExec** (server side) | ||
Processes a mission start or abort dependent on the passed arguments | ||
|
||
### Functions | ||
* KPLIB_fnc_mission_abortMission | ||
|
||
*Aborts the given mission.* | ||
|
||
* KPLIB_fnc_mission_buttonClick | ||
|
||
*Selects which mission should be started/aborted and starts th next function.* | ||
|
||
* KPLIB_fnc_mission_displayMission | ||
|
||
*Displays the information for the given mission.* | ||
|
||
* KPLIB_fnc_mission_endMission | ||
|
||
*Deletes the mission from the running missions* | ||
|
||
* KPLIB_fnc_mission_loadData | ||
|
||
*Loads data which is bound to the this module from the given save data or initializes needed data for a new campaign.* | ||
|
||
* KPLIB_fnc_mission_openDialog | ||
|
||
*Opens the mission dialog.* | ||
|
||
* KPLIB_fnc_mission_postInit | ||
|
||
*Module post initialization.* | ||
|
||
* KPLIB_fnc_mission_preCheck | ||
|
||
*Checks the mission conditions on a changing selection and disables the button.* | ||
|
||
* KPLIB_fnc_mission_preInit | ||
|
||
*Module pre initialization* | ||
|
||
* KPLIB_fnc_mission_readData | ||
|
||
*Reads the data of the given listbox.* | ||
|
||
* KPLIB_fnc_mission_registerMission | ||
|
||
*Registers a mission for the usage as event or "buyable" sidemission.* | ||
|
||
* KPLIB_fnc_mission_saveData | ||
|
||
*Fetches data which is bound to this module and send it to the global save data array.* | ||
|
||
* KPLIB_fnc_mission_settings | ||
|
||
*CBA Settings initialization for this module.* | ||
|
||
* KPLIB_fnc_mission_setupPlayerActions | ||
|
||
*Initialization of actions available to players.* | ||
|
||
* KPLIB_fnc_mission_startMission | ||
|
||
*Starts the given mission or selects one from the given array.* | ||
|
||
### Scripts | ||
No scripts will be started by this module |
89 changes: 89 additions & 0 deletions
89
Missionframework/modules/27_mission/fnc/fn_mission_abortMission.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "script_component.hpp" | ||
/* | ||
KPLIB_fnc_mission_abortMission | ||
File: fn_mission_abortMission.sqf | ||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes | ||
Date: 2019-06-13 | ||
Last Update: 2019-06-23 | ||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html | ||
Public: No | ||
Description: | ||
Aborts the given mission. | ||
Parameter(s): | ||
_mission - String of the mission [STRING, defaults to ""] | ||
Returns: | ||
Function reached the end [BOOL] | ||
*/ | ||
|
||
params [ | ||
["_mission", "", [""]] | ||
]; | ||
|
||
// Exit if one of the condition isn't true | ||
if (_mission isEqualTo "") exitWith { | ||
false | ||
}; | ||
|
||
// Get data from namespace | ||
private _missionData = MGVAR(_mission, []); | ||
private _runningMissions = MGVAR("runningMissions", []); | ||
private _cost = _missionData select 9; | ||
_cost params [ | ||
"_costSupply", | ||
"_costAmmo", | ||
"_costFuel", | ||
"_costIntel" | ||
]; | ||
private _FOB = (_runningMissions select (_runningMissions findIf {(_x select 0) isEqualTo _mission})) select 1; | ||
private _crateCapacity = 0; | ||
private _crateCount = 0; | ||
_costSupply = _costSupply * (KPLIB_param_missionRefund / 100); | ||
_costAmmo = _costAmmo * (KPLIB_param_missionRefund / 100); | ||
_costFuel = _costFuel * (KPLIB_param_missionRefund / 100); | ||
_costIntel = _costIntel * (KPLIB_param_missionRefund / 100); | ||
|
||
// Check if the mission is a buyable mission and if there's enough empty storage capacity | ||
if !(_missionData select 0) then { | ||
private _supplyCrates = ceil (_costSupply / KPLIB_param_crateVolume); | ||
private _ammoCrates = ceil (_costAmmo / KPLIB_param_crateVolume); | ||
private _fuelCrates = ceil (_costFuel / KPLIB_param_crateVolume); | ||
private _crateCount = _supplyCrates + _ammoCrates + _fuelCrates; | ||
private _storages = [getMarkerPos _FOB, KPLIB_param_fobRange] call KPLIB_fnc_resources_getStorages; | ||
|
||
{ | ||
_crateCapacity = _crateCapacity + ([_x] call KPLIB_fnc_resources_getStorageSpace); | ||
} forEach _storages; | ||
}; | ||
|
||
// Exit if there's not enough storage | ||
if (_crateCapacity < _crateCount) exitWith { | ||
[ | ||
["a3\3den\data\controlsgroups\tutorial\close_ca.paa", 1, [1,0,0]], | ||
[localize "STR_KPLIB_HINT_MISSIONSTORAGE"] | ||
] call CBA_fnc_notify; | ||
false | ||
}; | ||
|
||
// Delete the mission from the running mission data | ||
_runningMissions deleteAt (_runningMissions findIf {(_x select 0) isEqualTo _mission}); | ||
|
||
// Refund the costs | ||
if !(_cost isEqualTo [0, 0, 0, 0]) then { | ||
[_FOB, _costSupply, _costAmmo, _costFuel] call KPLIB_fnc_resources_refund; | ||
[_costIntel] call KPLIB_fnc_resources_addIntel; | ||
}; | ||
|
||
// Set data in namespace | ||
MSVAR("runningMissions", _runningMissions); | ||
|
||
// Execute the abort function via server event | ||
["KPLIB_missionExec", [_missionData select 2]] call CBA_fnc_serverEvent; | ||
|
||
closeDialog 0; | ||
[{!dialog}, {[] call KPLIB_fnc_mission_openDialog;}] call CBA_fnc_waitUntilAndExecute; | ||
|
||
true |
Oops, something went wrong.