Would This work and be MUI?

wellwish3r

wishes wells.
Reaction score
52
So if you call this function via another trigger
JASS:
function RangeAttack takes unit u,unit t returns nothing


would this whole block work and be MUI?

JASS:
function RangeAttack takes unit u,unit t returns nothing
        local integer i = 0
        local integer ai
        local boolean found = false
        local group grp = CreateGroup()
        local real facing
        loop
            exitwhen found == true
            if D<i>.attacker == u then
                set ai = i
                set found  = true
            endif
            set i = i+1
        endloop
        call TargDmg(D[ai].attacker,t)
        set D[ai].stamina = 0
    endfunction
    
    private function DmgActions takes nothing returns nothing
    endfunction
    
    private function TargDmg takes unit u, unit ta returns nothing\
        local trigger t = CreateTrigger()
        call TriggerRegisterUnitEvent(t,ta,EVENT_UNIT_DAMAGED)
        call TriggerAddAction(t,function DmgActions)
    endfunction</i>


the struct etc where declared before
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
MUI? I don't see why not, providing no other function is changed the D[] global at the same time as this one.

Works, however, is a different matter. For it to work, you need to either move RangeAttack below TargDmg, or change
JASS:
call TargDmg(D[ai].attacker,t)
to
JASS:
call TargDmg.execute(D[ai].attacker,t)


Might also want to get rid of the \ after
JASS:
private function TargDmg takes unit u, unit ta returns nothing\
 

wellwish3r

wishes wells.
Reaction score
52
ye just noticed the / (handwrote this in notepad :))

why would that make it work (i didnt care about the order at the time, moved it above already)

JASS:
call TargDmg.execute(D[ai].attacker,t)
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
A function cannot call another function that is below it, as that function hasn't been defined yet. FunctionName.execute() is a vJass feature that can call a function from above or below, because it uses the native ExecuteFunc("FunctionName"), but allows arguments. This would let RangeAttack be above TargDmg, but still call TargDmg.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top