HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Really new to JASS... help ><

08-13-2007, 07:10 AM#1
st33m
Okay, so as previously stated, I'm really new to JASS. As in learning it tonight.

Heres an attempt at converting a GUI trigger to JASS, but I'm having so much trouble... or something.

Collapse JASS:
function Trig_Attack_Copy_3_Copy_2_Func001Func002002003 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true )
endfunction

function Trig_Attack_Copy_3_Copy_2_Func001Func003002 takes nothing returns nothing
    call UnitDamageTargetBJ( GetSpellAbilityUnit(), GetEnumUnit(), ( 100.00 + ( I2R(GetHeroStatBJ(bj_HEROSTAT_STR, GetSpellAbilityUnit(), true)) * 2.50 ) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Attack_Copy_3_Copy_2_Func001Func004002 takes nothing returns nothing
    call AddSpecialEffectTargetUnitBJ( "origin", GetEnumUnit(), "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
endfunction

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

function Trig_Attack_Copy_3_Copy_2_Actions takes nothing returns nothing
    if ( Trig_Attack_Copy_3_Copy_2_Func001C() ) then
        local unit c = GetTriggerUnit()
        local location cl = PolarProjectionBJ(c), 100.00, GetUnitFacing(c)
        local group hg = GetUnitsInRangeOfLocMatching(100.00, cl)], Condition(function Trig_Attack_Copy_3_Copy_2_Func001Func002002003))
        call ForGroupBJ( hg)], function Trig_Attack_Copy_3_Copy_2_Func001Func003002 )
        call ForGroupBJ( hg)], function Trig_Attack_Copy_3_Copy_2_Func001Func004002 )
        set c = null
        set cl = null
        set hg = null
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Attack_Copy_3_Copy_2 takes nothing returns nothing
    set gg_trg_Attack_Copy_3_Copy_2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Copy_3_Copy_2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Attack_Copy_3_Copy_2, function Trig_Attack_Copy_3_Copy_2_Actions )
endfunction


It is having problems with
Collapse JASS:
        local unit c = GetTriggerUnit()
        local location cl = PolarProjectionBJ(c), 100.00, GetUnitFacing(c)
        local group hg = GetUnitsInRangeOfLocMatching(100.00, cl)], Condition(function Trig_Attack_Copy_3_Copy_2_Func001Func002002003))
        call ForGroupBJ( hg)], function Trig_Attack_Copy_3_Copy_2_Func001Func003002 )
        call ForGroupBJ( hg)], function Trig_Attack_Copy_3_Copy_2_Func001Func004002 )
        set c = null
        set cl = null
        set hg = null

I'm really new, so sorry if this is really obvious, but why can't I just do that and have it all work out?

For when I'm setting locals it says "Expected 'endif'" and for the calls it says "Expected a name" and for the nulls it says "Expected a variable name."

I'm guessing this all stems from the inability to set the locals, but if thats not how you set locals then how do you?

Sorry ><
08-13-2007, 07:18 AM#2
PipeDream
  • Locals must be declared all together at the start of the function
  • There are some random ']' characters floating around
  • Probably other stuff? If you haven't used the Jass NewGen Pack (or PJASS at all) I encourage you to try.
08-13-2007, 07:26 AM#3
st33m
Oh. There are some ] floating around. At the start of the function? Wait... but if I want to make it an if don't I need to do that first and then declare the variables?
08-13-2007, 09:35 AM#4
Fireeye
steem, the local variables must ever be declared as first no matter what you want to do.
The only thing allowed to make before declaring the variables is to add comments.
I reorganized your trigger and changed a few things.
Trigger

Collapse JASS:
function Trig_Attack_Copy_3_Copy_2_Func001Func002002003 takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true
endfunction

function Trig_Attack_Copy_3_Copy_2_Func001Func003002 takes nothing returns nothing
    local unit u = GetEnumUnit()
    local effect e
    call UnitDamageTarget(GetSpellAbilityUnit(),u,100.00 + ( GetHeroStatBJ(bj_HEROSTAT_STR, GetSpellAbilityUnit(), true) * 2.50 ),true,false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
    set e = AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" , u, "origin"  )
    //You proably want to destroy the effect with the following line
    //call DestroyEffect(e)
    set u = null
    set e = null
endfunction

function Trig_Attack_Copy_3_Copy_2_Func001C takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_Attack_Copy_3_Copy_2_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    //Hint:
    //function PolarProjectionBJ takes location source, real dist, real angle returns location
    //local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    //local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    //return Location(x, y)
    //endfunction
    local real x = GetUnitX(c) + 100 * Cos(GetUnitFacing(c) * bj_DEGTORAD)
    local real y = GetUnitY(c) + 100 * Sin(GetUnitFacing(c) * bj_DEGTORAD)
    local group hg = CreateGroup()
    call GroupEnumUnitsInRange(hg,x,y,100.00,Condition(function Trig_Attack_Copy_3_Copy_2_Func001Func002002003))
    call ForGroupBJ( hg, function Trig_Attack_Copy_3_Copy_2_Func001Func003002 )
    call DestroyGroup(hg)
    set c = null
    set hg = null
endfunction

//===========================================================================
function InitTrig_Attack_Copy_3_Copy_2 takes nothing returns nothing
    set gg_trg_Attack_Copy_3_Copy_2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Copy_3_Copy_2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Attack_Copy_3_Copy_2, function Trig_Attack_Copy_3_Copy_2_Actions )
    call TriggerAddCondition( gg_trg_Attack_Copy_3_Copy_2, Condition(function Trig_Attack_Copy_3_Copy_2_Func001C))
endfunction



Also i move the entire thing to x and y value, due you made some mistakes beside the mentioned.
e.g. you tried to use a unit as location.
Also you would have leaked 2 location and 1 group every time this function would have been executed.
Beside that why did you use an if for getting the Spell Ability and didn't add it directly into the Trigger Condition?
Well, in my oppinion it could still be a bit optimized, but i think this is much better.
Here's the changelog
Changelog


- moved from locations to x and y values
- fixed group leak
- added trigger condition
- removed some BJ's
- merged Trig_Attack_Copy_3_Copy_2_Func001Func003002 and Trig_Attack_Copy_3_Copy_2_Func001Func004002 together
- fixed those ['s and )'s problems (you had some un-needed )'s which cause errors)
- That's all i can remember so far ...

08-13-2007, 09:43 AM#5
st33m
Erm. A lot of the errors came (maybe) from me first making this not multinstanceable in GUI and then trying to both a) convert it to JASS and b) make it multinstanceable, which I don't know if I succeeded in doing yet, but I was somewhat stuck over those errors.

Thanks.

EDIT:

I tried to do it in X, Y first but I couldn't figure out how so then I tried it a different way.

I'm also going about learning JASS all wrong (well not really, but read on) and I just sort of downloaded JassCraft and tried to guess at a lot of things while vaguely looking at the Stomp Spell tutorial for ideas on how to make this work... so um... yeah.