• 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.

[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