Condition not working properly

trb92

Throwing science at the wall to see what sticks
Reaction score
142
I have this code, to detect when a unit enters the map.
JASS:

globals
group G = CreateGroup()
endglobals

function EnteranceFilter takes nothing returns boolean
    call BJDebugMsg("Unit entrance being tested")
    debug   if ((IsUnitInGroup(GetEnteringUnit(),G) == false) and (IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO) == true)) then
    debug       call BJDebugMsg("Returning true")
    debug   else
    debug       call BJDebugMsg("Returning false")
    debug   endif
    return ((IsUnitInGroup(GetEnteringUnit(),G) == false) and (IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO) == true))
endfunction
When a hero enters the map, created via call CreateUnit(arguments), it shows the "Returning false" message. If I comment out/delete the IsUnitType function, it returns true. How come that comparison doesn't return true even when the unit is a hero?

The weird thing is that this trigger worked before the patch, but ever since patching my warcraft it has started returning false. I don't get how that could break this, but that's when the issue started.
 

XxShadyxX

I abused the rep system.
Reaction score
81
Try reinstalling you game then see if it will work. If it does just wait for the patch to be fixed. I dont see anything wrong with your code..... try what i said and get back to me on it.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
Try reinstalling you game then see if it will work. If it does just wait for the patch to be fixed. I dont see anything wrong with your code..... try what i said and get back to me on it.

I can't reinstall warcraft. I have a few problems doing that: lost RoC CD, scratched to hell TFT CD, not sure where the TFT case is to find my CDkey(bet it's with my RoC CD, whereever that is).

Any other options? If not, I guess... I'll just scratch this entire trigger and recode it, hoping that starting over on it will fix the weird bug.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
Try checking the conditions separately? If that works, then just do multiple if's to check your conditions

The problem seems to the with the IsUnitType(), because this returns "Isn't a hero", even when the unit is clearly a hero.
JASS:
function EnteranceFilter takes nothing returns boolean
    call BJDebugMsg("unit entrance being tested")
    debug   if (IsUnitInGroup(GetEnteringUnit(),G) == false) then
    debug       call BJDebugMsg("Not in group")
    debug       if  (IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO) == true) then
    debug           call BJDebugMsg("Is a hero, returning true")
    debug           return true
    debug       else
    debug           call BJDebugMsg("Isn't a hero")
    debug           return false
    debug       endif
    debug   else
    debug       call BJDebugMsg("Returning false")
    debug           return false
    debug   endif
    //return ((IsUnitInGroup(GetEnteringUnit(),G) == false) and (IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO) == true))
endfunction

Argh... This is frustrating, because I can't seem to find the issue within this code. It looks right to me.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top