Changing mouse order behavior. Single target vs area command

Changing mouse order behavior. Single target vs area command

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

Post Reply
Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Changing mouse order behavior. Single target vs area command

Post by Godde »

It is hard to target a specific moving unit with an attack command because if I press the mouse button and move the mouse at the same time, I will get an attack circle.

How can I make it easier to target moving units?
Could a widget change the mouse order behavior?
0 x

User avatar
Silentwings
Moderator
Posts: 3646
Joined: 25 Oct 2008, 00:23

Re: Changing mouse order behavior. Single target vs area com

Post by Silentwings »

0 x

User avatar
Jools
XTA Developer
Posts: 2812
Joined: 23 Feb 2009, 16:29

Re: Changing mouse order behavior. Single target vs area com

Post by Jools »

I assume you're using CustomFormations2? That's the one that does the area command that way.

You could try to find an older version of CF2 that doesn't make attack + move an area command.
0 x

User avatar
Silentwings
Moderator
Posts: 3646
Joined: 25 Oct 2008, 00:23

Re: Changing mouse order behavior. Single target vs area com

Post by Silentwings »

Area attack circles are drawn by the engine. Custom formations only deals with line commands.
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

Silentwings wrote:Maybe this viewtopic.php?f=11&t=33173 ?
That only works for "select", right?

I tried:
bind z attack FromMouse_50++_ClearSelection_SelectNum_1+
but that only gave me a regular attack command.
0 x

User avatar
Silentwings
Moderator
Posts: 3646
Joined: 25 Oct 2008, 00:23

Re: Changing mouse order behavior. Single target vs area com

Post by Silentwings »

I'm afraid I don't know, I've never messed with uikeys much. I think what I linked to is only for select, but maybe it can be modified.

If not, it's certainly possible (and might actually be easier) to write a widget that, when you click to attack ground, looks to see if there is a unit nearby within small radius and attacks that instead.
0 x

8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Changing mouse order behavior. Single target vs area com

Post by 8611 »

viewtopic.php?f=11&t=33173 is about SelectionKeys.txt, it is only about selecting things.
https://github.com/spring/spring/blob/d ... onKeys.txt
---
It is hard to target a specific moving unit with an attack command because if I press the mouse button and move the mouse at the same time, I will get an attack circle.
I understand like this:
You have some units selected and want to give an attack-order on enemy unit.
When you do the right-click on the enemy you drag the mouse a bit because clumsy fingers and it ends up as an area-attack around the unit? And that is bad because now too many enemy units are inside the attack-circle...?

One idea might be that area-attacks with very small radius get converted to attacks on single unit.
This widget test detects area-attacks and if radius is too small then it ignores the command and instead gives new single-unit attack cmd.

Code: Select all

function widget:GetInfo()
  return {
    name      = "no small area attack",
    layer     = 0,
    enabled   = true,
  }
end

local minRadius = 200
function widget:CommandNotify(cmdId, cmdParams, cmdOpts)	
	if cmdId == CMD.ATTACK then
		if #cmdParams==4 and cmdParams[4] < minRadius then --x,z,y,radius => it is area attack			
			local targets = Spring.GetUnitsInCylinder(cmdParams[1],cmdParams[3],cmdParams[4],Spring.ENEMY_UNITS)
			for _,unitID in pairs(Spring.GetSelectedUnits()) do
				Spring.GiveOrderToUnit (unitID, CMD.ATTACK, {targets[1]}, cmdOpts)
			end
		return true
		end
	end    

	return false
end
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

8611 wrote:This widget test detects area-attacks and if radius is too small then it ignores the command and instead gives new single-unit attack cmd.
It doesn't work well on airplanes. Probably because the cylinder just extends upwards and if the camera is tilted, the plane might be missed completely.
Also if there is a group of enemies you might not get the intended target even if it is is closest to the mouse cursor.

Maybe it would work well if you could check which unit that is closest to the mouse cursor and ignore the cylinder entirely.
0 x

8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Changing mouse order behavior. Single target vs area com

Post by 8611 »

which unit that is closest to the mouse cursor
1) I think when dragging the area-circle the mouse would be at outside, far away from wanted target.
Maybe instead: "which unit is clostest to center of circle"?

2) on aircraft: The mouse moves in 2D but aircraft move in 3D.
So "closest to the mouse cursor" is tricky and might not always give desired result.
Imo user needs a way to specify if the mouseclick are aimed on a high-flying bomber or at the unit underneath. On screen it might be five pixels difference, but in 3D world both units are maybe 500 elmos apart.

Perhaps instead you want something entirely different:
'Hold this key and area-attack will only target aircraft' ?
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

8611 wrote:1) I think when dragging the area-circle the mouse would be at outside, far away from wanted target.
Maybe instead: "which unit is clostest to center of circle"?
I think that people who tries to target a moving unit will naturally try to move the mouse cursor with the motion of the unit.
There are 2 events that happen when you click the mouse:
Mouse button press and mouse button release.
Mouse press happens first and is where the center of the circle is.
Mouse release happens later and is how large the circle becomes.
This means that you have to first press the mouse infront of the unit and then release it as the unit passes the center of the circle. This is pretty hard to do on fast moving units.
Also the size of the circle is irrelevant as it is only matter how close the unit is to the middle of the circle if you are trying to target a specific unit out of many.


8611 wrote:2) on aircraft: The mouse moves in 2D but aircraft move in 3D.
So "closest to the mouse cursor" is tricky and might not always give desired result.
Imo user needs a way to specify if the mouseclick are aimed on a high-flying bomber or at the unit underneath. On screen it might be five pixels difference, but in 3D world both units are maybe 500 elmos apart.
You don't really need to specify if you are aiming on a high flying bomber or at unit underneath because if you want to target the the bomber you just click on it which doesn't really work now. If you want to target the ground unit you can move the camera so that the bomber doesn't obscure the ground unit.
8611 wrote:Perhaps instead you want something entirely different:
'Hold this key and area-attack will only target aircraft' ?
Useful but a tilted camera makes it a little hard to target airplanes with the default cylindrical area attacks. But it would still be really helpful to be able to only attack targets of either ground or air.

Basically I just wants the same functionality as this FromMouse_50++_FromMouse_50++_ClearSelection_SelectNum_1+
where FromMouse_50+ where is distance from the mouse visually in pixels or something like that.
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10314
Joined: 24 Jan 2006, 21:12

Re: Changing mouse order behavior. Single target vs area com

Post by PicassoCT »

What i never got is - why there are unused commands..

For example, i can click guard a unit and the folllow up commandos are what? commands to execute relative to the guarded unit when it is attacked?

Fallbacks when it is destroyed?

Why not be honest- by the time they get executed, they are outdated junk. And so- everything happening after a guard command is basically useless..

That is one of the reasons why i added TacZones in the first place..
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

PicassoCT wrote:That is one of the reasons why i added TacZones in the first place..
What is TacZones?
0 x

8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Changing mouse order behavior. Single target vs area com

Post by 8611 »

PicassoCT wrote:For example, i can click guard a unit and the folllow up commandos are what?
Fallbacks when it is destroyed?
Yup.
Once the guarded unit is destroyed the guard will move on to next command.
My hate-favorite are constructors: give several buildorders, one order is guard the factory - but "guarding the factory" never ends and the constructor never moves on. Bit annoying but imo "user-error."
Godde wrote:Basically I just wants the same functionality as this FromMouse_50++_FromMouse_50++_ClearSelection_SelectNum_1+
where FromMouse_50+ where is distance from the mouse visually in pixels or something like that.
So basically instead of tiny precise pointer that needs to click directly on target want a big fat pointer that just needs to click near the target?


The ground/air targeting thing sounds bit what "Area attack tweak" does in zero-K: automatically filter out ground target for AA units.
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

8611 wrote:
Godde wrote:Basically I just wants the same functionality as this FromMouse_50++_FromMouse_50++_ClearSelection_SelectNum_1+
where FromMouse_50+ where is distance from the mouse visually in pixels or something like that.
So basically instead of tiny precise pointer that needs to click directly on target want a big fat pointer that just needs to click near the target?
Maybe. Although I'd prefer if I could just not make an attack circle when clicking and moving the mouse and having the target get selected on mouse button release even if I move the mouse. Alternatively the target could be selected on mouse button press.
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

Made a widget to target unit on mouse button release. viewtopic.php?f=23&t=33275&p=567663#p567663

I think I'm gonna use this in all the games i play.

Code: Select all

function widget:GetInfo()
  return {
    name      = "Attack target on mouse release",
    desc      = "attacks specific target under mouse cursor on mouse button release",
    author    = "Godde",
    date      = "Mar 14, 2015",
    license   = "No license",
    enabled   = true
  }
end

local TraceScreenRay = Spring.TraceScreenRay
local GetMouseState = Spring.GetMouseState


function widget:CommandNotify(cmdId, cmdParams, cmdOpts)   
   if cmdId == CMD.ATTACK then
      if #cmdParams==4 then -- if area attack 

		local mx, my = GetMouseState()
		local mouseTargetType, mouseTarget = TraceScreenRay(mx, my)
		if mouseTargetType == "unit" then
			for _,unitID in pairs(Spring.GetSelectedUnits()) do
				Spring.GiveOrderToUnit (unitID, CMD.ATTACK, {mouseTarget}, cmdOpts)
			end
			return true
		end

      end
   end   

   return false
end
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10314
Joined: 24 Jan 2006, 21:12

Re: Changing mouse order behavior. Single target vs area com

Post by PicassoCT »

Godde wrote:
PicassoCT wrote:That is one of the reasons why i added TacZones in the first place..
What is TacZones?

Basically - you can place three types of zones on the battlefield. Triggerzones, which activate actionzones connected to them, once a enemy steps inside. Actionzones, which store commands, just like a unit would. Finally Reservoirezones, which is the place where the units stand around that wait for the enemy to come.
It allows for example to make triggered patrolls, with a return to the reservoirzone.
Or automated counterattacks.

Its still pretty hacky (uses invisible units for the zones) but it works
0 x

User avatar
Jools
XTA Developer
Posts: 2812
Joined: 23 Feb 2009, 16:29

Re: Changing mouse order behavior. Single target vs area com

Post by Jools »

I like that: like the Art of War with the different grounds.
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

TacZones sounds interesting. I have always wanted to do something similar. Mm... I searched for TacZones but couldn't find anything on the forum except for this thread. Do you have a link?
Jools wrote:I like that: like the Art of War with the different grounds.
Is it a game? I searched on youtube but couldn't find anything specific. Do you have an example?
0 x

User avatar
Jools
XTA Developer
Posts: 2812
Joined: 23 Feb 2009, 16:29

Re: Changing mouse order behavior. Single target vs area com

Post by Jools »

It's a book, I recommend it warmly. Here's the part covering the grounds:

http://suntzusaid.com/book/11

For example:
7

When an army has penetrated into the heart of a hostile country, leaving a number of fortified cities in its rear, it is serious ground.
0 x

Godde
Posts: 268
Joined: 29 Mar 2010, 17:54

Re: Changing mouse order behavior. Single target vs area com

Post by Godde »

Lol, yeah. I know it is a book. But I thought it was some game that had a proper zone control UI.
0 x

Post Reply

Return to “General Discussion”