Jump to content
iV - Ghost

Check for alive objects in trigger area

Recommended Posts

There is a unknown amount of objects (Land_dp_transformer_F) inArea thisTrigger.

How can I count if all alive of this are smaller then 1 (< 1)?

This should be the Trigger condition.

Share this post


Link to post
Share on other sites

i think you need code like this, not sure haven't used triggers much my self:

 

{alive _x} count thislist < 1

 

Share this post


Link to post
Share on other sites

OK. And where is the object defined?

Should I write it like this:

 

{alive "Land_dp_transformer_F"} count thislist < 1;

And what is with the Trigger area ?

 

 

This is my scripted Trigger to check if a minefield is disabled:

// TRIGGER FOR SUCCEEDED END
_triggerSucceeded = createTrigger ["EmptyDetector", [7860.5, 10205.042, 0], true];
_triggerSucceeded setTriggerArea [30, 30, 0, false, 10];
_triggerSucceeded setTriggerActivation ["NONE", "", false];
_triggerSucceeded setTriggerTimeout [8, 8, 8, false];
_triggerSucceeded setTriggerType "NONE";
_triggerSucceeded setTriggerStatements [

    // CONDITIONS
    "{mineActive _x && _x inArea thisTrigger} count allMines == 0",
		
		
    // ON ACTIVATION
    "['Airport_T6', 'Succeeded', false] remoteExec ['BIS_fnc_taskSetState', 0, true];
    ['TaskSucceeded', ['', localize 'STR_iV_TaskSucceeded_Landmines']] remoteExec ['BIS_fnc_showNotification', 0, true];
		
    deleteMarker 'M1';
    {deleteVehicle _x} forEach (getpos thisTrigger nearSupplies 30 select {_x isKindOf 'groundweaponholder'});
		
		
    // ON DEACTIVATION
    ""
		
];

 

In the conditions is what I'm looking for.

But I need it for the generators (Land_dp_transformer_F) and with !alive instead of mineActive and allMines.

Share this post


Link to post
Share on other sites

You didn't choose the easiest building!

The Land_dp_transformer_F is a "terrain" object without any workable class. It simply disappear when destroyed.

Its brother Land_spp_transformer_F, generally not too far,  can be destroyed and you can script with "Land_spp_transformer_F" class.

Don't ask me why so difference in BI classification. Probably because "solar power" was an update.

 

So, anyway, the way to check if your Land_dp_transformer_F is "destroyed" seems to add a trigger, very small area (2m) on the Land_dp_transformer_F position (use editor).

Then, let it none none and add the condition:

count (nearestTerrainObjects [getpos thistrigger,[],triggerArea thistrigger select 0]) == 0

 

The trigger is activated when the Land_dp_transformer_F is destroyed.

You need to do that for each transformer. Then add an ultimate trigger to check if all triggers are activated.

Share this post


Link to post
Share on other sites

land_dp is on Tanoa, and is a terrain object, whereas on Altis, the identical, but slighly different coloured land_spp object is not a terrain object and can be manipulated.

I plan to remove all the land_dp ones in mission init and replace them with the spp type because I want to be able to destroy them in a mission.

Share this post


Link to post
Share on other sites
3 hours ago, Tankbuster said:

 land_spp object is not a terrain object and can be manipulated.
 

????

What the vanilla map could be, Land_dp_transformer_F and Land_spp_transformer_F are terrain objects.

Same for the Land_DPP_01_transformer_F on Tanoa (different color).

But you're right. You can add editable Land_spp_transformer_F object. The "power plant" transformers (Land_dp_transformer_F or Land_DPP_01_transformer_F) seem to be forgotten. I wrote about that above.

The weird thing is you can "destroy" both of them (on Altis, not on Tanoa, see note below). The spp has a ruin model, so it's more "sexy" than the "dp" one which simply disappear.

 

On the other hand, if you want to replace any terrain object Land_dp.... by an edited Land_spp_transformer_F, you have to hide them !
Not so simple with no class.

In a trigger area (example here for TANOA map, see note):
 

{ _dp = _x;
  _dir = getdir _dp;
  _pos = getpos _dp;
  _dp hideObjectGlobal true;
  _spp = "Land_spp_transformer_F" createVehicle _pos;
  _spp setdir _dir
} forEach  ((nearestTerrainObjects [getpos thistrigger,[],triggerArea thistrigger select 0]) select {["dpp_01_trans",getModelInfo _x select 0] call bis_fnc_inString})

 

Note:

ATLIS STRATIS : dp_transformer_f.p3d  // take damage, disappear when destroyed  // can be hidden

TANOA : dpp_01_transformer_f.p3d // can't be damaged (simple object i guess)  // can be hidden

  • Like 1

Share this post


Link to post
Share on other sites

OK. Til now I check if the generators are destroyed by:

 

// TRIGGER FOR SUCCEEDED END
_triggerSucceeded = createTrigger ["EmptyDetector", [5977, 3443, 0], true];
_triggerSucceeded setTriggerArea [0, 0, 0, false, 0];
_triggerSucceeded setTriggerActivation ["NONE", "", false];
_triggerSucceeded setTriggerTimeout [8, 8, 8, false];
_triggerSucceeded setTriggerType "NONE";
_triggerSucceeded setTriggerStatements [
  
    // CONDITIONS
    "!alive ([5977, 3443] nearestObject 86542) && 
     !alive ([5977, 3443] nearestObject 86543) && 
     !alive ([5977, 3443] nearestObject 86956) && 
     !alive ([5977, 3443] nearestObject 86955) && 
     !alive ([5977, 3443] nearestObject 86958) && 
     !alive ([5977, 3443] nearestObject 86957) && 
     !alive ([5977, 3443] nearestObject 86954)",
		
		
    // ON ACTIVATION
    "['Chapoi_T2', 'Succeeded', false] remoteExec ['BIS_fnc_taskSetState', 0, true];
    ['TaskSucceeded', ['', localize 'STR_iV_TaskSucceeded_PowerGenerators']] remoteExec ['BIS_fnc_showNotification', 0, true];
	
    call iV_fnc_taskSucceededNumbers;",
		
		
    // ON DEACTIVATION
    ""
		
];

 Works fine on Malden. But I think the code in the condition could be smaller if I can check for these objects in the trigger area.

Share this post


Link to post
Share on other sites

You're using objectid? Be aware that objectids are not guaranteed to stay the same.

Share this post


Link to post
Share on other sites
On 07/12/2017 at 10:38 AM, iV - Ghost said:

OK. Til now I check if the generators are destroyed by:

 

 Works fine on Malden. But I think the code in the condition could be smaller if I can check for these objects in the trigger area.

Just try it with an edited trigger, placed on your bunch of objects and use this condition:

count ((nearestTerrainObjects [getpos thistrigger,[],triggerArea thistrigger select 0]) select {_x inArea thisTriggger && alive _x}) == 0

 

NB: triggerArea ThisTrigger select 0 works for a square or a radius. Mind for the biggest side for rectangle.

Share this post


Link to post
Share on other sites

Because BI often add map content, changing many of the ids. Ghost Hotel is a case in point. It was added to it's island some time after we first got the island

Share this post


Link to post
Share on other sites

OK. This is not good. I hope this is an "inglorious" part of the past.

I think id's should be persistent and unique for working with.

A lot of my tasks are based on the id of an object what is still present in the map.

Share this post


Link to post
Share on other sites

In my area of operations there are often a lot of other terrain objects which are not part of the mission.

How can I select only the object I want if I use this code:

 

count ((nearestTerrainObjects [getpos thistrigger,[],triggerArea thistrigger select 0]) select {_x inArea thisTriggger && alive _x}) == 0 

 

Share this post


Link to post
Share on other sites

Read the nearestTerrainObjects syntax. I let the [ ] empty because, in your case, all dp-transformer classes don't work. You need some workable class(es) and it's a BI lottery.

You need to adjust your trigger(s) to catch what you really want to delete (hide) and nothing more.

You can filter the dp_transformers as I wrote above (with select):

((nearestTerrainObjects [getpos thistrigger,[],triggerArea thistrigger select 0]) select {["dpp_01_trans",getModelInfo _x select 0] call bis_fnc_inString})

 

The alternate solution is to determine objects' ids.

In 3den, run on console: do3DENAction "ToggleMapIDs";

then work with nearestObject:

([0,0,0] nearestObject 278985) hideObjectGlobal true

 

Share this post


Link to post
Share on other sites

The dpp transformers are type "HOUSE" in the nearestTerrainObjects command, by the way.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Tankbuster said:

The dpp transformers are type "HOUSE" in the nearestTerrainObjects command, by the way.

sure, that can reduce the filtering.

Share this post


Link to post
Share on other sites

OFFTOPIC:

The id's from Malden objects has changed in the past.

Have to change/adjust my whole task system.

 

:dontgetit:

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

×