GroupBlink

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
Hey,
I'm sure you've all seen the Starcraft 2 ingame preview trailer. I really liked the way the zealots can now rapidly leap to a position thus greatly improving their melee fighting capabilities. I tried to emulate that with wc3. Well, first I was a bit disappointed, since in wc3 only one unit actually casts the spell, even if a bunch of the same unit type is selected. So even out of ten selected units with the blink ability, only one will actually blink to the position.
To get that right, I wrote this little trigger, which I used on satyrs with a modified blink ability. Now it's real fun moving and blinking them around in a bunch. Here's my simpleton trigger:

JASS:

function OneId_filter takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId and GetWidgetLife(GetFilterUnit()) > 0.4
endfunction

function GroupBlink takes nothing returns nothing
    local group g=CreateGroup()
    local boolexpr b=Filter(function OneId_filter)
    local unit u=GetOrderedUnit()
    if GetIssuedOrderId()==OrderId("blink") then
        call DisableTrigger(gg_trg_Order)
        set bj_groupEnumTypeId='n00M'
        call GroupEnumUnitsSelected(g, GetOwningPlayer(u), b)
        call GroupPointOrder(g,"blink",GetOrderPointX(),GetOrderPointY())
        call TriggerSleepAction(0.2)
        call EnableTrigger(gg_trg_Order)
    endif
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set u=null
    set b=null
    set g=null
endfunction
        
function InitTrig_Order takes nothing returns nothing
    local integer i=0
    set gg_trg_Order = CreateTrigger()
    loop
        exitwhen i>5
        call TriggerRegisterPlayerUnitEvent(gg_trg_Order,Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER,null)
        call TriggerAddAction(gg_trg_Order, function GroupBlink)
        set i=i+1
    endloop
endfunction


little annotation: my map only got 6 players, that's why 'exitwhen i>5' in the trigger.
 

N-a-z-g-u-l

New Member
Reaction score
30
looks nice ;) i also made a script like that to sell multiple towers without the stupid flag at the towers in a TD...
there is only one thing i would improve: i dont know if that works, but either reduce the TriggerSleepAction thing to TriggerSleepAction(0) or remove it completely, as your trigger reacts on the order, and im pretty sure the order has no delay so the wait is not needed...
as i read over it again, i found another thing... you are creating the unit group and the filter even if the ability isnt blink, it would save performance if you put that into the if-part (well, would not make a difference, but is better style ;) )
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
oh, that's to prevent the trigger from repeating itself - we don't want useless cycles which eventually crash the game

@hero
show me the script of Some! - if Some's script is better, then I'll ask if I can use it.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Nice code here.

JASS:
call DestroyBoolExpr(b) // Never destroy a BoolExpr


You could put the units in a global group when leaping and then as a condition check that the ordered unit is not is the global group, this way no need to disable the trigger.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
you're the first one to say that a boolexpr shouldn't be destroyed.
I've always destroyed them, and never got any problems with it.

so what's your point?

and whom or what do you refer to with your conclusion? (official jass manual, forum discussion, own experience...?)
 

grim001

New Member
Reaction score
10
there's no point in destroying a boolexpr, it always returns the same handle, so just use Condition() always or put it in a global.
 

Sim

Forum Administrator
Staff member
Reaction score
534
> I really liked the way the zealots can now rapidly leap to a position thus greatly improving their melee fighting capabilities.

The Zealots charge, while the Stalkers blink ;)

----------------------------------------------

Good stuff!
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
there's no point in destroying a boolexpr, it always returns the same handle, so just use Condition() always or put it in a global.

so in this case there won't be any need to declare it either. (local boolexpr b=....) ?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top