Advertisement
Rimsiakas

Force Through faction adapter for Scion mod

Dec 15th, 2021
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 5.79 KB | None | 0 0
  1. span class="re5"> Rimsiakas_fnc_AISpawnerGroupsInitAdapter = {      
  2.     params["_emitter"];      
  3.      
  4.     private["_sideStr","_cfgRoot"];      
  5.        
  6.     _emitter = _this select 0;      
  7.     _sideStr = _emitter getVariable ["side",""];      
  8.     _cfgRoot = [["CfgGroups"]] call bis_fnc_loadClass;      
  9.            
  10.     private["_factions","_maxVehicles","_maxInfantry","_type","_typeRaw","_groups","_groupDataPoolStored","_groupDataPoolVar","_group","_groupDataPool"];      
  11.            
  12.     _factions = (_cfgRoot >> _sideStr) call bis_fnc_getCfgSubClasses;      
  13.            
  14.     _maxVehicles = _emitter getVariable ["VehiclesInGroup",-1];      
  15.     _maxInfantry = _emitter getVariable ["InfantryInGroup",-1];      
  16.            
  17.     if (_maxVehicles < 0) then {_maxVehicles = 10e10};      
  18.     if (_maxInfantry < 0) then {_maxInfantry = 10e10};      
  19.          
  20.      
  21.     {    
  22.         scopeName "factionLoop";    
  23.      
  24.         _faction = _x;      
  25.      
  26.         private _rawTypes = (_cfgRoot >> _sideStr >> _faction) call bis_fnc_getCfgSubClasses;      
  27.            
  28.         {    
  29.             scopeName "typeLoop";    
  30.      
  31.             _typeRaw = _x;      
  32.            
  33.             _groups = (_cfgRoot >> _sideStr >> _faction >> _x) call bis_fnc_getCfgSubClasses;      
  34.             _groupDataPool = [];      
  35.            
  36.             private["_groupData","_groupConfig","_groupCost","_groupWeight","_groupUnitCount","_groupComposition","_groupType"];      
  37.            
  38.             {    
  39.                 scopeName "groupLoop";    
  40.      
  41.                 _group = _x;      
  42.      
  43.                 _type = switch (_typeRaw) do      
  44.                 {  
  45.                     case "SpecOps";  
  46.                     case "UInfantry";
  47.                     case "Taiga";
  48.                     case "Taiga2";
  49.                     case "Woodland_Hex";
  50.                     case "Group_43";
  51.                     case "SE_Warbots";
  52.                     case "AC_Warbots";
  53.                     case "AR_Warbots";      
  54.                     case "Infantry":      
  55.                     {      
  56.                         "Infantry";      
  57.                     };      
  58.                     case "Motorized";      
  59.                     case "Motorized_MTP":      
  60.                     {      
  61.                         "Motorized";      
  62.                     };      
  63.                     case "Mechanized":      
  64.                     {      
  65.                         "Mechanized";      
  66.                     };      
  67.                     case "Armored":      
  68.                     {      
  69.                         "Armored";      
  70.                     };      
  71.                     default      
  72.                     {      
  73.                         _aliveCategory = getText (_cfgRoot >> _sideStr >> _faction >> _typeRaw >> "aliveCategory");      
  74.                         if (_aliveCategory != "") then {      
  75.                             _aliveCategory;      
  76.                         };      
  77.                     };      
  78.                 };    
  79.      
  80.                 if (isNil "_type") then {    
  81.                     breakOut "groupLoop";    
  82.                 };    
  83.            
  84.                 _groupData = [];      
  85.            
  86.                 if ({_x == _group} count (_emitter getVariable ["BlacklistedGroups",[]]) == 0) then      
  87.                 {      
  88.                     _groupConfig = (_cfgRoot >> _sideStr >> _faction >> _typeRaw >> _group);      
  89.                     _groupComposition = [_groupConfig,_maxVehicles,_maxInfantry] call bis_fnc_moduleSpawnAI_getGroupComposition;      
  90.                     _groupUnitCount = count _groupComposition;      
  91.            
  92.                     if (_groupUnitCount > 0) then      
  93.                     {      
  94.                         _groupCost = [_groupConfig,_maxVehicles,_maxInfantry] call bis_fnc_moduleSpawnAI_getGroupCost;      
  95.                         _groupWeight = [_groupCost,_groupUnitCount] call bis_fnc_moduleSpawnAI_getGroupWeight;      
  96.                         _groupType = _groupComposition call bis_fnc_moduleSpawnAI_getGroupType;      
  97.                         _groupData = [_groupConfig,_groupCost,_groupWeight,_groupUnitCount,_groupComposition,_groupType];      
  98.            
  99.                         _groupDataPool set [count _groupDataPool, _groupData];      
  100.                     };      
  101.                 };      
  102.             }      
  103.             forEach _groups;      
  104.            
  105.             if (isNil "_type") then {    
  106.                 continue;    
  107.             };  
  108.  
  109.             _groupDataPoolVar = format["groups%1_%2",_faction,_type];      
  110.             _groupDataPoolStored = _emitter getVariable [_groupDataPoolVar,[]];      
  111.             _groupDataPoolStored = _groupDataPoolStored + _groupDataPool;      
  112.             _emitter setVariable [_groupDataPoolVar,_groupDataPoolStored];      
  113.         }      
  114.         forEach _rawTypes;      
  115.            
  116.         if (missionNamespace getVariable ["bis_fnc_moduleSpawnAI_debug",false]) then      
  117.         {      
  118.             ["[ ][%1]---------------------------------------------------------",_emitter] call bis_fnc_moduleSpawnAI_logFormat;      
  119.             {      
  120.                 _type = _x;      
  121.                 _groupDataPoolVar = format["groups%1_%2",_faction,_type];      
  122.            
  123.                 {      
  124.                     ["[ ][%4][%1][%2]: %3",_faction,_type,_x,_emitter] call bis_fnc_moduleSpawnAI_logFormat;      
  125.                 }      
  126.                 forEach (_emitter getVariable [_groupDataPoolVar,[]]);      
  127.             }      
  128.             forEach      
  129.             [      
  130.                 "Infantry",      
  131.                 "Motorized",      
  132.                 "Mechanized",      
  133.                 "Armored"      
  134.             ];      
  135.         };      
  136.     }      
  137.     forEach _factions;      
  138. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement