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

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