[JASS] Synthax Error?

Status
Not open for further replies.
Level 4
Joined
Sep 18, 2007
Messages
104
I finished reading a JASS tutorial, and JASSHelper gives me a synthax error when I try saving the map, the error is supposed to be on the first line of this function.

JASS:
private function Targets takes unit target returns boolean
    //the units the spell will affect
        return (GetWidgetLife(target) > 0.405) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false)
    endfunction

Here's the whole trigger:

JASS:
scope InstantJustice initializer Init
//===================================
//-----------SETUP START-------------
//===================================
    globals
        private constant integer SPELL_ID = 'ANsi'  //Spell rawcode
        private constant integer DUMMY_ID = 'h000'  // rawcode of the dummy unit
        private constant string AOE_EFFECT = "Units\\NightElf\\Wisp\\WispExplode.mdl"
        private constant string HEAL_EFFECT = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
        private constant string DAMAGE_EFFECT = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl"
        private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL
        private constant attacktype A_TYPE = ATTACK_TYPE_MAGIC
    endglobals
    
    private function Range takes integer level returns real
    //returns the range the spell will affect
        return level * 150.
    endfunction
    
    private function Heal takes integer level returns real
    //returns the amount allies will be healed
        return level * 75.
    endfunction
    
    private function Damage takes integer level returns real
    //returns damage enemies will take
        return level * 50
    endfuntion
    
    private function Targets takes unit target returns boolean
    //the units the spell will affect
        return (GetWidgetLife(target) > 0.405) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false)
    endfunction
//==========================================
//--------------SETUP END-------------------
//==========================================
    globals
        private group all
        private group copy
        private boolexpr b
    endglobals
//==========================================
//Function made by Blade.dk; search [url=http://www.wc3campaigns.net]Welcome to Wc3Campaigns[/url] for more info.
    private function CopyGroup takes group g returns group
        set bj_groupAddGroupDest = CreateGroup()
        call ForGroup(g, function GroupAddGroupEnum)
        return bj_groupAddGroupDest
    endfunction
//==========================================
    private function Pick takes nothing returns boolean
        return Targets(GetFilterUnit())
    endfunction
//==========================================
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction
//==============================
    private function Actions takes nothing returns nothing
        local location spellLoc = GetSpellTargetLoc()
        local real spellX = GetLocationX(spellLoc)
        local real spellY = GetLocationY(spellLoc)
        local unit caster = GetTriggerUnit()
        local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
        local unit f
        local integer allies = 0
        local integer enemies = 0
        
        //create the AOE effect
        call DestroyEffect(AddSpecialEffect(AOE_EFFECT, spellX, spellY
        
        //counting the units
        call GroupEnumUnitsInRange(all, spellX, spellY, Range(level), b)
        set copy = CopyGroup(all)
        loop
            set f = FirstOfGroup(all)
            exitwhen(f == null)
            call GroupRemoveUnit(copy, f)
            if IsUnitAlly(f, GetOwningPlayer(caster)) then
                set allies = allies + 1
            else
                set enemies = enemies + 1
            endif
        endloop
        
        //making the effect of the spell
        if allies > enemies then
            loop
                set f = FirstOfGroup(all)
                exitwhen (f==null)
                call GroupRemoveUnit(all, f)
                //heal allies
                if IsUnitAlly(f, GetOwningPlayer(caster)) then
                    call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin")) // the healing effect
                    call SetWidgetLife(f, GetWidgetLife(f) + Heal(level))
                endif
            endloop
        elsif enemies > allies then
            loop
                set f = FirstOfGroup(all)
                exitwhen (f==null)
                call GroupRemoveUnit(all, f)
                //damage enemies
                if IsUnitEnemy(f, GetOwningPlayer(caster)) then
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin"))  // the damage effect
                    call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null)
                endif
            endloop
        elseif allies = enemies then
            loop
                set f = FirstOfGroup(all)
                exitwhen (f == null)
                call GroupRemoveUnit(all, f)
                //heal allies
                if IsUnitAlly(f, GetOwningPlayer(caster)) then
                    call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin"))
                    call SetWidgetLife(f, GetwidgetLife(f) + Heal(level))
                //if an unit is not an ally than it is an enemy
                else
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin"))
                    call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null_
                endif
            endloop
        endif
        
        call RemoveLocation(spellLoc)
        set spellLoc = null
        set caster = null
    endfunction
//==============================
    private function Init takes nothing returns nothing
        local trigger InstantJusticeTrig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(InstantJusticeTrig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(InstantJusticeTrig, Condition(function Condtions))
        call TriggerAddAction(InstantJusticeTrig, function Actions)
        set InstantJusticeTrig = null
    
        //setting globals
        set all = CreateGroup()
        set copy = CreateGroup()
        set b = Condition(function Pick)
    
        //preloading effects
        call Preload(AOE_EFFECT)
        call Preload(HEAL_EFFECT)
        call Preload(DAMAGE_EFFECT)
        
        //preloading the ability
        set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMY_ID, 0, 0, 0)
        call UnitAddAbility(bj_lastCreatedUnit, SPELL_ID)
        call KillUnit(bj_lastCreatedUnit)
        
    endfunction
endscope

On the testmap at the end of the tutorial, I can save it without errors, but it gives me an error when I try to save my map. It could be from the other triggers, but they come before, and don't give me errors.
 
Status
Not open for further replies.
Top