Trigger not working completly

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
This trigger works but the right level is never correct.
JASS:
scope TitanBlood initializer TBInit

    globals
        private constant integer TBId   = 'A014'
        private constant integer AbilId = 'D014'
        private constant integer BookId = 'DA14'
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetUnitAbilityLevel(GetTriggerUnit(), TBId) > 0
    endfunction
    
    struct Blood extends array
    //! runtextmacro AIDS()
        unit Titan
        integer lvl
        boolean reset
        
        method AIDS_OnDestoy takes nothing returns nothing
            set this.lvl = 1
        endmethod
    endstruct
    
    private function Reset takes nothing returns nothing
        local Blood b = GetTimerData(GetExpiredTimer())
        if GetDamageCount(b.Titan) > 0. then
            set b.lvl = GetUnitAbilityLevel(b.Titan, TBId)
            call SetUnitAbilityLevel(b.Titan, AbilId, b.lvl)
        endif
    endfunction
    
    private function Actions takes nothing returns nothing
        local Blood b = Blood[GetTriggerUnit()]
        local timer ti = GetDTimer()
        set b.Titan = GetTriggerUnit()
        if GetUnitAbilityLevel(b.Titan, TBId) == 0 then
            call BJDebugMsg("Abil")
            call UnitAddAbility(b.Titan, BookId)
        endif
        if b.lvl < GetUnitAbilityLevel(b.Titan,TBId) + 15 then 
            set b.lvl = b.lvl + 1
            call BJDebugMsg(I2S(b.lvl))
            call SetUnitAbilityLevel(b.Titan, AbilId, b.lvl)
        endif
        call CountUnitDamage(b.Titan)
        call ResetDamageCount(b.Titan)
        call SetTimerData(ti, b)
        call TimerStart(ti, 6., true, function Reset)
    endfunction
    
    private function TBInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterDamageEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function Actions)
        call SetPlayerAbilityAvailable(Player(1), 'DA14', false)
    endfunction

endscope


after the unit has taken a few damage the lvl never increase its always at 1.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top