• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Need help with this error

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
JASS:
library DamageDetection initializer onInit requires RegisterPlayerUnitEvent

    globals
        private constant integer DETECTION_ID   = 'A001'
        private constant integer DETECTION_BUFF = 'B000'
        private trigger trig = CreateTrigger()
        private integer array spells
        private integer index = 0
    endglobals

    /**
     * When the ability is learned for the first time, the damage detection ability
     * is added to the unit.
     */
    public function RegisterSpell takes integer abilityId returns nothing
        if (abilityId != 0) then
            set spells[index] = abilityId
            set index = index + 1
        endif
    endfunction
    
    /**
     * Register an on-attack event.
     */
    public function RegisterAttack takes code onAttack returns nothing
        call TriggerAddCondition(trig, Condition(onAttack))
    endfunction
    
    private function CheckSkill takes nothing returns nothing
        local integer abilityId
        local integer i
        
        if (GetLearnedSkillLevel() == 1 and GetUnitAbilityLevel(GetTriggerUnit(), DETECTION_ID) == 0) then
            set abilityId = GetLearnedSkill()
            
            for i = 0 to (index - 1)
                if (spells[i] == abilityId) then
                    call UnitAddAbility(GetTriggerUnit(), DETECTION_ID)
                    return
                endif
            endfor
        endif
        
    endfunction
    
    private function CheckAttack takes nothing returns boolean
        if (GetUnitAbilityLevel(udg_GDD_DamagedUnit, DETECTION_BUFF) > 0) then
            call UnitRemoveAbility(udg_GDD_DamagedUnit, DETECTION_BUFF)
            call TriggerEvaluate(trig)
        endif
        
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CheckAttack))
        call TriggerRegisterVariableEvent(t, "udg_GDD_Event", EQUAL, 0.0)
        call RegisterPlayerUnitEvent(EVENT_PLAYER_HERO_SKILL, function CheckSkill)
        set t = null
    endfunction

endlibrary

Hello guys I need help with this trigger, this line is causing an error '' Syntax Error, unexpected: ''i''?

:fp: for i = 0 to (DamageDetection___index - 1)
if (DamageDetection___spells == abilityId) then
call UnitAddAbility(GetTriggerUnit(), DamageDetection___DETECTION_ID)
return
 
Status
Not open for further replies.
Top