FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login
    The current pre-release of the client ("pioneer" in the version) is only compatible to itself. So you can only play with other testers. Please be aware!

    radar proximity clusters

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 267 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.
    • N Offline
      nerod10
      last edited by

      I thought of something that works in real life - the ability to hide the number of aircraft displayed on the radar based on their proximity

      I asked GPT and maybe the code she returned matches the requirement:

      -- define a function to calculate the distance between two objects
      function calc_distance(obj1, obj2)
          -- get the x and y coordinates of each object
          local x1, y1 = obj1:getPosition()
          local x2, y2 = obj2:getPosition()
          
          -- calculate the distance between the objects using the distance formula
          local distance = math.sqrt((x2 - x1)^2 + (y2 - y1)^2)
          
          -- return the calculated distance
          return distance
      end
      
      -- define a function to group enemy planes that are in close proximity
      function group_planes(planes, threshold)
          -- create a table to store the groups of planes
          local groups = {}
          
          -- loop through all of the planes
          for i = 1, #planes do
              -- get the current plane
              local plane = planes[i]
              
              -- create a new group for the current plane
              local group = {plane}
              
              -- loop through the remaining planes
              for j = i + 1, #planes do
                  -- get the next plane
                  local other_plane = planes[j]
                  
                  -- calculate the distance between the two planes
                  local distance = calc_distance(plane, other_plane)
                  
                  -- if the distance is below the threshold, add the other plane to the group
                  if distance < threshold then
                      table.insert(group, other_plane)
                  end
              end
              
              -- add the group of planes to the groups table
              table.insert(groups, group)
          end
          
          -- return the groups of planes
          return groups
      end
      
      -- test the group_planes function with a list of planes and a proximity threshold
      local planes = {plane1, plane2, plane3, plane4, plane5}
      local threshold = 50
      local groups = group_planes(planes, threshold)
      
      -- print the groups of planes
      for i, group in ipairs(groups) do
          print("Group " .. i .. ":")
          for j, plane in ipairs(group) do
              print("- " .. plane:getName())
          end
      end
      
      
      1 Reply Last reply Reply Quote 0
      • Ctrl-KC Offline
        Ctrl-K
        last edited by

        noises of cringing

        “Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
        — Steve Jobs.
        My UI Mods
        Support me

        1 Reply Last reply Reply Quote 0
        • K Offline
          Katharsas
          last edited by

          I asked GPT and maybe the code she returned matches the requirement

          Narrator: It didn't.

          1 Reply Last reply Reply Quote 3
          • First post
            Last post