• 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] Unusual wc3err message

Status
Not open for further replies.
Level 8
Joined
Jul 23, 2005
Messages
329
The error "Uninitialized variable 'Struct method generated initializers/callers: ***************** cape to select." used in IceMoveNow()" appears whenever IceMoveNow() is called. What's strange about the entire thing is that in no case do I ever use a struct, only globals.
JASS:
function IceMoveNow takes nothing returns nothing
    local rect RawrRect
    local group RawrGroup = CreateGroup()
    local unit RawrUnit
    call SetUnitPosition(MovedUnit, GetUnitX(MovedUnit), GetUnitY(MovedUnit) + 50)
    
    
    set RawrRect = Rect(GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 128, GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) + 128)
    call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
    set RawrUnit = FirstOfGroup(RawrGroup)
    
    //First: The hit unit
    if RawrUnit != null then
        call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
        call UnitAddAbility(RawrUnit, 'A208')
        
        //Second: The unit behind
        if GetUnitAbilityLevel(udg_P1Unit, 'A118') >= 2 then
            set RawrRect = Rect(GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 256, GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) + 512)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
        endif
        
        //Third: The unit to the sides
        if GetUnitAbilityLevel(udg_P1Unit, 'A118') == 3 then
            //Unit to the left
            set RawrRect = Rect(GetUnitX(MovedUnit) - 384, GetUnitY(MovedUnit) - 128, GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 128)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
            
            //Unit to the right
            set RawrRect = Rect(GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) - 128, GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 384)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
        endif
        call KillUnit(MovedUnit)
        call DestroyTimer(GetExpiredTimer())
    endif
    
    //Detect if the bullet's gone out of range.
    if GetUnitY(MovedUnit) >= GetRectMinY(gg_rct_TopBoundry) then
        call KillUnit(MovedUnit)
        call DestroyTimer(GetExpiredTimer())
    endif
    
    set RawrRect = null
    set RawrGroup = null
    set RawrUnit = null
endfunction

That's the code... Can someone explain to me what wc3err is trying to say?
 
Level 8
Joined
Jul 23, 2005
Messages
329
Fixed it... MovedUnit IS a global, but in the version of this code I was running, I accidently also declared a local with the same name in this function. Oddly enough, the compiler didn't crash, but gave me that strange error message.

I'll rep you both...
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Fixed it... MovedUnit IS a global, but in the version of this code I was running, I accidently also declared a local with the same name in this function. Oddly enough, the compiler didn't crash, but gave me that strange error message.
Globals and locals having the same name is a well-known bug, and is actually the source of "locals" in GUI, in a sense - if you make a global with the same name as a local, whenever the global is attempted to be used inside that function, it will reference the local instead. From what I know, this also works with locals vs arguments, and only works for one variable per function.
 
Status
Not open for further replies.
Top