Jump to content
code34

OO GRID - oriented object Strategic GRID

Recommended Posts

Object Oriented GRID
Lastest version : 0.4 by Code34

 

 

Download from : Dropbox

Download from: Armaholic

 

Like to Donate ? Donate with paypal

 



Github: https://github.com/code34/oo_grid.Altis
Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling




Description
OO GRID is a class (object oriented) grid that permits to manage a virtual strategic GRID of sectors on map. This object will permit to handle some events depending of objects/players position, create some virtual life & scenari, etc. This object uses Object Oriented SQF scripting of Naught and doesn't require to use addon.

Features:
  • Translation Position to Grid position

Licence:
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author

Documentation:

       Author: code34 nicolas_boiteux@yahoo.fr
    Copyright (C) 2013-2016 Nicolas BOITEUX

    CLASS OO_GRID STRATEGIC GRID
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    --------------------------------------------------------------------------------------------------------------

    Function: _grid = ["new", [xgrid,ygrid,xgridsize,ygridsize,xsectorsize,ysectorsize]] call OO_GRID;
    Create a new grid object

    Parameters:
        xgrid - x grid pos - scalar
        ygrid - y grid pos - scalar
        xgridsize - grid width - scalar
        ygridsize - grid height - scalar
        xsectorsize - sector width - scalar
        ysectorsize - sector height - scalar
    
    --------------------------------------------------------------------------------------------------------------

    Function: ["setXgrid", _scalar] call _grid;
    Set xgrid value

    Parameters : _scalar : scalar x grid pos
    --------------------------------------------------------------------------------------------------------------

    Function: ["setYgrid", _scalar] call _grid;
    Set xgrid value

    Parameters : _scalar : scalar y grid pos
    --------------------------------------------------------------------------------------------------------------

    Function: ["setXgridsize", _scalar] call _grid;
    Set xgridsize value

    Parameters : _scalar : scalar grid width
    --------------------------------------------------------------------------------------------------------------

    Function: ["setYgridsize", _scalar] call _grid;
    Set ygridsize value

    Parameters : _scalar : scalar grid height
    --------------------------------------------------------------------------------------------------------------

    Function: ["setXsectorsize", _scalar] call _grid;
    Set sector width

    Parameters : _scalar : scalar sector width

    --------------------------------------------------------------------------------------------------------------

    Function: ["setYsectorsize", _scalar] call _grid;
    Set sector height

    Parameters : _scalar : scalar sector height

    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getXgrid" call _grid;
    Get xgrid value

    Parameters : nothing

    Return: scalar

    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getYgrid" call _grid;
    Get ygrid value

    Parameters : nothing

    Return: scalar

    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getXgridsize" call _grid;
    Get xgridsize value

    Parameters : nothing

    Return : scalar

    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getYgridsize" call _grid;
    Get ygridsize value

    Parameters : nothing

    Return : scalar
    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getXsectorsize" call _grid;
    Get sector width

    Parameters = nothing

    Return : scalar

    --------------------------------------------------------------------------------------------------------------

    Function: _scalar = "getYsectorsize" call _grid;
    Get sector height

    Parameters : nothing

    Return : scalar

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["parseAllSectors", string] call _grid;
    Parse all sectors of grid with a function call that returns true or false
    
    Parameters: string - function name (functin must return true or false)

    Return : array of sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["parseSectors", string] call _grid;
    Parse sectors of grid with a function call that returns true or false
    
    Parameters:
        array - array of sectors
        string - function name (functin must return true or false)

    Return : array of sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _sector = ["getSectorFromPos", _position] call _grid;
    Translate a position to a sector
    
    Parameters:
        array - position array

    Return : array - sector

    --------------------------------------------------------------------------------------------------------------

    Function: _position = ["getPosFromSector", _position] call _grid;
    Translate a sector to position
    
    Parameters: array - sector array

    Return : array position

    --------------------------------------------------------------------------------------------------------------

    Function: _sector = ["getSectorCenterPos", _position] call _grid;
    Retrieve the center position of a sector, from a position
    
    Parameters: array - position
    
    Return : array position of the sector center

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getSectorsAroundSector", _sector] call _grid;
    Get all sectors around one sector at 1 scale
    
    Parameters: array - array sector
    
    Return : array containing all sectors
    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getSectorsAroundPos", _position] call _grid;
    Get all sectors around a position at 1 scale
    
    Parameters: array - array position
    
    Return : array containing all sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getSectorsCrossAroundSector", _sector] call _grid;
    Get cross sectors around a sector
    
    Parameters: array - array sector
    
    Return : array containing all sectors
    
    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getSectorsCrossAroundPos", _position] call _grid;
    Get cross sectors around a position
    
    Parameters: array - array position
    
    Return : array containing all sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getAllSectorsAroundSector", _array] call _grid;
    Get all sectors around a sector at scale sector distance

    Parameters: array [_sector, _scale]
        _sector : array sector
        _scale : scalar (scale to extend)

    Return : array containing all sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getAllSectorsAroundPos", _array] call _grid;
    Get all sectors around a sector at scale sector distance
    
    Parameters: array [_position, _scale]
        _position : array position
        _scale : scalar (scale to extend)    
    Return : array containing all sectors

    --------------------------------------------------------------------------------------------------------------

    Function: _bool = ["hasBuildingsAtSector", _sector] call _grid;
    Check if sector has building
    
    Parameters: array sector
    Return : bool

    --------------------------------------------------------------------------------------------------------------

    Function: _bool = ["hasBuildingsAtPos", _position] call _grid;
    Check if position has buildings
    
    Parameters: array position
    Return : bool

    --------------------------------------------------------------------------------------------------------------

    Function: _array = ["getPositionsBuilding", _position] call _grid;
    Return all the positions in the building  at position
    
    Parameters: array position
    Return : array - array of buildings positions

    --------------------------------------------------------------------------------------------------------------

    Function: ["delete", _grid] call OO_GRID;
    Delete the grid object
    
    Parameters:  _grid - OO GRID object


Readme:


    /*
    Author: code34 nicolas_boiteux@yahoo.fr
    Copyright (C) 2014 Nicolas BOITEUX

    CLASS OO_GRID STRATEGIC GRID
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

    Create a main bus message between clients & server
    
    Usage:
        put the "oo_grid.sqf" and the "oop.h" files in your mission directory
        put this code into your mission init.sqf
        call compilefinal preprocessFileLineNumbers "oo_grid.sqf";

    See example mission in directory: init.sqf
    
    Licence:
    You can share, modify, distribute this script but don't remove the licence and the name of the original author

    logs:
        0.4     
            - improve performance
            - add direct translation for around methods
            - fix around methods
            - fix constructor method, add origins positions for grid
            - refactory methods
        0.3 - Delete useless functions
        0.2 - Make arma not war contest
        0.1 - OO GRID - first release



Examples

Hint the sector pos of the player :)
        call compilefinal preprocessFileLineNumbers "oo_grid.sqf";

        _grid = ["new", [0,0,31000,31000,100,100]] call OO_GRID;

        sleep 2;

        hint format ["player sector %1", ["getSectorFromPos", position player] call _grid];
Edited by code34

Share this post


Link to post
Share on other sites

hi guys ,

i just release the lastest 0.3 version of the grid object. This one includes the several functions uses by COMBAT ASSAULT mission and delete useless functions :)

logs:

0.3 - Delete useless functions

0.2 - Make arma not war contest

0.1 - OO GRID - first release

Major difference between 0.1 and 0.3 is Grid now focus on grid convertion, no more uses of index [x,y] translation instead :)

Share this post


Link to post
Share on other sites

hi guys !

 

just release the version 0.4 of grid object.

 

This version virtualize complety the grid over map, fix must of the old bugs, and delete useless functions.

 

Change logs:

            - improve performance
            - add direct translation for around methods
            - fix around methods
            - fix constructor method, add origins positions for grid
            - refactory methods

 

Download from Dropbox

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×