• 🏆 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] 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.
 
Level 9
Joined
Mar 26, 2017
Messages
376
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.
 
Level 4
Joined
Jul 26, 2017
Messages
66
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,
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
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.
 
Level 9
Joined
Mar 26, 2017
Messages
376
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.
 
Level 4
Joined
Jul 26, 2017
Messages
66
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.
Top