Page 1 of 1

UnitDestroyed is called when construction is canceled?

Posted: 05 Nov 2010, 04:50
by smoth
Um so why? or am I doin it rong?

I cannot use the attackerid param to detect it, because if the attacker dies before the projectile hits from what I understand the attackerid will be nil

so is there a call that is ONLY called when a unit dies? or is there a way I can better use this command?

Re: UnitDestroyed is called when construction is canceled?

Posted: 05 Nov 2010, 04:56
by FLOZi
Have you tried using Spring.GetUnitHealth to get the buildprogress? I'm not sure whether it will work or not but it's worth a try.

Re: UnitDestroyed is called when construction is canceled?

Posted: 05 Nov 2010, 04:56
by knorke
for my logging thing i use UnitDamaged

Code: Select all

function widget:UnitDamaged (unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, attackerID, attackerDefID, attackerTeam) 
if (Spring.GetGameSeconds() < 1) then 
	return --for some reason units "die" in the first moments of gameplay when startunits spawn in some mods
	end
	
if (Spring.GetUnitHealth (unitID) > 0 ) then 
	return 
	end
--unit actually died here--
...
...
didnt notice it getting called for decaying nano frames.

Re: UnitDestroyed is called when construction is canceled?

Posted: 05 Nov 2010, 05:06
by smoth
I will try it out..

for now I have to sleep, thanks guys.

Re: UnitDestroyed is called when construction is canceled?

Posted: 06 Nov 2010, 22:27
by smoth
that seems to have worked. thanks guys