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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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