• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Simple problem with jass :[

Status
Not open for further replies.
Level 3
Joined
Aug 22, 2009
Messages
51
Hi, ok so i have learned realy basic jass about an hour ago, and decided to make my GUI spell MUI.
I came up with this:
JASS:
function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig1 takes unit Temp_Caster  returns nothing
    call UnitDamageTargetBJ( Temp_Caster, GetEnumUnit(), 200, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions takes nothing returns nothing
    local unit Apocalyptica_Temp_Caster = GetSpellAbilityUnit()
    local real Apocalyptica_Temp_Dmg = I2R(( ( 50 + ( 50 * GetUnitAbilityLevelSwapped(GetSpellAbilityId(), Apocalyptica_Temp_Caster) ) ) + ( R2I(Pow(I2R(GetHeroStatBJ(bj_HEROSTAT_INT, Apocalyptica_Temp_Caster, true)), 2.00)) / 7 ) ))
    local location Apocalyptica_Temp_Point = GetSpellTargetLoc()
    call DisplayTextToForce( GetPlayersAll(), R2S(Apocalyptica_Temp_Dmg) )
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(Apocalyptica_Temp_Caster), Apocalyptica_Temp_Point) / 680.00 ) )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "war3mapImported\\NewGroundEX.mdx" )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl" )
    // ======== Look here ========
    call ForGroupBJ( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point),function Trig1(Apocalyptica_Temp_Caster))
    // ========  ======== 
    call CameraSetEQNoiseForPlayer( Player(0), 3 )
    call TriggerSleepAction( 0.50 )
    call CameraClearNoiseForPlayer( Player(0) )
    call RemoveLocation( Apocalyptica_Temp_Point)
endfunction

//===========================================================================
function InitTrig_Apocalyptica_Copy_Copy_2_Copy takes nothing returns nothing
    set gg_trg_Apocalyptica_Copy_Copy_2_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Apocalyptica_Copy_Copy_2_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Apocalyptica_Copy_Copy_2_Copy, Condition( function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Apocalyptica_Copy_Copy_2_Copy, function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions )
endfunction

The problem is, at line 60:
call ForGroupBJ( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point),function Trig1(Apocalyptica_Temp_Caster))

He says:
Expected '

I have no idea what it means, can anyone help me?
 
Level 6
Joined
May 19, 2004
Messages
267
The problem is that you can't pass parameters with ForGroup, the solution is using globals, and assigning your locals to those globals. Not tested, but this should work (note that you need to create a global variable);

JASS:
//This block will only work if you use NewGen/JassHelper.
//Else just remove it and create a global with the Variable Editor.
globals
    unit udg_Temp_Caster
endglobals

function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig1 takes nothing returns nothing
    local unit Apocalyptica_Temp_Caster = udg_Temp_Caster
    call UnitDamageTargetBJ(Apocalyptica_Temp_Caster, GetEnumUnit(), 200, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions takes nothing returns nothing
    local unit Apocalyptica_Temp_Caster = GetSpellAbilityUnit()
    local real Apocalyptica_Temp_Dmg = I2R(( ( 50 + ( 50 * GetUnitAbilityLevelSwapped(GetSpellAbilityId(), Apocalyptica_Temp_Caster) ) ) + ( R2I(Pow(I2R(GetHeroStatBJ(bj_HEROSTAT_INT, Apocalyptica_Temp_Caster, true)), 2.00)) / 7 ) ))
    local location Apocalyptica_Temp_Point = GetSpellTargetLoc()
    call DisplayTextToForce( GetPlayersAll(), R2S(Apocalyptica_Temp_Dmg) )
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(Apocalyptica_Temp_Caster), Apocalyptica_Temp_Point) / 680.00 ) )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "war3mapImported\\NewGroundEX.mdx" )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl" )
    // ======== Look here ========
    set udg_Temp_Caster = Apocalyptica_Temp_Caster
    call ForGroupBJ( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point), function Trig1)
    // ========  ======== 
    call CameraSetEQNoiseForPlayer( Player(0), 3 )
    call TriggerSleepAction( 0.50 )
    call CameraClearNoiseForPlayer( Player(0) )
    call RemoveLocation( Apocalyptica_Temp_Point)
endfunction

//===========================================================================
function InitTrig_Apocalyptica_Copy_Copy_2_Copy takes nothing returns nothing
    set gg_trg_Apocalyptica_Copy_Copy_2_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Apocalyptica_Copy_Copy_2_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Apocalyptica_Copy_Copy_2_Copy, Condition( function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Apocalyptica_Copy_Copy_2_Copy, function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions )
endfunction

If you don't want to use globals, you could try a FirstOfGroup loop instead (note that there are some issues with it if used incorrectly, so I'd recommend ForGroup). Just do a search on it.
You also have a few leaks.
 
Hi, ok so i have learned realy basic jass about an hour ago, and decided to make my GUI spell MUI.
I came up with this:
JASS:
function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig1 takes unit Temp_Caster  returns nothing
    call UnitDamageTargetBJ( Temp_Caster, GetEnumUnit(), 200, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions takes nothing returns nothing
    local unit Apocalyptica_Temp_Caster = GetSpellAbilityUnit()
    local real Apocalyptica_Temp_Dmg = I2R(( ( 50 + ( 50 * GetUnitAbilityLevelSwapped(GetSpellAbilityId(), Apocalyptica_Temp_Caster) ) ) + ( R2I(Pow(I2R(GetHeroStatBJ(bj_HEROSTAT_INT, Apocalyptica_Temp_Caster, true)), 2.00)) / 7 ) ))
    local location Apocalyptica_Temp_Point = GetSpellTargetLoc()
    call DisplayTextToForce( GetPlayersAll(), R2S(Apocalyptica_Temp_Dmg) )
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(Apocalyptica_Temp_Caster), Apocalyptica_Temp_Point) / 680.00 ) )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "war3mapImported\\NewGroundEX.mdx" )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl" )
    // ======== Look here ========
    call ForGroupBJ( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point),function Trig1(Apocalyptica_Temp_Caster))
    // ========  ======== 
    call CameraSetEQNoiseForPlayer( Player(0), 3 )
    call TriggerSleepAction( 0.50 )
    call CameraClearNoiseForPlayer( Player(0) )
    call RemoveLocation( Apocalyptica_Temp_Point)
endfunction

//===========================================================================
function InitTrig_Apocalyptica_Copy_Copy_2_Copy takes nothing returns nothing
    set gg_trg_Apocalyptica_Copy_Copy_2_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Apocalyptica_Copy_Copy_2_Copy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Apocalyptica_Copy_Copy_2_Copy, Condition( function Trig_Apocalyptica_Copy_Copy_2_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Apocalyptica_Copy_Copy_2_Copy, function Trig_Apocalyptica_Copy_Copy_2_Copy_Actions )
endfunction

The problem is, at line 60:
call ForGroupBJ( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point),function Trig1(Apocalyptica_Temp_Caster))

He says:
Expected '

I have no idea what it means, can anyone help me?

you dont need parameters with functions used within ForGroups I think because it will always use GetEnumUnit()....
 
Status
Not open for further replies.
Top