Jump to content
Larrow

Eden Composition Spawning

Recommended Posts

Hy Larrow,

 

i hope you are doing well. 

I notice a problem since the last ARMA Updates. The Compositions we spawn are not working correct anymore.

All Vehicles will flip 45 Degress and the positions are not correct also. And some objects or triggers will not spawn.

Objects like buildings and other objects seems to spawn ok. At the moment we found just vehicles and triggers.

 

We use the following code to spawn

comphammer = ["Hammerschlag"] call LARs_fnc_spawnComp;

 

This spawn works 2 month ago without any problems.

 

Include in Composition

  • Units
  • Vehicles
  • Waypoints (move)
  • Trigger

Do you have any ideas how we can solve this?

 

ArmA_3_Screenshot_2020.05.11_-_10.39.12.

 

Kind regards

Baker

Share this post


Link to post
Share on other sites

Thanks @pierremgi

 

this code

this setVelocityModelSpace [0,0,0];

 

did it. With that code in init from each vehicle spawn will work fine again.

Many thanks.

Share this post


Link to post
Share on other sites
On 5/10/2020 at 6:52 PM, Cobra Commander said:

Is there anyway to get this script to act before players load in? Not sure how to describe what I am asking. Essentially the composition I am using has our playable slots and I am hoping there is a way to init the script before players hit the lobby screen so they can slot.

Thanks


Yes you can spawn the comp in on server start but you wont get the results you want. Arma requires playable units to be defined in the mission file. Below are links to how to spawn your comp in on load. You can write your own script to identify the units from the comp that you want to replace with the mission created playable units. Copy the comp units loadouts and positions and then apply that to the playable units from the mission file. Players shouldn't know the difference.

This lists the files that allow you call scripts at specific times in the order of initialization.

https://community.bistudio.com/wiki/Initialization_Order
 

This is for registering functions and when they should be called. Search the page for "postInit".
https://community.bistudio.com/wiki/Arma_3_Functions_Library

 

 

Share this post


Link to post
Share on other sites

Sup Larrow! In first place, must say that this works like a charm.

 

I've noticed that if you have smoke or fire modules in the composition (from modules > effects on EDEN), they do not "start" upon composition placement. 

Found a workaround that want to share with you:

 

_compReference = [ .... ] call LARs_fnc_spawnComp;

{
	_x setvariable ["BIS_fnc_initModules_activate", true];
} forEach (nearestObjects [_compPosition, ["ModuleEffectsFire_F", "ModuleEffectsSmoke_F"], _compRadius, true]);

I hope it helps.
Thanks again for your work, man.


- edit -
Tested in SP and MP, and works.

Share this post


Link to post
Share on other sites
13 hours ago, kaleb c0d3 said:

I've noticed that if you have smoke or fire modules in the composition (from modules > effects on EDEN), they do not "start" upon composition placement. 

Found a workaround that want to share with you:

Strange, that should already be accounted for in fn_spawnLogic. Added note in my development branch to check out next time I do an update. Thanks for the heads up.

 

To save doing a nearestObjects around the composition area, which could possibly pick up other things not actually spawned via the composition, you can always use the utility function to get all spawned composition objects. Then check their type for the effect modules.

_compReference = [ .... ] call LARs_fnc_spawnComp;

{
	if ( toLowerANSI typeOf _x in [ "moduleeffectsfire_f", "moduleeffectssmoke_f" ] ) then {
		_x setVariable ["BIS_fnc_initModules_activate", true];
	};
} forEach ( _compReference call LARs_fnc_getCompObjects );

 

Share this post


Link to post
Share on other sites
On 10/8/2020 at 7:49 AM, Larrow said:

Strange, that should already be accounted for in fn_spawnLogic. Added note in my development branch to check out next time I do an update. Thanks for the heads up.

 

To save doing a nearestObjects around the composition area, which could possibly pick up other things not actually spawned via the composition, you can always use the utility function to get all spawned composition objects. Then check their type for the effect modules.


_compReference = [ .... ] call LARs_fnc_spawnComp;

{
	if ( toLowerANSI typeOf _x in [ "moduleeffectsfire_f", "moduleeffectssmoke_f" ] ) then {
		_x setVariable ["BIS_fnc_initModules_activate", true];
	};
} forEach ( _compReference call LARs_fnc_getCompObjects );

 

You're welcome.
Ok... maybe they do not start because my way of implementing it. I've made a dynamic mission objective module, wich do it's thing inside a function declared with postInit = 1 (where after some config data fetching, it calls LARs_fnc_spawnComp). As far as I understand, it should work ok, but Arma engine has it's own witchcraft. 
I will implement the getCompObjects call to make it right, but I'm not having that problem because I clean the area prior the placement (I've extended the composition definition config to add some parameters, for example the center offset and "clearArea=true").
An example:
 

class CfgCompositions {
	// ---- Base Compositions Classes [DO NOT EDIT THIS!] ---------------------
	class BaseComposition {
		enabled = true;               // Can this be used by DynamicOps module?
		compType = "none";            // Can be one of: none, roadblock, fob, ....
		aiAreaRadius = 50;            // Radius used to estimate the AI occupation zone.
		areaRadius = 20;              // Radius of the composition area. 
		centerOffset[] = {0, 0, 0};   // Center Offset for the composition
		hideExisting = false;         // Hide existing world objects inside composition area?
	};
    
    // ---- FOBs --------------------------------------------------------------
    class FOB_01 : BaseComposition {
		compType = "fob";
		areaRadius = 30; 
		hideExisting = true;
        #include "fob_01.sqe"
    };
};

 

Share this post


Link to post
Share on other sites

good evening everyone,

I wanted to spawn my compositions, on random locations: everything works perfectly ... except for the elevation.

 

the composition appears well at the place of the marker, in the right orientation, and correctly follow the curves of the terrain ... but it floats above the ground (more or less depending on the original Z of the sqe) ...

I tried the function on an object ... same thing: the z of the composition seems to add to that of the target

 

an idea ?

 

Thank you

 

example of sqe :

 

camp insurgé

base alpha_1

Share this post


Link to post
Share on other sites

Hey, Larrow.

 

I'm attempting to use this script, but I can't seem to spawn any compositions from triggers.

 

Any ideas?

 

Edit: Nvm. Figured it out. Thanks for the script!

Edited by duderide

Share this post


Link to post
Share on other sites

1. Great script, thanks Larrow for your hard work 

 

2. Anyway to diagnose what is specifically causing my "Bad vehicle type" error on compSpawn? Everything else is working fine. 

Share this post


Link to post
Share on other sites

I have a small composition that I'm trying to have spawn in front of the player on the first surface (Terrain or Building) but it just goes through the floor to the terrain. Any possible way to change that?

Share this post


Link to post
Share on other sites

Hey, Larrow. I wanted to thank you for making such a versatile system for spawning compositions. It has been super helpful.

 

I have run into an issue that has been stumping me for a while now though. It could just be user error, but it appears raised turret objects (class O_HMG_01_high_F) do not spawn in the same position as they were placed in the composition. I could be mistaken, but it almost looks like they spawn at their top-left corner instead of their center position. What tends to happen when I spawn them in a composition is the turret gets launched through the air (presumably because it clips into another object). Any ideas?

 

Here's a screenshot and the composition I am working with. I found testing it on Virtual Reality seems to regularly demonstrate the issue.

 

Here's a sample of the parameters I am using:

["CSAT_DEPOT_EXAMPLE", [1000, 1000, 0], 0, true] call LARs_fnc_spawnComp;

 

Thanks for all you've done to keep this project working!

 

Edit:

I have found a hacky fix to the issue. Temporarily disabling the turret's damage and physics simulation seems to work (and it spawns in the correct position, leading me to believe that might not actually be the issue). Then it's just a matter of re-enabling those object attributes and everything seems to be fine.

Edited by ClassyElm
Found a hacky solution to my problem

Share this post


Link to post
Share on other sites

@Larrow

Since the latest Arma Update 2.10 newly created compositions are not spawn correct any more. 
If you place vehicle you get an error message at spawn 
 

bis_fnc_removevirtualbackpackcargo;

#if (_isVirutal) then [

 

[_entity,(_input..."

Error if: Typ Array, erwartet Bool

File A3\3DEN\Functions\fn_initammobox.sqf..., line 43

 

If you not place vehicles it spawns the whole objects but all modules are not spawned correct anymore. Tasks, Smoke, and so on.

maybe this new tweaked function is a problem.
Tweaked: Expanded Virtual Arsenal itemSelected and itemDeselected Event Handlers so they also work with items and accessories

Share this post


Link to post
Share on other sites
On 8/25/2022 at 9:45 AM, RagcBaker said:

Since the latest Arma Update 2.10 newly created compositions are not spawn correct any more. 

This is due to BI's changes in how CustomAttributes are saved in the config( sqe sqm etc ).

I have updated the project and kept backwards compatibility with old compositions(sqe's).

See the original download in the first topic post.

  • Like 1

Share this post


Link to post
Share on other sites

AWESOME Larrow.
Many thanks for that quick solution you provide.

 

You made my day. Really. 

Share this post


Link to post
Share on other sites

Unfortunately, all AI spawn outside the composition. Sometimes it give "bad vehicle type" or something ... 
 

"New Mission Ready!" remoteExec ["hint", 0];
_rpos = _rsad call BIS_fnc_randomPosTrigger;
_compReference = ["camp2", _rpos, [0,0,0], 0, true, true, false] call LARs_fnc_spawnComp;
private _defpos = [_rpos, 0, 10, 1, 0, 0, 0] call BIS_fnc_findSafePos;
_group = [_defpos, independent,[     
"CUP_I_GUE_Soldier_GL", 
"CUP_I_GUE_Soldier_AT", 
"CUP_I_GUE_Soldier_MG", 
"CUP_I_GUE_Soldier_AT",
"CUP_I_GUE_Soldier_AT",
"CUP_I_GUE_Soldier_AA", 
"CUP_I_GUE_Soldier_AR"    
]] call BIS_fnc_spawnGroup;
_group setBehaviourStrong "AWARE";         
{_x setCombatMode "RED"} forEach units _group;    
_group setSpeedMode "FULL";    
_group setFormation "LINE";    
_group deleteGroupWhenEmpty true;     
 {    
 _x setSkill ["general",1];    
 _x setSkill ["courage",1];     
 _x setSkill ["aimingAccuracy", 0.20];     
 _x setSkill ["aimingShake", 0.50];     
 _x setSkill ["aimingSpeed", 0.50];     
 _x setSkill ["reloadSpeed", 0.50];     
} forEach (units _group);
[_group, _rpos] call BIS_fnc_taskDefend;

The guerilla camp composition is define as "camp2". This is how my composition.cfg looks like:
 

LARs_spawnComp_debug = 1
class CfgCompositions {
    class gerilla_camp { 
        #include "gerilla_camp.sqe" 
    };
	class generator {
		#include "generator.sqe"
	};
	class cache {
		#include "cache.sqe"
	};
	class fueldepot {
		#include "fueldepot.sqe"
	};
	class camp2 {
		#include "camp2.sqe"
	};
	class generator2 {
		#include "generator2.sqe"
	};
	class cache2 {
		#include "cache2.sqe"
	};
};

Apart from this, @Larrow made really useful script spawns perfectly aligned composition even on narrow terrain. But without garrison AI its use is limited because nearestBuilding command does not work with spawned buildings (it is mentioned on it's biki page I think).    

UPDATE: @Larrow how to spawn random from the predefined compositions? Tried 

_compPos = "obj_area" call BIS_fnc_randomPosTrigger;
_rComp = selectRandom ["lythium_cache","lythium_fuel","lythium_hq","lythium_medical",
"lythium_tower","lythium_uav","lythium_bunker"];
_compReference = [_rComp,_compPos,[0,0,0],0,true,false,false];

but no composition is spawning. 😥
UPDATE: I was saving the compositions in VR map and figured it should be on the mission map. I overwrite the compositions, gave them other names, still nothing spawns. They are properly defined in compositions.cfg ...  
 

Share this post


Link to post
Share on other sites

Trying to pass a variable through to the custom function that spawns comps. The function works in other tests just fine. However, I am trying to call it on initServer.
 

_ZoneComp = missionNamespace getVariable ["ALP_mainZone", ""];

diag_log format ["_ZoneComp value:%1", _ZoneComp];

_compReference = [_ZoneComp, [], [0,0,0], 0, true, true, false] call LARs_fnc_spawnComp;



And just to verify here is my compositions.cfg:
 

//LARs_spawnComp_debug = 1; //1 = RPT output, 2 = RPT output and ingame visual positioning info

class CfgCompositions {
    class ALP_Area_01 { //Name that the composition is spawned by
        #include "ALP_Area_01.sqe" //Renamed composition.sqe
    };
};

 

Upon mission start, I get the Error >>: Type Object, expected string. In the RPT, this pops out:

11:17:13 "_ZoneComp value:ALP_Area_01" 11:17:13 Error in expression < missionConfigFile >> "CfgCompositions" >> _compName;

Any ideas ?

Edit: Fixed

Quote

_ZoneComp = str(missionNamespace getVariable ["ALP_mainZone", ""]);
diag_log format ["_ZoneComp value: %1", _ZoneComp];
_compReference = [_ZoneComp, [], [0,0,0], 0, true, true, false] call LARs_fnc_spawnComp;



Thanks. Great Script!

 

Share this post


Link to post
Share on other sites

OP with issue ("fix" found below)

 

Hi @Larrow, I've been using your script for quite a bit with a scenario I'm working on but have now hit a wall:

 

When creating a composition with a unit that has customized loadout / inventory, spawning the composition triggers a "bad vehicle" error.

 

I've also found the post where you said you fixed a similar (or even the exact same) issue back in 2017, but it seems the fix has been broken now.

 

 

Update 2023-09-09 - Potential fix:

 

Sorry, please disregard the code below. It turns out that as soon as the _loadout array is shorter than usual, the bad vehicle type error will no longer occur. However, the loadout will also not be applied at all.

 

So I think I have found a "solution" (it's actually more of a workaround rn). Doing this will cause the script to set all slots correctly EXCEPT THE BINOCULARS. If that's irrelevant to you, here's what you can do:

 

1. Go to "LARs/spawnComp/functions/fn_getUnitInventory.sqf" and find this line:

private _nul = _loadout pushBack ( "binocular" call _fnc_getWeaponDetails );

2. Change it to this (comment it out):

//private _nul = _loadout pushBack ( "binocular" call _fnc_getWeaponDetails );

3. Save the changes and you're all set.

 

Just a heads-up, though: This isn't a perfect fix. As mentioned before, your units won't have their "Binoculars" slot set as in the collection, but if that's not a big deal for you, it should work. I haven't tested this change thoroughly, so I can't be certain if it might cause any other issues.

Share this post


Link to post
Share on other sites

hi everyone. this might not be the right place to ask but its related to spawning compos. i just can't, for the life of me, find a reliable way to get an actually flat and empty area to spawn some rather large compos (20x20 being the largest). i've tried shk_pos script, isFlatEmpty, findSafePos and combinations of them all. im pretty sure the way im scripting it is flawed but at this point i just have a very bad headache from trying to figure this out. so to save you time... got something wokring that your a willing to share?
im creating a marker randomly around the map (invade and annex style) and spawning my stuff in it's area. only 2 tasks, so far, are meant to spawn a compo. 1 is "working" cos the compo is rather small. the 20x20 is just way more complex with items inside a building (large hq type). im just overwelmed.. HELP?

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, tobias-ripper said:

hi everyone. this might not be the right place to ask but its related to spawning compos. i just can't, for the life of me, find a reliable way to get an actually flat and empty area to spawn some rather large compos (20x20 being the largest). i've tried shk_pos script, isFlatEmpty, findSafePos and combinations of them all. im pretty sure the way im scripting it is flawed but at this point i just have a very bad headache from trying to figure this out. so to save you time... got something wokring that your a willing to share?
im creating a marker randomly around the map (invade and annex style) and spawning my stuff in it's area. only 2 tasks, so far, are meant to spawn a compo. 1 is "working" cos the compo is rather small. the 20x20 is just way more complex with items inside a building (large hq type). im just overwelmed.. HELP?

 

Tbh that is something for it's own thread 'cause best practices for "finding places to put things" is like a whole thing...

I also find that "finding"-code is often heavily connected with other features so giving you something that "just works" is no small ask.

What works for my project might not work for yours.

 

I don't want to bog down this thread with unrelated detailed discussion (it's already long as it is) so here's just some ideas to apply to your design.
If you want more specific help create a new thread with your ideas, terrain and current code, or send 'em through a PM.
 

  • First off - There are many ways to skin this particular cat.
    An automated approach is cool and all but sometimes just manually doing it can get the job done, and better too. Maybe when a marker is selected you select from a list of preselected positions instead.
    Ask yourself: Does finding the flat space with code improve your player's experience or are you just being lazy? 😉
     
  • I mainly use the same tools you mentioned, I currently prefer BIS_fnc_findSafePos.
    Finding the right parameters for the search can be hard but don't get discouraged, play around with the settings and test a lot, especially in places where success is dubious.
    Remember: There's nothing wrong with searching multiple times with different parameters if the search fails. Start strict and loosen up.
     
  • Figure out which compositions are required to spawn and which (if any) can be ignored if no suitable position is found. Define your needs clearly.
     
  • Use a Solver / Spawner combo, the idea goes like this:
    • The mission logic runs the Solver to find the positions around a given spot (e.g. a marker). The Solver spawns nothing, only returns a solution: a bunch of valid positions to place stuff at.
    • The mission logic then checks the returned solution:
      • Solution is valid - Run the Spawner which does the actual spawning of your stuff.
      • Solution is invalid - Invalidate the selected spot (marker) and select a new one then repeat the process from the beginning.
         
  • If your composition is often colliding with terrain objects: ask yourself if you need those map objects or can they be safely hidden without detriment to the player experience? 
    hideObjectGlobal is your friend here. Players won't miss a tree or a rock but an important landmark might be noticed, take this into account in your solver.
     
  • Prefect is the enemy of good. This is especially true for this.

 

 

Share this post


Link to post
Share on other sites

Ignore this comment, I decided to make my own post about my issues/errors/questions for more in-depth q/a without spamming this post. If you're looking for my issues and answers about them here's the post link 

Spoiler

 

 

Edited by NFG WhatHiMean
Making my own post for more in-depth q/a

Share this post


Link to post
Share on other sites

Hey guys, hopefully this thread is not dead. I'm trying to spawn my compositions with the script, and it works almost perfectly. But on every single composition, some stuff won't stay in its position as it's placed (it's a battle bus with some plating etc., and the objects are attached via "attachToRelative" in the init).

Share this post


Link to post
Share on other sites
On 2/10/2023 at 10:59 PM, kibaBG said:


 

Apart from this, @Larrow made really useful script spawns perfectly aligned composition even on narrow terrain. But without garrison AI its use is limited because nearestBuilding command does not work with spawned buildings (it is mentioned on it's biki page I think).    


 

 

Hey, idk if it's too late for this, but, you can just set up the garrison manually, when you're "building" the composition and they get saved in the process and spawned in as you set them.

Share this post


Link to post
Share on other sites
On 10/20/2023 at 3:00 PM, tobias-ripper said:

hi everyone. this might not be the right place to ask but its related to spawning compos. i just can't, for the life of me, find a reliable way to get an actually flat and empty area to spawn some rather large compos (20x20 being the largest). i've tried shk_pos script, isFlatEmpty, findSafePos and combinations of them all. im pretty sure the way im scripting it is flawed but at this point i just have a very bad headache from trying to figure this out. so to save you time... got something wokring that your a willing to share?
im creating a marker randomly around the map (invade and annex style) and spawning my stuff in it's area. only 2 tasks, so far, are meant to spawn a compo. 1 is "working" cos the compo is rather small. the 20x20 is just way more complex with items inside a building (large hq type). im just overwelmed.. HELP?

Hmm. Might make use of setterrainheight and triggers. Name the triggers something like terrainTrigger_%1. Make sure trigger c - trigger area Z size is 0.002, set itz height pos to 0. Make sure it is level with ground in vr when you save it as a comp. Then, reference those triggers in your script:

private _triggerNames = [terrainTrigger_01, terrainTrigger_02, terrainTrigger_03, terrainTrigger_04];

{
    private _triggerPos = getPosWorld _x;
    private _triggerSize = triggerArea _x;
    private _height = _triggerPos select 2;
    private _position = getPosWorld _x;
    private _triggerLength = (_triggerSize) # 0;
    private _triggerWidth = (_triggerSize) # 1;
    private _triggerAngle = (_triggerSize) # 2;

    private _pos = [(_position#0 + cos(_triggerAngle) * _triggerLength + sin(_triggerAngle) * _triggerWidth), (_position#1 - sin(_triggerAngle) * _triggerLength + cos(_triggerAngle) * _triggerWidth)];
    private _positionsAndHeights = [];
    _pos pushBack _height;

    for "_i" from 0 to (_triggerLength * 8) do {
        private _pos2 = _pos;

        for "_j" from 0 to (_triggerWidth * 8) do {
            _positionsAndHeights pushBack _pos2;
            _pos2 = _pos2 vectorAdd [-0.25 * sin(_triggerAngle), -0.25 * cos(_triggerAngle), 0];
        };

        _pos = _pos  vectorAdd [-0.25 * cos(_triggerAngle), 0.25 * sin(_triggerAngle), 0];
    };

    setTerrainHeight[_positionsAndHeights, true];
            
} forEach _triggerNames;

The downside is I'm not near math smart enough to smooth the edges, so you'll have to find a relatively open area to minimize jarring transitions (don't place it partially on a hill. 

Share this post


Link to post
Share on other sites
On 6/13/2017 at 3:13 PM, Larrow said:

_compositions = [ "comp1", "comp2", "comp3" /* etc */ ]; _randomComp = selectRandom _compositions; _compReference = [ _randomComp, POS_ATL, OFFSET, DIR, ALIGN_TERRAIN, ALIGN_WATER ] call LARs_fnc_spawnComp;

Hey @Larrow, I know it's a little late to ask, but when but when a random compositions is chosen and then the delete function is used:

["_compReference"] call LARs_fnc_deleteComp;(or ["_randomComp"] call LARs_fnc_deleteComp;)

it will not delete the composition. I don't know if there is anyone who can give me some advice on this but I'll wait.

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

×