jakerod 254 Posted January 3, 2010 I am presently using the following code to destroy buildings. (position this nearestobject 143871) setdammage 1 I am using the following code to damage buildings: this setPos [getPos this select 0, getPos this select 1, 1]; bomb = "Bo_GBU12_LGB" createvehicle GetPos this; Is there a better way to destroy buildings without using the nearestobject command? I tried using a trigger grouping it and using this setdammage 1 but it doesn't work. Is there a better way to damage buildings and take out chunks of wall other than creating bombs on it? I am worried it might damage units placed in the future. Share this post Link to post Share on other sites
nomdeplume 0 Posted January 3, 2010 I just did an experiment using the control tower on Utes, and it looks like you can use setHit for it. This is what I did: Put a gamelogic near the tower with this code in it's init: tower = (position this nearestobject 6540) ; nul = tower addEventHandler ["handleDamage", "diag_log _this"]; Popped myself into a tag and shot the building a couple of times. Had a look in the arma2.rpt to see what the names of the parts were. For the control tower, I got "", "dam tower", "dam glass", and "dam 1" to "dam 6". So I updated my gamelogic's init to: tower = (position this nearestobject 6540) ; [b]tower setHit ["dam 1", 1] ;[/b] nul = tower addEventHandler ["handleDamage", "diag_log _this"]; Previewed the mission, and the control tower had blast marks and cracks, went around it a bit and saw that the northeast corner was all caved in. ---------- Post added at 04:43 PM ---------- Previous post was at 04:40 PM ---------- Is there a better way to destroy buildings without using the nearestobject command? Might depend on what you consider "better" - what's wrong with the nearestObject command? I've seen some people using nearObjects ["House", radius] to destroy all buildings in a given area so you don't have to manually specify every single one. Other than that, I'm not aware of other methods. Share this post Link to post Share on other sites
jakerod 254 Posted January 3, 2010 I just did an experiment using the control tower on Utes, and it looks like you can use setHit for it. This is what I did:Put a gamelogic near the tower with this code in it's init: tower = (position this nearestobject 6540) ; nul = tower addEventHandler ["handleDamage", "diag_log _this"]; Popped myself into a tag and shot the building a couple of times. Had a look in the arma2.rpt to see what the names of the parts were. For the control tower, I got "", "dam tower", "dam glass", and "dam 1" to "dam 6". So I updated my gamelogic's init to: tower = (position this nearestobject 6540) ; [b]tower setHit ["dam 1", 1] ;[/b] nul = tower addEventHandler ["handleDamage", "diag_log _this"]; Previewed the mission, and the control tower had blast marks and cracks, went around it a bit and saw that the northeast corner was all caved in. ---------- Post added at 04:43 PM ---------- Previous post was at 04:40 PM ---------- Might depend on what you consider "better" - what's wrong with the nearestObject command? I've seen some people using nearObjects ["House", radius] to destroy all buildings in a given area so you don't have to manually specify every single one. Other than that, I'm not aware of other methods. Occasionally when they patch stuff the ids can change slightly because they moved or deleted an object that was no longer wanted. Which means it would break the mission. I don't know if that is true but I heard someone else somewhere mention it. Its not a big deal I was just wondering if there was a better way. Thank you. Its odd that you ended up using the same building (different island) that I am trying to damage. Share this post Link to post Share on other sites
nomdeplume 0 Posted January 3, 2010 It's probably quite rare that that happens. You could prevent it from breaking the mission by making sure you check whether you actually got an object back from "nearestObject", i.e. bldg = (position this nearestObject nnnn); if (not isNull bldg) then { bldg setHit [...] }; That way if the building magically disappears in a later release, your script will just disregard it. Or alternatively damage one in some other location on the island. Of course, even if it isn't found, the only script that might fail to run will be that particular one which probably doesn't do anything else. Share this post Link to post Share on other sites
Deadfast 43 Posted January 3, 2010 That way if the building magically disappears in a later release, your script will just disregard it. Actually it will still attempt to find it, scan the whole map and freeze your game for several seconds. Share this post Link to post Share on other sites
A-SUICIDAL 11 Posted July 9, 2011 What if I am trying to make it so the building cannot be destroyed. For instance the control tower at south air base in Takistan. I have a nonplayable AI commander that stand ins the glass room, but I don't want coop players or enemy destroying the building and leaving the commander standing in rubble, lol. It would be easier if I could just set the building to "this allowDamage false;". How would I do this? ---------- Post added at 08:00 PM ---------- Previous post was at 07:51 PM ---------- Do I add a gameLogic and set it to "objects" and put this in it's init field? tower = (position this nearestobject 123256); tower allowDamage false; The id number of the building was 123256. I'm guessing that I am way off. Share this post Link to post Share on other sites
riouken 15 Posted July 9, 2011 The best way to destoy buildings and leave some "untouched" and would probaly will be a whole lot easier to do as well: BIS_fnc_destroyCity Here is another thread with some more great examples: http://forums.bistudio.com/showthread.php?t=121727 Share this post Link to post Share on other sites
A-SUICIDAL 11 Posted July 9, 2011 I think my guess was correct: gamelogic tower = (position this nearestobject 123256); tower allowDamage false; I tried destroying the building and I could not. Share this post Link to post Share on other sites