• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] JASS Spell Help

Status
Not open for further replies.
Level 3
Joined
Nov 3, 2004
Messages
43
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:
JASS:
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]
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Few things...

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

B)
JASS:
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
JASS:
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
JASS:
call TriggerSleepAction( 1.00 )
line, it is coming from the
JASS:
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.
 
Status
Not open for further replies.
Top