HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass problem :\

10-06-2009, 05:13 AM#1
Mendel
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:
Open This

Collapse 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?
10-06-2009, 05:30 AM#2
midiway
in jass, callback functions, like the one you specify to ForGroupBJ, can not receive parameters, they must takes nothing, so the right way to use the ForGroupBJ is writing only the name of the callback functions, whithout any parameter, adjusting the function prototype that is being called:

call ForGroup( GetUnitsInRangeOfLocAll(512, Apocalyptica_Temp_Point), function Trig1 ) //replaced ForGroupBJ with ForGroup
10-06-2009, 05:39 AM#3
Mendel
The thing is i need to get that parameters to work,
since i use a unit and a real number wich is declared at the very first of the trigger,
and i can't declare it again since after that wait period things can be changed, so how can i get this to work?
10-06-2009, 06:23 AM#4
Tot
Quote:
Originally Posted by Mendel
The thing is i need to get that parameters to work,
since i use a unit and a real number wich is declared at the very first of the trigger,
and i can't declare it again since after that wait period things can be changed, so how can i get this to work?

with a global variable it should work
set the global = <what you give your func> before calling ForGroup or ForGroupBJ and use it in the called func

after everything is done, you can remove your global (calling either destroy or setting it = null
10-07-2009, 04:06 AM#5
TheKid
You could do it this way.

Declare a struct:
Collapse JASS:
struct s_name
    unit    tempUnit1  = null
    unit    tempUnit2  = null
    
    real    tempReal1
    real    tempReal2
    
    //* Any data-types you may need can be declared in this struct, which will be saved to the
    //* Group handle as an integer;
endstruct

Next, initialize a hashtable and use it to store the value of the struct to the necessary group.

Collapse JASS:
// ...
    set hash = InitHashtable()
// ...
    call SaveInteger( hash, GetHandleId(yourGroup), 1, nameStruct )     //* youGroup would be the group you are attaching the values to, and nameStruct would be
// ...                                                                  //* a reference to an instance of s_name.

Once you are done with the data (after the ForGroup) you will need to use the RemoveSavedInteger( hash, GetHandleId(youGroup), 1 ) for cleanup. I still don't know how necessary this is but I don't like leaving it to chance.

For something like this, it is probably more efficient in general to use globals, but there are some situations where globals may not cut it.