Jump to content
Sgt_HARTMAN

Randomize AO's spawning

Recommended Posts

Hello everyone.


Would anyone know how to randomize the appearance of the main missions?


Indeed, I would like to do as on the old I & A at least two years old.


That is, start the first mission anywhere on Altis and at the end of it, select another random location and no longer work with the "controlled zones".

 

After several attempts to modify scripts in "fn_getAo.sqf" and "MainAos.hpp, I can not find a solution to what I want to achieve.

 

I thank you in advance for your help.

 

Sorry for any mistakes in my sentences, I am French and my English is not great ...

 

Sgt_HARTMAN

 

Share this post


Link to post
Share on other sites

This is a little script I've written to find the closest AO to a given position, you can probably tweak it to pick a random AO:

private _sortedByRange = [allMapMarkers, [_pos], {(getMarkerPos _x) distance2D _input0}, "ASCEND"] call BIS_fnc_sortBy;
        private _breakOut = false;
        {
            if (markerType _x == "Empty") then {
                private _name = (missionConfigFile >> "Main_Aos" >> "AOs" >> _x >> "name") call BIS_fnc_getCfgData;
                if (!isNil "_name") then {
                    if (str _name != "any") then {
                        private _result = [format ["Do you want to set %1 as the next AO?", _name], "", "Yes", "No"] call BIS_fnc_guiMessage;
                        if (_result) exitWith {
                            manualAO = _x;
                            publicVariableServer "manualAO";
                            hint (_name + " set as next AO.");
                            _breakOut = true;
                        };
                        if (!_result) exitWith {
                            hint "Did nothing";
                            _breakOut = true;
                        };
                    };
                };
            };
            if (_breakOut) exitWith {};
        } forEach _sortedByRange;

 

Share this post


Link to post
Share on other sites

Well probably fn_getAo.sqf but as I said this is some code I've made to find the closest AO to a given location.  You'll need to alter it for it to pick a random AO. 

Share this post


Link to post
Share on other sites

I am not an expert in scripting, I made several attempts but unsuccessful.
Would there be another way to only change the order of appearance? In my tests I changed the order of "Class" in "MainAos.hpp" but the first AO spawn always to "Atkinarki".
Would there be another script determining the order of appearance of "Aos"?

Thanks

Share this post


Link to post
Share on other sites
private _nextAO = "";
if (manualAO != "") then {
	_nextAO = manualAO;
};

while {_nextAO == ""} do {
	private _testAO = selectRandom allMapMarkers;
  	
  	private _testAOName = (missionConfigFile >> "Main_Aos" >> "AOs" >> _x >> "name") call BIS_fnc_getCfgData;
  
  	if (!isNil "_name") then {
    	if (str _name != "any") then {
        	if (!(_nextAO in controlledZones)) then {
            	_nextAO = _testAO;
            };
        };
    };
};
_nextAO

Replace whatever is in fn_getAo by this.  Don't know if it works or not, I didn't test it.

Share this post


Link to post
Share on other sites

bug.PNG.796545a1a445095ee47dbedfb4e1e830.PNG

 

 


I tried to declare the variable or replace

_x

with

_AO_Entry

by declaring

_AO_Entry = _this select 0;

but it does not work, I will try other things while waiting for some help. 

 

Thank you

Share this post


Link to post
Share on other sites

You should really learn some scripting if you want to edit scripts to make them do something else.

 

private _nextAO = "";
if (manualAO != "") then {
	_nextAO = manualAO;
};

while {_nextAO == ""} do {
	private _testAO = selectRandom allMapMarkers;
  	
  	private _testAOName = (missionConfigFile >> "Main_Aos" >> "AOs" >> _testAO >> "name") call BIS_fnc_getCfgData;
  
  	if (!isNil "_name") then {
    	if (str _name != "any") then {
        	if (!(_nextAO in controlledZones)) then {
            	_nextAO = _testAO;
            };
        };
    };
};
_nextAO

This should fix that, still untested.

Share this post


Link to post
Share on other sites

That's what I do, I learn by integrating pre-edited scripts and create some basic ones. I & A is quite complex and it allows me to learn.

 

I thank you for the advice you give me because you help me to learn even if I know you have more important things to do.

 

I tried the last script you gave me but unfortunately nothing happens. the main and secondaries missions don't spawn but no error messages appears.

 

Would this be a problem with "(_nextAO in controlledZones)" or because the "manualAO" should be called by another scipt ? or quite simply manually called by an admin command in game ? 

 

I will continue my tests by modifying the script in "MainMachine.sqf"

 

thanks for your help.

Share this post


Link to post
Share on other sites

Thank you, I just found how to move the spawn point of the first AO and following.

 

I keep looking how spawn the AOs as in the 2.82 version of the invade & annex

 

Do I wish you a good holiday ? lol

 

Thank's

Share this post


Link to post
Share on other sites

 

Hello world,

 

I allow myself to UP this subject because because I did not find the solution.

 

I understood why the sides did not appear and have fixed it. 

 

 

thank you in advance 

Share this post


Link to post
Share on other sites
private _nextAO = "";
if (manualAO != "") then { _nextAO = manualAO; };

while {_nextAO == ""} do {
  	private _testAO = selectRandom allMapMarkers;
  	private _testAOName = (missionConfigFile >> "Main_Aos" >> "AOs" >> _testAO >> "name") call BIS_fnc_getCfgData;
  
  	if (!isNil "_testAOName") then {
    	if (str _testAOName != "any") then {
        	if (!(_nextAO in controlledZones)) then {
            	_nextAO = _testAO;
            };
        };
    };
};
_nextAO

Try that, didn't test it myself though. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    9,436
    Total Topics
    60,839
    Total Posts
×
×
  • Create New...