Custom Spell JASS Help

Status
Not open for further replies.
Level 3
Joined
May 18, 2011
Messages
6
Hi All!

Hope you're doing well.

I require some help with this custom spell I'm making. It's a targetable spell that increases armor by 15 for 10 seconds, and increases to 20 and 30 seconds as the hero levels up the spell.

I originality tested in GUI and it works, but then I wanted to make it MUI, and as soon as I converted it to JASS with no changes whatsoever, it would no longer apply the armor increase or special effect despite the hero still playing the cast animation.

Could someone please kindly help me find out what seems to be the problem? I have not even changed the variables to local variables yet and it's already no longer working.

Many thanks!

Code:
function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A003' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func004Func003001 takes nothing returns boolean
    return ( UnitHasBuffBJ(udg_RadiantShieldUnit2, 'B000') == true )
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func004C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A003', gg_unit_H005_0017) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func005Func003001 takes nothing returns boolean
    return ( UnitHasBuffBJ(udg_RadiantShieldUnit2, 'B000') == true )
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func005C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A003', gg_unit_H005_0017) == 2 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func006Func003001 takes nothing returns boolean
    return ( UnitHasBuffBJ(udg_RadiantShieldUnit2, 'B000') == true )
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func006C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A003', gg_unit_H005_0017) == 3 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Actions takes nothing returns nothing
    set udg_RadiantShieldPlayer2 = GetOwningPlayer(GetSpellTargetUnit())
    set udg_RadiantShieldUnit2 = GetSpellTargetUnit()
    if ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func004C() ) then
        call TriggerSleepAction( 0.10 )
        loop
            exitwhen ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func004Func003001() )
            call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
        endloop
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) + 15.00 ) )
        call AddSpecialEffectTargetUnitBJ( "origin", udg_RadiantShieldUnit2, "Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl" )
        set udg_RadiantShieldEffect2 = GetLastCreatedEffectBJ()
        call TriggerSleepAction( 10.00 )
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) - 15.00 ) )
        call DestroyEffectBJ( udg_RadiantShieldEffect2 )
        set udg_RadiantShieldPlayer2 = GetFilterPlayer()
        set udg_RadiantShieldUnit2 = null
    else
        call DoNothing(  )
    endif
    if ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func005C() ) then
        call TriggerSleepAction( 0.10 )
        loop
            exitwhen ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func005Func003001() )
            call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
        endloop
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) + 15.00 ) )
        call AddSpecialEffectTargetUnitBJ( "origin", udg_RadiantShieldUnit2, "Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl" )
        set udg_RadiantShieldEffect2 = GetLastCreatedEffectBJ()
        call TriggerSleepAction( 20.00 )
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) - 15.00 ) )
        call DestroyEffectBJ( udg_RadiantShieldEffect2 )
        set udg_RadiantShieldPlayer2 = GetFilterPlayer()
        set udg_RadiantShieldUnit2 = null
    else
        call DoNothing(  )
    endif
    if ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func006C() ) then
        call TriggerSleepAction( 0.10 )
        loop
            exitwhen ( Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Func006Func003001() )
            call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.10))
        endloop
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) + 15.00 ) )
        call AddSpecialEffectTargetUnitBJ( "origin", udg_RadiantShieldUnit2, "Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl" )
        set udg_RadiantShieldEffect2 = GetLastCreatedEffectBJ()
        call TriggerSleepAction( 30.00 )
        call BlzSetUnitArmor( udg_RadiantShieldUnit2, ( BlzGetUnitArmor(udg_RadiantShieldUnit2) - 15.00 ) )
        call DestroyEffectBJ( udg_RadiantShieldEffect2 )
        set udg_RadiantShieldPlayer2 = GetFilterPlayer()
        set udg_RadiantShieldUnit2 = null
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Radiant_Shield_Effect_2_Copy_Copy_2 takes nothing returns nothing
    set gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2 = CreateTrigger(  )
    call DisableTrigger( gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2 )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2, Condition( function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Conditions ) )
    call TriggerAddAction( gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2, function Trig_Radiant_Shield_Effect_2_Copy_Copy_2_Actions )
endfunction
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
You should use [code=jass][/code] tags instead of code tags. The issue is likely because you're referring to the unit via this variable: gg_unit_H005_0017. If an auto-generated unit variable like that is only referenced in JASS code it will not be assigned a value at map start, so it will still be null. To fix this, you have two options:
  1. Instead of using the unit variable directly, use something appropriate like Triggering Unit (in jass: GetTriggerUnit()). This is the suggested approach as it will be unlikely to break again in the future.
  2. Create a GUI trigger that references the unit in some way. It doesn't have to run, it just has to use the variable:
    • Events
    • Conditions
    • Actions
      • Unit - Kill <the unit>
While I wholeheartedly encourage you to learn JASS (or better yet Lua), most spells can be made MUI with just GUI. The key resources I would suggest for this are Visualize: Dynamic Indexing and local udg_.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
call DisableTrigger( gg_trg_Radiant_Shield_Effect_2_Copy_Copy_2 )
The trigger appears initially disabled. So it cannot run unless another trigger enables it.

You also appear to duplicate a lot of code. You could have a lookup table for the duration and armor value and then use the same code to perform the actual spell using the appropriate values from that lookup table. This also makes it trivial to add more levels to the ability or change the stats of existing levels in the future.

In any case this ability very much sounds like Inner Fire. Are you planning on adding another effect which is why it needs to be triggered?
 
Status
Not open for further replies.
Top