View Single Post
Old 02-17-2008, 11:30 AM   #1 (permalink)
Registered User Flame_Phoenix
 
Flame_Phoenix's Avatar

Map Maker
 
Join Date: May 2007
Posts: 1,536

Flame_Phoenix has a spectacular aura about (144)Flame_Phoenix has a spectacular aura about (144)Flame_Phoenix has a spectacular aura about (144)Flame_Phoenix has a spectacular aura about (144)


Life or Death !! Help fast rep+ !!! Chain spell

GUYS this is a spell for a competition. I know the is not greatly optimized, but according to the time, was the best I could do.
Anyway, if you post it in JassCraft, in line 69, (the "call ForGroup") has an error.
Please tell me why it is wrong !!! I don't understand why !
Also, if you see any instruction with "//" uts because I am not sure about that same instruction. It means that I don't know if it will compromise the spell, so comments on that would also be appreciated.

Guys, I don't want any optimizations, please the spell is already difficult enough for me to understand (keep in mind that I am its creator). Please just tell what is wrong and What can I do to fix it !
Fast plz !

Chain:
function Trig_Chain_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
//=========================================================
//ver local vars MB_targ, MB_SMax, MB_alltargs
function forUnit takes unit targ, real max, group g returns nothing
    local unit u = GetEnumUnit()
    local player p = GetOwningPlayer(GetTriggerUnit())
    local unit MB_targ = targ
    local real MB_SMax = max
local group MB_alltarg = g
    if IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and IsUnitType(u, UNIT_TYPE_MECHANICAL) and IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) and IsUnitEnemy(u, p) and (GetUnitState(u, UNIT_STATE_LIFE) > 0) and IsUnitInGroup(u, MB_alltarg) == false and (GetUnitState(u, UNIT_STATE_MAX_MANA) > 0) and (GetUnitState(u, UNIT_STATE_MANA) >= MB_SMax) then
        set MB_targ = u
        set MB_SMax = GetUnitState(u, UNIT_STATE_MANA)
    endif
    //call DestroyGroup(MB_alltarg)
    //set MB_alltarg = null
    //set u = null
    //set p = null
    //set MB_targ = null
endfunction
//=========================================================
function Trig_Chain_Actions takes nothing returns nothing
    //variables part
    local unit MB_targ = GetSpellTargetUnit()//current target
    local unit MB_prev = GetTriggerUnit() //previous target, the source where it all came
    local integer MB_level = GetUnitAbilityLevel(MB_prev, 'A000')
    local integer MB_targetsnum = (4 + (2 * (MB_level - 1))) //maximum number of affected unit
    local integer MB_cur //current number of targets
    local group MB_alltarg //Group that will save hit units in the past
    local unit dummy //casts the spells
    local group MB_TempGroup //will pick a random unit, that will be the next target
    local real MB_SMax//chooses the unit with more mana
    local location l
    //action part
    loop
        exitwhen (MB_cur > MB_targetsnum)
        //start
        call GroupAddUnit(MB_alltarg, MB_targ)
        set dummy = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h000', GetUnitX(MB_prev), GetUnitY(MB_prev), 0.0)
        call UnitAddAbility(dummy, 'A002')
        call IssueTargetOrder(dummy, "shadowstrike", MB_targ)
        call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
        //set dummy = null
        //Wait Unit Unit was reached by effect
        loop
            exitwhen ((GetUnitAbilityLevel(MB_targ, 'BEsh') > 0) or (GetUnitState(MB_targ, UNIT_STATE_LIFE) <= 0))
            call TriggerSleepAction(0.30)
        endloop
        //If unit is alive, take mana
        if (GetUnitState(MB_targ, UNIT_STATE_LIFE) <= 0) == false then
            call CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h000', GetUnitX(MB_targ), GetUnitY(MB_targ), 0.0)
            call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
            call UnitAddAbility(dummy, 'A001')
            call SetUnitAbilityLevel(dummy, 'A001', 8 * (MB_level - 1) + MB_cur)
            call IssueTargetOrder(dummy, "manaburn", MB_targ)
        else
            set MB_cur = MB_targetsnum + 1
        endif
        //Choose New target
        if (MB_cur < MB_targetsnum) then
            set MB_prev = MB_targ
            set MB_SMax = -1
            set l = GetUnitLoc(MB_prev)
            call ForGroup(GetUnitsInRangeOfLocAll(500, l), function forUnit(MB_targ, MB_SMax, MB_alltarg))//error . WHYY!!!!!
            call RemoveLocation(l)
            set l = null
            call GroupClear(MB_alltarg)
endif
        set MB_cur = MB_cur + 1
    endloop
    call DestroyGroup(MB_alltarg)
    call DestroyGroup(MB_TempGroup)
    set MB_alltarg = null
    set MB_TempGroup = null
    set MB_targ = null
    set MB_prev = null
    set dummy = null
endfunction
//=========================================================
function InitTrig_Chain takes nothing returns nothing
    set gg_trg_Chain = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_Chain, Condition(function Trig_Chain_Conditions))
    call TriggerAddAction(gg_trg_Chain, function Trig_Chain_Actions)
endfunction

If you don't understand something, tell me so I can help you help me ! (lol)
Hurry ! The clock is tickling !

Btw, Credits will be given as well !
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
Check out all my current spells at here
This spells belong to my project
Castle vs Castle Flame Edition and I hope you all enjoy it.

Last edited by Flame_Phoenix; 02-17-2008 at 02:55 PM..
Flame_Phoenix is offline   Reply With Quote