Jump to content

Randomize AO's spawning


Sgt_HARTMAN

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

 
Link to comment
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;

 

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...
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. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Forum Statistics

    11.1k
    Total Topics
    66.4k
    Total Posts
×
×
  • Create New...