HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JASS Help

07-04-2007, 01:02 AM#1
Dil999
I'm working on a simple spell right now. So far I'm only on the eye candy, it should create 2 units, make one cast a chain lightning spell for eye candy on a random unit in a group (the group is all the created units). For some reason, it seems to stop doing anything after creating the first trigger, as you can see from the debug messages, it does not display anything under' unit created 1'
Collapse JASS:
function Smite_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Smite_Actions takes nothing returns nothing
    local boolean b
    local integer i2
    local unit u = GetTriggerUnit()
    local group g
    local player p = GetOwningPlayer(u)
    local integer i = GetUnitAbilityLevel(u,'A001')
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x2
    local real y2
    local real dist
    local real height
    local real angle
    local real angle2
    call BJDebugMsg("started")
        loop                   
            call BJDebugMsg("loop 1")
            set dist = GetRandomReal(50,500)
            set height = GetRandomReal(0,230)
            set angle = GetRandomReal(0,360)
            set angle2 = GetRandomReal(0,360)
            set x2 = (x + dist * Cos(angle * bj_DEGTORAD))
            set y2 = (y + dist * Sin(angle * bj_DEGTORAD))
            call CreateUnit(p,'h000',x2,y2,angle2)
            call BJDebugMsg("unit created 1")
            call UnitApplyTimedLife(GetLastCreatedUnit(),'BTLF',5.0)
            call GroupAddUnit(g,GetLastCreatedUnit())
            call BJDebugMsg("h")
            set dist = GetRandomReal(50,500)
            call BJDebugMsg("h")
            set height = GetRandomReal(0,230)
            set angle = GetRandomReal(0,360)
            set angle2 = GetRandomReal(0,360)
            set x2 = (x + dist * Cos(angle * bj_DEGTORAD))
            set y2 = (y + dist * Sin(angle * bj_DEGTORAD))
            call CreateUnit(p,'h000',x2,y2,angle2)
            call BJDebugMsg("unit created 2")
            call UnitApplyTimedLife(GetLastCreatedUnit(),'BTLF',5.0)
            call GroupAddUnit(g,GetLastCreatedUnit())
            call IssueTargetOrder(GetLastCreatedUnit(),"healingwave",GroupPickRandomUnit(g))
            call PolledWait(0.20)
        endloop
endfunction

function InitTrig_Smite takes nothing returns nothing
    set gg_trg_Smite = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Smite, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition( gg_trg_Smite, Condition( function Smite_Conds  ) )
    call TriggerAddAction(gg_trg_Smite, function Smite_Actions )
endfunction
07-04-2007, 04:05 AM#2
Ammorth
Last Created unit does not work with CreateUnit() assign it to a variable and then null it later.
07-04-2007, 05:34 AM#3
Dil999
So I would do this?
Collapse JASS:
local unit u2
....
....
call CreateUnit(p,'h000',x2,y2,angle2)
set u2 = GetLastCreatedUnit()
call UnitApplyTimedLife(u2,'BTLF',5.0)
call GroupAddUnit(g,u2)
07-04-2007, 05:35 AM#4
Rising_Dusk
No.
You would do --
Collapse JASS:
local unit u2
....
....
set u2 = CreateUnit(p,'h000',x2,y2,angle2)
call UnitApplyTimedLife(u2,'BTLF',5.0)
call GroupAddUnit(g,u2)