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

Dynasty Warriors 2 Yi Ling [vJass Coders needed!]

Status
Not open for further replies.
Level 5
Joined
Jul 25, 2008
Messages
126
war3mapPreview_zps5f8f79f2.png


Brief Description:

A decisive battle between two

warring states of China. Liu Bei the leader

of the Shu faction seeks

vengeance on the Kingdom of Wu

for Ambushing his oath brother Guan Yu.

Screenshots

Items that can heal your wounds or temporarily increase your attack, defense, or movement speed.
yiling4_zpsf39c265e.png


The Shu encampment.
yiling2_zpsf9b09c7d.png


Tents that can heal you Physically (health) and Spiritually (mana).
yiling5_zps557bed3f.png


The officer line-up.
yiling_zps9a288d36.png
The Terrain is all set, I have all the models ranging from the environment to the character models.
My pressing needs are coding I have some triggers and systems in place but I feel they could be made more
efficient and I also need a few more triggers implemented. The project is open to any help but the main needs
are spell making and coding.

Thanks for your interest!
 
Level 5
Joined
Jul 25, 2008
Messages
126
Is anyone available to help? I need something converted from cJass to vJass. This isn't a massive project but I intend to create more battles in other maps. This map is going to serve as the foundation on which the others will be based off of. Redbaron is almost finished with the UI. I could really use the help of a coder.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
You could try posting the script here so that interested people would get the idea what they're gonna do... Just be patient waiting, we have a shortage free vJass coders atm, most of them are busy building systems.
 
Level 5
Joined
Jul 25, 2008
Messages
126
This is what I need converted from cJass into vJass.

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

this system uses this library

JASS:
library ArrowKeyEvent /*
    =========================================================================
    ArrowKeyEvent version 1.0.0.1
    =========================================================================
    Credits:
    -------------------------------------------------------------------------
    -   Written by Bribe.
    -   Earth-Fury for providing a lot of inspiration for the development of
        this system (especially documentation) via his KeyAction resource.
    -   tooltiperror & Sgqvur for providing very helpful, constructive advice.
    =========================================================================
    Introduction:
    -------------------------------------------------------------------------
    Easy to use, efficient system for handling all arrow key events. It uses
    arrays and GetHandleId lookups to avoid the trap of many cloned functions
    that so many arrow key systems suffer from.
    =========================================================================
    API Guide:
    -------------------------------------------------------------------------
    To help centralize and make everything understandable, I originally used
    the constants appointed by Blizzard (bj_KEYEVENTKEY_LEFT/RIGHT/etc). But
    there was a lot of criticism over their ugliness so I made the following
    constants to correspond accordingly. They have the same values as the BJ
    constants, so you can use whichever is more appealing for you.

    Their purpose is to be passed as arguments so you are able to query such
    things as "is this key pressed" or simply to help make sense of what key
    was pressed from an event response and interpret it as an integer.

        constant integer ARROW_KEY_LEFT  = 0
        constant integer ARROW_KEY_RIGHT = 1
        constant integer ARROW_KEY_DOWN  = 2
        constant integer ARROW_KEY_UP    = 3

    -------------------------------------------------------------------------
    As I was developing this resource, is was mostly written in vanilla JASS.
    I had since converted it to OOP syntax but it has been requested to bring
    it back. I have made it available once again.

    function IsArrowKeyPressed
        takes player whichPlayer, integer arrowKey
            returns boolean

        To find out if the arrow key was pressed, you need to first ask which
        player is holding down the key, and then pass an ARROW_KEY constant
        to represent the key you are querying for.

    function RegisterArrowKeyEvent
        takes code onEvent
            returns nothing

        Instead of making up to 8 different functions for 8 different events,
        you can use this instead. Just specify a function that you want to be
        called whenever any key is pressed. For event responses, reference 1
        of the following 3 functions:

    function GetEventArrowKeyPlayerId
        takes nothing
            returns integer

        This is more of an optimization benefit than not. GetTriggerPlayer()
        will get you the player who pressed the key, but most of the time you
        just need to know the player ID of that person.

    function GetEventArrowKey
        takes nothing
            returns integer

        Call this function to find out which key was pressed. It will return
        one of the four ARROW_KEY constants, of course.

    function IsEventArrowKeyPressed
        takes nothing
            returns boolean

        This is also here more for optimization's benefit. You can certainly
        use "IsArrowKeyPressed(GetEventArrowKey(GetEventArrowKeyPlayerId()))"
        but this is much more convenient I must say.

    -------------------------------------------------------------------------
    "implement ArrowKey"

    ArrowKey API is accessible as if it were part of the implementing struct
    itself. As a bonus, you can create a method "onArrowKeyEvent" that gets
    called automatically when any key is pressed. The method musn't be static,
    because the member "this" is a player ID (to mirror the ArrowKey struct's
    own API). It must take an integer as its first argument to represent the
    pressed or released key. As a final argument, it must take a boolean to
    determine if the key was pressed (true) or released (false).

    The member "this" taken by the method is a player ID.
*/
    //=======================================================================
    //
    // System Code
    //
    //=======================================================================

    globals
        //-------------------------------------------------------------------
        // Yo dawg, I herd you like constant variables so I gave you some new
        // constant variables so you can have some constant variables to go
        // with Blizzard's constant variables.
        //
        constant integer ARROW_KEY_LEFT  = bj_KEYEVENTKEY_LEFT
        constant integer ARROW_KEY_RIGHT = bj_KEYEVENTKEY_RIGHT
        constant integer ARROW_KEY_DOWN  = bj_KEYEVENTKEY_DOWN
        constant integer ARROW_KEY_UP    = bj_KEYEVENTKEY_UP
    endglobals

    //=======================================================================
    // Ugly modules are needed to prevent initialization bugs.
    //
    private module Init
        private static method onInit takes nothing returns nothing
            local player p
            local integer i = 12
            local trigger t = .trig
            loop
                set i = i - 1
                set p = Player(i)
                if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(p) == MAP_CONTROL_USER then

                    //Register arrow key events for playing players
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_LEFT_UP)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_RIGHT_UP)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_DOWN_DOWN)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_DOWN_UP)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_UP_DOWN)
                    call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_ARROW_UP_UP)

                    //Run if library ArrowKey is found in the map.
                    //! runtextmacro optional INIT_ARROW_KEY_AA()
                endif
                exitwhen i == 0
            endloop

            //Run if library ArrowKey is found in the map.
            //! runtextmacro optional INIT_ARROW_KEY_CALL_LINK()

            call .registerEvent(function ArrowKey.actions)
            set p = null
            set t = null
        endmethod
    endmodule

    //=======================================================================
    // A central struct to handle all ArrowKey mechanics. This has its uses,
    // giving you slightly more control over the inner system functionality.
    //
    struct ArrowKey extends array

        //-------------------------------------------------------------------
        // Event responses
        //
        readonly static integer  eventKey        = 0     //Arrow key that triggered the event.
        readonly static boolean  eventKeyPressed = false //Was the arrow key pressed?
        readonly static ArrowKey eventPlayerId   = 0     //The id of the player who pressed the key.

        //Run if library ArrowKey is found in the map.
        //! runtextmacro optional ARROW_KEY_DECLARE_ARRAYS()

        //-------------------------------------------------------------------
        // System variables
        //
        private static trigger trig = CreateTrigger()   //Handles all events.
        private static boolean array press              //Is key pressed?

        //===================================================================
        // User-friendly typecasting.
        //
        static method operator [] takes player who returns ArrowKey
            return GetPlayerId(who)
        endmethod

        //===================================================================
        // Great for simplifying arrow key events - this function runs when
        // any player presses or releases an arrow key. The code passed is
        // expected to "return false".
        //
        static method registerEvent takes code onEvent returns nothing
            call TriggerAddCondition(.trig, Filter(onEvent))
            return
        endmethod

        //===================================================================
        // Returns true if the key is pressed, false if it is released.
        //
        method isPressed takes integer arrow returns boolean
            return press[this + arrow * 12]
        endmethod

        //Run if library ArrowKey is found in the map.
        //! runtextmacro optional ARROW_KEY_AXIS_METHODS()

        //===================================================================
        // If you are running debug tests, this might come in handy.
        //
        static if DEBUG_MODE then
            static method getKeyName takes integer arrow returns string
                if arrow == ARROW_KEY_LEFT then
                    return "LEFT"
                elseif arrow == ARROW_KEY_RIGHT then
                    return "RIGHT"
                elseif arrow == ARROW_KEY_DOWN then
                    return "DOWN"
                elseif arrow == ARROW_KEY_UP then
                    return "UP"
                endif
                return "--"
            endmethod
        endif

        //===================================================================
        //
        // Private Components
        //
        //===================================================================

        //===================================================================
        // Key event handler.
        //
        private static method actions takes nothing returns nothing
            local integer id = GetHandleId(GetTriggerEventId()) - 261
            set .eventPlayerId = GetPlayerId(GetTriggerPlayer())

            //If id is an even number, the key was pressed.
            set .eventKey = id / 2
            set .eventKeyPressed = .eventKey * 2 == id
            set .press[.eventPlayerId + .eventKey * 12] = .eventKeyPressed

            //Run if library ArrowKey is found in the map.
            //! runtextmacro optional ARROW_KEY_SETUP()
        endmethod

        //Run if library ArrowKey is found in the map.
        //! runtextmacro optional INIT_ARROW_KEY_LINK()

        //Initialize the system via module
        implement Init

    endstruct

    //=======================================================================
    //
    // Event Responses
    //
    //=======================================================================

    //=======================================================================
    function IsArrowKeyPressed takes player whichPlayer, integer arrowKey returns boolean
        return ArrowKey[whichPlayer].isPressed(arrowKey)
    endfunction

    //=======================================================================
    function RegisterArrowKeyEvent takes code onEvent returns nothing
        call ArrowKey.registerEvent(onEvent)
    endfunction

    //=======================================================================
    function GetEventArrowKeyPlayerId takes nothing returns integer
        return ArrowKey.eventPlayerId
    endfunction

    //=======================================================================
    function GetEventArrowKey takes nothing returns integer
        return ArrowKey.eventKey
    endfunction

    //=======================================================================
    function IsEventArrowKeyPressed takes nothing returns boolean
        return ArrowKey.eventKeyPressed
    endfunction

    //=======================================================================
    // Implementation of this module allows you to make your struct "extend"
    // the ArrowKey struct. As a bonus feature, you can create a method named
    // "onArrowKeyEvent" that is called whenever a key is pressed or released.
    // The method needs "takes integer arrow, boolean pressed", and must be
    // positioned *above* the "implement ArrowKey" statement (this way it is
    // detected by the static if and doesn't compile to a function interface).
    //
    module ArrowKey

        //Delegates are fun, you should try them out.
        private delegate ArrowKey AK

        //===================================================================
        // Please call this method from *below the module implement statement
        // if you know what's good for you.
        //
        static method operator [] takes player who returns thistype
            return GetPlayerId(who)
        endmethod

        static if thistype.onArrowKeyEvent.exists then
            private static method eventProxy takes nothing returns nothing
                call thistype(.eventPlayerId).onArrowKeyEvent(.eventKey, .eventKeyPressed)
            endmethod
        endif

        private static method onInit takes nothing returns nothing
            local thistype i = 12
            loop
                set i = i - 1
                set i.AK = i    //Delegates require some delegation of course.
                exitwhen i == 0
            endloop
            static if thistype.onArrowKeyEvent.exists then
                call ArrowKey.registerEvent(function thistype.eventProxy)
            endif
        endmethod

    endmodule

endlibrary
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
So, there are errors? Please head to the Triggers & Scripts section and post the errors, help would come quicker there. Good luck.
 
Level 5
Joined
Jul 25, 2008
Messages
126
You sure its vJass? Why would it work flawlessly with cohader's enabled? That's the reason why I thought it in cJass. Anyways posted it in the scripts section like you said. Here's the error I get when trying to save with vexorian's enabled.

136523d1404189648-help-vjass-error-error.png
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Try using cohadar mode on jasshelper, I think the for keyword is only available to cohadar's version of jasshelper.

EDIT: Oh I see, the problem was with the for keyword, it only works on cohadar's jasshelper...
 
Level 5
Joined
Jul 25, 2008
Messages
126
Most of my systems and scripts use vexorian so I can't enable cohaders. Tried doing what Fingolfin said but not sure if I did it correctly. See here

http://www.hiveworkshop.com/forums/triggers-scripts-269/help-vjass-error-254159/#post2549259

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

I'm not fluent in vJass all I know is that some systems work when vexorians is enabled and they dont work when cohaders is enabled (in my map) and this particular system we are discussing now, works with cohader's and not vexorians. Which is why I need it to work with vexorians.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Cohadar's JassHelper != cJass. cJass is separate project that has syntax very similar to C. Cohadar's JassHelper is just continuation of Vexorian's. Just so you dont confuse it anymore. And you cant say most systems use vexorians, I think that everything that is compilable under vexorian's JassHelper will also compile under Cohadar's
 
Level 5
Joined
Jul 25, 2008
Messages
126
Thanks for the clarification I thought:
vJass = vexorian jass
cJass = cohader

Not sure if i'm do more harm then good to the code by attempting to fix it myself. I'm just not familiar with vJass to jump into a huge code like this. I will make a thread to commission a coder soon if any interest pm or vm me.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Looks like you just need to convert some of Cohader's syntactic sugar into plain old (v)Jass, like that for loop for example. You could do that manually (fix each error, save script, then fix then the next).

I'm in the middle of my own project, but I think I can get your libraries to work for plain vJASS (no Cohader) if that's what you need. I'm also looking for help in my own project--specifically terrain work. If you think we could help each other, send me a PM.
 
Status
Not open for further replies.

Similar threads

Top