Unit Auto Repair Widget - Page 2

Unit Auto Repair Widget

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

Moderator: Moderators

User avatar
ginekolog
Posts: 837
Joined: 27 Feb 2006, 13:49

Re: Unit Auto Repair Widget

Post by ginekolog » 03 Feb 2009, 19:20

nice if u fix it, i ll use it. ATM i cant as i order cons to build antinuke and he start reparing stuff first.. wtf :roll: :|

Imo only idle const should repair stuff nearby... not even moving ones. (or put that as variable in widget file so we can easily change it?)
0 x

User avatar
thesleepless
Posts: 417
Joined: 24 Oct 2007, 04:49

Re: Unit Auto Repair Widget

Post by thesleepless » 04 Feb 2009, 02:43

ginekolog wrote:nice if u fix it, i ll use it. ATM i cant as i order cons to build antinuke and he start reparing stuff first.. wtf :roll: :|

Imo only idle const should repair stuff nearby... not even moving ones. (or put that as variable in widget file so we can easily change it?)
yep, it'd be best they didn't stop building to repair stuff,
but it was intentional that they repair while moving
that's so you can grab a bunch of cons + combat units and move them at the enemy base and any combat units that get damaged will get repaired by the cons on the way, unfortunately it seems its not easy to order a con to repair something and keep moving while it does it

ideally it should work the same way as attacking, if a combat unit encounters an enemy while it's moving then it'll attack it, if a repair unit encounters a damaged friendly while moving it should repair it

IMO nanospray should just a weapon like every other weapon, but target friendlies by default rather than enemies
0 x

User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Unit Auto Repair Widget

Post by CarRepairer » 04 Feb 2009, 17:25

thesleepless wrote:
ginekolog wrote:nice if u fix it, i ll use it. ATM i cant as i order cons to build antinuke and he start reparing stuff first.. wtf :roll: :|

Imo only idle const should repair stuff nearby... not even moving ones. (or put that as variable in widget file so we can easily change it?)
yep, it'd be best they didn't stop building to repair stuff,
but it was intentional that they repair while moving
that's so you can grab a bunch of cons + combat units and move them at the enemy base and any combat units that get damaged will get repaired by the cons on the way, unfortunately it seems its not easy to order a con to repair something and keep moving while it does it

Edit: Still bugged, will need more testing.
ideally it should work the same way as attacking, if a combat unit encounters an enemy while it's moving then it'll attack it, if a repair unit encounters a damaged friendly while moving it should repair it

IMO nanospray should just a weapon like every other weapon, but target friendlies by default rather than enemies
Okay, fixed here http://trac.caspring.org/changeset/3896

Only truly idle cons will autorepair now. I think you were confusing getfullbuildqueue, it's something you only use for factories.

I added a leash so that if they began the auto repair but start moving too far from where they began, they will stop repairing and go back. det pointed this out to me since a damaged plane might fly over a con in your base, then fly across the map and the con will follow that plane into his doom until the plane is healed or is dead.

Tip: If you really want cons to be moving along with your mobile army and heal them as they travel, issue a fight command to the cons (or just select all the combat units and cons and issue a fight command to the whole lot)! Autorepair is for cons to be in a single spot of safety and they won't stray too far from it.

Edit: still bugged, will need more testing.
0 x

klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Unit Auto Repair Widget

Post by klapmongool » 30 Aug 2010, 10:27

I have been using this widget recently. It still suffers from bugs.

Worst is that builders that aren't really idle decide to go repair stuff. I think this is caused by the intended function in this widget that allows moving repair units in a moving front to repair. The problem is that this overrides genuine move commands (fe to get ur comm out of danger by moving him away). Also repairunits still follow air that passes over them.

Can someone remove that part of the widget please;

1. repairing while moving doesn't work for most repair units anyway.
2. i dont need that part anyway :)
0 x

User avatar
thesleepless
Posts: 417
Joined: 24 Oct 2007, 04:49

Re: Unit Auto Repair Widget

Post by thesleepless » 30 Aug 2010, 12:00

yeah this widget is broken and i don't have time to fix it sorry.
shouldn't be hard to modify though, even with minimal coding ability
0 x

klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Unit Auto Repair Widget

Post by klapmongool » 01 Sep 2010, 14:26

I am afraid I have less than minimal coding ability. But I gave it a try anyway.

I started out by identifying the way to determine whether a potential repair unit is idle. Next I looked at another widget (idlebuilders) for comparison. Both seem to beat around the bush. Autorepair checks for all units that have repair capability (right?), then eliminating all units that arenÔÇÖt available for various reasons while idlebuilder checks for units that can have build queues without build queues but donÔÇÖt have em.

What script is behind ctrl-b, and why isnÔÇÖt it used in these scripts? For the purpose of improving this script for my needs this seems the fastest way to go. Would it work if this part below gets replaced for the ctrl-b way of determining idle builders?

Code from Autorepairunit widget:
local function isIdleRepairer(unitID)
local udef = spGetUnitDefID(unitID)
local ud = UnitDefs[udef]
if not ud.canRepair then
return false
end
local _, _, _, _, buildProg = spGetUnitHealth(unitID)
if buildProg < 1 then
return false
end

local cQueue = spGetCommandQueue(unitID)
if cQueue[1] then
return false
end
return true
end
Code from Idlebuilder widget:
local function IsIdleBuilder(unitID)
local udef = Spring.GetUnitDefID(unitID)
local ud = UnitDefs[udef]
local qCount = 0
if ud.buildSpeed > 0 then --- can build
local bQueue = Spring.GetFullBuildQueue(unitID)
if not bQueue[1] then --- has no build queue
local _, _, _, _, buildProg = Spring.GetUnitHealth(unitID)
if buildProg == 1 then --- isnt under construction
if ud.isFactory then
return true
else
local cQueue = Spring.GetCommandQueue(unitID)
if not cQueue[1] then
return true
end
end
end
elseif ud.isFactory then
for _, thing in ipairs(bQueue) do
for _, count in pairs(thing) do
qCount = qCount + count
end
end
if qCount <= NEAR_IDLE then
QCount[unitID] = qCount
return true
end
end
end
return false
end
0 x

User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Unit Auto Repair Widget

Post by CarRepairer » 01 Sep 2010, 17:32

I have the feeling you're not using the updated version from CA which has some fixes.
0 x

klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Unit Auto Repair Widget

Post by klapmongool » 01 Sep 2010, 19:24

CarRepairer wrote:I have the feeling you're not using the updated version from CA which has some fixes.

hmmm, and where would I find those? This widget I found on http://widgets.springrts.de/index.php#76.
0 x

User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: Unit Auto Repair Widget

Post by manolo_ » 01 Sep 2010, 19:36

the problem is, that ca-devs dont update the widgets in the wdb (if they just modified them)
0 x

SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: Unit Auto Repair Widget

Post by SirMaverick » 01 Sep 2010, 19:45

manolo_ wrote:the problem is, that ca-devs dont update the widgets in the wdb (if they just modified them)
We work and update on our repository. And it's not only ca-devs that put widget in wdb. A simple solution might be to put a link in to ca's repository in description if you add a widget in wdb.
0 x

User avatar
very_bad_soldier
Posts: 1371
Joined: 20 Feb 2007, 01:10

Re: Unit Auto Repair Widget

Post by very_bad_soldier » 01 Sep 2010, 21:13

manolo_ wrote:the problem is, that ca-devs dont update the widgets in the wdb (if they just modified them)
Car updates CCC quite regularly.
SirMaverick wrote:
manolo_ wrote:the problem is, that ca-devs dont update the widgets in the wdb (if they just modified them)
We work and update on our repository. And it's not only ca-devs that put widget in wdb. A simple solution might be to put a link in to ca's repository in description if you add a widget in wdb.
Hm, that would make it impossible to use most of SD's widgets features. (One-click install, auto-updating, version tracking, etc.)

How about this: When you update a widget you send a PM to me or manolo (with a changelog) and we will do the DB updates for you? Please understand it is a bit hard to keep track of the CA-widgets if you are not a CA-dev.
0 x

User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Unit Auto Repair Widget

Post by CarRepairer » 01 Sep 2010, 21:20

very_bad_soldier wrote:Car updates CCC quite regularly.
Nope...
very_bad_soldier wrote:How about this: When you update a widget you send a PM to me or manolo (with a changelog) and we will do the DB updates for you?
This is what I do. He has more patience than me with the wdb app.

Back to topic though, even with some fixes in CA the widget still had issues and we had to disable it. We should probably remove it to prevent newbies from using it by accident.
0 x

klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Unit Auto Repair Widget

Post by klapmongool » 01 Sep 2010, 21:56

CarRepairer wrote:
very_bad_soldier wrote:Car updates CCC quite regularly.
Nope...
very_bad_soldier wrote:How about this: When you update a widget you send a PM to me or manolo (with a changelog) and we will do the DB updates for you?
This is what I do. He has more patience than me with the wdb app.

Back to topic though, even with some fixes in CA the widget still had issues and we had to disable it. We should probably remove it to prevent newbies from using it by accident.
This widget has potential for specific use for me. I was using the latest version i think, since there is nothing newer than the one posted in this topic by you (http://trac.caspring.org/changeset/3896)

Although the widget might not fulfil its intended goal it still has its uses. Atm I am using it but have to switch it off in certain situations because of its buggyness. For my purposes it would be fixed if the ┬┤idle┬┤ cons could be identified better. (ctrl-b would be great) I don't need walking cons to be identified.
Last edited by klapmongool on 01 Sep 2010, 21:58, edited 1 time in total.
0 x

User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: Unit Auto Repair Widget

Post by manolo_ » 01 Sep 2010, 21:57

car is the only one who is sending me pms atmo and i look from time toi time at tthe ca-widget-source, but sometimes i forget it or i dont even recognize it, coz i think the changes are just ca-related
0 x

klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Unit Auto Repair Widget

Post by klapmongool » 02 Sep 2010, 22:12

Sooo.. would anyone know how to adjust this widget's method of selecting idle builders?
0 x

User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

Re: Unit Auto Repair Widget

Post by Hobo Joe » 03 Sep 2010, 05:31

Have a look at the idlebuilders widget and see how it identifies them and copy the code appropriately?
0 x

Post Reply

Return to “Lua Scripts”