1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The mythological era has spawned some interesting characters around. Check them out and be sure to vote for them in the 30th Poll of the Texturing Contest.
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Hivers united and created a bunch of 2v2 melee maps. Vote for the best in our Melee Mapping Contest #4 - Poll!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

GUI Unit Event v2.5.2.0

Submitted by Bribe
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


Triggers
  • 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]

Code (vJASS):

//===========================================================================
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
 



Keywords
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
Moderator
Approved. Makes easy to detect many events that do not exist in the editor. Very useful system.
  1. 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.
     
  2. -Berz-

    -Berz-

    Joined:
    Mar 5, 2008
    Messages:
    3,203
    Resources:
    123
    Icons:
    111
    Packs:
    1
    Skins:
    1
    Spells:
    10
    Resources:
    123
    Looks good, and GUI users will sure find a great use of it :)
     
  3. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,007
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    GJ
    At first, when I read the title "Death Event", I was like "... Fail" xD

    Oh and Believe it or not, I'm using your GUI UnitIndexer because Nestharus' UnitIndexer has LUA scripts :p
     
  4. OxygenD

    OxygenD

    Joined:
    Dec 10, 2010
    Messages:
    101
    Resources:
    0
    Resources:
    0
    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
     
  5. EvilCrizpy

    EvilCrizpy

    Joined:
    Jul 14, 2007
    Messages:
    692
    Resources:
    6
    Models:
    2
    Maps:
    1
    Spells:
    3
    Resources:
    6
    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: Aug 15, 2011
  6. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    @OxygenD - you should have read the post first especially the trigger itself...

    Anyway, this is certainly useful and nicely done... ^_^
     
  7. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,773
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Updated with description on why this is important and also how to use it.

    Evilcrizpy, anything I should change or add to make this a 5/5 for you?
     
  8. EvilCrizpy

    EvilCrizpy

    Joined:
    Jul 14, 2007
    Messages:
    692
    Resources:
    6
    Models:
    2
    Maps:
    1
    Spells:
    3
    Resources:
    6
    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....
     
  9. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,773
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    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.
     
  10. EvilCrizpy

    EvilCrizpy

    Joined:
    Jul 14, 2007
    Messages:
    692
    Resources:
    6
    Models:
    2
    Maps:
    1
    Spells:
    3
    Resources:
    6
    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.
     
  11. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,232
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    Lol instead of going through all this work I'd rather trigger my own reincarnate -.-
    Also, all this work for a spell that high end maps don't even use? Well the idea is bad, but the execution was good, I'll rate this 3/5.
     
  12. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,773
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    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.
     
  13. EvilCrizpy

    EvilCrizpy

    Joined:
    Jul 14, 2007
    Messages:
    692
    Resources:
    6
    Models:
    2
    Maps:
    1
    Spells:
    3
    Resources:
    6
    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.
     
  14. Jazztastic

    Jazztastic

    Joined:
    Apr 4, 2011
    Messages:
    895
    Resources:
    7
    Spells:
    6
    Tutorials:
    1
    Resources:
    7
    So if I understand this correctly, it can detect not only reincarnation, but also animate dead and resurrection?

    I love these systems. Keep making shit Bribe, it is purely amazing.
     
  15. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    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!
     
  16. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,773
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    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:

    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.

    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.
     
  17. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    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
     
  18. Orcnet

    Orcnet

    Joined:
    Jul 31, 2010
    Messages:
    3,873
    Resources:
    4
    Maps:
    3
    Tutorials:
    1
    Resources:
    4
    really useful for others like me :)
     
  19. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,773
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    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.