HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

2 Simple Questions

08-10-2008, 01:52 PM#1
Sophismata
Alright, I've searched around for the answers to these to no avail, so if someone could either answer them or direct me to another's response, I'd be much obliged.

Buildings

Is there a way to determine if a unit is a building? At the moment, I've been checking for the 'Avul' ability to disregard neutral buildings, but if there's a function or native that returns the value of 'isbldg'/'ubdg', I'd love to know about it :P.


Set X and Set Y

I'm trying to prevent moving units outside the map boundry. To that end, I made a funtion to check if two reals lie within a map's playable area. The error I'm getting is that the function is not returning a boolean.

The problem is probably something obvious, but I'm missing it, whatever it is...

Collapse JASS:
function CheckXY takes real x real y returns boolean
    local rect r = bj_mapInitialPlayableArea
    local x1 = GetRectMinX(r)
    local x2 = GetRectMaxX(r)
    local y1 = GetRectMinY(r)
    local y2 = GetRectMaxY(r)
    set r = null
    return ((x > x1 and x < x2) and (y > y1 and y < y2))
endfunction

That return is a boolean, right? It's a maths comparison...



Edit again:

Third question moved.
08-10-2008, 08:52 PM#2
Vexorian
Quote:
Is there a way to determine if a unit is a building?

IsUnitType( GetTriggerUnit(), UNIT_TYPE_STRUCTURE )
Quote:
Collapse JASS:
function CheckXY takes real x real y returns boolean
    local rect r = bj_mapInitialPlayableArea
    local x1 = GetRectMinX(r)
    local x2 = GetRectMaxX(r)
    local y1 = GetRectMinY(r)
    local y2 = GetRectMaxY(r)
    set r = null
    return ((x > x1 and x < x2) and (y > y1 and y < y2))
endfunction
You are forgetting to specify x1,y1,x2, and y2's types as real.

I'll leave the third question for someone else, it is better to have a thread per question, more organized.
08-11-2008, 05:05 AM#3
Sophismata
Thankyou very much for the quick reply.

Sorry about the triple question - there's a rule against double posting, I wasn't sure if it applied to threads as well. I'll create a new thread and move the final question.

Quote:
You are forgetting to specify x1,y1,x2, and y2's types as real.

Gah!

I completely missed IsUnitType, thanks again.


Edit:


Still no luck, getting told "expected returns":

Collapse JASS:
function CheckXY takes real x real y returns boolean
    local real x1 = GetRectMinX(bj_mapInitialPlayableArea)
    local real x2 = GetRectMaxX(bj_mapInitialPlayableArea)
    local real y1 = GetRectMinY(bj_mapInitialPlayableArea)
    local real y2 = GetRectMaxY(bj_mapInitialPlayableArea)
    return ((x > x1 and x < x2) and (y > y1 and y < y2))
endfunction


I have tried:

function Check XY takes real x real y returns nothing
Collapse JASS:
function CheckXY takes real x real y returns boolean
return true
endfunction
08-11-2008, 05:47 AM#4
Veev
You forgot commas.

function CheckXY takes real x, real y returns boolean
08-11-2008, 07:40 AM#5
Sophismata
Ahhh, thanks.

Now I understand the error, since it was expecting "returns" and got "real" instead.


Thankyou to both of you.