Prevent multiple [unit] from targeting the same thing

Prevent multiple [unit] from targeting the same thing

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

Moderator: Moderators

Post Reply
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Prevent multiple [unit] from targeting the same thing

Post by Caydr »

Suppose you have 10 snipers in a row, perpendicular to a column of approaching peewees. In all likelihood, as the peewees approach, at least 50% of the shots will be wasted as multiple snipers attempt to simultaneously headshot the same peewees.

Would it be possible with lua to have a unit "lock" a given target from being attacked by other units of a given type (armsnipe) if the following conditions are satisfied:
-the unit is ready to fire
-it is able to fire at the target without itself or the target moving, in other words it has a clean shot

...And prevent other units of said type from attacking the target until one of the following conditions has been satisfied:
-the target is no longer in the attacker's primary weapon range
-the unit is unable to fire (weapon not ready due to EMP, unit has been destroyed, etc)
-0.2s has passed since the unit fired and the target isn't dead
Last edited by Caydr on 16 Aug 2009, 10:36, edited 2 times in total.
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Prevent multiple [unit] from targeting the same thing

Post by REVENGE »

Caydr wrote:Suppose you have 10 snipers in a row, perpendicular to a column of approaching peewees. In all likelihood, as the peewees approach, at least 50% of the shots will be wasted as multiple snipers attempt to simultaneously headshot the same peewees.

Would it be possible with lua to have a unit "lock" a given target if the following conditions are satisfied:
-the unit is ready to fire
-it is able to fire at the target without itself or the target moving, in other words it has a clean shot

...And prevent other units from attacking the target until one of the following conditions has been satisfied:
-the target is no longer in the attacker's primary weapon range
-the unit is unable to fire (weapon not ready due to EMP, etc)
-0.2s has passed since the unit fired and the target isn't dead
Sure.

I'm too lazy to do it for you though. :twisted:
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Prevent multiple [unit] from targeting the same thing

Post by Google_Frog »

If someone is going to do this it would be worth adding predicted damage as well. This would stop units shooting at something if it is going to be dead but hasn't been hit yet. This would be great for units with slow projectiles and homing, for example the Janus.

Actually now I think a bit more the Janus thing can be worked into the original widget. Snipers are like Janus with faster shots so the predicted damage would still work.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Prevent multiple [unit] from targeting the same thing

Post by Caydr »

With snipers there's instant feedback, if the shot will hit you'll know it almost instantly, which is why I thought it would be ideal for this kind of thing. If someone actually decides to make this, IMHO it would be best to keep it as simple as possible... I realize that lua has a reputation of curing cancer and such, but things like predictive damage, excessively long waits to see if an attack actually landed (janus), will just make it unreliable and CPU intensive. Remember with predictive damage it'll have to figure out what side of the unit is going to get hit as well, because of directional bonuses.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Prevent multiple [unit] from targeting the same thing

Post by Pendrokar »

Cant there be instant hit weapons.

ex.

Unit fires weapon. Do damage at the same frame when it fires. Do not fire if dmg > enemy hp.

Can't Cob do it?
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Prevent multiple [unit] from targeting the same thing

Post by Caydr »

Pendrokar wrote:Can't Cob do it?
Nah, you'd need lua for something like that for sure.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Prevent multiple [unit] from targeting the same thing

Post by lurker »

No, no, can't be tempted by that into doing this in cob, because it can definitely be done in cob.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Prevent multiple [unit] from targeting the same thing

Post by Caydr »

Hell, for an instant-hit weapon you might even have to use TDF.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Prevent multiple [unit] from targeting the same thing

Post by lurker »

Oh, were you just talking about a subissue there? I stand by this entire feature being within cob's reach, can't be tempted.
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: Prevent multiple [unit] from targeting the same thing

Post by manolo_ »

btw other request in that context, could aa-units fire with higher priority vs air for mods that have aa-units that could shoot on ground?
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: Prevent multiple [unit] from targeting the same thing

Post by REVENGE »

manolo_ wrote:btw other request in that context, could aa-units fire with higher priority vs air for mods that have aa-units that could shoot on ground?
Certainly.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Prevent multiple [unit] from targeting the same thing

Post by Caydr »

They already do, as long as the mod has functioning category tags. But don't worry, according to one expert non-modder, apparently that can be "designed around" through sheer force of willpower and good intentions.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Prevent multiple [unit] from targeting the same thing

Post by lurker »

Don't berthas normally aim at radar blips when not explicitly given targets? It's not that important to have badtargetcategory mobile, now stop phrasing things in a trollish way please.
Post Reply

Return to “Lua Scripts”