• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] MapBounds

JASS:
/*
*=================================================================================*
*   Map Bounds 1.2                                                                *                                                          
*   By Adiktuz                                                                    *
*                                                                                 *
*                                                                                 *
*   This is a short snippet that provides some useful functions utilizing         *
*   the WorldBounds library created by Nestharus                                  * 
*                                                                                 *
*                                                                                 *  
*   Credits:                                                                      *
*       Nestharus for the WorldBounds library                                     *
*       Magtheridon96 for suggestions                                             *
*                                                                                 * 
*   Functions:                                                                    *
*                                                                                 *  
*       -> MapContainsX(real x) returns boolean                                    *
*       -> MapContainsY(real y) returns boolean                                    *
*       -> GetBoundedX(real x) returns real                                       *
*       -> GetBoundedY(real y) returns real                                       *
*                                                                                 *
*                                                                                 *
*   The MapContainsX/Y functions return if the given x/y value is inside the map   *
*                                                                                 *
*   The GetBoundedX/Y  checks if the given value is within the map. If it's       *
*       within the map, it will return the value given and if Not                 *
*       it will return the value of the border that it will exceed                *
*                                                                                 *
*=================================================================================*
*/

library MapBounds requires WorldBounds

    function MapContainsX takes real x returns boolean
        return x < WorldBounds.maxX and x > WorldBounds.minX
    endfunction
    
    function MapContainsY takes real y returns boolean
        return y < WorldBounds.maxY and y > WorldBounds.minY
    endfunction
    
    function GetBoundedX takes real x returns real
        if x > WorldBounds.maxX then
            return I2R(WorldBounds.maxX)
        elseif x < WorldBounds.minX then
            return I2R(WorldBounds.minX)
        endif
        return x
    endfunction
    
    function GetBoundedY takes real y returns real
        if y > WorldBounds.maxY then
            return I2R(WorldBounds.maxY)
        elseif y < WorldBounds.minY then
            return I2R(WorldBounds.minY)
        endif
        return y
    endfunction
    
endlibrary

Well, its a simple snippet of functions for WorldBounds...

I hope you find it useful even if its really simple...
 
Last edited by a moderator:
Top