Skip to content

Commit

Permalink
Add mission parameter to disable replacement of vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
theace0296 committed Oct 14, 2021
1 parent 6fb4469 commit f759cc7
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 82 deletions.
156 changes: 80 additions & 76 deletions RandFramework/Server/init/fn_main.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -133,91 +133,95 @@ TRGM_VAR_FactionSetupCompleted = true; publicVariable "TRGM_VAR_FactionSetupComp

[HQMan] call TRGM_GLOBAL_fnc_setLoadout;

try {
private _airTransClassName = [chopper1, TRGM_VAR_FriendlySide] call TRGM_GLOBAL_fnc_getFactionVehicle;
if (!isNil "chopper1" && {!(isNil "_airTransClassName") && {_airTransClassName != typeOf chopper1}}) then {
{deleteVehicle _x;} forEach crew chopper1 + [chopper1];
private _helipadPos = [heliPad1] call TRGM_GLOBAL_fnc_getRealPos;
private _safePos = _helipadPos findEmptyPosition [0, 20, _airTransClassName];
if !(count _safePos isEqualTo 3) then {
if (count _safePos isEqualTo 2) then {
_safePos = [_safePos # 0, _safePos # 1, _helipadPos # 2];
} else {
_safePos = _helipadPos;
private _bReplaceFriendlyVehicles = [false, true] select ((["ReplaceFriendlyVehicles", 1] call BIS_fnc_getParamValue) isEqualTo 1);

if (_bReplaceFriendlyVehicles) then {
try {
private _airTransClassName = [chopper1, TRGM_VAR_FriendlySide] call TRGM_GLOBAL_fnc_getFactionVehicle;
if (!isNil "chopper1" && {!(isNil "_airTransClassName") && {_airTransClassName != typeOf chopper1}}) then {
{deleteVehicle _x;} forEach crew chopper1 + [chopper1];
private _helipadPos = [heliPad1] call TRGM_GLOBAL_fnc_getRealPos;
private _safePos = _helipadPos findEmptyPosition [0, 20, _airTransClassName];
if !(count _safePos isEqualTo 3) then {
if (count _safePos isEqualTo 2) then {
_safePos = [_safePos # 0, _safePos # 1, _helipadPos # 2];
} else {
_safePos = _helipadPos;
};
};
chopper1 = createVehicle [_airTransClassName, _safePos, [], 0, "NONE"];
[TRGM_VAR_FriendlySide, chopper1, true] call TRGM_GLOBAL_fnc_createVehicleCrew;
chopper1 setVehicleVarName "chopper1";
publicVariable "chopper1";
chopper1 allowDamage false;
heliPad1 setPos ([chopper1] call TRGM_GLOBAL_fnc_getRealPos);
chopper1 setVelocity [0, 0, 0];
chopper1 setdamage 0;
chopper1 engineOn false;
chopper1 lockDriver true;
chopper1D = driver chopper1;
chopper1D setVehicleVarName "chopper1D";
{_x allowDamage false;} forEach crew chopper1;
chopper1D allowDamage false;
chopper1D setCaptive true;
chopper1D disableAI "AUTOTARGET";
chopper1D disableAI "TARGET";
chopper1D disableAI "SUPPRESSION";
chopper1D disableAI "AUTOCOMBAT";
chopper1D setBehaviour "CARELESS";
publicVariable "chopper1D";
private _totalTurrets = [_airTransClassName, true] call BIS_fnc_allTurrets;
{chopper1 lockTurret [_x, true]} forEach _totalTurrets;
{ _x disableAI "MOVE"; } forEach crew chopper1;
[] spawn {
waitUntil { !([chopper1] call TRGM_GLOBAL_fnc_helicopterIsFlying); };
{ _x enableAI "MOVE"; } forEach crew chopper1;
};
};
chopper1 = createVehicle [_airTransClassName, _safePos, [], 0, "NONE"];
[TRGM_VAR_FriendlySide, chopper1, true] call TRGM_GLOBAL_fnc_createVehicleCrew;
chopper1 setVehicleVarName "chopper1";
publicVariable "chopper1";
chopper1 allowDamage false;
heliPad1 setPos ([chopper1] call TRGM_GLOBAL_fnc_getRealPos);
chopper1 setVelocity [0, 0, 0];
chopper1 setdamage 0;
chopper1 engineOn false;
chopper1 lockDriver true;
chopper1D = driver chopper1;
chopper1D setVehicleVarName "chopper1D";
{_x allowDamage false;} forEach crew chopper1;
chopper1D allowDamage false;
chopper1D setCaptive true;
chopper1D disableAI "AUTOTARGET";
chopper1D disableAI "TARGET";
chopper1D disableAI "SUPPRESSION";
chopper1D disableAI "AUTOCOMBAT";
chopper1D setBehaviour "CARELESS";
publicVariable "chopper1D";
private _totalTurrets = [_airTransClassName, true] call BIS_fnc_allTurrets;
{chopper1 lockTurret [_x, true]} forEach _totalTurrets;
{ _x disableAI "MOVE"; } forEach crew chopper1;
[] spawn {
waitUntil { !([chopper1] call TRGM_GLOBAL_fnc_helicopterIsFlying); };
{ _x enableAI "MOVE"; } forEach crew chopper1;
};
};
} catch {};
} catch {};

try {
private _airSupClassName = [chopper2, TRGM_VAR_FriendlySide] call TRGM_GLOBAL_fnc_getFactionVehicle;
if (!isNil "chopper2" && {!(isNil "_airSupClassName") && {_airSupClassName != typeOf chopper2}}) then {
{deleteVehicle _x;} forEach crew chopper2 + [chopper2];
private _helipadPos = [airSupportHeliPad] call TRGM_GLOBAL_fnc_getRealPos;
private _safePos = _helipadPos findEmptyPosition [0, 20, _airSupClassName];
if !(count _safePos isEqualTo 3) then {
if (count _safePos isEqualTo 2) then {
_safePos = [_safePos # 0, _safePos # 1, _helipadPos # 2];
} else {
_safePos = _helipadPos;
try {
private _airSupClassName = [chopper2, TRGM_VAR_FriendlySide] call TRGM_GLOBAL_fnc_getFactionVehicle;
if (!isNil "chopper2" && {!(isNil "_airSupClassName") && {_airSupClassName != typeOf chopper2}}) then {
{deleteVehicle _x;} forEach crew chopper2 + [chopper2];
private _helipadPos = [airSupportHeliPad] call TRGM_GLOBAL_fnc_getRealPos;
private _safePos = _helipadPos findEmptyPosition [0, 20, _airSupClassName];
if !(count _safePos isEqualTo 3) then {
if (count _safePos isEqualTo 2) then {
_safePos = [_safePos # 0, _safePos # 1, _helipadPos # 2];
} else {
_safePos = _helipadPos;
};
};
chopper2 = createVehicle [_airSupClassName, _safePos, [], 0, "NONE"];
[TRGM_VAR_FriendlySide, chopper2, true] call TRGM_GLOBAL_fnc_createVehicleCrew;
chopper2 setVehicleVarName "chopper2";
publicVariable "chopper2";
chopper2 allowDamage false;
airSupportHeliPad setPos ([chopper2] call TRGM_GLOBAL_fnc_getRealPos);
chopper2 setVelocity [0, 0, 0];
chopper2 setdamage 0;
chopper2 engineOn false;
chopper2 lockDriver true;
chopper2D = driver chopper2;
chopper2D setVehicleVarName "chopper2D";
publicVariable "chopper2D";
{_x allowDamage false;} forEach crew chopper2;
private _totalTurrets = [_airSupClassName, true] call BIS_fnc_allTurrets;
{chopper2 lockTurret [_x, true]} forEach _totalTurrets;
{ _x disableAI "MOVE"; } forEach crew chopper2;
[] spawn {
waitUntil { !([chopper2] call TRGM_GLOBAL_fnc_helicopterIsFlying); };
{ _x enableAI "MOVE"; } forEach crew chopper2;
};
};
chopper2 = createVehicle [_airSupClassName, _safePos, [], 0, "NONE"];
[TRGM_VAR_FriendlySide, chopper2, true] call TRGM_GLOBAL_fnc_createVehicleCrew;
chopper2 setVehicleVarName "chopper2";
publicVariable "chopper2";
chopper2 allowDamage false;
airSupportHeliPad setPos ([chopper2] call TRGM_GLOBAL_fnc_getRealPos);
chopper2 setVelocity [0, 0, 0];
chopper2 setdamage 0;
chopper2 engineOn false;
chopper2 lockDriver true;
chopper2D = driver chopper2;
chopper2D setVehicleVarName "chopper2D";
publicVariable "chopper2D";
{_x allowDamage false;} forEach crew chopper2;
private _totalTurrets = [_airSupClassName, true] call BIS_fnc_allTurrets;
{chopper2 lockTurret [_x, true]} forEach _totalTurrets;
{ _x disableAI "MOVE"; } forEach crew chopper2;
[] spawn {
waitUntil { !([chopper2] call TRGM_GLOBAL_fnc_helicopterIsFlying); };
{ _x enableAI "MOVE"; } forEach crew chopper2;
};
};
} catch {};
} catch {};
};

TRGM_VAR_transportHelosToGetActions = [chopper1];
{
try {
if (isClass(configFile >> "CfgVehicles" >> typeOf _x) && {_x isKindOf "LandVehicle" || _x isKindOf "Air" || _x isKindOf "Ship"}) then {
if (_bReplaceFriendlyVehicles && {isClass(configFile >> "CfgVehicles" >> typeOf _x) && {_x isKindOf "LandVehicle" || _x isKindOf "Air" || _x isKindOf "Ship"}}) then {
private _faction = getText(configFile >> "CfgVehicles" >> typeOf _x >> "faction");
private _friendlyFactionIndex = TRGM_VAR_AdvancedSettings select TRGM_VAR_ADVSET_FRIENDLY_FACTIONS_IDX;
private _westFaction = (TRGM_VAR_AvailableFactions select _friendlyFactionIndex) select 0;
Expand Down
30 changes: 24 additions & 6 deletions description.ext
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class CfgRadio
#include "RandFramework\Sounds\cfgRadio.hpp"
};

__COUNTER_RESET__;

#define SPACER(INDEX) class Spacer_##INDEX##\
{\
title = "";\
Expand Down Expand Up @@ -123,7 +125,7 @@ class Params
texts[] = {"1","2","3","4","5","10","Disabled"};
default = 2;
};
SPACER(0);
SPACER(__COUNTER__);
class EnvironmentOptions {
title = "~~ Environment Options ~~";
values[] = {""};
Expand All @@ -137,7 +139,7 @@ class Params
texts[] = {"0.5x (120 minutes real-world = 60 minutes in-game)","1 (60 minutes real-world = 60 minutes in-game)","2 (30 minutes real-world = 60 minutes in-game)","4 (15 minutes real-world = 60 minutes in-game)","6 (10 minutes real-world = 60 minutes in-game)","12 (5 minutes real-world = 60 minutes in-game)"};
default = 1;
};
SPACER(1);
SPACER(__COUNTER__);
class CustomMissionOptions {
title = "~~ Custom Mission Options ~~";
values[] = {""};
Expand All @@ -158,7 +160,7 @@ class Params
texts[] = {"Disable","Enable"};
default = 0;
};
SPACER(2);
SPACER(__COUNTER__);
class CustomFactionOptions {
title = "~~ Custom Faction Options ~~";
values[] = {""};
Expand Down Expand Up @@ -207,7 +209,7 @@ class Params
texts[] = {"Disable","Enable"};
default = 0;
};
SPACER(3);
SPACER(__COUNTER__);
class CustomCampaignOptions {
title = "~~ Custom Campaign Options ~~";
values[] = {""};
Expand All @@ -228,7 +230,21 @@ class Params
texts[] = {"Disable","Enable"};
default = 0;
};
SPACER(4);
SPACER(__COUNTER__);
class MissionGenerationOptions {
title = "~~ Mission Generation Options ~~";
values[] = {""};
texts[] = {""};
default = "";
};
class ReplaceFriendlyVehicles
{
title = "Enables the replacement of friendly vehicles with chosen faction vehicles";
values[] = {0,1};
texts[] = {"Disable","Enable"};
default = 1;
};
SPACER(__COUNTER__);
class AddonSpecificOptions {
title = "~~ Addon Specific Options ~~";
values[] = {""};
Expand All @@ -242,7 +258,7 @@ class Params
texts[] = {"Disable","Enable"};
default = 0;
};
SPACER(5);
SPACER(__COUNTER__);
class TechnicalOptions {
title = "~~ Technical Options ~~";
values[] = {""};
Expand Down Expand Up @@ -279,6 +295,8 @@ class Params
};
};

__COUNTER_RESET__;

class RscTitles
{
class TRGM_VAR_notifications
Expand Down

0 comments on commit f759cc7

Please sign in to comment.