• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] help with trigger with specif unit event

Status
Not open for further replies.

fengar

F

fengar

i want to make a hero that when he use a skill it replace that hero with other and when the last replaced unit take some damage it replace it again for the first unit, the trouble is that the event takes damage is on specific unit event but i can't use the last replaced unit like the specific unit
 
May seem a little complicated but paste following script into your map header
JASS:
function TRAUTD_Actions takes nothing returns nothing
    local integer i = 0
    loop
        call TriggerRegisterUnitEvent(udg_t[i],GetTriggerUnit(),EVENT_UNIT_ATTACKED)
        set i = i+1
        exitwhen i >= JASS_MAX_ARRAY_SIZE
    endloop
endfunction

function TriggerRegisterAnyUnitTakesDamage takes trigger t returns nothing
    local integer max = CountUnitsInGroup(GetUnitsInRectAll(bj_mapInitialPlayableArea))
    local integer i = 0
    local unit u = null
    local group g = CreateGroup()
    local trigger t2 = CreateTrigger()
    call GroupAddGroup(GetUnitsInRectAll(bj_mapInitialPlayableArea),g)
    loop
        exitwhen i == max
        set u = FirstOfGroup(g)
        call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_ATTACKED)
        call GroupRemoveUnit(g,u)
        set u = null
    endloop
    set udg_t[udg_index] = t
    set udg_index = udg_index+1
    call TriggerAddAction(t2, function TRAUTD_Actions)
    call TriggerRegisterEnterRectSimple(t2,bj_mapInitialPlayableArea)
    set g = null
endfunction
then to use it do following in an initialization trigger.
  • Custom script - Custom script: call TriggerRegisterAnyUnitTakesDamage(CHANGE THIS)
Change the bit that says CHANGE THIS to gg_trg_MyTrigger(MyTrigger = your trigger name). Remember to replace spaces with underscores (_).

If you experience any problems with this just let me know and I'll sort them out.

EDIT:
requires 2 global variables:

t = trigger array
index = integer
 
Last edited:
Status
Not open for further replies.
Back
Top