View topic - Widget::UnitDestroyed



All times are UTC + 1 hour


Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Widget::UnitDestroyed
PostPosted: 31 Mar 2012, 20:29 
User avatar

Joined: 30 Nov 2008, 04:31
Location: the flow
So, upon losing yet another game in ZK, and finding myself with some spare time, i got to thinking that a widget that counted my own and confirmed enemy casualties and displayed their cost in metal would be a nice and useful idea.

However, i can't seem to get enemy losses - even those within my los - detected by the widget. Does widget::UnitDestroyed fire only on owned units in unsynced context?

If so - can anyone point me to how i could detect any confirmed kills from unsynced?


Top
 Offline Profile  
 
PostPosted: 31 Mar 2012, 20:39 
User avatar

Joined: 23 Feb 2009, 16:29
Location: Finland
I think you can get some information by looking at the UnitLeftLos and UnitLeftRadar callins. Don't remember how it worked.


Top
 Offline Profile  
 
PostPosted: 01 Apr 2012, 05:07 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
What if I made a game where there were no corpses, units disappear when they die, and they can cloak. If widget:unitdestroyed worked on enemy units, a widget could help you cheat in my game.


Top
 Offline Profile  
 
PostPosted: 01 Apr 2012, 09:59 
User avatar

Joined: 30 Nov 2008, 04:31
Location: the flow
I would gladly accept the limitation to confirmed kills only. So in that theoretical game, the widget would have been somewhat useless anyway, and even the player themselves wouldn't be able to determine, was unit killed or just cloaked and ran away.

Similarly, i'm completely ok if units killed outside LOS (such as glaives set on fire by a pyro) are not counted.

Going to try the left-los thing, see if it gives anything useful...


Top
 Offline Profile  
 
PostPosted: 01 Apr 2012, 11:57 
User avatar

Joined: 07 Dec 2008, 02:35
Code:
local inLos = {}

function widget:UnitEnteredLos(uID)
    inLos[uID] = true
end

function widget:UnitLeftLos(uID)
    inLos[uID] = nil
end

function widget:GameFrame(n)
    for uID, _ in pairs(inLos) do
        if not Spring.GetUnitDefID(uID) then
            Spring.Echo(uID .. ' has died !')
            inLos[uID] = nil
        end
    end
end


Top
 Offline Profile  
 
PostPosted: 01 Apr 2012, 12:59 
User avatar

Joined: 30 Nov 2008, 04:31
Location: the flow
Niobium ^^ <3


Top
 Offline Profile  
 
PostPosted: 13 Apr 2012, 11:40 
User avatar

Joined: 23 Feb 2009, 16:29
Location: Finland
Niobium wrote:
function widget:GameFrame(n)
for uID, _ in pairs(inLos) do
if not Spring.GetUnitDefID(uID) then
Spring.Echo(uID .. ' has died or morphed !')
inLos[uID] = nil
end
end
end[/code]


Corrected that. Unit has either died or morphed. Morphed units receive new uID:s.


Top
 Offline Profile  
 
PostPosted: 13 Apr 2012, 16:37 
User avatar

Joined: 07 Dec 2008, 02:35
Jools wrote:
Corrected that. Unit has either died or morphed. Morphed units receive new uID:s.

Morph == Destroyed and at the same time a completely new unit is spawned at the same position with the old commands, giving the appearance of just one unit changing types.


Top
 Offline Profile  
 
PostPosted: 13 Apr 2012, 18:14 
User avatar

Joined: 23 Feb 2009, 16:29
Location: Finland
Yes, that's technically what happens, but not what most users would consider as a confirmed kill.

Spring also counts built dragons teeth as killed units, but we don't have to copy everything spring does -- at least when it makes no sense.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 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.