Jump to content

Recommended Posts

Posted (edited)

Hi everyone,

 

I am trying to create a bubble-like area with complex trigger that will spawn and despawn certain objects when any aircraft is present at the area. To support more than a single aircraft in the area I need some kind of a counter that gets +1 when someone enters and -1 when someone leaves. The counter should then "trigger" when it reaches 0 - hence, then the area can be unloaded (despawned).

 

I had a look at a couple of existing MP missions, but haven't seen a scheme that can handle multiple aircrafts without issues yet. Does anyone have an idea how to approach this?

 

To illustrate the problem:

 

aircraft A enters alive (counter = 0 + 1 = 1) -> spawn

aircraft B enters alive (counter = 1 + 1 = 2)

aircraft B leaves alive (counter = 2 - 1 = 1)

aircraft A leaves alive (counter = 1 - 1 = 0) -> despawn

 

There is an increment/decrement counter scheme available in the mission blocks sharing topic that seems to work, but it is based on reaching a certain counter value, rather than triggering when empty (at 0).

Edited by Sim
Posted

Let c1 be a cyclic counter up to N

Let g1 be a 0s timer acting as a gate after c1 (c1 output goes into g1).

 

To increase the counter, increase c1

To decrease the counter, deactivate g1, then increase c1 N-2 times, activate g1, increase c1 once more.

 

Make it so that N is larger than the maximum number of planes in the mission (e.g. 49 if AIs are not used or do not trigger the bubble).

  • Upvote 1
Posted

...

 

Nice, just tried this scheme and it seems to work great. Although the bubble is intended for both players and AI, thus the N will need to be somewhat large number. Also, it seems you need to delay the timers at least 20ms before incrementing the counter multiple times. Seeing how I will need to increment them 20+ times, something someday will probably go wrong during this process.

 

Thanks for your help! Still, time to make a suggestion for Mission Editor as this functionality should be definitely available out of the box.

Posted

 

 

Also, it seems you need to delay the timers at least 20ms before incrementing the counter multiple times.

Yes, that could be a problem, but not too likely. If people flying in formation leave the bubble flying at 200kph, it's possible a decrease will be missed (or worse bugs if you forget to disable the input "decrease" 0s timer while decreasing) if people fly closer than 60m together (for N=50). That's quite a tight formation, but not unrealistic, I suppose.

 

To handle that problem, one would need to implement a queue of sorts on the input side. Probably doable, but I'm not sure how yet.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...