• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] how do i make this MUI? :O

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
first time i do a trigger like this and i have no idea how to make this MUI! :O shame on me

P.s its a unit ability so u cant learn it with a hero

JASS:
library Cryofrost initializer Init needs CSSafety,CSData

globals
    private constant integer Abil_id = 'A010'
    private constant integer Slow_id = 'A009'
    private constant integer Buff_id = 'B003'
endglobals

private struct Data
unit t

integer stacks

timer time
endstruct

private function PreLoad takes nothing returns nothing
    local unit dum = CreateUnit(Player(15),Dum_id,0.,0.,0.)
    call UnitAddAbility(dum,Slow_id)
    call RemoveUnit(dum)
    set dum = null
endfunction
    
private function Zero takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local Data d = GetCSData(t)
    
    set d.stacks = 0
    
    call ReleaseTimer(t)
endfunction
    
private function Atked takes nothing returns nothing
    local Data d = GetCSData(GetTriggeringTrigger())
    local unit a = GetAttacker()
    local unit t = GetTriggerUnit()
    local unit dum = CreateUnit(GetOwningPlayer(a),Dum_id,GetUnitX(t),GetUnitY(t),0.)
    
    call UnitAddAbility(dum,Slow_id)
    
    if t == d.t then
        if d.stacks < 10 then
            set d.stacks = d.stacks + 1
        endif
    else
        set d.stacks = 1
        set d.t = t
    endif
    
    call ReleaseTimer(d.time)
    set d.time = NewTimer()
    
    call SetUnitAbilityLevel(dum,Slow_id,d.stacks)
    call IssueTargetOrder(dum,"slow",t)
    call UnitApplyTimedLife(dum,'BTLF',2.)
    
    call SetCSData(d.time,d)
    call TimerStart(d.time,3.,false,function Zero)
    
    set a = null
    set t = null
    set dum = null
endfunction

private function atkfilt takes nothing returns boolean
    local Data d = GetCSData(GetTriggeringTrigger())
    local unit t = GetTriggerUnit()
    local unit a = GetAttacker()
    local boolean ok = GetUnitAbilityLevel(a,Abil_id) > 0 and IsUnitEnemy(t,GetOwningPlayer(a))
    set t = null
    set a = null
    return ok
endfunction

private function Init takes nothing returns nothing
    local Data d = Data.create()
    local trigger t = CreateTrigger()
    local integer index = 0

    
    call SetCSData(t,d)
    set d.time = NewTimer()
    
    loop
        call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_ATTACKED,null)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddAction(t,function Atked)
    call TriggerAddCondition(t,Filter(function atkfilt))
    
    set t = null
    call PreLoad()
endfunction

endlibrary
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Why in the attack filter, you retrieve an attached struct (local Data d = GetCSData(GetTriggeringTrigger())) and do not use it in any way?
 
Status
Not open for further replies.
Top