HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

*Help* my spell doesent work! (JASS)

10-03-2006, 10:20 AM#1
zeroXD
Im working on a spell, witch creates some dummies floating around the caster, casting spells every now and then. The spell they cast works perfectly, it is this script that is the problem. It wont pass throught the WE's syntax checker, the check says everything is expecting "=" and names and stuff.

EDIT: i made the code pass the syntax check, but, however, the dummies dont seems to move at the same speed if the caster starts moving, witch is, problemmatic.

Heres the new code:

Collapse JASS:
function Trig_initiate_toss_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A007' ) ) then
        return false
    endif
    return true
endfunction

function Trig_initiate_toss_Func001001003 takes nothing returns boolean
    return ( GetUnitFlyHeight(GetFilterUnit()) <= 0.00 )
endfunction

function Trig_initiate_toss_Func001A takes nothing returns nothing
    call IssueTargetOrderBJ( udg_dummy, "chainlightning", GetEnumUnit() )
endfunction

function Trig_initiate_toss_MoveOrbs takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit array dummy
local real angle
local unit caster=GetHandleUnit( t, "caster" )
local location loca=GetUnitLoc( caster )
local location locb
local integer steps=7
    set dummy[0]=GetHandleUnit( t, "dummy[0]" )
    set dummy[1]=GetHandleUnit( t, "dummy[1]" )
    set dummy[2]=GetHandleUnit( t, "dummy[2]" )
    set dummy[3]=GetHandleUnit( t, "dummy[3]" )
    set dummy[4]=GetHandleUnit( t, "dummy[4]" )
    set dummy[5]=GetHandleUnit( t, "dummy[5]" )
    set dummy[6]=GetHandleUnit( t, "dummy[6]" )
    set dummy[7]=GetHandleUnit( t, "dummy[7]" )
loop
    exitwhen steps<0
    set locb=GetUnitLoc( dummy[steps] )
    set angle=AngleBetweenPoints( loca, locb )+2.5
    call RemoveLocation( locb )
    set locb=PolarProjectionBJ( loca, 500, angle )
    call SetUnitPositionLoc( dummy[steps], locb )
    call RemoveLocation( locb )
    set dummy[steps]=null
    set steps=steps-1
endloop
    call RemoveLocation( loca )
set caster=null
endfunction

function Trig_initiate_toss_Actions takes nothing returns nothing
local timer t=CreateTimer()
local unit array dummy
local unit caster=GetTriggerUnit()
local location loca=GetUnitLoc( caster )
local location locb
local real angle=45
local integer steps=7
local integer step2=20
loop
    exitwhen steps<0
    set locb=PolarProjectionBJ( loca, 650, angle*steps )
    set dummy[steps]=CreateUnitAtLoc( GetOwningPlayer( caster ), 'h000', locb, 0 )
    call RemoveLocation( locb )
    set steps=steps-1
endloop
    call RemoveLocation( loca )
    call SetHandleHandle( t, "caster", caster )
    call SetHandleHandle( t, "dummy[0]", dummy[0] )
    call SetHandleHandle( t, "dummy[1]", dummy[1] )
    call SetHandleHandle( t, "dummy[2]", dummy[2] )
    call SetHandleHandle( t, "dummy[3]", dummy[3] )
    call SetHandleHandle( t, "dummy[4]", dummy[4] )
    call SetHandleHandle( t, "dummy[5]", dummy[5] )
    call SetHandleHandle( t, "dummy[6]", dummy[6] )
    call SetHandleHandle( t, "dummy[7]", dummy[7] )
    call SetHandleReal( t, "angle", angle )
    call TimerStart( t, 0.02, true, function Trig_initiate_toss_MoveOrbs )
loop
    exitwhen step2<=0
    set steps=7
    loop
        exitwhen steps<0
        set udg_dummy=dummy[steps]
        call ForGroupBJ( GetUnitsInRangeOfLocMatching( 400.00, GetUnitLoc( udg_dummy ), Condition( function Trig_initiate_toss_Func001001003 ) ), function Trig_initiate_toss_Func001A )
        set udg_dummy=null
        call TriggerSleepAction( 0.01 )
        set steps=steps-1
    endloop
    call TriggerSleepAction( 0.01 )
    set step2=step2-1
endloop
set steps=7
loop
    exitwhen steps<0
    call RemoveUnit( dummy[steps] )
    set dummy[steps]=null
    set steps=steps-1
endloop
    call FlushHandleLocals( t )
    call DestroyTimer( t )
set caster=null
endfunction

//===========================================================================
function InitTrig_initiate_toss takes nothing returns nothing
    set gg_trg_initiate_toss = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_initiate_toss, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_initiate_toss, Condition( function Trig_initiate_toss_Conditions ) )
    call TriggerAddAction( gg_trg_initiate_toss, function Trig_initiate_toss_Actions )
endfunction

Help, please
10-03-2006, 01:18 PM#2
Chuckle_Brother
The error is that you declared locals AFTER setting some variables.
Collapse JASS:
local location loca=GetUnitLoc( caster )
local location locb
local integer steps=7

Those are all illegal declarations, put them above the code:

Collapse JASS:
set dummy[0]=GetHandleUnit( t, "dummy[0]" )
set dummy[1]=GetHandleUnit( t, "dummy[1]" )
set dummy[2]=GetHandleUnit( t, "dummy[2]" )
set dummy[3]=GetHandleUnit( t, "dummy[3]" )
set dummy[4]=GetHandleUnit( t, "dummy[4]" )
set dummy[5]=GetHandleUnit( t, "dummy[5]" )
set dummy[6]=GetHandleUnit( t, "dummy[6]" )
set dummy[7]=GetHandleUnit( t, "dummy[7]" )

Edit: In the function Trig_initiate_toss_MoveOrbs
10-03-2006, 02:24 PM#3
zeroXD
Yes, i have actually fixed that, but i forgot to update :p updating now, a problem i got is moving the freaking dummies right!
10-03-2006, 06:28 PM#4
oNdizZ
how are they moving? (except just wrong)

i cant really see how this would not crash

Collapse JASS:
function Trig_initiate_toss_MoveOrbs takes nothing returns nothing
...
loop
    exitwhen steps<0
    set locb=GetUnitLoc( dummy[steps] )
    set angle=AngleBetweenPoints( loca, locb )
    call RemoveLocation( locb )
    set locb=PolarProjectionBJ( loca, 500, angle )
    call SetUnitPositionLoc( dummy[steps], locb )
    call RemoveLocation( locb )
    set dummy[steps]=null
endloop
...
endfunction

function Trig_initiate_toss_Actions takes nothing returns nothing
...
loop
    exitwhen steps<0
    set locb=PolarProjectionBJ( loca, 650, angle*steps )
    set dummy[steps]=CreateUnitAtLoc( GetOwningPlayer( caster ), 'h000', locb, 0 )
    call RemoveLocation( locb )
endloop
...
endfunction

i cant find any set steps = ... in neither of them
10-03-2006, 07:19 PM#5
Chuckle_Brother
Yeah, thats gonna infinite loop the shit out of the game.
10-04-2006, 05:50 AM#6
zeroXD
DUH!!! I copied from frong script XD! Fixing now, WITH steps decreasing.

EDIT: now its updated and ready. The problem is, that if the caster moves, then the dummies seems to start moving at different speeds. If you aint as lazy as me you can make a new map and put in KaTTaNa's handle vars and create a global unit variable named "dummy".

Another problem is that the dumies dont seems to cast the spell (i know they will have problems casting while being moved, but im using "EVENT_PLAYER_UNIT_SPELL_EFFECT" for that spell, witch should be working at once u target something, right?) I am telling them to use.