- Joined
- Aug 18, 2013
- Messages
- 71
Anyone know why this trigger loops forever?
I'm looking at it but I'm starting to think i'm crazy.
Not sure why.
the ability 'A05U' is based after channel
its instant so this trigger shouldn't be looping indefinitley.
It also does not move the caster back, but it does create a new werewolf ever 45 seconds at the same position removing the previous one.
I'm looking at it but I'm starting to think i'm crazy.
JASS:
///* Werewolf Transformation
// a unit casts 'A05U'
// moves caster to remote location and disables them
// werewolf unit is created in place with respective life and mana percentages, xp, and ability levels
// 45,60,or 75 seconds pass; caster returns to spot with werewolfs respective ^
// werewolf removed
//*/
function Trig_WereWolfTransform_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A05U' )
endfunction
function Trig_WereWolfTransform_Actions takes nothing returns nothing
//'H00W' = Werewolf Normal Form
//'H00X' = Werewolf Alternate Form
local integer w1 = 'H00W' // normal
local integer w2 = 'H00X' // werwolf
local unit u1 = GetSpellAbilityUnit()// caster
local unit u2
local integer l = GetUnitAbilityLevel(u1,'A05U')
local item array items //array of caster items, so can be added to new alternate
local integer i = 0 //generic iterator
local real x = GetUnitX(u1) //x coord of u
local real y = GetUnitY(u1) //y coord of u
local real f = GetUnitFacing(u1) //facing angle of u
local player p = GetOwningPlayer(u1) //owner of u
local real life = GetUnitStatePercent(u1, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)
local real m = GetUnitStatePercent(u1, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)
local integer xp = GetHeroXP(u1)
local integer lev = GetHeroLevel(u1)
local integer l1 = GetUnitAbilityLevel(u1,0)//q abil
local integer l2 = GetUnitAbilityLevel(u1,0)//w abil
local integer l3 = GetUnitAbilityLevel(u1,0)//e abil
local integer l4 = GetUnitAbilityLevel(u1,'A05T')//r abil
local integer l5 = GetUnitAbilityLevel(u1,'A005')//stat abil
local integer sp = GetHeroSkillPoints(u1)//stat points remaining
//vars setup
set items[1] = UnitItemInSlot(u1,0) //item in slot 1
set items[2] = UnitItemInSlot(u1,1) //item in slot 2
set items[3] = UnitItemInSlot(u1,2) //item in slot 3
set items[4] = UnitItemInSlot(u1,3) //item in slot 4
set items[5] = UnitItemInSlot(u1,4) //item in slot 5
set items[6] = UnitItemInSlot(u1,5) //item in slot 6
//Cast Start
call SetUnitX(u1, 5910)
call SetUnitY(u1, -5500)
call ShowUnit(u1,false)//hide caster
call PauseUnit(u1,true)//pause unit
set u2 = CreateUnit(p,w2,x,y,f)//create werewolf
call SetHeroXP(u2,xp,false)
call SetUnitAbilityLevel(u2,0,l1)//set q abil level
call SetUnitAbilityLevel(u2,0,l2)//set w abil level
call SetUnitAbilityLevel(u2,0,l3)//set e abil level
call SetUnitAbilityLevel(u2,'A05T',l4)//set r abil level
call SetUnitAbilityLevel(u2,'A005',l4)//set stat abil level
call SetUnitLifePercentBJ(u2,life)
call SetUnitManaPercentBJ(u2,m)
//inventory: this block adds all the items from caster to werewolf
set i = 0 //saftey set
loop
exitwhen i == 6 //all inventory
//---
call UnitAddItem(u2,items[i])
//---
set i = i+1 //iterator
endloop
//this block selects the newly created werewolf
if (GetLocalPlayer() == GetOwningPlayer(u2)) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit(u2, true)
endif //selects the new unit for the owner of caster
//Caster should be gone safe and sound, werewolf unit in its place.
call PolledWait(30 + l4*15)//wait = 45,60,75 based on level 1,2,3
//get hero level info
set xp = GetHeroXP(u2)
set l1 = GetUnitAbilityLevel(u2,0)//q abil
set l2 = GetUnitAbilityLevel(u2,0)//w abil
set l3 = GetUnitAbilityLevel(u2,0)//e abil
set l4 = GetUnitAbilityLevel(u2,0)//r abil
set l5 = GetUnitAbilityLevel(u2,'A005')//stat abil
//set hero levels
call SetHeroXP(u1,xp,false)//set original hero xp to werewolf
call SetUnitAbilityLevel(u1,0,l1)//set q abil level
call SetUnitAbilityLevel(u1,0,l2)//set w abil level
call SetUnitAbilityLevel(u1,0,l3)//set e abil level
call SetUnitAbilityLevel(u1,0,l4)//set r abil level
call SetUnitAbilityLevel(u1,'A005',l5)//set stat abil level
//set location
set x = GetUnitX(u2)
set y = GetUnitY(u2)
call SetUnitX(u1, x)//set original x to werewolf x
call SetUnitY(u1, y)//set original y to werewolf y
//enable unit
call ShowUnit(u1,true)//show caster
call PauseUnit(u1,false)//unpause unit
//set unit life and mana
set life = GetUnitStatePercent(u2, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)//get werewolf life percentage
set m = GetUnitStatePercent(u2, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)//get werewolf mana percentage
call SetUnitLifePercentBJ(u1,life)//set orig life
call SetUnitManaPercentBJ(u1,m)//set orig mana
//inventory revert
set i = 0 //saftey set
loop
exitwhen i == 6 //all inventory
//---
call UnitAddItem(u1,items[i])
//---
set i = i+1 //iterator
endloop
if (GetLocalPlayer() == GetOwningPlayer(u1)) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit(u1, true)
endif //selects the caster
//cleanup
call RemoveUnit(u2)
set u1 = null
set u2 = null
set l = 0
set i = 0 //generic iterator
set x = 0
set y = 0
set f = 0
call DisplayTimedTextToPlayer(p,0,0,5,"Werewolf Transformation Complete")//debug message
set p = null
set l = 0
set m = 0
set xp = 0
set lev = 0
set l1 = 0//q abil
set l2 = 0//w abil
set l3 = 0//e abil
set l4 = 0//r abil
set l5 = 0//stat abil
set sp = 0//stat points remaining
//vars setup
set items[1] = null //item in slot 1
set items[2] = null //item in slot 2
set items[3] = null //item in slot 3
set items[4] = null //item in slot 4
set items[5] = null //item in slot 5
set items[6] = null //item in slot 6
endfunction
//===========================================================================
function InitTrig_WereWolfTransform takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Trig_WereWolfTransform_Conditions ) )
call TriggerAddAction( t, function Trig_WereWolfTransform_Actions )
set t = null
endfunction
JASS:
///* Werewolf Transformation
// a unit casts 'A05U'
// moves caster to remote location and disables them
// werewolf unit is created in place with respective life and mana percentages, xp, and ability levels
// 45,60,or 75 seconds pass; caster returns to spot with werewolfs respective ^
// werewolf removed
//*/
function Trig_WereWolfTransform_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A05U' )
endfunction
function Trig_WereWolfTransform_Actions takes nothing returns nothing
//'H00W' = Werewolf Normal Form
//'H00X' = Werewolf Alternate Form
//Spells Vars
local integer Q = 0
local integer W = 'A05V'
local integer E = 'A05S'
local integer R1 = 'A05T'
local integer R2 = 'A05U'
local integer T = 'A005'
//Unit Numbers
local integer w1 = 'H00W' // normal
local integer w2 = 'H00X' // werwolf
//Local Vars
local unit u1 = GetSpellAbilityUnit()// caster
local unit u2
local integer l = GetUnitAbilityLevel(u1,'A05U')
local item array items //array of caster items, so can be added to new alternate
local integer i = 0 //generic iterator
local real x = GetUnitX(u1) //x coord of u
local real y = GetUnitY(u1) //y coord of u
local real f = GetUnitFacing(u1) //facing angle of u
local player p = GetOwningPlayer(u1) //owner of u
local real life = GetUnitStatePercent(u1, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)
local real m = GetUnitStatePercent(u1, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)
local integer xp = GetHeroXP(u1)
local integer lev = GetHeroLevel(u1)
local integer l1 = GetUnitAbilityLevel(u1,Q)//q abil
local integer l2 = GetUnitAbilityLevel(u1,W)//w abil
local integer l3 = GetUnitAbilityLevel(u1,E)//e abil
local integer l4 = GetUnitAbilityLevel(u1,R1)//r abil
local integer l5 = GetUnitAbilityLevel(u1,T)//stat abil
local integer sp = GetHeroSkillPoints(u1)//stat points remaining
//debug level display
call DisplayTextToPlayer(p,0,0,"Q : "+I2S(l1))
call DisplayTextToPlayer(p,0,0,"W : "+I2S(l2))
call DisplayTextToPlayer(p,0,0,"E : "+I2S(l3))
call DisplayTextToPlayer(p,0,0,"R : "+I2S(l4))
call DisplayTextToPlayer(p,0,0,"T : "+I2S(l5))
//----------
//vars setup
set items[1] = UnitItemInSlot(u1,0) //item in slot 1
set items[2] = UnitItemInSlot(u1,1) //item in slot 2
set items[3] = UnitItemInSlot(u1,2) //item in slot 3
set items[4] = UnitItemInSlot(u1,3) //item in slot 4
set items[5] = UnitItemInSlot(u1,4) //item in slot 5
set items[6] = UnitItemInSlot(u1,5) //item in slot 6
//Cast Start
call SetUnitX(u1, 5910)
call SetUnitY(u1, -5500)
set u2 = CreateUnit(p,w2,x,y,f)//create werewolf
call SetUnitLifePercentBJ(u2,life)
call SetUnitManaPercentBJ(u2,m)
//Set Werewolf Levels etc
call SetHeroXP(u2,xp,false)
call ModifyHeroSkillPoints(u2,bj_MODIFYMETHOD_ADD,sp)
call SetUnitAbilityLevel(u2,Q,l1)//set q abil level
call SetUnitAbilityLevel(u2,W,l2)//set w abil level
call SetUnitAbilityLevel(u2,E,l3)//set e abil level
call SetUnitAbilityLevel(u2,R1,l4)//set r abil level
call SetUnitAbilityLevel(u2,T,l5)//set stat abil level
//global set for etc. if werewolf dies saves him etc. idk
set udg_WerewolfUnit[GetConvertedPlayerId(GetOwningPlayer(u1))] = u2
//inventory: this block adds all the items from caster to werewolf
set i = 0 //saftey set
loop
exitwhen i == 7 //all inventory
//---
call UnitAddItem(u2,items[i])
//---
set i = i+1 //iterator
endloop
//this block selects the newly created werewolf
if (GetLocalPlayer() == GetOwningPlayer(u2)) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit(u2, true)
endif //selects the new unit for the owner of caster
// set ability levels try2
call SetUnitAbilityLevel(u2,Q,l1)//set q abil level
call SetUnitAbilityLevel(u2,W,l2)//set w abil level
call SetUnitAbilityLevel(u2,E,l3)//set e abil level
call SetUnitAbilityLevel(u2,R1,l4)//set r abil level
call SetUnitAbilityLevel(u2,T,l5)//set stat abil level
//hide Hero
call ShowUnit(u1,false)//hide caster
//Caster should be gone safe and sound, werewolf unit in its place.
call PolledWait(31 + l4*15)//wait = 45,60,75 based on level 1,2,3; Actual Values: 46,61,76
//enable unit
call ShowUnit(u1,true)//show caster
//remove TransformAbility
call UnitRemoveAbility( u1,'A05U' )
//get werewolf level info
set xp = GetHeroXP(u2)
set l1 = GetUnitAbilityLevel(u2,Q)//q abil
set l2 = GetUnitAbilityLevel(u2,W)//w abil
set l3 = GetUnitAbilityLevel(u2,E)//e abil
set l4 = GetUnitAbilityLevel(u2,R1)//r abil
set l5 = GetUnitAbilityLevel(u2,T)//stat abil
//debug level display
call DisplayTextToPlayer(p,0,0,"Q : "+I2S(l1))
call DisplayTextToPlayer(p,0,0,"W : "+I2S(l2))
call DisplayTextToPlayer(p,0,0,"E : "+I2S(l3))
call DisplayTextToPlayer(p,0,0,"R : "+I2S(l4))
call DisplayTextToPlayer(p,0,0,"T : "+I2S(l5))
//----------
//set hero levels
call SetHeroXP(u1,xp,false)//set original hero xp to werewolf
call SetUnitAbilityLevel(u1,Q,l1)//set q abil level
call SetUnitAbilityLevel(u1,W,l2)//set w abil level
call SetUnitAbilityLevel(u1,E,l3)//set e abil level
call SetUnitAbilityLevel(u1,R1,l4)//set r abil level
call SetUnitAbilityLevel(u1,T,l5)//set stat abil level
//set location
set x = GetUnitX(u2)
set y = GetUnitY(u2)
call SetUnitX(u1, x)//set original x to werewolf x
call SetUnitY(u1, y)//set original y to werewolf y
//set unit life and mana
set life = GetUnitStatePercent(u2, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)//get werewolf life percentage
set m = GetUnitStatePercent(u2, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)//get werewolf mana percentage
call SetUnitLifePercentBJ(u1,life)//set orig life
call SetUnitManaPercentBJ(u1,m)//set orig mana
//inventory revert
set i = 0 //saftey set
loop
exitwhen i == 7 //all inventory
//---
set items[i+1] = UnitItemInSlot(u2,i) //item in slot i
call UnitAddItem(u1,items[i])
//---
set i = i+1 //iterator
endloop
//this block selects the hero
if (GetLocalPlayer() == GetOwningPlayer(u1)) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit(u1, true)
endif //selects the caster
//cleanup
call RemoveUnit(u2)
set u1 = null
set u2 = null
set l = 0
set i = 0 //generic iterator
set x = 0
set y = 0
set f = 0
call DisplayTimedTextToPlayer(p,0,0,5,"Werewolf Transformation Complete")//debug message
set p = null
set l = 0
set m = 0
set xp = 0
set lev = 0
set l1 = 0//q abil
set l2 = 0//w abil
set l3 = 0//e abil
set l4 = 0//r abil
set l5 = 0//stat abil
set sp = 0//stat points remaining
//vars setup
set items[1] = null //item in slot 1
set items[2] = null //item in slot 2
set items[3] = null //item in slot 3
set items[4] = null //item in slot 4
set items[5] = null //item in slot 5
set items[6] = null //item in slot 6
endfunction
//===========================================================================
function InitTrig_WereWolfTransform takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Trig_WereWolfTransform_Conditions ) )
call TriggerAddAction( t, function Trig_WereWolfTransform_Actions )
set t = null
endfunction
Not sure why.
the ability 'A05U' is based after channel
its instant so this trigger shouldn't be looping indefinitley.
It also does not move the caster back, but it does create a new werewolf ever 45 seconds at the same position removing the previous one.
Last edited: