• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Trigger on Damage Script not working

Status
Not open for further replies.
Level 4
Joined
Jul 26, 2017
Messages
66
Hi, Please tell me why this trigger is not working?
JASS:
function Slammed takes nothing returns boolean
    if ( not ( GetEventDamage() > 0.00 ) ) then
        return false
    endif
    if ( not ( GetUnitAbilityLevelSwapped('A00A', GetEventDamageSource()) >= 1 ) ) then
        return false
    endif
    if ( not ( BlzGetUnitAbilityCooldownRemaining(GetEventDamageSource(), 'A00A') > 0.00 ) ) then
        return false
    endif
    if ( not (BlzGetEventAttackType() != ATTACK_TYPE_NORMAL ) ) then
        return false
    endif
    if ( not ( GetRandomInt (1, 5) == ( 1 ) ) ) then
        return false
    endif
    return true
endfunction

function RageOn takes nothing returns nothing
    local unit w = GetEventDamageSource()
    local texttag rb
    call BlzEndUnitAbilityCooldown( w, 'A00A' )
    set rb = CreateTextTagUnitBJ( "<Raging Blow!>", w, 0, 10.00, 0.00, 100.00, 0.00, 0 )
    call ShowTextTagForceBJ( false, rb, GetPlayersAll() )
    set udg_tempForce = GetForceOfPlayer(GetOwningPlayer(w))
    call ShowTextTagForceBJ( true, rb, udg_tempForce )
    call DestroyForce(udg_tempForce)
    call SetTextTagVelocityBJ( rb, 100.00, 90 )
    call SetTextTagPermanentBJ( rb, false )
    call SetTextTagFadepointBJ( rb, 2.00 )
    call SetTextTagLifespanBJ( rb, 3.00 )
endfunction


//===========================================================================
function InitTrig_Warr_Attack takes nothing returns nothing
    local trigger Slam= CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(Slam, EVENT_PLAYER_UNIT_DAMAGING)
    call TriggerAddCondition( Slam, Condition( function Slammed ) )
    call TriggerAddAction( Slam, function RageOn )
    set Slam = null
endfunction

The Ability A00A should have it's cooldown reset on a 20% chance on each normal attack, but it never activates even if i remove the chance condition.
I just started learning Jass and GUI conversion is how I'm trying to do it.
I'm on patch 1.31 if that makes a difference.

Thank you.
 
The 'ATTACK_TYPE_NORMAL' actually refers to the damage type the unit deals, like Normal, Piercing, Siege.

What you are looking for is check damage type with DAMAGE_TYPE_NORMAL, which refers to physical damage.

I was trying to separate spell attacks


Also, are you calling: InitTrig_Warr_Attack()
What should I put there or change? that's the name of the trigger in the Trigger Editor, I won't be able to save the map if I change it,
 
Ah, nvm, the InitTrig is called at map initialization. If the conditions aren't the issue and it's being called then idk, the last thing that comes to mind is this: set Slam = null

But I feel like that shouldn't cause any problems.
 
I was trying to separate spell attacks

What I'm meaning to say: with function BlzGetEventAttackType you can detect which damage type autoattacks does. So if you test with a unit that does Hero damage, it will always return false.

What you want is BlzGetEventDamageType. It will distinguish auto attacks from spell damage.


Also, your RageOn function leaks handles. You should null 'w' and 'rb' at the end of the function.
 
I found out the reason why tye trigger didn't work: I saved it as a custom script in the trigger editor, so it doesn't run. Thanks for helping
 
Status
Not open for further replies.
Back
Top