• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Undeclared Function

Status
Not open for further replies.
Level 4
Joined
Aug 1, 2007
Messages
66
I'm trying to figure out what the undeclared function is here. It's in the if (UNIT_STATE_LIFE(target)>damage[level]) then line at the begining of the loop. Also, some explanation of what undelcared function is would be nice.

JASS:
function Trig_Quick_Blades_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit target = GetSpellTargetUnit()
    local integer level = GetUnitAbilityLevel(caster,'A0AY')    
    local real array damage
    local effect effect1
    local effect effect2
    local location loc1
    local location loc2
    local integer hits = 4
    set damage[1] = 20
    set damage[2] = 25
    set damage[3] = 31.25
    set damage[4] = 39.06
    set damage[5] = 48.83
    set damage[6] = 61.04
    set damage[7] = 76.29
    set damage[8] = 95.37
    set damage[9] = 119.21
    set damage[10] = 149.01
    call PolledWait( 0.01 )
    call SetUnitTimeScalePercent( caster, 200.00 )
    call AddSpecialEffectTargetUnitBJ( "hand, right", caster, "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl" )
    set effect1 = GetLastCreatedEffectBJ()
    call AddSpecialEffectTargetUnitBJ( "hand, left", caster, "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl" )
    set effect2 = GetLastCreatedEffectBJ()
    loop
        exitwhen hits == 0
        if  (UNIT_STATE_LIFE(target)>damage[level]) then
            set hits = (hits-1)
            call SetUnitAnimation( caster, "attack" )
            set loc1 = GetUnitLoc(target)
            set loc2 = GetRandomLocInRect(RectFromCenterSizeBJ(loc1, 80.00, 80.00))
            call SetUnitFacingToFaceUnitTimed( caster, target, 0 )
            call SetUnitPositionLocFacingLocBJ( caster, loc2, loc1 )
            call UnitDamageTargetBJ( caster, target, damage[level], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
            call AddSpecialEffectTargetUnitBJ( "chest", caster, "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            call AddSpecialEffectTargetUnitBJ( "chest", target, "Abilities\\Weapons\\ZigguratMissile\\ZigguratMissile.mdl" )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            call TriggerSleepAction( 0.15 )
        else
            call SetUnitAnimation( caster, "attack" )
            call SetUnitTimeScalePercent( caster, 25.00 )
            call SetUnitTimeScalePercent( target, 25.00 )
            call PolledWait( 1.85 )
            call AddSpecialEffectTargetUnitBJ( "head", target, "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
            call UnitDamageTargetBJ( caster, target, damage[level], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            set hits = 0
        endif
    endloop
    call SetUnitTimeScalePercent( caster, 100.00 )
    call SetUnitVertexColorBJ( caster, 100.00, 100.00, 100.00, 0.00 )
    call DestroyEffectBJ( effect1 )
    call DestroyEffectBJ( effect2 )
    call RemoveLocation (loc1)
    call RemoveLocation (loc2)
    set caster = null
    set target = null
    set effect1 = null
    set effect2 = null
    set loc1 = null
    set loc2 = null
endfunction
 
Level 16
Joined
Feb 22, 2006
Messages
960
simple: u can't use only UNIT_STATE_LIFE u have to use GetUnitState(target,UNIT_STATE_LIFE)
JASS:
function Trig_Quick_Blades_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit target = GetSpellTargetUnit()
    local integer level = GetUnitAbilityLevel(caster,'A0AY')
    local real array damage
    local effect effect1
    local effect effect2
    local location loc1
    local location loc2
    local integer hits = 4
    set damage[1] = 20
    set damage[2] = 25
    set damage[3] = 31.25
    set damage[4] = 39.06
    set damage[5] = 48.83
    set damage[6] = 61.04
    set damage[7] = 76.29
    set damage[8] = 95.37
    set damage[9] = 119.21
    set damage[10] = 149.01
    call PolledWait( 0.01 )
    call SetUnitTimeScalePercent( caster, 200.00 )
    call AddSpecialEffectTargetUnitBJ( "hand, right", caster, "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl" )
    set effect1 = GetLastCreatedEffectBJ()
    call AddSpecialEffectTargetUnitBJ( "hand, left", caster, "Abilities\\Spells\\NightElf\\SpiritOfVengeance\\SpiritOfVengeanceBirthMissile.mdl" )
    set effect2 = GetLastCreatedEffectBJ()
    loop
        exitwhen hits == 0
        if GetUnitState(target,UNIT_STATE_LIFE) > damage[level]) then
            set hits = (hits-1)
            call SetUnitAnimation( caster, "attack" )
            set loc1 = GetUnitLoc(target)
            set loc2 = GetRandomLocInRect(RectFromCenterSizeBJ(loc1, 80.00, 80.00))
            call SetUnitFacingToFaceUnitTimed( caster, target, 0 )
            call SetUnitPositionLocFacingLocBJ( caster, loc2, loc1 )
            call UnitDamageTargetBJ( caster, target, damage[level], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
            call AddSpecialEffectTargetUnitBJ( "chest", caster, "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl" )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            call AddSpecialEffectTargetUnitBJ( "chest", target, "Abilities\\Weapons\\ZigguratMissile\\ZigguratMissile.mdl" )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            call TriggerSleepAction( 0.15 )
        else
            call SetUnitAnimation( caster, "attack" )
            call SetUnitTimeScalePercent( caster, 25.00 )
            call SetUnitTimeScalePercent( target, 25.00 )
            call PolledWait( 1.85 )
            call AddSpecialEffectTargetUnitBJ( "head", target, "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
            call UnitDamageTargetBJ( caster, target, damage[level], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
            call DestroyEffectBJ( GetLastCreatedEffectBJ() )
            set hits = 0
        endif
    endloop
    call SetUnitTimeScalePercent( caster, 100.00 )
    call SetUnitVertexColorBJ( caster, 100.00, 100.00, 100.00, 0.00 )
    call DestroyEffectBJ( effect1 )
    call DestroyEffectBJ( effect2 )
    call RemoveLocation (loc1)
    call RemoveLocation (loc2)
    set caster = null
    set target = null
    set effect1 = null
    set effect2 = null
    set loc1 = null
    set loc2 = null
endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
An undeclared function is obviously a function that isn't declared.

In Jass you declared functions by "function NAME takes PARAMETERS returns RETURN VALUE".

You can't just call any function name you want.

JASS:
function bla takes nothing returns nothing
    // do something
endfunction

function blo takes nothing returns nothing
    // do something
endfunction

function bli takes nothing returns nothing
    call bla() // ok, we declared bla
    call blo() // ok, we delcared blo too
    call blablo() // huh? were exactly did we say (declare) this function exists?
endfunction

Now specifically to your question, UNIT_STATE_LIFE can't take the parameter target because UNIT_STATE_LIFE is a constant integer which simply tells the game what state to return when you give functions that return states that integer.

And, as zandose said, use the GetWidgetLife native.
 
Status
Not open for further replies.
Top