REQ: Wiget Auto D-gun?

REQ: Wiget Auto D-gun?

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

Moderator: Moderators

Super Mario
Posts: 823
Joined: 21 Oct 2008, 02:54

REQ: Wiget Auto D-gun?

Post by Super Mario »

That way you don't have to click on the G-gun button everytime when attacking something. I don't know how to program though...
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: REQ: Wiget Auto D-gun?

Post by Pendrokar »

Super Mario wrote:I don't know how to program though...
Then you know everything about movement prediction? :shock:
I once questioned that! - viewtopic.php?f=23&t=13465&hilit=prediction
(regrettably I did not understand ILMTitan's evaluation) :?

Well I wanted to create a helper widget which draws circles of where you need to shoot the D-gun but what you want is an A.I.
Super Mario
Posts: 823
Joined: 21 Oct 2008, 02:54

Re: REQ: Wiget Auto D-gun?

Post by Super Mario »

I just want the COM to shoot D-guns automatically when attacking something.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: REQ: Wiget Auto D-gun?

Post by Pendrokar »

Super Mario wrote:I just want the COM to shoot D-guns automatically when attacking something.
Then he would shoot down anything behind the enemy unit(of course an if function is possible) and wouldn't be more effective than a skilled player because of possible less hits for more units if you know what I mean. :roll:
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: REQ: Wiget Auto D-gun?

Post by REVENGE »

I considered doing this, but it's to the point where I believe it's taking over some essential micro actions that should be done by the player, and not by an algorithm.

Although I must say, this is a fairly important piece of code for a competent AI to have.
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: REQ: Wiget Auto D-gun?

Post by Tribulexrenamed »

noob

Also dont click, press D
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: REQ: Wiget Auto D-gun?

Post by quantum »

Here you go!

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function widget:GetInfo()
  return {
    name      = "Auto D-Gunner",
    desc      = "Gives a d-gun order on units in range.",
    author    = "quantum",
    date      = "Oct, 26, 2008",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = true  --  loaded by default?
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local commIDs = {}
local lastAttack = 0

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function widget:UnitCreated(unitID, unitDefID)
  if (UnitDefs[unitDefID].isCommander) then
    for _, weaponData in ipairs(UnitDefs[unitDefID].weapons) do
      local wd = WeaponDefs[weaponData.weaponDef]
      if (wd.name:lower():find"disintegrator") then
        commIDs[unitID] = wd.range
      end
    end
  end
end


function widget:UnitDestroyed(unitID)
  commIDs[unitID] = nil
end


function widget:Initialize()
  for _, unitID in ipairs(Spring.GetAllUnits()) do
    widget:UnitCreated(unitID, Spring.GetUnitDefID(unitID))
  end
end


function widget:Update(dt)
  if (Spring.GetGameSeconds() - lastAttack < 0.2) then
    return
  end
  for unitID, range in pairs(commIDs) do
    if (not Spring.GetUnitIsDead(unitID)) then
      local nearestEnemy = Spring.GetUnitNearestEnemy(unitID, range)
      if (nearestEnemy) then
        Spring.GiveOrderToUnit(unitID, CMD.DGUN, { nearestEnemy },{})
        lastAttack = Spring.GetGameSeconds();
      end
    end
  end
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: REQ: Wiget Auto D-gun?

Post by REVENGE »

Meh... :?
I hope people won't start demanding widget whitelists because of this! :P
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: REQ: Wiget Auto D-gun?

Post by Pendrokar »

Code: Select all

Spring.GiveOrderToUnit(unitID, CMD.DGUN, { nearestEnemy },{})
"Bam... miss Bam... miss Bam... miss Bam... Oh finally a lucky shot yuhu! whups there was a friendly krogoth behind that one. BBBBUUUUUMMMM!!!"
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: REQ: Wiget Auto D-gun?

Post by Noruas »

Well its good but bad at the same time, it forces the commander to move by itself, if i could just move it and let the widget worry about the aiming part itd be great. :twisted:
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: REQ: Wiget Auto D-gun?

Post by REVENGE »

Noruas wrote:Well its good but bad at the same time, it forces the commander to move by itself, if i could just move it and let the widget worry about the aiming part itd be great. :twisted:
Trying to get that working, along with a target movement prediction algorithm. 8)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: REQ: Wiget Auto D-gun?

Post by AF »

Using such a widget can be troublesome because:
  • DGun can be expensive energywise in certain situations
  • Your now open to a horrible exploit where lots of cheap units surround commander and commander dguns, destroying hugely expensive base
  • DGun shots only work effectively when the unit is sitting still, otherwise you need to use predictive aiming
Next time someone plays you they know to spam fleas early game and trick your commander into auto d-gunning your factory crippling you.
User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: REQ: Wiget Auto D-gun?

Post by TheFatController »

Just do a string of GetUnitsInCylinder checks along the path of the dgun and look for friendly units :p
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Re: REQ: Wiget Auto D-gun?

Post by 1v0ry_k1ng »

there were some awesome widgets for xta that *someone* made:

1) where you could set unit types the commander would automaticly be set to dgun when they came within 240 range (ie, if an atlas came in dgun range it would be autotargetted and killed)

2) where you could set the number x unit type x coming within distance x make the commander cloak until they moved away

for obvious and funny reasons these were [RoX] only but these were excellent for people to lazy to microprotect their com
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: REQ: Wiget Auto D-gun?

Post by Noruas »

I always knew there was no way you were that good when you beat me to a pulp :lol:
User avatar
Otherside
Posts: 2296
Joined: 21 Feb 2006, 14:09

Re: REQ: Wiget Auto D-gun?

Post by Otherside »

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

Re: REQ: Wiget Auto D-gun?

Post by Pendrokar »

Otherside wrote:LEARN2DGUN
Face it and A.I. could D-gun BETTER! :D
Super Mario
Posts: 823
Joined: 21 Oct 2008, 02:54

Re: REQ: Wiget Auto D-gun?

Post by Super Mario »

AF wrote:Using such a widget can be troublesome because:
  • 1.DGun can be expensive energywise in certain situations
    2.Your now open to a horrible exploit where lots of cheap units surround commander and commander dguns, destroying hugely expensive base
    3.DGun shots only work effectively when the unit is sitting still, otherwise you need to use predictive aiming
Next time someone plays you they know to spam fleas early game and trick your commander into auto d-gunning your factory crippling you.
1.Then program the widget to not use the D-Gun when your energy is low.

2.Then program the widget to not fire when friendly units is in the D-Gun range and not to fire when friendly buildings is near by.

3. Then program the widget to only fire when the enemy unit is holding still.(The buildings shouldn't be a problem.

if that doesn't work out then program the widget to Auto D-gun when manually targeting a building or a enemy unit.
Otherside wrote:LEARN2DGUN
That's not what I was talking about
Tribulex wrote:noob
Also dont click, press D
When a swarm of enemy units surround your commander, believe me you have to D-gun them, AS FAST AS YOU CAN and besides you still have to click even though you already press D. I can D-gun a lot faster in FPS mode (which its frustrating when attacking something with a D-gun BTW)
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

Re: REQ: Wiget Auto D-gun?

Post by Noruas »

Super Mario im putting you in charge of this project.
User avatar
Scikar
Posts: 154
Joined: 30 Jan 2006, 07:13

Re: REQ: Wiget Auto D-gun?

Post by Scikar »

Didn't AF or someone make a dgun unit AI that could snipe planes out of the sky?
Post Reply

Return to “Lua Scripts”