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?
Widget::UnitDestroyed
Moderator: Moderators
Re: Widget::UnitDestroyed
I think you can get some information by looking at the UnitLeftLos and UnitLeftRadar callins. Don't remember how it worked.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: Widget::UnitDestroyed
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.
Re: Widget::UnitDestroyed
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...
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...
Re: Widget::UnitDestroyed
Code: Select all
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
Re: Widget::UnitDestroyed
Corrected that. Unit has either died or morphed. Morphed units receive new uID:s.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]
Re: Widget::UnitDestroyed
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.Jools wrote:Corrected that. Unit has either died or morphed. Morphed units receive new uID:s.
Re: Widget::UnitDestroyed
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.
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.
Re: Widget::UnitDestroyed
I just wanted to say: Niobium is such a cool guy! Just used that trick in my widget