forked from Bob-Murphy/A3-Antistasi-1.4
-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathfn_compatibilityLoadFaction.sqf
More file actions
102 lines (89 loc) · 4.34 KB
/
Copy pathfn_compatibilityLoadFaction.sqf
File metadata and controls
102 lines (89 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* File: fn_compatabilityLoadFaction.sqf
* Author: Spoffy
* Description:
* Loads a faction definition file, and transforms it into the old global variable system for sides.
* Params:
* _file - Faction definition file path
* _side - Side to load them in as
* Returns:
* Namespace containing faction information
* Example Usage:
*/
#include "..\..\script_component.hpp"
FIX_LINE_NUMBERS()
params ["_file", "_side"];
Info_2("Compatibility loading template: '%1' as side %2", _file, _side);
private _factionDefaultFile = ["EnemyDefaults","EnemyDefaults","RebelDefaults","CivilianDefaults"] #([west, east, independent, civilian] find _side);
_factionDefaultFile = QPATHTOFOLDER(Templates\Templates\FactionDefaults) + "\" + _factionDefaultFile + ".sqf";
private _faction = [[_factionDefaultFile,_file]] call A3A_fnc_loadFaction;
_faction set ["side", _side];
private _factionPrefix = ["occ", "inv", "reb", "civ"] #([west, east, independent, civilian] find _side);
missionNamespace setVariable ["A3A_faction_" + _factionPrefix, _faction];
[_faction, _factionPrefix] call A3A_fnc_compileGroups;
private _baseUnitClass = switch (_side) do {
case west: { "a3a_unit_west" };
case east: { "a3a_unit_east" };
case independent: { "a3a_unit_reb" };
case civilian: { "a3a_unit_civ" };
};
private _unitClassMap = if (_side isNotEqualTo independent) then { createHashMap } else {
createHashMapFromArray [ // Cases matter. Lower case here because allVariables on namespace returns lowercase
["militia_Unarmed", "a3a_unit_reb_unarmed"],
["militia_Rifleman", "a3a_unit_reb"],
["militia_staticCrew", "a3a_unit_reb"],
["militia_Medic", "a3a_unit_reb_medic"],
["militia_Sniper", "a3a_unit_reb_sniper"],
["militia_Marksman", "a3a_unit_reb_marksman"],
["militia_LAT", "a3a_unit_reb_lat"],
["militia_MachineGunner", "a3a_unit_reb_mg"],
["militia_ExplosivesExpert", "a3a_unit_reb_exp"],
["militia_Grenadier", "a3a_unit_reb_gl"],
["militia_SquadLeader", "a3a_unit_reb_sl"],
["militia_Engineer", "a3a_unit_reb_eng"],
["militia_AT", "a3a_unit_reb_at"],
["militia_AA", "a3a_unit_reb_aa"],
["militia_Petros", "a3a_unit_reb_petros"]
]
};
//validate loadouts
private _loadoutsPrefix = format ["loadouts_%1_", _factionPrefix];
private _allDefinitions = _faction get "loadouts";
#if __A3_DEBUG__
[_faction, _file] call A3A_fnc_TV_verifyLoadoutsData;
#endif
//Register loadouts globally.
{
private _loadoutName = _x;
private _unitDef = +_y;
private _customClass = _unitDef # 2;
if (_customClass == "") then {
_unitDef set [2, _unitClassMap getOrDefault [_loadoutName, _baseUnitClass]];
} else {
A3A_customSkeletonClasses pushBackUnique _customClass;
};
[_loadoutsPrefix + _loadoutName, _unitDef] call A3A_fnc_registerUnitType;
} forEach _allDefinitions;
#if __A3_DEBUG__
[_faction, _side, _file] call A3A_fnc_TV_verifyAssets;
#endif
if (_side in [Occupants, Invaders]) then {
// Compile light armed that also have 4+ passenger seats
private _lightArmedTroop = (_faction get "vehiclesLightArmed") select {
([_x, true] call BIS_fnc_crewCount) - ([_x, false] call BIS_fnc_crewCount) >= 4
};
_faction set ["vehiclesLightArmedTroop", _lightArmedTroop];
private _cargoCapable = (_faction get "vehiclesTrucks") + (_faction get "vehiclesCargoTrucks") + (_faction get "vehiclesMilitiaTrucks")
select { [_x] call A3A_Logistics_fnc_getVehCapacity > 1 };
_faction set ["vehiclesCargo", _cargoCapable];
private _noType = [];
if ((_faction get "vehiclesHelisAttack") + (_faction get "vehiclesHelisLightAttack") + (_faction get "vehiclesHelisTransport")
+ (_faction get "vehiclesHelisLight") isEqualTo []) then { _noType pushBack "heli" };
if (_faction get "staticAT" isEqualTo []) then { _noType pushBack "staticAT" };
if (_faction get "vehiclesGunBoats" isEqualTo []) then { _noType pushBack "boat" };
if ((_faction get "vehiclesPlanesAA") + (_faction get "vehiclesPlanesCAS") isEqualTo []) then { _noType append ["plane", "runway"] };
if (_faction get "vehiclesArtillery" isEqualTo []) then { _noType pushBack "vehicleArty" };
if (_faction get "vehiclesSAM" isEqualTo []) then { _noType pushBack "vehicleSAM" };
_faction set ["noPlaceTypes", _noType];
};
_faction;