- Joined
- Mar 23, 2008
- Messages
- 942
That is what happen: (See attachs)
That is the code:
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!
That is the code:
JASS:
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!