IsUnitAlly() filter malfunctioning

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Solved!


JASS:
library Experience requires Shared

globals
    private constant integer ForestMeleeCreep1 = 'e003'
    private constant integer ForestRangeCreep1 = 'e004'
    private constant integer ForestMeleeCreep2 = 'e000'
    private constant integer ForestRangeCreep2 = 'e002'
    private constant integer ForestTower1 = 'etrp'
    private constant integer ForestTower2 = 'e011'
    private constant integer ForestTower3 = 'e00M'
    private constant integer AncientOfWar = 'e00N'
    private constant integer GlaiveThrower = 'e00O'
    
    private constant integer DoomMeleeCreep1 = 'u002'
    private constant integer DoomRangeCreep1 = 'u003'
    private constant integer DoomMeleeCreep2 = 'u000'
    private constant integer DoomRangeCreep2 = 'u001'
    private constant integer DoomTower1 = 'uzg1'
    private constant integer DoomTower2 = 'u00D'
    private constant integer DoomTower3 = 'u00O'
    private constant integer Crypt = 'u00P'
    private constant integer MeatWagon = 'u00Q'
    
    //Experience rate setup
    private constant real MeleeCreep1BaseExp = 25.
    private constant real RangeCreep1BaseExp = 40.
    private constant real MeleeCreep2BaseExp = 40.
    private constant real RangeCreep2BaseExp = 55.
    private constant real Tower1BaseExp = 125.
    private constant real Tower2BaseExp = 200.
    private constant real Tower3BaseExp = 300.
    private constant real CryptAncientBaseExp = 175.
    private constant real CatapultBaseExp = 500.
    
    private constant real ExpAoE = 750.
    private constant real KillBlowExpRate = 1.2
    private constant real DenyExpRate = 0.25
    
    //Can be changed with -em and similar for increased exp gain.
    public real Rate = 1.
endglobals

public function Gain takes unit k, unit d returns nothing
    local group UG = CreateGroup()
    local unit FLoop
    local real NettoExpGain
    
    if GetUnitTypeId(d) == ForestMeleeCreep1 or GetUnitTypeId(d) == DoomMeleeCreep1 then
        set NettoExpGain = MeleeCreep1BaseExp
    elseif GetUnitTypeId(d) == ForestRangeCreep1 or GetUnitTypeId(d) == DoomRangeCreep1 then
        set NettoExpGain = RangeCreep1BaseExp
    elseif GetUnitTypeId(d) == ForestMeleeCreep2 or GetUnitTypeId(d) == DoomMeleeCreep2 then
        set NettoExpGain = MeleeCreep2BaseExp
    elseif GetUnitTypeId(d) == ForestRangeCreep2 or GetUnitTypeId(d) == DoomRangeCreep2 then
        set NettoExpGain = RangeCreep2BaseExp
    elseif GetUnitTypeId(d) == ForestTower1 or GetUnitTypeId(d) == DoomTower1 then
        set NettoExpGain = Tower1BaseExp
    elseif GetUnitTypeId(d) == ForestTower2 or GetUnitTypeId(d) == DoomTower2 then
        set NettoExpGain = Tower2BaseExp
    elseif GetUnitTypeId(d) == ForestTower3 or GetUnitTypeId(d) == DoomTower3 then
        set NettoExpGain = Tower3BaseExp
    elseif GetUnitTypeId(d) == AncientOfWar or GetUnitTypeId(d) == Crypt then
        set NettoExpGain = CryptAncientBaseExp
    elseif GetUnitTypeId(d) == GlaiveThrower or GetUnitTypeId(d) == MeatWagon then
        set NettoExpGain = CatapultBaseExp
    endif
        
    
    
    call GroupEnumUnitsInRange(UG, GetUnitX(d), GetUnitY(d), ExpAoE, Condition(function True))
    loop
        set FLoop = FirstOfGroup(UG)
        exitwhen FLoop == null
        if IsUnitEnemy(FLoop, GetOwningPlayer(d)) == true and GetWidgetLife(FLoop) > .405 and IsUnitType(FLoop, UNIT_TYPE_HERO) == true then
            if IsUnitAlly(k, GetOwningPlayer(d)) == true then
                call AddHeroXP(FLoop, R2I(NettoExpGain * DenyExpRate * Rate + 0.5), true)
                call BJDebugMsg("Test")
            else
                if FLoop == k then
                    call AddHeroXP(FLoop, R2I(NettoExpGain * KillBlowExpRate * Rate + 0.5), true)
                else
                    call AddHeroXP(FLoop, R2I(NettoExpGain * Rate + 0.5), true)
                endif
            endif
        endif
        call GroupRemoveUnit(UG, FLoop)
    endloop
    
    call DestroyGroup(UG)
    
    set UG = null
endfunction
endlibrary

The main purpose is to work as a system that manipulates experience gained based on some factors. Regular exp gain and the killing blow bonus works just fine, though the denying part does not trigger.

This is the part that doesn't work as planned:

JASS:
            if IsUnitAlly(k, GetOwningPlayer(d)) == true then
                call AddHeroXP(FLoop, R2I(NettoExpGain * DenyExpRate * Rate + 0.5), true)
                call BJDebugMsg("Test")
            else
                if FLoop == k then
                    call AddHeroXP(FLoop, R2I(NettoExpGain * KillBlowExpRate * Rate + 0.5), true)
                else
                    call AddHeroXP(FLoop, R2I(NettoExpGain * Rate + 0.5), true)
                endif
            endif


Even if the killing unit is an ally of the dying unit the then actions does not fire.

Edit: Solved, it was working all the time though only noticable when an enemy hero was withing exp range.
 
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