Undeclared variable problem

killingdyl

Active Member
Reaction score
6
Bare with me, i am very new to jass. I am making this trigger but i keep getting this error with an undeclared variable and i know i declared it.
Heres the code
JASS:
function Trig_Elemental_Vortex_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean
    if ( not ( GetUnitTypeId(Dummy[(bj_forLoopAIndex)]) == 'h002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false ) ) then
        return false
    endif
    if ( not ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if ( Trig_Elemental_Vortex_Func011Func001Func001C() ) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl" )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
        endif
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Elemental_Vortex_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location casterLoc = GetUnitLoc(GetTriggerUnit())
    local real Real = 0
    local location array LocOffset
    local unit array Dummy
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 8
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 700.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, 'BTLF', GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set Real = (360/16)
    set bj_forLoopAIndex = 9
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'h002', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 500.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, 'BTLF', GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 3.45 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsInRangeOfLocAll(50.00, GetUnitLoc(Dummy[(bj_forLoopAIndex)])), function Trig_Elemental_Vortex_Func011Func001A )
        set Dummy[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set casterLoc = null
endfunction

//===========================================================================
function InitTrig_Elemental_Vortex takes nothing returns nothing
    set gg_trg_Elemental_Vortex = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Elemental_Vortex, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Elemental_Vortex, Condition( function Trig_Elemental_Vortex_Conditions ) )
    call TriggerAddAction( gg_trg_Elemental_Vortex, function Trig_Elemental_Vortex_Actions )
endfunction

Also if u find any leaks tell me please. Thanks
 

Lehona

New Member
Reaction score
12
Seems like converted GUI :(

And tell us what variables seems not to be declared.
 

Exide

I am amazingly focused right now!
Reaction score
448
You are using a local variable in another function:

First you declare the variable in this function:
function Trig_Elemental_Vortex_Actions takes nothing returns nothing

Then you are using it in a condition:
function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean

local variables doesn't transfer between functions.

(It's the 'Dummy' variable, btw.)

You should loop through it in the same function as you declared it in, and remove that condition completely.

Converted GUI is horrible, btw. :p
 

killingdyl

Active Member
Reaction score
6
ok can u walk me through it or something, and im using locals cuz im making them mui. As i said very very new to this. (and i know converted gui is horrible, but gotta start somewhere right?)
 

shiFt

Member
Reaction score
8
Declare all the variables that you would need in more than one function at the top of the trigger in a globals block.
JASS:
globals // this is the block
       unit Dummy 
endglobals


Then when you use the variable set a value to it in the function you want to use , random example making a dummy unit at a units location:
JASS:
set Dummy= CreateUnit(Player, DummyUnit, GetWidgetX(U), GetWidgetY(U) ,0.00)
 

Lehona

New Member
Reaction score
12
You need vJass/NewGen for that - if you don't want to use it (I recommend you to, but maybe you have a Mac or sth.) just declare it as a GUI-Variable and use udg_<name>.
 

shiFt

Member
Reaction score
8
..or you can just get NewGen :), its alot better/easier to learn that way, iv found
 

Exide

I am amazingly focused right now!
Reaction score
448
I haven't used World Editor in a long time, and my skills are very rusty.
I will help you with a few hints first:

When using a loop in GUI, WE (by default) uses the variables:
bj_forLoopAIndex and bj_forLoopAIndexEnd
_Index is the number that changes for each loop, and _End is for the game to know when to stop looping. -Logic.

We can replace these with a local integer variable:
JASS:

function blabla takes nothing returns nothing
local integer i = 0
loop
exitwhen i &gt; 10    //This loop goes from 0 to 10 = eleven times
//Do actions..
set i = i + 1
endloop
endfunction


This loop is now perfectly local.

Now you can add a condition, by adding 'If/Then':

JASS:

if (GetUnitTypeId(Dummy[*Local_Integer_Variable_Here*]) == &#039;h002&#039;) then
//Put actions here..
endif


If you put this condition within the loop, it should check every unit's Id in the Dummy Variable.


If we put it all together it should look something like this:

JASS:

function myloop takes nothing returns nothing
local integer i = 0
//Don&#039;t forget to declare the local Dummy -variable!

loop
exitwhen i &gt; 10

if (GetUnitTypeId(Dummy<i>) == &#039;h002&#039;) then
//Put actions here..
endif

set i = i + 1
endloop

endfunction
</i>
 

Exide

I am amazingly focused right now!
Reaction score
448

cleeezzz

The Undead Ranger.
Reaction score
268
>How would i combine it into 1(one) function?

you cant, you need at least two (for what you're trying to do)

you need to 1. define the trigger, add event/action. and then 2. the action itself

i suggest you make a working GUI trigger, convert it to JASS, look up a tutorial (theres a bunch that help you move from GUI to JASS), and learn how to change converted GUI into good JASS. thats probably the best way to learn

btw, hi exide
 

killingdyl

Active Member
Reaction score
6
How would i combine these functions? I have taken it apart and figured out what each part does, every time theres an if/then/else in gui, it makes it into a seperate function. How do i fix that?

Here are the action codes:
JASS:
function Trig_Elemental_Vortex_Func011Func001Func001Func002C takes nothing returns boolean
    if ( not ( GetUnitTypeId(Dummy[(bj_forLoopAIndex)]) == &#039;h002&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false ) ) then
        return false
    endif
    if ( not ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if ( Trig_Elemental_Vortex_Func011Func001Func001C() ) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl&quot; )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl&quot; )
        endif
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Elemental_Vortex_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location casterLoc = GetUnitLoc(GetTriggerUnit())
    local real Real = 0
    local location array LocOffset
    local unit array Dummy
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 8
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, &#039;h003&#039;, GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 700.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), &quot;move&quot;, LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, &#039;BTLF&#039;, GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set Real = (360/16)
    set bj_forLoopAIndex = 9
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, &#039;h002&#039;, GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        set LocOffset[(bj_forLoopAIndex)] = PolarProjectionBJ(casterLoc, 500.00, Real)
        call IssuePointOrderLocBJ( GetLastCreatedUnit(), &quot;move&quot;, LocOffset[bj_forLoopAIndex] )
        call UnitApplyTimedLifeBJ( 3.50, &#039;BTLF&#039;, GetLastCreatedUnit() )
        set Dummy[(bj_forLoopAIndex)] = GetLastCreatedUnit()
        set Real = (Real + (360/8))
        set LocOffset[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call TriggerSleepAction( 3.45 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 16
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsInRangeOfLocAll(50.00, GetUnitLoc(Dummy[(bj_forLoopAIndex)])), function Trig_Elemental_Vortex_Func011Func001A )
        set Dummy[(bj_forLoopAIndex)] = null
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    set casterLoc = null
endfunction
 

Lehona

New Member
Reaction score
12
Instead of
JASS:
 If (MyFunc()) then

write

JASS:
 If (WhatShouldBeTrue == true) then


So in your example:
JASS:
function Trig_Elemental_Vortex_Func011Func001A takes nothing returns nothing
    if (( IsUnitType(GetEnumUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == false) then
        if ( Trig_Elemental_Vortex_Func011Func001Func001Func002C() ) then
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl&quot; )
        else
            call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetEnumUnit()), &quot;Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl&quot; )
        endif
    else
        call DoNothing(  )
    endif
endfunction


And so on.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top