Jump to content
vihkr

Battle Damage Script?

Recommended Posts

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.

  • Like 1

Share this post


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

a script

 

Hello there vihkr !

 

You can check here:

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Many scripts fails to damage all buildings, even BIS_fnc_destroCity... :evil:

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.

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites
6 hours ago, GEORGE FLOROS GR said:

You can check here:

Thanks! The approach with applying random damage worked pretty good.

  • Like 1

Share this post


Link to post
Share on other sites
27 minutes ago, pierremgi said:

Have fun.

 

I did! Here's Chernogorsk from the SE.

 

zf7D82Y.jpg

 

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.

  • Like 1

Share this post


Link to post
Share on other sites

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.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
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.

  • Like 1

Share this post


Link to post
Share on other sites

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.

 

  • Like 1

Share this post


Link to post
Share on other sites
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
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 :f:

  • Haha 1

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

×