luafy the aim/targeting/priorty code please?

luafy the aim/targeting/priorty code please?

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22300
Joined: 13 Jan 2005, 00:46

luafy the aim/targeting/priorty code please?

Post by smoth » 15 May 2011, 18:03

The reason I am asking is because many projects include armor systems(s44, gundam, 0k) which should definitely effect target priority/selection. However, as it stands we cannot take these sort of things into account and have this weird power tag which cannot take take into account the armor class systems employed by the games.

So is it possible to break this out into lua instead of hard-coded in the engine? Would it hurt performance?

*INB4LUAIT* I don't want to do a targeting override gadget as I would be fighting the spring targeting system
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6109
Joined: 29 Apr 2005, 01:14

Re: luafy the aim/targeting/priorty code please?

Post by FLOZi » 15 May 2011, 18:06

There's an argument that this is already possible through the script callins like BlockShot & TargetWeight...
0 x

Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: luafy the aim/targeting/priorty code please?

Post by Kloot » 15 May 2011, 18:22

Already done, wait for 0.83.

Code: Select all

AllowWeaponTargetCheck(attUnitID, attWeaponNum, attWeaponDefID) --> true | false
AllowWeaponTarget(attUnitID, tgtUnitID, attWeaponNum, attWeaponDefID) --> true | false [, tgtPriority]
0 x

User avatar
smoth
Posts: 22300
Joined: 13 Jan 2005, 00:46

Re: luafy the aim/targeting/priorty code please?

Post by smoth » 15 May 2011, 18:53

woo hoo
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6109
Joined: 29 Apr 2005, 01:14

Re: luafy the aim/targeting/priorty code please?

Post by FLOZi » 15 May 2011, 19:58

Ah sweet, even better. How exactly do they work?
0 x


Kloot
Spring Developer
Posts: 1865
Joined: 08 Oct 2006, 16:58

Re: luafy the aim/targeting/priorty code please?

Post by Kloot » 15 May 2011, 23:10

FLOZi wrote:Ah sweet, even better. How exactly do they work?
That's best explained by some pseudocode:

Code: Select all

Engine:SlowUpdate()
    for every unit u
        for every weapon w of u
            if Lua:AllowWeaponTargetCheck(u, w, ...)
                for each potential target unit t in range of w
                    allowed, priority = Lua:AllowWeaponTarget(u, t, w, ...)
                    if allowed
                        insert t into target list of w with returned priority
                    else
                        -- this is subject to change (I may have it skip t
                        -- entirely if the callin exists but returns false,
                        -- as opposed to when it doesn't exist at all)
                        calculate priority value via hardcoded logic
                        insert t into target list of w with that value

                sort target list by priority (increasing order)
                for each target t in list
                    if t can be hit by w
                        select t as target for w; break
knorke wrote:nobody knows.
False, enough with the FUD.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: luafy the aim/targeting/priorty code please?

Post by knorke » 16 May 2011, 00:13

"nobody knows" as in "i would like to know more." ;)
BlockShot is quite obvious (though I do not understand in what details it is different from return true/false in AimWeapon) and seems to work but on how TargetWeight and UnitScript.SetUnitValue(COB.CHANGE_TARGET, 1) work I understood practically nothing.
ie what is up with that:
Rafal on Q&A page wrote:I am working on it and have a half ready solution that works if userTarget == false. The problem is that Spring ingores COB.CHANGE_TARGET if userTarget == true, and it is true in most cases.
It is true if you tell the unit to attack, but is also true if the unit is idle and something gets into range and it starts firing. It is only false if the unit has some non-combat order in its queue
If we knew how it works then I think what smoth wants is already possible.

But of course more functions and info on all that is always greatly appreciated.

Maybe related request:
scripts chosing what weapon the unit uses for manouering/getting in range, maybe also with weighting between multiple weapons.
Right now it seems to be done using a fake weapon1 which seems to have some problems (?)
0 x

User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: luafy the aim/targeting/priorty code please?

Post by Pxtl » 16 May 2011, 01:38

Cool. Can BA and ZK and all the other games with anti-air-specific weapon and aircraft-that-lands amend their SAM code to target *all* airborne units and ignore landed units? And make anti-ground weapons target (and harm) landed aircraft? Because the current behavior of landed aircraft being magically different from other units on the ground seems silly.
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6109
Joined: 29 Apr 2005, 01:14

Re: luafy the aim/targeting/priorty code please?

Post by FLOZi » 16 May 2011, 06:15

Kloot wrote:
FLOZi wrote:Ah sweet, even better. How exactly do they work?
That's best explained by some pseudocode:

*snip*
Thanks. I'm a little unsure of what happens if AllowWeaponTargetCheck returns false, though?
0 x

User avatar
TheFatController
Balanced Annihilation Developer
Posts: 1177
Joined: 10 Dec 2006, 18:46

Re: luafy the aim/targeting/priorty code please?

Post by TheFatController » 24 May 2011, 23:06

Is there going to be a way to get hold of the list of targets the unit is considering cause 'AllowWeaponTarget' doesn't seem to allow you to implement BadTargetCategory if you don't know what else the unit would target if you declined the check... (See: http://springrts.com/phpbb/viewtopic.php?f=21&t=23417)
0 x

Google_Frog
Moderator
Posts: 2441
Joined: 12 Oct 2007, 09:24

Re: luafy the aim/targeting/priorty code please?

Post by Google_Frog » 25 May 2011, 10:23

I would like a list of possible targets as well. I would like to implement dynamic bad targets for status effect weapons that gain nothing from attacking a unit once the unit is fully effected. It is much like the current hardcoded retarget behaviour for EMP.
0 x

User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Re: luafy the aim/targeting/priorty code please?

Post by Rafal99 » 28 Jun 2011, 10:59

So do these callings allow to replace OnlyTargetCategory with custom code or not yet?
I would like to be able to change unit's targetCategory in real time.
Possible uses are submarines surfacing/submerging and aircraft landing/taking off.

An Anti-Air cannon that cannot shoot ground units but somehow can shoot landed aircraft doesn't make much sense.
0 x

User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: luafy the aim/targeting/priorty code please?

Post by Licho » 28 Jun 2011, 11:44

Google_Frog wrote:I would like a list of possible targets as well. I would like to implement dynamic bad targets for status effect weapons that gain nothing from attacking a unit once the unit is fully effected. It is much like the current hardcoded retarget behaviour for EMP.
That was what i wanted for capture - prevent allies froma ttacking unit being captured and focus capture power on same unit.
0 x

Post Reply

Return to “Feature Requests”