Spring.DisableUnit

Spring.DisableUnit

Requests for features in the spring code.

Moderator: Moderators

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Spring.DisableUnit

Post by gajop »

Requesting the addition of a (synced) "Spring.DisableUnit(unitID)" function, as well as the Spring.EnableUnit(unitID) and Spring.IsUnitEnabled(unitID) that would come along.

A disabled unit would not be able to execute commands, regardless if they were given manually or automatically. It also shouldn't generate new commands automatically (i.e. it shouldn't get the attack order if an enemy unit is nearby).
It may get new commands manually like an enabled unit would, but it won't execute any.
It could still be interacted with by other units, e.g. attacked, healed, etc, and any Lua commands such as Spring.SetUnitPosition would still take effect.

Upon enabling the unit again, it will do its orders normally.

The closest thing that currently exists is the "paralyze" status, but it doesn't work on some units (e.g. commanders and dragon claw's in BA-like games), comes with an unwanted visual effect and has a mandatory expiry time based on the HP of the unit.

Thoughts?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Spring.DisableUnit

Post by Silentwings »

Can't that already be done by saving/reloading the command queue and temporarily denying all commands to the unit via synced gadget:AllowCommand?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Spring.DisableUnit

Post by zwzsg »

What about adding paralyse damage to it via Spring.AddUnitDamage ?
Or Spring.MoveCtrl.Enable to pin it?
Or, yes, clearing queue or simply giving it a STOP command every frame?

The unwanted visual effect or paralyse is purely lua gadget no?
And the expiry time can be skipped via Spring.SetUnitHealth(id,hp,{paralyze=0})
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Spring.DisableUnit

Post by Anarchid »

Can't that already be done by saving/reloading the command queue and temporarily denying all commands to the unit via synced gadget:AllowCommand?
There are things that are not commands yet are still unit actions. E.g. aiming and firing weapons, for example while FPS-controlled.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Spring.DisableUnit

Post by Silentwings »

Orders given in FPS mode don't pass through the widget or gadget callins (they do reach LUS), so typically gadgetry that works by supressing orders must entirely block FPS mode. This is a general problem that wouldn't be (much) helped by having a callout to freeze/unfreeze a unit. Outside of FPS mode, lua already has methods to control normal aiming & firing, but my interpretation of gajops feature request was that he didn't need those.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Spring.DisableUnit

Post by gajop »

I tried most of these things:

Spring.AddUnitDamage - acts weird as doesn't work for all units in all cases (e.g. sometimes it freezes a BA's ARM commander, and sometimes it doesn't, depending on the commander's team).
Spring.MoveCtrl.Enable - doesn't prevent the unit from doing actions that are in its range (e.g. attacking nearby units, building nearby stuff).
gadget:AllowCommand - seems closest to what I want, but it prevents the unit from gaining any new commands.
Spring.SetUnitHealth(id,hp,{paralyze=0}) - will try on some units I had issues with, but I'm not hopeful :p
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Spring.DisableUnit

Post by Silentwings »

gadget:AllowCommand - seems closest to what I want, but it prevents the unit from gaining any new commands.
Cache the commands you deny while disabled, and give to units as appropriate when they become un-disabled. But it won't show the usual visuals to display cached command queue unless you reimplement them (which is a pain to write but it can be done and look absolutely correct - e.g. the Set Target custom command and Initial Queue widget in BA both do this).
Last edited by Silentwings on 05 Sep 2014, 12:38, edited 2 times in total.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Spring.DisableUnit

Post by Anarchid »

I think that decoupling ability to deactivate units completely from the OTA paralyze mechanic would be a good thing to have, and would be less inelegant than using layered gadgetry as described above to work around the issue.

Spring seems to aim to be a versatile engine, and requiring any game that wants a non-OTA-like paralyze behaviour, or something else that turns units off, to go to such lengths, sounds weird.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Spring.DisableUnit

Post by Google_Frog »

This may contain everything you need to disable a unit: https://github.com/ZeroK-RTS/Zero-K/blo ... ibutes.lua
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Spring.DisableUnit

Post by FLOZi »

Anarchid wrote:I think that decoupling ability to deactivate units completely from the OTA paralyze mechanic would be a good thing to have, and would be less inelegant than using layered gadgetry as described above to work around the issue.

Spring seems to aim to be a versatile engine, and requiring any game that wants a non-OTA-like paralyze behaviour, or something else that turns units off, to go to such lengths, sounds weird.
Scores a big +1 from me.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Spring.DisableUnit

Post by smoth »

Image
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Spring.DisableUnit

Post by gajop »

I'm all in favor of a new Spring.DisableUnit, but in the meanwhile, can I get some info on this:
zwzsg wrote:The unwanted visual effect or paralyse is purely lua gadget no?
Is the visual effect something that is present by default, and could be removed (if so, how?)? Or is this something that each game has to add, and in that case, where is it added in BA and ZK?
Post Reply

Return to “Feature Requests”