TheGeneral2899 19 Posted September 27, 2017 Hello all! So in an attempt to keep this short, I've got a while loop that is running which (is supposed to) spawn a group of AI and then have them run to a marker known as "ai_move". Everything works great. The AI spawn in the first go and will run to the marker, however in every consecutive loop, nothing happens. My suspect is that it has to do with the naming of the groups (i.e. I am using the BIS func to spawn group), thus not allowing it keep spawning in a group when the name already exists? I have encountered this same problem before and would love any and all help from someone who has experience with this / knows what the problem is! All the code is commented and marked for use by anyone of course if they need! Additionally, the vehicle group that spawns, the driver will get out of the car and move to next way point, however the soldiers inside do not. I suspect it's due to the 2nd soldier group spawned not joining the driver group thus following his waypoint? Thank you in advance for anyone who helps! _i = 1; while { _i < 21 } do { // hint "DEBUG - LOOP IS RUNNING"; // SELECTS A RANDOM LOCATION TO SPAWN AI FROM MARKERS PLACED ON MAP _spawnloc = ["spawn_1", "spawn_2", "spawn_3", "spawn_4", "spawn_5", "spawn_6", "spawn_7", "spawn_8", "spawn_9", "spawn_10", "spawn_11", "spawn_12", "spawn_13", "spawn_14", "spawn_15", "spawn_16", "spawn_17", "spawn_18", "spawn_19", "spawn_20", "spawn_21", "spawn_22", "spawn_23", "spawn_24", "spawn_25", "spawn_26", "spawn_27", "spawn_28"] call BIS_fnc_selectRandom; // SELECTS A GROUP TO SPAWN - FOUND USING CfgGroups _group = ["rhsgref_group_national_infantry_patrol", "rhsgref_group_national_infantry_squad1", "rhsgref_group_national_infantry_squad2"] call BIS_fnc_selectRandom; // SPAWNS THE GROUP NAMED _aiGRP _aiGRP = [getMarkerPos _spawnloc, INDEPENDENT, (configfile >> "CfgGroups" >> "Indep" >> "rhsgref_faction_nationalist" >> "rhsgref_group_national_infantry" >> _group)] call BIS_fnc_spawnGroup; // CREATE WAYPOINT AND ATTRIBUTES _waypoint0 = _aiGRP addWaypoint [getMarkerPos "ai_move",0]; _waypoint0 setWaypointType "MOVE"; _waypoint0 setWaypointFormation "STAG COLUMN"; _waypoint0 setWaypointSpeed "FULL"; _waypoint0 setWaypointBehaviour "AWARE"; // ON LOOP # 1, 11, 14, 17 - SPAWN A VEHICLE AS WELL if ( _i == 1 || _i == 11 || _i == 14 || _i == 17) then { // SAME AS ABOVE JUST USING VEHICLE SET MARKERS _vehiclespawnloc = ["vehspawn_1", "vehspawn_2"] call BIS_fnc_selectRandom; _vehspawngroup = ["rhsgref_group_national_infantry_patrol", "rhsgref_group_national_infantry_squad1", "rhsgref_group_national_infantry_squad2"] call BIS_fnc_selectRandom; // IF STATEMENT MAKING SURE THE DROP OFF WAYPOINT IS ON CORRECT SIDE (NORTH OR SOUTH) ACCORDING TO SPAWN LOCATION if (_vehiclespawnloc == "vehspawn_1") then { vehDrop = "vehdropoff_1"; } else { vehDrop = "vehdropoff_2"; }; // SPAWNS VEHICLE IN AND SETS ITS DIRECTION _veh = "I_C_Van_02_transport_F" createVehicle getMarkerPos _vehiclespawnloc; createVehicleCrew _veh; _dirVeh = markerDir _vehiclespawnloc; _veh setDir _dirVeh; // SETS GROUP OF THE DRIVER _vehgrp = group driver _veh; // SPAWNS IN GROUP TO JOIN THE VEHICLE ASSAULT _aiVehGroup = [getMarkerPos _vehiclespawnloc, INDEPENDENT, (configfile >> "CfgGroups" >> "Indep" >> "rhsgref_faction_nationalist" >> "rhsgref_group_national_infantry" >> _vehspawngroup)] call BIS_fnc_spawnGroup; // MOVES SPAWNED UNITS INTO VEHICLE {_x moveInCargo _veh} forEach units _aiVehGroup; // SPAWNED UNITS JOIN THE DRIVERS GROUP _aiVehGroup join _vehgrp; // CREATE WAYPOINT AND ATTRIBUTES _waypoint0 = _vehgrp addWaypoint [getMarkerPos vehDrop, 0]; _waypoint0 setWaypointType "UNLOAD"; _waypoint0 setWaypointFormation "FILE"; _waypoint0 setWaypointSpeed "NORMAL"; _waypoint0 setWaypointBehaviour "AWARE"; _waypoint1 = _vehgrp addWaypoint [getMarkerPos "ai_move",0]; _waypoint1 setWaypointType "MOVE"; _waypoint1 setWaypointFormation "FILE"; _waypoint1 setWaypointSpeed "NORMAL"; _waypoint1 setWaypointBehaviour "AWARE"; hint "Vehicle Spawn worked"; }; sleep 50; //--- delay between rounds _i = _i + 1; }; Share this post Link to post Share on other sites
TheGeneral2899 19 Posted September 27, 2017 So I'm an idiot and after triple checking everything... it looks as though I had mistyped the name of the groups that the spawnGroup function was calling. Thus is why at random 1/3 of the times it called a group that was actually working. Pasting the updated script in case anybody wants to use it. It works wonderfully! =) _i = 1; while { _i < 21 } do { // hint "DEBUG - LOOP IS RUNNING"; // SELECTS A RANDOM LOCATION TO SPAWN AI FROM MARKERS PLACED ON MAP _spawnloc = ["spawn_1", "spawn_2", "spawn_3", "spawn_4", "spawn_5", "spawn_6", "spawn_7", "spawn_8", "spawn_9", "spawn_10", "spawn_11", "spawn_12", "spawn_13", "spawn_14", "spawn_15", "spawn_16", "spawn_17", "spawn_18", "spawn_19", "spawn_20", "spawn_21", "spawn_22", "spawn_23", "spawn_24", "spawn_25", "spawn_26", "spawn_27", "spawn_28"] call BIS_fnc_selectRandom; // SELECTS A GROUP TO SPAWN - FOUND USING CfgGroups _group = ["rhsgref_group_national_infantry_patrol", "rhsgref_group_national_infantry_squad", "rhsgref_group_national_infantry_squad_2"] call BIS_fnc_selectRandom; // SPAWNS THE GROUP NAMED _aiGRP _aiGRP = [getMarkerPos _spawnloc, INDEPENDENT, (configfile >> "CfgGroups" >> "Indep" >> "rhsgref_faction_nationalist" >> "rhsgref_group_national_infantry" >> _group)] call BIS_fnc_spawnGroup; // CREATE WAYPOINT AND ATTRIBUTES _waypoint0 = _aiGRP addWaypoint [getMarkerPos "ai_move",0]; _waypoint0 setWaypointType "MOVE"; _waypoint0 setWaypointFormation "STAG COLUMN"; _waypoint0 setWaypointSpeed "FULL"; _waypoint0 setWaypointBehaviour "AWARE"; hint "AI SPAWNED"; // ON LOOP # 1, 11, 14, 17 - SPAWN A VEHICLE AS WELL if ( _i == 1 || _i == 11 || _i == 14 || _i == 17) then { // SAME AS ABOVE JUST USING VEHICLE SET MARKERS _vehiclespawnloc = ["vehspawn_1", "vehspawn_2"] call BIS_fnc_selectRandom; _vehspawngroup = ["rhsgref_group_national_infantry_patrol", "rhsgref_group_national_infantry_squad", "rhsgref_group_national_infantry_squad_2"] call BIS_fnc_selectRandom; // IF STATEMENT MAKING SURE THE DROP OFF WAYPOINT IS ON CORRECT SIDE (NORTH OR SOUTH) ACCORDING TO SPAWN LOCATION if (_vehiclespawnloc == "vehspawn_1") then { vehDrop = "vehdropoff_1"; } else { vehDrop = "vehdropoff_2"; }; // SPAWNS VEHICLE IN AND SETS ITS DIRECTION _veh = "I_C_Van_02_transport_F" createVehicle getMarkerPos _vehiclespawnloc; createVehicleCrew _veh; _dirVeh = markerDir _vehiclespawnloc; _veh setDir _dirVeh; // SETS GROUP OF THE DRIVER _vehgrp = group driver _veh; // SPAWNS IN GROUP TO JOIN THE VEHICLE ASSAULT _aiVehGroup = [getMarkerPos _vehiclespawnloc, INDEPENDENT, (configfile >> "CfgGroups" >> "Indep" >> "rhsgref_faction_nationalist" >> "rhsgref_group_national_infantry" >> _vehspawngroup)] call BIS_fnc_spawnGroup; // MOVES SPAWNED UNITS INTO VEHICLE {_x moveInCargo _veh} forEach units _aiVehGroup; _vehgrouparray = units _aiVehGroup; _vehgrouparray join _vehgrp; // CREATE WAYPOINT AND ATTRIBUTES _waypoint0 = _vehgrp addWaypoint [getMarkerPos vehDrop, 0]; _waypoint0 setWaypointType "TR UNLOAD"; _waypoint0 setWaypointFormation "FILE"; _waypoint0 setWaypointSpeed "NORMAL"; _waypoint0 setWaypointBehaviour "AWARE"; _waypoint0 = _vehgrp addWaypoint [getMarkerPos vehDrop, 0]; _waypoint0 setWaypointType "GETOUT"; _waypoint0 setWaypointFormation "FILE"; _waypoint0 setWaypointSpeed "NORMAL"; _waypoint0 setWaypointBehaviour "AWARE"; _waypoint1 = _vehgrp addWaypoint [getMarkerPos "ai_move",0]; _waypoint1 setWaypointType "MOVE"; _waypoint1 setWaypointFormation "FILE"; _waypoint1 setWaypointSpeed "NORMAL"; _waypoint1 setWaypointBehaviour "AWARE"; }; sleep 50; //--- delay between rounds _i = _i + 1; }; Share this post Link to post Share on other sites