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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top