Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] How to make Combat abilities?

Discussion in 'Triggers & Scripts' started by wikidme, Nov 1, 2004.

  1. wikidme

    wikidme

    Joined:
    Aug 4, 2004
    Messages:
    22
    Resources:
    0
    Resources:
    0
    ok well im trying to make this combat ability like critical strike but instead the bonus damage is determined from your current mana. now i can get everything working but its buggy.

    here is the spell (quite small)

    function Trig_ManaStrike_Conditions takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A00R', GetAttacker()) > 0 and GetRandomInt(1, 10)<=4 ) ) then
    return false
    endif
    return true
    endfunction


    function GetUnit2 takes trigger t returns unit
    return GetHandleHandle(t,"caster")
    endfunction



    function ManaStrike takes nothing returns nothing

    local trigger t=GetTriggeringTrigger()
    local unit caster=GetUnit2(t)
    if GetEventDamageSource()==caster then
    call FlushHandleLocals(t)
    call DestroyTrigger(t)
    call UnitDamageTargetBJ( caster, GetTriggerUnit(), 0.5*GetUnitStateSwap(UNIT_STATE_MANA, caster), ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_UPDATED, ( R2S(0.5*GetUnitStateSwap(UNIT_STATE_MANA, caster)) + " Mana damage!" ) )

    //call DestroyTrigger(t)
    endif
    set t=null
    set caster=null
    endfunction

    function Trig_ManaStrike_Actions takes nothing returns nothing
    local trigger t=CreateTrigger()

    call SetHandleHandle(t,"caster",GetAttacker())
    call TriggerRegisterUnitEvent(t,GetAttackedUnitBJ(),EVENT_UNIT_DAMAGED)
    call TriggerAddAction( t,function ManaStrike)
    set t=null

    endfunction

    //===========================================================================
    function InitTrig_ManaStrike takes nothing returns nothing
    set gg_trg_ManaStrike = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ManaStrike, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_ManaStrike, Condition( function Trig_ManaStrike_Conditions ) )
    call TriggerAddAction( gg_trg_ManaStrike, function Trig_ManaStrike_Actions )
    endfunction


    the problem im having is if, between the trigger triggering, i.e. when the unit is attacked, and detecting when the hit connects, the caster is told to do something else or the his misses for whatever reason (target blinks or has evasion), this trigger leak.

    the point im making is, how is it possible to detect the hit NOT connecting and so delete the created trigger?