REQ: Wiget Auto D-gun?
Moderator: Moderators
-
- Posts: 823
- Joined: 21 Oct 2008, 02:54
REQ: Wiget Auto D-gun?
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...
Re: REQ: Wiget Auto D-gun?
Then you know everything about movement prediction?Super Mario wrote:I don't know how to program though...

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.
-
- Posts: 823
- Joined: 21 Oct 2008, 02:54
Re: REQ: Wiget Auto D-gun?
I just want the COM to shoot D-guns automatically when attacking something.
Re: REQ: Wiget Auto D-gun?
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.Super Mario wrote:I just want the COM to shoot D-guns automatically when attacking something.

Re: REQ: Wiget Auto D-gun?
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.
Although I must say, this is a fairly important piece of code for a competent AI to have.
- Tribulexrenamed
- Posts: 775
- Joined: 22 Apr 2008, 19:06
Re: REQ: Wiget Auto D-gun?
noob
Also dont click, press D
Also dont click, press D
Re: REQ: Wiget Auto D-gun?
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
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Re: REQ: Wiget Auto D-gun?
Meh... 
I hope people won't start demanding widget whitelists because of this!

I hope people won't start demanding widget whitelists because of this!

Re: REQ: Wiget Auto D-gun?
Code: Select all
Spring.GiveOrderToUnit(unitID, CMD.DGUN, { nearestEnemy },{})
Re: REQ: Wiget Auto D-gun?
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. 

Re: REQ: Wiget Auto D-gun?
Trying to get that working, along with a target movement prediction algorithm.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.

Re: REQ: Wiget Auto D-gun?
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
- TheFatController
- Balanced Annihilation Developer
- Posts: 1177
- Joined: 10 Dec 2006, 18:46
Re: REQ: Wiget Auto D-gun?
Just do a string of GetUnitsInCylinder checks along the path of the dgun and look for friendly units :p
- 1v0ry_k1ng
- Posts: 4656
- Joined: 10 Mar 2006, 10:24
Re: REQ: Wiget Auto D-gun?
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
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
Re: REQ: Wiget Auto D-gun?
I always knew there was no way you were that good when you beat me to a pulp 

Re: REQ: Wiget Auto D-gun?
Face it and A.I. could D-gun BETTER! :DOtherside wrote:LEARN2DGUN
-
- Posts: 823
- Joined: 21 Oct 2008, 02:54
Re: REQ: Wiget Auto D-gun?
1.Then program the widget to not use the D-Gun when your energy is low.AF wrote:Using such a widget can be troublesome because:
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.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
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.
That's not what I was talking aboutOtherside wrote:LEARN2DGUN
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)Tribulex wrote:noob
Also dont click, press D
Re: REQ: Wiget Auto D-gun?
Super Mario im putting you in charge of this project.
Re: REQ: Wiget Auto D-gun?
Didn't AF or someone make a dgun unit AI that could snipe planes out of the sky?