Jump to content
Sign in to follow this  
LLv34_Untamo

Need help in counting objects

Recommended Posts

S!

 

A) Is there a way to determine the number of certain type of objects in an area?

 

B) Is there a way to decrement a counter?

 

What I would want to do is the following:

I want to count the number of destroyed objects around an airfield and when a certain number of objects have been destroyed, set the airfield disabled, declare victory or whatever. I could increment a counter everytime an object is destroyed. But there's a catch: The objects respawn after a set amount of time after being destroyed.

 

So, I would need to decrement the counter everytime an object respawns to keep track of things. But, as far as I know, that seems to be next to impossible, according to RoF forums anyways.

 

Any ideas?

Share this post


Link to post
Share on other sites

Send to destroyed report to a timer then on to the counter. link the same timer to a detective trigger and link the deactivate to the timer. When the timer receives the destroyed report it passes it on to the counter then deactivates itself so no more reports from the object can get through to the counter.

 

Object damage report  -> Trigger: Timer -> Trigger: Counter

                                                    \/

                                                    /\

                                      Trigger: Deactivate    

Share this post


Link to post
Share on other sites

Send to destroyed report to a timer then on to the counter. link the same timer to a detective trigger and link the deactivate to the timer. When the timer receives the destroyed report it passes it on to the counter then deactivates itself so no more reports from the object can get through to the counter.

 

Object damage report  -> Trigger: Timer -> Trigger: Counter

                                                    \/

                                                    /\

                                      Trigger: Deactivate    

 

 

You could replace your Trigger: timer/deactivate pair by a non-resetting 1x counter and you would achieve the same thing, which I do not think is what OP wanted to do. If I understood him correctly, he wants to maintain a count of currently damaged objects, not the count of objects that have been damaged at least once.

 

 

S!

 

B) Is there a way to decrement a counter?

 

 

A resetting counter that counts up to n can be decreased by adding n-1. Send the counter to a 0s timer that is disabled while you are decreasing the counter, and make sure the rest of your mission uses that 0s timer instead of the counter itself, and you should be good to go.

 

I posted a group last week in the pinned thread dedicated to groups. This group implements a counter that can be manually reset to 0. If you modify the "tick-tack" timer pair at the top by a chain of n-1 timer, and update the enabling/disabling logic of the output 0s timer, you should get what you need.

 

If that works, please consider sharing that modified group, I'm sure many will find it very useful. I've been thinking about that functionality for a while, it allows to count the number of players on each side, which makes it possible to fill in empty slots with AIs. That would be a very useful functionality to have outside of prime time, or for servers that are starting and struggling to attract players.

Share this post


Link to post
Share on other sites

You could replace your Trigger: timer/deactivate pair by a non-resetting 1x counter and you would achieve the same thing, which I do not think is what OP wanted to do. If I understood him correctly, he wants to maintain a count of currently damaged objects, not the count of objects that have been damaged at least once.

Yes, I want to be able to count the amount of currently destroyed objects as they get destroyed and respawn.

 

 

A resetting counter that counts up to n can be decreased by adding n-1. Send the counter to a 0s timer that is disabled while you are decreasing the counter, and make sure the rest of your mission uses that 0s timer instead of the counter itself, and you should be good to go.

 

I posted a group last week in the pinned thread dedicated to groups. This group implements a counter that can be manually reset to 0. If you modify the "tick-tack" timer pair at the top by a chain of n-1 timer, and update the enabling/disabling logic of the output 0s timer, you should get what you need.

 

If that works, please consider sharing that modified group, I'm sure many will find it very useful. I've been thinking about that functionality for a while, it allows to count the number of players on each side, which makes it possible to fill in empty slots with AIs. That would be a very useful functionality to have outside of prime time, or for servers that are starting and struggling to attract players.

I saw your resetting timer, but I must say, this goes a wee bit over my head :D ... I am a software designer, but this is a bit too "low level" programming for me :) .. I have engineer friend that works on embedded logics, maybe I will give him a call ;)

Edited by LLv34_Untamo

Share this post


Link to post
Share on other sites

S!

 

I looked at your resetting timer again, Coconut, and I think I now understood how it works... I will give this another thought, maybe I still have hope ;)

 

I seriously do hope that the devs give us better tools in the future though :)

Edited by LLv34_Untamo

Share this post


Link to post
Share on other sites

S!

 

I looked at your resetting timer again, Coconut, and I think I now understood how it works... I will give this another thought, maybe I still have hope ;)

 

I seriously do hope that the devs give us better tools in the future though :)

 

Great! In the mean time, I did the changes to the reset-able counter to turn it into an increase/decrease counter. I was reluctant to do it myself at first because I'm away from my regular PC, but my travel laptop was able to run the FMB and the game, if somewhat uncomfortably.

 

Caveat 1: if you decrease from 0, you end up in n-1. Increasing after that will trigger the output. Not necessarily wrong, but something worth knowing.

 

Caveat 2: It takes n-1 20ms cycles to decrease the counter. If a signal comes in to increase or decrease again while the logic is still going on, things might get wrong.

 

The attached file gives a group for n=3. For other values, insert additional "plus x" timers between "plus 2" and the timer beside it that re-activates the output.

IncDecCounter.zip

Edited by -IRRE-coconut

Share this post


Link to post
Share on other sites

S!

I tried your counter, it didn't seem to do the job I wanted it to do :O ... But, I managed to make my own!
 
IncDecCounter_v3

 

Usage notes:
Decrement counter limit must be one smaller than counter limit.

 

I think the same possible caveats apply to this counter too :)

Edited by LLv34_Untamo
  • Upvote 1

Share this post


Link to post
Share on other sites

Very nicely done Untamo! Your version is nicer, changing the max value is as easy as editing two counters.

Share this post


Link to post
Share on other sites

S!

 

Oh, and thanks for the help guys :)

 

But now that I got the hang of this,  I'm still not satisfied, now I need to go one step further. I need to also get a signal from the counter when I go under the limit. My requirements are getting a bit complex and I'm starting to feel that I need to go LUA with this project. But, is that possible through the mission editor, or will I have to dig into the mission file? :O .. I will try to find out.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...