Warcraft III resources & community, 2003–2006 · archived

JASS Spell Help

2 posts
#1

JASS Spell Help

Ok, first things first. I am REALLY new at JASS. This is literally my second day using it so bare with me. I have just been messing around trying to make some spells and some with JASS just to try and improve my skills.

Second:
This is the code I put together this morning:

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

function Trig_MyFirstSpell_Actions takes nothing returns nothing
    call AddSpecialEffectLocBJ( GetUnitLoc(GetSpellTargetUnit()), "Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl" )
    call AddSpecialEffectLocBJ( PolarProjectionBJ(GetSpellTargetLoc(), 100.00, 0), "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" )
    call AddSpecialEffectLocBJ( PolarProjectionBJ(GetSpellTargetLoc(), 100.00, 90.00), "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" )
    call AddSpecialEffectLocBJ( PolarProjectionBJ(GetSpellTargetLoc(), 100.00, 180.00), "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" )
    call AddSpecialEffectLocBJ( PolarProjectionBJ(GetSpellTargetLoc(), 100.00, 270.00), "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl")
    call CreateUnitAtLoc ( GetOwningPlayer( GetTriggerUnit()), 'n000' , GetUnitLoc(GetSpellTargetUnit()), 0.00)
    call IssueTargetOrderBJ ( bj_lastCreatedUnit , 'A000', GetSpellTargetUnit())
    call TriggerSleepAction(1.00)  //ERROR HERE!! <--
    call KillUnit (bj_lastCreatedUnit)        
endfunction

//===========================================================================
function InitTrig_MyFirstSpell takes nothing returns nothing
    set gg_trg_MyFirstSpell = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MyFirstSpell, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_MyFirstSpell, Condition( function Trig_MyFirstSpell_Conditions ) )
    call TriggerAddAction( gg_trg_MyFirstSpell, function Trig_MyFirstSpell_Actions )
endfunction


When I try to run warcraft/enable the trigger, I get the error message "Line 30 (the sleep action) Invalid Argument Type (integer)"

What is wrong?? :cry: [/code]
#2
Few things...

A) Post scripts in JASS tags please, as it makes them 100x easier to read :D

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


I take it you got this part from a GUI code, converted (well, we all did >.>). This type of condition sucks, because you are using a boolean to see if you can return a boolean. Replace that with
function Trig_MyFirstSpell_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction


C) That script is leaking like crazy. You can replace all those AddSpecialEffectLocBJ calls with AddSpecialEffect calls assigned to local variables, so that you can destroy the effects later

D) The actual problem is not coming from the
call TriggerSleepAction( 1.00 )

line, it is coming from the
call IssueTargetOrderBJ( bj_lastCreatedUnit , 'A000', GetSpellTargetUnit())

line above it.

The second parameter of that line should be the orderstring of the ability you want to be casted, not the rawcode of that ability.

E) Finally, I see you use bj_lastCreatedUnit alot there. bj_lastCreatedUnit is only assigned in CreateNUnitsAtLoc, so in this case, the CreateUnitAtLoc call will not reset bj_lastCreatedUnit. You'll have to define a local unit and use it as a substitute.