Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

What I want is that when I order some group of units to Fight.. the units without weapons that is radar and jammer vehicles/kbots would follow(guard) units with the longest range.

Not that hard to do. Most likely I will do it after a while. But someone might do it more professionally.
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by REVENGE »

Hell, I'd be happy if they fixed stupid radar/jammer behavior: walking into a firefight with nothing but a radar dish.
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

REVENGE wrote:Hell, I'd be happy if they fixed stupid radar/jammer behavior: walking into a firefight with nothing but a radar dish.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pressure Line »

iirc thats because BA jammers and radar vechs/bots have fake weapons (for whatever reason, damned if i know) this causes them to leap into the fray. id suggest putting them on hold-fire
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

Pressure Line wrote:iirc thats because BA jammers and radar vechs/bots have fake weapons (for whatever reason, damned if i know) this causes them to leap into the fray. id suggest putting them on hold-fire
what about canattack=0? i dont know if they will still be able to use radar/jammer but if they can then it would be a good idea(going to test....)
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by KDR_11k »

The dummy weapons are so they'll stop when given a fight command instead of ignoring enemies and just marching forward.
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

KDR_11k wrote:The dummy weapons are so they'll stop when given a fight command instead of ignoring enemies and just marching forward.
but when you use attack, they just rush in the enemy, thinking that ther radar beams can kill the enemy or something
User avatar
ginekolog
Posts: 837
Joined: 27 Feb 2006, 13:49

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by ginekolog »

I use this widget so jamers dont charge enemeis:

unit_dontmove.lua
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

BTW does anyone think that this widget should work on moving order too?
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pxtl »

Hoi wrote:
KDR_11k wrote:The dummy weapons are so they'll stop when given a fight command instead of ignoring enemies and just marching forward.
but when you use attack, they just rush in the enemy, thinking that ther radar beams can kill the enemy or something
Perhaps the range of the fake weapon is too short, or an LOS weapon? If it was slightly longer than arty range, they'd park outside of arty radius of their chosen impossible target.

I just wish there was a way to order a unit to maintain a minimum distance to target instead of a maximum one.

How about a Group Guard widget? That is, select group A and order it to guard all units in group B. They get a queue of guard orders that starts with a random unit and then continues to the next random unit in the group, so that if it dies. Wouldn't be useful for some things, but for basic radar-follow behaviour it would help - move your arty units into a group, order radars to group-guard the arties. I do this often with flakkers and my slowest units in a team, but usually I just task them all to one unit, so when it dies they all get lost.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

Pxtl wrote: How about a Group Guard widget? That is, select group A and order it to guard all units in group B. They get a queue of guard orders that starts with a random unit and then continues to the next random unit in the group, so that if it dies. Wouldn't be useful for some things, but for basic radar-follow behaviour it would help - move your arty units into a group, order radars to group-guard the arties. I do this often with flakkers and my slowest units in a team, but usually I just task them all to one unit, so when it dies they all get lost.
Well I ain't signing for that! :twisted:

[EDIT] Though your idea actually isn't that hard to implement. :? But I don't know how to make a right interface for group to group guarding. Then again the Group Label/Grouping or what the widget was called with the 1/2/3/4... groups at a side bar would be useful.
Last edited by Pendrokar on 17 Jul 2008, 17:23, edited 1 time in total.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by CarRepairer »

Retreat + Autoretreat widgets in CA. Radar and jammer vehicles are automatically set to retreat at 90% health. If something dents them, they turn and run home.
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

CarRepairer wrote:Retreat + Autoretreat widgets in CA. Radar and jammer vehicles are automatically set to retreat at 90% health. If something dents them, they turn and run home.
fail they die before they retreated
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

This is how far I've gotten (non-Group Guard version)-

Code: Select all

local radarunitSet = {}
local jammerunitSet = {}

local unitArray = {}
unitArray["radarunitArray"] = {
 
  --radar units
   -----BA-----
  "armseer",
  "armmark",
  "corvrad",
  "corvoyr",}
unitArray["jammerunitArray"] = {

  --jammer units
   -----BA-----
  "armaser",
  "coreter",
  "arm_jammer",
  "core_spectre",
  "armsjam",
  "corsjam",}
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:Initialize()
  if Spring.GetSpectatingState() or Spring.IsReplay() then
    widgetHandler:RemoveWidget()
    return true
  end
  for i, v in pairs(unitArray["radarunitArray"]) do
    radarunitSet[v] = true
  end
  for i, v in pairs(unitArray["jammerunitArray"]) do
    jammerunitSet[v] = true
  end
end

function widget:CommandNotify(commandID, params, options)
  local selUnits = Spring.GetSelectedUnits()
  local count = #selUnits
  table.foreachi(options,Spring.Echo)

  if (count>1) and (commandID == CMD.FIGHT) then
    local radarunittable = {}
    local jammerunittable = {}
    local offensiveunittable = {}
    local countradars = 0
    local countjammers = 0
    local countoffensive = 0
  
    for k,unitID in pairs(selUnits) do
      local udef = Spring.GetUnitDefID(unitID)
      local ud = UnitDefs[udef]
      if (ud ~=nil) and (radarunitSet[ud.name]) then
       --radar unit
       countradars = countradars + 1
       radarunittable[countradars] = unitID
       
      elseif (ud ~=nil) and (jammerunitSet[ud.name]) then
       --jammer unit
       countjammers = countjammers + 1
       jammerunittable[countjammers] = unitID
       
      elseif (ud ~= nil) then
       --other unit
       local wd = ud.weapons[1]
       if (wd ~= nil) then
        local weaponDefID = wd.weaponDef
        if (weaponDefID ~= nil) then
         --offensive unit
         if (WeaponDefs[weaponDefID].range ~= nil) then 
          table.insert(offensiveunittable,{ unitID, WeaponDefs[weaponDefID].range })
          --Spring.Echo("U:",unitID,WeaponDefs[weaponDefID].range)
         end 
         countoffensive = countoffensive + 1
        end
       end  
      end 
    end
    
    if((countradars ~= 0) or (countjammers ~= 0)) and (countoffensive ~= 0) then
      local aradar = 1
      local ajammer = 1
      table.sort(offensiveunittable, compRanges) --reversed sorting, compRanges is a function
      for i in ipairs(offensiveunittable) do
        unitID = offensiveunittable[i][1]
        range = offensiveunittable[i][2]
        if(aradar<countradars+1) then
          Spring.GiveOrderToUnit(radarunittable[aradar], CMD.GUARD, {unitID},options)
          --Spring.Echo("R",radarunittable[aradar], unitID)
          aradar = aradar + 1
        end
        if(ajammer<countjammers+1) then
          Spring.GiveOrderToUnit(jammerunittable[ajammer], CMD.GUARD, {unitID},options)
          --Spring.Echo("J",jammerunittable[ajammer], unitID)
          ajammer = ajammer + 1
        end
        
        -- issue called command

        Spring.GiveOrderToUnit(unitID, commandID, params, options) -- for offensive units to move on with their order
        -- if radars and jammers are more than offensive units they will still go forth with fight order
      end
      -- Override command issue process
      return true
    end
  end
  return false
end

function compRanges(a,b) 
return a[2] > b[2]
end
Problems - Well it kinda works except that queue commands dont! So the offensive units just move on with the last command.
And the radars and jammers will stop if the unit they follow dies. (just haven't added)
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

@pendrokar
i might be wrong, but if you just add canattack=0 to the radars/jammers fbi they wont attack but wait, however this is a solution that creates other problems it would be best if the jammers stay in jamming range but dont attack and the radars in x radar range
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

Hoi wrote:@pendrokar
i might be wrong, but if you just add canattack=0 to the radars/jammers fbi they wont attack but wait, however this is a solution that creates other problems it would be best if the jammers stay in jamming range but dont attack and the radars in x radar range
Im not a dev of either BA, CA or NOTA(doubt other mods have set radars and jammers like that). So I'm the wrong person to whom you should say that. The radar and jammer guarding issue is a mods issue.
User avatar
Hoi
Posts: 2917
Joined: 13 May 2008, 16:51

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Hoi »

Pendrokar wrote:
Hoi wrote:@pendrokar
i might be wrong, but if you just add canattack=0 to the radars/jammers fbi they wont attack but wait, however this is a solution that creates other problems it would be best if the jammers stay in jamming range but dont attack and the radars in x radar range
Im not a dev of either BA, CA or NOTA(doubt other mods have set radars and jammers like that). So I'm the wrong person to whom you should say that. The radar and jammer guarding issue is a mods issue.
i was just suggesting and if it would work i will ask the mod devs to add it
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by yuritch »

Fake weapons on radar units are leftovers from OTA times. Back then the AI didn't know how to use radar units, so they were often given a fake long-range weapon by modders to make the AI bring them closer to battle.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

Ok I uploaded a 0.8 version at Spring Job Jol.
- http://spring.jobjol.nl/show_file.php?id=1294
When ordering a group of units to fight, Any specified in the widget mobile radars or jammers will guard units that have the
longest range. If radars or jammers are more than other units then those will still go with the fight order,

Improvements
needed:
1) After having the Fight order pressed with shift the Fight cursor will change to Move! Need to fix
2) Radars and
Jammers to follow closest units that have the longest range. Right now they will guard a random unit withing the unit range
sort(Means even if there is a unit with the longest range in the group close to a radar unit the radar unit may guard some
other unit).
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget Request/(later)Reveal: Radar&Jammer vehicle follow.

Post by Pendrokar »

2) issue fixed. Though the offensive units are the ones making decisions of which closest radar/jammer to take!
- http://spring.jobjol.nl/show_file.php?id=1294
When ordering a group of units to fight, Any specified in the widget mobile radars or jammers will guard units that have the
longest range. If radars or jammers are more than other units then those will still go with the fight order,

Improvements needed:
1) After having the Fight order pressed with shift the Fight cursor will change to Move! Need to fix
Post Reply

Return to “Lua Scripts”