What does Spring.SetUnitMaxRange() do exactly?

What does Spring.SetUnitMaxRange() do exactly?

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

Moderator: Moderators

Post Reply
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

What does Spring.SetUnitMaxRange() do exactly?

Post by KingRaptor »

My initial assumption was that you can use it to force a unit with long-ranged weapons to close in to a shorter range when having an Attack order.
e.g. unit has three weapons, longest ranged one has 600 range, so it normally tries to close to 600 range and then stops
but with Spring.SetUnitMaxRange(unitID, 100), it closes to 100 range.

However, in Spring 100 and 100.0.1-289-g236a068, all it actually seems to do is change the leash range at which units which are idle or have Fight/Patrol orders move to attack nearby enemies. The unit will always camp at its longest weapon range when Attacking, no matter what.

Do I mantis this? Is there a way to do the thing described in the first paragraph?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by FLOZi »

I think you'll have to make your own custom attack command to do it properly, MaxRange only sets leash for patrol/fight as you said, though this is also tied to movestate, so you will get different results for hold / manuever / roam.
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by hokomoko »

You're correct, units stop trying to close distance once they can fire at their target with any weapon, so as FLOZi said, you must implement a custom command.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by Google_Frog »

Didn't units once stop once their first weapon is in range? Have we lost functionality somewhere?
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by hokomoko »

Google_Frog wrote:Didn't units once stop once their first weapon is in range? Have we lost functionality somewhere?
That's the current situation as well.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by FLOZi »

hokomoko wrote:
Google_Frog wrote:Didn't units once stop once their first weapon is in range? Have we lost functionality somewhere?
That's the current situation as well.
Are you sure?

I think it is now the longest ranged weapon (though may depend on movestate)
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by hokomoko »

Ah, communication issue! I thought:
First weapon = the first to be in range
and not
First weapon = weapons[1]
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by Forboding Angel »

I'm guessing that it completely ignores categories? I hope not. Otherwise you might have a long range aa unit with a shorter range ground weapon happily stopping short of a ground target with it's thumb lodged directly up it's ass.

That's of course just one scenario... What if it is a ground unit with a ground weapon but can't fire at a target due to categories? Spring allows targeting of things that the unit can't fire at when there is no better target around, it just isn't able to fire at those things it has targeted. This behavior is especially irritating with air units.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by Silentwings »

GF is right though, it used to be first weapon and was changed, a long time ago, afaik by accident since I never saw it in the changelog. BAs chickens suffers a bit as a result.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by FLOZi »

My hope was for the function to allow us to set it arbitrarily but I didn't go deep enough
raaar
Metal Factions Developer
Posts: 1094
Joined: 20 Feb 2010, 12:17

Re: What does Spring.SetUnitMaxRange() do exactly?

Post by raaar »

last time I checked, if you make a gunship-type aircraft with both a med range weapon and a long range weapon (ex: 450 range rockets and 700 range missiles), it'll hover at the longest weapon range instead of closing in to fire with both.
Post Reply

Return to “Lua Scripts”