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

[Solved] syntax error, unexpected: "takes"

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
For some reason I keep getting an error with this function below, specifically Syntax Error, unexpected: "takes" on this line function Demonic_Flames_Targets_Filter takes nothing returns boolean
JASS:
function Demonic_Flames_Targets_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitEnemy(u, GetTriggerPlayer()) == true and IsUnitType(u, UNIT_TYPE_GROUND) == true and IsUnitType(u UNIT_TYPE_STRUCTURE == false then
        return true
    endif
    return false
endfunction


Here's the whole trigger:
JASS:
globals
    real dem_fla_dmgInc = 50                                                //per level increase of base damage
    real dem_fla_dmgBase = (100 - dem_fla_dmgInc)                           //base damage
    real dem_fla_dmgMulti_inc = 0.2                                         //how much attributes increase the damage by (per level)
    real dem_fla_dmgMulti_base = (1 - dem_fla_dmgMulti_inc)                 //how much attributes increase the damage by (base)
    real dem_fla_range_radius_inc = 15                                      //how big the AoE increase per level is
    real dem_fla_range_radius_base = (325 - dem_fla_range_radius_inc)       //how big the base AOE is
endglobals

function Trig_Demonic_Flames_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A043' then
        return true
    endif
    return false
endfunction


function Demonic_Flames_Damage takes real dmgAmount returns nothing
    local unit u = GetEnumUnit()
    //call UnitDamageTargetBJ( GetTriggerUnit(), GetEnumUnit(), ( ( 125.00 * I2R(GetUnitAbilityLevelSwapped('A043', GetTriggerUnit())) ) + ( I2R(GetHeroStatBJ(bj_HEROSTAT_AGI, GetTriggerUnit(), true)) * ( I2R(GetUnitAbilityLevelSwapped('A043', GetTriggerUnit())) * 0.75 ) ) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
    call UnitDamageTarget(sourceUnit, u, dmgAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffectTarget("Abilities\Weapons\FireBallMissile\FireBallMissile.mdl", u, "chest"))
endfuction

function Demonic_Flames_Targets_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitEnemy(u, GetTriggerPlayer()) == true and IsUnitType(u, UNIT_TYPE_GROUND) == true and IsUnitType(u UNIT_TYPE_STRUCTURE == false then
        return true
    endif
    return false
endfunction


function Demonic_Flames_TimerEnd takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer timerId = GetHandleId(t)
    local unit sourceUnit = LoadUnitHandle(udg_Hashtable, timerId, 0)
    local real x = GetUnitX(sourceUnit)
    local real y = GetUnitY(sourceUnit)
  
    local integer abilLevel = GetUnitAbilityLevel(sourceUnit, 'A043')
    local real abilLevel_real = I2R(abilLevel)
  
    local real dmgAoE = dem_fla_range_radius_base + dem_fla_range_radius_inc * abilLevel_real
    local real dmgHeroStat = I2R(GetHeroInt(sourceUnit, true)) * (dem_fla_dmgMulti_base + dem_fla_dmgMulti_inc * abilLevel_real)
    local real dmgAmount = dem_fla_dmgBase + dem_fla_dmgBase * abilLevel_real + dmgHeroStat
    local group dmgTargets = CreateGroup()
  
    call DestroyEffect(AddSpecialEffect("Abilities\Spells\Other\Doom\DoomDeath.mdl", x, y))
    call GroupEnumUnitsInRange(dmgTargets, x, y,dmgAoE , Condition(function Demonic_Flames_Targets_Filter))
  
    call ForGroup(dmgTargets, function Demonic_Flames_Damage(dmgAmount))
    call DestroyGroup(dmgTargets)
  
    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(udg_Hashtable, timerId)
endfunction

function Trig_Demonic_Flames_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit u = GetTriggerUnit()
    call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 0, u)
    call TimerStart(t, 2, false, function Demonic_Flames_TimerEnd)
      
endfunction

//===========================================================================
function InitTrig_Demonic_Flames takes nothing returns nothing
    set gg_trg_Demonic_Flames = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Demonic_Flames, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Demonic_Flames, Condition( function Trig_Demonic_Flames_Conditions ) )
    call TriggerAddAction( gg_trg_Demonic_Flames, function Trig_Demonic_Flames_Actions )
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Look at the highlighted code in your very own post. You wrote endfuction instead of endfunction right above the reported function.
 
Don't forget to pair up the parentheses as well.
JASS:
function Demonic_Flames_Targets_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitEnemy(u, GetTriggerPlayer()) and IsUnitType(u, UNIT_TYPE_GROUND) and (not IsUnitType(u UNIT_TYPE_STRUCTURE)) then
        return true
    endif
    return false
endfunction
 
Level 12
Joined
Nov 3, 2013
Messages
989
Don't forget to pair up the parentheses as well.
JASS:
function Demonic_Flames_Targets_Filter takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitEnemy(u, GetTriggerPlayer()) and IsUnitType(u, UNIT_TYPE_GROUND) and (not IsUnitType(u UNIT_TYPE_STRUCTURE)) then
        return true
    endif
    return false
endfunction
Yeah I found a lot more problems afterwards, and also apparently you can't have a callback function take anything, so I had to use globals as well. But I've fixed the trigger now at least.

The issue in the OP was just that I kept trying to figure out what the problem was with the line that gave the error message, when I should've looked at the previous function instead.
 
Status
Not open for further replies.
Top