falconx1 13 Posted June 29, 2013 (edited) how can i mod this to check if east units are all dead and only spawn more if all east units are dead? _waves_east = 0; while {_waves_east < 6} do { _waves_east = _waves_east + 1; //---count waves as we spawn them hint format["%1",_waves_east]; //---spawn AI group sleep 60; if (_waves_east == 5) then { hint "5 waves debug"; }; }; i guess i just don't know how to finish adding/modding this script into the one above if ( ({(side _x) == east} count allUnits) then { ---------- Post added at 08:58 AM ---------- Previous post was at 08:41 AM ---------- i think i got it can someone let me know if this is right? objective: Check before we spawn east ai and make sure none exist first, count waves as we spawn them using +1 and stop at 5 waves that's pretty much it _waves_east = 0; while {_waves_east < 6} do { _waves_east = _waves_east + 1; hint format["%1",_waves_east]; sleep 2; if ( ({(side _x) == east} count allUnits) == 0 ) then { //---spawn more east AI }; if (_waves_east == 5) then { //---Exit loop }; }; Edited June 29, 2013 by falconx1 Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 Generally correct, but you don't need _waves_east == 5 check since while will just stop and you can do whatever you want after it _waves_east = 0; while {_waves_east <= 5} do { //Increase counter _waves_east = _waves_east + 1; hint format["%1",_waves_east]; //Spawn AI depending on _waves_east //Wait until all east units are dead waitUntil {({(side _x) == east} count allUnits) == 0}; //Some sleep sleep 2; }; Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 thanks, im prolly gonna use this one i think, but how can i get it to exit loop? after five waves? while {true} do { hint format["%1",_waves_east]; sleep 60; if ( ({(side _x) == east} count allUnits) == 0 ) then { _waves_east = _waves_east + 1; execVM "ai.sqf"; }; if (_waves_east == 5) then { //---Exit loop }; }; Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 Oh it should have been while {_waves_east < 5} do { Loop will end when _waves_east will be 5 (and 5th waves spawned and killed) In your case it can be if (_waves_east == 5) exitWith {}; Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 here is where i'm stuck again server.sqf if (!isServer || time > 30) exitWith {}; createCenter EAST; WEST setFriend [EAST, 0]; EAST setFriend [WEST, 0]; //-- Relocate Players and Spawn AI if (GetStartLocation == 1) then { RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackAirport"; player setpos getmarkerpos "StartingLocation1"; player setdir 180; ExecVM "AI\AI.sqf"; }; if (GetStartLocation == 2) then { RandomDirection = ["North of Airstation","North East of Airstation","North West of Airstation","South of Airstation","South East of Airstation","South West of Airstation","West of Airstation","East of Airstation"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackAirStation"; player setpos getmarkerpos "StartingLocation2"; player setdir 180; ExecVM "AI\AI.sqf"; }; if (GetStartLocation == 3) then { RandomDirection = ["North of Military Range","North East of Military Range","North West of Military Range","South of Military Range","South East of Military Range","South West of Military Range","West of Military Range","East of Military Range"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackMilitaryRange"; player setpos getmarkerpos "StartingLocation3"; player setdir 180; ExecVM "AI\AI.sqf"; }; if (GetStartLocation == 4) then { ExecVM "Randomize_Start_Location.sqf"; }; sleep 5; _waves_east = 0; while {_waves_east < 5} do { //Wait until all east units are dead waitUntil {({(side _x) == east} count allUnits) == 0}; //Increase counter _waves_east = _waves_east + 1; hint format["Reinforcments: %1",_waves_east]; execVM "AI\AI.sqf"; //Some sleep sleep 5; }; AI.sqf //if (isServer) then { //SELECT ENEMY AI SKILL. Using the value from param AISkill. switch (AICurrentSkill) do { //Novice case 1: { AICurrentSkill = 0.25; }; //Rookie case 2: { AICurrentSkill = 0.45; }; //Veteran case 3: { AICurrentSkill = 0.65; }; //Expert case 4: { AICurrentSkill = 0.85; }; //Elite case 5: { AICurrentSkill = 0.95; }; }; //RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); _rndDirhint = [nil,nil,"per",rHINT,RandomDirection] call RE; //Display Intel if true. if (ShowIntel) then { hint format ["Intel: Infantry Spotted: %1", RandomDirection]; }; _grp1 = createGroup east; _grp1 = [getMarkerPos RandomDirection, east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; _grp1 allowFleeing 0; _wp0 = _grp1 addWaypoint [AttackMarkerLocation,0]; _wp0 setWaypointType "SAD"; _wp0 setWaypointFormation "LINE"; _wp0 setWaypointBehaviour "COMBAT"; _wp0 setwaypointcombatmode "YELLOW"; _wp0 setWaypointSpeed "NORMAL"; _wp0 setWaypointCompletionRadius 20; //_wp0 = nil; fnc_AI_Skill ={ _grpname = _this select 0; _grpleader = leader _grpname; _grpleader setskill AICurrentSkill; { _x setskill ["aimingAccuracy",AICurrentSkill]; _x setskill ["aimingShake",AICurrentSkill]; _x setskill ["aimingSpeed",AICurrentSkill]; _x setskill ["commanding",AICurrentSkill]; _x setskill ["courage",AICurrentSkill]; _x setskill ["spotDistance",AICurrentSkill]; _x setskill ["spotTime",AICurrentSkill]; //Call Set Skill [_grp1] call fnc_AI_Skill; Appreciate all the help mate. Ok, so the code before i asked about is at the bottom of the server.sqf now, code is getting quite large. been messing with this for over an hour trying to get the new loop script added in a way in which, based on the start locations randomizes the 8 markers based on what ever of the start location was used. you follow me? i cant seem to figure it out. Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 Don't understand what's your problem here. Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 the part in the server.sqf where it shows this: RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); that works 1 time, but then the loop takes over at the bottom of the code in the server.sqf and keeps the old randomdirection looping, so all new ai in that loop spawn in the same spot instead of random. i need to add "RandomDirection" code to the loop some how so it regenerates a random location based on if the startlocation was airport, air station mike or miltary range. Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 in server.sqf depending on GetStartLocation RandomDirections = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"]; in AI.sqf RandomDirection = RandomDirections select floor(random(count RandomDirections)); Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 but it could be any of the 3 based on parameter RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); RandomDirection = ["North of Airstation","North East of Airstation","North West of Airstation","South of Airstation","South East of Airstation","South West of Airstation","West of Airstation","East of Airstation"] select floor(random 8); RandomDirection = ["North of Military Range","North East of Military Range","North West of Military Range","South of Military Range","South East of Military Range","South West of Military Range","West of Military Range","East of Military Range"] select floor(random 8); ---------- Post added at 02:27 PM ---------- Previous post was at 02:24 PM ---------- i dont want to spawn ai buy the airport if the players playing the mission spawned at the milatary ranged vise versa ya see? Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 You don't change location after each wave, right? Set RandomDirections once and then select random value from it each wave. Also notice RandomDirections and RandomDirection are different variable names in my example. Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 no starting locations dont change after spawn. the only thing that needs new spawn locations is the AI if (GetStartLocation == 1) then { RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); }; _waves_east = 0; while {_waves_east < 5} do { waitUntil {({(side _x) == east} count allUnits) == 0}; _waves_east = _waves_east + 1; execVM "AI\AI.sqf"; sleep 5; }; WOuld be nice if its possble to add if statmentes in the loop, i dont know if it's pssable? so while it loops if "getlocation" ==1 then it generates the Location 1 Airport Array etc... etc Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 Why you need to check GetStartLocation each loop? Check it once and them use selected variable later switch(GetStartLocation) do { case 0: {whatever = [1,2,3];}; case 1: {whatever = [4,5,6];}; }; // ... while {true} do { random_whatever = whatever select floor(random(count whatever)); }; Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 im not good with syntax at all, this is what i am assuming to do with the code u showed lol switch(GetStartLocation) do { case 1: {whatever = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"];}; case 2: {whatever = ["North of Airstation","North East of Airstation","North West of Airstation","South of Airstation","South East of Airstation","South West of Airstation","West of Airstation","East of Airstation"];}; case 3: {whatever = ["North of Military Range","North East of Military Range","North West of Military Range","South of Military Range","South East of Military Range","South West of Military Range","West of Military Range","East of Military Range"] select floor(random 8); while {true} do { random_whatever = whatever select floor(random(count whatever)); }; while {_waves_east < 5} do { waitUntil {({(side _x) == east} count allUnits) == 0}; _waves_east = _waves_east + 1; execVM "AI\AI.sqf"; sleep 5; }; Share this post Link to post Share on other sites
samatra 85 Posted June 29, 2013 It was just a generic example of script logic that you should use in your script. Share this post Link to post Share on other sites
falconx1 13 Posted June 29, 2013 Error in expression <r = RandomDirection select floor(random(count RandomDirection)); hint format ["I> Error position: <count RandomDirection)); hint format ["I> Error count: Type String, expected Array,Config entry File C:\Users\Arma 3 - Other Profiles\FalconX-1\missions\missionname.Stratis\server.sqf, line 60 server.sqf if (!isServer || time > 30) exitWith {}; createCenter EAST; WEST setFriend [EAST, 0]; EAST setFriend [WEST, 0]; //-- Relocate Players and Spawn AI if (GetStartLocation == 1) then { RandomDirection = ["North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackAirport"; player setpos getmarkerpos "StartingLocation1"; player setdir 180; ExecVM "AI\AI_4X_Infantry_Airport.sqf"; }; if (GetStartLocation == 2) then { RandomDirection = ["North of Airstation","North East of Airstation","North West of Airstation","South of Airstation","South East of Airstation","South West of Airstation","West of Airstation","East of Airstation"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackAirStation"; player setpos getmarkerpos "StartingLocation2"; player setdir 180; ExecVM "AI\AI_4X_Infantry_Airport.sqf"; }; if (GetStartLocation == 3) then { RandomDirection = ["North of Military Range","North East of Military Range","North West of Military Range","South of Military Range","South East of Military Range","South West of Military Range","West of Military Range","East of Military Range"] select floor(random 8); AttackMarkerLocation = getMarkerPos "AttackMilitaryRange"; player setpos getmarkerpos "StartingLocation3"; player setdir 180; ExecVM "AI\AI_4X_Infantry_Airport.sqf"; }; if (GetStartLocation == 4) then { ExecVM "Randomize_Start_Location.sqf"; }; sleep 5; switch(GetStartLocation) do { case 1: {RandomDirection = "North of Airport","North East of Airport","North West of Airport","South of Airport","South East of Airport","South West of Airport","West of Airport","East of Airport";}; case 2: {RandomDirection = "North of Airstation","North East of Airstation","North West of Airstation","South of Airstation","South East of Airstation","South West of Airstation","West of Airstation","East of Airstation";}; case 3: {RandomDirection = "North of Military Range","North East of Military Range","North West of Military Range","South of Military Range","South East of Military Range","South West of Military Range","West of Military Range","East of Military Range";}; }; _waves_east = 0; while {_waves_east < 5} do { waitUntil {({(side _x) == east} count allUnits) == 0}; //Increase counter _waves_east = _waves_east + 1; random_Dir = RandomDirection select floor(random(count RandomDirection)); hint format ["Intel: Infantry Spotted: %1", RandomDirection]; ExecVM "AI\AI.sqf"; sleep 5; }; diag_log format ["ERROR CODES: %1", RandomDirection]; Share this post Link to post Share on other sites