• 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.

[Solved] Is this safe for MUI?

Status
Not open for further replies.
Level 14
Joined
Nov 30, 2013
Messages
926
I'm starting to become stupid about this so it might be easy to answer. :p
I created a Trigger that uses "Wait" action and a local variable.
I'm not sure whether this is safe or not for the MUI.
Can someone tell me? :confused:
  • AutoRepair
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Wait 0.03 seconds
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Owner of (Constructing structure)) of type |cff808080Repair Tinker|r (Repair Tower Lvl 1)) and do (Actions)
        • Loop - Actions
          • Custom script: local unit TempU = GetConstructingStructure()
          • Custom script: call IssueTargetOrder(GetEnumUnit(), "repair", TempU )
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Minimum wait time is ~0.27 seconds, so anything less than that will wait the minimum time (0.03 is not happening here). Why do you need to delay so briefly? In any case the local unit inside the "Loop - Actions" is completely useless since it's actually a separate function from the main trigger actions (convert to custom text and you'll see how GroupEnum() works by running all units through a separate function). Even if you stored the unit locally properly you wouldn't be able to access it in the group loop.
 
Level 14
Joined
Nov 30, 2013
Messages
926
Why do you need to delay so briefly?

I been having a problem that the picked unit wouldn't respond to the "Order" action if it doesn't have a delay in it.
Adding a delay makes them worked. :l

Edited: So I look around the old threads in this site and find something.
I remodified my Trigger into a bunch a scripts that the local variable works on the group within a single function.
JASS:
function Trig_AutoRepair_Actions takes nothing returns nothing
    local group G = CreateGroup()
    local unit TempU = GetConstructingStructure()
    local unit pU
    call TriggerSleepAction( 0.05 )
    call GroupEnumUnitsOfPlayer(G, GetOwningPlayer(GetConstructingStructure()), null)
    loop
        set pU = FirstOfGroup(G)
        exitwhen pU == null
        if(GetUnitTypeId(pU) == 'h00C') then
            call IssueTargetOrder(pU, "repair", TempU )
        elseif(GetUnitTypeId(pU) == 'h00D') then
            call IssueTargetOrder(pU, "repair", TempU )
        elseif(GetUnitTypeId(pU) == 'h00E') then
            call IssueTargetOrder(pU, "repair", TempU )
        endif
        call GroupRemoveUnit(G, pU)
    endloop
   
    call DestroyGroup(G)
    set G = null
    set pU = null
    set TempU = null
endfunction

//===========================================================================
function InitTrig_AutoRepair takes nothing returns nothing
    set gg_trg_AutoRepair = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_AutoRepair, EVENT_PLAYER_UNIT_CONSTRUCT_START )
    call TriggerAddAction( gg_trg_AutoRepair, function Trig_AutoRepair_Actions )
endfunction
Is this even better than the previous one for the MUI?
 
Last edited:
Status
Not open for further replies.
Top