• 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.

please help a noob

Status
Not open for further replies.
Level 10
Joined
Jul 2, 2004
Messages
690
ok i cant seem to get this trigger to work
Code:
function HSC takes nothing returns boolean
    return GetAttacker() == 'Huth'
endfunction

function HSA takes nothing returns nothing
    if ( udg_I < 10 ) then
        set udg_I = (udg_I + 1)
        else
        call AddSpecialEffectLocBJ( GetUnitLoc(GetAttackedUnitBJ()), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
        call AddSpecialEffectLocBJ( GetUnitLoc(GetAttackedUnitBJ()), "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl" )
        call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, GetAttacker(), true)) * 0.08 ), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
        set udg_I = 0
    endif
endfunction

function HSE takes nothing returns nothing
    local trigger t
    set udg_I = 0
    set t= CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (t, EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(t, Condition(function HSC))
    call TriggerAddAction(t, function HSA)
endfunction

basically, on every tenth attack the hero makes, he would deal bonus damage. but i cant seem to get it to work! :oops:
 
Level 8
Joined
Nov 27, 2004
Messages
251
JASS:
function Trig_HeroAttackCounter_Conditions takes nothing returns boolean
    return  GetUnitTypeId( GetAttacker() ) == 'Huth'
endfunction

function Trig_HeroAttackCounter_Actions takes nothing returns nothing
    set udg_HeroattackCounter = udg_HeroattackCounter + 1
    
    if udg_HeroattackCounter == 10 then
        set udg_HeroattackCounter = 0
    endif
    
endfunction // this is a trigger which counts the heros attacks

//==== Init Trigger HeroAttackCounter ====
function InitTrig_HeroAttackCounter takes nothing returns nothing
    set gg_trg_HeroAttackCounter = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (gg_trg_HeroAttackCounter, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_HeroAttackCounter, Condition(function Trig_HeroAttackCounter_Conditions))
    call TriggerAddAction(gg_trg_HeroAttackCounter, function Trig_HeroAttackCounter_Actions)
endfunction





function HSC takes nothing returns boolean
    return GetUnitTypeId( GetAttacker() ) == 'Huth' and udg_HeroattackCounter == 10
endfunction

function HSA takes nothing returns nothing
    local real x = GetUnitX ( GetTriggerUnit ( ) )
    local real y = GetUnitY ( GetTriggerUnit ( ) )

    call DestroyEffect ( AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" , x , y ) )
    call DestroyEffect ( AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl" , x , y ) )
    call UnitDamageTarget ( GetAttacker ( ) , GetTriggerUnit ( ) , GetHeroStr ( GetAttacker ( ) , false ) * 0.08 , true , false , ATTACK_TYPE_HERO , DAMAGE_TYPE_NORMAL , WEAPON_TYPE_WHOKNOWS )
        
endfunction

function HSE takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (t, EVENT_PLAYER_UNIT_ATTACKED) // EVENT_UNIT_DAMAGED wont work,that is a unitevent while this function takes a playerunitevent,there is some difference.
                                                                       // actually there is a way to make the unit takes damage generic . . .
    call TriggerAddCondition(t, Condition(function HSC))
    call TriggerAddAction(t, function HSA)
    set t = null
endfunction

your previous trigger leaked so much. this will be okay.


EDIT :

@Daelin : as i said

TriggerRegisterAnyUnitEventBJ takes a playerunitevent as an argument,while unit takes damage is a unitevent , so it wont work with it.
 
Level 10
Joined
Jul 2, 2004
Messages
690
thanks guys. ill try and improve :oops:

PS: if i use EVENT_PLAYER_UNIT_ATTACKED, would it be like the "a unit is attacked" trigger in GUI? because then it can be abused.
 
Level 10
Joined
Jul 2, 2004
Messages
690
but wouldnt that trigger be abused with the delay when the unit STARTS to attack the enemy and when the damage is atually APPLIED?
 
Status
Not open for further replies.
Top