Jump to content
Sign in to follow this  
Sekra

Repairing mapobjects (houses)

Recommended Posts

I've been trying to make a small script that would repair the destroyed houses on a map.

_houses = (getpos testpos) nearobjects ["House",25];
{
_x setDamage 1;
} foreach _houses;

works brilliantly to blow up the houses but if you use setDamage 0 afterwards to repair them, nothing happens. Anyone got an idea how to make the buildings revert back to being not destroyed? The intention is to use it on a MP mission where the destruction of the buildings is completely viable and even desirable at some point, but I'd also need them to be repaired after some time back to normal, so allowdamage false and the rest is not really an option here.

Share this post


Link to post
Share on other sites

Guess the problem here is that destroyed houses actually switch the whole model. Instead of houses, you end up with a bunch of ruins, which are completely different models than the original houses, only linked by some config sorcery. So what happens if you try to undo the damage with a call to setDamage 0 is that your ruins will be completely new now, hahaha - yet they're still ruins, and not the original models.

I'm not sure if you can go from a ruin back to the original model again without too much hassle (or even at all).

So good luck with that. :p

Share this post


Link to post
Share on other sites

Okay. Like I said in the first post but maybe not clear enough, I'm not trying to make them indestructible but rather to fix destroyed / damaged buildings later on. Also the problem with allowdamage false has been that a big single amount of damage could still destroy the object, thus using the handledamage eventhandler is a better option in making stuff indestructible. Plus the wiki shows the arguments can be global, but effects are local. I don't understand why you brought this up when I said its not what I want.

For the workaround, I don't think its possible to delete mapobjects.

Edited by Sekra

Share this post


Link to post
Share on other sites

Thank you Demonized for the link, it seems that the problem lies elsewhere in my scripts then. And naturally like always, the repairing buildings was one term I didn't search on the forums but tried repairing houses and repairing mapobjects which returned nothing usefull. My problem was that I was passing the array of houses when the house was still intact rather than after it was destroyed so it was only referencing the original building, not the destroyed one. Doing a new search with nearobjects of houses at the time of rebuilding yields a successfull result too.

---------- Post added at 12:37 ---------- Previous post was at 12:06 ----------

And I'm back to square one after realizing this only works on damaged buildings and not on completely destroyed buildings. If the building is destroyed into a rubble, it seems it cannot be repaired like Kylania posts in that thread Demonized linked to as even using nearestObjects [pos, [], 25]; will yield a empty list if just moments before you used the same command to destroy everything in the area. Anyhow as far as I'm concerned I've moved on to other things and the locals will just have to live in blown up houses if it comes to that :P

Share this post


Link to post
Share on other sites
And I'm back to square one after realizing this only works on damaged buildings and not on completely destroyed buildings. If the building is destroyed into a rubble, it seems it cannot be repaired like Kylania posts in that thread Demonized linked to as even using nearestObjects [pos, [], 25]; will yield a empty list if just moments before you used the same command to destroy everything in the area. Anyhow as far as I'm concerned I've moved on to other things and the locals will just have to live in blown up houses if it comes to that :P

I dropped 200 GBUS over a 300 diameter circle in the middle of ferus abad city (Takistan MAP), when the smoke cleared i pressed the radio trigger wich activated the repair and the city came back.

I asure you, it was completely in rubble...

Share this post


Link to post
Share on other sites

Ah, looks like it works in the single player editor but in multiplayer editor it is a no go and thus this doesn't seem to work in MP. For clarification my mission is a MP mission. Sorry about that.

---------- Post added at 14:29 ---------- Previous post was at 14:10 ----------

Take that back. Does not work even in SP editor if you wait for the dust to settle. If you setdamage 0 while the building is collapsing after doing setdamage 1 it will work.

---------- Post added at 14:43 ---------- Previous post was at 14:29 ----------

Download my test and try it out yourself.

Share this post


Link to post
Share on other sites

place player on safe distance and place this code in alpha radio trigger.

player allowDammage false;
_null = [] spawn {
_cnt = 500;
_pos = getPos rebuilder;
while {_cnt != 0} do {
	_lightsoff = "Bo_GBU12_LGB" createVehicle [(_pos select 0)+((random 300)+(random -300)),(_pos select 1)+((random 300)+(random -300)),50];
	_cnt = _cnt - 1;
	sleep 0.05;
};
hint "back to the stoneage, ah well";
};

place a game logic named rebuilder where you want to fix buildings.

place this code in a bravo radio trigger:

_null = [rebuilder,500] spawn {
_pos = _this select 0;
_dist = _this select 1;
_static = nearestobjects [_pos,["Building"], _dist];
{_x setdammage 0} foreach _static;
};

demo mission:

arma2oa2012021313564086.th.png

arma2oa2012021313524983.th.png

arma2oa2012021313524633.th.png

arma2oa2012021313562784.th.png

arma2oa2012021313523900.th.png

Edited by Demonized
picture proof

Share this post


Link to post
Share on other sites

I finally found the culprit. I was using getposATL in the nearestobjects instead of getpos on the item to check distance from. Finally got it working reliably.

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
Sign in to follow this  

×