Jump to content
mcnools

Trigger activated when any PLAYER is X metres from any OPFOR

Recommended Posts

I'm working on a few missions for my group where we are working a bit covertly in a chaotic country, now, I want us to be able to drive/walk around carefully and not get attacked as long as we don't get too close to armed rebels/other armed forces. I use ALIVE so I need to have a trigger that activates if any PLAYER (on a dedicated server) is within a certain range of any OPFOR-unit (the trigger will then change OPFOR to hostile against us).

 

Is this possible to add as a condition at all, and if it's possible, is it possible to do without affecting performance very much? 

 

To be clear, I want the condition of the trigger to be "if any player is within 25 metres of any OPFOR". 

  • Like 1

Share this post


Link to post
Share on other sites

The undercover script looks great and very in depth, but that's it, for this mission at least I'm looking for a more simple function, but if it's not possible I suppose I'll have to look into that undercover script more. :)

Share this post


Link to post
Share on other sites


{ side _x == opfor && _x distance player < 25 } count allUnits > 0

I think that's right. Change opfor to whatever side suits your needs.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, AZCoder said:

I think that's right. Change opfor to whatever side suits your needs.

 

On 2/4/2018 at 10:00 PM, mcnools said:

I want the condition of the trigger to be "if any player is within 25 metres of any OPFOR".

 

Hello there mcnools !

 

I dont know if this help but take a look .

this will change the enemy side :

I have also add there an example mission.

 

Share this post


Link to post
Share on other sites
On 4/2/2018 at 9:00 PM, mcnools said:

To be clear, I want the condition of the trigger to be "if any player is within 25 metres of any OPFOR". 

 

While this thread has a few good suggestions on alternative undercover script solutions,

something like this might do the trick:

count (allplayers select {count (_x nearentities 25 select {side _x isEqualTo east}) > 0}) > 0

This will return true if any player is within 25m of any opfor unit.

Runs for 0.0082ms on my rig, so no performance issues if only called once every frame.

 

Once 1.81 hits stable branch you can also use findIf, which is a decent bit faster:

allplayers findIf {count (_x nearentities 25 select {side _x isEqualTo east}) > 0} >= 0

Also returns boolean, same as above.

Runs for 0.0052ms, so almost twice as fast than the above example, worth switching once 1.81 hits stable branch.

 

Cheers

  • Like 3

Share this post


Link to post
Share on other sites

@GOM Very good news. The findIf was missing.

 

My two cents: I used to reduce arrays instead of checking a wide "all units".

For example:

{ _x distance player < 25 } count (allUnits select {side _x == East}) > 0

seems to me faster than:

{ side _x == opfor && _x distance player < 25 } count allUnits > 0

 

and, as GOM said:

count (allplayers select {count (_x nearentities 25 select {side _x isEqualTo east}) > 0}) > 0

is a good mean to shrink the arrays.

  • Like 3

Share this post


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

@GOM Very good news. The findIf was missing.

 

My two cents: I used to reduce arrays instead of checking a wide "all units".

For example:

{ _x distance player < 25 } count (allUnits select {side _x == East}) > 0

seems to me faster than:

{ side _x == opfor && _x distance player < 25 } count allUnits > 0

 

and, as GOM said:

count (allplayers select {count (_x nearentities 25 select {side _x isEqualTo east}) > 0}) > 0

is a good mean to shrink the arrays.

 

{ _x distance player < 25 } count (allUnits select {side _x == East}) > 0;//0.16292 ms
{ side _x == opfor && _x distance player < 25 } count allUnits > 0;//0.134753 ms

Taking the findIf example as a reference with 0.0052ms runtime both examples above don't even come close in terms of speed, since nearEntities in such a small radius is pretty darn fast (0.16292 is around 3000% of 0.0052).

Especially since both of your examples only check for one player, not for all players present, assuming 10 players and a linear increase in runtime per player, both examples above can start to impact performance.

 

This showcases how fast findIf is.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the tips guys! I'm going to try and find time to test this weekend.

  • Like 1

Share this post


Link to post
Share on other sites

Sorry for bumping my own thread here, my undercover mission was postponed a bit but is now underway again, I just figured another thing I would like to add apart from the other side turning hostile if your'e too close.

Is there any way to program a condition so that if any blufor player kills an AI from say opfor or independent, that entire side turns hostile towards blufor? we're using alive etc. and the plan is to have opfor and independent fight each other a bit while we move in slightly covertly in the chaos trying to keep out of it. That means I can't program it so the trigger will activate when any unit from opfor/ind dies, it needs to happen if WE kill them so that we can't just stand around picking them off from afar.

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

×