[Spell] How I can make this trigger not lagg

Status
Not open for further replies.
Level 2
Joined
Feb 4, 2014
Messages
8
JASS:
function Trig_Player_HeroDryLTB_Conditions takes nothing returns boolean
    local unit HeroKiller = GetKillingUnitBJ()
    local unit HeroKilled = GetDyingUnit()
    local player PlayerOwnHeroKilled = GetOwningPlayer(HeroKilled)
    local integer N = 1

    if (GetUnitTypeId(HeroKilled) == 'U000') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U001') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U002') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U003') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U004') then
        set N = 0
    endif

    if (IsUnitType(HeroKilled, UNIT_TYPE_HERO) == false) then
        set N = 0
    endif

    if (IsUnitEnemy(HeroKiller, PlayerOwnHeroKilled) == false) then
        set N = 0
    endif

    set HeroKiller = null
    set HeroKilled = null
    set PlayerOwnHeroKilled = null

    if ( N == 1) then
        return true
    else
        return false
    endif
endfunction

function Query_Archangels_Staff_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITArchangels_Staff[N])) then
            set AS_ID_NEW = N
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Manamune_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITManamune[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Mejais_Soulstealer_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITMejais_Soulstealer[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Rod_of_Ages_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITRod_of_Ages[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Seekers_Armguard_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 16
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSeekers_Armguard[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Sword_of_the_Occult_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSword_of_the_Occult[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_The_Bloodthirster_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 31
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITThe_Bloodthirster[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Player_Own_Player_and_Hero001 takes unit HeroA, integer PlayerNumberN returns boolean
    local integer N =1
    local integer AAA1 = GetConvertedPlayerId(GetOwningPlayer(HeroA))

    if (IsUnitType(HeroA , UNIT_TYPE_HERO) == false ) then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U000') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U001') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U002') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U003') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U004') then
        set N = 0
    endif
    if ( not ( AAA1 == PlayerNumberN) ) then
        set N = 0
    endif

    if ( N == 1 ) then
        return true
    else
        return false
    endif
endfunction

function HeroDryLTB_ClearNoUse takes nothing returns nothing
    local unit NextUnit = GetEnumUnit()
    local integer PlayerNumberN = udg_UnitGroup_IntegerSent

    if (Player_Own_Player_and_Hero001(NextUnit,PlayerNumberN) == false) then
         call GroupRemoveUnitSimple( NextUnit, udg_UnitGroup_SpellEffect02 )
    endif

    set NextUnit = null
endfunction

function Hero_Have_ManaRegenKA_Item takes unit HeroA returns integer
    local integer N = 0

    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I006') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I08V') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I08W') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I016') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I01A') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I01B') == true ) ) then
        set N = 1
    endif

    return N
endfunction

function HeroDryLTB_KillAssWork_Killer takes nothing returns nothing
    local unit HeroKiller = GetEnumUnit()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID (HeroKiller)
    local integer NMejais_SoulstealerKiller  = Query_Mejais_Soulstealer_ID (HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID (HeroKiller)
    local integer NSeekers_ArmguardKiller    = Query_Seekers_Armguard_ID (HeroKiller)
    local integer NSword_of_the_OccultKiller = Query_Sword_of_the_Occult_ID (HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID (HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NMejais_SoulstealerKiller > 0) then
        if (NMejais_SoulstealerKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITMejais_Soulstealer[NMejais_SoulstealerKiller]) )
            call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[IMinBJ(NMejais_SoulstealerKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif
    call DisplayTextToForce( GetPlayersAll(), R2S(4.000) )
  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSeekers_ArmguardKiller > 0) then
        if (NSeekers_ArmguardKiller < 16) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSeekers_Armguard[NSeekers_ArmguardKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSeekers_Armguard[IMinBJ(NSeekers_ArmguardKiller + 1,16)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSword_of_the_OccultKiller > 0) then
        if (NSword_of_the_OccultKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSword_of_the_Occult[NSword_of_the_OccultKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[IMinBJ(NSword_of_the_OccultKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    if (Hero_Have_ManaRegenKA_Item(HeroKiller)>0) then
        set HeroCurrentMana = GetUnitStateSwap(UNIT_STATE_MANA,HeroKiller) + GetUnitStateSwap(UNIT_STATE_MAX_MANA, HeroKiller)*0.15
        call SetUnitManaBJ( HeroKiller, HeroCurrentMana )
    endif

    set HeroKiller = null
endfunction

function HeroDryLTB_KillAssWork_Asster takes nothing returns nothing
    local unit HeroKiller = GetEnumUnit()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID (HeroKiller)
    local integer NMejais_SoulstealerKiller  = Query_Mejais_Soulstealer_ID (HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID (HeroKiller)
    local integer NSword_of_the_OccultKiller = Query_Sword_of_the_Occult_ID (HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID (HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NMejais_SoulstealerKiller > 0) then
        if (NMejais_SoulstealerKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITMejais_Soulstealer[NMejais_SoulstealerKiller]) )
            call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[IMinBJ(NMejais_SoulstealerKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSword_of_the_OccultKiller > 0) then
        if (NSword_of_the_OccultKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSword_of_the_Occult[NSword_of_the_OccultKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[IMinBJ(NSword_of_the_OccultKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    set HeroKiller = null
endfunction

function Trig_Player_HeroDryLTB_Actions takes nothing returns nothing
    local unit HeroKiller = GetKillingUnitBJ()
    local unit HeroKilled = GetDyingUnit()
    local player PlayerOwnHeroKiller = GetOwningPlayer(HeroKiller)
    local player PlayerOwnHeroKilled = GetOwningPlayer(HeroKilled)
    local integer OKN = GetConvertedPlayerId(PlayerOwnHeroKiller)
    local integer ODN = GetConvertedPlayerId(PlayerOwnHeroKilled)
    local integer NumberofAss = 0
    local integer I = 0

    local integer NMejais_SoulstealerKilled  = Query_Mejais_Soulstealer_ID (HeroKilled)
    local integer NSword_of_the_OccultKilled = Query_Sword_of_the_Occult_ID (HeroKilled)
    local integer NThe_BloodthirsterKilled   = Query_The_Bloodthirster_ID (HeroKilled)

    local real TaxK1  = udg_P_HeroS001_Kill[OKN] - udg_P_HeroS002_Die[OKN] + udg_P_HeroS003_Ass[OKN] / 5
    local real TaxK2  = TaxK1 - udg_P_HeroS005_DeniceHero[OKN] - udg_P_HeroS006_DeniceMinion[OKN] / 5
    local real TaxK3  = TaxK2 + udg_P_HeroS007_ChainKill[OKN] - udg_P_HeroS008_ChainDie[OKN]
    local real BTaxK1 = udg_P_HeroS001_Kill[ODN] - udg_P_HeroS002_Die[ODN] + udg_P_HeroS003_Ass[ODN] / 5
    local real BTaxK2 = BTaxK1 - udg_P_HeroS005_DeniceHero[ODN] - udg_P_HeroS006_DeniceMinion[ODN] / 5
    local real BTaxK3 = BTaxK2 + udg_P_HeroS007_ChainKill[ODN] - udg_P_HeroS008_ChainDie[ODN]
    local real FTaxK  = 300 + (BTaxK3-TaxK3) * 5
    local integer BountMoney = IMaxBJ(R2I(FTaxK),25)
    local integer AssMoney   = IMaxBJ(R2I(FTaxK),25)/3

    set udg_P_HeroS001_Kill[OKN]          = udg_P_HeroS001_Kill[OKN] + 1
    set udg_P_HeroS007_ChainKill[OKN]     = udg_P_HeroS007_ChainKill[OKN] + 1
    set udg_P_HeroS008_ChainDie[OKN]      = 0
    set udg_P_HeroS009_CooldownKill [OKN] = 60
    set udg_P_HeroS010_ComboKill[OKN]     = udg_P_HeroS010_ComboKill[OKN] + 1

    set udg_P_HeroS002_Die[ODN]       = udg_P_HeroS002_Die[ODN] + 1
    set udg_P_HeroS008_ChainDie[ODN]  = udg_P_HeroS008_ChainDie[ODN] + 1
    set udg_P_HeroS007_ChainKill[ODN] = 0

    call AdjustPlayerStateBJ( BountMoney, PlayerOwnHeroKiller, PLAYER_STATE_RESOURCE_GOLD )

    call GroupClear(udg_UnitGroup_SpellEffect02)

    set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
    set udg_UnitGroup_IntegerSent   = OKN
    call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
    call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Killer )
    call GroupClear(udg_UnitGroup_SpellEffect02)

    if (NMejais_SoulstealerKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITMejais_Soulstealer[NMejais_SoulstealerKilled]) )
        call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[(NMejais_SoulstealerKilled-1)/2+1], HeroKilled )
    endif
    if (NSword_of_the_OccultKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITSword_of_the_Occult[NSword_of_the_OccultKilled]) )
        call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[(NSword_of_the_OccultKilled-1)/2+1], HeroKilled )
    endif
    if (NThe_BloodthirsterKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITThe_Bloodthirster[NThe_BloodthirsterKilled]) )
        call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[(NThe_BloodthirsterKilled-1)/2+1], HeroKilled )
    endif

    if (GetOwningPlayer(HeroKilled) == Player(0)) then
        set udg_GPlayer01_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer01_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(1)) then
        set udg_GPlayer02_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer02_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(2)) then
        set udg_GPlayer03_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer03_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(3)) then
        set udg_GPlayer04_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer04_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(4)) then
        set udg_GPlayer05_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer05_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(5)) then
        set udg_GPlayer06_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer06_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(6)) then
        set udg_GPlayer07_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer07_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(7)) then
        set udg_GPlayer08_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer08_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(8)) then
        set udg_GPlayer09_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer09_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(9)) then
        set udg_GPlayer10_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer10_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(10)) then
        set udg_GPlayer11_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer11_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(11)) then
        set udg_GPlayer12_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer12_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    set HeroKiller = null
    set HeroKilled = null
    set PlayerOwnHeroKiller = null
    set PlayerOwnHeroKilled = null
endfunction

//===========================================================================
function InitTrig_Player_HeroDryLTB takes nothing returns nothing
    set gg_trg_Player_HeroDryLTB = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_HeroDryLTB, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Player_HeroDryLTB, Condition( function Trig_Player_HeroDryLTB_Conditions ) )
    call TriggerAddAction( gg_trg_Player_HeroDryLTB, function Trig_Player_HeroDryLTB_Actions )
endfunction

and this too

JASS:
function Trig_Player_NonHeroDryLTB_Conditions takes nothing returns boolean
    local unit HeroKiller    = GetKillingUnitBJ()
    local unit UnitDryforCon = GetDyingUnit()
    local player PlayerOwnKiller = GetOwningPlayer(HeroKiller)
    local integer N = 1

    if (IsUnitType(UnitDryforCon, UNIT_TYPE_HERO) == true) then
        set N = 0
    endif

    if ( IsUnitEnemy(UnitDryforCon, PlayerOwnKiller) == false ) then
        set N = 0
    endif

    set HeroKiller      = null
    set UnitDryforCon   = null
    set PlayerOwnKiller = null

    if ( N == 1) then
        return true
    else
        return false
    endif
endfunction

function Query_Archangels_Staff_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITArchangels_Staff[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Manamune_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITManamune[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Rod_of_Ages_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITRod_of_Ages[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Seekers_Armguard_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 16
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSeekers_Armguard[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_The_Bloodthirster_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 31
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITThe_Bloodthirster[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Trig_Player_NonHeroDryLTB_Actions takes nothing returns nothing
    local unit HeroKiller = GetKillingUnitBJ()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID_001(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID_001(HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID_001(HeroKiller)
    local integer NSeekers_ArmguardKiller    = Query_Seekers_Armguard_ID_001(HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID_001(HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 1,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 1,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 1,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSeekers_ArmguardKiller > 0) then
        if (NSeekers_ArmguardKiller < 16) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSeekers_Armguard[NSeekers_ArmguardKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSeekers_Armguard[IMinBJ(NSeekers_ArmguardKiller + 1,16)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    set HeroKiller = null
endfunction

//===========================================================================
function InitTrig_Player_NonHeroDryLTB takes nothing returns nothing
    set gg_trg_Player_NonHeroDryLTB = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_NonHeroDryLTB, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Player_NonHeroDryLTB, Condition( function Trig_Player_NonHeroDryLTB_Conditions ) )
    call TriggerAddAction( gg_trg_Player_NonHeroDryLTB, function Trig_Player_NonHeroDryLTB_Actions )
endfunction

and sample map

Edit: i post in wrong place again :vw_death:

JASS:
function Trig_Player_HeroDryLTB_Conditions takes nothing returns boolean
    local unit HeroKiller = GetKillingUnitBJ()
    local unit HeroKilled = GetDyingUnit()
    local player PlayerOwnHeroKilled = GetOwningPlayer(HeroKilled)
    local integer N = 1

    if (GetUnitTypeId(HeroKilled) == 'U000') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U001') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U002') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U003') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroKilled) == 'U004') then
        set N = 0
    endif

    if (IsUnitType(HeroKilled, UNIT_TYPE_HERO) == false) then
        set N = 0
    endif

    if (IsUnitEnemy(HeroKiller, PlayerOwnHeroKilled) == false) then
        set N = 0
    endif

    set HeroKiller = null
    set HeroKilled = null
    set PlayerOwnHeroKilled = null

    if ( N == 1) then
        return true
    else
        return false
    endif
endfunction

function Query_Archangels_Staff_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITArchangels_Staff[N])) then
            set AS_ID_NEW = N
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Manamune_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITManamune[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Mejais_Soulstealer_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITMejais_Soulstealer[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Rod_of_Ages_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITRod_of_Ages[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Seekers_Armguard_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 16
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSeekers_Armguard[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Sword_of_the_Occult_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSword_of_the_Occult[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_The_Bloodthirster_ID takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 31
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITThe_Bloodthirster[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Player_Own_Player_and_Hero001 takes unit HeroA, integer PlayerNumberN returns boolean
    local integer N =1
    local integer AAA1 = GetConvertedPlayerId(GetOwningPlayer(HeroA))

    if (IsUnitType(HeroA , UNIT_TYPE_HERO) == false ) then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U000') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U001') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U002') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U003') then
        set N = 0
    endif
    if (GetUnitTypeId(HeroA) == 'U004') then
        set N = 0
    endif
    if ( not ( AAA1 == PlayerNumberN) ) then
        set N = 0
    endif

    if ( N == 1 ) then
        return true
    else
        return false
    endif
endfunction

function HeroDryLTB_ClearNoUse takes nothing returns nothing
    local unit NextUnit = GetEnumUnit()
    local integer PlayerNumberN = udg_UnitGroup_IntegerSent

    if (Player_Own_Player_and_Hero001(NextUnit,PlayerNumberN) == false) then
         call GroupRemoveUnitSimple( NextUnit, udg_UnitGroup_SpellEffect02 )
    endif

    set NextUnit = null
endfunction

function Hero_Have_ManaRegenKA_Item takes unit HeroA returns integer
    local integer N = 0

    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I006') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I08V') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I08W') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I016') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I01A') == true ) ) then
        set N = 1
    endif
    if ( ( UnitHasItemOfTypeBJ(HeroA, 'I01B') == true ) ) then
        set N = 1
    endif

    return N
endfunction

function HeroDryLTB_KillAssWork_Killer takes nothing returns nothing
    local unit HeroKiller = GetEnumUnit()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID (HeroKiller)
    local integer NMejais_SoulstealerKiller  = Query_Mejais_Soulstealer_ID (HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID (HeroKiller)
    local integer NSeekers_ArmguardKiller    = Query_Seekers_Armguard_ID (HeroKiller)
    local integer NSword_of_the_OccultKiller = Query_Sword_of_the_Occult_ID (HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID (HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NMejais_SoulstealerKiller > 0) then
        if (NMejais_SoulstealerKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITMejais_Soulstealer[NMejais_SoulstealerKiller]) )
            call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[IMinBJ(NMejais_SoulstealerKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif
    call DisplayTextToForce( GetPlayersAll(), R2S(4.000) )
  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSeekers_ArmguardKiller > 0) then
        if (NSeekers_ArmguardKiller < 16) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSeekers_Armguard[NSeekers_ArmguardKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSeekers_Armguard[IMinBJ(NSeekers_ArmguardKiller + 1,16)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSword_of_the_OccultKiller > 0) then
        if (NSword_of_the_OccultKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSword_of_the_Occult[NSword_of_the_OccultKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[IMinBJ(NSword_of_the_OccultKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    if (Hero_Have_ManaRegenKA_Item(HeroKiller)>0) then
        set HeroCurrentMana = GetUnitStateSwap(UNIT_STATE_MANA,HeroKiller) + GetUnitStateSwap(UNIT_STATE_MAX_MANA, HeroKiller)*0.15
        call SetUnitManaBJ( HeroKiller, HeroCurrentMana )
    endif

    set HeroKiller = null
endfunction

function HeroDryLTB_KillAssWork_Asster takes nothing returns nothing
    local unit HeroKiller = GetEnumUnit()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID (HeroKiller)
    local integer NMejais_SoulstealerKiller  = Query_Mejais_Soulstealer_ID (HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID (HeroKiller)
    local integer NSword_of_the_OccultKiller = Query_Sword_of_the_Occult_ID (HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID (HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 2,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NMejais_SoulstealerKiller > 0) then
        if (NMejais_SoulstealerKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITMejais_Soulstealer[NMejais_SoulstealerKiller]) )
            call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[IMinBJ(NMejais_SoulstealerKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSword_of_the_OccultKiller > 0) then
        if (NSword_of_the_OccultKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSword_of_the_Occult[NSword_of_the_OccultKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[IMinBJ(NSword_of_the_OccultKiller + 2,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    set HeroKiller = null
endfunction

function Trig_Player_HeroDryLTB_Actions takes nothing returns nothing
    local unit HeroKiller = GetKillingUnitBJ()
    local unit HeroKilled = GetDyingUnit()
    local player PlayerOwnHeroKiller = GetOwningPlayer(HeroKiller)
    local player PlayerOwnHeroKilled = GetOwningPlayer(HeroKilled)
    local integer OKN = GetConvertedPlayerId(PlayerOwnHeroKiller)
    local integer ODN = GetConvertedPlayerId(PlayerOwnHeroKilled)
    local integer NumberofAss = 0
    local integer I = 0

    local integer NMejais_SoulstealerKilled  = Query_Mejais_Soulstealer_ID (HeroKilled)
    local integer NSword_of_the_OccultKilled = Query_Sword_of_the_Occult_ID (HeroKilled)
    local integer NThe_BloodthirsterKilled   = Query_The_Bloodthirster_ID (HeroKilled)

    local real TaxK1  = udg_P_HeroS001_Kill[OKN] - udg_P_HeroS002_Die[OKN] + udg_P_HeroS003_Ass[OKN] / 5
    local real TaxK2  = TaxK1 - udg_P_HeroS005_DeniceHero[OKN] - udg_P_HeroS006_DeniceMinion[OKN] / 5
    local real TaxK3  = TaxK2 + udg_P_HeroS007_ChainKill[OKN] - udg_P_HeroS008_ChainDie[OKN]
    local real BTaxK1 = udg_P_HeroS001_Kill[ODN] - udg_P_HeroS002_Die[ODN] + udg_P_HeroS003_Ass[ODN] / 5
    local real BTaxK2 = BTaxK1 - udg_P_HeroS005_DeniceHero[ODN] - udg_P_HeroS006_DeniceMinion[ODN] / 5
    local real BTaxK3 = BTaxK2 + udg_P_HeroS007_ChainKill[ODN] - udg_P_HeroS008_ChainDie[ODN]
    local real FTaxK  = 300 + (BTaxK3-TaxK3) * 5
    local integer BountMoney = IMaxBJ(R2I(FTaxK),25)
    local integer AssMoney   = IMaxBJ(R2I(FTaxK),25)/3

    set udg_P_HeroS001_Kill[OKN]          = udg_P_HeroS001_Kill[OKN] + 1
    set udg_P_HeroS007_ChainKill[OKN]     = udg_P_HeroS007_ChainKill[OKN] + 1
    set udg_P_HeroS008_ChainDie[OKN]      = 0
    set udg_P_HeroS009_CooldownKill [OKN] = 60
    set udg_P_HeroS010_ComboKill[OKN]     = udg_P_HeroS010_ComboKill[OKN] + 1

    set udg_P_HeroS002_Die[ODN]       = udg_P_HeroS002_Die[ODN] + 1
    set udg_P_HeroS008_ChainDie[ODN]  = udg_P_HeroS008_ChainDie[ODN] + 1
    set udg_P_HeroS007_ChainKill[ODN] = 0

    call AdjustPlayerStateBJ( BountMoney, PlayerOwnHeroKiller, PLAYER_STATE_RESOURCE_GOLD )

    call GroupClear(udg_UnitGroup_SpellEffect02)

    set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
    set udg_UnitGroup_IntegerSent   = OKN
    call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
    call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Killer )
    call GroupClear(udg_UnitGroup_SpellEffect02)

    if (NMejais_SoulstealerKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITMejais_Soulstealer[NMejais_SoulstealerKilled]) )
        call UnitAddItemByIdSwapped( udg_ITMejais_Soulstealer[(NMejais_SoulstealerKilled-1)/2+1], HeroKilled )
    endif
    if (NSword_of_the_OccultKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITSword_of_the_Occult[NSword_of_the_OccultKilled]) )
        call UnitAddItemByIdSwapped( udg_ITSword_of_the_Occult[(NSword_of_the_OccultKilled-1)/2+1], HeroKilled )
    endif
    if (NThe_BloodthirsterKilled > 0) then
        call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKilled, udg_ITThe_Bloodthirster[NThe_BloodthirsterKilled]) )
        call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[(NThe_BloodthirsterKilled-1)/2+1], HeroKilled )
    endif

    if (GetOwningPlayer(HeroKilled) == Player(0)) then
        set udg_GPlayer01_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer01_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(1)) then
        set udg_GPlayer02_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer02_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(2)) then
        set udg_GPlayer03_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer03_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(3)) then
        set udg_GPlayer04_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer04_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(4)) then
        set udg_GPlayer05_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer05_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(5)) then
        set udg_GPlayer06_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer06_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(6)) then
        set udg_GPlayer07_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer07_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(7)) then
        set udg_GPlayer08_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer08_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(8)) then
        set udg_GPlayer09_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer09_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(9)) then
        set udg_GPlayer10_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer10_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(10)) then
        set udg_GPlayer11_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer11_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    if (GetOwningPlayer(HeroKilled) == Player(11)) then
        set udg_GPlayer12_HeroBeHit[OKN] = 0
        loop
            exitwhen I > udg_MaxPlayerJoinGame
            if (udg_GPlayer12_HeroBeHit[I] > 0) then
                set udg_P_HeroS003_Ass[I] = udg_P_HeroS003_Ass[I] + 1
                call AdjustPlayerStateBJ( AssMoney, Player(I), PLAYER_STATE_RESOURCE_GOLD )

                call GroupClear(udg_UnitGroup_SpellEffect02)

                set udg_UnitGroup_SpellEffect02 = GetUnitsInRectAll(udg_AllMapRegon)
                set udg_UnitGroup_IntegerSent   = I
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_ClearNoUse )
                call ForGroupBJ(udg_UnitGroup_SpellEffect02, function HeroDryLTB_KillAssWork_Asster )
                call GroupClear(udg_UnitGroup_SpellEffect02)
            endif
            set I = I +1
        endloop
    endif

    set HeroKiller = null
    set HeroKilled = null
    set PlayerOwnHeroKiller = null
    set PlayerOwnHeroKilled = null
endfunction

//===========================================================================
function InitTrig_Player_HeroDryLTB takes nothing returns nothing
    set gg_trg_Player_HeroDryLTB = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_HeroDryLTB, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Player_HeroDryLTB, Condition( function Trig_Player_HeroDryLTB_Conditions ) )
    call TriggerAddAction( gg_trg_Player_HeroDryLTB, function Trig_Player_HeroDryLTB_Actions )
endfunction

and this:

JASS:
function Trig_Player_NonHeroDryLTB_Conditions takes nothing returns boolean
    local unit HeroKiller    = GetKillingUnitBJ()
    local unit UnitDryforCon = GetDyingUnit()
    local player PlayerOwnKiller = GetOwningPlayer(HeroKiller)
    local integer N = 1

    if (IsUnitType(UnitDryforCon, UNIT_TYPE_HERO) == true) then
        set N = 0
    endif

    if ( IsUnitEnemy(UnitDryforCon, PlayerOwnKiller) == false ) then
        set N = 0
    endif

    set HeroKiller      = null
    set UnitDryforCon   = null
    set PlayerOwnKiller = null

    if ( N == 1) then
        return true
    else
        return false
    endif
endfunction

function Query_Archangels_Staff_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITArchangels_Staff[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Manamune_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 51
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITManamune[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Rod_of_Ages_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 21
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITRod_of_Ages[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_Seekers_Armguard_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 16
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITSeekers_Armguard[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Query_The_Bloodthirster_ID_001 takes unit HeroA returns integer
    local integer N    = 1
    local integer NMax = 31
    local integer AS_ID_NEW = 0

    loop
        exitwhen N > NMax
        if (UnitHasItemOfTypeBJ(HeroA, udg_ITThe_Bloodthirster[N])) then
            set AS_ID_NEW = IMaxBJ(N,AS_ID_NEW)
        endif
        set N = N +1
    endloop

    return AS_ID_NEW
endfunction

function Trig_Player_NonHeroDryLTB_Actions takes nothing returns nothing
    local unit HeroKiller = GetKillingUnitBJ()
    local integer NArchangels_StaffKiller    = Query_Archangels_Staff_ID_001(HeroKiller)
    local integer NManamuneKiller            = Query_Manamune_ID_001(HeroKiller)
    local integer NRod_of_AgesKiller         = Query_Rod_of_Ages_ID_001(HeroKiller)
    local integer NSeekers_ArmguardKiller    = Query_Seekers_Armguard_ID_001(HeroKiller)
    local integer NThe_BloodthirsterKiller   = Query_The_Bloodthirster_ID_001(HeroKiller)
    local real HeroCurrentMana = 0.000
    local integer N = 0

  if (N<4) then
    if (NArchangels_StaffKiller > 0) then
        if (NArchangels_StaffKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITArchangels_Staff[NArchangels_StaffKiller]) )
            call UnitAddItemByIdSwapped( udg_ITArchangels_Staff[IMinBJ(NArchangels_StaffKiller + 1,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NManamuneKiller > 0) then
        if (NManamuneKiller < 51) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITManamune[NManamuneKiller]) )
            call UnitAddItemByIdSwapped( udg_ITManamune[IMinBJ(NManamuneKiller + 1,51)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NRod_of_AgesKiller > 0) then
        if (NRod_of_AgesKiller < 21) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITRod_of_Ages[NRod_of_AgesKiller]) )
            call UnitAddItemByIdSwapped( udg_ITRod_of_Ages[IMinBJ(NRod_of_AgesKiller + 1,21)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NSeekers_ArmguardKiller > 0) then
        if (NSeekers_ArmguardKiller < 16) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITSeekers_Armguard[NSeekers_ArmguardKiller]) )
            call UnitAddItemByIdSwapped( udg_ITSeekers_Armguard[IMinBJ(NSeekers_ArmguardKiller + 1,16)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

  if (N<4) then
    if (NThe_BloodthirsterKiller > 0) then
        if (NThe_BloodthirsterKiller < 31) then
            call RemoveItem( GetItemOfTypeFromUnitBJ(HeroKiller, udg_ITThe_Bloodthirster[NThe_BloodthirsterKiller]) )
            call UnitAddItemByIdSwapped( udg_ITThe_Bloodthirster[IMinBJ(NThe_BloodthirsterKiller + 1,31)], HeroKiller )
            set N = N + 1
        endif
    endif
  endif

    set HeroKiller = null
endfunction

//===========================================================================
function InitTrig_Player_NonHeroDryLTB takes nothing returns nothing
    set gg_trg_Player_NonHeroDryLTB = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Player_NonHeroDryLTB, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Player_NonHeroDryLTB, Condition( function Trig_Player_NonHeroDryLTB_Conditions ) )
    call TriggerAddAction( gg_trg_Player_NonHeroDryLTB, function Trig_Player_NonHeroDryLTB_Actions )
endfunction

i attach the map too
 
Last edited by a moderator:
Level 23
Joined
Feb 6, 2014
Messages
2,466
Here are tips:
-Use GetKillingUnit() and elseifs
-Make your own UnitHasItemOfType instead of using UnitHasItemOfTypeBJ
-Replace UnitAddItemByIdSwapped by UnitAddItemById
- Use ForGroup instead of ForGroupBJ since you are not using the wantDestroyGroup
-Use the OR if it has the same 'then' actions like this
JASS:
if (GetUnitTypeId(HeroKilled) == 'U000' or GetUnitTypeId(HeroKilled) == 'U001' or GetUnitTypeId(HeroKilled) == 'U002' or GetUnitTypeId(HeroKilled) == 'U003' or GetUnitTypeId(HeroKilled) == 'U004') then  //add the other conditions 
    set N = 0
endif
OR (for multiple lines for easy reading)
JASS:
if (GetUnitTypeId(HeroKilled) == 'U000') then  
    set N = 0
elseif (GetUnitTypeId(HeroKilled) == 'U001') then
    set N = 0
elseif (GetUnitTypeId(HeroKilled) == 'U002') then
    set N = 0
elseif (GetUnitTypeId(HeroKilled) == 'U003') then
    set N = 0
elseif (GetUnitTypeId(HeroKilled) == 'U004') then
    set N = 0
elseif (IsUnitType(HeroKilled, UNIT_TYPE_HERO) == false) then
    set N = 0
elseif (IsUnitEnemy(HeroKiller, PlayerOwnHeroKilled) == false) then
    set N = 0
endif
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
The main performance problem with the script that I see is the iterating through every unit in the entire map which is obviously going to be demanding. If it is true that it does leak (did not check through it all) then that would also cause performance to degrade over time.

There are also a number of other optimizations you could do. These will improve performance especially in performance critical sections (such as when run on every unit in the map). For example try merging HeroDryLTB_ClearNoUse and HeroDryLTB_KillAssWork_Asster functions so that you can filter the unit group in a single iteration of all elements instead of iterating all elements then a reduced number of elements again.

If the unit group contents is relatively stable consider caching it instead of rebuilding it each time. By doing this it saves on time filtering all units on the map.
 
Status
Not open for further replies.
Top