• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Yet,another jass error

Status
Not open for further replies.
Level 4
Joined
Dec 14, 2007
Messages
41
JASS:
function Trig_Lockon_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Lockon_Actions takes nothing returns nothing
    call AttachObject(GetSpellTargetUnit(),"target",GetSpellAbilityUnit())
    call TriggerSleepAction(3.00)
    if UnitHasBuffBJ(GetSpellTargetUnit(),'B000' ) == true then
     call DisplayTimedTextToPlayer(GetOwningPlayer(GetSpellAbilityUnit()),GetUnitX(GetSpellTargetUnit()),GetUnitY(GetSpellTargetUnit()),5.00,"Lock On Complete!")
     call UnitAddAbility(GetSpellAbilityUnit(),'A003')
     call AttachBoolean(GetSpellTargetUnit(),"lockbreakable",false)
    else
     call DisplayTimedTextToPlayer(GetOwningPlayer(GetSpellAbilityUnit()),GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit()),5.00,"Lock Lost")
    endif
endfunction

//===========================================================================
function InitTrig_Lockon takes nothing returns nothing
    set gg_trg_Lockon = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lockon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Lockon, Condition( function Trig_Lockon_Conditions ) )
    call TriggerAddAction( gg_trg_Lockon, function Trig_Lockon_Actions )
endfunction

nothing happens,all the IDS are correct. no errors when i save.but ingame nothing happens?
 
I'm quite sure that it's because the TriggerSleepAction. GetSpellTargetAbility will "lose" value after the 'wait', as it happens in GUI.

Solution is to use timers o/
And watch out for BJ calls: you have UnitHasBuffBJ(), which you can change by GetUnitAbilityLevel( 'B000', GetSpellTargetUnit() ) > 0
And your condition function can be much improved:

JASS:
function Trig_Lockon_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

EDIT: Ah the timer stuff xD
Before the Trig_Lockon_Actions, create a function that has all the actions AFTER the wait. Then create a timer at Trig_Lockon_Actions and start it instead of calling TriggerSleepAction:
call TimerStart( TimerVar, 3.00, false, function TimerFunction )
Don't forget to attach GetSpellTargetUnit() to the timer with AttachObject().
This will make TimerFunction to be executed after 3 seconds.
 
Status
Not open for further replies.
Top