Jump to content
fathersarge

Repair buildings (Map and placed) in specified area

Recommended Posts

Hey there everyone!

 

I'm building multiple MOUT courses on my training map and I've wanted to be able to do this for awhile.

 

player addAction ["Repair Building", "repairbuild.sqf"];
repairbuild.sqf:
_rbuilding = nearestBuilding player;
_rbuilding setdamage 1;
sleep 2;
_rbuilding setdamage 0;

Possible addition of placed objects (not original map objects)

_buildings = nearestobjects [player,["House"],5];
_rBuilding = _buildings select 0;

 

I pulled this script from here

 

I'm not too grand at this but I'd like to specify an area and repair everything in it in one command so any fences or buildings, be them original map objects or objects I've added, are affected.

Can someone get me smarter on this and help a guy out? I've got 2 courses planned with one already mostly finished. I'd like to be able to run them independently. 

 

Share this post


Link to post
Share on other sites

Are these houses/buildings placed in the editor?

Pierre MGI notes on the nearestBuilding docs on the biki:

This command doesn't return any house or building placed in editor (with createVehicle). Use nearestObjects instead: 

wit this command following: 

nearestObjects [player, ["House", "Building"], 50] select 0

So I recommend you try and use nearestObjects instead.

It'll still find the buildings you are looking for. 

Share this post


Link to post
Share on other sites

So I'm probably looking to add something in as well? I feel like respawning editor placed buildings would be trivial.

 

As far as the map buildings though, I've got a "command center" of sorts that I'm using to control the mout course (they will have script spawned enemy as well) and they need to be independent of one another. Is there a way to specify like AREA1 rebuild bs AREA2 rebuild?

Share this post


Link to post
Share on other sites
6 hours ago, fathersarge said:

So I'm probably looking to add something in as well? I feel like respawning editor placed buildings would be trivial.

 

As far as the map buildings though, I've got a "command center" of sorts that I'm using to control the mout course (they will have script spawned enemy as well) and they need to be independent of one another. Is there a way to specify like AREA1 rebuild bs AREA2 rebuild?

yeah, you could define a radius for the nearestObjects.

For area one and two.

Small enough for one building, or you could just check for specific classnames within the radius

Share this post


Link to post
Share on other sites

So how would that look exactly? Right now I've got triggers that spawn enemies into the same area that I'd want to repair the buildings, it would be great if I could just use that as the reference point

Share this post


Link to post
Share on other sites
3 hours ago, fathersarge said:

So how would that look exactly? Right now I've got triggers that spawn enemies into the same area that I'd want to repair the buildings, it would be great if I could just use that as the reference point

It's like this:

ex:

nearestObjects[player,["UnderwaterMine","Land_LampDecor_off_F"],200];

the 200 being your radius

and the array that contains ["UnderwaterMine", and "Land_LampDecor_off_F"]

are the objects in classname form it's looking for.

if you leave the array area blank it'll return all the objects within the radius regardless of what classname they are defined by.

 

Share this post


Link to post
Share on other sites

Ah gotcha, so can I use a flagpole or something as the reference point and use the variable name in place of player?

Share this post


Link to post
Share on other sites
6 hours ago, fathersarge said:

Ah gotcha, so can I use a flagpole or something as the reference point and use the variable name in place of player?

indeed!

Share this post


Link to post
Share on other sites

Ok so, here's the script I've got, it doesn't return any errors but it doesn't rebuild anything, map objects or placed

 

_buildings = nearestobjects [build1,[],125];
_rBuilding = _buildings select 0;
_rbuilding setdamage 1;
sleep 2;
_rbuilding setdamage 0;

 

Any suggestions?

Share this post


Link to post
Share on other sites
8 hours ago, fathersarge said:

Ok so, here's the script I've got, it doesn't return any errors but it doesn't rebuild anything, map objects or placed

 


_buildings = nearestobjects [build1,[],125];
_rBuilding = _buildings select 0;
_rbuilding setdamage 1;
sleep 2;
_rbuilding setdamage 0;

 

Any suggestions?

make sure you have a list of building classnames in the array

so

_buildings = nearestObjects[build1,["Mybuildingclassname"],125];

that'd be the easiest way to just find buildings.

Share this post


Link to post
Share on other sites
14 hours ago, Midnighters said:

make sure you have a list of building classnames in the array

so

_buildings = nearestObjects[build1,["Mybuildingclassname"],125];

that'd be the easiest way to just find buildings.

 

 

Well... It's basically a city. Is there a way to do it in such a way as to just get everything in the radius?

Share this post


Link to post
Share on other sites

Use a parent class like "House_F" or "House" or maybe go further back up the hierarchy and use "Building"

Share this post


Link to post
Share on other sites
4 hours ago, fathersarge said:

 

Well... It's basically a city. Is there a way to do it in such a way as to just get everything in the radius?

well yes, just leave the array blank.

_buildings = nearestObjects[build1,[],125]; 

 

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

Use a parent class like "House_F" or "House" or maybe go further back up the hierarchy and use "Building"

Could you explain a little bit?

Share this post


Link to post
Share on other sites
28 minutes ago, Midnighters said:

Could you explain a little bit?

Lets take Stratis as an example and to be more specific the crossroads in Agia Marina by the seafront bridge.

Walk up to the nearest house and place you cross hairs over it and bring down the debugConsole.

Type in a watch line

typeof cursorTarget

and you will see displayed "Land_i_House_Big_01_V1_F".

Now all placeable objects in Arma come from the config under CfgVehicles. So open up the config and navigate to CfgVehicles anf find "Land_i_House_Big_01_V1_F" and select it.

If you now look at the bottom of the config viewers display you will see a box called Parents, this is the config hierarchy of the current selected config entry.

For the above "Land_i_House_Big_01_V1_F" you will see ["House_F","House","HouseBase","NonStrategic","Building","Static","All"]

This is basically telling you that "Land_i_House_Big_01_V1_F" is a child class of "House_F" which in turn is a child of "House" etc etc where "All" is the base class for all things CfgVehicles.

 

So you can use any of these child types in the Types parameter for nearestObjects just keep in mind the higher up the hierarchy you go the more things you are going to get returned that are not what you are looking for. e.g

Using "Land_i_House_Big_01_V1_F" you will only get this exact type of object, "House_F" will give you most buildings but you will also find stuff like the decorative street lamps, "House" you will start to get things like the power poles etc etc.

Share this post


Link to post
Share on other sites
2 hours ago, Larrow said:

Lets take Stratis as an example and to be more specific the crossroads in Agia Marina by the seafront bridge.

Walk up to the nearest house and place you cross hairs over it and bring down the debugConsole.

Type in a watch line


typeof cursorTarget

and you will see displayed "Land_i_House_Big_01_V1_F".

Now all placeable objects in Arma come from the config under CfgVehicles. So open up the config and navigate to CfgVehicles anf find "Land_i_House_Big_01_V1_F" and select it.

If you now look at the bottom of the config viewers display you will see a box called Parents, this is the config hierarchy of the current selected config entry.

For the above "Land_i_House_Big_01_V1_F" you will see ["House_F","House","HouseBase","NonStrategic","Building","Static","All"]

This is basically telling you that "Land_i_House_Big_01_V1_F" is a child class of "House_F" which in turn is a child of "House" etc etc where "All" is the base class for all things CfgVehicles.

 

So you can use any of these child types in the Types parameter for nearestObjects just keep in mind the higher up the hierarchy you go the more things you are going to get returned that are not what you are looking for. e.g

Using "Land_i_House_Big_01_V1_F" you will only get this exact type of object, "House_F" will give you most buildings but you will also find stuff like the decorative street lamps, "House" you will start to get things like the power poles etc etc.

Ooohh..yes. This is cool.

I don't know if fathersarge is looking for a specific building or not.

But, this is still cool.

Share this post


Link to post
Share on other sites
On 2/2/2017 at 5:01 PM, Larrow said:

Lets take Stratis as an example and to be more specific the crossroads in Agia Marina by the seafront bridge.

Walk up to the nearest house and place you cross hairs over it and bring down the debugConsole.

Type in a watch line


typeof cursorTarget

and you will see displayed "Land_i_House_Big_01_V1_F".

Now all placeable objects in Arma come from the config under CfgVehicles. So open up the config and navigate to CfgVehicles anf find "Land_i_House_Big_01_V1_F" and select it.

If you now look at the bottom of the config viewers display you will see a box called Parents, this is the config hierarchy of the current selected config entry.

For the above "Land_i_House_Big_01_V1_F" you will see ["House_F","House","HouseBase","NonStrategic","Building","Static","All"]

This is basically telling you that "Land_i_House_Big_01_V1_F" is a child class of "House_F" which in turn is a child of "House" etc etc where "All" is the base class for all things CfgVehicles.

 

So you can use any of these child types in the Types parameter for nearestObjects just keep in mind the higher up the hierarchy you go the more things you are going to get returned that are not what you are looking for. e.g

Using "Land_i_House_Big_01_V1_F" you will only get this exact type of object, "House_F" will give you most buildings but you will also find stuff like the decorative street lamps, "House" you will start to get things like the power poles etc etc.

 

 

On 2/2/2017 at 7:39 PM, Midnighters said:

Ooohh..yes. This is cool.

I don't know if fathersarge is looking for a specific building or not.

But, this is still cool.

 

 

Wow I had no idea about this. Honestly didn't think "Building" was anything more than a placeholder. Awesome. I'll give it a go soon and get back to you all. Thanks!

Share this post


Link to post
Share on other sites
10 hours ago, fathersarge said:

 

 

Wow I had no idea about this. Honestly didn't think "Building" was anything more than a placeholder. Awesome. I'll give it a go soon and get back to you all. Thanks!

Sweet! Hope all works out

Share this post


Link to post
Share on other sites

The potential problem you have is that many objects are configured as houses when they aren't. Lampposts, pier objects, phone booths, fences..loads of stuff like that. I greatly lament the death of the six config browser.

Share this post


Link to post
Share on other sites
On 03/02/2017 at 0:01 AM, Larrow said:

Lets take Stratis as an example and to be more specific the crossroads in Agia Marina by the seafront bridge.

Walk up to the nearest house and place you cross hairs over it and bring down the debugConsole.

Type in a watch line


typeof cursorTarget

and you will see displayed "Land_i_House_Big_01_V1_F".

Now all placeable objects in Arma come from the config under CfgVehicles. So open up the config and navigate to CfgVehicles anf find "Land_i_House_Big_01_V1_F" and select it.

If you now look at the bottom of the config viewers display you will see a box called Parents, this is the config hierarchy of the current selected config entry.

For the above "Land_i_House_Big_01_V1_F" you will see ["House_F","House","HouseBase","NonStrategic","Building","Static","All"]

This is basically telling you that "Land_i_House_Big_01_V1_F" is a child class of "House_F" which in turn is a child of "House" etc etc where "All" is the base class for all things CfgVehicles.

 

So you can use any of these child types in the Types parameter for nearestObjects just keep in mind the higher up the hierarchy you go the more things you are going to get returned that are not what you are looking for. e.g

Using "Land_i_House_Big_01_V1_F" you will only get this exact type of object, "House_F" will give you most buildings but you will also find stuff like the decorative street lamps, "House" you will start to get things like the power poles etc etc.

 

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

Can show this in live debug without having to dig into the config screens

Share this post


Link to post
Share on other sites
9 hours ago, Tankbuster said:

The potential problem you have is that many objects are configured as houses when they aren't. Lampposts, pier objects, phone booths, fences..loads of stuff like that. I greatly lament the death of the six config browser.

interesting point.

I've seen some as structures instead of buildings before,

or are structures placed similarly as buildings?

Share this post


Link to post
Share on other sites

Unfortunately this did not work:

 

_buildings = nearestobjects [build1,["Building"],125];
_rBuilding = _buildings select 0;
_rbuilding setdamage 1;
sleep 2;
_rbuilding setdamage 0;

 

On 2/5/2017 at 2:18 AM, Tankbuster said:

The potential problem you have is that many objects are configured as houses when they aren't. Lampposts, pier objects, phone booths, fences..loads of stuff like that. I greatly lament the death of the six config browser.

 

Thankfully this isn't much of an issue because I want everything in the radius to be repaired, included everything on that list

Share this post


Link to post
Share on other sites

I'm dragging this up from distance and faint memory;

 

It used to be the case that buildings had their original model sunk into the ground and replaced with the wreck model when they are destroyed. This was implicated some time ago in an FPS killing bug often caused by area artillery strikes that were razing build up areas.

 

If I remember correctly, the way to repair a building was not to setdamage 0 it, but to find the wreck model, delete it, find the sunken good model and bring it back to the surface.

Share this post


Link to post
Share on other sites

Just had a flash of inspiration.  What IF all buildings in a town start destroyed and as you spend time in it, do missions etc, the buildings get repaired.  Kinda hearts and minds stuff :)  It could be a new type of CTI (through rebuilding the island!)

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

×