HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with a spell

03-12-2007, 01:58 PM#1
botanic
the script that I am using is erroring at the lines after the triggers... "call SetAllianceStateAllyBj( Player(9), Player(11), true ) " to be exact. it says Line 7728 Expected a name...

The script that is causing the problem is
Collapse JASS:
constant function PerfectBlue_SpellId takes nothing returns integer
    return 'A00S'
endfunction

constant function PerfectBlue_Chaos takes nothing returns integer
    return 'S000'
endfunction
constant function PerfectBlue_Firebolt takes nothing returns integer
    return 'A00P'
endfunction

constant function PerfectBlue_Dummy takes nothing returns integer
    return 'n00R'
endfunction
constant function PerfectBlue_Part takes nothing returns integer
    return 'n00T'
endfunction

function PerfectBlue_Level2Seconds takes integer level returns real
    if level == 1 then
        return 20.0
    elseif level == 2 then
        return 35.0
    elseif level == 3 then
        return 60.0
    endif
    return 25.0
endfunction

function PerfectBlue_MoveNearHero takes nothing returns nothing
    local integer i = 1
    local real a = 0.5
    local real b = 1 - a
    local string ref = CacheGetRef(GetExpiredTimer())
    local unit caster = CacheGetUnit(ref,"caster")
    local unit array u

    set u[1] = CacheGetUnit(ref,"unit1")
    set u[2] = CacheGetUnit(ref,"unit2")
    set u[3] = CacheGetUnit(ref,"unit3")
    set u[4] = CacheGetUnit(ref,"unit4")
    set u[5] = CacheGetUnit(ref,"unit5")
    set u[6] = CacheGetUnit(ref,"unit6")
    set u[7] = CacheGetUnit(ref,"unit7")
    set u[8] = CacheGetUnit(ref,"unit8")
    set u[9] = CacheGetUnit(ref,"unit9")
    set u[10] = CacheGetUnit(ref,"unit10")
    call SetUnitX(u[1], GetUnitX(caster))
    call SetUnitY(u[1], GetUnitY(caster))
    loop
        set i = i + 1
        exitwhen i >= 10
        call SetUnitX( u[i], GetUnitX(u[i - 1]) * a + GetUnitX(u[i + 1]) * b)
        call SetUnitY( u[i], GetUnitY(u[i - 1]) * a + GetUnitY(u[i + 1]) * b)
        call SetUnitFlyHeight( u[i], GetUnitFlyHeight(u[i - 1]) * a + GetUnitFlyHeight(u[i + 1]) * b, 0.2)
    endloop
    if CacheGetBoolean(ref,"done") then
        set i = 0
        loop
            set i = i + 1
            exitwhen i > 10
            call UnitApplyTimedLife(u[i], 'BTLF', 0.5)
        endloop
    endif
    set u[1] = null
    set u[2] = null
    set u[3] = null
    set u[4] = null
    set u[5] = null
    set u[6] = null
    set u[7] = null
    set u[8] = null
    set u[9] = null
    set u[10] = null
    set caster = null
    if CacheGetBoolean(ref,"done") then
        call CacheClearAll(ref)
        call TimerDestroy(GetExpiredTimer())
    endif
endfunction

function PerfectBlue_Move_FindEnemy takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(bj_lastCreatedUnit)) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endfunction

function PerfectBlue_JumpAround takes nothing returns nothing
    local integer i
    local real x
    local real y
    local unit u
    local string ref = CacheGetRef(GetExpiredTimer())
    local unit caster = CacheGetUnit(ref,"caster")
    local group g = CreateGroup()
    local boolexpr filter = Condition(function PerfectBlue_Move_FindEnemy)
    local unit thorny = CacheGetUnit(ref,"unit10")

    if GetWidgetLife(caster) < 0.4 then
        call CacheSetInt(ref,"count",1)
    endif

    call GroupAddUnit(g, null)
    set bj_lastCreatedUnit = thorny
    call GroupEnumUnitsInRange(g, GetUnitX(bj_lastCreatedUnit), GetUnitY(bj_lastCreatedUnit), 512, filter)
    set u = FirstOfGroup(g)
    if u == null then
        set bj_lastCreatedUnit = caster
        call GroupEnumUnitsInRange(g, GetUnitX(caster), GetUnitY(caster), 512, filter)
    endif
    set u = GroupPickRandomUnit(g)
    if u != null then
        set x = GetUnitX(u)
        set y = GetUnitY(u)
        call SetUnitX(thorny, x)
        call SetUnitY(thorny, y)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl", x, y))
        set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(thorny), PerfectBlue_Dummy(), x, y, bj_UNIT_FACING)
        call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 1.0)
        call UnitAddAbility(bj_lastCreatedUnit, PerfectBlue_Firebolt())
        call IssueTargetOrder(bj_lastCreatedUnit, "firebolt", u)
        set u = null
    endif

    call DestroyBoolExpr(filter)
    set filter = null
    set caster = null
    call DestroyGroup(g)
    set g = null
    set thorny = null

    set i = CacheGetInt(ref,"count") - 1
    if i > 0 then
        call CacheSetInt(ref,"count",i)
    else
        call CacheSetBoolean(CacheGetRef(CacheGetTrigger(ref,"part2")),"done",true)
        call CacheClearAll(ref)
        call TimerDestroy(GetExpiredTimer())
    endif
endfunction

function Trig_PerfectBlue_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == PerfectBlue_SpellId()
endfunction

function Trig_Perfect_Blue_Actions takes nothing returns nothing
    local integer i = 0
    local real x = GetLocationX(GetSpellTargetLoc())
    local real y = GetLocationY(GetSpellTargetLoc())
    local real duration = PerfectBlue_Level2Seconds(GetUnitAbilityLevel(GetTriggerUnit(), GetSpellAbilityId()))
    local timer t1 = TimerCreate()
    local timer t2 = TimerCreate()
    local string ref1 = CacheGetRef(t1)
    local string ref2 = CacheGetRef(t2)
    local unit u
    local unit array U

    call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl", x, y))

    loop
        exitwhen GetUnitCurrentOrder(GetTriggerUnit()) != OrderId("summonfactory")
        call TriggerSleepAction(0.05)
    endloop

    call CacheSetUnit(ref1,"caster",GetTriggerUnit())
    call CacheSetUnit(ref2,"caster",GetTriggerUnit())

    loop
        set i = i + 1
        exitwhen i > 10
        set u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), PerfectBlue_Part(), x, y, bj_UNIT_FACING)
        call SetUnitFlyHeight(u, i * 5 + 40, 0)
        call SetUnitState(u, UNIT_STATE_LIFE, 500)
        call CacheSetUnit(ref1,"unit" + I2S(i),u)
//        call CacheSetUnit(ref2,"unit" + I2S(i),u)
        set U[i] = u
    endloop
    call CacheSetUnit(ref2,"unit10",u)
    call UnitAddAbility(u, PerfectBlue_Chaos())
    call UnitAddAbility(u, 'Aloc')
    call SetUnitFlyHeight(u, 90, 0)
    call SetUnitTimeScale(u, 1)
    set u = null

    call CacheSetBoolean(ref1,"done",false)
    call TimerStart(t1, 0.12, true, function PerfectBlue_MoveNearHero)

    call TriggerSleepAction(1.2)

    set i = 0
    loop
        set i = i + 1
        exitwhen i > 9
        call IssueTargetOrder(U[i], "drain", U[i + 1])
        set U[i] = null
    endloop
    set U[i] = null

    call CacheSetInt(ref2,"count",1 + R2I(duration / 3.5))
    call CacheSetHandle(ref2,"part2",t1)
    call TriggerSleepAction(2)
    call TimerStart(t2, 3.5, true, function PerfectBlue_JumpAround)

    set t1 = null
    set t2 = null
endfunction

//===========================================================================
function InitTrig_Perfect_Blue takes nothing returns nothing
    set gg_trg_Perfect_Blue = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Perfect_Blue, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Perfect_Blue, Condition( function Trig_PerfectBlue_Conditions))
    call TriggerAddAction(gg_trg_Perfect_Blue, function Trig_Perfect_Blue_Actions)
endfunction


I uploaded the map if anyone wants to see it.

also I am having a problem with the units camp locations if anyone would mind helping with that so I dont have to post again.
Attached Files
File type: w3xPOH V.7.w3x (375.9 KB)
03-13-2007, 02:19 AM#2
Pyrogasm
Just wondering... why the fuck would you do things like this:
Collapse JASS:
    set bj_lastCreatedUnit = thorny
    call GroupEnumUnitsInRange(g, GetUnitX(bj_lastCreatedUnit), GetUnitY(bj_lastCreatedUnit), 512, filter)
Collapse JASS:
    set u = FirstOfGroup(g)
    if u == null then
        set bj_lastCreatedUnit = caster
        call GroupEnumUnitsInRange(g, GetUnitX(caster), GetUnitY(caster), 512, filter)
You could just use a variable...

Also, that line isn't even in that script, but the problem is that you typed "Bj" instead of "BJ".

A good BJ for replacing lots of code, though.