• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[vJass] Out of Map

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Yes it's another thread from me. I try to learn vJass since 3 days and I finish my first own spell this day. Was a long day to make it but it's done so far =)

Now I have a problem, the spell creates a ball (dummy unit) that flies over the map. The problem is the dummy can fly out of the map.

I know that Vexorian created a good system called Bound Sentinel, but my plan was to make it so, that the spell will END when the ball is out of the map.


The dummy walks to the points "d.x1 und d.y1" also a rect named "ENUM_RECT" is always at the position of the ball, so I thought maybe something like "if the coordinates or the rect is out of map then end spell". Maybe it isn't that simple but can someone help me with that please?

Again: I'm learning vJass, so please a clear help that I can understand it ^^


Greetings - Thanks - Peace
Dr. Boom
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hm, did you try this already?

JASS:
function test takes nothing returns nothing
    local real X = GetRectCenterX(ENUM_RECT)
    local real Y = GetRectCenterY(ENUM_RECT)
    local real x1 = GetRectMaxX(bj_mapInitialPlayableArea)
    local real y1 = GetRectMaxY(bj_mapInitialPlayableArea)
    local real x2 = GetRectMinX(bj_mapInitialPlayableArea)
    local real y2 = GetRectMinY(bj_mapInitialPlayableArea)

    if X >= x1 or Y >= y1 or X <= x2 or Y <= y2 then
        call RemoveUnit(bj_lastCreatedUnit)
    endif
endfunction
The 'or's are important (once one of these limits is exceeded, the unit is considered out of bounds) and try to double-check the x1, x2, y1 and y2 for the correct values :p (you might mix up a few and it'll bug the 'system' :/).
At least, in MY theory it works xD

And in case it doesn't work, a worse method:
JASS:
    local region check = CreateRegion()
    local location l = Location(GetRectCenterX(ENUM_RECT), GetRectCenterY(ENUM_RECT)) // Yes a location! D:

    call RegionAddRect(check, bj_mapInitialPlayableArea)
    if IsLocationInRegion(check, l) then
        call RemoveUnit(dummy)
    endif
    
    call RemoveRegion(check)
    call RemoveLocation(l)
    set l = null
    set check = null

Edit: too late ^^
 
Status
Not open for further replies.
Top