• 0

    posted a message on [New Small Question] Code Elegance Question

    Others have covered the WHAT... As for the WHY would you have 2 commands to do the same thing?

    In effect, using the "pick each player" is like a shortcut where it will create a "hidden" variable which you can access using "picked player". Feel free to use this whenever you loop through a player group.

    So why would you use the "worse" version? Well, there are times though when you would want to do things "by hand" so to speak, because you need more control than the "pick each player" is able to give you.

    This is the first scenario that I thought of. Hopefully even if it is a bit more advanced than you are ready for you will be able to see why "picked each player" is too blunt a tool to use in complex situations.

    EXAMPLE A -
    You created an 8 player FFA game.
    Once every minute you want to create 7 monsters belonging to player 1 at player 1s base and send them to attack each opponent.

    You could create 7 commands:
    this_player = 1;
    create a monster belonging to (this_player) in (this_player) base and send it to attack (player 2);
    create a monster belonging to (this_player) in (this_player) base and send it to attack (player 3);
    create a monster belonging to (this_player) in (this_player) base and send it to attack (player 4);
    create a monster belonging to (this_player) in (this_player) base and send it to attack (player 4);
    etcetc...

    But the above solution is tedious, error prone, time consuming etcetc.
    (EDIT: I just realised that I ACTUALLY made a mistake above which just goes to show how easy it is to do. I'm leaving the mistake in.)

    Since we are only doing a simple loop we can use a "pick each player" loop. The code would be:

    this_player = 1;
    pick each player in group (all players)
    {
        if (picked player) != this_player
            create a monster belonging to (this_player) in (this_player) base and send it to attack (picked player);
    }

    This will not do anything when  "picked player" == this_player. Because it makes no sense to create a monster to attack our own base.

    EXAMPLE B -
    *surprise!* During play testing it was discovered that the game in example A completely sucks!

    It was completely unfair to only create monsters to help player 1. But you liked the game mechanic so you decided to make it fair and do this for all players!

    You could do this by creating 8 identical loops one for each player... or you could have a loop within a loop.

    for each player (this_player) in group (all_players)
    {
        pick each player in group (all players)
        {
            if (picked player) != this_player
                create a monster belonging to (this_player) in (this_player) base and send it to attack (picked player);
        }
    }

    Notice that the inside loop is identical to the one in example A. (I LITERALLY copy&pasted it). The only thing I changed was to create a loop which iterates over the variable "this_player".

    The reason that you HAD to use the "for each player" loop and NOT the "pick each player loop" was because you cannot have a "pick each player" within another "pick each player". this is because "picked player" usually refers to the player we are looping over, however if we are using 2 loops AT THE SAME TIME then there is no way to distinguish which player we meant... it could be the player from either loop! That is why we need the ability to specify a variable instead of letting "pick each player" do it for us.

    CONCLUSION:
    "pick each player" is more limited. It could be removed from the editor and I for one would not mourn its passing. However it is a bit like the "for" vs "while" arguments at the start of this thread. There is nothing wrong with using a less powerful tool to do a job. In fact, it is actively encouraged in most circumstances... It is not a good idea to use a steamroller to iron your clothes or a bulldozer to dig up weeds. Yes it is more powerfull, but there is a far greater chance of you f**king something up! "Less is more" and all that jazz.

    tldr;
    having a "pick each player" loop inside a "pick each player" loop makes no sense

    Posted in: Triggers
  • 0

    posted a message on Problem with Texts in Dialogs

    you have to make a dialog visible which you have not done in the editor pic. Use the "show dialog" action.

    As for the in-game image this is what can happen when you edit the galaxy script from a map but the localization data is not up to date... Something about it not actually storing the raw text but a reference to a string so that you can have a version in different languages. Don't really know much about it or how to easily fix it.

    can you show an image from a blank map with just the code:

    create dialog .......
    create label with text "abc" for last created dialog
    show last created dialog

    to see if that works?

    Posted in: Triggers
  • 0

    posted a message on [New Small Question] Code Elegance Question

    lol.

    I think while loops are less scary for people who are just starting to learn how to code. Even if they use them exactly like a for loop at least it gets them thinking about the actual logic of the problem.

    If you worked for me and used while loops instead of for loops for simple tasks... I would wait until you'd had a few months of experience behind you before I started flaying skin :P join my hypothetical coding team instead, I'm less of a harsh task master hahahaha.

    EDIT:
    When he wrote "int i = 0;" he is blending into other languages. It is very common in C like languages to declare an integer variable like that.

    It is just like creating a variable in the trigger editor of type "integer" and setting the default value to 0.

    Posted in: Triggers
  • 0

    posted a message on [New Small Question] Code Elegance Question

    It's great that you are looking at how to better structure your code. So often people only concern themselves with what works. This usually backfires and they are left with a mess which is impossible to understand and fix/extend/debug. I have to re-learn this lesson every time I code :P

    First off: NEITHER of these solutions is correct. They both have bugs in them that will prevent them from working in their current form* (solutions at the back). Example 1 will assign people to the wrong teams and example 2 will loop infinitely until the game client times out and kills the process.

    However I can see where you are going and in terms of //**style**// the first one is much better for a two reasons i can think of:

    READABILITY- The first one is much more concise, there is only 1 loop and one if statement so the logic is simpler. At a glance you can tell that tmpPlayerInteger ranges from 1 to 6 (can't do this in example 2) and you can tell what logic is used to assign a player to a team.

    MAINTAINABILITY - The first one is quite easy to edit if you want changes or if you want to copy+paste it to another map. I cannot stress how much easier and less stressful your time will be if you code with an eye towards maintainability. Say for example you wanted to make it 4v4 or if you wanted to make the teams 4v2. For both of these it would be easy to change the code in example 1, simply edit the loop and if statement. Changing the code in example 2 would very likely introduce bugs as the logic flows from one while loop to the next so you would need to track how each while loop effects the next one a much more error prone task.

    A few points (not nescessarily about the code examples you showed but just some advice)
    1) Variable names makes a big difference in readability. naming a variable "Player" is simple and can be read at a glance unlike "tmpPlayerInteger".
    2) Spread comments throughout your code to make it easier to understand. You might know what is going on but if you take a break and come back in 2 weeks time the comments are going to really help you.
    3) use functions whenever there is a block of logic which you want to write once and then forever after think of conceptualy as a "black box". where you can call that function and not have to worry about how it works.

    my solution would be

    //variables://
    Player (integer)
    Team (integer)
    Team_Members (integer)
    Number_of_players (integer)
    Number_of_teams (integer)

    //Actions://
    Number_of_players = 6;
    Number_of_teams = 2;

    Player = 1;
    for each variable ( Team ) from ( 1 ) to ( Number_of_teams )
         for each variable ( Team_Members ) from (1) to (number_of_players / number_of_teams)
              AddPlayerToTeam( Team, Player)
              Player = Player + 1;

    Use of "for loops" is easier to read than "while loops" and easier to code (although if you are just begining while loops may be a simpler starting block).
    This is much more flexible as changing **Number_of_teams** = 3 will result in a 2v2v2. Changing **Number_of_players** = 8 will result in 4v4 etcetcetc
    If you are unfamiliar with the "for loop" it is just like a "while loop" except that it lets you assign the starting vale and how much you increment by.

    * //answers in the back of the book//
    Example 1 - oops, sorry I misread your code, it might actually work... but here is a much cleaner and simpler way of doing what you are doing:

    While player <= 6
         if player <= 3
              AddPlayerToTeam(1, Player)
         else
              AddPlayerToTeam(2, Player)
         Player = Player + 1

    In fact I think this is what you should do. It is still clean and elegant but less confusing than the solution I gave so is probably better for you while still learning.

    example 2 in the code you gave is broken at the second "while loop". While player == 3 you are incrementing team. However player is not being changed inside the loop so player == 3 will always be true and the while loop will continue to loop forever (except that SC2 detects this after a few seconds and kills the process). remove the while loop and just put "team = team + 1" and example 2 should work.

    EDIT: I misread the code example 1 that you gave. But read the solution any way because it is a lot simpler and cleaner.

    Posted in: Triggers
  • 0

    posted a message on Name of Reseach Upgrade

    Sorry for the necro but I'm wondering if anyone has discovered how to do this.

    I also want to do this for every upgrade in the game. It's not so bad with something like "ProtossAirArmorsLevel1" but sometimes the internal name is not the same as the standard name. For example "Adrenal Glands" is called "Zergling Attack Speed" internally.

    Does anyone have a solution? or is the only way to have arrays of each upgrade and the name of each upgrade.

    Thank you

    Posted in: Triggers
  • 0

    posted a message on ELO mod

    @Karawasa: Go

    Each tournament is all in one local bank file. "Global" is just the name of one tournament. It is created automatically and cannot be deleted.

    Posted in: Map Feedback
  • 0

    posted a message on ELO mod

    @Eimtr: Go

    OK, I found the library where you have made a system which records win/loss/win percentage and assigns people into your own custom leagues.

    You didn't say that this was your own custom ranking system and leagues. You were making it sound like you were integrating it with the official battlenet MMR and leagues system and using those to match players against eachother which is not what it does.

    The mod that I made is also a library not just a single map. It can be imported into any map you chose. It is currently released on only one map but when I am finished it will be released on several maps.

    Out of curiosity what formula did you use for your custom ranking system?

    Posted in: Map Feedback
  • 0

    posted a message on ELO mod

    @Eimtr: Go

    OK there is some kind of communication problem going on here because I don't understand what you are saying and I don't think you understand what I am saying either.

    You keep trying to explaining to me how the ladder works on Battlenet. I completely 100% understand how the ladder works.

    A lot of really good players spend a lot of time training and versing against other clan members and other really good players. They do this in custom games not ladder. Ladder rank and MMR are completely seperate.

    There are many people (Masters and Grandmasters) who find that the ladder is a verry BAD way of comparing two players and they want a BETTER way to compare players. It is their belief and mine that this is a far BETTER way for a close knit group of players such as a clan to compare against each other.

    Can you send me a link to information about this library you keep mentioning. I do not understand the way you are trying to explain it.

    Posted in: Map Feedback
  • 0

    posted a message on ELO mod

    @Eimtr: Go

    MMR is simillar to an ELO ranking from what I understand of it. But like you said you cannot know what it is and it is not a very useful way for players to compare against eachother especially at high levels.

    This was actually a request by one of the top clans on SEA server. So if they want to rank their players then their ladder rank is not a useful way to compare the best players in the region against eachother.

    ELO scores also come with a mathamatical prediction on the outcome. For example if you look at the 3rd pic of HerO vs Sheth in the active tournament list there are the numbers

    Global 53%-47% TL Forums 55%-45%

    which are the calculations of the percentage chance each player has to win.

    Sorry, I found your post a little hard to understand. Did you create a library that did something simillar? what does it do?

    Posted in: Map Feedback
  • 0

    posted a message on ELO mod

    I'm just in the last stages of creating a mod which can be added to any map and will keep track of the players ELO rating.

    For those of you who do not know what an ELO rating is it is the ratings system used in chess and many other competitions (including League of Legends).

    This is so that people in clans who practice against eachother in custom games already can have a rating to compare each other with. Simply looking at things like ladder ranking will not be an effective way to compare players. In fact, many people have been requesting that the public ladder be an ELO system from the release of SC2.

    How it works is:

    1. join the game with your opponent.
    2. you can create a new tournament and provide a password if you wish it to be private
    3. select which tournaments you would like to be rated in.
    4. click on "ready" and the game will begin.
    5. each players score will be recorded based on win/loss and updated for the next game.

    I have included some pics to demonstrate the creation/selection of tournaments

    at the start of the game:

    One player inviting the other to a tournament

    Players click on "compete" to enter the tournament

    Demonstration of me trying to cheat by editing my bank file and providing a false password for a private tournament

    I am currently looking for people to help test the mod or to just provide general feedback. at the moment there is only 1 map released with this mod which is "ELO Cloud Kingdom". Just search for ELO on NA server and it should be listed. Thanks and I look forward to hearing what you all think.

    Bye.

    EDIT: I forgot to mention that this was created on my monitor with a resolution of 1280x720. For people using a SMALLER resolution this may not work as there is no way to detect screen resolution in game and adjust for it.

    Posted in: Map Feedback
  • 0

    posted a message on list box font size

    Yes, the list box size is many times larger than the text I am inserting into the list. But I guess when you increase the size of the list the space allocated for each item in the list remains the same.

    So I am guessing there is no solution to this?

    Hopefully list boxes will become much more flexible in HOTS

    Posted in: UI Development
  • 0

    posted a message on can you change the colour of a list box?

    I have a couple of list boxes on a UI that I want to be different colours.

    Let me show you what I mean

    In this photo all the list boxes are a pale blue colour which is the default colour for a list box when your race is protoss.

    If I try and change the colour through the line "set dialog item colour" to change the colour there is some very strange behaviour. For example setting the colour to pure red (FF0000) will make it disapear. Setting the colour to orange will make it turn a bright green etcetc

    I believe that when you try and set the colour it does no directly set the colour but mix it somehow with the colour it already is (blue in this case)

    Tried changing it via "set dialog item image" as well with no luck yet.

    Anyone know how to do this?

    Posted in: UI Development
  • 0

    posted a message on detect mouse scroll

    @finiteturtles: Go

    Also I should add that the "list box" dialog item detects the scroll wheel so obviously the mouse scroll event is detectable somehow

    Posted in: Triggers
  • 0

    posted a message on detect mouse scroll

    I cannot find one in the trigger editor so I'm guessing the answer is "no". But I would like to know for sure as it is not the first time I have ever overlooked anything :)

    when you type "scroll" into the search bar in the editor the only item that shows up is the "mouse click" event but I can't find any "scroll" option

    Posted in: Triggers
  • 0

    posted a message on list box font size

    Is there any way to have larger text inside of a list box?

    The default text size is REALLY, really <sub>really tiny</sub>

    I can change the font of a list box with the "set dialog item style" action but it only seems to work for fonts that are really small.

    If I change the size of the font to anything larger then the text does not show up in the list.

    At the moment my dialog looks absurd having reasonable sized buttons/images etc and then a list right in the middle with tiny little writing in it.

    If the text size cannot be increased is there a list box equivalent that someone has already written and released that I could borrow? I do not want to spend several days coding a list box to overcome this but I may end up having to do so.

    Thanks.

    Posted in: UI Development
  • To post a comment, please or register a new account.