Skip to content

Instantly share code, notes, and snippets.

@JonBons
Created February 10, 2013 21:45
Show Gist options
  • Select an option

  • Save JonBons/4751171 to your computer and use it in GitHub Desktop.

Select an option

Save JonBons/4751171 to your computer and use it in GitHub Desktop.
#define KINDOF_ARRAY(a,b) [##a,##b] call {_veh = _this select 0;_types = _this select 1;_res = false; {if (_veh isKindOf _x) exitwith { _res = true };} forEach _types;_res}
hint "Starting garrison script!";
kron = [] execVM "scripts\KRON_Strings.sqf";
/* Available factions:
* - USMC
* - RU
* - GUE
* - INS
* - CDF
* - CIV
* - CIV_RU
* - BIS_TK_CIV
* - BIS_CIV_special
* - BIS_TK_INS
* - BIS_TK_GUE
* - BIS_CZ
* - BIS_US
* - BIS_UN
* - BIS_TK
* - BIS_GER
* - PMC_BAF
* - BIS_BAF
*/
_radiusMarker = _this select 0;
_spawnRadius = _this select 1;
_percentBuildings = _this select 2;
_percentPositions = _this select 3;
_minSkill = _this select 4;
_maxSkill = _this select 5;
_factionSpawn = _this select 6;
_spawnMarker = _this select 7;
_buildings = [];
_buildings = _buildings + [["Land_MBG_Killhouse_4", [[1.91675,2.41504,-3.84317],[6.6012,-3.83325,-3.84318],[7.39697,6.65479,-3.84318],[-3.47327,5.86035,-3.84318],[-6.00708,-1.40588,-3.84318],[-1.75098,0.593506,-3.84318],[-0.220947,6.89148,-0.543175],[7.08728,0.453003,-0.543175],[4.46423,-3.59338,-0.543175],[-4.83618,-3.69653,-0.543175],[7.552,2.22827,-0.543175],[-5.64502,3.76831,-0.543175]]]];
_buildings = _buildings + [["Land_MBG_Killhouse_5", [[-6.44153,5.67566,-4.00021],[6.56299,6.38507,-4.00022],[-4.00659,3.20886,-4.00021],[-6.2583,2.13025,-4.00021],[-6.1123,-4.71338,-4.00022],[4.52783,3.05322,-4.00021],[6.44946,-4.80676,-4.00022],[-6.64539,5.43567,-0.700218],[0.726318,6.79956,-0.700218],[-0.814209,-4.80566,-0.700218],[4.52087,-3.9375,-0.700218],[-4.43188,-3.65747,-0.700218],[4.19495,6.40149,-0.700218],[0.121582,6.797,-4.00021]]]];
_buildings = _buildings + [["Land_MBG_Killhouse_3", [[-4.84094,-2.04199,-2.84856],[-1.75342,-1.69849,-2.84856],[-8.90894,3.19165,-2.84856],[-2.01599,2.60889,-2.84856],[-8.60352,-1.90405,0.451439],[-7.6322,1.70776,0.451439],[-12.1096,3.25061,0.451439],[-1.78723,-1.61853,0.451439],[-0.598267,4.03369,0.451439],[4.53162,3.36194,-2.84856],[8.55713,4.03088,-2.84856],[12.0518,3.70654,-2.84856],[1.32532,-0.606934,-2.84856],[8.32129,-1.99475,0.451439],[6.70313,2.48987,0.451439],[1.83789,3.28333,0.451439],[5.47595,-2.38562,0.451439],[11.99,3.99377,0.451439],[8.93872,3.11438,0.451439]]]];
_buildings = _buildings + [["Land_kostel", [[5.64929,-6.42371,-7.33662],[4.87817,-5.85229,-0.905098]]]];
_buildings = _buildings + [["Land_hruzdum", [[0.336304,3.97107,-4.73357],[-0.973206,3.49414,-1.16265],[2.14636,1.57385,-1.16265],[-0.441223,-0.956787,-1.16265],[-0.11615,3.57178,1.59321],[-0.203674,-0.794312,1.59321]]]];
_buildings = _buildings + [["Land_cihlovej_dum_in", [[1.48938,-1.45715,-5.27588],[-2.52844,2.22705,-5.27588],[1.82239,2.27551,-5.27588],[1.974,2.63379,-1.81473],[0.00463867,-1.63672,-1.81471],[-2.09888,2.04163,-1.8147],[-7.94788,1.65247,-5.27588],[-9.10681,-1.58142,-5.27588],[-5.2572,-1.9884,-5.27588],[-7.11389,2.57092,-1.81471],[-5.11462,-1.60388,-1.8147],[-9.23181,-1.85303,-1.81473]]]];
_buildings = _buildings + [["Land_MBG_Killhouse_2", [[6.69604,5.28033,-2.79856],[-7.09961,4.06067,-2.79856],[-7.2998,-3.44171,-2.79856],[5.54932,-4.65912,-2.79856],[1.74109,-3.81085,-2.79856],[6.30054,0.887268,0.501442],[-0.0909424,-0.64917,0.501442],[1.5033,-4.6828,0.501442],[5.2793,-4.76044,0.501442],[-6.45276,4.16315,0.501442],[5.99902,5.3587,3.80144],[5.90515,-4.67987,3.80144],[-5.40601,-4.9505,3.80144]]]];
_buildings = _buildings + [["Land_MBG_Killhouse_1", [[4.20972,-3.42651,-2.04856],[3.2074,5.38818,-2.04856],[-2.01904,0.334106,-2.04856],[-3.28772,-3.17053,1.25144],[3.57178,-3.03345,1.25144],[3.07068,4.93494,1.25144]]]];
_buildings = _buildings + [["Land_Hlidac_budka", [[-1.96619,1.28101,-0.783615]]]];
_buildings = _buildings + [["Land_Shed_Ind02", [[4.04688,9.20862,-4.62599],[3.44141,-0.217651,-4.62599],[-2.61206,-3.19287,-4.62599],[5.05396,-8.64905,-1.27445],[4.53027,6.34412,-1.28143],[-1.06592,11.7415,-1.27647],[-3.96277,-2.06006,-1.28579]]]];
_buildings = _buildings + [["Land_dum_mesto2", [[2.2901,4.88037,-4.34476],[-0.310547,6.87085,-4.34476],[-2.12427,5.58533,-4.34476],[-2.28247,1.17285,-4.34476],[2.01794,2.16211,-4.34476],[-3.03864,1.4375,-0.945702],[2.86646,1.39648,-0.945724]]]];
_buildings = _buildings + [["Land_MBG_Warehouse", [[-16.0571,18.3226,-6.14345],[-15.3406,-1.22028,-6.14345],[-3.97949,-11.9939,-6.14345],[21.5266,1.60608,-6.14345],[13.604,18.0469,-6.14345],[20.0369,-11.2003,-6.14345],[21.15,-10.1867,-2.84344],[18.2366,-5.07422,-2.84344],[19.3654,0.335754,-2.84344],[20.9041,7.60052,-2.84344],[17.3333,18.4678,-2.84345],[-7.47485,17.866,-2.81845],[-18.9556,17.9041,-2.84344],[-19.516,16.9872,5.15656],[-14.1096,18.3699,5.15656],[1.10474,18.4713,5.15656],[20.1858,16.189,5.15656],[21.4116,1.11963,5.15656],[20.9399,-12.593,5.15656],[8.07886,-12.4698,5.15656],[-15.2827,-13.5441,5.15656],[-16.4402,-1.70514,5.15656],[0.0871582,1.66125,5.15656]]]];
_buildings = _buildings + [["Land_Panelak", [[-0.642151,-3.40088,0.0714188],[-3.24335,-6.6051,0.0714188],[-2.79156,2.16577,0.0714188],[-5.70984,1.93701,0.0714188],[-5.80975,-0.790405,0.0714188],[-0.443848,1.69556,1.32864],[3.08032,-6.2771,2.77145],[3.07916,2.25867,2.77145],[6.05719,-0.633667,2.77145],[6.01306,-6.04565,5.62586],[-2.03784,-5.22461,5.62586],[-4.76215,1.4613,5.62586],[2.95471,0.98938,5.62586]]]];
_exludedClasses = ["USMC_LHD_Crew_Base", "USMC_LHD_Crew_White","USMC_LHD_Crew_Blue","USMC_LHD_Crew_Green","USMC_LHD_Crew_Red","USMC_LHD_Crew_Purple","USMC_LHD_Crew_Yellow","CDF_Soldier_Pilot"];
_exludedClasses = _exludedClasses + ["USMC_Soldier_Pilot", "USMC_Soldier_Crew","RU_Soldier_Pilot", "RU_Soldier_Crew","GUE_Soldier_Pilot", "GUE_Soldier_Crew","Ins_Soldier_Pilot", "Ins_Soldier_Crew", "CDF_Soldier_Crew"];
_exludedClasses = _exludedClasses + ["CZ_Soldier_Pilot_EP1", "US_Soldier_Pilot_EP1","US_Soldier_Crew_EP1","US_Pilot_Light_EP1","UN_CDF_Soldier_Pilot_EP1","UN_CDF_Soldier_Crew_EP1","TK_Soldier_Crew_EP1","TK_Soldier_Pilot_EP1"];
_exludedClasses = _exludedClasses + ["BAF_Pilot_MTP","BAF_Pilot_DDPM","BAF_crewman_MTP","BAF_crewman_DDPM","Soldier_Crew_PMC","Soldier_Pilot_PMC","BAF_Pilot_W","BAF_creWman_W"];
_exludedClasses = _exludedClasses + ["FR_Light","USMC_Soldier_Light","RU_Soldier_Light","CDF_Soldier_Light","CZ_Soldier_Light_DES_EP1","US_Soldier_Light_EP1","Drake_Light","Herrera_Light","Pierce_Light","Graves_Light","UN_CDF_Soldier_Light_EP1",""];
_classesRifle = [];
_classesAT = [];
_classesMG = [];
_classesATMG = [];
_classesSniper = [];
_cfgvehicles = configFile >> "CfgVehicles";
for "_i" from 0 to (count _cfgvehicles)-1 do {
_vehicle = _cfgvehicles select _i;
if (isClass _vehicle) then {
_veh_type = configName(_vehicle);
_cur_type = getNumber(_vehicle >> "type");
_display_name = getText(_vehicle >> "displayName");
_faction = getText(_vehicle >> "faction");
if (_veh_type isKindOf "Man") then {
if (!(KINDOF_ARRAY(_veh_type,_exludedClasses))) then {
if (_faction != "Default") then {
_foundBase = [_veh_type, "_Base"] call KRON_StrInStr;
if (!_foundBase) then {
if (_faction == _factionSpawn) then {
_foundAT = [_veh_type, "_AT"] call KRON_StrInStr;
if (_foundAT) then {
_classesAT = _classesAT + [_veh_type];
};
_foundSniper = [_veh_type, "_Sniper"] call KRON_StrInStr;
if (_foundSniper) then {
_classesSniper = _classesSniper + [_veh_type];
};
_foundMarksman = [_veh_type, "_Marksman"] call KRON_StrInStr;
if (_foundMarksman) then {
_classesSniper = _classesSniper + [_veh_type];
};
_foundMG = [_veh_type, "_MG"] call KRON_StrInStr;
if (_foundMG) then {
_classesMG = _classesMG + [_veh_type];
};
_foundAR = [_veh_type, "_AR"] call KRON_StrInStr;
if (_foundAR) then {
_classesMG = _classesMG + [_veh_type];
};
if (!_foundMG && !_foundSniper && !_foundAT && !_foundMG && !_foundAR) then {
_classesRifle = _classesRifle + [_veh_type];
};
//diag_log format["CfgVehicles : type = %1, name = %2, faction = %3", _veh_type, _display_name, _faction];
}
}
}
}
}
}
};
_classesATMG = _classesAT + _classesMG;
diag_log format["_classesAT = %1", _classesAT];
diag_log format["_classesMG = %1", _classesMG];
diag_log format["_classesATMG = %1", _classesATMG];
diag_log format["_classesSniper = %1", _classesSniper];
diag_log format["_classesRifle = %1", _classesRifle];
_curSpawns = 0;
_maxSpawns = 150;
{
_type = _x select 0;
_positions = _x select 1;
_search = (getMarkerPos _radiusMarker) nearObjects [_type, _spawnRadius];
If (count _search > 0) then {
{
for [{_i=0}, {_i < (count _positions) / 2}, {_i=_i+1}] do
{
if (_curSpawns < _maxSpawns) then {
_local = (_positions select _i);
_world = _x modelToWorld _local;
_class = _classesRifle select floor(random count _classesRifle);
_group = createGroup east;
hint format ["class = %1", _class];
_class createUnit [getMarkerPos _spawnMarker, _group, "curUnit = this"];
sleep 0.1;
curUnit setPosATL _world;
_curSpawns = _curSpawns +1;
}
};
} forEach _search;
}
} forEach _buildings;
hint "Finished garrison script!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment