Custom Objectives

  1. 8 years ago

    I was planning on using the Military placement (Cust. Obj.) module, in an asym game mode, to get the AI commander to spread out to the nearest objective instead of the most important one that might be on the other side of the map. However i have run into the problem that it spawns a custom military objective, and i need custom civilian ones, because they won't recruit at military objectives. Is there a way to get the custom objective module to spawn custom civilian objectives, or a similar work around?

  2. Yeah I think I can help with this when im home. Just have to try modifyng one thing to make sure it works.

  3. Glad to hear there is a method for this. :)

  4. Edited 8 years ago by SpyderBlack723

    Alright here we go, it looks complicated but I just have a tendency to put a ton of information since I don't know your experience level with scripting.

    First you need to define this function which you can do just by placing it in your init.sqf ( I usually put it at the bottom so you don't crowd the file (and so the sleep command which is explained later doesn't hold up the bulk of your init.sqf)).

    cjb_addObjectiveToSides = {
    	private["_objectiveParams","_factions","_faction","_opcom","_opcomSide"];
    	_objectiveParams = _this select 0;
    	_factions = _this select 1;
    	{
    		_opcom = _x;
    		{
    			_faction = _x;
    			_opcomSide = [_opcom,"side",""] call ALiVE_fnc_HashGet;
     
    			if( _opcomSide == _faction) then {
    				[_opcom, "addObjective", _objectiveParams] call ALiVE_fnc_OPCOM;
    			};
    		} forEach _factions;
    	} forEach OPCOM_INSTANCES;
    };

    Then, also in the init.sqf you need to do this for each objective you are going to add

    [["obj_1", getMarkerPos "Markername", 100,"CIV"],["WEST","INDEP","EAST"]] call cjb_addObjectiveToSides;

    For each objective you will have to change a few things to make sure they are each unique

    1. "obj_1" -- this can just be changed to ex. "obj_2" ,"obj_3" just add 1 each time you add another objective

    3. 100 is the size, you can change the size up or down depending on the size of objective you want

    4. ["WEST","INDEP","EAST"] This is the sides that the objective is made aware of to, the current setup will do it for all sides. However, if you make it ["EAST"] then it will only be made aware to the EAST side. If you make it ["EAST","WEST"] then both EAST and WEST will attempt to occupy the objective.
    -----------------------------------------------------------------------------------------------------------------------
    An example of this being used is

    [["obj_1", getMarkerPos "Marker1", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;
    [["obj_2", getMarkerPos "Marker2", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;

    This will make two objectives at Marker1 and Marker 2 with a size of 100 square meters that is only occupied by the EAST side.
    2. getMarkerPos "Markername" , you need to change "Markername" to the marker where this objective will be added -- this defines the location of the objective

    IMPORTANT
    Since ALiVE initializes during mission init, if it is called immediately it will fail since ALiVE has not initialized the OPCOM (Military AI Commander) module yet. To get around this ( I couldn't figure out another automatic way) you can simply put a sleep command before calling this.You may need a longer sleep time if your mission takes a long time to load, haven't really tested it so I am not sure how long on average ALiVE would take to initialize.

    sleep 60;
    [["obj_1", getMarkerPos "Marker1", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;
    [["obj_2", getMarkerPos "Marker2", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;

    This will create the objectives 60 seconds after you press "Launch" in the Editor/MP.

  5. This looks great, if you find an alternate method to that sleep command that is a tad more reliable that might be useful, as i usually run this on my communities dedicated server, with anywhere from 20-40 players and ALiVE can take upwards of 10 minutes sometimes to load up a mission on altis. So something other than guessing the time taken would be more reliable, if you or anyone else can think of something. But thanks for the help this is exactly what i need. :D

  6. I'm pretty sure there is a function that checks for when ALiVE has finished initializing... something like this:

    waitUntil {!isNil "ALIVE_profileSystemInit"};

    Not sure if that's right however.. might have to wait for a dev to respond.

  7. Edited 8 years ago by SpyderBlack723

    That would be much more useful.. can test later to find out if it works. I assume it will.

  8. I know I've seen it somewhere but can't find it in the wiki.. might be in a demo mission.

  9. Edited 8 years ago by SpyderBlack723

    Works beautifully, thanks Savage.

    This would be the updated example, you can remove the sleep in the waitUntil but I figured I'd throw it in there since you said your missions sometimes take up to 10 minutes to load (so no reason to check every frame as it is kind of pointless).

    waitUntil {sleep 10;!isNil "ALIVE_profileSystemInit"};
    [["obj_1", getMarkerPos "Marker1", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;
    [["obj_2", getMarkerPos "Marker2", 100,"CIV"],["EAST"]] call cjb_addObjectiveToSides;
  10. } forEach _factions;
    } forEach OPCOM_INSTANCES;
    };

    This section chucks out a script error, with OPCOM_INSTANCES as an undefined variable.

  11. Edited 8 years ago by SpyderBlack723

    Are you using the waitUntil {sleep 10;!isNil "ALIVE_profileSystemInit"}; on the line before the objectives are being set?

    That is exactly that is supposed to prevent, so if it is still happening not sure why.

    It's chucking out an error because ALiVE hasn't fully initialized so OPCOM is still undefined(I don't know the complete details).

  12. Edited 8 years ago by Twelvecaliber

    Okay, i have it working, however the AI seem to be now going after each objective in the order that the objectives are created, so the first one in the list is the one they will always go to first, is there a way to change this behavior and make them go for the nearest objective instead of the one they are told about first, seen as it is on the other side of the map from where they start, and this adds predictability as they will always choose the same general route.

  13. Edited 8 years ago by SpyderBlack723

    I don't think so atm. I believe this was one thing they were looking to change in the future because OPCOM always prioritized the same objectives every mission with little to no randomization.

    Edit: Here's the DH ticket
    http://dev.withsix.com/issues/76102
    Edit: Ticket has been closed and feature will be available in next release.

  14. Hi, guys.

    I'm trying to manually sub in an objective (and hopefully induce an ALiVE reinforcement location) on the new northern island on icebreakr's Isla Duala 3.33.

    I'm currently using a mil placement (custom obj.) in a clear space on the new northern island. The composition I chose is spawning correctly, along with the units I specified (though a mechanized unit would occasionally drop the IFVs on a durable object at spawning and blow up). So I'd like to use the custom objective instead..? It'd be moot if OPCOM doesn't use the custom objective to reinforce and spawn new units. I'm not even sure if the current mil placement custom objective is doing so, b/c I haven't seen anything beyond the initial units spawn.

    I found the script snippet to include in the init.sqf, but I'm still new to scripting and am not sure what I need to define, to feed correctly into the parameters for ALiVE_fnc_OPCOM.

    This is the snippet as shown in the FAQ:

    [_OPCOM,"addObjective",[_id, _pos, _size]] call ALiVE_fnc_OPCOM

    I have nothing else in my init.sqf -- no variables defined at all. I have a marker named "marker01" placed on the map, on Kalimbo Armybase (which obviously currently doesn't register as any kind of objective with ALiVE b/c the map update hasn't been reindexed with ALiVE yet). The marker is located in a TAOR marker for a military placement (mil. obj.) with debug turned on (if my custom objective is correct, I'd see it, right?). I understand from other threads that due to init order, ALiVE may or may not register the custom objective in time to populate it with the battalion (400) force I specified in the mil placement. Is there a way to cause that military placement to populate? If not, I'll settle for using it as a reinforcement point (which it will if it's recognized as an objective and occupied by friendly units, right?).

    This is my best guess, that I put in the init.sqf. It didn't work -- why is obvious to you but a mystery to me right now. What do I need to fix/change?

    [_OPCOM,"addObjective",["custom_1", getMarkerPos "marker01", 100, "MIL", 200]] call ALiVE_fnc_OPCOM;

    I saw the additional sub-array options somewhere in a thread with SpyderBlack723, and I assumed that they refer to 100 priority, MIL type instead of CIV, and 200 objective size. I've also tried it without the MIL and 200, exactly per the FAQ.

    Do I need to define the global variable _OPCOM? Does it need input from somewhere or from me?

    Is "addObjective" a placeholder that I need to edit?

    Is "custom_1" a suitable name for the _id global variable? I assumed it is what shows up on debug maps as "c_17", "c_xx" for placement objectives.

    ---
    Is there an explanation of syntax somewhere in the online ALiVE instructions? For that matter, it seems like there is no real manual for ARMA 3 sqf scripting, other than the usually-not-helpful BIS wiki for functions (which is like writing an essay using a foreign language dictionary with no grammar, when everyone else has been speaking and modifying the language for 12 years). I'm getting tired of making Frankenscripts that don't work. :P I tried using Zenophon's framework (great documentation), but would prefer to throw some ALiVE modules in and just play.

  15. Friznit

    11 Aug 2015 Administrator

    The custom objective module and the custom objective script are the same thing. Just stick to using the module. It doesn't need a composition, that's optional. Make sure its within the area covered by your mil placement module and that you have Create HQ turned on. The ai commander will pick it up as an objective and use it as a logistics hub of its the closest.

  16. What Friznit said is correct so I'll see if I can tie any loose ends together so you may not be as confused on certain things going forward

    The script that I was explaining above was actually a community written script (cjb_addObjectiveToSides) to add an objective mid mission. To use it you would have to define it first by placing it in your init.sqf or placing it in a file and then calling that file from the init.sqf. You could then input the parameters that the script would use to add an objective and it does the rest for you.

    Example: [["opforComRetake_obj", getMarkerPos "opforComRetake", 200,"MIL"],["EAST"]] call cjb_addObjectiveToSides;

    Params:
    [[_objID, _pos, _size,_type],[_sides]] call cjb_addObjectiveToSides;

    _objID: String , "name" of the objective
    _pos: Array, position the objective will be added
    _size: Number, the size of the objective
    _type: String, MIL or CIV >> the type of the objective
    _sides: Array, the sides that the objective will be made known to, each side must be wrapped in quotes

    Here's another example

    [["letsAddAn_obj", position player, 100,"CIV"],["EAST","WEST"]] call cjb_addObjectiveToSides;

    --

    Is there an explanation of syntax somewhere in the online ALiVE instructions? For that matter, it seems like there is no real manual for ARMA 3 sqf scripting, other than the usually-not-helpful BIS wiki for functions (which is like writing an essay using a foreign language dictionary with no grammar, when everyone else has been speaking and modifying the language for 12 years). I'm getting tired of making Frankenscripts that don't work. :P I tried using Zenophon's framework (great documentation), but would prefer to throw some ALiVE modules in and just play.

    Yeah scripting is hard to get into, especially when you have no real background on it. The way I learned was by scouring the wiki and just getting a big picture in terms of what commands I had available to me. Writing scripts is hands down the best way to learn imo. I had barely any clue what to do in terms of scripting until I sat down and made a simple (player controlled) suicide bomber system which introduced me and familiarized me with how variables can get passed from one script/function to another and even return a return variable. From there I kept going forward with slightly harder scripts, each one focusing mainly on a new command that I had learned that I thought was really cool, such as "Switch", "setVariable/getVariable","if/then/else".

    My preferred way of learning SQF is just by trying first hand to put scripts together and by taking a look at the scripts of others who have done similiar things. I am pretty good at reverse engineering so imo that's a pretty handy tool to use especially when the community has such talented scripters.

    Good luck!

  17. Thanks, guys. The custom mil placement clarification really helps, Friznit -- I was getting a little frustrated with the constant messages saying that OPCOM couldn't find any military objectives in its area. So if I understand the order of operations correctly, OPCOM will send reinforcements to the custom placement, but b/c it's not detected early enough, the initial overall mil placement force (e.g. a battalion (400)) will not get placed at all if the custom objective mil placement is the only military objective in the specified TAOR. I'd have to rely on the custom objective's initial unit placement list, compensate with a larger number of reinforcement logistics points, or some combination.

    SpyderBlack, I did indeed see the cjb_addObjectivesToSides function, and was doing my beginner's version of selective reverse engineering by leaving out the stuff I didn't feel like tackling on this attempt. :D

    But yeah, Zenophon's framework was a huge help last week in helping me to follow how variables are created and defined. It helped me to better understand the scripts in your demo missions.

    Thanks for everything on this go around!

  18. Yep that's correct, mil/civ placements won't place units at Custom Objective modules so you'll have to use it's built-in unit spawning options. It will receive reinforcements though as you also stated.

 

or Sign Up to reply!