• 🏆 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] MUI Timer

Status
Not open for further replies.
Level 9
Joined
Jan 3, 2010
Messages
359
I've Created this Trigger :
JASS:
scope IntelligenceBlow initializer init

globals
    private unit u = null
    private real inc = 0
    private timer time = CreateTimer()
endglobals

    private function Ends takes nothing returns nothing
        call UnitRemoveAbility(u, 'B007')
        call UnitAddBonus(u, 7, R2I(inc / -1))
    endfunction

    private function Actions takes nothing returns nothing
        set u = GetSpellTargetUnit()
        call PauseTimer(time)
        if GetUnitAbilityLevel(u, 'B007') > 0 then
        call UnitAddBonus(u, 7, R2I(inc / -1))
        endif
        set inc = GetHeroInt(u, true) * 0.5
        call UnitAddBonus(u, 7, R2I(inc))
        call CreateSpellBar(u, 'A00K', 0.5, "Intelligence Blow")
        call TimerStart(time, 300, false, function Ends)
    endfunction

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00K'
    endfunction
        
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0

        call TriggerAddAction(t, function Actions)
        call TriggerAddCondition(t, Condition(function Conditions))

        loop
            exitwhen i >= 15

            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CHANNEL, null)
            set i = i + 1
        endloop

        set t = null
    endfunction

endscope

and my question is, how to make it MUI ?
 
Level 11
Joined
Sep 30, 2009
Messages
697
JASS:
scope IntelligenceBlow

    private struct spell
        unit u = null
        real inc = 0
        timer time

        private static method timeout takes nothing returns nothing
            local thistype this = GetTimerData(GetExpiredTimer())
            call UnitRemoveAbility(.u, 'B007')
            call UnitAddBonus(.u, 7, R2I(.inc / -1))
            call DestroyTimer(GetExpiredTimer())
        endmethod

        private static method actions takes nothing returns nothing
            local thistype this = thistype.allocate()
            set .u = GetSpellTargetUnit()
            set .time = NewTimer()
            
            if GetUnitAbilityLevel(.u, 'B007') > 0 then
                //call UnitAddBonus(.u, 7, R2I(.inc / -1))
            endif
            
            set .inc = GetHeroInt(.u, true) * 0.5
            call UnitAddBonus(.u, 7, R2I(.inc))
            call CreateSpellBar(.u, 'A00K', 0.5, "Intelligence Blow")
            call SetTimerData(.time, this)
            call TimerStart(.time, 300, false, function thistype.timeout)
        endmethod

        private static method conditions takes nothing returns boolean
            return GetSpellAbilityId() == 'A00K'
        endmethod

        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            local integer i = 0

            call TriggerAddAction(t, function thistype.actions)
            call TriggerAddCondition(t, Condition(function thistype.conditions))

            loop
                exitwhen i >= 15

                call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CHANNEL, null)
                set i = i + 1
            endloop

            set t = null
        endmethod
    
    endstruct

endscope
 
Status
Not open for further replies.
Top