• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Extension] Unit Event

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Something just occurred to me, if the DecayEvent is prolonged with
something like UnitSuspendDecay, it can really increase the chances
that the corpse was removed via RemoveUnit after the 88 second (or
whatever) cutoff period. What is wrong with hooking RemoveUnit?
The RemoveUnit hook could not possibly be called enough times to
produce lag.

Hooking RemoveUnit would also help you to deindex units properly
when they are paused, in a transport and then removed, because
your Unit Indexer still bugs when this happens.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Actually... it does matter


I had a map long ago and when I had an early version of this system that hooked RemoveUnit, it caused mass low fps (like 0). When I got rid of RemoveUnit hook and used timer, it ran at 60 fps.


So the RemoveUnit hook request is denied. I worked hard to get rid of it because it made one of my maps unplayable (a map I never finished, but w/e).
 
Level 7
Joined
Dec 3, 2006
Messages
339
JASS:
            loop
                call TriggerRegisterPlayerUnitEvent(death,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
                exitwhen 0==i
                set i=i-1
            endloop
Could be replaced with:
JASS:
            call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath)

using RegisterPlayerUnitEvent ofc.

Heck you could even make UnitIndexer use it as well probably; but it's probably not that much of a speed boost.
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
Was just notified that the unit in the map had an unknown ability. This is the Unit Indexer ability. I have re-uploaded the map to make it so that it has the UnitIndexer ability in the map. If you do not edit it to have the correct UnitIndexer ability for your map, the system decay event will not work and will fire incorrectly as a RemoveUnit event.

The Lua code does add the ability to the unit, but as Lua doesn't appear to work on newer machines, you'll just have to remember to edit the ability on the unit to the UnitIndexer ability.

edit
I have just modified the code in the Lua version and the code in the map to automatically add the UnitIndexer ability, so don't worry about editing it now, just update if you aren't using the Lua version : ).
 
Top