Area Guard - Page 2

Area Guard

Requests for features in the spring code.

Moderator: Moderators

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Area Guard

Post by knorke »

Imo queued guard-commands have a few problems that make them useless:
Unit is to set to guard A and B. One would expect that if either A or B gets attacked, the unit will defend it.
But what actually happens is that it guards A then it guards B.
So if B is attacked the unit will not defend it because it is still busy guarding A. Only once A is destroyed will the unit care about B.

Similiar with constructors set to guard multiple other cons or factories. If the first con/factory is idle it will just stare at it instead of helping the next unit in queue.

Fix might be a wupget that whenever a unit was damaged, checks if some unit was supposed to guarding it. If yes, that attacked unit is moved to first place in guard queue of the guarding unit.
---
Jools wrote:
Google_Frog wrote:Click detection is to be avoided.
Yes, I was thinking to have it in mousepress and mousedrag. Why is that bad? You cannot issue a guard order without clicking.
There already is AllowCommand() and CMDTYPE.ICON_UNIT_OR_AREA so no need to re-invent it.


http://code.google.com/p/zero-k/source/ ... ard.lua#77
local units = Spring.GetUnitsInSphere( unpack(cmdParams) )
Why not GetUnitsInCylinder? In case of mountains!
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Area Guard

Post by Jools »

knorke wrote:Imo queued guard-commands have a few problems that make them useless:
Unit is to set to guard A and B. One would expect that if either A or B gets attacked, the unit will defend it.
But what actually happens is that it guards A then it guards B.
So if B is attacked the unit will not defend it because it is still busy guarding A. Only once A is destroyed will the unit care about B.
I have already thought of that. There is a squadron mode (if you press "alt" when you drag) that divides the guard job into groups, so that each guarding unit only guards some of the units. There is also a persistent mode (if you also hold "ctrl" while dragging), where the guard order is changed to the unit with least hp (as percent) first. It works on unitdamaged.

It's not good to make it a gadget until the cost has been investigated. I tested with 40 farks guarding 125 rockos, against 125 storms. Profiler doesnt blame this widget but I still think it causes some lag. On non-persistent mode there was less lag and I think the battle performance is about the same. Needs more testing though.

New version:
http://code.google.com/p/xta-springrts/ ... aguard.lua
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Area Guard

Post by CarRepairer »

knorke wrote:So if B is attacked the unit will not defend it because it is still busy guarding A. Only once A is destroyed will the unit care about B.
That's technically true, but Spring is of course a lot more complex than that, and units that fire-at-will will attack any enemy in their vicinity. I'll outline my goal (which is now solved).

Previously: Want 10 robots to follow 10 tanks. They can guard one, but if it dies, they stop. Required multiple clicks to ensure they follow all of them.

Now: Select 10 robots, drag the mouse over 10 tanks. Now 10 robots are following 10 tanks, no matter which tanks die.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Area Guard

Post by Google_Frog »

I've discovered that area guard is always annoying. When I right click drag to give line move commands I often start the command on one of my units (accidentally). Area guard interferes with this.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Area Guard

Post by Jools »

I guess that's the default command function, because I can't reproduce that behaviour. Just comment or remove that function => problem solved.

I finished the xta version of it, I had to make it a gadget/widget couple to get the button showing. The gadget adds the button but makes it hidden. When widget loads it makes the button visible and hides the normal guard button. When widget unloads it reverses the procedure.

Can someone tell me how the heck SetCustomCommandDrawData works. It returns nil for me and has no effect. How do you change the draw colour?

How the area guard works:

Basic mode, like zk one.

If you hold alt while dragging: distributes the guard task into squadrons based on how many units you have selected to guard.

Alt+ctrl while dragging: makes the squadrons permanent. When one unit in the squadron gets damaged, the unit guarding the squadron will shift the guard task to prioritise the unit wth least health. Selecting a unit that is guarding a squadron and pressing "stop" will also clear the guard task.

Files:

http://code.google.com/p/xta-springrts/ ... ommand.lua

http://code.google.com/p/xta-springrts/ ... rd_xta.lua
Post Reply

Return to “Feature Requests”