OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: sharkattack on 11 Jun 2009, 21:40:31

Title: object destruction
Post by: sharkattack on 11 Jun 2009, 21:40:31
hi lads

how could i set up a trigger/ script  to detect if a certain building class  has been destroyed

only way i can do it at the min is to list all possible object ids ... ???

any tips on an easier way  would be much appreciated

best wishes  :good:
Title: Re: object destruction
Post by: Spooner on 12 Jun 2009, 02:54:44
Code: (init line for a logic in the middle of the map area you are using) [Select]
{ _x addEventHandler ["KILLED", { _this execVM "somethingWentBoom.sqf" }] } forEach nearestObjects [this, ["CheeseFactory", "BigHouse"], 1000];
I made up the classnames (you didn't specify what you were searching for), but this would mean that it would add killed handlers to all objects that inherited from CheeseFactory or BigHouse within 1000m of the logic.

Title: Re: object destruction
Post by: sharkattack on 12 Jun 2009, 18:06:46
thanks a million mate ...
just tried it ... works a treat ..  :good:

Title: Re: object destruction
Post by: Kessler on 25 Jun 2009, 05:43:47
is it possible to say, make a seek and destroy waypoint, use this script and blow up.. 'said barracks' and waypoint complete? Also, use this same method to triggered victory for killing 'units'?
Title: Re: object destruction
Post by: sharkattack on 26 Jun 2009, 17:53:05
having similar trouble  trying to  setdamage 1 to  work on certain buildings within a set area
statues in this example

{_x setDamage 1} foreach (position target1 nearObjects ["Land_A_statue01", "Land_A_statue01", 500]);


anyone tell me where im going wrong  with the code  cant get it to work

many thanks  and best wishes
Title: Re: object destruction
Post by: mikey on 26 Jun 2009, 19:48:13
from what I see in my rpt-file, nearObjects only accepts 1 or 2 arguments (while you give it 3). If you want to check for multiple types, use nearestObjects.

btw, you're using the same object type twice?
Title: Re: object destruction
Post by: sharkattack on 26 Jun 2009, 23:54:36
oops should of read

{_x setDamage 1} foreach (position target1 nearObjects ["Land_A_statue01", "Land_A_statue02", 500]);

thanks mikey 
will try nearestObjects

nice one mate   :good:
Title: Re: object destruction
Post by: sharkattack on 08 Jul 2009, 14:31:59
both codes work perfectly thanks a million lads .

however ... would it be possible to include a count to spooners code so that the somethingwentboom.sqf was only fired when say 5 of the "cheesefactorys" were destroyed ?

Code: [Select]
{ _x addEventHandler ["KILLED", { _this execVM "somethingWentBoom.sqf" }] } forEach nearestObjects [this, ["CheeseFactory", "BigHouse"], 1000];


many thanks and best wishes and  long live ofpec

Title: Re: object destruction
Post by: Spooner on 08 Jul 2009, 16:19:49
Easiest to deal with this in the handler script:
Code: (somethingWentBoom.sqf) [Select]
if (isNil "boomCounter") then { boomCounter = 0 };

boomCounter = boomCounter + 1;

// <-- Do stuff every time.

if (boomCounter == 5) then
{
  // <-- Do stuff on 5th destroyed.
};
Title: Re: object destruction
Post by: sharkattack on 13 Jul 2009, 17:54:05
thank you works a charm !   :good: