• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] I need help with this script!

Status
Not open for further replies.
Level 4
Joined
Nov 3, 2004
Messages
79
I need help with this script it the dummy doesnt learn the ability and doesnt cast it X<

function Trig_Spalter_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A001' ) ) then
return false
endif
return true
endfunction

function Trig_Spalter_Actions takes nothing returns nothing
local unit casterOfSR = GetSpellAbilityUnit()
local unit dummy
local integer CastMulti
set CastMulti = GetRandomInt(1, 4)
loop
exitwhen CastMulti == 0
call CreateUnit(GetOwningPlayer(casterOfSR), 'n000', GetUnitX(casterOfSR), GetUnitY(casterOfSR), 0.00 )
set dummy = GetLastCreatedUnit()
call UnitAddAbilityBJ( udg_SpalterArray[GetUnitAbilityLevelSwapped('A001', casterOfSR)], dummy )
call IssueImmediateOrderBJ( dummy, "thunderclap" )
set CastMulti = CastMulti - 1
call TriggerSleepAction(1.00)
endloop
set casterOfSR = null
set dummy = null
endfunction

//===========================================================================
function InitTrig_Spalter takes nothing returns nothing
set gg_trg_Spalter = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spalter, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spalter, Condition( function Trig_Spalter_Conditions ) )
call TriggerAddAction( gg_trg_Spalter, function Trig_Spalter_Actions )
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
here

JASS:
function Trig_Spalter_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Spalter_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local unit dummy
    local integer CastMulti = GetRandomInt(1, 4)
    loop
        exitwhen CastMulti == 0
        set dummy = CreateUnit(GetOwningPlayer(cast), 'n000', GetUnitX(cast), GetUnitY(cast), 0.00 )
        call UnitAddAbility( dummy, udg_SpalterArray[GetUnitAbilityLevel(cast, 'A001')] )
        call IssueImmediateOrder( dummy, "thunderclap" )
        set CastMulti = CastMulti - 1
        call TriggerSleepAction(1.00)
    endloop
    set cast = null
    set dummy = null
endfunction

//===========================================================================
function InitTrig_Spalter takes nothing returns nothing
set gg_trg_Spalter = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spalter, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spalter, Condition( function Trig_Spalter_Conditions ) )
call TriggerAddAction( gg_trg_Spalter, function Trig_Spalter_Actions )
endfunction

the problem was that you were saying

CreateUnit

and then

Get Last Created Unit.

Get Last Created Unit ( bj_lastCreatedUnit ) has to be defined, so it is defined by CreateNUnitsAtLoc. Since you were trying to access the dummy thru Last Created Unit which was undefined, this didnt work.

I fixed up some BJ's and stuff as well.
 
Status
Not open for further replies.
Top