twakkie 57 Posted July 21, 2016 Amazing work Larrow! Going to test it this coming weekend! Share this post Link to post Share on other sites
R3vo 2654 Posted July 21, 2016 Now wheres the WTFYL(What The F*** You Like) license i saw some one use the other day,made me laugh. I believe that was T800a's download data script. Had a good laugh when I read the licence :D 1 Share this post Link to post Share on other sites
Revdogma 6 Posted November 5, 2016 @Larrow sorry if you thought this post was a thing of the past LOL! I'm having JIP issues. When i spawn a composition i declare the _compReference variable (in this case FOB_Alpha) as public. However when I JIP, the _compReference return (FOBAlpha_0) no longer references the composition. I checked the server RPT and all i get is "CLIENT: Remote object #:# not found" (# would be various numbers).I'm assuming the problem would be fixed in fn_spawnComp.sqf I dug around and could follow the logic but got lost in the syntax. If you can offer any guidance at least that would be awesome. Either way, thanks! Share this post Link to post Share on other sites
Larrow 2820 Posted November 6, 2016 @Larrow sorry if you thought this post was a thing of the past LOL! Aye project it currently in permanent limbo due to the problems with positioning stuff properly due to handling large config numbers in sqf. I'm having JIP issues. When i spawn a composition i declare the _compReference variable (in this case FOB_Alpha) as public. However when I JIP, the _compReference return (FOBAlpha_0) no longer references the composition. The whole system is meant to be used server side. If you use it client side and then leave and rejoin then the whole data structure used for referencing comp objects will be lost. You can try PVing LARs_spawnedCompositions as well, which is the data structure that holds all the info about spawned compositions. Depending on how big you compositions are this could potentially be a bad idea and would recommend just hadling all spawning of compositions on the server. Share this post Link to post Share on other sites
Revdogma 6 Posted November 6, 2016 I'm using addAction on a named spawned vehicle, That action execVMs a script containing the comp spawn. I guess im confused about what step is causing the client to handle the comp spawning? Is it the execVMing of the script from the action since actions are local? Share this post Link to post Share on other sites
twakkie 57 Posted November 7, 2016 I'm using addAction on a named spawned vehicle, That action execVMs a script containing the comp spawn. I guess im confused about what step is causing the client to handle the comp spawning? Is it the execVMing of the script from the action since actions are local? Well as far as I understand, whoever gets in the vehicle as driver takes "control" of the vehicle locally. So I suppose whoever is driver would execute the script. Dont take my word as gospel but that is my understanding of it. Share this post Link to post Share on other sites
Larrow 2820 Posted November 7, 2016 Is it the execVMing of the script from the action since actions are local?Correct, as you say due to the action being a local effect anything run from it will generally be local as well. You will need to run a function server side that will spawn the comp and handle the returned comp reference( maybe place it on the vehicle ).Something like.. //initServer.sqf TAG_fnc_addVehicleComp = { params[ "_veh", "_vehVar", "_compInfo" ]; //Spawn composition and place the comp reference on the vehicle in _vehVar //with PV( true ) so it propogates to all clients _veh setVariable [ _vehVar, _compInfo call LARs_fnc_spawnComp, true ]; }; TAG_fnc_removeVehicleComp = { params[ "_veh", "_vehVar" ]; //Get the comp Reference from the vehicles _vehVar and delete the composition [ _veh getVariable _vehVar ] call LARs_fnc_deleteComp; //Set the vehicle var to nil and PV( true ) it to all clients _veh setVariable [ _vehVar, nil, true ]; }; //initPlayerLocal.sqf _theVehicle addAction [ "Spawn Composition", { params [ "_target" ]; //Call server function to spawn composition //Passing the vehicle, the vehicle var to store the comp reference in and the parameters for spawning the composition [ _target, "compRef", [ COMP_NAME, POS_ATL, OFFSET, DIR, ALIGN_TERRAIN, ALIGN_WATER ] ] remoteExec [ "TAG_fnc_addVehicleComp", 2 ]; }, [], 1, true, true, "", //If the vehicle does not hold a comp reference in its 'compRef' variable then show spawn composition action "isNull ( _target getVariable[ 'compRef', objNull ] )" ]; _theVehicle addAction [ "Delete Composition", { params [ "_target" ]; //Call server function to delete composition [ _target, "compRef" ] remoteExec [ "TAG_fnc_removeVehicleComp", 2 ]; }, [], 1, true, true, "", //If the vehicle holds a comp reference in its 'compRef' variable then show delete composition action "!isNull ( _target getVariable[ 'compRef', objNull ] )" ]; Share this post Link to post Share on other sites
Larrow 2820 Posted November 7, 2016 Well as far as I understand, whoever gets in the vehicle as driver takes "control" of the vehicle locally.You are correct Twakkie in relation to the vehicle locality but this has no bearing on spawning the composition. No matter the vehicle locality if a player has access to an action this action will be local to them. 1 Share this post Link to post Share on other sites
Revdogma 6 Posted November 8, 2016 Well shoot! Thanks Larrow! That should be more than enough to get me up and going! Share this post Link to post Share on other sites
celludriel 79 Posted November 13, 2016 Great script Larrow, it is doing what a lot of people wanted when they made compositions , make them spawnable by script. A feature that lets be frank should have been in there when they released it. I have a programmer concern though, especially in regards to maintainability. This script will probably be used in many mods and missions, and will have to be appended or fixed from time to time and you might not always be available. Your fn_createComp.sqf is very big , 1213 lines, while most of it are private functions. In Java I would put those private functions in a static class so I could unit test it seperate, but considering we are dealing with sqf. Could you put them in their own function library, and add documentation to each function so it's more clear what they actually do. I've figured out most of it but there are gaps in my understanding how each of those privates ties together in the main loop. Great work really ! Thanks for this ! Share this post Link to post Share on other sites
jetset22a 7 Posted January 17, 2017 This is great work! I spent so much time trying to find a way to spawn compositions in a random position and this has nearly solved all my problems! Big thanks to Larrow! Also, I know this is on permanent limbo, but I did some testing and I found a few things in case Larrow or anyone else wants to pick up where he left off. I found a way to define the Z coordinate in relation to the surface that the composition is spawned while trying to dynamically spawn Silos' OilRig composition. Basically by going to the composition file and changing adding some constant to the z coordinate of all the objects in the composition you can change the z coordinate of where the composition is spawned. Perhaps a way to implement this into the script is by adding another parameter to the spawnComp and createComp function that is the _ZCoordinate of the position where you would like to spawn your composition. Then when the script reads the data from the composition file it adds the _ZCoordinate value to the z coordinate in all the Position [] = {0,z,0}; lines, which is the second value in the array, not the third. I also noticed that when reading the angles[] = {0,z,0}; lines for each object, the script transposes the x and y values so the rotation gets screwed up. I haven't double checked yet, but I believe it is {x,z,y} for rotation but the script reads it as {y,z,x}. Share this post Link to post Share on other sites
Larrow 2820 Posted January 18, 2017 1 hour ago, jetset22a said: Perhaps a way to implement this into the script is by adding another parameter to the spawnComp and createComp function that is the _ZCoordinate of the position where you would like to spawn your composition You already have this ability with the Offset parameter, using [0,0,10] for instance would add a constant of 10 to all composition objects Z value. 1 hour ago, jetset22a said: I also noticed that when reading the angles[] = {0,z,0}; lines for each object, the script transposes the x and y values so the rotation gets screwed up. Are you sure, from memory it reads them as {x,z,y} which it turns into {Pitch,Yaw,Roll} which I think is correct. Rotating X axis is Pitch, Z is Yaw and Y is Roll. Otherwise spawning things like the example comp Camp Ant on a hill side would set them up all misaligned from the slope, which it does not. Dont get me wrong there is something not quite right with rotation but I do not think it is what you suggest as the outcome would be drastically wrong which its is not. Share this post Link to post Share on other sites
jetset22a 7 Posted January 18, 2017 On 1/17/2017 at 8:02 PM, Larrow said: You already have this ability with the Offset parameter, using [0,0,10] for instance would add a constant of 10 to all composition objects Z value. Are you sure, from memory it reads them as {x,z,y} which it turns into {Pitch,Yaw,Roll} which I think is correct. Rotating X axis is Pitch, Z is Yaw and Y is Roll. Otherwise spawning things like the example comp Camp Ant on a hill side would set them up all misaligned from the slope, which it does not. Dont get me wrong there is something not quite right with rotation but I do not think it is what you suggest as the outcome would be drastically wrong which its is not. GAH, I wish I knew about the Offset parameter sooner! I must have glossed over it, because I ended up doing it all by hand in the composition file like an idiot! I'll try it out soon. And as far as the transposition of the x and y parameters, I'm not 100% sure it applies to all objects in the composition, but for sure I checked in the eden editor for some objects that would spawn with incorrect rotation what their rotation should be, transposed the x and y values in the composition file myself, and it spawned correctly. Edit: So I looked at the composition I was working with and it looks like most objects get the rotation right while a few others transpose the X and Y values. Don't know why though. I tested this by throwing the composition in the test mission you created and anytime a object spawns with incorrect rotation, I add a variable name so I can find it in the composition file then transpose the x and y myself and it works fine. Edit2: Checked again, Larrow is right again and I'm stupid. Yes it does transpose a few X and Y values but some other objects have very strange values applied to them that isn't just simply a transposition of array values. Stupid me. Share this post Link to post Share on other sites
elchupy 3 Posted February 17, 2017 Hi, first of all, great script, I refactored it to fit my project and added simpleObject support to it, But after changing some varNames in a composition, i got almost every object floating in the air. Working compo : https://bitbucket.org/bgillissen/direct-action/src/ac291e972057667309671da651a07e00e77bbdc6/scripts/feats/baseAtmosphere/Tanoa/tuvanaka.sqe?at=master&fileviewer=file-view-default Broken Compo : https://bitbucket.org/bgillissen/direct-action/src/8907ddbc258bffaaea311e1a4a4bc7f2000d4536/scripts/feats/baseAtmosphere/Tanoa/tuvanaka.sqe?at=master&fileviewer=file-view-default The only thing i can think of, is that i probably changed the "Toggle vertical mode" and "Toggle surface snapping" values, I tryed to export the composition again with all the possible combinations of thoses value, and it always ends up with floating objects. ho yeah i forgot, i spawn the compo as it was placed in the editor with those args : [_comp, [], [0,0,0], 0, false, false] Link to the working compo mission.sqm : https://bitbucket.org/bgillissen/direct-action/src/ac291e972057667309671da651a07e00e77bbdc6/missionFiles/tanoa/tuvanaka/mission.sqm?at=master&fileviewer=file-view-default I fxed my issue by changing the line : _obj setPosWorld _pos; from _fnc_setPositionAndRotation into _obj setPosATL [_pos select 0, _pos select 1, _ATLOffset]; i still don't get why suddently the composition did not spawn at the right altitude. Share this post Link to post Share on other sites
thecoolsideofthepillow 22 Posted May 3, 2017 I can not get the composition to spawn. Set up a super basic thing on Stratis to just spawn my composition somewhere and while I get no script errors, I also wind up with no composition. _basePos = [[],0,15000,5,0,0.5,0,[]] call BIS_fnc_findSafePos; _FlagRef = "FlagPole_F" createVehicle _basePos; _basePosATL = getPosATL _FlagRef; _Blu_Base = ["BluBase",_basePosATL,0,0,true,true] call LARs_fnc_spawnComp; The flag spawns, the composition doesn't. Share this post Link to post Share on other sites
Squirtman 5 Posted May 14, 2017 Hey Larrow not sure if you are still working on this or are planning to at some point in the future. If you are not feel free to disregard but if you are I have encountered and issue I figured i would bring to your attention since no one else seems to have, at least in this thread. When spawning a composition that contains a unit with a customized inventory there are a couple of issues. The composition will spawn and in the correct position however when LARs_fnc_spawnComp is called a "Bad Vehicle Type" error comes up that has to be closed similar to a error you get from when loading a mod that is missing a picture of some sort or a bin\cfg entry missing. After doing some testing to try and resolve this problem myself I have discovered the section of code that is throwing the error when spawnComp is called. I have commented out the block of code in the composition.sqe shown below that is causing both of the problems when interracting with spawnComp. Spoiler version=53; center[]={2456.4785,2.8396227,1153.7153}; class items { items=1; class Item0 { dataType="Group"; side="West"; class Entities { items=1; class Item0 { dataType="Object"; class PositionInfo { position[]={0,0.0014388561,0.050048828}; }; side="West"; flags=7; class Attributes { /* class Inventory { class handgun { name="hgun_Pistol_heavy_01_F"; class primaryMuzzleMag { name="11Rnd_45ACP_Mag"; ammoLeft=11; }; }; class uniform { typeName="U_B_CombatUniform_mcam"; isBackpack=0; class MagazineCargo { items=1; class Item0 { name="11Rnd_45ACP_Mag"; count=1; ammoLeft=11; }; }; }; goggles="G_Tactical_Clear"; }; */ }; id=399; type="B_Survivor_F"; atlOffset=-0.0024998188; class CustomAttributes { class Attribute0 { property="speaker"; expression="_this setspeaker _value;"; class Value { class data { class type { type[]= { "STRING" }; }; value="Male09ENG"; }; }; }; class Attribute1 { property="pitch"; expression="_this setpitch _value;"; class Value { class data { class type { type[]= { "SCALAR" }; }; value=1.04; }; }; }; nAttributes=2; }; }; }; class Attributes { }; id=398; atlOffset=-0.0024998188; }; }; I spoilered the code in the interest of shortening the posts initial display length The second problem i have encountered also relates to that same block of code. Like i said the composition will spawn in the correct position and with the correct orientation however the function will spawn the wrong amount of any item listed in class magazineCargo. For example the unit that goes with the above composition is a survivor that I added a pistol and an extra 11rnd mag to. After Spawning however the unit has a pistol and 11 extra mags. Basically it's using the ammoLeft value as the number of that item the unit has as opposed to the count. This problem has also affected chemlights although i don't have them in the example code but when i tried spawning a unit that was supposed to have 2 of the same color chemlights on it only one spawned. the code for the chemlight would have been name="official chemlight name"; count=2; ammoLeft=1; because a chemlight is technically considered a grenade, at least with the other mods i am using, it has an ammoleft of 1 for each of the 2 count of them. the mods i have loaded on the mission i am trying to use this in are. CBA_A3, RHSAFRF, RHSUSAF, RHSSAF, RHSGREF, Dynasound2, Enhanced soundscape, bwmod, ravage, virtual arsenal 2.0, mocap, qs mag repack. Sorry for the long ass post that was probably confusing at some point. If you have any questions PM me and i will do my best to answer them. I hope you haven't written this project off as a lost cause because this is amazing and the only thing else i have found that does something even remotely similar is JEBUS and that's not quite what i am looking for. Share this post Link to post Share on other sites
Larrow 2820 Posted May 14, 2017 2 hours ago, Squirtman said: Basically it's using the ammoLeft value as the number of that item the unit has as opposed to the count. Fixed both ammo/count and bad vehicle error, see original download in OP. BI changed around the mag count and ammo details of get/setUnitLoadout in patch v1.64. Thanks for the supplying a basic .sqe that pointed straight at the issue. Share this post Link to post Share on other sites
Squirtman 5 Posted May 17, 2017 On 5/14/2017 at 6:25 PM, Larrow said: Thanks for the supplying a basic .sqe that pointed straight at the issue. You're quite welcome. The way i see it the more detailed information you can give to someone you are asking to fix will cut down on the time and difficulty of fixing the issue. Thanks for the fix. Share this post Link to post Share on other sites
baton1990 30 Posted May 18, 2017 Hellow, where can I get LARs folder or demo mission for this script ? Share this post Link to post Share on other sites
Larrow 2820 Posted May 19, 2017 16 hours ago, baton1990 said: Hellow, where can I get LARs folder or demo mission for this script ? Your the second person to ask that this week. Its near the bottom of the OP on the right linked as DOWNLOAD. I have now made a copy of the link and placed it at the top of the OP so as to make it clearer. Share this post Link to post Share on other sites
baton1990 30 Posted May 19, 2017 Thanks :), sorry. Very nice and usefull script, thanks for hard work mate. Share this post Link to post Share on other sites
baton1990 30 Posted May 23, 2017 I have five LAR's compositions sqe files. Does anybody know how I can spawn random one of them (one from list of compositions) in the mission start via initserver.sqf ? Thanks. Share this post Link to post Share on other sites
Squirtman 5 Posted June 10, 2017 _num = floor(random 3); if (_num==0) then { //spawn composition1 }; if (_num==1) then { //spawn composition2 }; if (_num==2) then { //spawn composition3 }; this is the method i use for selecting code blocks at random i would recommend reading the wiki entry on random located at https://community.bistudio.com/wiki/random to understand the different types of output random can have. for instance in this instance floor(random 3) has an equal chance to output a number between 0 and 2. for what you want to do you would use random 5 and then if statements for 0-4 Share this post Link to post Share on other sites
miogushi 4 Posted June 12, 2017 hi @Larrow ! i m trying to use your script to spawn compostion with random location but it doesn't work . can you explain me where is my mystake ? private ["_telep"]; _town = ["town_1","town_2","town_3","town_4","town_5","town_6","town_7","town_8","town_9","town_10","town_11","town_12","town_13","town_14","town_15","town_16","town_17","town_18","town_19","town_20","town_21","town_22","town_23","town_24","town_25","town_26","town_27","town_28","town_29","town_30","town_31"] call BIS_fnc_selectRandom; _basePosATL = getMarkerPos _town; _Blu_Base = ["Task",_basePosATL,0,0,true,true] call LARs_fnc_spawnComp; _town = markers on the map sorry for my bad english Share this post Link to post Share on other sites
Squirtman 5 Posted June 12, 2017 I believe your problem is that _town is a variable and not a marker name so getmarkerpos can't actually get a location from it. try using private ["_telep"]; _town = [getMarkerPos "town_1",getMarkerPos "town_2",getMarkerPos "town_3",getMarkerPos "town_4",getMarkerPos "town_5",getMarkerPos "town_6",getMarkerPos "town_7",getMarkerPos "town_8",getMarkerPos "town_9",getMarkerPos "town_10",getMarkerPos "town_11",getMarkerPos "town_12",getMarkerPos "town_13",getMarkerPos "town_14",getMarkerPos "town_15",getMarkerPos "town_16",getMarkerPos "town_17",getMarkerPos "town_18",getMarkerPos "town_19",getMarkerPos "town_20",getMarkerPos "town_21",getMarkerPos "town_22",getMarkerPos "town_23",getMarkerPos "town_24",getMarkerPos "town_25",getMarkerPos "town_26",getMarkerPos "town_27",getMarkerPos "town_28",getMarkerPos "town_29",getMarkerPos "town_30",getMarkerPos "town_31"] call BIS_fnc_selectRandom; _Blu_Base = ["Task",_town,0,0,true,true] call LARs_fnc_spawnComp; I haven't tested this so i don't know if it will work but i believe it will Share this post Link to post Share on other sites