OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Luke on 03 Jul 2009, 06:48:57

Title: Setdammage for nearestobjects buildings
Post by: Luke on 03 Jul 2009, 06:48:57
Code: [Select]

_static = nearestobjects [_pos,["Building"], _dist];
{
      [_x,_letpos,_dist] spawn {
      _dude = _this select 0;
      _letpos = _this select 1;
      _dist = _this select 2;
      _dammage=(getdammage _dude)+((_statdist^2)/(((_dude distance _pos)^2)+1));
      _posr = [getpos _dude select 0,getpos _dude select 1,getpos _dude select 2];
       _scale=(random .1) + .95;
      _dude setdammage (_dammage * _scale);
      if ((_dammage * _scale) >=1) then
      {
      deletevehicle _dude;
      };
 } foreach _static;

The buildings stand firm.

How do I solve this?

Luke
Title: Re: Setdammage for nearestobjects buildings
Post by: Trapper on 03 Jul 2009, 10:20:00
I don't know this kind of scripting. Maybe I'm completely wrong.

First of all this wasn't originally created for a building but for a character, was it? _dude?

Some variables are defined and never used?
_letpos, _dist, _posr

Other variables are used but aren't defined?
_statdist,
_pos probably fetched from the main script call?

Then there is this bracket open and I don't find a bracket closed for it:
[_x,_letpos,_dist] spawn {

I don't understand why you would use a deletevehicle command on a map object.

Following to your topic title I would just use one simple line for everything:
_static = nearestobjects [_pos,["Building"], _dist]
{_x setdammage 1} foreach _static


PS:
You don't have to explain this script to me if it's just beyond my knowledge and I was writing crap.  ;)
Title: Re: Setdammage for nearestobjects buildings
Post by: Luke on 06 Jul 2009, 05:38:47
Okay, got it to work, but bridges, fences, and signs do not go down.

What class names do I use for those?

Thanx, as always.

Luke