View topic - luafy the aim/targeting/priorty code please?



All times are UTC + 1 hour


Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: 15 May 2011, 17:03 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
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


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 17:06 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
There's an argument that this is already possible through the script callins like BlockShot & TargetWeight...


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 17:22 
Spring Developer

Joined: 08 Oct 2006, 15:58
Already done, wait for 0.83.

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


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 17:53 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
woo hoo


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 18:58 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Ah sweet, even better. How exactly do they work?


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 19:53 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
nobody knows.
http://answers.springlobby.info/questio ... rgetweight


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 22:10 
Spring Developer

Joined: 08 Oct 2006, 15:58
FLOZi wrote:
Ah sweet, even better. How exactly do they work?


That's best explained by some pseudocode:

Code:
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.


Top
 Offline Profile  
 
PostPosted: 15 May 2011, 23:13 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
"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 (?)


Top
 Offline Profile  
 
PostPosted: 16 May 2011, 00:38 
User avatar

Joined: 23 Oct 2004, 00:43
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.


Top
 Offline Profile  
 
PostPosted: 16 May 2011, 05:15 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
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?


Top
 Offline Profile  
 
PostPosted: 24 May 2011, 22:06 
Balanced Annihilation Maintainer
User avatar

Joined: 10 Dec 2006, 18:46
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: viewtopic.php?f=21&t=23417)


Top
 Offline Profile  
 
PostPosted: 25 May 2011, 09:23 
Moderator

Joined: 12 Oct 2007, 08:24
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.


Top
 Offline Profile  
 
PostPosted: 28 Jun 2011, 09:59 
User avatar

Joined: 14 Jan 2006, 04:09
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.


Top
 Offline Profile  
 
PostPosted: 28 Jun 2011, 10:44 
Server Owner & Developer
User avatar

Joined: 19 May 2006, 18:13
Location: Brno, Czech rep., EU, Terra, Sol, Orion arm, Milky way, Virgo supercluster
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.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.