• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[vJASS] Help VJass error?

Status
Not open for further replies.
Level 5
Joined
Jul 25, 2008
Messages
126
Need some help. This system only works for me when I enable cohaders Jasshelper. All my other scripts use Vexorian. So I thought this was cJass and needed it to be made vJass. Someone here told me it was already in vjass so I posted the image of the error (see attachment) I get when trying to save the map with Vexorians jasshelper enabled. The code is below. Attached the map as well.

JASS:
/*
==============================================================
ANIME HERO SELECTION SYSTEM v1.0
--------------------------------------------------------------
Created by: 
    IncendiaryMonkey ([email protected])
For more systems like that, visit:
    [url]http://www.warcraftmule.blogspot.com[/url]
--------------------------------------------------------------
REQUIRES:
    - Arrow Event Key ([url]http://www.hiveworkshop.com/forums/jass-resources-412/system-arrowkeyevent-205650/[/url])
--------------------------------------------------------------
Instructions below. You can use this selection screen at any moment 
by calling the "custom script" code on a trigger:
    call AHSS_Configurations.start(all_random)
"all_random" can be true or false. 
*/
scope AHSS 
    //--------------------------------------------------------
    // CONFIGURATIONS
    //--------------------------------------------------------
    public struct Configurations
        public static constant integer DUMMY_ID  = 'hss1'                //Object id of an invisible dummy
        public static constant integer MAX_SLOTS = 30                    //Max number of slots for heroes 
        public rect INITIAL_AREA = gg_rct_SELECTION_AREA                 //This is a region where the screen will be displayed
                                                                         //Preferentially it must be isolated
        public camerasetup CAMERA = gg_cam_Camera_001                    //This camera is applied to make screen more planar
                                                                         //The naming is: "gg_cam_" + Camera name, where spaces are replaced by underline (_)
        
        public static method init takes nothing returns nothing
            //-----------------------------------------------------------------
            //ATTENTION: THE ORDER OF FUNCTION CALLS MUST BE RESPECTED! 
            //I.e, you can't call "teams.addPlayer()" before "teams.createTeam()".
            
            //---------------------------------------------------------------------------------
            // TEAMS SECTION
            //---------------------------------------------------------------------------------
            //Here you configure the teams. Just insert user controller players.
            //Remember: 0 = Red, 1 = Blue, and so on. 
            call teams.createTeam("Team 1") 
            call teams.addPlayer(0)
            call teams.addPlayer(1)
            call teams.addPlayer(2)
            call teams.setSpawningSpot(gg_rct_TEAM_1_SPOT) //Here you define a region to where the heroes of this team will go when picked. 
                                                           //If you don't understand the naming, all regions have to have "gg_rct_" in front of 
                                                           //their name and spaces are replaced by underline (_).
            call teams.createTeam("Team 2")
            call teams.addPlayer(4)
            call teams.addPlayer(5)
            call teams.addPlayer(6)
            call teams.setSpawningSpot(gg_rct_TEAM_2_SPOT)
            
            call teams.createTeam("Team 3")
            call teams.addPlayer(8)
            call teams.addPlayer(9)
            call teams.addPlayer(10)
            call teams.setSpawningSpot(gg_rct_TEAM_3_SPOT)
            
            //---------------------------------------------------------------------------------
            // HEROES SECTION
            //---------------------------------------------------------------------------------
            //Here you add heroes to selection. Follow the template.
            call heroes.addHero("Paladin", 'Hpal') //'Hpal' representates the object id of the hero. To discover it, go to Object Editor and presses CTRL+D
            call heroes.setStr("22 + 2.70") 
            call heroes.setAgi("13 + 1.50")
            call heroes.setInt("17 + 1.80")
            call heroes.setDescription("Warrior Hero, exceptional at defense and augmenting nearby friendly troops.\n\n1. Holy Light\n2. Divine Shield\n3. Devotion Aura\n4. Ressurrection")
            call heroes.setModel('xu01', "spell") //Here you define an unit id to representates graphically the hero on selection screen. 
                                                  //The second parameter is the animation tag that the unit will display when the hero is selected.
            call heroes.setIcon('xd01') //Icons are represented by a destructable
                                                                                           
            call heroes.addHero("Archmage", 'Hamg')
            call heroes.setStr("14 + 1.80")
            call heroes.setAgi("17 + 1.00")
            call heroes.setInt("19 + 3.20")
            call heroes.setDescription("Mystical Hero, adept at ranged assaults.\n\n1. Blizzard\n2. Summon Water Elemental\n3. Brilliance Aura\n4. Mass Teleport\n")
            call heroes.setModel('xu02', "spell") 
            call heroes.setIcon('xd02')

            call heroes.addHero("Mountain King", 'Hmkg') 
            call heroes.setStr("24 + 3.00")
            call heroes.setAgi("11 + 1.50")
            call heroes.setInt("15 + 1.50")
            call heroes.setDescription("Warrior Hero, adept at offensive combat and disrupting enemy troops.\n\n1. Storm Bolt\n 2. Thunder clap\n3. Bash\n4. Avatar")
            call heroes.setModel('xu03', "spell")
            call heroes.setIcon('xd03')
            
            call heroes.addHero("Blood Mage", 'Hblm') 
            call heroes.setStr("18 + 2.00")
            call heroes.setAgi("14 + 1.00")
            call heroes.setInt("19 + 3.00")
            call heroes.setDescription("Mystical Hero, adept at controlling magic and ranged assaults.\n\n1. Flame Strike\n2. Banish\n3. Siphon Mana\n4. Phoenix")
            call heroes.setModel('xu04', "spell")
            call heroes.setIcon('xd04')
            
            //---------------------------------------------------------------------------------
            // OPTIONS SECTION
            //---------------------------------------------------------------------------------
            //Here you configurate severals options of the system.
            call options.timeLimit(true, 60.0) //If "true", the players have a limited time to pick a hero. The time is given in seconds.
            call options.botsPick(true) //Computer players pick heros too? 
            
            call options.setIconScale(1.5) //Size of heroes icons. Not recommended to change.
            call options.setIconsByLine(10) //Set the amount of heroes icons by row
            
            call options.setSoundClick(gg_snd_MouseClick1) //This sound is played when selection changes 
            call options.setSoundError(gg_snd_Error) //This sound is played when an invalid action is perfomed
            call options.setSoundOk(gg_snd_BigButtonClick) //This sound is played when you confirm a hero selection
            
            //---------------------------------------------------------------------------------
            // FILE PATHS SECTION
            //---------------------------------------------------------------------------------
            call paths.setBackground("war3mapImported\\AHSS_Background.blp") //Background of selection screen
            call paths.setSelection('hss2') //The selection square above hero icon. It's the single one that it's an unit.
            call paths.setEmptyIcon('hss3') //Icon that is display in the absence of a hero. It's a destructable. 
            call paths.setRandomIcon('hss4') //Icon for random selection. 
            call paths.setStrIcon('hss5') //Icon to display beside the hero strength. 
            call paths.setAgiIcon('hss6') 
            call paths.setIntIcon('hss7')
            call paths.setLogo('hss8') //This is displayed on top-center
            
            //---------------------------------------------------------------------------------
            // OBJECT CREATION SECTION
            //---------------------------------------------------------------------------------
            ///* //<------ REMOVE TWO BACKSLASHES IN THE BEGINNING OF THIS LINE WHEN READY
            //On the 'blue block' below you can create automatically units or doodads on Object Editor.
            //You just need to run it once, but everytime you want create something else you have to run all it again.
            //After you run this block you must comment all this block by removing double slash on indicated lines.
            //Caution with object ids. Two objects with the same id will be replaced by the newest.
            
            //! externalblock extension=lua ObjectMerger $FILENAME$
                //! runtextmacro CREATE_OBJECTS()
                //---------------------------------------------------------------------------------
                // DEFAULT OBJECTS
                //---------------------------------------------------------------------------------
                // Those are default objects required for system operation.
                //! i createDummy("AHSS_DUMMY", "hss1", "", 1.0)   
                //! i createDummy("AHSS_SELECTION", "hss2", "war3mapImported\\AHSS_Selection.mdx", 1.0) 
                //! i createDestructable("AHSS_EMPTY_ICON", "hss3", "war3mapImported\\AHSS_Empty_Icon.blp")
                //! i createDestructable("AHHS_RANDOM_ICON", "hss4", "war3mapImported\\AHSS_Random_Icon.blp")
                //! i createDestructable("AHHS_STR_ICON", "hss5", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-str.blp")
                //! i createDestructable("AHHS_AGI_ICON", "hss6", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-agi.blp")
                //! i createDestructable("AHHS_INT_ICON", "hss7", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-int.blp")
                //! i createDestructable("AHHS_LOGO", "hss8", "war3mapImported\\AHSS_Logo.blp")
                //---------------------------------------------------------------------------------
                // CUSTOM OBJECTS 
                //---------------------------------------------------------------------------------
                // Those are objects used by the heroes
                //---------------------------------------------------------------------------------
                // MODELS
                //---------------------------------------------------------------------------------
                //The lines below creates units on Object Editor with the name, object id, model and scale defined, respectively.
                //! i createUnit("AHSS_PALADIN_DUMMY", "xu01", "units\\human\\HeroPaladin\\HeroPaladin", 3.0) 
                //! i createUnit("AHSS_ARCHMAGE_DUMMY", "xu02", "units\\human\\HeroArchMage\\HeroArchMage", 3.0)
                //! i createUnit("AHSS_MOUNTAIN_KING_DUMMY", "xu03", "units\\human\\HeroMountainKing\\HeroMountainKing", 3.0)
                //! i createUnit("AHSS_BLOOD_MAGE_DUMMY", "xu04", "units\\human\\HeroBloodElf\\HeroBloodElf", 3.0)
                //---------------------------------------------------------------------------------
                // ICONS
                //---------------------------------------------------------------------------------
                //The lines below creates a destructable on Object Editor with name, object id and texture defined, respectively. 
                //! i createDestructable("AHSS_PALADIN_ICON", "xd01", "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin.blp")
                //! i createDestructable("AHSS_ARCHMAGE_ICON", "xd02", "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage.blp") 
                //! i createDestructable("AHSS_MOUNTAING_KING_ICON", "xd03", "ReplaceableTextures\\CommandButtons\\BTNHeroMountainKing.blp")
                //! i createDestructable("AHSS_BLOOD_MAGE_ICON", "xd04", "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince.blp")
            //! endexternalblock
            //*/ //<------ REMOVE TWO BACKSLASHES IN THE BEGINNING OF THIS LINE WHEN READY
        endmethod
        //--------------------------------------------------------
        // END OF CONFIGURATIONS
        //--------------------------------------------------------
        //! textmacro CREATE_OBJECTS 
            //! i function createDummy(name, id, model, scale)
                //! i setobjecttype("units")
                //! i createobject("hpea", id)
                //! i makechange(current,"uabi","Aloc,Avul")
                //! i makechange(current,"umdl",model)
                //! i makechange(current,"usca",scale)
                //! i makechange(current,"ushu","")
                //! i makechange(current,"ufoo",0)
                //! i makechange(current,"unam",name)
                //! i makechange(current,"ucol",0)
                //! i makechange(current,"utyp","")
                //! i makechange(current,"uble",0)
                //! i makechange(current,"ucbs",0)
                //! i makechange(current,"ucpt",0)
                //! i makechange(current,"urun",0)
                //! i makechange(current,"uwal",0)
                //! i makechange(current,"umxp",0)
                //! i makechange(current,"umxr",0)
            //! i end
            //! i function createUnit(name, id, model, scale)
                //! i createDummy(name, id, model, scale)
                //! i makechange(current,"umxp",-285)
                //! i makechange(current,"umxr",-90)
                //! i makechange(current,"usca",3.0)
            //! i end
            //! i function createDestructable(name, id, path) 
                //! i setobjecttype("destructables")
                //! i createobject("YTlb", id) 
                //! i makechange(current,"bfil","war3mapImported\\AHSS_Button.mdx")
                //! i makechange(current,"boch",0)
                //! i makechange(current,"btxf",path) 
                //! i makechange(current,"btxi",31)
                //! i makechange(current,"bsel",0)
                //! i makechange(current,"bgsc",0)
                //! i makechange(current,"bshd","")
                //! i makechange(current,"btar","")
                //! i makechange(current,"bcpr",false)
                //! i makechange(current,"bcpd",false) 
                //! i makechange(current,"buch",false)
                //! i makechange(current,"bptx","")
                //! i makechange(current,"bnam",name)
            //! i end
        //! endtextmacro
        public static AHSS_Teams teams
        public static AHSS_Heroes heroes 
        public static AHSS_Options options 
        public static AHSS_Paths paths 
        public static AHSS_Graphics graphics
        private static method onInit takes nothing returns nothing 
            set teams = AHSS_Teams.create()
            set heroes = AHSS_Heroes.create()
            set options = AHSS_Options.create()
            set paths = AHSS_Paths.create() 
            set graphics = AHSS_Graphics.create(teams, heroes, options, paths)
            call thistype.init()
        endmethod
        public static method start takes boolean allRandom returns nothing 
            call graphics.draw(allRandom)
        endmethod
    endstruct
    /*============================================================
    * DATA STRUCT SECTION
    *-------------------------------------------------------------
    * This section contains structs that armazenates data only.
    *=============================================================*/
    /*----------------------------------------------------------
    *This class stores all informations about teams
    *----------------------------------------------------------*/
    private struct Team 
        private string name 
        private integer array players[12] 
        private integer count 
        private rect spawningSpot
        public static method create takes string name returns thistype 
            local thistype this = thistype.allocate()
            set this.name = name 
            set this.count = 0 
            return this
        endmethod 
        public method addPlayer takes integer whichPlayer returns nothing 
            set players[count] = whichPlayer 
            set count = count + 1
        endmethod 
        public method setSpawningSpot takes rect whichRect returns nothing 
            set spawningSpot = whichRect 
        endmethod
        public method getName takes nothing returns string 
            return name
        endmethod
        public method getPlayer takes integer index returns integer 
            return players[index] 
        endmethod
        public method getSpawningSpot takes nothing returns rect 
            return spawningSpot 
        endmethod
        /*
        Get the quantify of players inside this team 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class stores manages all the teams in selection screen
    *----------------------------------------------------------*/
    public struct Teams
        private Team array teams[12]
        private integer count 
        public static method create takes nothing returns thistype 
            local thistype this = thistype.allocate()
            set this.count = 0 
            return this 
        endmethod
        /*
        Create a team of determined name 
        */
        public method createTeam takes string name returns nothing  
            set teams[count] = Team.create(name) 
            set count = count + 1
        endmethod
        /*
        Add a player to the lastest created team 
        */
        public method addPlayer takes integer whichPlayer returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: addPlayer to a team that doesn't exist.") 
                return 
            endif
            call teams[count - 1].addPlayer(whichPlayer) 
        endmethod
        /*
        Set the spawning spot of the lastest created team 
        */
        public method setSpawningSpot takes rect whichRect returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setSpawningSpot to a team that doesn't exist.")
                return 
            endif 
            call teams[count - 1].setSpawningSpot(whichRect)
        endmethod
        /*
        Get a team by index 
        */
        public method getTeam takes integer index returns Team 
            return teams[index] 
        endmethod
        /*
        Get the quantify of teams created 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
        /*
        Destroy all teams 
        */ 
        public method destroy takes nothing returns nothing 
            local integer i 
            for i = 0 to (count - 1) 
                call teams[i].destroy() 
            endfor 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class stores all informations about heroes 
    *----------------------------------------------------------*/
    private struct Hero 
        private string name 
        private string strength
        private string agility
        private string intelligence
        private string description
        private integer heroid
        private integer dummyid
        private string animation 
        private integer icon 
        public static method create takes string whichName, integer heroId returns thistype 
            local thistype this = thistype.allocate()
            set this.name = whichName 
            set this.strength = ""
            set this.agility = ""
            set this.intelligence = "" 
            set this.description = ""
            set this.heroid = heroId 
            set this.dummyid = Configurations.DUMMY_ID
            set this.animation = "stand"
            set this.icon = 'OTip'
            return this 
        endmethod
        public method setStr takes string whichStr returns nothing 
            set strength = whichStr
        endmethod 
        public method setAgi takes string whichAgi returns nothing 
            set agility = whichAgi 
        endmethod
        public method setInt takes string whichInt returns nothing 
            set intelligence = whichInt 
        endmethod
        public method setDescription takes string whichDescription returns nothing 
            set description = whichDescription 
        endmethod
        public method setModel takes integer whichDummyId, string whichAnimatin returns nothing 
            set dummyid = whichDummyId
            set animation = whichAnimatin 
        endmethod
        public method setIcon takes integer whichIcon returns nothing 
            set icon = whichIcon 
        endmethod
        public method getName takes nothing returns string 
            return name 
        endmethod
        public method getStr takes nothing returns string 
            return strength 
        endmethod
        public method getAgi takes nothing returns string 
            return agility 
        endmethod 
        public method getInt takes nothing returns string 
            return intelligence 
        endmethod
        public method getDescription takes nothing returns string 
            return description 
        endmethod
        public method getHeroid takes nothing returns integer 
            return heroid
        endmethod
        /*
        "Dummyid" is the unit that serves as model to a hero.
        */
        public method getDummyid takes nothing returns integer 
            return dummyid 
        endmethod
        /*
        "Animation" is the animation that the dummy plays when the hero is selected 
        */
        public method getAnimation takes nothing returns string 
            return animation 
        endmethod
        public method getIcon takes nothing returns integer 
            return icon 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class manages all heroes in selection screen 
    ----------------------------------------------------------*/
    public struct Heroes 
        private Hero array heroes[Configurations.MAX_SLOTS]
        private integer count 
        public static method create takes nothing returns thistype 
            local thistype this = thistype.allocate()
            set this.count = 0 
            return this 
        endmethod
        /*
        Add a hero to selection screen 
        */
        public method addHero takes string name, integer id returns nothing 
            if count >= Configurations.MAX_SLOTS then
                debug call BJDebugMsg("WARNING: addHero: Quantify of heroes already reached maximum slots.") 
                return 
            endif
            set heroes[count] = Hero.create(name, id) 
            set count = count + 1
        endmethod
        /*
        Set the strength of the lastest created hero 
        */
        public method setStr takes string whichStr returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setStr to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setStr(whichStr) 
        endmethod
        public method setAgi takes string whichAgi returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setAgi to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setAgi(whichAgi) 
        endmethod
        public method setInt takes string whichInt returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setInt to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setInt(whichInt) 
        endmethod
        public method setDescription takes string whichDescription returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setDescription to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setDescription(whichDescription)
        endmethod
        public method setModel takes integer whichDummyid, string whichAnimation returns nothing 
            if count == 0 then
                debug call BJDebugMsg("WARNING: setModel to a hero that doesn't exist.") 
                return 
            endif 
            call heroes[count - 1].setModel(whichDummyid, whichAnimation)
        endmethod
        public method setIcon takes integer whichIcon returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setIcon to a hero that doesn't exist.") 
                return 
            endif 
            call heroes[count - 1].setIcon(whichIcon) 
        endmethod
        /*
        Get a hero by index
        */
        public method getHero takes integer index returns Hero 
            return heroes[index] 
        endmethod 
        /*
        Get the quantify of heroes created 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
        /*
        Remove all heroes from selection screen 
        */
        public method destroy takes nothing returns nothing 
            local integer i 
            for i = 0 to (count - 1)
                call heroes[i].destroy() 
            endfor 
        endmethod
    endstruct
    
    public struct Options 
        private boolean timeLimit_actived 
        private real timeLimit_time 
        private real iconScale 
        private integer iconsByLine
        private sound click 
        private sound error
        private sound ok 
        private boolean bots 
        public method timeLimit takes boolean timeLimitActived, real whichTime returns nothing 
            set timeLimit_actived = timeLimitActived 
            set timeLimit_time = whichTime 
        endmethod
        public method isTimeLimited takes nothing returns boolean 
            return timeLimit_actived 
        endmethod
        public method setIconScale takes real whichScale returns nothing 
            set iconScale = whichScale 
        endmethod 
        public method setIconsByLine takes integer howMany returns nothing 
            set iconsByLine = howMany 
        endmethod
        public method setSoundClick takes sound whichSound returns nothing 
            set click = whichSound 
        endmethod 
        public method setSoundError takes sound whichSound returns nothing 
            set error = whichSound 
        endmethod
        public method setSoundOk takes sound whichSound returns nothing 
            set ok = whichSound 
        endmethod
        public method botsPick takes boolean b returns nothing 
            set bots = b
        endmethod
        public method getTimeLimit takes nothing returns real     
            return timeLimit_time 
        endmethod
        public method getIconScale takes nothing returns real   
            return iconScale 
        endmethod 
        public method getIconsByLine takes nothing returns integer 
            return iconsByLine 
        endmethod
        public method getSoundClick takes nothing returns sound 
            return click 
        endmethod 
        public method getSoundError takes nothing returns sound 
            return error
        endmethod
        public method getSoundOk takes nothing returns sound 
            return ok 
        endmethod
        public method doesBotsPick takes nothing returns boolean
            return bots 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class manages the file paths of selection screen
    ----------------------------------------------------------*/
    public struct Paths 
        private string background 
        private integer logo
        private integer emptyIcon 
        private integer randomIcon 
        private integer selection 
        private integer strength 
        private integer agility 
        private integer intelligence 
        public method setBackground takes string whichPath returns nothing 
            set background = whichPath 
        endmethod
        public method setLogo takes integer whichid returns nothing 
            set logo = whichid 
        endmethod 
        public method setEmptyIcon takes integer whichid returns nothing 
            set emptyIcon = whichid
        endmethod 
        public method setRandomIcon takes integer whichid returns nothing 
            set randomIcon = whichid 
        endmethod
        public method setSelection takes integer whichid returns nothing 
            set selection = whichid 
        endmethod 
        public method setStrIcon takes integer whichid returns nothing 
            set strength = whichid
        endmethod
        public method setAgiIcon takes integer whichid returns nothing
            set agility = whichid 
        endmethod 
        public method setIntIcon takes integer whichid returns nothing 
            set intelligence = whichid 
        endmethod
        public method getBackground takes nothing returns string 
            return background 
        endmethod
        public method getLogo takes nothing returns integer 
            return logo 
        endmethod
        public method getEmptyIcon takes nothing returns integer  
            return emptyIcon 
        endmethod
        public method getRandomIcon takes nothing returns integer 
            return randomIcon 
        endmethod
        public method getSelection takes nothing returns integer 
            return selection 
        endmethod
        public method getStrIcon takes nothing returns integer 
            return strength 
        endmethod 
        public method getAgiIcon takes nothing returns integer 
            return agility 
        endmethod 
        public method getIntIcon takes nothing returns integer 
            return intelligence 
        endmethod
    endstruct
    /*============================================================
    * END OF DATA STRUCT SECTION
    *=============================================================*/
    /*============================================================
    * SYSTEM DYNAMIC SECTION
    *=============================================================*/
    /*----------------------------------------------------------
    * This is just a trick class to allow me using bidimensional arrays. 
    ----------------------------------------------------------*/
    private struct TeamIcon 
        public destructable array icons[12] 
        public method destroy takes nothing returns nothing 
            local integer i 
            for i = 0 to 11
                if icons[i] != null then 
                    call RemoveDestructable(icons[i]) 
                    set icons[i] = null
                endif 
            endfor 
        endmethod 
    endstruct
    /*----------------------------------------------------------
    * This class manages the player selection 
    ----------------------------------------------------------*/
    private struct PlayerSelection 
        private integer whichPlayer 
        private unit selectionBox 
        private integer row 
        private integer column 
        public static method create takes integer whichPlayer, integer unitid, real x, real y, real red, real green, real blue returns thistype 
            local thistype this = thistype.allocate()
            set this.whichPlayer = whichPlayer 
            set this.selectionBox = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), unitid, x, y, 270) 
            call SetUnitVertexColorBJ(this.selectionBox, R2I(red * 100), R2I(green * 100), R2I(blue * 100), 0) 
            call UnitAddAbility(this.selectionBox, 'Arav')
            call UnitRemoveAbility(this.selectionBox, 'Arav')
            call SetUnitFlyHeight(this.selectionBox, 250 + 12 - whichPlayer, 0)
            call SetUnitX(this.selectionBox, x) 
            call SetUnitY(this.selectionBox, y)
            set this.row = 0
            set this.column = 0
            return this
        endmethod
        public method setRow takes integer whichRow returns nothing 
            set row = whichRow 
        endmethod 
        public method setColumn takes integer whichColumn returns nothing 
            set column = whichColumn 
        endmethod
        public method setPos takes real x, real y returns nothing 
            call SetUnitPosition(selectionBox, x, y) 
        endmethod
        public method setX takes real x returns nothing 
            call SetUnitX(selectionBox, x) 
        endmethod 
        public method setY takes real y returns nothing 
            call SetUnitY(selectionBox, y) 
        endmethod
        public method getRow takes nothing returns integer 
            return row 
        endmethod 
        public method getColumn takes nothing returns integer 
            return column 
        endmethod
        public method getUnit takes nothing returns unit 
            return selectionBox 
        endmethod
        public method destroy takes nothing returns nothing 
            call RemoveUnit(selectionBox) 
            set selectionBox = null 
        endmethod 
    endstruct 
    /*----------------------------------------------------------
    * This is where the real show happens 
    *----------------------------------------------------------*/
    public struct Graphics 
        private static constant integer ICON_SIZE = 64
        private static force cameraForce
        private timer cameraTimer 
        private AHSS_Teams teams
        private AHSS_Heroes heroes 
        private AHSS_Options options
        private AHSS_Paths paths
        private unit dummy 
        private image backgroundImg
        private destructable logoImg
        private destructable array emptyIcon[Configurations.MAX_SLOTS]
        private destructable randomIcon 
        private PlayerSelection array selections[12]
        private TeamIcon array teamsIcon[12]
        private texttag array teamsText[12]
        private unit array heroesModels[12]
        private texttag array heroesName[12]
        private destructable array heroesIcon[Configurations.MAX_SLOTS]
        //! textmacro CREATE_ATT_STAT takes stat 
        private destructable array $stat$Icon[12]
        private texttag array $stat$Text[12]
        //! endtextmacro 
        //! runtextmacro CREATE_ATT_STAT("str")
        //! runtextmacro CREATE_ATT_STAT("agi")
        //! runtextmacro CREATE_ATT_STAT("int")
        private texttag array descriptionText[12]
        private boolean array selectionUsed[12]
        private boolean gameStarted
        private timer gameStartedTimer 
        private timerdialog gameStartedTimerDialog
        private fogmodifier array modifier[12] 
        private timer timeLimitTimer 
        private timerdialog timeLimitTimerDialog 
        /*
        Register the arrow key event 
        */
        private static method onInit takes nothing returns nothing 
            local trigger t = CreateTrigger()
            local integer i 
            for i = 0 to 11 
                call TriggerRegisterPlayerEventEndCinematic(t, Player(i))
            endfor 
            call TriggerAddCondition(t, Condition(function thistype.pressEsc))
            set t = null
            call RegisterArrowKeyEvent(function thistype.pressKey) 
        endmethod
        public static method create takes AHSS_Teams teams, AHSS_Heroes heroes, AHSS_Options options, AHSS_Paths paths returns thistype 
            local thistype this = 1 
            if this.dummy != null then 
                call this.destroy() 
            endif 
            set this = thistype.allocate()
            set this.teams = teams 
            set this.heroes = heroes 
            set this.options = options
            set this.paths = paths
            return this
        endmethod
        //------------------------------------------------------------------
        //------------------------------------------------------------------
        private static method start takes nothing returns nothing 
            local thistype this = 1
            local integer i 
            local integer j 
            local integer id 
            local integer index 
            for i = 0 to (this.teams.getSize() - 1) 
                for j = 0 to (this.teams.getTeam(i).getSize() - 1) 
                    set id = this.teams.getTeam(i).getPlayer(j) 
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING and (GetPlayerController(Player(id)) == MAP_CONTROL_USER or  (GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER and this.options.doesBotsPick())) then
                        set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        if this.selections[id].getColumn() == -1 or (this.heroesIcon[index] == null and not this.selectionUsed[id]) then 
                            call selectHeroRandom(this, id) 
                            set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        endif
                        set this.emptyIcon[index] = CreateDestructableZ(this.paths.getEmptyIcon(), GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                        call RemoveDestructable(this.heroesIcon[index]) 
                        set this.heroesIcon[index] = null
                        call CreateUnit(Player(id), this.heroes.getHero(index).getHeroid(), GetRectCenterX(this.teams.getTeam(i).getSpawningSpot()), GetRectCenterY(this.teams.getTeam(i).getSpawningSpot()), 270) 
                        call PanCameraToTimedForPlayer(Player(id), GetRectCenterX(this.teams.getTeam(i).getSpawningSpot()), GetRectCenterY(this.teams.getTeam(i).getSpawningSpot()), 0)
                    endif
                endfor
            endfor
            call this.destroy() 
        endmethod
        //------------------------------------------------------------------
        //------------------------------------------------------------------
        private static method hideSelection takes thistype this, integer playerid returns nothing 
            local integer i = playerid
            call SetUnitScale(this.selections[playerid].getUnit(), 0, 0, 0)  
            //! runtextmacro DESTROY_MODELS()
            //! runtextmacro DESTROY_STAT("str", "Str") 
            //! runtextmacro DESTROY_STAT("agi", "Agi")
            //! runtextmacro DESTROY_STAT("int", "Int")
        endmethod 
        private static method showSelection takes thistype this, integer playerid returns nothing 
            call SetUnitScale(this.selections[playerid].getUnit(), 1, 1, 1) 
        endmethod
        private static method createTeamIcon takes thistype this, integer playerid, integer index, boolean remove returns nothing 
            local integer i 
            local integer j 
            local real x 
            local real y
            for i = 0 to (this.teams.getSize() - 1)
                for j = 0 to (this.teams.getTeam(i).getSize() - 1) 
                    if this.teams.getTeam(i).getPlayer(j) == playerid then 
                        set x = GetDestructableX(this.teamsIcon[i].icons[j]) 
                        set y = GetDestructableY(this.teamsIcon[i].icons[j]) 
                        call RemoveDestructable(this.teamsIcon[i].icons[j]) 
                        if remove then 
                            set this.teamsIcon[i].icons[j] = CreateDestructable(this.heroes.getHero(index).getIcon(), x, y, 270, options.getIconScale()/2, 1) 
                        else
                            set this.teamsIcon[i].icons[j] = CreateDestructable(this.paths.getEmptyIcon(), x, y, 270, options.getIconScale()/2, 1) 
                        endif
                        return
                    endif
                endfor
            endfor
        endmethod
        private static method allReady takes thistype this returns boolean
            local integer i 
            local integer j 
            for i = 0 to (this.teams.getSize() - 1)
                for j = 0 to (this.teams.getTeam(i).getSize() - 1)
                    if GetPlayerController(Player(this.teams.getTeam(i).getPlayer(j))) == MAP_CONTROL_USER and GetPlayerSlotState(Player(this.teams.getTeam(i).getPlayer(j))) == PLAYER_SLOT_STATE_PLAYING then
                        if not selectionUsed[this.teams.getTeam(i).getPlayer(j)] then 
                            return false 
                        endif
                    endif
                endfor
            endfor
            return true
        endmethod
        private static method verifyStart takes thistype this returns nothing 
            if allReady(this) and not gameStarted then 
                call PauseTimer(timeLimitTimer)
                call TimerDialogDisplay(timeLimitTimerDialog, false)
                set gameStarted = true 
                set gameStartedTimer = CreateTimer() 
                call TimerStart(gameStartedTimer, 5.0, false, function thistype.start) 
                set gameStartedTimerDialog = CreateTimerDialogBJ(gameStartedTimer, "Game Starting...") 
                call TimerDialogDisplayBJ(true, gameStartedTimerDialog)
                call SetImageColor(backgroundImg, 100, 100, 100, 255)
            endif
        endmethod
        private static method selectHeroRandom takes thistype this, integer id returns nothing 
            local integer random
            local integer count = 0
            for random = 0 to (Configurations.MAX_SLOTS - 1) 
                if this.heroesIcon[random] != null then 
                    set count = count + 1
                endif
            endfor
            if count > 0 then   
                loop
                    set random = GetRandomInt(0, Configurations.MAX_SLOTS-1) 
                    exitwhen this.heroesIcon[random] != null 
                endloop
                call showHero(this, id, random) 
                call this.selections[id].setColumn(random/this.options.getIconsByLine()) 
                loop
                    exitwhen random < this.options.getIconsByLine() 
                    set random = random - this.options.getIconsByLine()
                endloop
                call this.selections[id].setRow(random) 
                call updateCursor(this, id)
                call pressEscActions(this, id)
            endif
        endmethod
        private static method pressEscActions takes thistype this, integer id returns boolean 
            local integer index
            if not gameStarted then
                if this.dummy != null and IsPlayerInForce(Player(id), cameraForce) then
                    if this.selections[id].getColumn() == -1 then 
                        call selectHeroRandom(this, id)
                    else
                        set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        if not selectionUsed[id] then
                            if this.heroesIcon[index] == null then 
                                if GetLocalPlayer() == GetTriggerPlayer() then
                                    call PlaySoundBJ(this.options.getSoundError()) 
                                endif
                                return false 
                            endif
                            if GetLocalPlayer() == GetTriggerPlayer() then 
                                call PlaySoundBJ(this.options.getSoundOk()) 
                            endif
                            set this.emptyIcon[index] = CreateDestructableZ(this.paths.getEmptyIcon(), GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                            call RemoveDestructable(this.heroesIcon[index])
                            set this.heroesIcon[index] = null
                            call RemoveDestructable(this.heroesIcon[index]) 
                            set selectionUsed[id] = true
                            call hideSelection(this, id)
                            call createTeamIcon(this, id, index, true)
                        else 
                            if GetLocalPlayer() == GetTriggerPlayer() then 
                                call PlaySoundBJ(this.options.getSoundOk()) 
                            endif
                            call showSelection(this, id)
                            call createTeamIcon(this, id, index, false)
                            set this.heroesIcon[index] = CreateDestructableZ(this.heroes.getHero(index).getIcon(), GetDestructableX(this.emptyIcon[index]), GetDestructableY(this.emptyIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                            call RemoveDestructable(this.emptyIcon[index]) 
                            set this.emptyIcon[index] = null 
                            call showHero(this, id, index)
                            set selectionUsed[id] = false
                        endif
                    endif
                    call verifyStart(this)
                endif
            endif
            return false 
        endmethod
        private static method pressEsc takes nothing returns boolean 
            local thistype this = 1 
            local integer index 
            local integer id = GetPlayerId(GetTriggerPlayer()) 
            call pressEscActions(this, id)
            return false
        endmethod
        private static method pressKey takes nothing returns nothing
            local thistype this = 1
            local integer playerid = GetEventArrowKeyPlayerId()
            local integer index 
            if this.dummy != null and this.selections[playerid] != 0 and IsPlayerInForce(Player(playerid), cameraForce) and IsEventArrowKeyPressed() and not selectionUsed[playerid] then
                call moveCursor(this, playerid)
                set index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
                call showHero(this, playerid, index) 
            endif
        endmethod 
        /*
        Move the selection to left
        */
        private static method moveLeft takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getRow() == 0 then 
                set i = 0 
                loop
                    exitwhen i >= (this.options.getIconsByLine()-1) or (this.emptyIcon[index+i] == null and this.heroesIcon[index+i] == null)
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow(i) 
            else 
                call this.selections[playerid].setRow(this.selections[playerid].getRow()-1)
            endif 
        endmethod
        /*
        Move the selection to right
        */
        private static method moveRight takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getRow() >= (this.options.getIconsByLine()-1) or (this.emptyIcon[index+1] == null and this.heroesIcon[index+1] == null) then 
                call this.selections[playerid].setRow(0) 
            else 
                call this.selections[playerid].setRow(this.selections[playerid].getRow()+1)
            endif 
        endmethod
        /*
        Move the selection downward
        */
        private static method moveDown takes thistype this, integer playerid, integer index returns nothing 
            local integer i
            if this.selections[playerid].getColumn() == -1 then 
                call this.selections[playerid].setColumn(0)
                set i = 0 
                loop
                    exitwhen i >= options.getIconsByLine() or (this.heroesIcon[i] == null and this.emptyIcon[i] == null) 
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow((i-1)/2)
            elseif this.emptyIcon[index+options.getIconsByLine()] == null and this.heroesIcon[index+options.getIconsByLine()] == null then 
                call this.selections[playerid].setColumn(-1)
            else
                call this.selections[playerid].setColumn(this.selections[playerid].getColumn()+1)
            endif
        endmethod
        /*
        Move the selection upward
        */
        private static method moveUp takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getColumn() == 0 then 
                call this.selections[playerid].setColumn(-1)
            elseif this.selections[playerid].getColumn() == -1 then 
                set i = 0 
                loop
                    exitwhen this.emptyIcon[i*options.getIconsByLine()] == null and this.heroesIcon[i*options.getIconsByLine()] == null 
                    set i = i + 1
                endloop
                call this.selections[playerid].setColumn(i-1)
                set i = 0 
                loop
                    exitwhen this.emptyIcon[this.selections[playerid].getColumn()*options.getIconsByLine()+i] == null and this.heroesIcon[this.selections[playerid].getColumn()*options.getIconsByLine()+i] == null 
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow((i-1)/2)
            else 
                call this.selections[playerid].setColumn(this.selections[playerid].getColumn()-1)
            endif 
        endmethod
        /*
        Update the selection box position
        */
        private static method updateCursor takes thistype this, integer playerid returns nothing 
            local integer index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
            local integer i 
            if this.selections[playerid].getColumn() == - 1 then 
                call this.selections[playerid].setPos(GetDestructableX(this.randomIcon), GetDestructableY(this.randomIcon)) 
            else 
                if this.emptyIcon[index] != null then 
                    call this.selections[playerid].setPos(GetDestructableX(this.emptyIcon[index]), GetDestructableY(this.emptyIcon[index])) 
                else 
                    call this.selections[playerid].setPos(GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index])) 
                endif 
            endif 
            if GetLocalPlayer() == Player(playerid) then 
                call PlaySoundBJ(this.options.getSoundClick()) 
            endif
        endmethod 
        /*
        Move the selection box for each Player
        */
        private static method moveCursor takes thistype this, integer playerid returns nothing 
            local integer index
            local integer i 
            set index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
            if GetEventArrowKey() == 0 then 
                call moveLeft(this, playerid, index)
            elseif GetEventArrowKey() == 1 then 
                call moveRight(this, playerid, index)
            elseif GetEventArrowKey() == 2 then 
                call moveDown(this, playerid, index)
            else 
                call moveUp(this, playerid, index)
            endif
            call updateCursor(this, playerid)
        endmethod 
        private static method countLines takes string s returns integer 
            local integer count = 0 
            local integer i 
            for i = 0 to StringLength(s) - 2
                if SubString(s, i, i+1) == "\n" then 
                    set count = count + 1
                endif
            endfor 
            return count 
        endmethod 
        /*
        Show select hero information o screen
        */
        private static method showHero takes thistype this, integer playerid, integer index returns nothing
            local real x
            local real y
            local integer i = playerid
            //-------------------------------------------------------------------
            //! textmacro STAT_TEXT takes stat Stat 
            set x = GetDestructableX(this.$stat$Icon[playerid]) + 50
            set y = GetDestructableY(this.$stat$Icon[playerid]) - 15
            set this.$stat$Text[playerid] = CreateTextTag()  
            call SetTextTagText(this.$stat$Text[playerid], this.heroes.getHero(index).get$Stat$(), TextTagSize2Height(13))
            call SetTextTagPos(this.$stat$Text[playerid], x, y, 0)
            call SetTextTagColor(this.$stat$Text[playerid], 255, 255, 255, 255)
            if GetLocalPlayer() != Player(playerid) then 
                if this.$stat$Text[playerid] != null then 
                    call SetTextTagVisibility(this.$stat$Text[playerid], false) 
                endif 
                if this.$stat$Icon[playerid] != null then 
                    call ShowDestructable(this.$stat$Icon[playerid], false) 
                endif
            endif
            //! endtextmacro
            //! textmacro DESTROY_STAT takes stat Stat 
            if this.$stat$Icon[i] != null then 
                call RemoveDestructable(this.$stat$Icon[i])
                set this.$stat$Icon[i] = null 
            endif 
            if this.$stat$Text[i] != null then 
                call DestroyTextTag(this.$stat$Text[i]) 
                set this.$stat$Text[i] = null
            endif 
            //! endtextmacro 
            //! textmacro DESTROY_MODELS 
            if this.heroesModels[i] != null then
                call RemoveUnit(this.heroesModels[i])
                set this.heroesModels[i] = null
            endif
            if this.heroesName[i] != null then 
                call DestroyTextTag(this.heroesName[i]) 
                set this.heroesName[i] = null
            endif
            if this.descriptionText[i] != null then 
                call DestroyTextTag(this.descriptionText[i]) 
                set this.descriptionText[i] = null 
            endif
            //! endtextmacro
            //-------------------------------------------------------------------
            //! runtextmacro DESTROY_MODELS()
            //! runtextmacro DESTROY_STAT("str", "Str") 
            //! runtextmacro DESTROY_STAT("agi", "Agi")
            //! runtextmacro DESTROY_STAT("int", "Int")
            if this.heroesIcon[index] != null then 
                //CREATE THE UNIT
                set x = GetUnitX(dummy) 
                set y = GetUnitY(dummy) - 100
                set this.heroesModels[playerid] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), this.heroes.getHero(index).getDummyid(), x, y, 180) 
                call UnitAddAbility(this.heroesModels[playerid], 'Arav') 
                call UnitRemoveAbility(this.heroesModels[playerid], 'Arav') 
                call SetUnitFlyHeight(this.heroesModels[playerid], 100, 0) 
                call SetUnitAnimation(this.heroesModels[playerid], this.heroes.getHero(index).getAnimation())
                //CREATE HERO NAME
                set x = x + 600
                set y = y + 500
                set this.heroesName[playerid] = CreateTextTag()  
                call SetTextTagText(this.heroesName[playerid], this.heroes.getHero(index).getName(), TextTagSize2Height(16))
                call SetTextTagPos(this.heroesName[playerid], x, y, 0)
                call SetTextTagColor(this.heroesName[playerid], 255, 255, 255, 255)
                //CREATE STATS INFO
                set y = y - 100 
                set this.strIcon[playerid] = CreateDestructable(this.paths.getStrIcon(), x, y, 270, this.options.getIconScale(), 1) 
                set y = y - ICON_SIZE * this.options.getIconScale() - 10 
                set this.agiIcon[playerid] = CreateDestructable(this.paths.getAgiIcon(), x, y, 270, this.options.getIconScale(), 1) 
                set y = y - ICON_SIZE * this.options.getIconScale() - 10 
                set this.intIcon[playerid] = CreateDestructable(this.paths.getIntIcon(), x, y, 270, this.options.getIconScale(), 1) 
                //! runtextmacro STAT_TEXT("str", "Str")
                //! runtextmacro STAT_TEXT("agi", "Agi")
                //! runtextmacro STAT_TEXT("int", "Int")
                //CREATE HERO INFO 
                set x = x - 100
                set y = y - 200 - (20 * countLines(this.heroes.getHero(index).getDescription()))
                set this.descriptionText[playerid] = CreateTextTag()  
                call SetTextTagText(this.descriptionText[playerid], this.heroes.getHero(index).getDescription(), TextTagSize2Height(10))
                call SetTextTagPos(this.descriptionText[playerid], x, y, 0)
                call SetTextTagColor(this.descriptionText[playerid], 255, 255, 255, 255)
                //HIDE INFO FROM OTHER PLAYERS
                if GetLocalPlayer() != Player(playerid) then 
                    if this.heroesName[playerid] != null then 
                        call SetTextTagVisibility(this.heroesName[playerid], false) 
                    endif 
                    if this.descriptionText[playerid] != null then 
                        call SetTextTagVisibility(this.descriptionText[playerid], false) 
                    endif 
                    if this.heroesModels[playerid] != null then 
                        call SetUnitVertexColor(this.heroesModels[playerid], 255, 255, 255, 0)
                    endif
                endif
            endif 
        endmethod
        //"Lock" the camera so the player can't avoid it :)
        private static method loopCamera takes nothing returns nothing 
            local thistype this = 1
            local Configurations c = Configurations.create()
            local integer i 
            for i = 0 to 11 
                if IsPlayerInForce(Player(i), cameraForce) then 
                    call CameraSetupApplyForceDuration(c.CAMERA, true, 0)
                    call SetCameraTargetController(this.dummy, 0, 0, false)
                endif 
            endfor
            call c.destroy()
        endmethod
        private method createCamera takes nothing returns nothing 
            local integer i = 0 
            local Configurations c = Configurations.create()
            call PanCameraToTimed(GetRectCenterX(c.INITIAL_AREA), GetRectCenterY(c.INITIAL_AREA), 0) 
            if dummy == null then
                set dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), Configurations.DUMMY_ID, GetRectCenterX(c.INITIAL_AREA), GetRectCenterY(c.INITIAL_AREA), 0)
            endif
            set cameraForce = CreateForce() 
            for i = 0 to 11 
                call ForceAddPlayer(cameraForce, Player(i)) 
                set modifier[i] = CreateFogModifierRectBJ(true, Player(i), FOG_OF_WAR_VISIBLE, gg_rct_SELECTION_AREA)
            endfor
            set cameraTimer = CreateTimer()
            call TimerStart(cameraTimer, 0.01, true, function thistype.loopCamera) 
            call c.destroy()
        endmethod
        private method createHeroesIcon takes nothing returns nothing 
            local integer i 
            for i = 0 to (heroes.getSize() - 1)
                set heroesIcon[i] = CreateDestructableZ(heroes.getHero(i).getIcon(), GetDestructableX(emptyIcon[i]), GetDestructableY(emptyIcon[i]), 250, 270, options.getIconScale(), 1) 
                call RemoveDestructable(emptyIcon[i]) 
                set emptyIcon[i] = null
            endfor 
        endmethod 
        private method createTeamsIcon takes nothing returns nothing 
            local real iconSize = ICON_SIZE * (options.getIconScale() / 2)
            local real x 
            local real y = GetUnitY(dummy) + 500 
            local integer i
            local integer j 
            for i = 0 to (teams.getSize() - 1)
                set teamsIcon[i] = TeamIcon.create()
                set y = y - (ICON_SIZE * options.getIconScale()/2) - iconSize
                set x = GetUnitX(dummy) - 950
                for j = 0 to (teams.getTeam(i).getSize() - 1)   
                    set teamsIcon[i].icons[j] = CreateDestructable(paths.getEmptyIcon(), x, y, 270, options.getIconScale()/2, 1) 
                    set x = x + iconSize 
                endfor 
            endfor 
        endmethod
        private method createEmptyIcons takes nothing returns nothing 
            local integer count = Configurations.MAX_SLOTS
            local integer iconsByLine = options.getIconsByLine()
            local real scale = 1.5
            local real iconSize = ICON_SIZE * options.getIconScale()
            local real x 
            local real y = GetUnitY(dummy) 
            local integer row = 0 
            local integer i 
            loop
                exitwhen count < iconsByLine
                set x = GetUnitX(dummy) - ((iconSize * iconsByLine)/2)
                for i = 0 to (iconsByLine - 1)
                    set emptyIcon[row * iconsByLine + i] = CreateDestructableZ(paths.getEmptyIcon(), x, y, 250, 270, scale, 1)
                    set x = x + iconSize
                endfor
                set y = y - iconSize
                set row = row + 1
                set count = count - iconsByLine
            endloop
            set x = GetUnitX(dummy) - ((iconSize * count)/2) 
            for i = 0 to (count - 1) 
                set emptyIcon[row * iconsByLine + i] = CreateDestructableZ(paths.getEmptyIcon(), x, y, 250, 270, scale, 1) 
                set x = x + iconSize 
            endfor
            if count > 0 then
                set y = y - iconSize
            endif
            set x = GetUnitX(dummy) - (iconSize/2)
            set randomIcon = CreateDestructableZ(paths.getRandomIcon(), x, y, 250, 270, scale, 1) 
        endmethod 
        private method createImages takes nothing returns nothing 
            if backgroundImg == null then
                set backgroundImg = CreateImage(paths.getBackground(), 2200, 1800, 1800, GetUnitX(dummy), GetUnitY(dummy), 0, 1100, 900, 900, 2)
                call SetImageRenderAlways(backgroundImg, true)
            endif
            if logoImg == null then 
                set logoImg = CreateDestructable(paths.getLogo(), GetUnitX(dummy), GetUnitY(dummy) + 350, 270, 6.0, 1)  
            endif
            call createEmptyIcons()
            call createTeamsIcon()
            call createHeroesIcon()
        endmethod
        private method createTexts takes nothing returns nothing 
            local real x = GetUnitX(dummy) - 1000
            local real y = GetUnitY(dummy) + 550
            local integer i 
            for i = 0 to (teams.getSize() - 1)
                set y = y - (64 * options.getIconScale()) - 10 
                set teamsText[i] = CreateTextTag()  
                call SetTextTagText(teamsText[i], teams.getTeam(i).getName(), TextTagSize2Height(12))
                call SetTextTagPos(teamsText[i], x, y, 0)
                call SetTextTagColor(teamsText[i], 255, 255, 255, 255) 
            endfor
        endmethod
        private method createSelections takes nothing returns nothing 
            local integer i
            local integer j
            local real x 
            local real y 
            local integer count = 0 
            local integer id 
            if emptyIcon[0] != null then 
                set x = GetDestructableX(emptyIcon[0]) 
                set y = GetDestructableY(emptyIcon[0])
            else 
                set x = GetDestructableX(heroesIcon[0]) 
                set y = GetDestructableY(heroesIcon[0]) 
            endif
            for i = 0 to (teams.getSize() - 1) 
                for j = 0 to (teams.getTeam(i).getSize() - 1) 
                    set id = teams.getTeam(i).getPlayer(j) 
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
                        if GetPlayerController(Player(id)) == MAP_CONTROL_USER or (GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER and options.doesBotsPick()) then 
                            if teams.getTeam(i).getPlayer(j) == 0 then 
                                set selections[teams.getTeam(i).getPlayer(j)] = PlayerSelection.create(0, paths.getSelection(), x, y, 1.00, 0.01, 0.01)
                            //! textmacro COND takes ID RED BLUE GREEN
                            elseif teams.getTeam(i).getPlayer(j) == $ID$ then 
                                set selections[teams.getTeam(i).getPlayer(j)] = PlayerSelection.create($ID$, paths.getSelection(), x, y, $RED$, $BLUE$, $GREEN$)
                            //! endtextmacro
                            //! runtextmacro COND("1", "0.00","0.25","1.00")
                            //! runtextmacro COND("2", "0.09","0.90","0.70")
                            //! runtextmacro COND("3", "0.32","0.00","0.50")
                            //! runtextmacro COND("4", "1.00","0.98","0.40")
                            //! runtextmacro COND("5", "0.99","0.72","0.05")
                            //! runtextmacro COND("6", "0.12","0.75","0.00")
                            //! runtextmacro COND("7", "0.89","0.35","0.69")
                            //! runtextmacro COND("8", "0.58","0.58","0.58")
                            //! runtextmacro COND("9", "0.49","0.74","0.94")
                            //! runtextmacro COND("10","0.06","0.38","0.27")
                            //! runtextmacro COND("11","0.30","0.16","0.01")
                            endif
                        endif
                    endif
                    set count = count + 1
                endfor
            endfor
        endmethod
        public method draw takes boolean allRandom returns nothing 
            local integer i 
            local integer j 
            local integer id
            call createCamera()
            call createImages()
            call createTexts()
            call createSelections()
            for i = 0 to (this.teams.getSize() - 1)
                for j = 0 to (this.teams.getTeam(i).getSize() - 1)
                    set id = this.teams.getTeam(i).getPlayer(j)
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
                        if GetPlayerController(Player(id)) == MAP_CONTROL_USER then
                            if allRandom then 
                                call thistype.selectHeroRandom(this, id)
                            else
                                call showHero(this, i, 0)
                            endif
                        else
                            if this.options.doesBotsPick() then 
                                call thistype.selectHeroRandom(this, id)
                            endif
                        endif
                    endif
                endfor
            endfor
            if options.isTimeLimited() then 
                set timeLimitTimer = CreateTimer()
                call TimerStart(timeLimitTimer, options.getTimeLimit(), false, function thistype.start) 
                set timeLimitTimerDialog = CreateTimerDialogBJ(timeLimitTimer, "Time to pick")
                call TimerDialogDisplay(timeLimitTimerDialog, true)
            endif
        endmethod
        public method destroy takes nothing returns nothing 
            local integer i 
            if dummy != null then 
                call RemoveUnit(dummy)
                set dummy = null 
            endif 
            //if backgroundImg != null then 
                call ShowImage(backgroundImg, false)
                call DestroyImage(backgroundImg) 
            //endif
            if logoImg != null then 
                call RemoveDestructable(logoImg)
                set logoImg = null
            endif
            for i = 0 to (Configurations.MAX_SLOTS - 1) 
                if emptyIcon[i] != null then 
                    call RemoveDestructable(emptyIcon[i])
                    set emptyIcon[i] = null
                endif
                if heroesIcon[i] != null then 
                    call RemoveDestructable(heroesIcon[i]) 
                    set heroesIcon[i] = null 
                endif 
            endfor
            if randomIcon != null then 
                call RemoveDestructable(randomIcon)
                set randomIcon = null
            endif 
            for i = 0 to 11 
                if selections[i] != 0 then 
                    call selections[i].destroy() 
                endif 
                if modifier[i] != null then 
                    call FogModifierStop(modifier[i])
                    call DestroyFogModifier(modifier[i]) 
                    set modifier[i] = null
                endif
                //! runtextmacro DESTROY_MODELS()
                //! runtextmacro DESTROY_STAT("str", "Str") 
                //! runtextmacro DESTROY_STAT("agi", "Agi")
                //! runtextmacro DESTROY_STAT("int", "Int")
            endfor
            for i = 0 to (teams.getSize() - 1) 
                call teamsIcon[i].destroy()
                call DestroyTextTag(teamsText[i])
                set teamsText[i] = null
            endfor
            if cameraTimer != null then 
                call PauseTimer(cameraTimer)
                call DestroyTimer(cameraTimer) 
            endif
            if gameStartedTimer != null then 
                call PauseTimer(gameStartedTimer) 
                call DestroyTimer(gameStartedTimer) 
                set gameStartedTimer = null 
            endif 
            if gameStartedTimerDialog != null then 
                call TimerDialogDisplay(gameStartedTimerDialog, false)
                call DestroyTimerDialog(gameStartedTimerDialog) 
                set gameStartedTimerDialog = null 
            endif
            if timeLimitTimer != null then 
                call PauseTimer(timeLimitTimer) 
                call DestroyTimer(timeLimitTimer) 
                set timeLimitTimer = null 
            endif 
            if timeLimitTimerDialog != null then 
                call TimerDialogDisplay(timeLimitTimerDialog, false)
                call DestroyTimerDialog(timeLimitTimerDialog) 
                set timeLimitTimerDialog = null 
            endif
            call DestroyForce(cameraForce) 
            call teams.destroy() 
            call heroes.destroy() 
            call options.destroy() 
            call paths.destroy()
            set cameraTimer = null
            set cameraForce = null
        endmethod
    endstruct
    
endscope
 

Attachments

  • AHSS_1.0(2).w3x
    400.9 KB · Views: 93
  • error.png
    error.png
    17.7 KB · Views: 291
Yeah, just change the part in the error message to this:

JASS:
public method destroy takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i == count-1
        call teams[i].destroy()
        set i = i + 1
    endloop
endmethod

EDIT: Actually, every loop in the script uses the cJass approach. There is quite a lot that needs rewriting i don't have time for right now.
 
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
540
Yeah, just change the part in the error message to this:

JASS:
public method destroy takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i == count-1
        call teams[i].destroy()
        set i = i + 1
    endloop
endmethod

EDIT: Actually, every look in the script uses the cJass approach. There is quite a lot that needs rewriting i don't have time for right now.

Not cJass as far as i can see but the updated jasshelper from cohadar. You can download it and replace your current jasshelper.exe with it or download that new JNGP from moyack where it already is included.
 
Level 5
Joined
Jul 25, 2008
Messages
126
Not cJass as far as i can see but the updated jasshelper from cohadar. You can download it and replace your current jasshelper.exe with it or download that new JNGP from moyack where it already is included.

I have JNGP 1.5e, it does work with cohaders jasshelper however all of my other scripts use vexorians jasshelper, so I need this system to be compatible with vexorian.

@Fingolfin, will you be able to do this when you get the time?
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
540
I have JNGP 1.5e, it does work with cohaders jasshelper however all of my other scripts use vexorians jasshelper, so I need this system to be compatible with vexorian.

But every script that worked w/ vexorians jasshelper should also work w/ cohadars…

@Fingolfin, will you be able to do this when you get the time?

haha lolwat, he already showed you the pattern to translate this (even though as stated above it should not be neccessary).
JASS:
public method destroy takes nothing returns nothing 
    local integer i 
    for i = 0 to (count - 1) 
        call teams[i].destroy() 
    endfor 
endmethod

public method destroy takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i == count-1
        call teams[i].destroy()
        set i = i + 1
    endloop
endmethod

Observe how the code changed and apply it to every error.
 
Level 5
Joined
Jul 25, 2008
Messages
126
I attempted to follow the pattern (not sure if I did more damage to it) get an error
'Line 696 : member redeclared : create' . If 1.5e the version you were refering to because I tried enabling cohader and many systems produced errors. I asked before because my vJass is not all that great.
JASS:
/*
==============================================================
ANIME HERO SELECTION SYSTEM v1.0
--------------------------------------------------------------
Created by: 
    IncendiaryMonkey ([email protected])
For more systems like that, visit:
    [url]http://www.warcraftmule.blogspot.com[/url]
--------------------------------------------------------------
REQUIRES:
    - Arrow Event Key ([url]http://www.hiveworkshop.com/forums/jass-resources-412/system-arrowkeyevent-205650/[/url])
--------------------------------------------------------------
Instructions below. You can use this selection screen at any moment 
by calling the "custom script" code on a trigger:
    call AHSS_Configurations.start(all_random)
"all_random" can be true or false. 
*/
scope AHSS 
    //--------------------------------------------------------
    // CONFIGURATIONS
    //--------------------------------------------------------
    public struct Configurations
        public static constant integer DUMMY_ID  = 'hss1'                //Object id of an invisible dummy
        public static constant integer MAX_SLOTS = 30                    //Max number of slots for heroes 
        public rect INITIAL_AREA = gg_rct_SELECTION_AREA                 //This is a region where the screen will be displayed
                                                                         //Preferentially it must be isolated
        public camerasetup CAMERA = gg_cam_Camera_001                    //This camera is applied to make screen more planar
                                                                         //The naming is: "gg_cam_" + Camera name, where spaces are replaced by underline (_)
        
        public static method init takes nothing returns nothing
            //-----------------------------------------------------------------
            //ATTENTION: THE ORDER OF FUNCTION CALLS MUST BE RESPECTED! 
            //I.e, you can't call "teams.addPlayer()" before "teams.createTeam()".
            
            //---------------------------------------------------------------------------------
            // TEAMS SECTION
            //---------------------------------------------------------------------------------
            //Here you configure the teams. Just insert user controller players.
            //Remember: 0 = Red, 1 = Blue, and so on. 
            call teams.createTeam("Team 1") 
            call teams.addPlayer(0)
            call teams.addPlayer(1)
            call teams.addPlayer(2)
            call teams.setSpawningSpot(gg_rct_TEAM_1_SPOT) //Here you define a region to where the heroes of this team will go when picked. 
                                                           //If you don't understand the naming, all regions have to have "gg_rct_" in front of 
                                                           //their name and spaces are replaced by underline (_).
            call teams.createTeam("Team 2")
            call teams.addPlayer(4)
            call teams.addPlayer(5)
            call teams.addPlayer(6)
            call teams.setSpawningSpot(gg_rct_TEAM_2_SPOT)
            
            call teams.createTeam("Team 3")
            call teams.addPlayer(8)
            call teams.addPlayer(9)
            call teams.addPlayer(10)
            call teams.setSpawningSpot(gg_rct_TEAM_3_SPOT)
            
            //---------------------------------------------------------------------------------
            // HEROES SECTION
            //---------------------------------------------------------------------------------
            //Here you add heroes to selection. Follow the template.
            call heroes.addHero("Paladin", 'Hpal') //'Hpal' representates the object id of the hero. To discover it, go to Object Editor and presses CTRL+D
            call heroes.setStr("22 + 2.70") 
            call heroes.setAgi("13 + 1.50")
            call heroes.setInt("17 + 1.80")
            call heroes.setDescription("Warrior Hero, exceptional at defense and augmenting nearby friendly troops.\n\n1. Holy Light\n2. Divine Shield\n3. Devotion Aura\n4. Ressurrection")
            call heroes.setModel('xu01', "spell") //Here you define an unit id to representates graphically the hero on selection screen. 
                                                  //The second parameter is the animation tag that the unit will display when the hero is selected.
            call heroes.setIcon('xd01') //Icons are represented by a destructable
                                                                                           
            call heroes.addHero("Archmage", 'Hamg')
            call heroes.setStr("14 + 1.80")
            call heroes.setAgi("17 + 1.00")
            call heroes.setInt("19 + 3.20")
            call heroes.setDescription("Mystical Hero, adept at ranged assaults.\n\n1. Blizzard\n2. Summon Water Elemental\n3. Brilliance Aura\n4. Mass Teleport\n")
            call heroes.setModel('xu02', "spell") 
            call heroes.setIcon('xd02')

            call heroes.addHero("Mountain King", 'Hmkg') 
            call heroes.setStr("24 + 3.00")
            call heroes.setAgi("11 + 1.50")
            call heroes.setInt("15 + 1.50")
            call heroes.setDescription("Warrior Hero, adept at offensive combat and disrupting enemy troops.\n\n1. Storm Bolt\n 2. Thunder clap\n3. Bash\n4. Avatar")
            call heroes.setModel('xu03', "spell")
            call heroes.setIcon('xd03')
            
            call heroes.addHero("Blood Mage", 'Hblm') 
            call heroes.setStr("18 + 2.00")
            call heroes.setAgi("14 + 1.00")
            call heroes.setInt("19 + 3.00")
            call heroes.setDescription("Mystical Hero, adept at controlling magic and ranged assaults.\n\n1. Flame Strike\n2. Banish\n3. Siphon Mana\n4. Phoenix")
            call heroes.setModel('xu04', "spell")
            call heroes.setIcon('xd04')
            
            //---------------------------------------------------------------------------------
            // OPTIONS SECTION
            //---------------------------------------------------------------------------------
            //Here you configurate severals options of the system.
            call options.timeLimit(true, 60.0) //If "true", the players have a limited time to pick a hero. The time is given in seconds.
            call options.botsPick(true) //Computer players pick heros too? 
            
            call options.setIconScale(1.5) //Size of heroes icons. Not recommended to change.
            call options.setIconsByLine(10) //Set the amount of heroes icons by row
            
            call options.setSoundClick(gg_snd_MouseClick1) //This sound is played when selection changes 
            call options.setSoundError(gg_snd_Error) //This sound is played when an invalid action is perfomed
            call options.setSoundOk(gg_snd_BigButtonClick) //This sound is played when you confirm a hero selection
            
            //---------------------------------------------------------------------------------
            // FILE PATHS SECTION
            //---------------------------------------------------------------------------------
            call paths.setBackground("war3mapImported\\AHSS_Background.blp") //Background of selection screen
            call paths.setSelection('hss2') //The selection square above hero icon. It's the single one that it's an unit.
            call paths.setEmptyIcon('hss3') //Icon that is display in the absence of a hero. It's a destructable. 
            call paths.setRandomIcon('hss4') //Icon for random selection. 
            call paths.setStrIcon('hss5') //Icon to display beside the hero strength. 
            call paths.setAgiIcon('hss6') 
            call paths.setIntIcon('hss7')
            call paths.setLogo('hss8') //This is displayed on top-center
            
            //---------------------------------------------------------------------------------
            // OBJECT CREATION SECTION
            //---------------------------------------------------------------------------------
            ///* //<------ REMOVE TWO BACKSLASHES IN THE BEGINNING OF THIS LINE WHEN READY
            //On the 'blue block' below you can create automatically units or doodads on Object Editor.
            //You just need to run it once, but everytime you want create something else you have to run all it again.
            //After you run this block you must comment all this block by removing double slash on indicated lines.
            //Caution with object ids. Two objects with the same id will be replaced by the newest.
            
            //! externalblock extension=lua ObjectMerger $FILENAME$
                //! runtextmacro CREATE_OBJECTS()
                //---------------------------------------------------------------------------------
                // DEFAULT OBJECTS
                //---------------------------------------------------------------------------------
                // Those are default objects required for system operation.
                //! i createDummy("AHSS_DUMMY", "hss1", "", 1.0)   
                //! i createDummy("AHSS_SELECTION", "hss2", "war3mapImported\\AHSS_Selection.mdx", 1.0) 
                //! i createDestructable("AHSS_EMPTY_ICON", "hss3", "war3mapImported\\AHSS_Empty_Icon.blp")
                //! i createDestructable("AHHS_RANDOM_ICON", "hss4", "war3mapImported\\AHSS_Random_Icon.blp")
                //! i createDestructable("AHHS_STR_ICON", "hss5", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-str.blp")
                //! i createDestructable("AHHS_AGI_ICON", "hss6", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-agi.blp")
                //! i createDestructable("AHHS_INT_ICON", "hss7", "UI\\Widgets\\Console\\Human\\infocard-heroattributes-int.blp")
                //! i createDestructable("AHHS_LOGO", "hss8", "war3mapImported\\AHSS_Logo.blp")
                //---------------------------------------------------------------------------------
                // CUSTOM OBJECTS 
                //---------------------------------------------------------------------------------
                // Those are objects used by the heroes
                //---------------------------------------------------------------------------------
                // MODELS
                //---------------------------------------------------------------------------------
                //The lines below creates units on Object Editor with the name, object id, model and scale defined, respectively.
                //! i createUnit("AHSS_PALADIN_DUMMY", "xu01", "units\\human\\HeroPaladin\\HeroPaladin", 3.0) 
                //! i createUnit("AHSS_ARCHMAGE_DUMMY", "xu02", "units\\human\\HeroArchMage\\HeroArchMage", 3.0)
                //! i createUnit("AHSS_MOUNTAIN_KING_DUMMY", "xu03", "units\\human\\HeroMountainKing\\HeroMountainKing", 3.0)
                //! i createUnit("AHSS_BLOOD_MAGE_DUMMY", "xu04", "units\\human\\HeroBloodElf\\HeroBloodElf", 3.0)
                //---------------------------------------------------------------------------------
                // ICONS
                //---------------------------------------------------------------------------------
                //The lines below creates a destructable on Object Editor with name, object id and texture defined, respectively. 
                //! i createDestructable("AHSS_PALADIN_ICON", "xd01", "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin.blp")
                //! i createDestructable("AHSS_ARCHMAGE_ICON", "xd02", "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage.blp") 
                //! i createDestructable("AHSS_MOUNTAING_KING_ICON", "xd03", "ReplaceableTextures\\CommandButtons\\BTNHeroMountainKing.blp")
                //! i createDestructable("AHSS_BLOOD_MAGE_ICON", "xd04", "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince.blp")
            //! endexternalblock
            //*/ //<------ REMOVE TWO BACKSLASHES IN THE BEGINNING OF THIS LINE WHEN READY
        endmethod
        //--------------------------------------------------------
        // END OF CONFIGURATIONS
        //--------------------------------------------------------
        //! textmacro CREATE_OBJECTS 
            //! i function createDummy(name, id, model, scale)
                //! i setobjecttype("units")
                //! i createobject("hpea", id)
                //! i makechange(current,"uabi","Aloc,Avul")
                //! i makechange(current,"umdl",model)
                //! i makechange(current,"usca",scale)
                //! i makechange(current,"ushu","")
                //! i makechange(current,"ufoo",0)
                //! i makechange(current,"unam",name)
                //! i makechange(current,"ucol",0)
                //! i makechange(current,"utyp","")
                //! i makechange(current,"uble",0)
                //! i makechange(current,"ucbs",0)
                //! i makechange(current,"ucpt",0)
                //! i makechange(current,"urun",0)
                //! i makechange(current,"uwal",0)
                //! i makechange(current,"umxp",0)
                //! i makechange(current,"umxr",0)
            //! i end
            //! i function createUnit(name, id, model, scale)
                //! i createDummy(name, id, model, scale)
                //! i makechange(current,"umxp",-285)
                //! i makechange(current,"umxr",-90)
                //! i makechange(current,"usca",3.0)
            //! i end
            //! i function createDestructable(name, id, path) 
                //! i setobjecttype("destructables")
                //! i createobject("YTlb", id) 
                //! i makechange(current,"bfil","war3mapImported\\AHSS_Button.mdx")
                //! i makechange(current,"boch",0)
                //! i makechange(current,"btxf",path) 
                //! i makechange(current,"btxi",31)
                //! i makechange(current,"bsel",0)
                //! i makechange(current,"bgsc",0)
                //! i makechange(current,"bshd","")
                //! i makechange(current,"btar","")
                //! i makechange(current,"bcpr",false)
                //! i makechange(current,"bcpd",false) 
                //! i makechange(current,"buch",false)
                //! i makechange(current,"bptx","")
                //! i makechange(current,"bnam",name)
            //! i end
        //! endtextmacro
        public static AHSS_Teams teams
        public static AHSS_Heroes heroes 
        public static AHSS_Options options 
        public static AHSS_Paths paths 
        public static AHSS_Graphics graphics
        private static method onInit takes nothing returns nothing 
            set teams = AHSS_Teams.create()
            set heroes = AHSS_Heroes.create()
            set options = AHSS_Options.create()
            set paths = AHSS_Paths.create() 
            set graphics = AHSS_Graphics.create(teams, heroes, options, paths)
            call thistype.init()
        endmethod
        public static method start takes boolean allRandom returns nothing 
            call graphics.draw(allRandom)
        endmethod
    endstruct
    /*============================================================
    * DATA STRUCT SECTION
    *-------------------------------------------------------------
    * This section contains structs that armazenates data only.
    *=============================================================*/
    /*----------------------------------------------------------
    *This class stores all informations about teams
    *----------------------------------------------------------*/
    private struct Team 
        private string name 
        private integer array players[12] 
        private integer count 
        private rect spawningSpot
        public static method create takes string name returns thistype 
            local thistype this = thistype.allocate()
            set this.name = name 
            set this.count = 0 
            return this
        endmethod 
        public method addPlayer takes integer whichPlayer returns nothing 
            set players[count] = whichPlayer 
            set count = count + 1
        endmethod 
        public method setSpawningSpot takes rect whichRect returns nothing 
            set spawningSpot = whichRect 
        endmethod
        public method getName takes nothing returns string 
            return name
        endmethod
        public method getPlayer takes integer index returns integer 
            return players[index] 
        endmethod
        public method getSpawningSpot takes nothing returns rect 
            return spawningSpot 
        endmethod
        /*
        Get the quantify of players inside this team 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class stores manages all the teams in selection screen
    *----------------------------------------------------------*/
    public struct Teams
        private Team array teams[12]
        private integer count 
        public static method create takes nothing returns thistype 
            local thistype this = thistype.allocate()
            set this.count = 0 
            return this 
        endmethod
        /*
        Create a team of determined name 
        */
        public method createTeam takes string name returns nothing  
            set teams[count] = Team.create(name) 
            set count = count + 1
        endmethod
        /*
        Add a player to the lastest created team 
        */
        public method addPlayer takes integer whichPlayer returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: addPlayer to a team that doesn't exist.") 
                return 
            endif
            call teams[count - 1].addPlayer(whichPlayer) 
        endmethod
        /*
        Set the spawning spot of the lastest created team 
        */
        public method setSpawningSpot takes rect whichRect returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setSpawningSpot to a team that doesn't exist.")
                return 
            endif 
            call teams[count - 1].setSpawningSpot(whichRect)
        endmethod
        /*
        Get a team by index 
        */
        public method getTeam takes integer index returns Team 
            return teams[index] 
        endmethod
        /*
        Get the quantify of teams created 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
        /*
        Destroy all teams 
        */ 
        public method destroy takes nothing returns nothing
            local integer i = 0
            loop
                exitwhen i == count-1
                call teams[i].destroy()
                set i = i + 1
            endloop
        endmethod
    
    /*----------------------------------------------------------
    *This class stores all informations about heroes 
    *----------------------------------------------------------*/
    private struct Hero 
        private string name 
        private string strength
        private string agility
        private string intelligence
        private string description
        private integer heroid
        private integer dummyid
        private string animation 
        private integer icon 
        public static method create takes string whichName, integer heroId returns thistype 
            local thistype this = thistype.allocate()
            set this.name = whichName 
            set this.strength = ""
            set this.agility = ""
            set this.intelligence = "" 
            set this.description = ""
            set this.heroid = heroId 
            set this.dummyid = Configurations.DUMMY_ID
            set this.animation = "stand"
            set this.icon = 'OTip'
            return this 
        endmethod
        public method setStr takes string whichStr returns nothing 
            set strength = whichStr
        endmethod 
        public method setAgi takes string whichAgi returns nothing 
            set agility = whichAgi 
        endmethod
        public method setInt takes string whichInt returns nothing 
            set intelligence = whichInt 
        endmethod
        public method setDescription takes string whichDescription returns nothing 
            set description = whichDescription 
        endmethod
        public method setModel takes integer whichDummyId, string whichAnimatin returns nothing 
            set dummyid = whichDummyId
            set animation = whichAnimatin 
        endmethod
        public method setIcon takes integer whichIcon returns nothing 
            set icon = whichIcon 
        endmethod
        public method getName takes nothing returns string 
            return name 
        endmethod
        public method getStr takes nothing returns string 
            return strength 
        endmethod
        public method getAgi takes nothing returns string 
            return agility 
        endmethod 
        public method getInt takes nothing returns string 
            return intelligence 
        endmethod
        public method getDescription takes nothing returns string 
            return description 
        endmethod
        public method getHeroid takes nothing returns integer 
            return heroid
        endmethod
        /*
        "Dummyid" is the unit that serves as model to a hero.
        */
        public method getDummyid takes nothing returns integer 
            return dummyid 
        endmethod
        /*
        "Animation" is the animation that the dummy plays when the hero is selected 
        */
        public method getAnimation takes nothing returns string 
            return animation 
        endmethod
        public method getIcon takes nothing returns integer 
            return icon 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class manages all heroes in selection screen 
    ----------------------------------------------------------*/
    public struct Heroes 
        private Hero array heroes[Configurations.MAX_SLOTS]
        private integer count 
        public static method create takes nothing returns thistype 
            local thistype this = thistype.allocate()
            set this.count = 0 
            return this 
        endmethod
        /*
        Add a hero to selection screen 
        */
        public method addHero takes string name, integer id returns nothing 
            if count >= Configurations.MAX_SLOTS then
                debug call BJDebugMsg("WARNING: addHero: Quantify of heroes already reached maximum slots.") 
                return 
            endif
            set heroes[count] = Hero.create(name, id) 
            set count = count + 1
        endmethod
        /*
        Set the strength of the lastest created hero 
        */
        public method setStr takes string whichStr returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setStr to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setStr(whichStr) 
        endmethod
        public method setAgi takes string whichAgi returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setAgi to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setAgi(whichAgi) 
        endmethod
        public method setInt takes string whichInt returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setInt to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setInt(whichInt) 
        endmethod
        public method setDescription takes string whichDescription returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setDescription to a hero that doesn't exist.") 
                return 
            endif
            call heroes[count - 1].setDescription(whichDescription)
        endmethod
        public method setModel takes integer whichDummyid, string whichAnimation returns nothing 
            if count == 0 then
                debug call BJDebugMsg("WARNING: setModel to a hero that doesn't exist.") 
                return 
            endif 
            call heroes[count - 1].setModel(whichDummyid, whichAnimation)
        endmethod
        public method setIcon takes integer whichIcon returns nothing 
            if count == 0 then 
                debug call BJDebugMsg("WARNING: setIcon to a hero that doesn't exist.") 
                return 
            endif 
            call heroes[count - 1].setIcon(whichIcon) 
        endmethod
        /*
        Get a hero by index
        */
        public method getHero takes integer index returns Hero 
            return heroes[index] 
        endmethod 
        /*
        Get the quantify of heroes created 
        */
        public method getSize takes nothing returns integer 
            return count 
        endmethod
        /*
        Remove all heroes from selection screen 
        */
        public method destroy takes nothing returns nothing
            local integer i = 0
            loop
                exitwhen i == count-1
                call heroes[i].destroy()
                set i = i + 1
            endloop
        endmethod
    endstruct
    
    public struct Options 
        private boolean timeLimit_actived 
        private real timeLimit_time 
        private real iconScale 
        private integer iconsByLine
        private sound click 
        private sound error
        private sound ok 
        private boolean bots 
        public method timeLimit takes boolean timeLimitActived, real whichTime returns nothing 
            set timeLimit_actived = timeLimitActived 
            set timeLimit_time = whichTime 
        endmethod
        public method isTimeLimited takes nothing returns boolean 
            return timeLimit_actived 
        endmethod
        public method setIconScale takes real whichScale returns nothing 
            set iconScale = whichScale 
        endmethod 
        public method setIconsByLine takes integer howMany returns nothing 
            set iconsByLine = howMany 
        endmethod
        public method setSoundClick takes sound whichSound returns nothing 
            set click = whichSound 
        endmethod 
        public method setSoundError takes sound whichSound returns nothing 
            set error = whichSound 
        endmethod
        public method setSoundOk takes sound whichSound returns nothing 
            set ok = whichSound 
        endmethod
        public method botsPick takes boolean b returns nothing 
            set bots = b
        endmethod
        public method getTimeLimit takes nothing returns real     
            return timeLimit_time 
        endmethod
        public method getIconScale takes nothing returns real   
            return iconScale 
        endmethod 
        public method getIconsByLine takes nothing returns integer 
            return iconsByLine 
        endmethod
        public method getSoundClick takes nothing returns sound 
            return click 
        endmethod 
        public method getSoundError takes nothing returns sound 
            return error
        endmethod
        public method getSoundOk takes nothing returns sound 
            return ok 
        endmethod
        public method doesBotsPick takes nothing returns boolean
            return bots 
        endmethod
    endstruct
    
    /*----------------------------------------------------------
    *This class manages the file paths of selection screen
    ----------------------------------------------------------*/
    public struct Paths 
        private string background 
        private integer logo
        private integer emptyIcon 
        private integer randomIcon 
        private integer selection 
        private integer strength 
        private integer agility 
        private integer intelligence 
        public method setBackground takes string whichPath returns nothing 
            set background = whichPath 
        endmethod
        public method setLogo takes integer whichid returns nothing 
            set logo = whichid 
        endmethod 
        public method setEmptyIcon takes integer whichid returns nothing 
            set emptyIcon = whichid
        endmethod 
        public method setRandomIcon takes integer whichid returns nothing 
            set randomIcon = whichid 
        endmethod
        public method setSelection takes integer whichid returns nothing 
            set selection = whichid 
        endmethod 
        public method setStrIcon takes integer whichid returns nothing 
            set strength = whichid
        endmethod
        public method setAgiIcon takes integer whichid returns nothing
            set agility = whichid 
        endmethod 
        public method setIntIcon takes integer whichid returns nothing 
            set intelligence = whichid 
        endmethod
        public method getBackground takes nothing returns string 
            return background 
        endmethod
        public method getLogo takes nothing returns integer 
            return logo 
        endmethod
        public method getEmptyIcon takes nothing returns integer  
            return emptyIcon 
        endmethod
        public method getRandomIcon takes nothing returns integer 
            return randomIcon 
        endmethod
        public method getSelection takes nothing returns integer 
            return selection 
        endmethod
        public method getStrIcon takes nothing returns integer 
            return strength 
        endmethod 
        public method getAgiIcon takes nothing returns integer 
            return agility 
        endmethod 
        public method getIntIcon takes nothing returns integer 
            return intelligence 
        endmethod
    endstruct
    /*============================================================
    * END OF DATA STRUCT SECTION
    *=============================================================*/
    /*============================================================
    * SYSTEM DYNAMIC SECTION
    *=============================================================*/
    /*----------------------------------------------------------
    * This is just a trick class to allow me using bidimensional arrays. 
    ----------------------------------------------------------*/
    private struct TeamIcon 
        public destructable array icons[12] 
        public method destroy takes nothing returns nothing 
            local integer i 
            for i = 0 to 11
                if icons[i] != null then 
                    call RemoveDestructable(icons[i]) 
                    set icons[i] = null
                endif 
            endfor 
        endmethod 
    endstruct
    /*----------------------------------------------------------
    * This class manages the player selection 
    ----------------------------------------------------------*/
    private struct PlayerSelection 
        private integer whichPlayer 
        private unit selectionBox 
        private integer row 
        private integer column 
        public static method create takes integer whichPlayer, integer unitid, real x, real y, real red, real green, real blue returns thistype 
            local thistype this = thistype.allocate()
            set this.whichPlayer = whichPlayer 
            set this.selectionBox = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), unitid, x, y, 270) 
            call SetUnitVertexColorBJ(this.selectionBox, R2I(red * 100), R2I(green * 100), R2I(blue * 100), 0) 
            call UnitAddAbility(this.selectionBox, 'Arav')
            call UnitRemoveAbility(this.selectionBox, 'Arav')
            call SetUnitFlyHeight(this.selectionBox, 250 + 12 - whichPlayer, 0)
            call SetUnitX(this.selectionBox, x) 
            call SetUnitY(this.selectionBox, y)
            set this.row = 0
            set this.column = 0
            return this
        endmethod
        public method setRow takes integer whichRow returns nothing 
            set row = whichRow 
        endmethod 
        public method setColumn takes integer whichColumn returns nothing 
            set column = whichColumn 
        endmethod
        public method setPos takes real x, real y returns nothing 
            call SetUnitPosition(selectionBox, x, y) 
        endmethod
        public method setX takes real x returns nothing 
            call SetUnitX(selectionBox, x) 
        endmethod 
        public method setY takes real y returns nothing 
            call SetUnitY(selectionBox, y) 
        endmethod
        public method getRow takes nothing returns integer 
            return row 
        endmethod 
        public method getColumn takes nothing returns integer 
            return column 
        endmethod
        public method getUnit takes nothing returns unit 
            return selectionBox 
        endmethod
        public method destroy takes nothing returns nothing 
            call RemoveUnit(selectionBox) 
            set selectionBox = null 
        endmethod 
    endstruct 
    /*----------------------------------------------------------
    * This is where the real show happens 
    *----------------------------------------------------------*/
    public struct Graphics 
        private static constant integer ICON_SIZE = 64
        private static force cameraForce
        private timer cameraTimer 
        private AHSS_Teams teams
        private AHSS_Heroes heroes 
        private AHSS_Options options
        private AHSS_Paths paths
        private unit dummy 
        private image backgroundImg
        private destructable logoImg
        private destructable array emptyIcon[Configurations.MAX_SLOTS]
        private destructable randomIcon 
        private PlayerSelection array selections[12]
        private TeamIcon array teamsIcon[12]
        private texttag array teamsText[12]
        private unit array heroesModels[12]
        private texttag array heroesName[12]
        private destructable array heroesIcon[Configurations.MAX_SLOTS]
        //! textmacro CREATE_ATT_STAT takes stat 
        private destructable array $stat$Icon[12]
        private texttag array $stat$Text[12]
        //! endtextmacro 
        //! runtextmacro CREATE_ATT_STAT("str")
        //! runtextmacro CREATE_ATT_STAT("agi")
        //! runtextmacro CREATE_ATT_STAT("int")
        private texttag array descriptionText[12]
        private boolean array selectionUsed[12]
        private boolean gameStarted
        private timer gameStartedTimer 
        private timerdialog gameStartedTimerDialog
        private fogmodifier array modifier[12] 
        private timer timeLimitTimer 
        private timerdialog timeLimitTimerDialog 
        /*
        Register the arrow key event 
        */
        private static method onInit takes nothing returns nothing 
            local trigger t = CreateTrigger()
            local integer i = 0
            loop
                exitwhen i == 11
                call TriggerRegisterPlayerEventEndCinematic(t, Player(i))
            endloop
            call TriggerAddCondition(t, Condition(function thistype.pressEsc))
            set t = null
            call RegisterArrowKeyEvent(function thistype.pressKey) 
        endmethod
        public static method create takes AHSS_Teams teams, AHSS_Heroes heroes, AHSS_Options options, AHSS_Paths paths returns thistype 
            local thistype this = 1 
            if this.dummy != null then 
                call this.destroy() 
            endif 
            set this = thistype.allocate()
            set this.teams = teams 
            set this.heroes = heroes 
            set this.options = options
            set this.paths = paths
            return this
        endmethod
        //------------------------------------------------------------------
        //------------------------------------------------------------------
        private static method start takes nothing returns nothing 
            local thistype this = 1
            local integer i 
            local integer j 
            local integer id 
            local integer index 
            for i = 0 to (this.teams.getSize() - 1) 
                for j = 0 to (this.teams.getTeam(i).getSize() - 1) 
                    set id = this.teams.getTeam(i).getPlayer(j) 
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING and (GetPlayerController(Player(id)) == MAP_CONTROL_USER or  (GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER and this.options.doesBotsPick())) then
                        set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        if this.selections[id].getColumn() == -1 or (this.heroesIcon[index] == null and not this.selectionUsed[id]) then 
                            call selectHeroRandom(this, id) 
                            set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        endif
                        set this.emptyIcon[index] = CreateDestructableZ(this.paths.getEmptyIcon(), GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                        call RemoveDestructable(this.heroesIcon[index]) 
                        set this.heroesIcon[index] = null
                        call CreateUnit(Player(id), this.heroes.getHero(index).getHeroid(), GetRectCenterX(this.teams.getTeam(i).getSpawningSpot()), GetRectCenterY(this.teams.getTeam(i).getSpawningSpot()), 270) 
                        call PanCameraToTimedForPlayer(Player(id), GetRectCenterX(this.teams.getTeam(i).getSpawningSpot()), GetRectCenterY(this.teams.getTeam(i).getSpawningSpot()), 0)
                    endif
                endfor
            endfor
            call this.destroy() 
        endmethod
        //------------------------------------------------------------------
        //------------------------------------------------------------------
        private static method hideSelection takes thistype this, integer playerid returns nothing 
            local integer i = playerid
            call SetUnitScale(this.selections[playerid].getUnit(), 0, 0, 0)  
            //! runtextmacro DESTROY_MODELS()
            //! runtextmacro DESTROY_STAT("str", "Str") 
            //! runtextmacro DESTROY_STAT("agi", "Agi")
            //! runtextmacro DESTROY_STAT("int", "Int")
        endmethod 
        private static method showSelection takes thistype this, integer playerid returns nothing 
            call SetUnitScale(this.selections[playerid].getUnit(), 1, 1, 1) 
        endmethod
        private static method createTeamIcon takes thistype this, integer playerid, integer index, boolean remove returns nothing 
            local integer i = 0
            local integer j = 0
            local real x 
            local real y
            loop
                exitwhen i = (this.teams.getSize() - 1)
                loop
                exitwhen j = (this.teams.getSize() - 1)
                    if this.teams.getTeam(i).getPlayer(j) == playerid then 
                        set x = GetDestructableX(this.teamsIcon[i].icons[j]) 
                        set y = GetDestructableY(this.teamsIcon[i].icons[j]) 
                        call RemoveDestructable(this.teamsIcon[i].icons[j]) 
                        if remove then 
                            set this.teamsIcon[i].icons[j] = CreateDestructable(this.heroes.getHero(index).getIcon(), x, y, 270, options.getIconScale()/2, 1) 
                        else
                            set this.teamsIcon[i].icons[j] = CreateDestructable(this.paths.getEmptyIcon(), x, y, 270, options.getIconScale()/2, 1) 
                        endif
                        return
                    endif
                endloop
            endloop
        endmethod
        private static method allReady takes thistype this returns boolean
            local integer i = 0
            local integer j = 0
            loop
                exitwhen i = (this.teams.getSize() - 1)
                loop
                    exitwhen j = (this.teams.getTeam(i).getSize() - 1)
                    if GetPlayerController(Player(this.teams.getTeam(i).getPlayer(j))) == MAP_CONTROL_USER and GetPlayerSlotState(Player(this.teams.getTeam(i).getPlayer(j))) == PLAYER_SLOT_STATE_PLAYING then
                        if not selectionUsed[this.teams.getTeam(i).getPlayer(j)] then 
                            return false 
                        endif
                    endif
                endloop
            endloop
            return true
        endmethod
        private static method verifyStart takes thistype this returns nothing 
            if allReady(this) and not gameStarted then 
                call PauseTimer(timeLimitTimer)
                call TimerDialogDisplay(timeLimitTimerDialog, false)
                set gameStarted = true 
                set gameStartedTimer = CreateTimer() 
                call TimerStart(gameStartedTimer, 5.0, false, function thistype.start) 
                set gameStartedTimerDialog = CreateTimerDialogBJ(gameStartedTimer, "Game Starting...") 
                call TimerDialogDisplayBJ(true, gameStartedTimerDialog)
                call SetImageColor(backgroundImg, 100, 100, 100, 255)
            endif
        endmethod
        private static method selectHeroRandom takes thistype this, integer id returns nothing 
            local integer random = 0
            local integer count = 0
            loop
                exitwhen random = (Configurations.MAX_SLOTS - 1)
                if this.heroesIcon[random] != null then 
                    set count = count + 1
                endif
            endloop
            if count > 0 then   
                loop
                    set random = GetRandomInt(0, Configurations.MAX_SLOTS-1) 
                    exitwhen this.heroesIcon[random] != null 
                endloop
                call showHero(this, id, random) 
                call this.selections[id].setColumn(random/this.options.getIconsByLine()) 
                loop
                    exitwhen random < this.options.getIconsByLine() 
                    set random = random - this.options.getIconsByLine()
                endloop
                call this.selections[id].setRow(random) 
                call updateCursor(this, id)
                call pressEscActions(this, id)
            endif
        endmethod
        private static method pressEscActions takes thistype this, integer id returns boolean 
            local integer index
            if not gameStarted then
                if this.dummy != null and IsPlayerInForce(Player(id), cameraForce) then
                    if this.selections[id].getColumn() == -1 then 
                        call selectHeroRandom(this, id)
                    else
                        set index = this.selections[id].getColumn() * this.options.getIconsByLine() + this.selections[id].getRow() 
                        if not selectionUsed[id] then
                            if this.heroesIcon[index] == null then 
                                if GetLocalPlayer() == GetTriggerPlayer() then
                                    call PlaySoundBJ(this.options.getSoundError()) 
                                endif
                                return false 
                            endif
                            if GetLocalPlayer() == GetTriggerPlayer() then 
                                call PlaySoundBJ(this.options.getSoundOk()) 
                            endif
                            set this.emptyIcon[index] = CreateDestructableZ(this.paths.getEmptyIcon(), GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                            call RemoveDestructable(this.heroesIcon[index])
                            set this.heroesIcon[index] = null
                            call RemoveDestructable(this.heroesIcon[index]) 
                            set selectionUsed[id] = true
                            call hideSelection(this, id)
                            call createTeamIcon(this, id, index, true)
                        else 
                            if GetLocalPlayer() == GetTriggerPlayer() then 
                                call PlaySoundBJ(this.options.getSoundOk()) 
                            endif
                            call showSelection(this, id)
                            call createTeamIcon(this, id, index, false)
                            set this.heroesIcon[index] = CreateDestructableZ(this.heroes.getHero(index).getIcon(), GetDestructableX(this.emptyIcon[index]), GetDestructableY(this.emptyIcon[index]), 250, 270, this.options.getIconScale(), 1) 
                            call RemoveDestructable(this.emptyIcon[index]) 
                            set this.emptyIcon[index] = null 
                            call showHero(this, id, index)
                            set selectionUsed[id] = false
                        endif
                    endif
                    call verifyStart(this)
                endif
            endif
            return false 
        endmethod
        private static method pressEsc takes nothing returns boolean 
            local thistype this = 1 
            local integer index 
            local integer id = GetPlayerId(GetTriggerPlayer()) 
            call pressEscActions(this, id)
            return false
        endmethod
        private static method pressKey takes nothing returns nothing
            local thistype this = 1
            local integer playerid = GetEventArrowKeyPlayerId()
            local integer index 
            if this.dummy != null and this.selections[playerid] != 0 and IsPlayerInForce(Player(playerid), cameraForce) and IsEventArrowKeyPressed() and not selectionUsed[playerid] then
                call moveCursor(this, playerid)
                set index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
                call showHero(this, playerid, index) 
            endif
        endmethod 
        /*
        Move the selection to left
        */
        private static method moveLeft takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getRow() == 0 then 
                set i = 0 
                loop
                    exitwhen i >= (this.options.getIconsByLine()-1) or (this.emptyIcon[index+i] == null and this.heroesIcon[index+i] == null)
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow(i) 
            else 
                call this.selections[playerid].setRow(this.selections[playerid].getRow()-1)
            endif 
        endmethod
        /*
        Move the selection to right
        */
        private static method moveRight takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getRow() >= (this.options.getIconsByLine()-1) or (this.emptyIcon[index+1] == null and this.heroesIcon[index+1] == null) then 
                call this.selections[playerid].setRow(0) 
            else 
                call this.selections[playerid].setRow(this.selections[playerid].getRow()+1)
            endif 
        endmethod
        /*
        Move the selection downward
        */
        private static method moveDown takes thistype this, integer playerid, integer index returns nothing 
            local integer i
            if this.selections[playerid].getColumn() == -1 then 
                call this.selections[playerid].setColumn(0)
                set i = 0 
                loop
                    exitwhen i >= options.getIconsByLine() or (this.heroesIcon[i] == null and this.emptyIcon[i] == null) 
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow((i-1)/2)
            elseif this.emptyIcon[index+options.getIconsByLine()] == null and this.heroesIcon[index+options.getIconsByLine()] == null then 
                call this.selections[playerid].setColumn(-1)
            else
                call this.selections[playerid].setColumn(this.selections[playerid].getColumn()+1)
            endif
        endmethod
        /*
        Move the selection upward
        */
        private static method moveUp takes thistype this, integer playerid, integer index returns nothing 
            local integer i 
            if this.selections[playerid].getColumn() == 0 then 
                call this.selections[playerid].setColumn(-1)
            elseif this.selections[playerid].getColumn() == -1 then 
                set i = 0 
                loop
                    exitwhen this.emptyIcon[i*options.getIconsByLine()] == null and this.heroesIcon[i*options.getIconsByLine()] == null 
                    set i = i + 1
                endloop
                call this.selections[playerid].setColumn(i-1)
                set i = 0 
                loop
                    exitwhen this.emptyIcon[this.selections[playerid].getColumn()*options.getIconsByLine()+i] == null and this.heroesIcon[this.selections[playerid].getColumn()*options.getIconsByLine()+i] == null 
                    set i = i + 1
                endloop
                call this.selections[playerid].setRow((i-1)/2)
            else 
                call this.selections[playerid].setColumn(this.selections[playerid].getColumn()-1)
            endif 
        endmethod
        /*
        Update the selection box position
        */
        private static method updateCursor takes thistype this, integer playerid returns nothing 
            local integer index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
            local integer i 
            if this.selections[playerid].getColumn() == - 1 then 
                call this.selections[playerid].setPos(GetDestructableX(this.randomIcon), GetDestructableY(this.randomIcon)) 
            else 
                if this.emptyIcon[index] != null then 
                    call this.selections[playerid].setPos(GetDestructableX(this.emptyIcon[index]), GetDestructableY(this.emptyIcon[index])) 
                else 
                    call this.selections[playerid].setPos(GetDestructableX(this.heroesIcon[index]), GetDestructableY(this.heroesIcon[index])) 
                endif 
            endif 
            if GetLocalPlayer() == Player(playerid) then 
                call PlaySoundBJ(this.options.getSoundClick()) 
            endif
        endmethod 
        /*
        Move the selection box for each Player
        */
        private static method moveCursor takes thistype this, integer playerid returns nothing 
            local integer index
            local integer i 
            set index = this.selections[playerid].getColumn()*this.options.getIconsByLine()+this.selections[playerid].getRow()
            if GetEventArrowKey() == 0 then 
                call moveLeft(this, playerid, index)
            elseif GetEventArrowKey() == 1 then 
                call moveRight(this, playerid, index)
            elseif GetEventArrowKey() == 2 then 
                call moveDown(this, playerid, index)
            else 
                call moveUp(this, playerid, index)
            endif
            call updateCursor(this, playerid)
        endmethod 
        private static method countLines takes string s returns integer 
            local integer count
            local integer i = 0
            loop
                exitwhen i = StringLength(s) - 2
                if SubString(s, i, i+1) == "\n" then 
                    set count = count + 1
                endif
            endloop
            return count 
        endmethod 
        /*
        Show select hero information o screen
        */
        private static method showHero takes thistype this, integer playerid, integer index returns nothing
            local real x
            local real y
            local integer i = playerid
            //-------------------------------------------------------------------
            //! textmacro STAT_TEXT takes stat Stat 
            set x = GetDestructableX(this.$stat$Icon[playerid]) + 50
            set y = GetDestructableY(this.$stat$Icon[playerid]) - 15
            set this.$stat$Text[playerid] = CreateTextTag()  
            call SetTextTagText(this.$stat$Text[playerid], this.heroes.getHero(index).get$Stat$(), TextTagSize2Height(13))
            call SetTextTagPos(this.$stat$Text[playerid], x, y, 0)
            call SetTextTagColor(this.$stat$Text[playerid], 255, 255, 255, 255)
            if GetLocalPlayer() != Player(playerid) then 
                if this.$stat$Text[playerid] != null then 
                    call SetTextTagVisibility(this.$stat$Text[playerid], false) 
                endif 
                if this.$stat$Icon[playerid] != null then 
                    call ShowDestructable(this.$stat$Icon[playerid], false) 
                endif
            endif
            //! endtextmacro
            //! textmacro DESTROY_STAT takes stat Stat 
            if this.$stat$Icon[i] != null then 
                call RemoveDestructable(this.$stat$Icon[i])
                set this.$stat$Icon[i] = null 
            endif 
            if this.$stat$Text[i] != null then 
                call DestroyTextTag(this.$stat$Text[i]) 
                set this.$stat$Text[i] = null
            endif 
            //! endtextmacro 
            //! textmacro DESTROY_MODELS 
            if this.heroesModels[i] != null then
                call RemoveUnit(this.heroesModels[i])
                set this.heroesModels[i] = null
            endif
            if this.heroesName[i] != null then 
                call DestroyTextTag(this.heroesName[i]) 
                set this.heroesName[i] = null
            endif
            if this.descriptionText[i] != null then 
                call DestroyTextTag(this.descriptionText[i]) 
                set this.descriptionText[i] = null 
            endif
            //! endtextmacro
            //-------------------------------------------------------------------
            //! runtextmacro DESTROY_MODELS()
            //! runtextmacro DESTROY_STAT("str", "Str") 
            //! runtextmacro DESTROY_STAT("agi", "Agi")
            //! runtextmacro DESTROY_STAT("int", "Int")
            if this.heroesIcon[index] != null then 
                //CREATE THE UNIT
                set x = GetUnitX(dummy) 
                set y = GetUnitY(dummy) - 100
                set this.heroesModels[playerid] = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), this.heroes.getHero(index).getDummyid(), x, y, 180) 
                call UnitAddAbility(this.heroesModels[playerid], 'Arav') 
                call UnitRemoveAbility(this.heroesModels[playerid], 'Arav') 
                call SetUnitFlyHeight(this.heroesModels[playerid], 100, 0) 
                call SetUnitAnimation(this.heroesModels[playerid], this.heroes.getHero(index).getAnimation())
                //CREATE HERO NAME
                set x = x + 600
                set y = y + 500
                set this.heroesName[playerid] = CreateTextTag()  
                call SetTextTagText(this.heroesName[playerid], this.heroes.getHero(index).getName(), TextTagSize2Height(16))
                call SetTextTagPos(this.heroesName[playerid], x, y, 0)
                call SetTextTagColor(this.heroesName[playerid], 255, 255, 255, 255)
                //CREATE STATS INFO
                set y = y - 100 
                set this.strIcon[playerid] = CreateDestructable(this.paths.getStrIcon(), x, y, 270, this.options.getIconScale(), 1) 
                set y = y - ICON_SIZE * this.options.getIconScale() - 10 
                set this.agiIcon[playerid] = CreateDestructable(this.paths.getAgiIcon(), x, y, 270, this.options.getIconScale(), 1) 
                set y = y - ICON_SIZE * this.options.getIconScale() - 10 
                set this.intIcon[playerid] = CreateDestructable(this.paths.getIntIcon(), x, y, 270, this.options.getIconScale(), 1) 
                //! runtextmacro STAT_TEXT("str", "Str")
                //! runtextmacro STAT_TEXT("agi", "Agi")
                //! runtextmacro STAT_TEXT("int", "Int")
                //CREATE HERO INFO 
                set x = x - 100
                set y = y - 200 - (20 * countLines(this.heroes.getHero(index).getDescription()))
                set this.descriptionText[playerid] = CreateTextTag()  
                call SetTextTagText(this.descriptionText[playerid], this.heroes.getHero(index).getDescription(), TextTagSize2Height(10))
                call SetTextTagPos(this.descriptionText[playerid], x, y, 0)
                call SetTextTagColor(this.descriptionText[playerid], 255, 255, 255, 255)
                //HIDE INFO FROM OTHER PLAYERS
                if GetLocalPlayer() != Player(playerid) then 
                    if this.heroesName[playerid] != null then 
                        call SetTextTagVisibility(this.heroesName[playerid], false) 
                    endif 
                    if this.descriptionText[playerid] != null then 
                        call SetTextTagVisibility(this.descriptionText[playerid], false) 
                    endif 
                    if this.heroesModels[playerid] != null then 
                        call SetUnitVertexColor(this.heroesModels[playerid], 255, 255, 255, 0)
                    endif
                endif
            endif 
        endmethod
        //"Lock" the camera so the player can't avoid it :)
        private static method loopCamera takes nothing returns nothing 
            local thistype this = 1
            local Configurations c = Configurations.create()
            local integer i 
            loop
                exitwhen i = 11
                if IsPlayerInForce(Player(i), cameraForce) then 
                    call CameraSetupApplyForceDuration(c.CAMERA, true, 0)
                    call SetCameraTargetController(this.dummy, 0, 0, false)
                endif 
            endloop
            call c.destroy()
        endmethod
        private method createCamera takes nothing returns nothing 
            local integer i = 0 
            local Configurations c = Configurations.create()
            call PanCameraToTimed(GetRectCenterX(c.INITIAL_AREA), GetRectCenterY(c.INITIAL_AREA), 0) 
            if dummy == null then
                set dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), Configurations.DUMMY_ID, GetRectCenterX(c.INITIAL_AREA), GetRectCenterY(c.INITIAL_AREA), 0)
            endif
            set cameraForce = CreateForce() 
            loop
                exitwhen i = 11
                call ForceAddPlayer(cameraForce, Player(i)) 
                set modifier[i] = CreateFogModifierRectBJ(true, Player(i), FOG_OF_WAR_VISIBLE, gg_rct_SELECTION_AREA)
            endloop
            set cameraTimer = CreateTimer()
            call TimerStart(cameraTimer, 0.01, true, function thistype.loopCamera) 
            call c.destroy()
        endmethod
        private method createHeroesIcon takes nothing returns nothing 
            local integer i 
            loop
                exitwhen i = (heroes.getSize() - 1)
                set heroesIcon[i] = CreateDestructableZ(heroes.getHero(i).getIcon(), GetDestructableX(emptyIcon[i]), GetDestructableY(emptyIcon[i]), 250, 270, options.getIconScale(), 1) 
                call RemoveDestructable(emptyIcon[i]) 
                set emptyIcon[i] = null
            endloop
        endmethod 
        private method createTeamsIcon takes nothing returns nothing 
            local real iconSize = ICON_SIZE * (options.getIconScale() / 2)
            local real x 
            local real y = GetUnitY(dummy) + 500 
            local integer i = 0
            local integer j = 0
            loop
                exitwhen i = (teams.getSize() - 1)
                set teamsIcon[i] = TeamIcon.create()
                set y = y - (ICON_SIZE * options.getIconScale()/2) - iconSize
                set x = GetUnitX(dummy) - 950
                loop
                    exitwhen j = (teams.getTeam(i).getSize() - 1)   
                    set teamsIcon[i].icons[j] = CreateDestructable(paths.getEmptyIcon(), x, y, 270, options.getIconScale()/2, 1) 
                    set x = x + iconSize 
                endloop
            endloop
        endmethod
        private method createEmptyIcons takes nothing returns nothing 
            local integer count = Configurations.MAX_SLOTS
            local integer iconsByLine = options.getIconsByLine()
            local real scale = 1.5
            local real iconSize = ICON_SIZE * options.getIconScale()
            local real x 
            local real y = GetUnitY(dummy) 
            local integer row = 0 
            local integer i = 0
            loop
                exitwhen count < iconsByLine
                set x = GetUnitX(dummy) - ((iconSize * iconsByLine)/2)
                loop
                    exitwhen i = (iconsByLine - 1)
                    set emptyIcon[row * iconsByLine + i] = CreateDestructableZ(paths.getEmptyIcon(), x, y, 250, 270, scale, 1)
                    set x = x + iconSize
                endloop
                set y = y - iconSize
                set row = row + 1
                set count = count - iconsByLine
            endloop
            set x = GetUnitX(dummy) - ((iconSize * count)/2) 
            loop
                exitwhen i = (count - 1) 
                set emptyIcon[row * iconsByLine + i] = CreateDestructableZ(paths.getEmptyIcon(), x, y, 250, 270, scale, 1) 
                set x = x + iconSize 
            endloop
            if count > 0 then
                set y = y - iconSize
            endif
            set x = GetUnitX(dummy) - (iconSize/2)
            set randomIcon = CreateDestructableZ(paths.getRandomIcon(), x, y, 250, 270, scale, 1) 
        endmethod 
        private method createImages takes nothing returns nothing 
            if backgroundImg == null then
                set backgroundImg = CreateImage(paths.getBackground(), 2200, 1800, 1800, GetUnitX(dummy), GetUnitY(dummy), 0, 1100, 900, 900, 2)
                call SetImageRenderAlways(backgroundImg, true)
            endif
            if logoImg == null then 
                set logoImg = CreateDestructable(paths.getLogo(), GetUnitX(dummy), GetUnitY(dummy) + 350, 270, 6.0, 1)  
            endif
            call createEmptyIcons()
            call createTeamsIcon()
            call createHeroesIcon()
        endmethod
        private method createTexts takes nothing returns nothing 
            local real x = GetUnitX(dummy) - 1000
            local real y = GetUnitY(dummy) + 550
            local integer i 
            loop
                exitwhen i = (teams.getSize() - 1)
                set y = y - (64 * options.getIconScale()) - 10 
                set teamsText[i] = CreateTextTag()  
                call SetTextTagText(teamsText[i], teams.getTeam(i).getName(), TextTagSize2Height(12))
                call SetTextTagPos(teamsText[i], x, y, 0)
                call SetTextTagColor(teamsText[i], 255, 255, 255, 255) 
            endloop
        endmethod
        private method createSelections takes nothing returns nothing 
            local integer i
            local integer j = 0
            local real x 
            local real y 
            local integer count = 0 
            local integer id 
            if emptyIcon[0] != null then 
                set x = GetDestructableX(emptyIcon[0]) 
                set y = GetDestructableY(emptyIcon[0])
            else 
                set x = GetDestructableX(heroesIcon[0]) 
                set y = GetDestructableY(heroesIcon[0]) 
            endif
            loop
                exitwhen j = (teams.getTeam(i).getSize() - 1) 
                    set id = teams.getTeam(i).getPlayer(j) 
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
                        if GetPlayerController(Player(id)) == MAP_CONTROL_USER or (GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER and options.doesBotsPick()) then 
                            if teams.getTeam(i).getPlayer(j) == 0 then 
                                set selections[teams.getTeam(i).getPlayer(j)] = PlayerSelection.create(0, paths.getSelection(), x, y, 1.00, 0.01, 0.01)
                            //! textmacro COND takes ID RED BLUE GREEN
                            elseif teams.getTeam(i).getPlayer(j) == $ID$ then 
                                set selections[teams.getTeam(i).getPlayer(j)] = PlayerSelection.create($ID$, paths.getSelection(), x, y, $RED$, $BLUE$, $GREEN$)
                            //! endtextmacro
                            //! runtextmacro COND("1", "0.00","0.25","1.00")
                            //! runtextmacro COND("2", "0.09","0.90","0.70")
                            //! runtextmacro COND("3", "0.32","0.00","0.50")
                            //! runtextmacro COND("4", "1.00","0.98","0.40")
                            //! runtextmacro COND("5", "0.99","0.72","0.05")
                            //! runtextmacro COND("6", "0.12","0.75","0.00")
                            //! runtextmacro COND("7", "0.89","0.35","0.69")
                            //! runtextmacro COND("8", "0.58","0.58","0.58")
                            //! runtextmacro COND("9", "0.49","0.74","0.94")
                            //! runtextmacro COND("10","0.06","0.38","0.27")
                            //! runtextmacro COND("11","0.30","0.16","0.01")
                            endif
                        endif
                    endif
                    set count = count + 1
                endloop
            endfor
        endmethod
        public method draw takes boolean allRandom returns nothing 
            local integer i = 0
            local integer j = 0
            local integer id
            call createCamera()
            call createImages()
            call createTexts()
            call createSelections()
            loop
                exitwhen i = (this.teams.getSize() - 1)
                loop
                    exitwhen j = (this.teams.getTeam(i).getSize() - 1)
                    set id = this.teams.getTeam(i).getPlayer(j)
                    if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
                        if GetPlayerController(Player(id)) == MAP_CONTROL_USER then
                            if allRandom then 
                                call thistype.selectHeroRandom(this, id)
                            else
                                call showHero(this, i, 0)
                            endif
                        else
                            if this.options.doesBotsPick() then 
                                call thistype.selectHeroRandom(this, id)
                            endif
                        endif
                    endif
                endloop
            endloop
            if options.isTimeLimited() then 
                set timeLimitTimer = CreateTimer()
                call TimerStart(timeLimitTimer, options.getTimeLimit(), false, function thistype.start) 
                set timeLimitTimerDialog = CreateTimerDialogBJ(timeLimitTimer, "Time to pick")
                call TimerDialogDisplay(timeLimitTimerDialog, true)
            endif
        endmethod
        public method destroy takes nothing returns nothing 
            local integer i = 0
            if dummy != null then 
                call RemoveUnit(dummy)
                set dummy = null 
            endif 
            //if backgroundImg != null then 
                call ShowImage(backgroundImg, false)
                call DestroyImage(backgroundImg) 
            //endif
            if logoImg != null then 
                call RemoveDestructable(logoImg)
                set logoImg = null
            endif
            loop
                exitwhen i = (Configurations.MAX_SLOTS - 1) 
                if emptyIcon[i] != null then 
                    call RemoveDestructable(emptyIcon[i])
                    set emptyIcon[i] = null
                endif
                if heroesIcon[i] != null then 
                    call RemoveDestructable(heroesIcon[i]) 
                    set heroesIcon[i] = null 
                endif 
            endloop
            if randomIcon != null then 
                call RemoveDestructable(randomIcon)
                set randomIcon = null
            endif 
            loop
                exitwhen i = 11
                if selections[i] != 0 then 
                    call selections[i].destroy() 
                endif 
                if modifier[i] != null then 
                    call FogModifierStop(modifier[i])
                    call DestroyFogModifier(modifier[i]) 
                    set modifier[i] = null
                endif
                //! runtextmacro DESTROY_MODELS()
                //! runtextmacro DESTROY_STAT("str", "Str") 
                //! runtextmacro DESTROY_STAT("agi", "Agi")
                //! runtextmacro DESTROY_STAT("int", "Int")
            endloop
            loop
                exitwhen i = (teams.getSize() - 1) 
                call teamsIcon[i].destroy()
                call DestroyTextTag(teamsText[i])
                set teamsText[i] = null
            endloop
            if cameraTimer != null then 
                call PauseTimer(cameraTimer)
                call DestroyTimer(cameraTimer) 
            endif
            if gameStartedTimer != null then 
                call PauseTimer(gameStartedTimer) 
                call DestroyTimer(gameStartedTimer) 
                set gameStartedTimer = null 
            endif 
            if gameStartedTimerDialog != null then 
                call TimerDialogDisplay(gameStartedTimerDialog, false)
                call DestroyTimerDialog(gameStartedTimerDialog) 
                set gameStartedTimerDialog = null 
            endif
            if timeLimitTimer != null then 
                call PauseTimer(timeLimitTimer) 
                call DestroyTimer(timeLimitTimer) 
                set timeLimitTimer = null 
            endif 
            if timeLimitTimerDialog != null then 
                call TimerDialogDisplay(timeLimitTimerDialog, false)
                call DestroyTimerDialog(timeLimitTimerDialog) 
                set timeLimitTimerDialog = null 
            endif
            call DestroyForce(cameraForce) 
            call teams.destroy() 
            call heroes.destroy() 
            call options.destroy() 
            call paths.destroy()
            set cameraTimer = null
            set cameraForce = null
        endmethod
    endstruct
    
endscope
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
540
I attempted to follow the pattern (not sure if I did more damage to it) get an error
'Line 696 : member redeclared : create' . If 1.5e the version you were refering to because I tried enabling cohader and many systems produced errors. I asked before because my vJass is not all that great.

you did good. your error is that you remove the endstruct from struct Teams. That means struct Teams is never closed and ofc. the other create methods conflict w/ it. Also sometimes you used = instead of ==.
And sometimes you forgot to initialize your variable. For example count in method countLines or i in loopCamera. You also forgot to increment i in the same method. You forgot to increment your variables quite often so im not going to list'em all.
But atleast PJass will catch all the = vs == errors.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Trust me, "create duplication" is just the begining. Whoever told you that it is properly converted into vJass was wrong, to say the least.

Divide the script into smaller pieces, so it will be easier for you/us to fix it. As mentioned above, there are multiple "for" loops still present in script which are not recognized properly by vJass compiler. Use loop/endloop/exitwhen threesome instead. Many iterations miss increment/decrement operations (iterator is static).
There are multiple references to "GetEventArrowKey" what suggests that you require additional library for this one to work.

Honestly, again: it's best to start from scratch and use this code block as a guideline.
 
Status
Not open for further replies.
Top