HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

First shot as Jass [Help Needed]

06-20-2009, 03:22 AM#1
Zorgrath
I'm just trying things out, I figured I would try and make a chain/forked lightning mix spell. First off, I don't know how to do the graphical stuff. I need help making the lightning arc.
Well, actually first off, should this code even work? (Look below)
Second (Third? lol, I've gotten' myself confused), Okay I've made the code, but I haven't made the spell within the object editor. How do I go around doing that, when I go to create a custom spell it bases it off an old one I don't think I want that or am I missing something?
Thirdly-ish, when I check my syntax I get this error:
Trigger:
set gg_trg_LightningNet = CreateTrigger( )
Undeclared variable gg_trg_LightningNet
yet, when I converted to custom text I got this bit of code. Why is it doing this?

Collapse JASS:
function Trig_LightningNet_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == '1Z00'
endfunction

function Trig_LightningNet_Filter takes nothing returns boolean
    return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 
endfunction


function Trig_LightningNet_Actions takes nothing returns nothing
 local unit caster = GetSpellAbilityUnit() 
 local location start_position = GetUnitLoc(caster) 
 local unit target = GetSpellTargetUnit() 
 local location target_position = GetUnitLoc(target) 
 local group enemies_start = CreateGroup() 
 local group enemies_one = CreateGroup() 
 local group enemies_two = CreateGroup()
 local group enemies_three = CreateGroup()
 local unit temp 
 local location temp_position = null
 local location wave_one_position = null
 local unit wave_one
 local location wave_two_position = null
 local unit wave_two
 local location wave_three_position = null
 local unit wave_three
 local integer count = 2 
 local boolexpr filt = Condition(function Trig_LightningNet_Filter)
 local integer i = GetUnitAbilityLevel(caster, '1Z00')
 local integer b = 1
 local integer d = 0
 local integer wave_number = 0
 local real wave_reduction = 0
 
    call GroupEnumUnitsInRangeOfLoc(enemies_start, start_position, 700.0, filt)
    call UnitDamageTarget(caster, target, 85+i*i*10, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
    call GroupRemoveUnit(enemies_start, target)
    
    loop
        set temp = FirstOfGroup(enemies_start)
        exitwhen temp == null or count == 0
        call UnitDamageTarget(caster, temp, 85+i*i*10, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
        set count = count - 1
        
        set temp_position = GetUnitLoc(temp)
        
        if wave_one_position != null then
            set wave_two_position = temp_position
            set wave_two = temp
        endif

        if wave_one_position == null and temp_position != null then
            set wave_one_position = temp_position
            set wave_one = temp
        endif 
        call GroupRemoveUnit(enemies_start, temp)
    endloop
    
    set wave_three = target
    set wave_three_position = target_position
    
    if i > 1 then
        set count = i
        set d = 85+i*i*10
        loop
            exitwhen count == 1 or temp == null
            set wave_number = wave_number + 1
            set wave_reduction = wave_number * 0.15 + 1
            
            call GroupEnumUnitsInRangeOfLoc(enemies_one, wave_one_position, 300.0, filt)
            call GroupRemoveUnit(enemies_one, wave_one)
            set temp = FirstOfGroup(enemies_one)
            call UnitDamageTarget(caster, temp, d/wave_reduction, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
            call GroupAddUnit(enemies_one, wave_one)
            set wave_one = temp
            set wave_one_position = GetUnitLoc(wave_one)
            
            call GroupEnumUnitsInRangeOfLoc(enemies_two, wave_two_position, 300.0, filt)
            call GroupRemoveUnit(enemies_two, wave_two)
            set temp = FirstOfGroup(enemies_two)
            call UnitDamageTarget(caster, temp, d/wave_reduction, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
            call GroupAddUnit(enemies_two, wave_two)
            set wave_two = temp
            set wave_two_position = GetUnitLoc(wave_two)
            
            call GroupEnumUnitsInRangeOfLoc(enemies_three, wave_three_position, 300.0, filt)
            call GroupRemoveUnit(enemies_three, wave_three)
            set temp = FirstOfGroup(enemies_three)
            call UnitDamageTarget(caster, temp, d/wave_reduction, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
            call GroupAddUnit(enemies_three, wave_three)
            set wave_three = temp
            set wave_three_position = GetUnitLoc(wave_three)
            
            set count = count - 1
            
        endloop
    endif 
endfunction

//===========================================================================
function InitTrig_LightningNet takes nothing returns nothing
    set gg_trg_LightningNet = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LightningNet, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_LightningNet, Condition( function Trig_LightningNet_Conditions ) )
    call TriggerAddAction( gg_trg_LightningNet, function Trig_LightningNet_Actions )
endfunction

On a completely side note I'm new here and I gotta' say I love these emoticons
06-20-2009, 06:28 PM#2
Anopob
Firstly, you WANT to base your spell off an original spell. eg. if it's a target spell with a buff, you might want to base it off of Acid Bomb or Drunken Haze. If it's instant cast, Fan of Knives, etc. Otherwise (besides Channel), you can't indicate what type of spell you're creating. Same goes with units but that's kinda off-topic.

For your error, are you sure that's exactly what you're put? If you're completely doing JASS, make sure your trigger name is the same as "LightningNet", no spaces or anything. I can't really tell much about your error because it isn't too specific. And for your code, you don't need to set locations to null once your create them. In fact, you do that at the end to prevent leaks. You might want to look up a tutorial for that, since right now you're leaking EVERYTHING (groups, locations, units).