Jump to content
coconut

How to count kills of vehicles in a column

Recommended Posts

Here is a little problem I solved that I thought I would share.

 

In one of my missions, I wanted to detect when a tank column was entirely destroyed. The solution seems simple enough: link the "OnKilled" event of each tank to a counter whose max value is set to the number of tanks in the column.

 

This did not work: the counter reached its max value as soon as half of the tanks had been destroyed. Apparently each kills were being counted twice.

 

The image below shows the solution, which consists of adding a 1x counter to the column leader:

 

post-31381-0-07985200-1428912567_thumb.jpg

 

Why is that needed? Here is what I think was happening:

  1. Leader was killed by an AT gun. That's one kill
  2. Next tank in line becomes leader. This tank inherits the "OnKilled" event from the leader, and retains its own "OnKilled" event.
  3. New leader gets killed. That kill is counted twice. Once as leader, once as member.
  4. goto 2.

My solution ensures that the leader kill is counted only once. Another solution would be to add a 1x counter to each tank in the column. That would work too, I suppose.

 

I also expect the same problem and solution to apply to planes in wings.

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Thanks a useful tip, Your solution in the image looks nice and compact

Share this post


Link to post
Share on other sites

FYI and YMMV -- but I have had various issues trying to accurately count deaths of anything in a group. Situations where weird stuff occurred was:

a) as you described above; double counting; which I would only get sometimes. Also, if non-leader was killed; sometimes no message was sent; then when the  leader died inconsistent numbers of "onKilled" hits.

b) When something like a large bomb destroys all units in a column very quickly. Often just one message. 

c) Also found planes to behave differently from ground units. 

d) Still inconsistent but different results if all members of  group are wired into "OnKilled" messages vs only the leader.

e) Additionally, I've had strange counts when all the units targeted their "OnKilled" message to a single trigger vs each unit having it's own dedicated ( i used timers ) trigger for it's events.

 

I had a test mission that showed the various things in RoF -- I may not be able to find it; but if I can I'll attach.

Share this post


Link to post
Share on other sites

I also expect the same problem and solution to apply to planes in wings.

I've done a test in one of my missions and unfortunatly it doesn't fix the problems when counting planes.

Share this post


Link to post
Share on other sites

I solved inconsistencies by linking onKilled events of all tanks in a column to a timer of 200ms which acts as a "gate", then linking the timer to a counter. It seems the 2nd count is a bit late so it effectively stops it from counting twice and solving my issue, which was counting one kill as 17 kills (the entire column). This prevents the game counting simultaneous kills from a 2500kg bomb or something, but that is a non-factor for my mission since the tanks are very spread out.

 

For the OP's example...what happens if something other than the leader gets killed?

Edited by AbortedMan

Share this post


Link to post
Share on other sites

These reports of OnKilled inconsistencies get me a bit worried. If there are bugs in such fundamental building blocks, it's important to get them fixed. So far I haven't experienced any weirdness beside the initial problem I managed to solve, but I'll keep an eye open for those. I'm not sure I've understood the exact problems others were experiencing, but I'll try to write test cases to figure out exactly how OnKilled works and how counters work. I wonder for instance if counters can properly count two events that happen simultaneously.

 

A more robust solution, if needed, could simply be to have each tank OnKilled output link connected to a 1x counter. And if the total kills counter has problems registering simultaneous kills, connect each 1x counter to a timer, and have each timer have different delays that are multiple of 20ms (which appears to be the length of a simulation step). And to top it all, to cover the case where a unit that has not been killed raises its OnKilled event erroneously, delete any unit that raises an OnKilled event (so that what the player sees remains consistent with the logic).

 

I solved inconsistencies by linking onKilled events of all tanks in a column to a timer of 200ms which acts as a "gate", then linking the timer to a counter. It seems the 2nd count is a bit late so it effectively stops it from counting twice and solving my issue, which was counting one kill as 17 kills (the entire column). This prevents the game counting simultaneous kills from a 2500kg bomb or something, but that is a non-factor for my mission since the tanks are very spread out.

 

For the OP's example...what happens if something other than the leader gets killed?

 

I don't understand what the 200ms counter (or counters? Is it one per tank?) does. Wouldn't it just shift the problem 200ms later?

 

Regarding my example: The non-leader gets killed, its OnKilled event is raised and its death is counted (the counter gathering the total amount of kills is not visible on the picture, sorry if that was confusing).

Share this post


Link to post
Share on other sites

Mmmmm... In my learning process with editor i built 4 different vehicles groups with Onkilled event on the same mission. Every group is done with a leader and 4-5 targeted vehicles (to leader), but my counter work fine. :huh:  

Share this post


Link to post
Share on other sites

I don't understand what the 200ms counter (or counters? Is it one per tank?) does. Wouldn't it just shift the problem 200ms later?

This may be a different issue than yours altogether, but when I would spawn a group of tanks and they'd start getting attacked (or killed themselves due to crappy pathfinding) 3 or 4 kills would count up to and over 17 (17 was the total number of tanks in the column). This was in an online environment, so it seemed to me that the message of "onKilled" was being sent multiple times for one tank maybe due to lag or UDP packets being resent due to error checking/lag prediction (I dunno). The 200ms time gate seemed to filter all the erroneous counts of onKilled. I'm not sure how timers handle multiple pings...as in, do they restart their timer, start another parallel timer, or ignore any pings while the first timer is still counting...I was betting on the latter being true and it seemed to be so since the 200ms timer seemed to "absorb" the extra onKilled pings, but I haven't done any definitive testing on that...I just kinda threw it together and it seemed to work.

Share this post


Link to post
Share on other sites

Did you test in single mission where lag has no effect. I thing there is the same problem with Object stationnary and alive in the trigger complex. I asked to someone else to check.

Share this post


Link to post
Share on other sites

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...