• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login
FAForever Forums
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login

Weapon target check intervals

Scheduled Pinned Locked Moved Suggestions
41 Posts 18 Posters 4.7k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    Brutus5000 FAF Server Admin
    last edited by Brutus5000 13 May 2022, 07:56

    I'm not really into the details, but checking the same thing over and over again seems a bit weird, when there are good data structure such as a priority queue.

    Assuming the engine gives us access to events (a) a target entered turret range (b) a target left turret range (c) a target is no longer accessible (destroyed/submerge/lifted off).
    For a) Determine the targets priority and add it to the priority queue.
    For b) Delete it from the priority queue
    For c) Delete it from the priority queue
    For d) A user changes the priority: recalculate priority queue (but with same targets)

    For determining the current target: Take the first item from the priority queue.

    No need to iterate over all targets in range every recheck interval.

    He said, "I've been to the year 3000
    Not much has changed, but they live underwater
    And your great-great-great-granddaughter
    Is playin' FAF, playin' FAF"

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jip
      last edited by 13 May 2022, 08:11

      The targets are computed in the engine. We only have the parameters and the output that we can work with in Lua. Anything else requires assembly patches.

      A work of art is never finished, merely abandoned

      1 Reply Last reply Reply Quote 0
      • K Offline
        KaletheQuick
        last edited by 13 May 2022, 17:52

        Would it be possible to enforce some limit on target priorities? Like t1 can have 2 priorities, then some "ALLUNITS" catchall, t2 4, t3 6, exp 8? And enforce it so ATP mods don't interfere?

        Or would batching or target sharing be possible? Like one unit of a type can just 'give' its target to a nearby unit of the same type? Or I guess a unit searching for a target asks nearby allies of the same type for their target, checks if it's in range/valid, and then if not proceeds with a whole target check?

        You must deceive the enemy, sometimes your allies, but you must always deceive yourself!

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jip
          last edited by 13 May 2022, 20:53

          Would it be possible to enforce some limit on target priorities? Like t1 can have 2 priorities, then some "ALLUNITS" catchall, t2 4, t3 6, exp 8? And enforce it so ATP mods don't interfere?

          That is what I'd like to have - yes. Perhaps not that extreme, anywhere between 4 to 6 is fine. But 10+ is a bit much. The balance team isn't quite in favor yet.

          Or would batching or target sharing be possible? Like one unit of a type can just 'give' its target to a nearby unit of the same type? Or I guess a unit searching for a target asks nearby allies of the same type for their target, checks if it's in range/valid, and then if not proceeds with a whole target check?

          I'm afraid that finding nearby units is a similar query to finding nearby targets 😉 .

          A work of art is never finished, merely abandoned

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jip
            last edited by Jip 15 May 2022, 10:47

            I've given this some thought and I think we can have a good compromise.

            We can make a distinction between the 'primary' purpose of the unit and all the 'secondary' things that a unit can do too.

            As an example, take the T2 UEF Transport. The primary purpose of the transport is to transport units. It is accompanied by two air to ground guns and two air to air guns with the following statistics:

            -- air to ground
            
            -- damage related
            Damage = 3,
            RateOfFire = 3,
            
            -- performance related
            TargetCheckInterval = 0.3,
            AlwaysRecheckTarget = true
            TargetPriorities = {
                '(ALLUNITS - SPECIALLOWPRI)',
            },
            
            -- air to air
            
            -- damage related
            Damage = 12,
            RateOfFire = 1,
            
            -- performance related
            TargetCheckInterval = 0.5,
            TargetPriorities = {
                '(ALLUNITS - SPECIALLOWPRI)',
            },
            

            We can all agree that the weapons are not impressive. We can also all agree that nobody would ever use a t2 transport for anything beyond transporting units. These weapons primarily exist for aesthetics.

            Similarly, we can identify that:

            • The weapons of scouts (with the Selen as exception) are secondary to the purpose of the scout
            • The anti air weapons of frigates are secondary to the purpose of a frigate
            • The anti air weapons of destroyers are secondary to the purpose of a destroyer
            • The direct fire weapons of cruisers are secondary to the purpose of a cruiser
            • The anti air weapons of any tech 3 naval vessel (with the air carriers as exception) are secondary to their purpose
            • The anti air weapons on the average gunship / bomber (with the restorer as an exception) are secondary to their purpose
            • The anti air weapons of the average ground experimental is secondary to their purpose

            And we can find some more candidates by looking individual units.

            Performance

            With that we define the 'primary' weapons to be the weapons that the unit is supposed to be using, and all other weapons are 'secondary' to give the game a more aesthetical feeling.

            We can immediately see the impact on a reasonable scenario. Take 100 frigates in formation with 300 hostile ASF patrolling in the center of the formation.

            0770f58d-2f55-4df2-b722-fecb06ff7442-image.png
            Current situation, game is running at about 10 - 12 ms / tick, with a sudden jump to 25 - 28 ms / tick about every second

            f798f6b5-743c-4f46-b4e3-75ebeb589b79-image.png
            With the suggested changes of the next chapter, game is steadily running somewhere between 8 to 10 ms / tick and there's no sudden jump

            Changes

            With all of that said, I'm suggesting the following changes for primary / secondary weapons:

            Primary weapons

            TargetCheckInterval = math.max((0.5 * (1.0 / RateOfFire)), 0.5)
            AlwaysRecheckTarget = true
            TargetPriorities = { something between 4 to 6 elements }

            This means that primary weapons can respond to change, they can have decent target priorities and their check interval is reasonably fast in comparison to their attack speed.

            One exception: the primary weapons of an experimental unit are allowed to have a lower target check interval and have additional target priorities.

            Secondary weapons

            TargetCheckInterval = math.max((1.0 * (1.0 / RateOfFire)), 1.0)
            AlwaysRecheckTarget = false
            TargetPriorities = { ALLUNITS }

            This means that the secondary weapons are unable to respond to change, have a lower target check interval and they make no distinction between valid targets.

            What is next

            Unless I've been persuaded of anything else I will push this through into the game in about two weeks. Therefore use this topic to discuss this - what are the pros and cons? Is it worth the performance? Should we do this or not?

            I also highly recommend everyone to replicate the scenario used in the performance section. You can view the sim time (ms / tick) by opening the console (using ~ hotkey) and then typing ren_ShowNetworkStats. If it suddenly closes, type an e first and then remove it again.

            A work of art is never finished, merely abandoned

            M 1 Reply Last reply 15 May 2022, 12:16 Reply Quote 0
            • M Offline
              maudlin27 @Jip
              last edited by maudlin27 15 May 2022, 12:16

              @jip While I agree in principle with the idea of having simple checks for a secondary weapon where that weapon's effect is negligible, I'd disagree with making it as broad as 'if it's not the primary purpose then downgrade it'.

              As an example, you mention cruisers with direct fire weapons. Sometimes I will build a Cybran cruiser for the primary purpose of using its direct fire weapon, since on some maps it's the optimal unit for taking out a firebase (although having said that I dont actually know what its default priorities are so maybe it wouldnt make much difference).

              Seraphim sub hunters would be another example where you might build them both for the AA and for the anti-sub capabilities.

              Other examples where you might build a unit for a combination of its weapons/non-primary purpose would be restorers, and in theory continentals (although in practice they're a bit too weak to use efficiently as a combat unit that can also sometimes transport units)

              I'd therefore suggest a stricter threshold, where the weapon must both be a secondary purpose, and also be very bad at that secondary purpose. So for example a fatboy's anti-air or a transport's air to ground would fall into that category, but a Seraphim sub hunter's AA or a Cybran cruiser's direct fire attack wouldnt.

              M27AI and M28AI developer; Devlogs and more general AI development guide:
              https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
              https://forum.faforever.com/topic/5331/m28ai-devlog-v150

              1 Reply Last reply Reply Quote 1
              • J Offline
                Jip
                last edited by Jip 15 May 2022, 12:25

                As an example, you mention cruisers with direct fire weapons. Sometimes I will build a Cybran cruiser for the primary purpose of using its direct fire weapon, since on some maps it's the optimal unit for taking out a firebase (although having said that I dont actually know what its default priorities are so maybe it wouldnt make much difference).

                This is an example where I would not consider their direct fire a 'secondary' weapon. They actually do decent damage, they can actually take out a unit. I was thinking of the UEF / Aeon cruisers when writing this 🙂

                Seraphim sub hunters would be another example where you might build them both for the AA and for the anti-sub capabilities.

                Another example where it is not a 'secondary' weapon in the sense that it can actually take out a torpedo bomber.

                I'd therefore suggest a stricter threshold, where the weapon must both be a secondary purpose, and also be very bad at that secondary purpose.

                I agree - you phrased it better than I did.

                A work of art is never finished, merely abandoned

                1 Reply Last reply Reply Quote 1
                • S Offline
                  snoog
                  last edited by 15 May 2022, 12:48

                  Everything here sounds pretty good to me. I personally hate when units decide to change targets themselves and leave a unit nearly dead. Unfortunate we hit another limit of not having engine access though. That said, good job working with what you have access to Jip.

                  J 1 Reply Last reply 15 May 2022, 13:11 Reply Quote 0
                  • J Offline
                    Jip @snoog
                    last edited by 15 May 2022, 13:11

                    @snagglefox said in Weapon target check intervals:

                    Everything here sounds pretty good to me. I personally hate when units decide to change targets themselves and leave a unit nearly dead. Unfortunate we hit another limit of not having engine access though. That said, good job working with what you have access to Jip.

                    Me too - I'd prefer them to just fire away. But that is something to discuss with the balance team.

                    A work of art is never finished, merely abandoned

                    U 1 Reply Last reply 15 May 2022, 13:23 Reply Quote 0
                    • U Offline
                      Unknow
                      last edited by 15 May 2022, 13:23

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • U Offline
                        Unknow @Jip
                        last edited by 15 May 2022, 13:23

                        @jip Is it available on faf dev branch?

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          Jip
                          last edited by Jip 15 May 2022, 13:24

                          No - it is not.

                          edit: i'll make a small sim mod in this case, to allow you to reproduce the results of the performance test.

                          edit: here it is

                          ad3a2940-1d96-43a8-b5f5-e9980007b499-image.png

                          You can find the unit in the cheat menu:

                          8c079b7c-72a0-4a7a-93f7-fdba2e0f6abf-image.png

                          No other unit is adjusted. The unit in question also doesn't die properly. This mod is purely for making the performance comparison 🙂 .

                          Make sure to match the situation:

                          c8cf6e28-3339-4fdf-bc92-75c02ceb1fed-image.png

                          And restart when testing for different units.

                          The scenario in question:

                          • 100 frigates in formation
                          • 300 asf patrol in the center of the frigates (that are in formation)
                          • look at sim time by using the console command ren_ShowNetworkStats

                          Make sure to do a full restart of the map to prevent lingering units / wrecks from impacting the results.

                          A work of art is never finished, merely abandoned

                          1 Reply Last reply Reply Quote 0
                          • B Offline
                            Brannou
                            last edited by Brannou 15 May 2022, 15:57

                            I'm wondering how does the advanced targeting mod impact the sim and with the retargeting intervals?

                            It's not part the game but it's used quite often

                            J 1 Reply Last reply 15 May 2022, 16:07 Reply Quote 0
                            • J Offline
                              Jip @Brannou
                              last edited by 15 May 2022, 16:07

                              @brannou said in Weapon target check intervals:

                              I'm wondering how does the advanced targeting mod impact the sim and with the retargeting intervals?

                              It's not part the game but it's used quite often

                              Some of them are quite simple, others are terrible.

                              priorityTables = {
                                  ACU = "{categories.COMMAND}",
                                  Power = "{categories.ENERGYPRODUCTION * categories.STRUCTURE}",
                                  PD = "{categories.DEFENSE * categories.DIRECTFIRE * categories.STRUCTURE}",
                                  Units = "{categories.MOBILE - categories.COMMAND - categories.EXPERIMENTAL - categories.ENGINEER}",
                                  Shields = "{categories.SHIELD}",
                                  EXP = "{categories.EXPERIMENTAL}",
                                  Engies = "{categories.ENGINEER * categories.RECLAIMABLE}",
                                  Arty = "{categories.ARTILLERY}",
                                  Fighters = "{categories.AIR * categories.ANTIAIR - categories.EXPERIMENTAL}",
                                  SMD = "{categories.TECH3 * categories.STRUCTURE * categories.ANTIMISSILE}",
                                  Gunship = "{categories.AIR * categories.GROUNDATTACK}",
                                  Mex = "{categories.MASSEXTRACTION}",
                                  Snipe = "{categories.COMMAND, categories.STRATEGIC, categories.ANTIMISSILE * categories.TECH3, "..
                                      "categories.MASSEXTRACTION * categories.STRUCTURE * categories.TECH3, categories.MASSEXTRACTION * categories.STRUCTURE * categories.TECH2, "..
                                      "categories.ENERGYPRODUCTION * categories.STRUCTURE * categories.TECH3, categories.ENERGYPRODUCTION * categories.STRUCTURE * categories.TECH2, ".. 
                                      "categories.MASSFABRICATION * categories.STRUCTURE, categories.SHIELD,}",
                                  Naval = "{categories.MOBILE * categories.NAVAL * categories.TECH3, categories.MOBILE * categories.NAVAL * categories.TECH2, categories.MOBILE * categories.NAVAL * categories.TECH1}",
                                  Bships = "{categories.BATTLESHIP}",
                                  Destros = "{categories.DESTROYER}",
                                  Cruiser = "{categories.CRUISER}",
                                  SACU = "{categories.SUBCOMMANDER}",
                                  Factory = "{categories.TECH3 * categories.STRUCTURE * categories.FACTORY, categories.TECH2 * categories.STRUCTURE * categories.FACTORY, categories.TECH1 * categories.STRUCTURE * categories.FACTORY}",
                              },
                              

                              As an example, the Snipe version is terrible. But a lot of them are quite simple, and in general better for performance. It influences the TargetPriorities property, it doesn't influence anything else.

                              A work of art is never finished, merely abandoned

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                Turinturambar Balance Team
                                last edited by 15 May 2022, 18:34

                                transport anti ground weapons are for ghettos gunships and therefore have an important role

                                Forumpros doing balance https://www.youtube.com/watch?v=4wTcguJZh3A .
                                When a canis player remembers to build more than 3 units https://www.youtube.com/watch?v=7hjp8xJHuyA .

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  Jip
                                  last edited by 15 May 2022, 19:14

                                  I'm not suggesting to remove them. Just to make them less responsive and significantly cheaper on the simulation.

                                  A work of art is never finished, merely abandoned

                                  1 Reply Last reply Reply Quote 0
                                  • B Offline
                                    Blade_Walker
                                    last edited by Blade_Walker 16 May 2022, 20:21

                                    I think for all anti-air as a secondary, you want to at least include HIGHPRIO, and then all other units in the priorities.

                                    Otherwise you will have, say destros or battleships simply dying to scouted mercies...

                                    If Advanced Target Priorities is still available, and would act to immediately override the defaults and prompts a target check when it is selected, then I don't see a downside to making this change for rank and file units, bring on the uber simspeed !

                                    1 Reply Last reply Reply Quote 0
                                    • J Offline
                                      Jip
                                      last edited by 16 May 2022, 20:25

                                      High priority is not used by mercys. See also this list:

                                      • https://pastebin.com/fZ7Mcrep

                                      It is commonly used for campaign related units and the CZAR 🙂 .

                                      Otherwise you will have, say destros or battleships simply dying to scouted mercies...

                                      I'd say this is fine if you choose to send in units with no proper air support. Any additional proper AA would prioritize the mercies and take them out. But we could, I suppose, have AA prioritize bombers / gunships and then everything else 🙂 . That is still quite simple and low on simulation costs.

                                      If Advanced Target Priorities is still available

                                      That remains available, just like Snipe mode will remain.

                                      A work of art is never finished, merely abandoned

                                      B 1 Reply Last reply 16 May 2022, 23:42 Reply Quote 0
                                      • J Jip referenced this topic on 16 May 2022, 21:12
                                      • B Offline
                                        Blade_Walker @Jip
                                        last edited by 16 May 2022, 23:42

                                        @jip said in Weapon target check intervals:

                                        High priority is not used by mercys. See also this list:

                                        • https://pastebin.com/fZ7Mcrep

                                        It is commonly used for campaign related units and the CZAR 🙂 .

                                        Otherwise you will have, say destros or battleships simply dying to scouted mercies...

                                        No I mean mercies have 'HIGHPRIAIR' as one of their unit categories, not shared by any others AFAIK, and unit anti-air, even minor, has this as first priority, and mercies with their 10 hps are straight countered by it, as long as they are not just blips.

                                        I'd say this is fine if you choose to send in units with no proper air support. Any additional proper AA would prioritize the mercies and take them out. But we could, I suppose, have AA prioritize bombers / gunships and then everything else 🙂 . That is still quite simple and low on simulation costs.

                                        I'd say this would be a rather large balance change 🙂 so I would definitely want this added to all the secondary AA at least, over bombers or gunships

                                        J 1 Reply Last reply 17 May 2022, 06:08 Reply Quote 0
                                        • J Offline
                                          Jip @Blade_Walker
                                          last edited by Jip 17 May 2022, 06:08

                                          @black_wriggler said in Weapon target check intervals:

                                          I'd say this would be a rather large balance change so I would definitely want this added to all the secondary AA at least, over bombers or gunships

                                          Don't worry, that is what the balance team is for to make a compromise with 🙂 .

                                          A work of art is never finished, merely abandoned

                                          1 Reply Last reply Reply Quote 0
                                          • J Jip referenced this topic on 23 May 2022, 18:10
                                          26 out of 41
                                          • First post
                                            26/41
                                            Last post