Jump to content
greywolf907

Random tasks\objectives

Recommended Posts

yeah I tried that but I still need the code below somewhere to complete the waitUntil _clearTask function.

 

_trigger setTriggerStatements ["this",format ["[%1,'Succeeded'] call BIS_fnc_taskSetState",_clearTask],""];

 

I was hoping by just putting down a second trigger just like the one you're using that it would actually detect the spawned AI, but it doesn't seem to work that way for this implementation... :/ I'm looking around now to see if I can add a second trigger logic that will detect from trg1's the presents of EAST so that when they are all dead I can actually fire the statement above.

 

hope this is making sense, but if not, when I get home from work today I'll post up some of the code.

Thanks again.  

Share this post


Link to post
Share on other sites

You sure DAC doesn't provide access to an array of all DAC spawned AI?

Share this post


Link to post
Share on other sites

Think I found the solution. https://forums.bistudio.com/topic/167033-dac-v31-dynamic-ai-creator-released/?p=2943643

 

I'll test right when I get home and post results if you all want.

thanks for the help jshock and Iarrow.

Honestly you dont need the DAC approach now. Silola was responding to my query on that thread you pointed out. I replaced it with JShocks amazing spawn function coupled with the delete AO function, as he told the guy earlier in this thread. You can change it to spawn units from all 3 sides. :)

 

You can take apart my mission "Al Inteqam" (in signature) you will find your answer. Its neat and doesnt cause lag like DAC. :)

 

Thank you.

Share this post


Link to post
Share on other sites

JShocks amazing spawn function coupled with the delete AO function

Amazing no, simple so others can hopefully learn something, yes :D. Appreciate the complement though. I made it readable, not optimal :p.

  • Like 1

Share this post


Link to post
Share on other sites

Hey jshock, not sure what happened something changed since the last couple game updates I noticed that no more air assets were at the AO's anymore here is the script you put together for me see what you think is the problem I messed with it a bit can't sort it out. Thanks

 

/* ////////////////////////////////////////////// 
Author: J.Shock 
 
File: fn_patrols.sqf 
 
Description: Creates randomly positioned and sized patrols throughout a defined radius of an AO 
             using a marker as the center position. 
 
Parameters:  
        1- Center position: (array) (default: empty array) 
        2- Radius to spawn units: (integer) (default: 300) 
        3- Number of foot patrol groups: (integer) (default: 5) 
        4- Number of vehicle patrol groups: (integer) (default: 3) 
        5- Number of mechanized patrol groups: (integer) (default: 2) 
        6- Number of armor patrol groups: (integer) (default: 2) 
        7- Number of air patrol groups: (integer) (default: 1) 
        8- Side: (side) (default: EAST) 
         
Return: Spawned units. 
 
Example Call line: _units = ["mrkName",200,5,3,2,2,1,EAST] call JSHK_fnc_patrols; 
 
*/////////////////////////////////////////////// 
private [ 
            "_AOmarker","_radius","_numFootPatrols","_numVehPatrols","_center", 
            "_numArmorPatrols","_numMechPatrols","_numAirPatrols","_side","_footUnits", 
            "_vehUnits","_armorUnits","_mechUnits","_airUnits","_units" 
        ]; 
 
_AOmarker = [_this, 0, [], [[]]] call BIS_fnc_param; 
_radius = [_this, 1, 300, [0]] call BIS_fnc_param; 
_numFootPatrols = [_this, 2, 30, [0]] call BIS_fnc_param; 
_numVehPatrols = [_this, 3, 3, [0]] call BIS_fnc_param; 
_numArmorPatrols = [_this, 4, 2, [0]] call BIS_fnc_param; 
_numMechPatrols = [_this, 5, 2, [0]] call BIS_fnc_param; 
_numAirPatrols = [_this, 6, 1, [0]] call BIS_fnc_param; 
_side = [_this, 7, EAST, [WEST]] call BIS_fnc_param; 
 
_footUnits = ["OIA_InfSentry","OIA_ReconSquad","OI_reconPatrol","OI_SniperTeam"]; 
_vehUnits = ["O_MRAP_02_hmg_F","O_MRAP_02_gmg_F"]; 
_armorUnits = ["O_MBT_02_cannon_F","O_APC_Tracked_02_AA_F"]; 
_mechUnits = ["O_APC_Wheeled_02_rcws_F","O_APC_Tracked_02_cannon_F"]; 
_airUnits = ["O_Heli_Attack_02_black_F","O_Plane_CAS_02_F"]; 
 
_center = createCenter _side; 
 
_units = []; 
 
if (_numFootPatrols > 0) then 
    for "_i" from 1 to (_numFootPatrols) step 1 do  
    { 
        _configGrp = _footUnits call BIS_fnc_selectRandom; 
        _rndPos = [[[_AOmarker, _radius], []], ["water", "out"]] call BIS_fnc_randomPos; 
        _grp = [_rndPos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_configGrp))] call BIS_fnc_spawnGroup; 
        [_grp, (_AOmarker), (random(50)+75)] call BIS_fnc_taskPatrol; 
        {_units pushBack _x} forEach units _grp; 
        sleep 0.05; 
    }; 
};     
 
if (_numVehPatrols > 0) then 
    for "_i" from 1 to (_numVehPatrols) step 1 do  
    { 
        _rndVeh = _vehUnits call BIS_fnc_selectRandom; 
        _rndPos = [_AOmarker,50,_radius,5,0,0.5,0,[],[]] call BIS_fnc_findSafePos; 
        _veh = [_rndPos,random(359),_rndVeh,_center] call BIS_fnc_spawnVehicle; 
        [(_veh select 2),(_AOmarker),(random(50)+100)] call BIS_fnc_taskPatrol; 
        {_units pushBack _x} forEach (_veh select 1); 
        _units pushBack (_veh select 0); 
        sleep 0.05; 
    }; 
}; 
 
if (_numArmorPatrols > 0) then 
    for "_i" from 1 to (_numArmorPatrols) step 1 do  
    { 
        _rndVeh = _armorUnits call BIS_fnc_selectRandom; 
        _rndPos = [_AOmarker,50,_radius,5,0,0.5,0,[],[]] call BIS_fnc_findSafePos; 
        _veh = [_rndPos,random(359),_rndVeh,_center] call BIS_fnc_spawnVehicle; 
        [(_veh select 2),(_AOmarker),(random(50)+100)] call BIS_fnc_taskPatrol; 
        {_units pushBack _x} forEach (_veh select 1); 
        _units pushBack (_veh select 0); 
        sleep 0.05; 
    }; 
}; 
 
if (_numMechPatrols > 0) then 
    for "_i" from 1 to (_numMechPatrols) step 1 do  
    { 
        _rndVeh = _mechUnits call BIS_fnc_selectRandom; 
        _rndPos = [_AOmarker,50,_radius,5,0,0.5,0,[],[]] call BIS_fnc_findSafePos; 
        _veh = [_rndPos,random(359),_rndVeh,_center] call BIS_fnc_spawnVehicle; 
        [(_veh select 2),(_AOmarker),(random(50)+100)] call BIS_fnc_taskPatrol; 
        {_units pushBack _x} forEach (_veh select 1); 
        _units pushBack (_veh select 0); 
        sleep 0.05; 
    }; 
}; 
 
if (_numAirPatrols > 0) then 
    for "_i" from 1 to (_numAirPatrols) step 1 do  
    { 
        _rndVeh = _airUnits call BIS_fnc_selectRandom; 
        _rndPos = [[[_AOmarker, _radius],[]],["water","out"],[],{}] call BIS_fnc_randomPos; 
        _veh = createVehicle [_rndVeh,_rndPos,[],0,"FLY"]; 
        createVehicleCrew _veh; 
        [(group _veh),(_AOmarker),350] call BIS_fnc_taskPatrol; 
        {_units pushBack _x} forEach (crew _veh); 
        _units pushBack _veh; 
        sleep 0.05; 
    }; 
};   
 
_units;  

Share this post


Link to post
Share on other sites

If there aren't any errors that pop up, I'm not 100% sure what it could be, I haven't been wholefully following any of the recent game updates, nor do I script as much as I once did. Have you checked to see if they spawn, but instead of in the air flying, maybe they just crashed on spawn? Or something similar to that at least.

A good debug you could try is to create a marker on the position that the air vehicle was supposed to be created at, then check that position with a character or through zeus.

Share this post


Link to post
Share on other sites

Hey jshock thanks for the help, It does throw up a script error I should have put that on my last post.

20160623193540_1_zpsocwshvgj.jpg

Share this post


Link to post
Share on other sites

Hm, seems like BIS_fnc_randomPos isn't returning anything, so the central position doesn't provide any possible positions within the radius or the BIS function has changed since my use of it in that script, I've looked at the wiki and it seems the same to me. If the BIS function works for the foot patrol portion, I don't know why it won't work on the air patrol.

Share this post


Link to post
Share on other sites

Anyone have an idea of how to fix that error?

Hey man. I too was having that error. You only have to change the spawn lines for the airplanes. Like so:

if (_numAirPatrols > 0) then 
{ 
    for "_i" from 1 to (_numAirPatrols) step 1 do  
    { 
        _rndVeh = _airUnits call BIS_fnc_selectRandom; 
        _rndPos = [_AOmarker, [80,100], random 360, 0, [0], 100] call SHK_pos;
        _veh = createVehicle [_rndVeh,_rndPos,[],0,"FLY"]; 
        createVehicleCrew _veh; 
	0 = [group _veh,_radius] execVM "shk_patrol.sqf";	
        {_units pushBack _x} forEach (crew _veh); 
        _units pushBack _veh; 
        sleep 0.05; 
    }; 
};

You need SHK_pos and shk_patrol. Hope this helps :)

Share this post


Link to post
Share on other sites

Hey thanks for response I was still getting an error but sorted it out with adding a line into my init.sqf air assets are back up and running Thanks. 

  • Like 1

Share this post


Link to post
Share on other sites

Hey thanks for response I was still getting an error but sorted it out with adding a line into my init.sqf air assets are back up and running Thanks. 

Good to hear..

Share this post


Link to post
Share on other sites

Hey Jshock do you still have the example mission from the first page of this thread??

The link no longer works

 

Thanks

Share this post


Link to post
Share on other sites

Hey Jshock do you still have the example mission from the first page of this thread??

The link no longer works

 

Thanks

I don't remember deleting it from my dropbox, but I guess I did somewhere down the line, however, greywolf's mission should be example enough:

 

http://www.armaholic.com/page.php?id=28149

  • Like 2

Share this post


Link to post
Share on other sites

Hey Shock simple question I'm sure you can answer faster than me trying to figure it out. How can I make the AO's have a colored circle marker around them when they spawn so they are easy to see and of course delete with the AO  when completed? Also the secondary objective auto assigns instead of the primary objective is there a better way to set that part up so that the primary always is assigned as main target and secondary is still marked within the AO's area?

Share this post


Link to post
Share on other sites

Hey thanks for response I was still getting an error but sorted it out with adding a line into my init.sqf air assets are back up and running Thanks. 

 

If you don't mind me asking what did you add to the init.sqf because I still cannot get air units. Doesn't like _rndpos even though works fine for other vehicles and infantry. Thanks in advance

  • Like 1

Share this post


Link to post
Share on other sites

If you don't mind me asking what did you add to the init.sqf because I still cannot get air units. Doesn't like _rndpos even though works fine for other vehicles and infantry. Thanks in advance

Here, I answered it on the last page: https://forums.bistudio.com/topic/177884-random-tasksobjectives/page-7#entry3055622

Share this post


Link to post
Share on other sites

Hey thanks for response I was still getting an error but sorted it out with adding a line into my init.sqf air assets are back up and running Thanks. 

 

 

 

Sorry I didnt test that yet as based on greywolfs response above believed it didnt work.

Im no expert on this stuff so can I just use the default files you listed or do they need modifying. Shkpos shkpatrol that is?

  • Like 1

Share this post


Link to post
Share on other sites

Sorry I didnt test that yet as based on greywolfs response above believed it didnt work.

Im no expert on this stuff so can I just use the default files you listed or do they need modifying. Shkpos shkpatrol that is?

you can replace SHK_pos and SHK_patrol with the vanilla BIS_fnc_findsafepos and use BIS_fnc_taskPatrol:

...

_rndpos = [_AOmarker, 50, 2000, 9, 0] call BIS_fnc_findSafePos;// Marker name, min distance from marker
//, max distance from marker, min distance from nearest map object to avoid collision, and finally 0 for only land positions

...

// now for vanilla patrol

[group _veh, _AOmarker, _radius] call BIS_fnc_taskPatrol; // I think there was a problem with bis task patrol
// when used on helis. not sure. check and share if you get any errors.

I forgot the type of error I received. Can you please enable error scripts and send a screenshot of the error message?

Share this post


Link to post
Share on other sites

you can replace SHK_pos and SHK_p with the vanilla BIS_fnc_findsafepos and use BIS_fnc_taskPatrol:

...

_rndpos = [_AOmarker, 50, 2000, 9, 0] call BIS_fnc_findSafePos;// marker name, min distance from marker
//, max distance from marker, min distance from nearest map object to avoid collision, and finally 0 for only land positions

...

// now for vanilla patrol

[group _veh, _AOmarker, _radius] call bis_fnc_taskPatrol; //i think there as a problem with bis task patrol
// when used on helis. not sure. check and share if you get any errors.

I forgot the type of error I received. Can you please enable error scripts and send a screenshot of the error message?

 

Error message was exactly same as greywolfs on previous page. I will try what you have given me there and update you with how I go. Thanks for the help. At work now so prob wont get back to it till tommorrow. Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Error message was exactly same as greywolfs on previous page. I will try what you have given me there and update you with how I go. Thanks for the help. At work now so prob wont get back to it till tommorrow. Cheers

Ok. put these 2 lines in place of shk_pos and the shkpatrol lines in the mission sqf. It should solve your problem. :)

 

And I feel that issue with Greywolf which was solved by adding a line in the init.sqf prolly had to do with him accidentally not including the Shk_pos and ShkPatrol exec lines earlier. Just guessing.

  • Like 1

Share this post


Link to post
Share on other sites

Ok. put these 2 lines in place of shk_pos and the shkpatrol lines in the mission sqf. It should solve your problem. :)

 

And I feel that issue with Greywolf which was solved by adding a line in the init.sqf prolly had to do with him accidentally not including the Shk_pos and ShkPatrol exec lines earlier. Just guessing.

 

Thanks Armaman,

 

The above worked and spawned air unit but now I cant get it to spawn more than 1...lol

 

Errors

Error in expression <unt (_testPos isFlatEmpty [_objDist, 0, _maxGradient, _objDist max 5, _waterMode>
15:19:05   Error position: <_maxGradient, _objDist max 5, _waterMode>
15:19:05   Error Undefined variable in expression: _maxgradient
15:19:05 File A3\functions_f\misc\fn_findSafePos.sqf, line 100
if (_shoreMode == 0) then {_s>
15:19:05   Error position: <select 6;
 
if (_shoreMode == 0) then {_s>
15:19:05   Error Zero divisor
15:19:05 File A3\functions_f\misc\fn_findSafePos.sqf, line 48

 

Weird but then I dont understand all this code.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Armaman,

 

The above worked and spawned air unit but now I cant get it to spawn more than 1...lol

 

Errors

Error in expression <unt (_testPos isFlatEmpty [_objDist, 0, _maxGradient, _objDist max 5, _waterMode>
15:19:05   Error position: <_maxGradient, _objDist max 5, _waterMode>
15:19:05   Error Undefined variable in expression: _maxgradient
15:19:05 File A3\functions_f\misc\fn_findSafePos.sqf, line 100
if (_shoreMode == 0) then {_s>
15:19:05   Error position: <select 6;
 
if (_shoreMode == 0) then {_s>
15:19:05   Error Zero divisor
15:19:05 File A3\functions_f\misc\fn_findSafePos.sqf, line 48

 

Weird but then I dont understand all this code.

 

 

Try this line instead of the above safepos line:

_rndpos = [_AOmarker, 50, 2000,[],0] call BIS_fnc_findSafePos;// I guess the gradient thing interferes with Air units

If that doest work, try this:

_rndpos = [_AOmarker, 50, 2000] call BIS_fnc_findSafePos;// this will also consider any water bodies in the radius, but who cares  // its a flying heli :)
  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×