vihkr 8 Posted June 24, 2018 Is there a script or add-on that will allow me to apply battle damage to the environment as part of a mission? As in placing the add-on on a town or city and randomly damaging or destroying buildings, fences, tress and props and cratering the ground. Instead of having to add environmental effects to each asset manually. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4206 Posted June 24, 2018 6 hours ago, vihkr said: a script Hello there vihkr ! You can check here: 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted June 25, 2018 Many scripts fails to damage all buildings, even BIS_fnc_destroCity... It's easy to get a visible result on damaged things... when theses things have adestroyed/wreck model. Ruins in fact for houses. Native maps Altis and Stratis contain plenty of destroyable houses. But Tanoa is a pity for that. Many buildings have just some exploded windows (or nuts) and that's all. So the question is: what can be destroyed, and if not, what should disappear. If you want a more realistic destruction, here is my 2 cent contrib: - place a trigger with the radius you want for destruction, - add the condition you want, on act field: 0 = thisTrigger spawn { MGI_BuildEnv = _this; addMissionEventHandler ["BuildingChanged", { params ["_previousObject", "_newObject", "_isRuin"]; if (_previousObject in nearestTerrainObjects [MGI_BuildEnv,[],triggerArea MGI_BuildEnv select 0]) then { _previousObject setVariable ["MGI_destroyable",true] } }]; private _radius = triggerArea MGI_BuildEnv select 0; {_x setDamage 1} forEach (nearestTerrainObjects [MGI_BuildEnv,[],_radius]); uisleep 1; {_x hideObjectGlobal true} forEach (nearestTerrainObjects [MGI_BuildEnv,["HOUSE","BUSSTOP","TRANSMITTER","TOURISM", "WATERTOWER","POWER LINES"],_radius]) select {!(_x getVariable ["MGI_destroyable",false])}; for "_i" from 0 to (_radius/40)^2 do { _crater = selectRandom ["CraterLong","CraterLong_small"] createVehicle (MGI_BuildEnv getpos [ - _radius + (random _radius *2), - _radius + (random _radius *2) ]); _crater setDir random 360; }; }; The smaller radius, the more flawless (if during mission) You can play with the array : ["HOUSE","BUSSTOP","TRANSMITTER","TOURISM", "WATERTOWER","POWER LINES"] For example, remove house and you will see crippled hotels but also slum houses... not very credible, add "HIDE" and some objects like water tanks will disappear but also lying signs and street lamps.. The place is far clearer. Have fun. 2 2 Share this post Link to post Share on other sites
vihkr 8 Posted June 25, 2018 6 hours ago, GEORGE FLOROS GR said: You can check here: Thanks! The approach with applying random damage worked pretty good. 1 Share this post Link to post Share on other sites
vihkr 8 Posted June 25, 2018 27 minutes ago, pierremgi said: Have fun. I did! Here's Chernogorsk from the SE. So clearly your code works great, thanks. The question is, how do I tone it down? Damaged > Destroyed. Your point about damage states for certain terrains is well taken, however. 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted June 25, 2018 you can write {_x setdamage ((random 1) max 0.5) } forEach (nearestTerrainObjects [MGI_BuildEnv,[],_radius]); and {if (random 1 > 0.5) then {_x hideObjectGlobal true} } forEach (nearestTerrainObjects [MGI_BuildEnv,["HOUSE","BUSSTOP","TRANSMITTER","TOURISM", "WATERTOWER","POWER LINES"],_radius]) select {!(_x getVariable ["MGI_destroyable",false])}; Just an example. All these commands are in BIKI. 2 1 Share this post Link to post Share on other sites
vihkr 8 Posted June 25, 2018 14 hours ago, pierremgi said: you can write {_x setdamage ((random 1) max 0.5) } forEach (nearestTerrainObjects [MGI_BuildEnv,[],_radius]); and {if (random 1 > 0.5) then {_x hideObjectGlobal true} } forEach (nearestTerrainObjects [MGI_BuildEnv,["HOUSE","BUSSTOP","TRANSMITTER","TOURISM", "WATERTOWER","POWER LINES"],_radius]) select {!(_x getVariable ["MGI_destroyable",false])}; Just an example. All these commands are in BIKI. Cheers. I'm still rather an SQF noob but I've doing bash scripting, Python and Java for a while. Thanks for the examples and references. 1 Share this post Link to post Share on other sites
pierremgi 4739 Posted June 26, 2018 You could add this nuclear script. A must! thanks to Moerderhoschi 1 Share this post Link to post Share on other sites
AZCoder 921 Posted June 26, 2018 You might want to test if AI can shoot through the rubble ... if there is any AI. I've had problems with that in the past and had to tone down the destruction a bit. 1 Share this post Link to post Share on other sites
vihkr 8 Posted June 28, 2018 On 6/26/2018 at 12:05 PM, AZCoder said: You might want to test if AI can shoot through the rubble ... if there is any AI. I've had problems with that in the past and had to tone down the destruction a bit. VCOM 3.0 and ALiVE AI are pretty good at avoiding stuff like that, as they will frequently flank. I may check if it's an issue, thanks. Share this post Link to post Share on other sites
pierremgi 4739 Posted June 28, 2018 On 26/06/2018 at 6:05 AM, AZCoder said: You might want to test if AI can shoot through the rubble ... if there is any AI. I've had problems with that in the past and had to tone down the destruction a bit. Or spawn the AI after... I do prefer placing skeletons and skulls, then alive survivors, rather than killing poor useless AIs in a mushroom 1 Share this post Link to post Share on other sites