1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Very very very strange error

Discussion in 'Triggers & Scripts' started by Saishy, Jan 14, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    That is what happen: (See attachs)

    That is the code:

    Code (vJASS):
    scope UnlimitedBladeWorks initializer Init_UBW

    globals
        private player tempplayer
        private group tempgroup
        private boolexpr EnumFilter
        private string array messages[3]
    endglobals

    private struct UBW
        unit archer
        real xarcher
        real yarcher
        location array pother[12]
        integer count
    endstruct

    //===========================================================================

    private function Trig_UBW_start_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A01W' ) then
            return true
        endif
        return false
    endfunction

    //===========================================================================

    private function IsEnemyHero takes nothing returns boolean
        return (((IsUnitEnemy(GetFilterUnit(), tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)) and (IsUnitIllusion(GetFilterUnit()) == false)) == true)
    endfunction

    //===========================================================================

    private function UBW_ItemPos takes nothing returns nothing
        local real x = -2684.00
        local real y = 5240.00
        call SetItemPosition(GetEnumItem(), x, y)
    endfunction

    //===========================================================================

    private function UBW_battle takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local integer ti = 0
        local unit tempunit
       
        // Already end
        call SetUnitPosition(u.archer, u.xarcher, u.yarcher)
        call PanCameraToTimedForPlayer(GetOwningPlayer(u.archer), u.xarcher, u.yarcher, 0)
        set tempgroup = GetUnitsInRectMatching(gg_rct_Unlimited_Blade_Works, null)
       
        loop
            set tempunit = FirstOfGroup(tempgroup)
            exitwhen tempunit == null
            call SetUnitPositionLoc(tempunit, u.pother[GetPlayerId(GetOwningPlayer(tempunit))])
            call PanCameraToTimedLocForPlayer(GetOwningPlayer(tempunit), u.pother[GetPlayerId(GetOwningPlayer(tempunit))], 0)
        endloop
       
        call EnumItemsInRect(gg_rct_Unlimited_Blade_Works, null, function UBW_ItemPos)
        call UnitRemoveAbility(u.archer, 'A021')
        call UnitRemoveAbility(u.archer, 'B009')
        call UnitRemoveAbility(u.archer, 'A01X')
        call UnitRemoveAbility(u.archer, 'A01H')
        call UnitRemoveAbility(u.archer, 'A01Z')
        call DisableTrigger( gg_trg_UBW_mana_regen )
       
        call ReleaseTimer(GetExpiredTimer())
        call u.destroy()
    endfunction

    //===========================================================================

    private function UBW_Phrases takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local timer t
        local real tempx1
        local real tempy1
        local real tempx2
        local real tempy2
        local unit tempunit
        local integer ti
       
        call BJDebugMsg("u.archer is equal to " + GetUnitName(u.archer))
        call BJDebugMsg("u.count is equal to " + (I2S(u.count)))
       
        if (GetWidgetLife(u.archer) > 0.405) then // Checks if alive
                call CreateTextTagUnitBJ( messages[u.count], u.archer, 0, 10, 100, 100, 100, 0 )
                call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                call SetTextTagLifespan( bj_lastCreatedTextTag, 2.50 )            
            if (u.count == 3) then
                set tempx1 = GetUnitX(u.archer)
                set tempy1 = GetUnitY(u.archer)
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", tempx1, tempy1))
                set tempplayer = GetOwningPlayer(u.archer)
                call GroupEnumUnitsInRange(tempgroup, tempx1, tempy1, 600, Condition(function IsEnemyHero))
               
                    call BJDebugMsg("hi1")
                   
                set tempx1 = GetRectCenterX(gg_rct_Unlimited_Blade_Works)
                set tempy1 = GetRectCenterY(gg_rct_Unlimited_Blade_Works)
               
                // Prepare to face your enemy
                set u.xarcher = GetUnitX(u.archer)
                set u.yarcher = GetUnitY(u.archer)
                set tempx2 = tempx1 + 250 * Cos(90 * bj_DEGTORAD)
                set tempy2 = tempy1 + 250 * Sin(90 * bj_DEGTORAD)
                call SetUnitPosition(u.archer, tempx2, tempy2)
                call PanCameraToTimedForPlayer( GetOwningPlayer(u.archer), tempx1, tempy1, 0 )
                call UnitAddAbility(u.archer, 'A021')
                call SetUnitAbilityLevel(u.archer, 'A01Y', GetUnitAbilityLevel(u.archer, 'A01W'))
                call SetPlayerAbilityAvailable(GetOwningPlayer(u.archer), 'A021', false)
                call UnitAddAbility(u.archer, 'A01X')
                call SetUnitAbilityLevel(u.archer, 'A01X', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01H')
                call SetUnitAbilityLevel(u.archer, 'A01H', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01Z')
                call SetUnitAbilityLevel(u.archer, 'A01Z', GetUnitAbilityLevel(u.archer, 'A01W'))
                //call EnableTrigger( gg_trg_UBW_mana_regen )
               
                call BJDebugMsg("hi2")
               
                loop // Time to send enemies to the battle
                    set tempunit = FirstOfGroup(tempgroup)
                    exitwhen tempunit == null
                    set u.pother[GetPlayerId(GetOwningPlayer(tempunit))] = GetUnitLoc(tempunit)
                    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", u.pother[GetPlayerId(GetOwningPlayer(tempunit))]))
                    set tempx2 = tempx1 + 250 * Cos(270 * bj_DEGTORAD)
                    set tempy2 = tempy1 + 250 * Sin(270 * bj_DEGTORAD)
                    call SetUnitPosition(tempunit, tempx2, tempy2)
                    call PanCameraToTimedForPlayer( GetOwningPlayer(tempunit), tempx1, tempy1, 0 )
                endloop
               
                    call BJDebugMsg("hi3")
            endif
        endif
       
        set u.count = (u.count + 1)
           
        if (u.count == 4) then
            call BJDebugMsg("Its over")
            call ReleaseTimer(GetExpiredTimer())
            set ti = (( 4 + ( 2 * (GetUnitAbilityLevel(u.archer, 'A01W')))))
            set t = NewTimer()
            call SetTimerData(t,u)
            call TimerStart(t, ti, false, function UBW_battle)
        endif
       
    endfunction

    //===========================================================================

    private function Trig_UBW_start_Actions takes nothing returns nothing
        local item tempitem
        local UBW u = UBW.create()
        local timer t = NewTimer()
        set u.archer = GetTriggerUnit()
        call CreateTextTagUnitBJ( "I am the bone of my sword.|nSteel is my body, and fire is my blood.", u.archer, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.50 )
        set u.count = 0
        call SetTimerData(t,u)
        call TimerStart(t, 2.5, true, function UBW_Phrases)
    endfunction

    //===========================================================================

    private function Init_UBW takes nothing returns nothing
        local trigger UBW_start = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( UBW_start, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( UBW_start, Condition( function Trig_UBW_start_Conditions ) )
        call TriggerAddAction( UBW_start, function Trig_UBW_start_Actions )
        set tempgroup = CreateGroup()
        set EnumFilter = Filter(function IsEnemyHero)
        set messages[0] = "I have created over a thousand blades.|nUnknown to death. Nor known to life."
        set messages[1] = "Have withstood pain to create many weapons.|nYet, those hands will never hold anything."
        set messages[2] = "So as I pray, Unlimited Blade Works."
        set UBW_start = null
    endfunction

    endscope


    I think the problem is between call BJDebugMsg("hi3") and call BJDebugMsg("hi2") since the trigger keep looping Hi2 and u.count never past over 3.

    Thanks for any help!
     

    Attached Files:

  2. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    You never remove tempunit from the group ;)
    So add:
    call GroupRemoveUnit(tempgroup,tempunit)
    in the loop after exitwhen tempunit==null
     
    Last edited: Jan 14, 2009
  3. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    I can't believe you fixed that o.o
    I feel more dumb each time I post here xD
    Really thanks!

    ----//----

    Solved, if anyone have an idea or optimization feel free to post!

    Code (vJASS):
    scope UnlimitedBladeWorks initializer Init_UBW

    globals
        private player tempplayer
        private group tempgroup
        private boolexpr EnumFilter
        private string array messages[3]
    endglobals

    private struct UBW
        unit archer
        real xarcher
        real yarcher
        location array pother[12]
        integer count
    endstruct

    //===========================================================================

    private function Trig_UBW_start_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A01W' ) then
            return true
        endif
        return false
    endfunction

    //===========================================================================

    private function IsEnemyHero takes nothing returns boolean
        return (((IsUnitEnemy(GetFilterUnit(), tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)) and (IsUnitIllusion(GetFilterUnit()) == false)) == true)
    endfunction

    //===========================================================================

    private function UBW_ItemPos takes nothing returns nothing
        local real x = -2684.00
        local real y = 5240.00
        call SetItemPosition(GetEnumItem(), x, y)
    endfunction

    //===========================================================================

    private function UBW_battle takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local integer ti = 0
        local unit tempunit
       
        // Already end
        call SetUnitPosition(u.archer, u.xarcher, u.yarcher)
        call PanCameraToTimedForPlayer(GetOwningPlayer(u.archer), u.xarcher, u.yarcher, 0)
        set tempgroup = GetUnitsInRectMatching(gg_rct_Unlimited_Blade_Works, null)
       
        loop
            set tempunit = FirstOfGroup(tempgroup)
            exitwhen tempunit == null
            call GroupRemoveUnit(tempgroup, tempunit)
            call SetUnitPositionLoc(tempunit, u.pother[GetPlayerId(GetOwningPlayer(tempunit))])
            call PanCameraToTimedLocForPlayer(GetOwningPlayer(tempunit), u.pother[GetPlayerId(GetOwningPlayer(tempunit))], 0)
        endloop
       
        call EnumItemsInRect(gg_rct_Unlimited_Blade_Works, null, function UBW_ItemPos)
        call UnitRemoveAbility(u.archer, 'A021')
        call UnitRemoveAbility(u.archer, 'B009')
        call UnitRemoveAbility(u.archer, 'A01X')
        call UnitRemoveAbility(u.archer, 'A01H')
        call UnitRemoveAbility(u.archer, 'A01Z')
        call DisableTrigger( gg_trg_UBW_mana_regen )
       
        call ReleaseTimer(GetExpiredTimer())
        call u.destroy()
    endfunction

    //===========================================================================

    private function UBW_Phrases takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local timer t
        local real tempx1
        local real tempy1
        local real tempx2
        local real tempy2
        local unit tempunit
        local integer ti
       
        call BJDebugMsg("u.archer is equal to " + GetUnitName(u.archer))
        call BJDebugMsg("u.count is equal to " + (I2S(u.count)))
       
        if (GetWidgetLife(u.archer) > 0.405) then // Checks if alive
                call CreateTextTagUnitBJ( messages[u.count], u.archer, 0, 10, 100, 100, 100, 0 )
                call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                call SetTextTagLifespan( bj_lastCreatedTextTag, 2.50 )            
            if (u.count == 3) then
                set tempx1 = GetUnitX(u.archer)
                set tempy1 = GetUnitY(u.archer)
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", tempx1, tempy1))
                set tempplayer = GetOwningPlayer(u.archer)
                call GroupEnumUnitsInRange(tempgroup, tempx1, tempy1, 600, Condition(function IsEnemyHero))
               
                    call BJDebugMsg("hi1")
                   
                set tempx1 = GetRectCenterX(gg_rct_Unlimited_Blade_Works)
                set tempy1 = GetRectCenterY(gg_rct_Unlimited_Blade_Works)
               
                // Prepare to face your enemy
                set u.xarcher = GetUnitX(u.archer)
                set u.yarcher = GetUnitY(u.archer)
                set tempx2 = tempx1 + 250 * Cos(90 * bj_DEGTORAD)
                set tempy2 = tempy1 + 250 * Sin(90 * bj_DEGTORAD)
                call SetUnitPosition(u.archer, tempx2, tempy2)
                call PanCameraToTimedForPlayer( GetOwningPlayer(u.archer), tempx1, tempy1, 0 )
                call UnitAddAbility(u.archer, 'A021')
                call SetUnitAbilityLevel(u.archer, 'A01Y', GetUnitAbilityLevel(u.archer, 'A01W'))
                call SetPlayerAbilityAvailable(GetOwningPlayer(u.archer), 'A021', false)
                call UnitAddAbility(u.archer, 'A01X')
                call SetUnitAbilityLevel(u.archer, 'A01X', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01H')
                call SetUnitAbilityLevel(u.archer, 'A01H', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01Z')
                call SetUnitAbilityLevel(u.archer, 'A01Z', GetUnitAbilityLevel(u.archer, 'A01W'))
                call EnableTrigger( gg_trg_UBW_mana_regen )
               
                call BJDebugMsg("hi2")
               
                loop // Time to send enemies to the battle
                    set tempunit = FirstOfGroup(tempgroup)
                    exitwhen tempunit == null
                    call GroupRemoveUnit(tempgroup, tempunit)
                    set u.pother[GetPlayerId(GetOwningPlayer(tempunit))] = GetUnitLoc(tempunit)
                    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", u.pother[GetPlayerId(GetOwningPlayer(tempunit))]))
                    set tempx2 = tempx1 + 250 * Cos(270 * bj_DEGTORAD)
                    set tempy2 = tempy1 + 250 * Sin(270 * bj_DEGTORAD)
                    call SetUnitPosition(tempunit, tempx2, tempy2)
                    call PanCameraToTimedForPlayer( GetOwningPlayer(tempunit), tempx1, tempy1, 0 )
                endloop
               
                    call BJDebugMsg("hi3")
            endif
        endif
       
        set u.count = (u.count + 1)
           
        if (u.count == 4) then
            call BJDebugMsg("Its over")
            call ReleaseTimer(GetExpiredTimer())
            set ti = (( 4 + ( 2 * (GetUnitAbilityLevel(u.archer, 'A01W')))))
            set t = NewTimer()
            call SetTimerData(t,u)
            call TimerStart(t, ti, false, function UBW_battle)
        endif
       
    endfunction

    //===========================================================================

    private function Trig_UBW_start_Actions takes nothing returns nothing
        local item tempitem
        local UBW u = UBW.create()
        local timer t = NewTimer()
        set u.archer = GetTriggerUnit()
        call CreateTextTagUnitBJ( "I am the bone of my sword.|nSteel is my body, and fire is my blood.", u.archer, 0, 10, 100, 100, 100, 0 )
        call SetTextTagPermanent( bj_lastCreatedTextTag, false )
        call SetTextTagLifespan( bj_lastCreatedTextTag, 2.50 )
        set u.count = 0
        call SetTimerData(t,u)
        call TimerStart(t, 2.5, true, function UBW_Phrases)
    endfunction

    //===========================================================================

    private function Init_UBW takes nothing returns nothing
        local trigger UBW_start = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( UBW_start, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( UBW_start, Condition( function Trig_UBW_start_Conditions ) )
        call TriggerAddAction( UBW_start, function Trig_UBW_start_Actions )
        set tempgroup = CreateGroup()
        set EnumFilter = Filter(function IsEnemyHero)
        set messages[0] = "I have created over a thousand blades.|nUnknown to death. Nor known to life."
        set messages[1] = "Have withstood pain to create many weapons.|nYet, those hands will never hold anything."
        set messages[2] = "So as I pray, Unlimited Blade Works."
        set UBW_start = null
    endfunction

    endscope
     
  4. Ciebron

    Ciebron

    Joined:
    Apr 6, 2008
    Messages:
    760
    Resources:
    2
    Spells:
    2
    Resources:
    2
    Code (vJASS):
    private function Trig_UBW_start_Conditions takes nothing returns boolean
        if ( GetSpellAbilityId() == 'A01W' ) then
            return true
        endif
        return false
    endfunction


    into this


    Code (vJASS):
    private function Trig_UBW_start_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A01W'
    endfunction


    also dont use actions

    do

    Big
    Code (vJASS):
    scope UnlimitedBladeWorks initializer Init_UBW

    globals
        private player tempplayer
        private group tempgroup
        private boolexpr EnumFilter
        private string array messages[3]
    endglobals

    private struct UBW
        unit archer
        real xarcher
        real yarcher
        location array pother[12]
        integer count
    endstruct

    //===========================================================================
    //===========================================================================

    private function IsEnemyHero takes nothing returns boolean
        return (((IsUnitEnemy(GetFilterUnit(), tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)) and (IsUnitIllusion(GetFilterUnit()) == false)) == true)
    endfunction

    //===========================================================================

    private function UBW_ItemPos takes nothing returns nothing
        local real x = -2684.00
        local real y = 5240.00
        call SetItemPosition(GetEnumItem(), x, y)
    endfunction

    //===========================================================================

    private function UBW_battle takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local integer ti = 0
        local unit tempunit

        // Already end
        call SetUnitPosition(u.archer, u.xarcher, u.yarcher)
        call PanCameraToTimedForPlayer(GetOwningPlayer(u.archer), u.xarcher, u.yarcher, 0)
        set tempgroup = GetUnitsInRectMatching(gg_rct_Unlimited_Blade_Works, null)

        loop
            set tempunit = FirstOfGroup(tempgroup)
            exitwhen tempunit == null
            call GroupRemoveUnit(tempgroup, tempunit)
            call SetUnitPositionLoc(tempunit, u.pother[GetPlayerId(GetOwningPlayer(tempunit))])
            call PanCameraToTimedLocForPlayer(GetOwningPlayer(tempunit), u.pother[GetPlayerId(GetOwningPlayer(tempunit))], 0)
        endloop

        call EnumItemsInRect(gg_rct_Unlimited_Blade_Works, null, function UBW_ItemPos)
        call UnitRemoveAbility(u.archer, 'A021')
        call UnitRemoveAbility(u.archer, 'B009')
        call UnitRemoveAbility(u.archer, 'A01X')
        call UnitRemoveAbility(u.archer, 'A01H')
        call UnitRemoveAbility(u.archer, 'A01Z')
        call DisableTrigger( gg_trg_UBW_mana_regen )

        call ReleaseTimer(GetExpiredTimer())
        call u.destroy()
    endfunction

    //===========================================================================

    private function UBW_Phrases takes nothing returns nothing
        local UBW u = GetTimerData(GetExpiredTimer())
        local timer t
        local real tempx1
        local real tempy1
        local real tempx2
        local real tempy2
        local unit tempunit
        local integer ti

        call BJDebugMsg("u.archer is equal to " + GetUnitName(u.archer))
        call BJDebugMsg("u.count is equal to " + (I2S(u.count)))

        if (GetWidgetLife(u.archer) > 0.405) then // Checks if alive
                call CreateTextTagUnitBJ( messages[u.count], u.archer, 0, 10, 100, 100, 100, 0 )
                call SetTextTagPermanent( bj_lastCreatedTextTag, false )
                call SetTextTagLifespan( bj_lastCreatedTextTag, 2.50 )
            if (u.count == 3) then
                set tempx1 = GetUnitX(u.archer)
                set tempy1 = GetUnitY(u.archer)
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", tempx1, tempy1))
                set tempplayer = GetOwningPlayer(u.archer)
                call GroupEnumUnitsInRange(tempgroup, tempx1, tempy1, 600, Condition(function IsEnemyHero))

                    call BJDebugMsg("hi1")

                set tempx1 = GetRectCenterX(gg_rct_Unlimited_Blade_Works)
                set tempy1 = GetRectCenterY(gg_rct_Unlimited_Blade_Works)

                // Prepare to face your enemy
                set u.xarcher = GetUnitX(u.archer)
                set u.yarcher = GetUnitY(u.archer)
                set tempx2 = tempx1 + 250 * Cos(90 * bj_DEGTORAD)
                set tempy2 = tempy1 + 250 * Sin(90 * bj_DEGTORAD)
                call SetUnitPosition(u.archer, tempx2, tempy2)
                call PanCameraToTimedForPlayer( GetOwningPlayer(u.archer), tempx1, tempy1, 0 )
                call UnitAddAbility(u.archer, 'A021')
                call SetUnitAbilityLevel(u.archer, 'A01Y', GetUnitAbilityLevel(u.archer, 'A01W'))
                call SetPlayerAbilityAvailable(GetOwningPlayer(u.archer), 'A021', false)
                call UnitAddAbility(u.archer, 'A01X')
                call SetUnitAbilityLevel(u.archer, 'A01X', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01H')
                call SetUnitAbilityLevel(u.archer, 'A01H', GetUnitAbilityLevel(u.archer, 'A01W'))
                call UnitAddAbility(u.archer, 'A01Z')
                call SetUnitAbilityLevel(u.archer, 'A01Z', GetUnitAbilityLevel(u.archer, 'A01W'))
                call EnableTrigger( gg_trg_UBW_mana_regen )

                call BJDebugMsg("hi2")

                loop // Time to send enemies to the battle
                    set tempunit = FirstOfGroup(tempgroup)
                    exitwhen tempunit == null
                    call GroupRemoveUnit(tempgroup, tempunit)
                    set u.pother[GetPlayerId(GetOwningPlayer(tempunit))] = GetUnitLoc(tempunit)
                    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", u.pother[GetPlayerId(GetOwningPlayer(tempunit))]))
                    set tempx2 = tempx1 + 250 * Cos(270 * bj_DEGTORAD)
                    set tempy2 = tempy1 + 250 * Sin(270 * bj_DEGTORAD)
                    call SetUnitPosition(tempunit, tempx2, tempy2)
                    call PanCameraToTimedForPlayer( GetOwningPlayer(tempunit), tempx1, tempy1, 0 )
                endloop

                    call BJDebugMsg("hi3")
            endif
        endif

        set u.count = (u.count + 1)

        if (u.count == 4) then
            call BJDebugMsg("Its over")
            call ReleaseTimer(GetExpiredTimer())
            set ti = (( 4 + ( 2 * (GetUnitAbilityLevel(u.archer, 'A01W')))))
            set t = NewTimer()
            call SetTimerData(t,u)
            call TimerStart(t, ti, false, function UBW_battle)
        endif

    endfunction

    //===========================================================================

    private function Trig_UBW_start_Actions takes nothing returns boolean
        local item tempitem //why is this here? :o
        local UBW u //dont set these to anything else they will get Set too something everytime someone cast a spell
        local timer t
        local texttag Text
       
        if GetSpellAbilityId() == 'A01W' then
            set Text = CreateTextTag()
            set u = UBW.create()
            set timer t = NewTimer()
            set u.archer = GetTriggerUnit()
            // instead is texttag bj shit do this :>
            set Text = CreateTextTag()
            call SetTextTagPosUnit(Text,u.archer,10.)
            call SetTextTagText(Text, "I am the bone of my sword.|nSteel is my body, and fire is my blood.",10.)
            call SetTextTagColor(Text,100,100,100,0)
            call SetTextTagPermanent(Text, false )
            call SetTextTagLifespan(Text, 2.50 )
            call SetTextTagVisibility(Text,true)
            //===========================
            set u.count = 0
            call SetTimerData(t,u)
            call TimerStart(t, 2.5, true, function UBW_Phrases)
           
            set t = null
            set tempitem = null
            set Text = null
        endif

        return false
    endfunction

    //===========================================================================

    private function Init_UBW takes nothing returns nothing
        local trigger UBW_start = CreateTrigger()

        call TriggerRegisterAnyUnitEventBJ( UBW_start, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( UBW_start, Condition( Trig_UBW_start_Actions ) )

        set tempgroup = CreateGroup()
        set EnumFilter = Filter(function IsEnemyHero)
        set messages[0] = "I have created over a thousand blades.|nUnknown to death. Nor known to life."
        set messages[1] = "Have withstood pain to create many weapons.|nYet, those hands will never hold anything."
        set messages[2] = "So as I pray, Unlimited Blade Works."
        set UBW_start = null
    endfunction

    endscope
     
    Last edited: Jan 16, 2009
  5. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    I didn't understand, why are you using conditions like actions? and what is YBW.create()?
    (The tempitem I have no idea why is there)

    Also, I would like to ask, is that MUI? I'm new to Jass and I don't know how private globals works.

    Thanks for your help.
     
  6. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    Conditions are faster than actions, but do not support waits.


    That( the custom globals and structs and scopes) is vJass, which requires Jass New Gen Pack (or just the Jass Helper).

    It is MUI but requires an struct attachment system (like Timer Utilities or something).
     
  7. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    How can that be MUI? I mean, it uses globals o.o

    (Also, that is my spell, I did that way because they told me so, but I can't understand how globals can be mui)
     
  8. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    The globals are used only in the filter ;)
     
  9. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Uhm, thanks for explanation.