• 🏆 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] I don't know why it doesn't works, help :(

Status
Not open for further replies.
Level 2
Joined
Jul 13, 2012
Messages
7
Howdy, I'm creaing a "Drain" spell. It's based on Drain Life. What differs is that for the duration of it both the caster and the target are paused, with the caster being invulnerable. After the spell is done, the caster gains "Well Fed" buff which increases attack speed for a few seconds.
To do this, I used as base ability Drain Life, as said before. The ability itself won't give the targeted unit no buff for some reason, so I made a dummy ability based on bloodlust to give the target a "drain" buff, so the triggers knows when the abillity end when the buff wears off.
For Well Fed I used another abillity also based on bloodlust.
-The problem is, the trigger doesn't fire, it doesn't pause the units or anything.

JASS:
function Trig_Drain_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Drain_Actions takes nothing returns nothing
    local unit affected
    local unit bloodhunter
    local unit dummy
    set affected = GetSpellTargetUnit()
    set bloodhunter = GetTriggerUnit()
    call PauseUnitBJ( true , affected )
    call PauseUnitBJ( true , bloodhunter )
    call SetUnitInvulnerable( bloodhunter , true )
    set udg_DeletingLeaks = GetUnitLoc(affected)
    call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(affected), udg_DeletingLeaks, bj_UNIT_FACING )
    set dummy = GetLastCreatedUnit()
    call RemoveLocation(udg_DeletingLeaks)
    call UnitAddAbilityBJ( 'A001', dummy )
    call IssueTargetOrderBJ( dummy, "bloodlust", affected )
    call UnitRemoveAbilityBJ( 'A001', dummy )
    call KillUnit( dummy )
    loop
        exitwhen ( UnitHasBuffBJ(affected, 'B005') == false )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1))
    endloop
    call SetUnitInvulnerable(bloodhunter,false)
    call PauseUnitBJ(false,affected)
    call PauseUnitBJ(false,bloodhunter)
    set udg_DeletingLeaks = GetUnitLoc(bloodhunter)
    call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(bloodhunter), udg_DeletingLeaks, bj_UNIT_FACING )
    set dummy = GetLastCreatedUnit()
    call RemoveLocation(udg_DeletingLeaks)
    call UnitAddAbilityBJ( 'A009', dummy )
    call IssueTargetOrderBJ( dummy, "bloodlust", bloodhunter )
    call UnitRemoveAbilityBJ( 'A001', dummy )
    call KillUnit( dummy )
    set dummy = null
    set affected = null
    set bloodhunter = null
endfunction

//===========================================================================
function InitTrig_Drain takes nothing returns nothing
    set gg_trg_Drain = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Drain, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Drain, Condition( function Trig_Drain_Conditions ) )
    call TriggerAddAction( gg_trg_Drain, function Trig_Drain_Actions )
endfunction
 
Level 2
Joined
Jul 13, 2012
Messages
7
:vw_death: by the way guys, just noticed pausing both units would intrerupt the spell, so I changed it to pausing only the target, which bugs the buff-checking, as I can simlpy move and break the spell while the target should still have the buff. But it's still not triggering, it's not pausing the target and it's not creating any dummy to cast an ability on it
 
Level 6
Joined
Apr 16, 2011
Messages
158
1) Try to get rid of these BJ's and turn them into native.
2) If you use the skill 'life drain' should not pause the caster
3 )you need a timer to say by how much time your code must wait to remove the pause the unit.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If both units are paused, I would trigger the life reduction/gain, and trigger the lightning creation, and pausing units, and making invulnerable, and then cast the bloodlust on the caster. Seems easier. You could even create a Floating Text over the units displaying the time remaining for the lifesteal to end.

I could do it for you if you want... but I don't really know how to work with timers, I would do it with Unit Group, Hashtable and a real being reduced by 0.03 as a timer.
 
Status
Not open for further replies.
Top