Jump to content
seed

Spawning Objects to buildings

Recommended Posts

Hello everyone, i have couple of questions and i hope soemone can help me out, or point me at the right direction.

 

1. I am working on a mission and i simply want to fill the "buildings" with Objects so they doesn´t look empty. For my first try i used the following code :

private["_gamelogic","_radius","_garageComposition","_vehArray","_class","_rack","_plasticContainer","_bench","_container","_can","_cargo"];
//Vehicle List of wrecks to be spawned
_vehArray = ["Land_Wreck_Car_F","Land_Wreck_Car2_F","Land_Wreck_Car3_F","Land_Wreck_CarDismantled_F","Land_Wreck_Offroad_F","Land_Wreck_Skodovka_F","Land_Wreck_UAZ_F","Land_Wreck_Van_F"];

_gamelogic = CENTER;

_radius = 10000;


//Search for garage in 10000 radius from center
_garageComposition = nearestObjects [getPosATL _gamelogic, ["Land_i_Garage_V1_F"], _radius];

{

	_class = _vehArray call BIS_fnc_selectRandom;

	_veh = createVehicle [_class, (_x modelToWorld [0, 0, 0]), [], 0, "CAN_COLLIDE"];
	
	_veh setDir (getDir _x - 90);
   
	_container = createVehicle ["Land_PlasticCase_01_large_F", (_x modelToWorld [4.6,0,0]), [], 0, "CAN_COLLIDE"];
	_container setDir (direction _x);

	_bench = createVehicle ["Land_Workbench_01_F", (_x modelToWorld [1.90198,-2.20996,0.881145]), [], 0, "CAN_COLLIDE"];
	
	_bench setDir (getDir _x - 180);
	
	_rack = createVehicle ["Land_Metal_wooden_rack_F", (_x modelToWorld [4.5,-2.3,0.881145]), [], 0, "CAN_COLLIDE"];
	


	_rack setDir (direction _x);
	
	_can = createVehicle ["Land_GarbageBarrel_01_F", (_x modelToWorld [-3.5,2.5,0]), [], 0, "CAN_COLLIDE"];
	
	_can setDir (direction _x);

}forEach _garageComposition;  

The above code does what i want, but it spawns the objects after the player been spawned. Ideally i would have it spawn the objects before the player spawns. With that in mind my question is : How can i write the above code so it will preload (if that is possible)? I have seen some people using "PreProcessfile" or something similar.. Is it possible to use the above as "PreProcess" file ?

 

2. I have created a composition of items inside a building. The code is the following :

/*
Grab data:
World: Bornholm
Anchor position: [1688.09, 7390.2]
Area size: 10
Using orientation of objects: no
*/
house1 = 
[
	["Land_Rack_F",[-1.11157,-0.358398,-0.0249062],309.941,1,0,[],"","",true,false], 
	["Fridge_01_open_F",[1.59033,0.330566,-0.0249386],308.992,1,0,[],"","",true,false], 
	["MapBoard_altis_F",[3.41943,2.30518,-0.0272217],354.627,1,0,[],"","",true,false], 
	["Land_ChairWood_F",[-3.61426,3.11084,0.530003],39.7183,1,0,[],"","",true,false], 
	["Land_WoodenTable_large_F",[-4.04749,2.58594,-0.00531006],309.559,1,0,[],"","",true,false], 
	["Land_WaterCooler_01_old_F",[3.94861,-4.57568,-0.0248737],164.321,1,0,[],"","",true,false], 
	["Land_OfficeCabinet_01_F",[5.15283,-3.31543,-0.0249634],130.005,1,0,[],"","",true,false], 
	["Land_OfficeCabinet_01_F",[5.7843,-2.56689,-0.0249214],130.113,1,0,[],"","",true,false], 
	["OfficeTable_01_old_F",[6.67444,-1.33838,-0.025013],130.018,1,0,[],"","",true,false]
];

How can i use the ObjectGrabber items position, to place then in all the "buildings" of the same type.? The reason for asking is that because it will save me time to simply copy and paste the composition on the "buildings" of the same time. Right now i am simply spawning and despawing objects in order to find their positions. I hope that you can understand my question even though my english is not so good.

 

 

 

Regards

 

Seed

Share this post


Link to post
Share on other sites

Good luck with this project. I started working on something exactly like this over 2 years ago. I gave up because nobody wanted to help make building layouts (the system would have been capable of choosing a random list of items for each room to spawn, allowing every single building on the map to be populated differently and give an actual "lived-in" feeling that altis is severely lacking, but I can't remember how far I got it working).

 

I may work on this again sometime, but I've got something else I'm trying to finish, so might as well do a code dump and see if somebody wants to work on it.

 

Download "Miscellaneous Housing" (Dropbox)

 

edit: all you have to do to use that is put the .rar in your missions folder, unpack, then load the mission in the editor.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you very much dreadedentity. I will try your mission when i am home. If i have any questions concerning your mission and your scripts i will ask it here.  In the meantime wishing you good luck with your other project that your are busy.

 

Regards

 

Seed

Share this post


Link to post
Share on other sites

The question is: why?

 

I mean, instead of making a complex thing, why not starting the mission with a black screen, some title text, and in the meantime do the spawn thing? This in the event the player is starting near one of those garages, but if not you don't need any kind of effect... 

Share this post


Link to post
Share on other sites

It seems like preprocess file should do it but I haven't worked with it a whole lot except for unitRecord.

Share this post


Link to post
Share on other sites

The above code does what i want, but it spawns the objects after the player been spawned. Ideally i would have it spawn the objects before the player spawns. With that in mind my question is : How can i write the above code so it will preload (if that is possible)? I have seen some people using "PreProcessfile" or something similar.. Is it possible to use the above as "PreProcess" file ?

I missed your first question because I was too excited somebody wanted to do exactly the same thing as something I worked on in the past.

 

I'm not sure if preprocessing can do what you want, have a look at the Functions Library. When you define a function here, you have several attributes you can apply and one of them, preInit, will cause the function to run before objects (ie players) get created/initialized. Look through that page to get an idea of how to add your custom scripts to the functions library, it's a small amount of description.ext work

Share this post


Link to post
Share on other sites

I'd be willing to help out with configuring other buildings to be furnished. Randomly select 1 of 3 configurations for that building for variety. I'd personally like to use this script, maybe turn it into a module eventually. I'm getting ahead of myself. I'm not a veteran scripter myself but I have no problem putting in some busy work with configuring the buildings and objects positions for individual building types.

Share this post


Link to post
Share on other sites

For Eden there is a plugin for object compositions https://forums.bistudio.com/topic/186056-composition-tool-eden-editor-plugin/

 

 

There is also a new command coming  createobject, this has no config so has little impact on performance.  https://forums.bistudio.com/topic/187670-new-command-createobject-for-decorative-objects/

Share this post


Link to post
Share on other sites

I'd be willing to help out with configuring other buildings to be furnished. Randomly select 1 of 3 configurations for that building for variety. I'd personally like to use this script, maybe turn it into a module eventually. I'm getting ahead of myself. I'm not a veteran scripter myself but I have no problem putting in some busy work with configuring the buildings and objects positions for individual building types.

Great! Whenever I start working on that project again, be on the lookout for a forum post asking for help!

  • Like 1

Share this post


Link to post
Share on other sites

I am nearly done with my other project, I have some testers doing things for me so I know if I need to change anything. So I have had a lot of time recently where I have no projects to work on. Because of that, I have restarted my miscellaneous hosing project, now with a permanent name instead of the placeholder name miscHousing, Inhabited World. I have no added a real editor to make creating layouts fast and easy!

 

You expressed interest in doing something similar to this and since I'm just about done now I'm wondering if you're still interested (and anyone else). If you are feel free to download this:

Download "Inhabited World" (Dropbox)

That is the IW system (not fully completed but working for people to create layouts) and the editor (pretty much done).

 

Just put the entire .rar file into your mission folder, and extract. You can then delete the .rar or keep it. Run the mission and the editor will start automatically.

 

Though, be sure to read the help pages thoroughly. Also I spent a lot of time on them. Once you have created a layout for a building, you don't need to separate the items by room, that can be done manually later.

 

If you have trouble understanding the "Class Example" help page, open "Inhabited_World\resources\layouts\Land_i_House_Big_02.txt" for a working example. "Land_Metal_Shed.txt" also has a working example. The buildings were a pain in the ass to furnish before I completed the editor so I only had 1 building done lol.

 

Make sure you send your layouts back to me and I will probably feature them (since I just put this out there and have no one helping atm). I may also make a video for youtube so you can see exactly how to work everything.

 

Cheers!

DE

  • Like 1

Share this post


Link to post
Share on other sites

Hello dreadentity. Yes i am still interested and i will definitely try out the Inhabited World. Due to a personal family matter currently i am unable to test "inhabited-World". But as i said i have interest and will definitely test it out.

 

Regards

 

Seed

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

×