• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Yet,another jass error

Not open for further replies.
Level 4
Dec 14, 2007
function Trig_Lockon_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A002' ) ) then
        return false
    return true

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)
     call DisplayTimedTextToPlayer(GetOwningPlayer(GetSpellAbilityUnit()),GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit()),5.00,"Lock Lost")

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 )

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:

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

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.
Not open for further replies.