HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Condition only partially working

01-18-2006, 06:06 AM#1
The_AwaKening
Any idea why this boolean is only checking the first condition within. Unit NC17 is not included in the group, but 'ocat' is getting included.
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit()) != 'NC17' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ocat' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ewsp' then
        return true
    endif
    return false
endfunction

function Kill_player_units takes nothing returns nothing
local unit u=GetEnumUnit()
    call KillUnit(u)
        set u=null
endfunction

function Trig_Kill_units_Actions takes nothing returns nothing
local group g
        set g=GetUnitsOfPlayerMatching(Player(1),Condition (function GolemsCatsBool))
        call ForGroup( g, function Kill_player_units )
        call DestroyGroup(g)
        set g=null
endfunction

This is shortened quite a bit, but the rest of it isn't the problem.
01-18-2006, 08:04 AM#2
qwertyui
well, try merging all of this in one single condition:
Collapse JASS:
if((GetUnitTypeID(GetFilterUnit())=='NC17')or(GetUnitTypeID(GetFilterUnit())=='ocat')or(GetUnitTypeID(GetFilterUnit())=='ewsp'))then
return false
else return true
01-18-2006, 08:57 AM#3
The_AwaKening
Wouldn't that be the same as
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) != 'NC17' or GetUnitTypeId(GetFilterUnit()) != 'ocat' or GetUnitTypeId(GetFilterUnit()) != 'ewsp' 
endfunction
because I already tried that.
01-18-2006, 09:34 AM#4
Blade.dk
It should probably be == (equal to) instead of != (not equal to), if I understand you correctly. Try that.
01-18-2006, 09:37 AM#5
qwertyui
Okay i think i found the error here
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit()) != 'NC17' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ocat' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ewsp' then
        return true
    endif
    return false
endfunction
Basically when GetFilterUnit() unit-type is 'ocat' or 'ewsp' it registers "true" on first "if: statement (not NC17) and returns true right there.

The next one has the same problem.
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) != 'NC17' or GetUnitTypeId(GetFilterUnit()) != 'ocat' or GetUnitTypeId(GetFilterUnit()) != 'ewsp' 
endfunction

This function will return "true" on these 3 unit types and false on all else:
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == 'NC17' or GetUnitTypeId(GetFilterUnit()) == 'ocat' or GetUnitTypeId(GetFilterUnit()) == 'ewsp' 
endfunction

The difference with your function is that all "!=" are replaced with "==".

P.S: Oh, BladeDK is fast :(
Man all are faster than me today. I should stop making such long posts.
01-18-2006, 07:00 PM#6
Vexorian
Quote:
Originally Posted by The_AwaKening
Any idea why this boolean is only checking the first condition within. Unit NC17 is not included in the group, but 'ocat' is getting included.
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    if GetUnitTypeId(GetFilterUnit()) != 'NC17' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ocat' then
        return true
    elseif GetUnitTypeId(GetFilterUnit()) != 'ewsp' then
        return true
    endif
    return false
endfunction

function Kill_player_units takes nothing returns nothing
local unit u=GetEnumUnit()
    call KillUnit(u)
        set u=null
endfunction

function Trig_Kill_units_Actions takes nothing returns nothing
local group g
        set g=GetUnitsOfPlayerMatching(Player(1),Condition (function GolemsCatsBool))
        call ForGroup( g, function Kill_player_units )
        call DestroyGroup(g)
        set g=null
endfunction

This is shortened quite a bit, but the rest of it isn't the problem.
That's an or like structure, and acording to what you are saying you want an and like structure.
01-18-2006, 10:27 PM#7
The_AwaKening
Quote:
Originally Posted by Vexorian
That's an or like structure, and acording to what you are saying you want an and like structure.
I think you are right. It does need to be != btw because I want it not to select those units. So I'm assuming I should just do it like this
Collapse JASS:
function GolemsCatsBool takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) != 'NC17' and GetUnitTypeId(GetFilterUnit()) != 'ocat' and GetUnitTypeId(GetFilterUnit()) != 'ewsp' 
endfunction
01-19-2006, 05:35 AM#8
qwertyui
On an unrelated note, do you know that a logical structure that looks like:
A and B and C and D

is equivalent to logical structure that looks like:
notA or notB or notC or notD

So in that sense, it doesn't matter if you use or's and ==, or and's and !=
01-19-2006, 06:30 AM#9
The_AwaKening
The problem ended up being something really dumb. NC17 was supposed to be nC17 Damn that was stupid.
01-19-2006, 09:13 AM#10
qwertyui
didn't know capitalisation mattered in these things :/
01-19-2006, 10:04 AM#11
iNfraNe
ofcourse it does, the number 'n' is completely different than the number 'N'