Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PVP Jets Redux #7

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
651bddb
Initial revision
3Mydlo3 Feb 4, 2023
9794e15
Remove required addons
3Mydlo3 Feb 4, 2023
e310330
Fix ACE GForce modifier reset after death
3Mydlo3 Feb 4, 2023
87dee5f
Add automatic ACRE radio setup
3Mydlo3 Feb 4, 2023
2ff722c
Remove some random ai pilot
3Mydlo3 Feb 4, 2023
9ae0e51
Modernize description.ext a bit
3Mydlo3 Feb 4, 2023
da48f1d
Kill pilot when plane is destroyed
3Mydlo3 Feb 4, 2023
af90832
Fix locality issues
3Mydlo3 Feb 4, 2023
e5d5ed9
Fix plane respawn
3Mydlo3 Feb 4, 2023
0c337f8
Destroy plane after player leaves it
3Mydlo3 Feb 4, 2023
b0072e5
Rework the gamemode into configurable presets with dynamic spawns
veteran29 Feb 6, 2023
3047a0b
Refactor plane launch into dedicated func, handle leftover planes
veteran29 Feb 6, 2023
61a09bc
Fix plane catapult locality
veteran29 Feb 6, 2023
b8b1d1c
Add notifications about position in queue
veteran29 Feb 6, 2023
344e81f
Fix double init
veteran29 Jan 11, 2024
ec964ec
Remove weapons which do not have any pylons/magazines
veteran29 Jan 11, 2024
50cc720
Mission rename
veteran29 Jan 11, 2024
169ab5b
Fix init on dedicated server and handle admin desync
veteran29 Jan 11, 2024
6dedaee
Fix wrong catapult used in MP
veteran29 Jan 11, 2024
6751164
Fix catapults and missing pylons in MP
veteran29 Jan 11, 2024
519c0e2
Fix ACRE preset handling
veteran29 Jan 11, 2024
96b6215
Remove ItemRadio from players
veteran29 Jan 11, 2024
c016c2b
Add ItemRadio if no ACRE
veteran29 Jan 11, 2024
86eeb59
Fix catapult collisions
veteran29 Jan 12, 2024
e86be26
Add CBA settings file
veteran29 Jan 12, 2024
4abe149
Set preset for mounted radios
veteran29 Jan 12, 2024
1f19437
Auto setup radio presets
veteran29 Jan 12, 2024
2a78b4b
Fix ACRE error
veteran29 Jan 12, 2024
ab0f742
Fix viewdistance gui
veteran29 Jan 15, 2024
65655b3
Add side and shared radios to player on spawn and respawn
veteran29 Jan 15, 2024
00a53f4
Fix mission settings not being forced
veteran29 Jan 15, 2024
9d589d0
Fix mission init without acre, fix view distance actio
veteran29 Jan 15, 2024
1bd94de
Add WIP for manual tickets handling
veteran29 Jan 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions PvP/PvP_Jets_Redux.Altis/MDL/config.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

MDL_PVP_Radio_Presets_Hash = createHashmapFromArray [
[WEST, "blufor"],
[EAST, "redfor"]
];

private _l159PylonLoadout = [
["Pylons1", "PylonWeapon_300Rnd_20mm_shells"],
["Pylons2", "PylonRack_7Rnd_Rocket_04_HE_F"],
["Pylons3", "PylonRack_7Rnd_Rocket_04_HE_F"],
["Pylons4", "PylonWeapon_300Rnd_20mm_shells"],
["Pylons5", "PylonRack_7Rnd_Rocket_04_HE_F"],
["Pylons6", "PylonRack_7Rnd_Rocket_04_HE_F"],
["Pylons7", "PylonWeapon_300Rnd_20mm_shells"]
];

MDL_PVP_presetsHash = createHashMapFromArray [
["L159", createHashMapFromArray [
["displayName", "L159"],
[WEST, createHashMapFromArray [
["plane", "I_Plane_Fighter_03_dynamicLoadout_F"],
["loadout", _l159PylonLoadout],
["textures", [
[0, "#(rgb,8,8,3)color(0,1,0,0.2)"],
[1, "#(rgb,8,8,3)color(0,1,0,0.2)"]
]]
]],
[EAST, createHashMapFromArray [
["plane", "I_Plane_Fighter_03_dynamicLoadout_F"],
["loadout", _l159PylonLoadout],
["textures", [
[0, "#(rgb,8,8,3)color(1,0,0,0.2)"],
[1, "#(rgb,8,8,3)color(1,0,0,0.2)"]
]]
]]
]]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

params ["_player"];

if (!isNull (_player getVariable ["MDL_PVP_handlingSpawner", objNull]) && {!is3DENPreview}) exitWith {
diag_log text format ["[PVP] ERROR: onStartRequest - player %1 already in queue", name _player];
};

private _spawner = missionNamespace getVariable format ["MDL_PVP_catapult%1", side group _player];
_player setVariable ["MDL_PVP_handlingSpawner", _spawner, true];

diag_log text format ["[PVP] INFO: onStartRequest - adding player %1 to queue for %2", name _player, _spawner];

private _queue = _spawner getVariable "MDL_PVP_queue";
if (isNil "_queue") then {
_queue = [];
_spawner setVariable ["MDL_PVP_queue", _queue];
};

_queue pushBack _player;

if (count _queue == 1) then {
diag_log text format ["[PVP] INFO: onStartRequest - starting queue for %1", _spawner];

private _fnc_queue = {
params ["_fnc_queue", "_spawner", "_queue"];
if (_queue isEqualTo []) exitWith {
diag_log text format ["[PVP] INFO: onStartRequest - empty queue for %1", _spawner];
};

//--- check if last spawned plane has pilot / moved from spawn
private _lastPlane = _spawner getVariable ["MDL_PVP_spawnerLastPlane", objNull];
if (!isNull _lastPlane && (crew _lastPlane isEqualTo [])) then {
diag_log text format ["[PVP] ERROR: onStartRequest - last spawned plane is empty %1", _spawner];
deleteVehicle _lastPlane;
};
//-------------

private _player = _queue deleteAt 0;
["MDL_PVP_startPosition", [_queue], _queue] call CBA_fnc_targetEvent;

private _plane = [_spawner, _player] call MDL_PvPJets_fnc_launchPlane;

_spawner setVariable ["MDL_PVP_spawnerLastPlane", _plane];
_spawner setVariable ["MDL_PVP_spawnerLastSpawnTime", CBA_missionTime];
_player setVariable ["MDL_PVP_handlingSpawner", nil, true];

// handle next queue element
[_fnc_queue, _this, 5] call CBA_fnc_waitAndExecute;
};

private _lastSpawn = _spawner getVariable ["MDL_PVP_spawnerLastSpawnTime", 0];
private _delay = [5, 1] select ((CBA_missionTime - _lastSpawn) > 5);

[_fnc_queue, [_fnc_queue, _spawner, _queue], _delay] call CBA_fnc_waitAndExecute;
};
77 changes: 77 additions & 0 deletions PvP/PvP_Jets_Redux.Altis/MDL/fnc/MDL_PVPJets_fnc_spawnPlane.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

params [
["_spawner", nil, [objNull]],
["_side", nil, [sideUnknown]]
];

private _preset = MDL_PVP_preset get _side;
private _class = _preset get "plane";

diag_log text format ["[PVP] DEBUG: spawnPlane - spawning %1 for %2 at %3", _class, _side, _spawner];

private _plane = createVehicle [_class, [0,0,0], [], 0, "NONE"];
_plane setPosASL getPosASL _spawner;
_plane setDir getDir _spawner;

// handle plane being shot down
_plane setVariable ["MDL_PVPJets_Ready", true];
_plane setVariable ["MDL_PVPJets_side", _side];
_plane addMPEventHandler ["MPKilled", {if (isServer) then {call MDL_PvPJets_fnc_onPlaneKilled}}];
_plane addEventHandler ["GetOut", {call MDL_PvPJets_fnc_onPlaneGetOut}];

if (_preset getOrDefault ["loadout", []] isNotEqualTo []) then {
diag_log text "[PVP] DEBUG: spawnPlane - adjusting pylon loadout";

_plane setVariable ["MDL_PVPJets_Ready", false];

private _turret = [-1];
private _previousTurretPylonsMagazines = getAllPylonsInfo _plane select {(_x select 2) isEqualTo _turret} apply {_x select 3};
_previousTurretPylonsMagazines = (_previousTurretPylonsMagazines arrayIntersect _previousTurretPylonsMagazines);

{
[_plane, (_x + [true])] remoteExec ["setPylonLoadout", 0];
} forEach (_preset get "loadout");

[{
params ["_plane", "_turret", "_previousTurretPylonsMagazines"];

private _currentTurretPylonsMagazines = getAllPylonsInfo _plane select {(_x select 2) isEqualTo _turret} apply {_x select 3};
_currentTurretPylonsMagazines = (_currentTurretPylonsMagazines arrayIntersect _currentTurretPylonsMagazines);

//---- remove pylon weapons without magazines
private _pylonsWeapons = _currentTurretPylonsMagazines apply {getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")};
{
private _magazine = _x;
private _magazineWeapon = getText (configFile >> "CfgMagazines" >> _magazine >> "pylonWeapon");
// remove weapon if none of the loaded pylons use it
// do not optimize with `in` or `find` as these are case sensitive
if (_pylonsWeapons findIf {_magazineWeapon == _x} > -1) then {continue};
[_plane, [_magazineWeapon, _turret]] remoteExec ["removeWeaponTurret", 0];
} forEach _previousTurretPylonsMagazines;

[{_this setVariable ["MDL_PVPJets_Ready", true]}, _plane, 1] call CBA_fnc_waitAndExecute;
}, [_plane, _turret, _previousTurretPylonsMagazines], 1] call CBA_fnc_waitAndExecute;

};

if (_preset getOrDefault ["textures", []] isNotEqualTo []) then {
diag_log text "[PVP] DEBUG: spawnPlane - adjusting textures";
{
_plane setObjectTextureGlobal _x;
} forEach (_preset get "textures");
};

_plane setVehicleReportOwnPosition true;
_plane setVehicleReportRemoteTargets true;
_plane setVehicleReceiveRemoteTargets true;

_plane allowDamage false;
[{_this allowDamage true}, _plane, 10] call CBA_fnc_waitAndExecute;

if (ACRE_Loaded) then {
private _radioPreset = MDL_PVP_Radio_Presets_Hash get _side;
diag_log text format ["[PVP] DEBUG: spawnPlane - radioPreset %1", _radioPreset];
[_plane, _radioPreset] call acre_api_fnc_setVehicleRacksPreset;
};

_plane // return
156 changes: 156 additions & 0 deletions PvP/PvP_Jets_Redux.Altis/MDL/fnc/MDL_PvPJets_fnc_configureDialog.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#include "\a3\ui_f\hpp\definecommoncolors.inc"

if (!hasInterface) exitWith {};
if (missionNamespace getVariable ["MDL_PVP_configured", false]) exitWith {
diag_log text "[PVP] INFO: gamemode already configured";
};

diag_log text "[PVP] INFO: configure dialog";

private _display = uiNamespace getVariable "RscDisplayMission";
_display = _display createDisplay "RscDisplayEmpty";
(uiNamespace setVariable ["MDL_PVP_ConfigureDialog", _display]);

_display displayAddEventHandler ["KeyDown", {
params ["_display", "_dik"];
if (_dik == 1) exitWith {
[] spawn {
disableSerialization;
private _interruptDisplay = (findDisplay 46) createDisplay "RscDisplayInterrupt";
waitUntil {_interruptDisplay isEqualTo displayNull};
[] call MDL_PvPJets_fnc_configureDialog;
};
};
true
}];

if (player != [] call MDL_PVPJets_fnc_getAdmin) exitWith {
"MDL_PVP_Wait" cutText [localize "STR_LOAD_GAME", "BLACK FADED", 1e10];
};

"MDL_PVP_Wait" cutText ["", "BLACK IN"];
player setVariable ["MDL_PVP_Admin", true];

private _dlgW = safeZoneW / 4;
private _dlgH = safeZoneH / 2;

private _dlgX = safeZoneX + (safeZoneW/2 - _dlgW/2);
private _dlgY = safeZoneY + (safeZoneH/2 - _dlgW/2);

private _titleColor = [
profileNamespace getVariable ["GUI_BCG_RGB_R", 0.13],
profileNamespace getVariable ["GUI_BCG_RGB_G", 0.54],
profileNamespace getVariable ["GUI_BCG_RGB_B", 0.21],
profileNamespace getVariable ["GUI_BCG_RGB_A", 0.8]
];

private _titleTextColor = [
profileNamespace getVariable ["GUI_TITLETEXT_RGB_R", 1.0],
profileNamespace getVariable ["GUI_TITLETEXT_RGB_G", 1.0],
profileNamespace getVariable ["GUI_TITLETEXT_RGB_B", 1.0],
profileNamespace getVariable ["GUI_TITLETEXT_RGB_A", 0.6]
];

// full screen background
private _ctrlBg = _display ctrlCreate ["RscBackgroundGUI", -1];
_ctrlBg ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH];
_ctrlBg ctrlCommit 0;

//--------- dialog layout
// header
private _headerH = _dlgH * 0.05;
private _ctrlHeader = _display ctrlCreate ["RscText", -1];
_ctrlHeader ctrlSetText toUpper localize "STR_AFSG_PvPJets_Configure";
_ctrlHeader ctrlSetTextColor _titleTextColor;
_ctrlHeader ctrlSetBackgroundColor _titleColor;
_ctrlHeader ctrlSetPosition [_dlgX, _dlgY, _dlgW, _headerH - pixelH*2];
_ctrlHeader ctrlCommit 0;

// main controls group
private _mainH = _dlgH * 0.85;
private _ctrlMainGrp = _display ctrlCreate ["RscControlsGroup", -1];
_ctrlMainGrp ctrlSetPosition [_dlgX, _dlgY + _headerH, _dlgW, _mainH];
_ctrlMainGrp ctrlCommit 0;

// footer / button
private _ctrlContinue = _display ctrlCreate ["RscButton", -1];
_ctrlContinue ctrlSetText localize "STR_DISP_HINTC_CONTINUE";
_ctrlContinue ctrlSetPosition [_dlgX, _dlgY + (_headerH + _mainH) + pixelH*2, _dlgW, _dlgH * 0.1 - pixelH*2];
_ctrlContinue ctrlCommit 0;
_ctrlContinue ctrlEnable false;
uiNamespace setVariable ["MDL_PVP_ctrlContinue", _ctrlContinue];

_ctrlContinue ctrlAddEventHandler ["ButtonClick", {
publicVariable "MDL_PVP_preset";
publicVariable "MDL_PVP_tickets";
missionNamespace setVariable ["MDL_PVP_configured", true, true];

ctrlParent (_this#0) closeDisplay 1;
}];

//-------------------------

private _ctrlPreset = _display ctrlCreate ["RscListBox", -1, _ctrlMainGrp];
_ctrlPreset ctrlSetPosition [0, 0, _dlgW, _mainH * 0.5];
_ctrlPreset ctrlCommit 0;
uiNamespace setVariable ["MDL_PVP_ctrlPreset", _ctrlPreset];

// fill the list of available presets
private _cfgVehicles = configFile >> "CfgVehicles";
{
private _preset = _y;
private _idx = _ctrlPreset lbAdd (_preset get "displayName");

if ([WEST, EAST] findIf {isNull (_cfgVehicles >> (_preset get _x get "plane"))} != -1) then {
_ctrlPreset lbSetData [_idx, ""];
} else {
_ctrlPreset lbSetData [_idx, _x];
};
} forEach MDL_PVP_presetsHash;

// handle missing preset plane (mods not loaded)
_ctrlPreset ctrlAddEventHandler ["LBSelChanged", {
params ["_ctrlPreset", "_idx"];

private _preset = _ctrlPreset lbData _idx;
private _planeAvailable = _preset != "";
private _ctrlContinue = uiNamespace getVariable "MDL_PVP_ctrlContinue";

_ctrlContinue ctrlEnable _planeAvailable;
if (!_planeAvailable) then {
_ctrlContinue ctrlSetTooltip "Selected preset plane is not available";
} else {
_ctrlContinue ctrlSetTooltip "Continue and start the Game Mode";
};

MDL_PVP_preset = MDL_PVP_presetsHash get _preset;
}];

_ctrlPreset lbSetCurSel 0;

private _ctrlTicketsGroup = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _ctrlMainGrp];
_ctrlTicketsGroup ctrlSetPosition [0, _mainH * 0.5, _dlgW, _mainH * 0.1];
_ctrlTicketsGroup ctrlCommit 0;

private _ctrlTickets = _display ctrlCreate ["ctrlXSliderH", -1, _ctrlTicketsGroup];
_ctrlTickets ctrlSetPosition [0, 0 + pixelH*5/2, _dlgW * 0.7, _mainH * 0.1 - pixelH*5];
_ctrlTickets ctrlCommit 0;
uiNamespace setVariable ["MDL_PVP_ctrlTickets", _ctrlTickets];

_ctrlTickets sliderSetRange [200, 2000];
_ctrlTickets sliderSetSpeed [100, 10, 10];
_ctrlTickets sliderSetPosition MDL_PVP_tickets;
_ctrlTickets ctrlAddEventHandler ["SliderPosChanged", {
params ["_ctrlTickets", "_value"];

private _ctrlTicketsText = uiNamespace getVariable "MDL_PVP_ctrlTicketsText";
_ctrlTicketsText ctrlSetText format [localize "STR_AFSG_PvPJets_ConfigureTickets", sliderPosition _ctrlTickets];

MDL_PVP_tickets = _value;
}];

private _ctrlTicketsText = _display ctrlCreate ["RscText", -1, _ctrlTicketsGroup];
_ctrlTicketsText ctrlSetPosition [_dlgW * 0.7, 0, _dlgW * 0.3, _mainH * 0.1];
_ctrlTicketsText ctrlCommit 0;
uiNamespace setVariable ["MDL_PVP_ctrlTicketsText", _ctrlTicketsText];
_ctrlTicketsText ctrlSetText format [localize "STR_AFSG_PvPJets_ConfigureTickets", sliderPosition _ctrlTickets];
6 changes: 6 additions & 0 deletions PvP/PvP_Jets_Redux.Altis/MDL/fnc/MDL_PvPJets_fnc_getAdmin.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

if (player getVariable ["MDL_PVP_Admin", false]) exitWith {
player // return
};

allPlayers select {_x call BIS_fnc_admin > 0} param [0, allPlayers select 0] // return
Loading