Jump to content
Kreu

Dead units automatically get deleted from array.

Recommended Posts

I made a small scenario to test the behaviour of arrays. I placed two BLUFOR soldiers inside an Trigger. Trigger name is ar1. Trigger activation is BLUFOR present.
I then execute forces = list ar1;

forces is now an array with two units.

Now if i kill one of those units, it automatically gets removed from the array forces.
I always thought i have to that myself.
This doesn't match with the experiences i previously made.
In another mission im currently creating, dead units seem to stay in my arrays.

 

So what is your knowledge about this topic?

 

Share this post


Link to post
Share on other sites
7 minutes ago, Kreu said:

I then execute forces = list ar1;

 

I don't understand how this could work because list is supposed to take trigger as parameter

 

to make the list stay and not change you have to use the + operator to copy the list to forces

 

like so:

forces = +(list triggerOne)

 

more info: https://community.bistudio.com/wiki/list

 

 

 

Share this post


Link to post
Share on other sites

I guess you mean you made a ”trigger” and not ”array”. (Since you mention ”activation”).

 

In that case it is maybe the trigger that manages the list (the array). And killing a unit and running ”list trigger” again returns the ones alive.

 

An ordinary array will not delete dead units, and empty items (removed units) will have value null (like objNull if it is a soldier).

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, engima said:

In that case it is maybe the trigger that manages the list (the array).

 

yep. list gives pointer to the trigger's array so the list returned will change. As the wiki states https://community.bistudio.com/wiki/list

  • Thanks 1

Share this post


Link to post
Share on other sites
15 minutes ago, gc8 said:

 

I don't understand how this could work because list is supposed to take trigger as parameter

 

to make the list stay and not change you have to use the + operator to copy the list to forces

 

like so:


forces = +(list triggerOne)

 

more info: https://community.bistudio.com/wiki/list

 

 

 

Sorry i meant trigger not array. My bad 🤦‍♂️

 

9 minutes ago, engima said:

I guess you mean you made a ”trigger” and not ”array”. (Since you mention ”activation”).

 

In that case it is maybe the trigger that manages the list (the array). And killing a unit and running ”list trigger” again returns the ones alive.

 

An ordinary array will not delete dead units, and empty items (removed units) will have value null (like objNull if it is a soldier).

Yeah i meant trigger. My bad 🤦‍♂️

 

7 minutes ago, gc8 said:

 

yep. list gives pointer to the trigger's array so the list returned will change. As the wiki states https://community.bistudio.com/wiki/list

Ah thanks. Thats very interresting and quite convinient.

Share this post


Link to post
Share on other sites

Yep, I always asked me why a non-repeatable trigger, once triggered, continues to check for a list every 0.5 second.

Share this post


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

Yep, I always asked me why a non-repeatable trigger, once triggered, continues to check for a list every 0.5 second.

 

Why do you think it does? Maybe it is updated only when you execute the list command?

Share this post


Link to post
Share on other sites

Simple test:

non repeatable trigger BLUFOR PRESENT  in on act field: 0 = thisTrigger spawn { while {triggerActivated _this} do {sleep 0.5; systemChat format ["list : %1",list _this] }};

 

If blufor present, the code run (once), trigger is definitely activated (non repeatable), list is updated. Here the 0.5 sleep is not related to the periodic check of the trigger. You can "on each frame" a code if you want.

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

×