• 🏆 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!

[vJASS] Supposed to add a spell after leveling.

Status
Not open for further replies.
Level 4
Joined
Apr 7, 2012
Messages
63
JASS:
scope AddChop initializer Init

globals
    private constant unit squire = GetLevelingUnit()
endglobals  

private function Conditions  takes nothing returns boolean
    return GetUnitTypeId(squire) == 'H006'  and  GetUnitLevel(squire) > 1 
endfunction

private function Actions takes nothing returns nothing
    call UnitAddAbility( squire, 'A000' )
    call DisplayTimedTextToForce( GetForceOfPlayer(GetOwningPlayer(squire)), 30, "New Ability learned! |cffff8040Chop|r" ) 
endfunction    
//===========================================================================
private function Init takes nothing returns nothing
    local trigger AddChopTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( AddChopTrg, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddCondition( AddChopTrg, Condition( function Conditions ) )
    call TriggerAddAction( AddChopTrg, function Actions )
endfunction
endscope

Pretty straight forward script, don't know what is wrong though, all the unit codes are correct.
Need help please. Will add rep ;)
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
private function Conditions  takes nothing returns boolean
    return GetUnitTypeId(squire) == 'H006'  and  GetUnitLevel(squire) > 1 
endfunction
->>>

JASS:
private function Conditions  takes nothing returns boolean
    set squire = GetTriggerUnit()
    return GetUnitTypeId(squire) == 'H006'  and  GetUnitLevel(squire) > 1 
endfunction

whats the get unit level check for? i believe you want GetHeroLevel
 
Let me optimize it
JASS:
scope AddChop initializer Init

globals
    private unit squire // Removed the value because GetLevelingUnit
                             // Because you are referrin to a null value
                             // Constants refer to values which are not changing
                             // Handles and its child types are not constants. Except for the other types.
endglobals  

private function act  takes nothing returns boolean
    set squire = GetTriggerUnit()
    if GetUnitTypeId(squire) == 'H006'  and  GetUnitLevel(squire) > 1  then
        call UnitAddAbility( squire, 'A000' )
        call DisplayTimedTextToPlayer(GetOwningPlayer(squire), 0, 0, 30, "New Ability learned! |cffff8040Chop|r")
    endif
    return false
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddCondition( t, Condition( function act ) )
    set t = null
endfunction
endscope
 
Status
Not open for further replies.
Top