• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Loop Problem

Status
Not open for further replies.
JASS:
function Trig_Press_Esc_Actions takes nothing returns nothing
local location Tmp_Loc
local location Tmp_Loc2
local unit Tmp_Unit
local unit Tmp_Unit2
local unit Tmp_Unit3
local effect Tmp_Effect
local effect array Tmp_Effect_Array
local integer Tmp_Integer
local integer LoopStart1
local integer LoopEnd1
local integer LoopStart2
local integer LoopEnd2
local real Tmp_Real
local real Tmp_Real2
set Tmp_Unit = GetTriggerUnit()
set Tmp_Loc = GetUnitLoc(Tmp_Unit)
set Tmp_Unit2 = CreateUnitAtLoc(GetOwningPlayer(Tmp_Unit),'bomb', Tmp_Loc, 0.00 )
set Tmp_Unit3 = Tmp_Unit2
call RemoveLocation(Tmp_Loc)
call TriggerSleepAction(3.00)
set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
set Tmp_Effect = AddSpecialEffectLoc("Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl",Tmp_Loc)
call RemoveLocation(Tmp_Loc)
call DestroyEffect(Tmp_Effect)
set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
set Tmp_Effect = AddSpecialEffectLoc("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",Tmp_Loc)
call RemoveLocation(Tmp_Loc)
set LoopStart2 = 0
set LoopEnd2 = 1
set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
loop
exitwhen(LoopStart2>LoopEnd2)
set LoopStart1 = 0
set LoopEnd1 = 3
set Tmp_Real2 = LoopStart2 * 128.00
loop
exitwhen(LoopStart1>LoopEnd1)
set Tmp_Integer = Tmp_Integer + 1
set Tmp_Real = LoopStart1 * 90.00
set Tmp_Loc2 = PolarProjectionBJ(Tmp_Loc,Tmp_Real2,Tmp_Real)
set Tmp_Effect_Array[Tmp_Integer] = AddSpecialEffectLoc("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl",Tmp_Loc2)
call RemoveLocation(Tmp_Loc2)
//call DestroyEffect(Tmp_Effect_Array[Tmp_Integer])
set LoopStart1 = LoopStart1 + 1
endloop
set LoopStart2 = LoopStart2 + 1
endloop
call RemoveLocation(Tmp_Loc)
call RemoveUnit(Tmp_Unit3)
call TriggerSleepAction(3.00)
call DestroyEffect(Tmp_Effect)
set Tmp_Unit3 = null
set Tmp_Unit2 = null
set Tmp_Unit = null
endfunction

//===========================================================================
function InitTrig_Press_Esc takes nothing returns nothing
    set gg_trg_Press_Esc = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Press_Esc, function Trig_Press_Esc_Actions )
endfunction
Hint: The event is added due another function with the action:
Add to gg_trg_Press_Esc the Event: A unit starts using an ability
This does work, but the loop will never take place and the unit will not be removed.
 
Level 5
Joined
Oct 27, 2007
Messages
158
JASS:
function Trig_Press_Esc_Actions takes nothing returns nothing
    local location Tmp_Loc = GetUnitLoc(Tmp_Unit)
    local location Tmp_Loc2
    local unit Tmp_Unit = GetTriggerUnit()
    local unit Tmp_Unit2 = CreateUnitAtLoc(GetOwningPlayer(Tmp_Unit),'bomb', Tmp_Loc, 0.00 )
    local unit Tmp_Unit3 = Tmp_Unit2
    local effect Tmp_Effect
    local effect array Tmp_Effect_Array
    local integer Tmp_Integer
    local integer LoopStart1
    local integer LoopEnd1
    local integer LoopStart2
    local integer LoopEnd2
    local real Tmp_Real
    local real Tmp_Real2

    call RemoveLocation(Tmp_Loc)
    call TriggerSleepAction(3.00)
    set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
    set Tmp_Effect = AddSpecialEffectLoc("Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl",Tmp_Loc)
    call RemoveLocation(Tmp_Loc)
    call DestroyEffect(Tmp_Effect)
    set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
    set Tmp_Effect = AddSpecialEffectLoc("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",Tmp_Loc)
    call RemoveLocation(Tmp_Loc)
    set LoopStart2 = 0
    set LoopEnd2 = 1
    set Tmp_Loc = GetUnitLoc(Tmp_Unit3)
    loop
        exitwhen(LoopStart2>LoopEnd2)
        set LoopStart1 = 0
        set LoopEnd1 = 3
        set Tmp_Real2 = LoopStart2 * 128.00
        loop
            exitwhen(LoopStart1>LoopEnd1)
            set Tmp_Integer = Tmp_Integer + 1
            set Tmp_Real = LoopStart1 * 90.00
            set Tmp_Loc2 = PolarProjectionBJ(Tmp_Loc,Tmp_Real2,Tmp_Real)
            set Tmp_Effect_Array[Tmp_Integer] = AddSpecialEffectLoc("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl",Tmp_Loc2)
            call RemoveLocation(Tmp_Loc2)
            //call DestroyEffect(Tmp_Effect_Array[Tmp_Integer])
            set LoopStart1 = LoopStart1 + 1
        endloop
        set LoopStart2 = LoopStart2 + 1
    endloop
    call RemoveLocation(Tmp_Loc)
    call RemoveUnit(Tmp_Unit3)
    call TriggerSleepAction(3.00)
    call DestroyEffect(Tmp_Effect)
    set Tmp_Unit3 = null
    set Tmp_Unit2 = null
    set Tmp_Unit = null
endfunction

//===========================================================================
function InitTrig_Press_Esc takes nothing returns nothing
    set gg_trg_Press_Esc = CreateTrigger()
    call TriggerAddAction(gg_trg_Press_Esc, function Trig_Press_Esc_Actions)
endfunction

Please use indentation next time. This will make it easier to track down potential problems and make your code more readable.

You say that you are sure the action is executed.
Do you see some special effects?
What exactly is happening?
How exactly did you setup the event in another trigger?

The only evaluations I see are the ones made in the loop and they don't cause the loop not to be executed. The loop has to be executed if the action triggers, so I doubt that you have it setup correctly.
 
Level 13
Joined
Mar 16, 2008
Messages
941
You set the loc to tmpunit, but tempunit isn't set?!?
JASS:
local location Tmp_Loc = GetUnitLoc(Tmp_Unit) //Tempunit == null
    local location Tmp_Loc2
    local unit Tmp_Unit = GetTriggerUnit() //!
    local unit Tmp_Unit2 = CreateUnitAtLoc(GetOwningPlayer(Tmp_Unit),'bomb', Tmp_Loc, 0.00 )
    local unit Tmp_Unit3 = Tmp_Unit2
    local effect Tmp_Effect
    local effect array Tmp_Effect_Array
    local integer Tmp_Integer
    local integer LoopStart1
    local integer LoopEnd1
    local integer LoopStart2
    local integer LoopEnd2
    local real Tmp_Real
    local real Tmp_Real2

Change the order :)
 
Status
Not open for further replies.
Top