GUI Unit Event v2.5.2.0

This bundle is marked as approved. It works and satisfies the submission rules.
Unit Event for GUI gives you access to all kinds of events which normal GUI events can't do. Now fully integrating Unit Indexer, I've listed all substantial events and variables. In each event, the custom value of the "triggering unit" is equal to UDex and the way to get the unit with that custom value is via UDexUnits[(Custom value of Unit) --- In this case "UDex"].

  • Detect the instant when a unit starts reincarnating
    Event: Game - DeathEvent Becomes Equal to 0.50

  • Detect when a unit is brought back to life via Reincarnation, Resurrect or Reanimate
    Event: Game - DeathEvent Becomes Equal to 2.00

    You can differentiate between the three of these as well. If it is summoned, that means it was reanimated. If IsUnitReincarnating[UDex] is true, that means it finished reincarnating. Otherwise, it was simply resurrected.

  • Detect when a unit is loaded into a transport
    Event: Game - CargoEvent Becomes Equal to 1.00
    Unit: CargoTransportUnit[UDex] --- The unit who loaded this unit

  • Detect when a unit is unloaded from a transport
    Event: Game - CargoEvent Becomes Equal to 2.00
    Unit: CargoTransportUnit[UDex] --- The unit who unloaded this unit

  • Detect when a unit transforms into a new unit type
    Event: Game - UnitTypeEvent Becomes Equal to 1.00
    Unit Type: UnitTypeOf[UDex] --- The previous unit type

  • Detect the instant before a unit is completely removed from the game
    Event: Game - UnitIndexEvent Becomes Equal to 2.00

  • To detect when any unit is created (including pre-placed units)
    Event: Game - UnitIndexEvent Becomes Equal to 1.00

  • To detect when a new unit is summoned (fires after the Create event)
    Event: Game - UnitIndexEvent Becomes Equal to 0.50
    Unit: SummonerOfUnit[UDex]

  • To detect when any unit dies (including units created dead)
    Event: Game - DeathEvent Becomes Equal to 1.00
    Unit: KillerOfUnit[UDex]

Unit Event also gives you access to some other useful variables, such as:

  • Boolean: IsUnitAlive[(Custom value of Unit)] - never bugs (checking life is not always accurate)

  • Unit Group: CargoTransportGroup[(Custom value of Transporter)] - A unit group which holds all of the cargo of a transporting unit.

There are also some additional obscure things you can do with the system as well, such as looping through all the units in a map or reading data/events based on when the system initialized.


How to install:

- Delete Unit Indexer from your map (if you already have it)
- Copy the "Unit Event Ability" ability from Object Editor
- Copy the Unit Event trigger category
- Paste the Unit Event Ability from object editor twice
- Set the DetectRemoveAbility variable in the Unit Event Config trigger to one of the abilities.
- Set the DetectTransformAbility variable in the same trigger to the other of the two.


Inspiration:

- AutoEvents by grim001
- UnitEvent by Nestharus
- Transport by Jesus4Lyf


  • Unit Event Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • -------- Copy Unit Event Ability from Object Editor, then set DetectRemoveAbility to it as follows: --------
      • -------- --------
      • Set DetectRemoveAbility = Unit Event Ability (Removal Detect)
      • -------- --------
      • -------- Paste it a second time, then set DetectTransformAbility to it as follows: --------
      • -------- --------
      • Set DetectTransformAbility = Unit Event Ability (Transform Detect)
      • -------- --------
      • -------- One additional event to run right before Unit Indexer initializes, added 29 May 2017 for ZiBitheWand3r3r --------
      • Set UnitIndexEvent = -1.00
      • -------- --------
      • -------- Initialize Unit Event now that all the InitTrig_ functions have run --------
      • -------- --------
      • Set IsUnitPreplaced[0] = True
      • Custom script: call ExecuteFunc("UnitEventInit")
      • Set UnitIndexEvent = 3.00
      • Set IsUnitPreplaced[0] = IsUnitTransforming[0]
JASS:
//===========================================================================
function UnitEventDestroyGroup takes integer i returns nothing
    if udg_CargoTransportGroup[i] != null then
        call DestroyGroup(udg_CargoTransportGroup[i])
        set udg_CargoTransportGroup[i] = null
    endif
endfunction
function UnitEventCheckAfter takes nothing returns nothing
    local integer i = 0
    loop
        set i = udg_CheckDeathList[i]
        exitwhen i == 0
        if udg_IsUnitNew[i] then
            //The unit was just created.
            set udg_IsUnitNew[i] = false
        elseif udg_IsUnitTransforming[i] then
           //Added 21 July 2017 to fix the issue re-adding this ability in the same instant
           set udg_UDex = i
           set udg_UnitTypeEvent = 0.00
           set udg_UnitTypeEvent = 1.00
           set udg_UnitTypeOf[i] = GetUnitTypeId(udg_UDexUnits[i]) //Set this afterward to give the user extra reference
           set udg_IsUnitTransforming[i] = false
           call UnitAddAbility(udg_UDexUnits[i], udg_DetectTransformAbility)
        elseif udg_IsUnitAlive[i] then
            //The unit has started reincarnating.
            set udg_IsUnitReincarnating[i] = true
            set udg_IsUnitAlive[i] = false
            set udg_UDex = i
            set udg_DeathEvent = 0.50
            set udg_DeathEvent = 0.00
        endif
        set udg_CheckDeathInList[i] = false
    endloop
    //Empty the list
    set udg_CheckDeathList[0] = 0
endfunction
function UnitEventCheckAfterProxy takes integer i returns nothing
    if udg_CheckDeathList[0] == 0 then
        call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter)
    endif
    if not udg_CheckDeathInList[i] then
        set udg_CheckDeathList[i] = udg_CheckDeathList[0]
        set udg_CheckDeathList[0] = i
        set udg_CheckDeathInList[i] = true
    endif
endfunction

function UnitEventOnUnload takes nothing returns nothing
    local integer i = udg_UDex
    call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i])
    set udg_IsUnitBeingUnloaded[i] = true
    set udg_CargoEvent = 0.00
    set udg_CargoEvent = 2.00
    set udg_CargoEvent = 0.00
    set udg_IsUnitBeingUnloaded[i] = false
    if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then
        set udg_CargoTransportUnit[i] = null
    endif
endfunction

function UnitEventOnDeath takes nothing returns boolean
    local integer pdex = udg_UDex
    set udg_UDex = GetUnitUserData(GetTriggerUnit())
    if udg_UDex != 0 then
        set udg_KillerOfUnit[udg_UDex] = GetKillingUnit() //Added 29 May 2017 for GIMLI_2 
        set udg_IsUnitAlive[udg_UDex] = false
        set udg_DeathEvent = 0.00
        set udg_DeathEvent = 1.00
        set udg_DeathEvent = 0.00
        set udg_KillerOfUnit[udg_UDex] = null
        if udg_CargoTransportUnit[udg_UDex] != null then
            call UnitEventOnUnload()
        endif
    endif
    set udg_UDex = pdex
    return false
endfunction
 
function UnitEventOnOrder takes nothing returns boolean
    local integer pdex = udg_UDex
    local unit u = GetFilterUnit()
    local integer i = GetUnitUserData(u)
    if i > 0 then
        set udg_UDex = i
        if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
            if not udg_IsUnitRemoved[i] then
                set udg_IsUnitRemoved[i] = true
                set udg_IsUnitAlive[i] = false
                set udg_SummonerOfUnit[i] = null
               
                //For backwards-compatibility:
                set udg_DeathEvent = 0.00
                set udg_DeathEvent = 3.00
                set udg_DeathEvent = 0.00
               
                //Fire deindex event for UDex:
                set udg_UnitIndexEvent = 0.00
                set udg_UnitIndexEvent = 2.00
                set udg_UnitIndexEvent = 0.00
               
                set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i]
                set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i]
               
                // Recycle the index for later use
                set udg_UDexUnits[i] = null
                set udg_UDexPrev[i] = udg_UDexLastRecycled
                set udg_UDexLastRecycled = i
                call UnitEventDestroyGroup(i)
            endif
        elseif not udg_IsUnitAlive[i] then
            if not IsUnitType(u, UNIT_TYPE_DEAD) then
                set udg_IsUnitAlive[i] = true
                set udg_DeathEvent = 0.00
                set udg_DeathEvent = 2.00
                set udg_DeathEvent = 0.00
                set udg_IsUnitReincarnating[i] = false
            endif
        elseif IsUnitType(u, UNIT_TYPE_DEAD) then
            if udg_IsUnitNew[i] then
                //This unit was created as a corpse.
                set udg_IsUnitAlive[i] = false
                set udg_DeathEvent = 0.00
                set udg_DeathEvent = 1.00
                set udg_DeathEvent = 0.00
            elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then
                //The unit may have just started reincarnating.
                call UnitEventCheckAfterProxy(i)
            endif
        elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 and not udg_IsUnitTransforming[i] then
            set udg_IsUnitTransforming[i] = true
            call UnitEventCheckAfterProxy(i)  //This block has been updated on 21 July 2017
        endif
        if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then
            call UnitEventOnUnload()
        endif
        set udg_UDex = pdex
    endif
    set u = null
    return false
endfunction
function UnitEventOnSummon takes nothing returns boolean
    local integer pdex = udg_UDex
    set udg_UDex = GetUnitUserData(GetTriggerUnit())
    if udg_IsUnitNew[udg_UDex] then
        set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit()
        set udg_UnitIndexEvent = 0.00
        set udg_UnitIndexEvent = 0.50
        set udg_UnitIndexEvent = 0.00
    endif
    set udg_UDex = pdex
    return false
endfunction
function UnitEventOnLoad takes nothing returns boolean
    local integer pdex = udg_UDex
    local integer i = GetUnitUserData(GetTriggerUnit())
    local integer index
    if i != 0 then
        set udg_UDex = i
        if udg_CargoTransportUnit[i] != null then
            call UnitEventOnUnload()
        endif
        //Loaded corpses do not issue an order when unloaded, therefore must
        //use the enter-region event method taken from Jesus4Lyf's Transport.
        if not udg_IsUnitAlive[i] then
            call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX)
            call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY)
        endif
       
        set udg_CargoTransportUnit[i] = GetTransportUnit()
        set index = GetUnitUserData(udg_CargoTransportUnit[i])
        if udg_CargoTransportGroup[index] == null then
            set udg_CargoTransportGroup[index] = CreateGroup()
        endif
        call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i])
        set udg_CargoEvent = 0.00
        set udg_CargoEvent = 1.00
        set udg_CargoEvent = 0.00
        set udg_UDex = pdex
    endif
    return false
endfunction
function UnitEventEnter takes nothing returns boolean
    local integer pdex = udg_UDex
    local integer i = udg_UDexLastRecycled
    local unit u = GetFilterUnit()
    if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
        //Generate a unique integer index for this unit
        if i == 0 then
            set i = udg_UDexMax + 1
            set udg_UDexMax = i
        else
            set udg_UDexLastRecycled = udg_UDexPrev[i]
        endif
        //Link index to unit, unit to index
        set udg_UDexUnits[i] = u
        call SetUnitUserData(u, i)
       
        //For backwards-compatibility, add the unit to a linked list
        set udg_UDexNext[i] = udg_UDexNext[0]
        set udg_UDexPrev[udg_UDexNext[0]] = i
        set udg_UDexNext[0] = i
        set udg_UDexPrev[i] = 0

        set udg_CheckDeathInList[i] = false

        call UnitAddAbility(u, udg_DetectRemoveAbility)
        call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility)
        call UnitAddAbility(u, udg_DetectTransformAbility)
        set udg_UnitTypeOf[i] = GetUnitTypeId(u)
        set udg_IsUnitNew[i] = true
        set udg_IsUnitAlive[i] = true
        set udg_IsUnitRemoved[i] = false
        set udg_IsUnitReincarnating[i] = false
        set udg_IsUnitPreplaced[i] = udg_IsUnitPreplaced[0] //Added 29 May 2017 for Spellbound
        call UnitEventCheckAfterProxy(i)
       
        //Fire index event for UDex
        set udg_UDex = i
        set udg_UnitIndexEvent = 0.00
        set udg_UnitIndexEvent = 1.00
        set udg_UnitIndexEvent = 0.00
    else
        set udg_UDex = GetUnitUserData(u)
        if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then
            //The unit was dead, but has re-entered the map.
            call UnitEventOnUnload()
        endif
    endif
    set udg_UDex = pdex
    set u = null
    return false
endfunction
//===========================================================================
function UnitEventInit takes nothing returns nothing
    local integer i = bj_MAX_PLAYER_SLOTS //update to make it work with 1.29 
    local player p
    local trigger t = CreateTrigger()
    local trigger load = CreateTrigger()
    local trigger death = CreateTrigger()
    local trigger summon = CreateTrigger()
    local rect r = GetWorldBounds()
    local region re = CreateRegion()
    local boolexpr enterB = Filter(function UnitEventEnter)
    local boolexpr orderB = Filter(function UnitEventOnOrder)
    set udg_WorldMaxX = GetRectMaxX(r)
    set udg_WorldMaxY = GetRectMaxY(r)
    call RegionAddRect(re, r)
    call RemoveRect(r)
    call UnitEventDestroyGroup(0)
    call UnitEventDestroyGroup(1)
   
    set udg_CheckDeathList[0] = 0
    set udg_UnitIndexerEnabled = true
    call TriggerRegisterEnterRegion(CreateTrigger(), re, enterB)
    call TriggerAddCondition(load, Filter(function UnitEventOnLoad))
    call TriggerAddCondition(death, Filter(function UnitEventOnDeath))
    call TriggerAddCondition(summon, Filter(function UnitEventOnSummon))
    loop
        set i = i - 1
        set p = Player(i)
        call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false)
        call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false)
        call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null)
        call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, orderB)
        call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null)
        call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null)
        call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, enterB)
        exitwhen i == 0
    endloop
    set summon = null
    set death = null
    set load = null
    set re = null
    set enterB = null
    set orderB = null
    set p = null
    set r = null
    set t = null
endfunction
function InitTrig_Unit_Event takes nothing returns nothing
endfunction


nestharus, grim001, unitevent, autoevents, unit indexer, reincarnate, reincarnation, reanimation, resurrect, resurrection, detect, death, removal, load, unload, transport, transform, unit type
Contents

Unit Event Testmap (Map)

Reviews
Approved. Makes easy to detect many events that do not exist in the editor. Very useful system.

Moderator

M

Moderator

Maker, Unit Event v2.0.0.0, 17:48, 24th Nov 2011

Approved.

Makes easy to detect many events that do not exist in the editor. Very useful system.
 
Level 6
Joined
Dec 10, 2010
Messages
119
And what for this needed? Senseless work.
My version -
  • Death Event
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
  • Custom script: local integer i=0
  • Custom script: loop
  • Custom script: exitwhen i > 12
    • Custom script: call DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetDyingUnit()) + " has dead.")
  • Custom script: i=i+1
  • Custom script: endloop
 
And what for this needed? Senseless work.
My version -
  • Death Event
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
  • Custom script: local integer i=0
  • Custom script: loop
  • Custom script: exitwhen i > 12
    • Custom script: call DisplayTextToPlayer(Player(0),0,0,GetUnitName(GetDyingUnit()) + " has dead.")
  • Custom script: i=i+1
  • Custom script: endloop

As you have fail to read what Bribe has wrote he mentions "reincarnation" and what you have there, is just a text that the unit has died?
Also this system also uses his famous GUI Unit Indexer; which turned out to be a quite remarkable system

Edit :

Bribe once again your work is remarkable; will surely help those who use GUI.
Good work; Rating 5/5

Evilcrizpy
 
Last edited:
Pain when people do that; Just saying...

On Topic :

Bribe never fails to amaze us all....

Edit :
Hmmmm im not too sure, what could be improved tbh :/
I feel like its missing something but dont know what...


Edit 2 :

How about a floating text at position of the dead unit, showing time till revived maybe?
But only shows for allies of the dying unit....
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
That's the demo map. This doesn't use a timer to detect when reincarnation finishes, so
a timer would not be possible here. The "defend" ability has a bug that make it fire an
"undefend" order when a unit dies, gets removed or gets revived, which is what this is
based on.

You can't get the duration of Reincarnation without consulting the object editor, so this
will work with any duration of reincarnation. It wouldn't make sense to set a timer
because the reincarnation could be 1 second, it could be 7 or it could be 60.
 
That's the demo map. This doesn't use a timer to detect when reincarnation finishes, so
a timer would not be possible here. The "defend" ability has a bug that make it fire an
"undefend" order when a unit dies, gets removed or gets revived, which is what this is
based on.

You can't get the duration of Reincarnation without consulting the object editor, so this
will work with any duration of reincarnation. It wouldn't make sense to set a timer
because the reincarnation could be 1 second, it could be 7 or it could be 60.

Ahh right okay,
haven't had chance todownload the map yet, cause not on my laptop,
I understand, okay then i shall change my rating to 5/5, just that was making it difficult to choose between 5 and 4.5,

Looks great tho.
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
maddeem, you have a very skeptical attitude towards basically everything I upload.

I challenge you to make a reincarnation detection that detects exactly when the unit starts
reincarnating, exactly when it stops reincarnating, perfectly on queue like this does. I also
challenge you to include a way to detect when a unit is raised from the dead like this does.
Also keep in mind that reincarnation can have basically any timeout. So starting a timer to
expire in 7 seconds is not going to do any good.

It can't be done any simpler than this. Look at how complex Unit Event by Nestharus is,
for comparison. This is a minimal approach to do something so useful.

http://www.hiveworkshop.com/forums/jass-functions-413/extension-unit-event-172365/

Reincarnation detection is one of the most requested things out there, as well. So the idea
is bad? Really, I'm calling you on this. Do it better or don't knock it. I want you to explain
your opinion better than this blank reply you've given.

Also, high end maps don't use reincarnation? I'm not sure you know what you're talking about.
 
maddeem, you have a very skeptical attitude towards basically everything I upload.

I challenge you to make a reincarnation detection that detects exactly when the unit starts
reincarnating, exactly when it stops reincarnating, perfectly on queue like this does. I also
challenge you to include a way to detect when a unit is raised from the dead like this does.
Also keep in mind that reincarnation can have basically any timeout. So starting a timer to
expire in 7 seconds is not going to do any good.

It can't be done any simpler than this. Look at how complex Unit Event by Nestharus is,
for comparison. This is a minimal approach to do something so useful.

http://www.hiveworkshop.com/forums/jass-functions-413/extension-unit-event-172365/

Reincarnation detection is one of the most requested things out there, as well. So the idea
is bad? Really, I'm calling you on this. Do it better or don't knock it. I want you to explain
your opinion better than this blank reply you've given.

Also, high end maps don't use reincarnation? I'm not sure you know what you're talking about.

maddeem, A world of notice;
- Don't mess with Bribe
- You should really read up a bit more before posting negative comments about someones system
- Unless you are able to create something the same but in a simpler form

- Bribe makes these, so people are able to have a much easier map making life, rather than doing it themselves, especially those new to Warcraft III and Jass, so he has made GUI Versions.

Evilcrizpy

Edit :
Also as bribe mentions, believe you can do bettter; go ahead.
If you are able to succeed then yes i shall applaud you.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
So let's do this.

-Make another ini trigger with this in? Isn't it useless to check this if all the time even if it's a ini thingie

  • Custom script: if udg_DEvAbility == 0 then
  • -------- --------
  • -------- Copy Death Event Ability from Object Editor, then set DEvAbility to it as follows --------
  • -------- --------
  • Set DEvAbility = Death Event Ability (Undefend Detect)
  • -------- --------
  • Custom script: call ExecuteFunc("InitDeathEvent")
  • Custom script: endif
-You made the make ability permanent bj go away so why not this one as well? (yeah it is a lame bj like the pause unit bj but you already know that)

  • Unit - Add DEvAbility to UDexUnits[UDex]
-Another bj

(Level of DEvAbility for UDexUnits[UDex]) Equal to 0

-And the variable safety checks are they really necessary? the first one could be removed or the last one, no?

  • Set DeathEvent = 0.00
  • Set DeathEvent = 1.00
  • Set DeathEvent = 0.00
Anyway great work as always although I'd like to see a GUIer use this.

edit

and a hidden tag around the code would be nice as well!
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
-And the variable safety checks are they really necessary? the first one could be removed or the last one, no?

I did that because of recursion - that is a nasty thing. If the function is called twice before
it can be set to 0, the second event won't fire because you set variable with value 1 to 1
again which doesn't trigger the event. I set to 0 afterward because maybe you want some
kind of event id check (which I use in this script btw).

Which brings my next point regarding this:

Make another ini trigger with this in? Isn't it useless to check this if all the time even if it's a ini thingie

The problem is the Map Initialization event is not guaranteed to run before the map
initialization event of Unit Indexer, so then you'd be adding an ability to the unit which
has a value of 0.

You made the make ability permanent bj go away so why not this one as well? (yeah it is a lame bj like the pause unit bj but you already know that)

Is there a GUI function for it? I didn't see it, which is why I made the custom script.
Obsessing over BJ's to the point where you make custom script just to avoid them is
pointless in almost all cases. If I cared so much I would eliminate all the GUI if-blocks
and well I'd not even use GUI for that matter, because then I'd be using conditions for
actions for that speed advantage, too. Then I'd be doing some inane variable shortening.

Trust me some things are not worth it. That's why I don't have such impositions on GUI
users who submit their spells here. The standards for a pure-JASS script are much
higher than a GUI script, because there are fewer limitations with pure JASS scripts.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
1.
The problem is the Map Initialization event is not guaranteed to run before the map
initialization event of Unit Indexer, so then you'd be adding an ability to the unit which
has a value of 0.


2.
Is there a GUI function for it? I didn't see it, which is why I made the custom script.
Obsessing over BJ's to the point where you make custom script just to avoid them is
pointless in almost all cases. If I cared so much I would eliminate all the GUI if-blocks
and well I'd not even use GUI for that matter, because then I'd be using conditions for
actions for that speed advantage, too. Then I'd be doing some inane variable shortening.

Trust me some things are not worth it. That's why I don't have such impositions on GUI
users who submit their spells here. The standards for a pure-JASS script are much
higher than a GUI script, because there are fewer limitations with pure JASS scripts.

1. Ah I see, my bad.

2. Yeah it's in the "player" category I think. It confused me a bit that you were a BJ hunter and still had a BJ right before it lol
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
I have a completed Cargo Event which lets you pick all units inside of a transport, detect
when a unit is unloaded from a transport, and also get the transport carrying a unit. It
would require this script to run, but I am wondering if I should just merge it into this
script because AutoEvents by grim001 merges those two libraries as well.
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
Yeah but there are pros and cons to doing it your way -

Pros: No coupling, so if you need reincarnate detect you are not forced to take transport detection
More relevant and specific resources

Cons: have to install this script before using Cargo Event, so Cargo Event will almost
be not worth its own submission because it would be very short.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Yeah maybe that's how it should be done. Either way just have it in another category and tell the user (some have really difficult issues with reading, maybe a picture in the description?) that this category is fully optional, nothing will happen if you remove it; and this and that you will get if you keep it.
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
The thing is it would blend in with this one trigger seamlessly (using these JASS scripts
you can do that, it makes importing easier). Well I will update this resource with the
Cargo Event detection and if anyone complains about this having too many features I
will move it to its own resource.
 
Level 8
Joined
Feb 17, 2009
Messages
292
Since someone like me is bound to stumble upon this resource again, let me just say if you are confused why you import it to another map and it doesn't work, make a new variable called DEvTimer as type Timer. Can't believe no one bothered to explain that after four years but whatever.
 

Wazzz

Map Reviewer
Level 32
Joined
Feb 5, 2009
Messages
4,403
I'm a bit confused as I have imported it into my map but find that everything works other than the reincarnation asset. For some reason it just seems completely unresponsive to reincarnation events.

UPDATE: I fixed it, it was a simple issue of me transferring the triggers before transferring the Death Event ability, so the trigger that relied upon that particular ability was relying on another - doy!

Great system, love it ^_^
 

Ardenian

A

Ardenian

Does this great system aims for adding new events in general ?

What about an event for ' A unit crosses a special effect/ lightning' ?
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
It's possible that the unit will fire the undefend event when it transforms back into a structure, though it's completely hypothetical. Go ahead and add a tree of life to this test map and make a trigger that displays the order ID when any of the 3 orders (point, immediate, target) are issued. If there is an order issued at the exact moment you need, that is the base of what you're looking for. You can then refine the conditions to rule out units that are not ancient type, and to make sure that the ancient is also alive.
 
Okay, so I tried to detect order id with this trigger:

  • Order String
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg("OrderId is: "+I2S(GetIssuedOrderId()))
When the Ancient uproots, it seems to detect something, but it doesn't detect an Order ID when then Tree of Life begins or ends rooting back into place. Does that mean it can't be detected then?
 
Tried building a farm and there was no order id detected upon completion (there was one on building start though). I'm using ConstructEvent to catch buildings that begin contruction - does that mean I can just use Unit Event instead? The reason I was curious about root/uproot was so that I could add/remove abilities to units/buildings that used it.

Alternatively, I could just try making a custom root/uproot with metamorphosis and build tiny farm for the rooting. The goal here is to have flying buildings since structures are generally targetable by anything that can attack structures.
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
Update to 2.1.0.0 - I have added an event "UnitTypeEvent becomes Equal to 1.00" to detect when a unit transforms to a different unit type the instant the new unit type is acquired (so at the very end of the demon hunter's metamorphosis transformation). This was achieved by making a second copy of the Undefend Detect ability that was set to "not permanent" unlike the primary death event ability which detects unit removal. It is re-added to the unit each time it transforms so it can detect subsequent transforms.
 
Oh? I kinda went around the issue of rooting by using metamorphosis and build tiny farm, using passive transformation when the unit got close enough to the x/y co-ordinates of the targeted building to morph into the rooted version. This also solves some crashing issues I was having with buildings that have root that cancel an upgrade.

Still, might come in handy :p
 
Level 38
Joined
Sep 26, 2009
Messages
8,477
Following the trend of my other resources to switch from GUIJASS to a GUI configuration trigger with a JASS backbone, I have updated UnitEvent to version 2.2.0.0!

This is a big departure from previous versions, namely that it actually absorbs the Unit Indexer trigger into itself - which means that Unit Event is now also Unit Indexer. Does this mean that no one can use Unit Indexer by itself without Unit Event? NO. But if you use Unit Event, you must delete the Unit Indexer trigger.

Why did I do this? Simplification and efficiency. The current code for Unit Event is about half of what the combined length of the old Unit Event and Unit Indexer were. I also had additional events running off of Unit Indexer which overlapped what I was doing in Unit Event. AutoEvents by grim001 and UnitEvent by Nestharus both integrate their event library with their indexer for this reason, and now I've done the same.

I made some big improvements, as well:

UnitIndexEvent Becomes Equal to 2.00 now fires the instant the unit is removed, not after an arbitrary amount of time. It also does not bug when a paused unit is removed from a transport, so I no longer need a timer to detect when they are unloaded.

I also no longer need a timer to detect when a corpse is unloaded from a transport, as I am now using Jesus4Lyf's "enter region" trick to detect when those are unloaded.

Hope you guys like it, and - as always - feel free to ask me any questions you have about it.
 
"UnitIndexEvent Becomes Equal to 2.00 now fires the instant the unit is removed, not after an arbitrary amount of time."

I always wondered about that. This way seems better. Also does that mean that the removal of a timer makes use up less resources to run?

Are you going to JASSify the actual Unit Indexer as well? And Heal Event and 2.5D Knockback?
 
Top