Filtering for area orders

Filtering for area orders

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

Moderator: Moderators

Post Reply
HeadHunter
Posts: 53
Joined: 15 May 2007, 12:33

Filtering for area orders

Post by HeadHunter »

Consider I want to have a filter that filters out units in area-attack or area load. For example, I might wish to skip all units cheaper then 100 M in an area-attack for strategic bombers, so that they concentrate on bigger targets. Or, if I am making an airdrop, I may wish for the heavier units to get more priority over lighter ones.

Any ideas how it can be done? I figured that it would require messing with command queues, but I have no idea where to start. The only callin i have found useful is allowCommand, but then I would have to duplicate the area-order logic in LUA which is redundant.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Filtering for area orders

Post by knorke »

maybe look at this?
Smart Area Reclaim
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Filtering for area orders

Post by Jools »

Hmmm, I think it will troublesome to issue unit-weighted attack priority, you don't know an unit's metal value unless it in within LOS. Thus, the filtering would only work on those units that are currently withing LOS, not very practical imo. If I'm wrong, please correct me.

About loading/unloading in different order, yes, I think you can do it. It's just to select a group of units and sort the group based on metal value.

Have a look at my keyfix widget for an example. It selects best transporter based on type and distance.

http://springrts.com/phpbb/viewtopic.ph ... pe#p501645
HeadHunter
Posts: 53
Joined: 15 May 2007, 12:33

Re: Filtering for area orders

Post by HeadHunter »

Well at the moment loading is a priority. And the most important thing is that in the best case scenario I'd like the immediate unit state to affect, not the state when the order is given. For example, if a stunned enemy unit is to be loaded into air transport, transport should check if the unit can still be loaded when it arrives to the load area, and keep on checking until the unit can be loaded.

So in the end i think that the best course of action will be to monitor a trans in a loop, when it gets close to target area start looking for units to load in a similar way to reclaim widget.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Filtering for area orders

Post by aegis »

the concepts in my SmartAreaReclaim and SmartSelect widgets might help get someone on the right track

SmartSelect has some very fast methods of locating and filtering units inside an area. SmartAreaReclaim shows how you can play with area commands

as for not duplicating commands, you can just check to see if the next command is an area load to decide when you want to start scanning, then insert your load command at the start of the queue in place of the area load once you've made a decision (maybe detect if the unit is on repeat, if so, cycle the area load to the end of the queue instead of removing it)
HeadHunter
Posts: 53
Joined: 15 May 2007, 12:33

Re: Filtering for area orders

Post by HeadHunter »

Yeah, that was the way I saw this. I was just kinda hoping there is a faster approach. But if there is none I will probably make a gadget/widget that would be general-purpose filter for are commands and then build transporting thing on top of that. Then if the functionality is merged into engine not much work will be wasted.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Filtering for area orders

Post by aegis »

SmartSelect runs something like six filters on 5k units with almost zero slowdown in my testing... and the method's already there, you'd just need to change the distance check to a circle for some commands.
HeadHunter
Posts: 53
Joined: 15 May 2007, 12:33

Re: Filtering for area orders

Post by HeadHunter »

Well if the performance is not a problem then I might just use it. For slow-update it should be quite OK.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Filtering for area orders

Post by jK »

There are other ways these days (duno if it is faster):
the event `UnitCommand` gets directly called after `AllowCommand`.
Post Reply

Return to “Lua Scripts”