RSharpe 0 Posted June 9, 2011 I was hoping to get some help on something that I'm trying to do. I'm trying to have a building that keeps spawning a squad once the previous squad has been entirely destroyed. I want the building to keep spawning these groups until the building has been destroyed. Does anyone know of an straightforward way to do this? THanks in advance. Share this post Link to post Share on other sites
demonized 20 Posted June 9, 2011 Save script below as buildingspawn.sqf and put in your mission folder. info in the script on how to use. i have higlighted some of the commands used, you can search for them here to understand more and learn to manipulate the script if you want. /* will spawn a group and make them guard the immediate area until all dead, then spawn a new copy of same group if the building start object was set near is not destroyed. place functions module on map in editor. place this in a objects initline: _null = this execVM "buildingspawn.sqf"; note object will be deleted after mission start, it can be any kind of object, for example the invicible H in empty objects. optional, place this in init for using ID number of house in editor, find ID when pressing ID button and zooming in. this setVariable ["house", 123456, true]; _null = this execVM "buildingspawn.sqf"; 123456 is the idNumber found in editor. */ // set this below to true to show a marker on map on the building, and end hint. true/false = on/off. _debug = true; // here we wait until the function module is ready, its needed for BIS_fnc_spawnGroup. [b]waitUntil [/b]{ !isNil "BIS_fnc_init" }; // position of the building wich you can walk inside nearest to the object placed in editor. _building = [b]nearestBuilding [/b][b]_this[/b]; // the building. _pos = [b]getPos [/b]_building; // the position of the building. // here is the optional ID way of locating a house, useful for those houses wich you cannot walk inside. _var = _this [b]getVariable [/b]["house", -666]; [b]if [/b](_var != -666) then { _building = getPos _this [b]nearestObject [/b]_var; // the building. _pos = getPos _building; // the position of the building. }; // creating the marker if debug is true. _mName = [b]format[/b]["%1",([b]vehicleVarName [/b]_this)]; _marker = [b]createMarker[/b][_mName,_pos]; _marker [b]setMarkerShape [/b]"ICON"; _marker [b]setMarkerType [/b]"DOT"; // here we delete the object used to start the script. [b]deleteVehicle [/b]_this; // a loop running while the building i still up. [b]while [/b]{[b]alive [/b]_building OR ([b]getDammage [/b]_building) < 1} do { // here we create a group with 2 units in on the building position, note they will spawn randomly at available positions near and in the building. _group = [_pos, EAST, ["TK_INS_Bonesetter_EP1", "TK_INS_Soldier_2_EP1"],[],[],[],[],[],180] call [b]BIS_fnc_spawnGroup[/b]; // here we create a random patrol around the house. _patrol = [_group, _pos, 100] call [b]bis_fnc_taskPatrol[/b]; // here we wait until all are dead in the group. [b]waitUntil [/b]{({alive _x} [b]count [/b][b]units [/b]_[b]group[/b]) == 0}; // at this point after the waitUntil check, all units in group is dead, what happens now is that if the building is still alive or have not been // completely destroyed, we go to the top, and repeat the creation of the group, otherwise we exit the loop here to show the hint below. }; if (_debug) then {hint "building destroyed, exiting script"}; Share this post Link to post Share on other sites
RSharpe 0 Posted June 9, 2011 Excellent. THanks so much! I'll give this a try tonight. Share this post Link to post Share on other sites
RSharpe 0 Posted June 10, 2011 Thanks for the script. It works quite well... However, is there any way for me to specify a task for the spawned groups? I would like for each spawned group to attack a position on the map. Thanks Share this post Link to post Share on other sites
demonized 20 Posted June 11, 2011 Thanks for the script. It works quite well...However, is there any way for me to specify a task for the spawned groups? I would like for each spawned group to attack a position on the map. Thanks instead of this highlighted line: // here we create a random patrol around the house. [b]_patrol = [_group, _pos, 100] call bis_fnc_taskPatrol;[/b] you can create waypoints or use another script on them like UPS by kronzky, example waypoints: _wp = _group addWaypoint [getMarkerPos "attackBase", 0]; _wp setWaypointBehaviour "AWARE"; _wp setWaypointType "SAD"; // search and destroy waypoint. here is info on addWaypoint: here is kronzkys great patroling script: Share this post Link to post Share on other sites