pcc 14 Posted March 7, 2017 In Commander_BuildTownDefenses.sqf, I changed if (Count _existingDefenses < 1) to if (Count _existingDefenses < 5) and increased the chances. But it still only builds 1 defense per camp. Spoiler if (_total > 0) then { ScopeName "CreateDefense"; //Find empty layout position and create defense. for [{_count = 0},{_count < _total},{_count = _count + 1}] do { _position = (_layout Select 0) Select 0; _existingDefenses = NearestObjects[_position,_weapons,3]; if (Count _existingDefenses < 5) then { _direction = (_layout Select 0) Select 1; _defense = _weapons Select Random (Count _weapons - 1); _type = _defenses Find _defense; if (_type != -1) then { //Calculate % chance per minute of constructing defense. At game start chance is much higher so there will be starting defenses. _chanceModifier = (BIS_WF_Constants GetVariable "TOWNCONSTRUCTIONTIME") / 60; if (time < 45) then {_chanceModifier = 10}; _chance = _defenseChances Select _type; if (!IsNil "_chance") then { if (_chance > 0) then { _chance = (_town GetVariable "SV") / 20 * _chanceModifier + _chance * _chanceModifier; if (_chance > 0) then { _script = _defenseScripts Select _type; [_type,_side,_position,_direction,true,true] ExecVM (corePath + Format["Server\Construction\Construction_%1.sqf",_script]); }; }; }; }; BreakTo "CreateDefense"; }; }; }; Share this post Link to post Share on other sites
opusfmspol 273 Posted March 8, 2017 Not tested, but you might try this: In custom Init_Common add a new variable, like: CampDefensesNumber = 3; Copy script Server\Init\Init_DefenseLayout.sqf to your mission file. Where it has this: Spoiler //If a layout does not exist then auto-generate one. else { _direction = ((Direction _location) - 45 + Random 90) % 360; _position = [_location,13 + Random 6,_direction] Call GetPositionFrom; _layout = [[_position,_direction]]; }; Change it to this: Spoiler //If a layout does not exist then auto-generate one. else { Private ["_count"]; for [{_count = 0},{_count < CampDefensesNumber},{_count = _count + 1}] do { _direction = ((Direction _location) - 45 + Random 90) % 360; _position = [_location,13 + Random 6,_direction] Call GetPositionFrom; _layout = [[_position,_direction]]; }; }; 1 Share this post Link to post Share on other sites
pcc 14 Posted March 8, 2017 Appreciate the help. Unfortunately, AI still only building 1 static defense. Edit: Actually AI is building more static defenses now just saw a D30 with spg9. Decreased the variable TOWNCONSTRUCTIONTIME. But for reason though it doesn't happen consistently. Also sometimes they built the weapons in the same spot but both weapons are still functioning. I noticed by default mortars are built 3 at a time and spaced out but they don't get manned by crew like other static defenses. So I copied the loop from Construction_Mortar.sqf to Construction_StationaryDefense.sqf, but they always get build at same spot resulting in overlapping. Not sure, how I can get them to space out more. Spoiler scriptName format ["%1Scripts\Server\Construction\Construction_StationaryDefense.sqf",BIS_WFdPath]; //Last modified 10/20/10 //***************************************************************************************** //Description: Creates a stationary defense. //***************************************************************************************** Private["_coinStructure","_camps","_commanderAI","_construct","_constructed","_defense","_direction","_garrison","_modifiedDirection","_position","_side","_structure","_town","_type"]; _type = _this Select 0; _side = _this Select 1; _position = _this Select 2; _direction = _this Select 3; _commanderAI = false; if (Count _this > 4) then {_commanderAI = _this Select 4}; _garrison = false; if (Count _this > 5) then {_garrison = _this Select 5}; if (Count _this > 6) then {_coinStructure = _this Select 6}; _structure = Call Compile Format ["%1DefenseNames Select _type",WFSideText _side]; _modifiedDirection = Call Compile Format ["%1DefenseDirections Select _type",WFSideText _side]; if (_commanderAI) then {_direction = _direction + _modifiedDirection}; _defense = ObjNull; if (IsNil "_coinStructure") then { Private["_count","_destination","_total"]; _defenses = []; _total = 1; if (_commanderAI) then {_total = 3}; for [{_count = 0},{_count < _total},{_count = _count + 1}] do { _destination = _position; if (_total > 1) then {_destination = [_position,0,15] Call GetRandomPosition}; _defense = _structure CreateVehicle _position; _defense SetDir _direction; [_defense,_side] Call BIS_WF_InitDefense; _defenses = _defenses + [_defense]; [_defense,_position] Call CorrectObjectPosition; }; if (_commanderAI) then {Call Compile Format ["last%1Defense = _defense",WFSideText _side]}; } else { _defense = _coinStructure; }; if (!IsNull _defense) then { [_defense,_side] Call BIS_WF_InitDefense; if (_garrison && _defense EmptyPositions "gunner" > 0) then { Private["_towns"]; //If town is nearby. _towns = _defense NearEntities["LocationLogicCity",2000]; if (Count _towns > 0) then { Private["_town"]; //If town belongs to same side. _town = [_defense,_towns] Call BIS_WF_GetClosest; if ((_town GetVariable "side") == _side) then { //If town is close enough then use garrison. if (_defense Distance _town < ((_town GetVariable "range") * 0.8)) then { Private["_defenses"]; _defenses = _town GetVariable Format["%1GarrisonDefenses",WFSideText _side]; _defenses = _defenses + [_defense]; _town SetVariable[Format["%1GarrisonDefenses",WFSideText _side],_defenses]; }; }; }; }; }; //***************************************************************************************** //5/24/7 MM - Created file. Share this post Link to post Share on other sites
opusfmspol 273 Posted March 9, 2017 Could add a nearObjects check for a nearby static, and have the new one reposition if one is found at the position. A small radius check like 5-7 meters and nearObjects works fine. As far as mortar crews, they would come from town garrison units. Garrison units are dependent upon a town's supply value. Lower SV and fewer units, more SV and more units. Each town only has a limited number of garrison units to man static defenses, and with more statics added they might go to other statics elsewhere. When reinforce happens they won't go over the limit set by the town's current SV. Defenses use garrison: PVFunctions\RequestGarrisonDefense.sqf Virtual garrison loop: VG\UpdateDefensiveVG.sqf Town defenses loop: Server\Server_UpdateTownVirtualDefenses.sqf 1 Share this post Link to post Share on other sites