Jump to content
Zenophon

Zenophon's ArmA 3 Co-op Mission Making Framework

Recommended Posts

Trying to re spawn units with the same gear how would I go about that? 

 

Or re spawn players with the same gear. 

 

Do a search on Armaholic for the set and get script. It's what I use and works well for the most part!

Share this post


Link to post
Share on other sites

Do a search on Armaholic for the set and get script. It's what I use and works well for the most part!

It dosenet seem to be supported anymore and the ACE setAllGear is a little over my skill level, I need working examples if anyones got one

Share this post


Link to post
Share on other sites

It dosenet seem to be supported anymore and the ACE setAllGear is a little over my skill level, I need working examples if anyones got one

 

I'm not sure about the support but it still works so they may not have modified it for a long time! You might get better results too if you make your own post in the forums as this one is for Zenophon's awesome framework!

Share this post


Link to post
Share on other sites

Trying to re spawn units with the same gear how would I go about that?

Or re spawn players with the same gear.

For AI you can spawn them again with Zen_SpawnInfantry and use ZEN_FMW_Code_GiveLoadoutsOrdered with either the preset loadouts from Zen_GiveLoadoutBlufor et al. or a custom loadout. The custom loadouts have a demonstration detailing how to format them and use Zen_GetUnitLoadout.

As for players I would use Zen_GetUnitLoadout and apply it with a MPRespawn eventhandler. You can refer to the Respawn Patrol sample mission or several of the tutorials for dealing with respawning players. I don't think there's an example specifically for reapplying the same gear, but getting the loadout with a killed/dammaged EH should work.

As biggdogg said, if you post here I'm of course to going to suggest framework functions and help you use them. If you're looking for an all-in-one respawn system that's easy to use, you can probably find something searching around or making a request thread that outlines your specific needs.

Share this post


Link to post
Share on other sites

Hi, I've been in this loop attempting to figure out how to best delete the units i've appended to an array using Zen_ArrayAppend. Over the course of the mission several groups are spawned, some are killed by the players and some will no doubt survive. towards the end of the mission my hope is to delete the entire array of units.

 

so for example I use this to spawn the units;

for "_i" from 0 to 7 do {
	_newPatrolUnitArray = [_markerJungleArray,AI_SKILL,_patrolUnitArray] call f_spawnsquad;
};

// i have a function that does the spawning

{
	private ["_pmarkerarray","_aiSkill","_pPatrolUnitArray","_startarea","_pos","_group"];
	
	_pmarkerarray = _this select 0;
	_aiSkill = _this select 1;
	_pPatrolUnitArray = _this select 2;
	
	_startArea = [_pmarkerarray] call Zen_ArrayGetRandom;
	_pos = [_startArea] call Zen_FindGroundPosition;
	_group = [_pos, ["LOP_AFR_Infantry_SL", "LOP_AFR_Infantry_GL", "LOP_AFR_Infantry_AT"]] call Zen_SpawnGroup; 
	0 = [_group, _aiSkill] call Zen_SetAISkill;
	0 = [_pPatrolUnitArray, _group] call Zen_ArrayAppend;
	_pPatrolUnitArray
};

that is all fine and dandy, and throughout the mission I have an array full of unit groups. So;

 

_newPatrolUnitArray = [alpha-1-1, alpha-1-2, alpha-1-3... etc...

 

I could delete them manually, provided I know their group ID. But Zen_ArrayAppend gives each group a unique ID as it append them to the array, starting from alpha-x-x and onwards. I've also tried unpacking each group into the existing array using the array insert slice function, and then attempting to deleting them. I've tried different flavours of deleteVehicle, but thats looking for objects, so throws an error.

 

Is there a zen function that will count how many indexes exist in the array so that i can then delete each item based on their index? Or maybe there is a simpler way for deleting units from merged arrays... any suggestions would be great!

 

thx

Share this post


Link to post
Share on other sites

Hi, I've been in this loop attempting to figure out how to best delete the units i've appended to an array using Zen_ArrayAppend. Over the course of the mission several groups are spawned, some are killed by the players and some will no doubt survive. towards the end of the mission my hope is to delete the entire array of units.

 

so for example I use this to spawn the units;

for "_i" from 0 to 7 do {
	_newPatrolUnitArray = [_markerJungleArray,AI_SKILL,_patrolUnitArray] call f_spawnsquad;
};

// i have a function that does the spawning

{
	private ["_pmarkerarray","_aiSkill","_pPatrolUnitArray","_startarea","_pos","_group"];
	
	_pmarkerarray = _this select 0;
	_aiSkill = _this select 1;
	_pPatrolUnitArray = _this select 2;
	
	_startArea = [_pmarkerarray] call Zen_ArrayGetRandom;
	_pos = [_startArea] call Zen_FindGroundPosition;
	_group = [_pos, ["LOP_AFR_Infantry_SL", "LOP_AFR_Infantry_GL", "LOP_AFR_Infantry_AT"]] call Zen_SpawnGroup; 
	0 = [_group, _aiSkill] call Zen_SetAISkill;
	0 = [_pPatrolUnitArray, _group] call Zen_ArrayAppend;
	_pPatrolUnitArray
};

that is all fine and dandy, and throughout the mission I have an array full of unit groups. So;

 

_newPatrolUnitArray = [alpha-1-1, alpha-1-2, alpha-1-3... etc...

 

I could delete them manually, provided I know their group ID. But Zen_ArrayAppend gives each group a unique ID as it append them to the array, starting from alpha-x-x and onwards. I've also tried unpacking each group into the existing array using the array insert slice function, and then attempting to deleting them. I've tried different flavours of deleteVehicle, but thats looking for objects, so throws an error.

 

Is there a zen function that will count how many indexes exist in the array so that i can then delete each item based on their index? Or maybe there is a simpler way for deleting units from merged arrays... any suggestions would be great!

 

thx

 

I personally do this a couple different ways depending on what I want. Keep in mind I'm by no means an expert coder and there's very likely better ways to do things!

 

If I want all the enemy deleted after a mission is completed then I use this bit of code:

{
	if (((side _x) == east) || ((side _x) == resistance)) then {
	deleteVehicle _x;
	};
} forEach allUnits;

What that does is test every unit in the game and if they are from the east or Independent sides then it deletes them including units in vehicles. (you have to delete the vehicles separately)

 

If I want to delete the units just within a certain array then I use:

_InfArray = [_InfArray] call Zen_ConvertToObjectArray;
{deleteVehicle _x;} forEach _InfArray;

This converts the group array to an object array then deletes each index.

 

I usually try to put the vehicles into an array when I spawn them so I can use the same technique to clean those up as well! (no need to convert it to an object array of course)

  • Like 1

Share this post


Link to post
Share on other sites

If I want to delete the units just within a certain array then I use:

_InfArray = [_InfArray] call Zen_ConvertToObjectArray;
{deleteVehicle _x;} forEach _InfArray;

This converts the group array to an object array then deletes each index.

 

I usually try to put the vehicles into an array when I spawn them so I can use the same technique to clean those up as well! (no need to convert it to an object array of course)

 

hi, thanks, that's really helpful. this worked for me. I tried Zen_ConvertToObjectArray but I was obviously doing it incorrectly, as in the end I was applying {deleteVehicle _x;} forEach units, rather than what you have. brilliant!

Share this post


Link to post
Share on other sites

Hi guys,

 

im really enjoying using this framework, so thanks to Zenophon for all the hard work!

 

Im having an issue using Zen_SpawnInfantry with units from the RHS mod. Issue being that I cant get it to spawn any units and in my rpt it simply states "No soldiers found for the given side, type, faction, and blacklist". If I use this code, no problem. Easy stuff, CSAT units as expected:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men'] call Zen_SpawnInfantry;

But if I try to introduce some Russian units from the RHS mod using the following, no dice:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men', 'rhs_faction_vdv'] call Zen_SpawnInfantry;

I've tried various combinations and alternatives based on what I've seen in the config viewer, using vehicleClass, faction etc etc. I've also seen code examples on this very thread for spawning RHS units. But I must be missing a prerequisite piece of code as I just cant get it to spawn any RHS units. Should I perhaps be using Zen_ConfigGetVehicleClasses to get a list of units before Zen_SpawnInfantry can use them?

 

Any pointers gratefully received.

Share this post


Link to post
Share on other sites

Hi guys,

 

im really enjoying using this framework, so thanks to Zenophon for all the hard work!

 

Im having an issue using Zen_SpawnInfantry with units from the RHS mod. Issue being that I cant get it to spawn any units and in my rpt it simply states "No soldiers found for the given side, type, faction, and blacklist". If I use this code, no problem. Easy stuff, CSAT units as expected:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men'] call Zen_SpawnInfantry;

But if I try to introduce some Russian units from the RHS mod using the following, no dice:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men', 'rhs_faction_vdv'] call Zen_SpawnInfantry;

I've tried various combinations and alternatives based on what I've seen in the config viewer, using vehicleClass, faction etc etc. I've also seen code examples on this very thread for spawning RHS units. But I must be missing a prerequisite piece of code as I just cant get it to spawn any RHS units. Should I perhaps be using Zen_ConfigGetVehicleClasses to get a list of units before Zen_SpawnInfantry can use them?

 

Any pointers gratefully received.

 

Zen_SpawnInfantry

Spawns (4) units of side (2) as a group with skill (3) at (1).  (5,6) are based upon

config file organization and are subject to change by BIS.

Usage : Call

Params: 1. Array, group, object, string, the spawn point

        2. Side, of the units to spawn

        3. Skill, see Zen_SetAISkill documentation (2) (Object Functions)

    AND

        4. Scalar, how many units to spawn

    OR

        4. Array:

            1. Scalar, the minimum number of units to spawn

            2. Scalar, the maximum number of units to spawn

    AND

 (opt.) 5. String, the type of soldiers to spawn, (default: 'Men'), 'MenDiver' 'MenRecon' 'MenSniper'

 (opt.) 6. String, the faction of soldiers to spawn, (default: 'All'), 'BLU_F', 'IND_F', 'OPF_F', 'BLU_G_F'

 (opt.) 7. Array of strings, classnames to blacklist from spawning, (default: [])

 (opt.) 8. Array or string, DLC type(s), 'All' for all DLC, (default: '')

Return: Group

 

One thing I can tell you is for modded units you'll have to dig into the cfgviewer and check out the entries for the type of unit!  (opt.) 5. String, the type of soldiers to spawn,

I use Massi's altis rebel units and the type I had to use wasn't 'men'! My spawn line ended up looking like this:

_cqbGroup = [_cqbBuildingPosSelect, east, 1, 1, "mas_gue_rebl_o", "mas_gue_opf", ["O_mas_gue_Rebel_CREW_F","O_mas_gue_Rebel_UNA_F","O_mas_gue_Rebel_amort_F", "O_mas_gue_Rebel_smort_F", "O_mas_gue_Rebel_AA_F"]] call Zen_SpawnInfantry;

So the type of unit ended up being called "mas_gue_rebl_o" and the faction was "mas_gue_opf". The type I had to dig out of the cfgviewer.

 

Hope this helps!

Share this post


Link to post
Share on other sites

 

Hope this helps!

 

Thanks for the reply biggdogg. Your example has given me something else to try. I'll report back when I suss it out.

Share this post


Link to post
Share on other sites

Hi guys,

im really enjoying using this framework, so thanks to Zenophon for all the hard work!

Im having an issue using Zen_SpawnInfantry with units from the RHS mod. Issue being that I cant get it to spawn any units and in my rpt it simply states "No soldiers found for the given side, type, faction, and blacklist". If I use this code, no problem. Easy stuff, CSAT units as expected:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men'] call Zen_SpawnInfantry;
But if I try to introduce some Russian units from the RHS mod using the following, no dice:

_patrolGroup = [_startPos, east, "infantry", [2,6], 'Men', 'rhs_faction_vdv'] call Zen_SpawnInfantry;
I've tried various combinations and alternatives based on what I've seen in the config viewer, using vehicleClass, faction etc etc. I've also seen code examples on this very thread for spawning RHS units. But I must be missing a prerequisite piece of code as I just cant get it to spawn any RHS units. Should I perhaps be using Zen_ConfigGetVehicleClasses to get a list of units before Zen_SpawnInfantry can use them?

Any pointers gratefully received.

As biggdogg says, the fifth parameter must also match the classes you want. Here's an example specifically for RHS:

_group = [_pos, west, "SOF", 4, "rhs_vehclass_infantry_ocp", "rhs_faction_usarmy_d"] call Zen_SpawnInfantry;
  • Like 1

Share this post


Link to post
Share on other sites

Hey Zenophon! Been a while, your framework has been very solid. I ran across something just now which is with your object function Zen_AreNotInArea not handling null groups and breaking the mission. Specifically I have a waitUntil looking for units to not be in an area and if they're killed it works fine but if they are deleted with a script it throws the null-group error and won't recognize they are no longer in the area. And the waitUntil never comes back true.

 

I also have a feature request. Something I looked into but was never competent enough to accomplish. Is it possible (with the new remoteExec commands maybe) for you to create a vehicle repair, rearm and refuel function that can attach to an object, position or marker that can service the vehicle for all human players within the vehicle? Other service scripts work ok but if I'm a pilot and buddy is the gunner, he has to disembark until I have finished the service then he can jump back in. Otherwise his ammo is never restocked!

 

Thanks as always for your hard work creating this framework!

Share this post


Link to post
Share on other sites

Zen_ConvertToObjectArray (which Zen_AreNotInArea uses) should filter out the null objects/groups. Failing that, you could always run Zen_ArrayRemoveDead before. For something like your specific case, this code:

_group = [player, west, 1, 1] call Zen_SpawnInfantry;
_array = [_group, group player];

deleteVehicle leader _group;
deleteGroup _group;

player sideChat str ([_array] call Zen_ConvertToObjectArray);
player sideChat str ([_array, "mkTest"] call Zen_AreNotInArea);
player sideChat str ([_array] call Zen_ArrayRemoveDead);

should be: player, true/false (depending on where you place mkTest), group player. Post how the groups are being deleted and the error that prints out.

It's interesting that the gunner doesn't receive ammo but the driver does. I would have said that the vehicle is local to the driver and therefore any argument-local, effect-global command (e.g. setVehicleAmmo) run on the driver's machine will affect the gunner. I'd have to look at the specific implementation; it may be that the vehicle was local to the gunner before the driver, so a script running local to the driver didn't work until the gunner got out.

Here's the code from one of my mini missions (Pursuit), with an option #2 added for including the gunner (and any other crew members) in the rearming. Try the code with options #1 or #2 and see if there's a difference. Both options dynamically find the owner of the vehicle.

F_HeliRearm = {
    _this setFuel 1;
    _this setVehicleAmmo 1;
};

// ...some mission specific code to get _playersHeli... //

_playerHeli = ["mkHeliRearm", "B_Heli_Attack_01_F", 0, random 360] call Zen_SpawnVehicle;
0 = [_playersHeli, _playerHeli, "All"] call Zen_MoveInVehicle;

0 = _playerHeli spawn {
    while {true} do {
        waitUntil {
            sleep 5;
            ((isTouchingGround _this) && {[_this, "mkHeliRearm"] call Zen_AreInArea})
        };

        {
            _args = ["hintSilent", ["Rearming and refuelling in 30 seconds."]];
            ZEN_FMW_MP_REClient("Zen_ExecuteCommand", _args, call, _x)
        } forEach (crew _this);

        sleep 30;

        // #1
        ZEN_FMW_MP_REClient("F_HeliRearm", _this, call, _this)

        // #2
        // {
            // ZEN_FMW_MP_REClient("F_HeliRearm", _this, call, _x)
        // } forEach (crew _this);
    };
};

Share this post


Link to post
Share on other sites

Zen,

 

I'm having trouble deciphering how to use your preprocessor library.  It's a little nebulous in the reference file exactly what to use to properly invoke it. Specifically, I'd like to use:  ZEN_FMW_Code_InsertionPatrol.

 

Assuming my arguments are: _dudesToPatrol, _vehClassname, _startPoint, _patrolMarker.  Is the following the correct usage?

 

 

0 = [_dudesToPatrol, _vehClassname, _startPoint, _patrolMarker] ZEN_FMW_Code_InsertionPatrol;

 

or is it still called?

 

0 = [_dudesToPatrol, _vehClassname, _startPoint, _patrolMarker] call ZEN_FMW_Code_InsertionPatrol;

 

 

Not sure if your preprocess stuff has been talked about already but I'm posting it here in case some else has this same question.

Share this post


Link to post
Share on other sites

Update and Release #42

Introduction

Greetings fellow scripters and Armaholics, in this latest installment, I will continue to discuss the development of the framework and, of course, shamelessly advertise the framework in any way possible.

If this sounds boring, you can download the latest version from the original post. As always, the links to Google Drive for the .7z and .zip versions are already up to date. For those looking for older versions, go to file>revisions. The new version will be on Armaholic soon. Please bring any technical issues or mistakes to my attention, so e.g. people don't download the wrong version etc.

Changelog

This release features numerous changes and fixes. The foremost is the framework's response to the new Eden 3D editor in the form of Zen_CreateTemplate and Zen_SpawnTemplate. Zen_CreateTemplate will scan for editor-placed objects within a radius or an area marker and compile them into a format that Zen_SpawnTemplate can use. This will help combine the ease new ease of use for placing objects in the 3D editor with the framework's dynamic spawning and randomization.

The remainder of the changelog is not nearly as exciting. A few technical errors about variables, stack traces, and debug were fixed. Zen_GiveLoadoutCargo now places backpacks in vehicles properly. Another change of the Eden editor is that Opfor and Indfor sides can place FIA units, so Zen_SpawnInfantry now filters them out. You can get them back the usual means. The framework has also adopted the new nearestTerrainObjects command; it seems to be an improvement for everything except roads.

3/20/16

  • New Function: Zen_CreateTemplate
  • New Function: Zen_SpawnTemplate
  • Fixed: Zen_AddSupportActionCustom let the player use the fire support menu from other units
  • Fixed: Zen_ArrayFindExtremum did not remove itself from the stack trace when given an empty or single element array
  • Fixed: Zen_FindCenterPosition overwrote its argument array
  • Fixed: Zen_FindCenterPosition printed some debug text
  • Fixed: ZEN_FMW_Code_InsertionPatrol did not handle land vehicles properly
  • Fixed: Zen_GetFreeSeats did not declare the identifier '_group' private, thus overriding its value
  • Fixed: Zen_GiveLoadoutCargo did not give backpacks
  • Fixed: Zen_SpawnInfantry spawned FIA units on East and Resistance sides by default
  • Improved: Zen_AreInVehicle and Zen_AreNotInVehicle now check their second argument
  • Improved: Zen_GetUnitLoadout now uses the type and count syntax for items
  • Improved: Zen_FindGroundPosition, Zen_GetAmbientClutterCount, Zen_IsForestArea, Zen_IsUrbanArea, and Zen_OrderInfantryPatrolBuilding now use nearestTerrainObjects
  • Documentation: Added for Zen_CreateTemplate, Zen_SpawnTemplate
  • Documentation: Improved Preprocessor Library documentation
  • Documentation: Updated JIP demonstration
  • Documentation: Updated Notepad++ SQF language and autocompletion file with ArmA 1.56 stable commands

Code Example

In this section, I will present a function or piece of code that shows something not present in the existing documentation. These examples are adapted to be general, accessible, and customizable. They are meant to be useful to mission makers who want to include the code as part of their mission, as well as those who want to learn general coding techniques and specific framework implementations. These are not contrived or coded with any specific skill level in mind; they are taken from full missions I have finished or am working on with minimal changes. Of course, if you have any questions about an example, suggestions for an example, your own example to present, or if find any bugs, please let me know.

This release's example is for endlessly delivering reinforcements to a patrol area. Each time the number of units on the east side falls below the number set (currently 30), a helicopter will ferry more troops (currently 60) from the first given point to the area marker given as the second argument. You can change many things about this code, from the side and number of units, to the time between reinforcements and the minimum number of units. Like most of these, this is just a starting template you can adapt to your teams.

If you are using this code in a larger mission, you may be concerned about spawning Zen_OrderInfantryPatrol for every squad. If you want an example of how to combine dynamically spawned squads into a single patrol thread, just post or PM me.

F_ReinforcementWaves = {
    private ["_mkHeliStart", "_mkPatrolArea", "_minUnitsToReinforce", "_reinforcementTimeConst", "_reinforcementTimeRand", "_heli", "_group", "_insertionPos", "_h_Squad"];

    _mkHeliStart = _this select 0;
    _mkPatrolArea = _this select 1;

    _minUnitsToReinforce = 30;
    _reinforcementTimeConst = 60*5;
    _reinforcementTimeRand = 60*1;
    _side = east;

    _heli = [_mkHeliStart, "O_Heli_Light_02_unarmed_F", 0] call Zen_SpawnHelicopter;

    while {true} do {
        waitUntil {
            sleep 5;
            ({((alive _x) && ((side _x) == _side))} count allUnits < _minUnitsToReinforce)
        };

        _group = [_mkHeliStart, _side, "infantry", 6] call Zen_SpawnInfantry;
        0 = [_group, ZEN_FMW_Loadout_StdInfantryPreset] call Zen_GiveLoadoutOpfor;
        0 = [_group, _heli] call Zen_MoveInVehicle;

        0 = [_group, _mkPatrolArea] spawn {
            waitUntil {
                sleep 5;
                (({alive _x} count units (_this select 0) == 0) || {({!isTouchingGround _x} count units (_this select 0) == 0)})
            };

            0 = _this spawn Zen_OrderInfantryPatrol;
        };

        _insertionPos = [_mkPatrolArea] call Zen_FindGroundPosition;
        _h_Squad = [_heli, [_insertionPos, _mkHeliStart], _group, "normal", 30, "fastrope"] spawn Zen_OrderInsertion;

        waitUntil {
            sleep 5;
            ((scriptDone _h_Squad) || {!(alive _heli)})
        };

        if !(alive _heli) exitWith {
            terminate _h_Squad;
        };
        sleep (_reinforcementTimeConst + random _reinforcementTimeRand);
    };
};

// Here's an example call
0 = ["mkHelipad", "mkPatrolArea"] call F_ReinforcementWaves;

Feedback

 

Zen,

I'm having trouble deciphering how to use your preprocessor library. It's a little nebulous in the reference file exactly what to use to properly invoke it. Specifically, I'd like to use: ZEN_FMW_Code_InsertionPatrol.

Assuming my arguments are: _dudesToPatrol, _vehClassname, _startPoint, _patrolMarker. Is the following the correct usage?

0 = [_dudesToPatrol, _vehClassname, _startPoint, _patrolMarker] ZEN_FMW_Code_InsertionPatrol;

or is it still called?

0 = [_dudesToPatrol, _vehClassname, _startPoint, _patrolMarker] call ZEN_FMW_Code_InsertionPatrol;

Not sure if your preprocess stuff has been talked about already but I'm posting it here in case some else has this same question.

In writing all that documentation I forgot to provide a simple example of how to call them. The syntax is:

 

ZEN_FMW_Code_InsertionPatrol(_dudesToPatrol, _vehClassname, _startPoint, _patrolMarker)
with '()' surrounding the arguments instead of '[]'; the ';' is omitted at the end because the macro returns void (it won't hurt to include it though). Another example the documentation doesn't provide is what it means by 'variable array'; it means that an array literal cannot be declared within the arguments.

// this won't work
ZEN_FMW_Array_RemoveIndexes(_array, [1, 2, 3, 4])

// but this will
_indexes = [1, 2, 3, 4];
ZEN_FMW_Array_RemoveIndexes(_array, _indexes)

// non-array literals are fine
ZEN_FMW_Code_InsertionPatrol(_dudesToPatrol, "b_mrap_01_f", "mkStart", "mkPatrolArea")

Share this post


Link to post
Share on other sites

Kudos on the awesome utility for mission making! I followed the tutorials but I have a couple things I need done that I can not figure out as a novice.

1. _boxClass = [(["ammo", _side] call Zen_ConfigGetVehicleClasses)] call Zen_ArrayGetRandom;  .... what does "ammo" refer to? I can not find where this is defined. I need to create my own custom array of addon ammo boxes. Can you help me out? I only have like 2 or 3 I want on the list. 

2. How would I go about spawning said ammo box inside of a building? I know Zen_FindBuildingPositions but does it work for objects as well? I keep getting coordinate errors saying I'm not giving valid x,y or x,y,z coords.... I am doing this using randomly generated grid markers based on random selection of towns and cities. I can get the ammo boxes to spawn by themselves, in completely random locations, I just need to get them inside of buildings. Am I going to have to use Zen_FindPositionPoly when placing boxes inside of buildings? Figured this out, but I have issues. See a couple posts below.

3. I would like to spawn 5 random boxes inside of buildings at one time, but I only want 1 to be the objective at any time. Once all 5 are destroyed I want the mission to end. I think I can figure this out on my own once I have everything working but any pointers would be nice.

Thanks in advance

Share this post


Link to post
Share on other sites

for (2), if Zen_FindBuildingPositions returns valid locations, then it should just be a matter of selecting values from that array. Maybe even shuffle the array before selecting. Check the Zen_DataFunctions document for interrogating arrays.

Share this post


Link to post
Share on other sites

for (2), if Zen_FindBuildingPositions returns valid locations, then it should just be a matter of selecting values from that array. Maybe even shuffle the array before selecting. Check the Zen_DataFunctions document for interrogating arrays.

I tried using ArrayGetRandom to no avail. The main issue is, I looked through all of the tutorials and all of the sample missions and can not find an example where _FindBuildingPositions is even used. Am I not looking hard enough? I found one example but it used SpawnInfantryGarrison and that's not what I need.

Share this post


Link to post
Share on other sites

 

// Call functon to get random city/village area marker

_randomCity = call f_getrandomcityAreaMarker;
 
// Generate a random position within the city
_ObjectivePos = [_randomCity] call Zen_FindBuildingPositions;
 
//Shuffle building poss array
_ShufflePos = [_ObjectivePos] call Zen_ArrayShuffle;
 
//Choose one pos in building array
_RandomPos = [_ShufflePos] call Zen_ArrayGetRandom;
 
// Create a cache objective at generated position
_YourObjective = [_CachePos, _players, east, "Box", "eliminate"] call Zen_CreateObjective;

Okay so I got the cache position to correctly establish itself inside of a random building. The problem is, half of the time the cache spawns just outside of the building. Sometimes, it spawns directly outside of a non enterable building. Once in a while, it spawns partially inside of a wall and blows up. I'm going to mess around and see what I can do but I would appreciate if somebody could help me out. One concern I have is when I figure out how to make a different typee of ammo box spawn (a much larger cache), the cache due to it's size will spawn inside of walls more often and blow up.

Share this post


Link to post
Share on other sites

I haven't done ammo boxes before, but what i generally do, if i want to avoid repetition, is have a specific array of objects from which I randomly select one. So if you want 5 different ones, you could have it within a for "_i" from 0 to 4 do loop

_randomElement = ["rhs_ural_chdkz","LOP_AFR_M113_W","LOP_AFR_BTR60"] call BIS_fnc_selectRandom;
	
_reconVehicle = _randomElement createVehicle _pSpawn; //where _pSpawn is a randomly selected location

I guess you could also do the same for your ammo boxes. But you would have to find their class names. I'm not sure about how best place them inside without them clipping or blowing up.

 

Then for setting your objective maybe try Zen_InvokeTask.

Share this post


Link to post
Share on other sites

Kudos on the awesome utility for mission making! I followed the tutorials but I have a couple things I need done that I can not figure out as a novice.

1. _boxClass = [(["ammo", _side] call Zen_ConfigGetVehicleClasses)] call Zen_ArrayGetRandom; .... what does "ammo" refer to? I can not find where this is defined. I need to create my own custom array of addon ammo boxes. Can you help me out? I only have like 2 or 3 I want on the list.

2. How would I go about spawning said ammo box inside of a building? I know Zen_FindBuildingPositions but does it work for objects as well? I keep getting coordinate errors saying I'm not giving valid x,y or x,y,z coords.... I am doing this using randomly generated grid markers based on random selection of towns and cities. I can get the ammo boxes to spawn by themselves, in completely random locations, I just need to get them inside of buildings. Am I going to have to use Zen_FindPositionPoly when placing boxes inside of buildings? Figured this out, but I have issues. See a couple posts below.

3. I would like to spawn 5 random boxes inside of buildings at one time, but I only want 1 to be the objective at any time. Once all 5 are destroyed I want the mission to end. I think I can figure this out on my own once I have everything working but any pointers would be nice.

Thanks in advance

1. The first argument of Zen_ConfigGetVehicleClasses is the 'vehicleClass' property of a class. So Box_East_Wps_F has vehicleClass = "Ammo", Boat_Civil_01_base_F has vehicleClass = "Ship", etc... This and more about Zen_ConfigGetVehicleClasses is discussed in the Random Battle demonstration.

2. For a quick debug, you can try this:

 

_positions = [player] call Zen_FindBuildingPositions;
_spawnPos = [_positions] call Zen_ArrayGetRandom;
_box = [[0,0,0], "Box_East_Support_F"] call Zen_SpawnVehicle;
_box setPosATL _spawnPos;
player setPosATL _spawnPos;
If you try that on various buildings you'll see it's not 100% successful. It will give a few positions in/outside the walls or where the box is damaged. There's a limit to what can be achieved by assuming that walls have no thickness, that there are no empty, non-enterable spaces in the 3D model, that a window and a missing wall are the same thing, etc. If you are dealing with completely non-enterable buildings, Zen_FindBuildingPositions won't handle that. It should be able to handle partially enterable buildings, such as the hospital in Kavala on Altis. I'll tweak Zen_FindBuildingPositions with a few more ray casts, but it will never be perfect.

3. If all five are destroyed one at a time, then you never have to check on all of them at once. I would break it into parts like this:

// choose a town and put an area marker over it somehow
_townMarker = ...

// define how many boxes and what types
_boxCount = 5;
_boxClasses = ["ammo", east] call Zen_ConfigGetVehicleClasses;

// generate the boxes
_boxObjs = [];
for "_i" from 1 to _boxCount do {
    _pos = [_townMarker] call Zen_FindGroundPosition;
    _buildingPositions = [_pos] call Zen_FindBuildingPositions;

    _box = [[0,0,0], ([_boxClasses] call Zen_ArrayGetRandom)] call Zen_SpawnVehicle;
    _box setPosATL ([_buildingPositions] call Zen_ArrayGetRandom);
    _boxObjs pushBack _box;
};

// then give them as objectives one by one
{
    _task = [...] call Zen_InvokeTask;
    waitUntil {
        sleep 2;
        !(alive _x)
    };
    0 = [_task, ...] call Zen_UpdateTask;
} forEach _boxObjs;

// mission complete
  • Like 1

Share this post


Link to post
Share on other sites

1. Okay I understand vehicle classes, and now I understand that ammo was the class for boxes. But my main issue still remains. How do I make it so it calls FIA boxes? I found this line in ConfigGetVehicleClasses:

if (["ammo", _classType] call Zen_ValueIsInArray) then {
    _returnClasses = [_returnClasses, ["box_ind_ammoveh_f", "box_east_ammoveh_f", "box_nato_ammoveh_f"]] call Zen_ArrayFilterValues;
};

I don't want a randomly selected box out of a large side dependent array, I want to choose 1 or maybe 2 or 3 boxes of my own and I want them to be the only ones spawning. They are FIA boxes. 

2. The main issue is that I am doing this on Fallujah. Somebody on Steam released a version of Fallujah that works on Arma 3 on Feb 27th this year. Most of the buildings are not enterable or partially enterable. I have noticed that most of the time FindBuildingPositions works with partially enterable buildings. Is there ANY way to exclude certain buildings from the list? A blacklist of sort? I have also noticed that only ground positions are being chosen, no first floor or roof positions. I feel like I'm doing something wrong.

3. I will try it out ASAP.

 

Share this post


Link to post
Share on other sites

Okay so I got the cache position to correctly establish itself inside of a random building. The problem is, half of the time the cache spawns just outside of the building. Sometimes, it spawns directly outside of a non enterable building. Once in a while, it spawns partially inside of a wall and blows up. I'm going to mess around and see what I can do but I would appreciate if somebody could help me out. One concern I have is when I figure out how to make a different typee of ammo box spawn (a much larger cache), the cache due to it's size will spawn inside of walls more often and blow up.

 

The random version of the Assassination Mission tutorial places an ammo box in a random building. It uses Zen_SpawnAmmoBox but that's probably not more reliable than Zen_SpawnVehicle.

 

When I wrote the tutorial I also struggled with these issues; ammo boxes are just sensitive to clipping. A call to setposATL will sometimes force the box back into a house.

 

Mimir

  • 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

×