1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Difficulty System - The Easy Way

Discussion in 'Trigger (GUI) Editor Tutorials' started by hunalexnl, Jun 6, 2009.

  1. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Hey there!
    This is a short tutorial I've just set together. It's about adding a difficulty system to your map. I think it's a really easy way to do it and to modify it later on, as it is based on simple spells.
    Here we go:

    • Difficulty System
      • Events
        • Player - Player 1 (Red) types a chat message containing -easy as An exact match
        • Player - Player 1 (Red) types a chat message containing -normal as An exact match
        • Player - Player 1 (Red) types a chat message containing -hard as An exact match
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Matched chat string) Equal to -easy
          • Then - Actions
            • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
              • Loop - Actions
                • Unit - Remove Attack (HARD) from (Picked unit)
                • Unit - Remove Attack (NORMAL) from (Picked unit)
                • Unit - Remove Max HP (HARD) from (Picked unit)
                • Unit - Remove Max HP (NORMAL) from (Picked unit)
                • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected easy mode.)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Matched chat string) Equal to -normal
              • Then - Actions
                • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
                  • Loop - Actions
                    • Unit - Add Attack (NORMAL) to (Picked unit)
                    • Unit - Add Max HP (NORMAL) to (Picked unit)
                    • Unit - Remove Attack (HARD) from (Picked unit)
                    • Unit - Remove Max HP (HARD) from (Picked unit)
                    • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected normal mode.)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Matched chat string) Equal to -hard
                  • Then - Actions
                    • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
                      • Loop - Actions
                        • Unit - Add Attack (HARD) to (Picked unit)
                        • Unit - Add Max HP (HARD) to (Picked unit)
                        • Unit - Remove Attack (NORMAL) from (Picked unit)
                        • Unit - Remove Max HP (NORMAL) from (Picked unit)
                        • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected hardl mode.)
                  • Else - Actions


    This is the whole trigger for your difficulty system. I'll start witch the description of the previously mentioned spells.
    You must go to the object editor and start watching through the spells in special/items (well, this is what I think is best for this). You'll find different spells here, like extra attack, extra HP, some regeneration, defense - these are the basic skills that you should include in your difficulty system. Just create new spells using these, but don't forget to set them to unit abilities, instead of item ones. You could even created special abilities for different modes, like an evasion for hard mode, or even damage reduction!
    After creating your abilities (it's a good idea to give them names like X - HARD or X - NORMAL, so you know which ones you should add to which mode), it's time for the trigger.

    • Events
      • Player - Player 1 (Red) types a chat message containing -easy as An exact match
      • Player - Player 1 (Red) types a chat message containing -normal as An exact match
      • Player - Player 1 (Red) types a chat message containing -hard as An exact match


    The event is really simple, for my trigger, I used a player event, an entered chat message will decide which mode we want. Of course, it's up to you to come up with different ways, you could start it with a dialog buttong click, or even a specific ability that's been created to set the difficulty.
    In my trigger, there is no need for a condition, as I've added them in my if-then-else actions. If you are working with 3 triggers for the 3 (or more of course) different modes, then it's best to leave out the if-then-else part and add the condition to where it belongs.

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Matched chat string) Equal to -easy
      • Then - Actions
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
          • Loop - Actions
            • Unit - Remove Attack (HARD) from (Picked unit)
            • Unit - Remove Attack (NORMAL) from (Picked unit)
            • Unit - Remove Max HP (HARD) from (Picked unit)
            • Unit - Remove Max HP (NORMAL) from (Picked unit)


    Coming to actions, you will notice that for each mode, you need to remove and re-add the abilities you wish to have. The reason for this is following: if I have set the difficulty to hard, but want to set it back to normal, it has to remove the abilities that were added in normal mode. Otherwise, it would all stay as it is. This is only needed if you want to allow the players to set the difficulties whenever and as many times as they want it to be. If you turn off the trigger at the end, then you can skip the "remove ability" part.

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Matched chat string) Equal to -easy
      • Then - Actions
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
          • Loop - Actions
            • Unit - Remove Attack (HARD) from (Picked unit)
            • Unit - Remove Attack (NORMAL) from (Picked unit)
            • Unit - Remove Max HP (HARD) from (Picked unit)
            • Unit - Remove Max HP (NORMAL) from (Picked unit)
            • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected easy mode.)
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Matched chat string) Equal to -normal
          • Then - Actions
            • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)


    You can see how I've set the if-then-else actions, once you're done with the first mode's setting, the next mode will continue inside the first one, using the "then - actions" function. This is my version, but you can also create seperate if-then-else actions to make it even easier for you (if you do that, just leave the "then - actions" as they are, or select the "do nothing" function.

    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
        • Loop - Actions


    Redmarine told me that the unit group part should be done like this, I can't really comment this, as I don't really know how these custom scripts work (yet), but he's more experienced, so let's all trust him hehe!

    At the end, you can add some fancy stuff to your trigger, like I did with the text message. This is just a simple example for it.
    If you want to make your mode even more "visible", you can create 3 spells for the 3 modes (or more, jeez...) based on auras. This means, the monsters must have the spells as buffs. The buff they have will have the name and the description of the mode (this way, if you select an enemy and have your mouse on the buff that it has, you will see which mode you are playing). You could even include a special effect, but that would be rather disturbing in a crowd. Note: do not forget to turn every value in the ability to 0, if you don't want your enemies to have those extra points the aura would basically offer!

    Please note that this is just an example, I simply wanted to help people get into the right way if they happened to want to create a difficulty system for their maps. I'm also sorry if there was a tutorial like this before. I know that for the experienced people this might be really simple (well, it is, but why would we make it too complicated if we don't have to?), but I hope I could help some people new to triggering.

    In this map I've included the spells that you could see in the triggers, and an aura I've been talking about as well!
    Now it also contains an example for the dialog version, as it was requested.
     

    Attached Files:

    Last edited: Jun 6, 2009
  2. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Remember to destroy the unit group leaks.

    Create an action called Custom Script and paste this line in it:
    set bj_wantDestroyGroup = true

    This should be implemented just before the group trigger like this:
    Custom Script: set bj_wantDestroyGroup = true
    Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)

    Make sure that you do that to every unit group action.
     
  3. Ricardo Irving

    Ricardo Irving

    Joined:
    May 10, 2009
    Messages:
    493
    Resources:
    0
    Resources:
    0
    Good work.
     
  4. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Woah, I have no idea what custom scripts are, bah... Is this actually a variable? Is there a custom script to randomize the "random number betwee X and Y" number?!! ;o
     
  5. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Add this custom script before your group actions to destroy the group leak:
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
        • Loop - Actions


    Here is the GUI code to randomize a real number between 0 and 1000.00
    • Set RandomReal = (Random real number between 0.00 and 1000.00)

    This can also be done using integers.
     
  6. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Yea right, but when I did this, it acted like REALLY strange. I mean, I tested a map several times, and when I was using random numbers, the first random number was (let's call it) X, second was Y, third was Z. When I tested it the second time, it gave me the exact same numbers. And the same happened in the other tests.

    Ok, I'll add that to the tutorial. Thanks.
     
  7. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    That is because you have to reset the variable each time you want another random number. If you don't want to store the value then just randomize within the action.

    An Example:
    • Unit - Create 1 Footman for Player 1 (Red) at ((Center of (Playable map area)) offset by ((Random real number between 0.00 and 1.00), 0.00)) facing Default building facing degrees
     
  8. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    And that's how I did it - I randomized it again and again - and it worked in the same game.
    But when I restarted the map, it gave me the same numbers.
    Example:
    Game A
    number 1: 5
    number 2: 10
    number 3: 1

    Game B
    number 1: 5
    number 2: 10
    number 3: 1

    Game C
    number 1: 5
    number 2: 10
    number 3: 1

    So the problem was not in the same game, but in several games. It gave me the same random number EVERY time I launched the game. And that is pretty weird...
     
  9. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    That only happens when you're testing the map using the World Editor's test feature. Try starting the game manually.
     
  10. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Damn lol, didn't know that... Thanks again!
     
  11. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    Good work, wondering( not myself, i CAN convert that to Dialog) if you would do a edit or somthing with a Dialogged verions of it? would help peeps alot.. But +rep :D

    EDIT: Sry... Can't even give you any xS
     
  12. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Let me do that for you.
     
  13. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    ^^

    thnx. Give him ALOT ^^
     
  14. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Re-uploaded the map with the requested changes.
    Thanks for the reputation, redmarine! (although I have no idea what it's good for)
     
  15. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    Thnx. Can be usefull for others :D
     
    Last edited: Jun 6, 2009
  16. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    I sure hope so, thanks for the suggestion.
     
  17. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    You are using more trigger call than you need it for.

    The right way to code it should be like this (Exclude the group leak).

    • Difficulty System
      • Events
        • Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Entered chat string) Equal to -easy
          • Then - Actions
            • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
              • Loop - Actions
                • Unit - Remove Attack (HARD) from (Picked unit)
                • Unit - Remove Attack (NORMAL) from (Picked unit)
                • Unit - Remove Max HP (HARD) from (Picked unit)
                • Unit - Remove Max HP (NORMAL) from (Picked unit)
                • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected easy mode.)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Entered chat string) Equal to -normal
              • Then - Actions
                • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
                  • Loop - Actions
                    • Unit - Add Attack (NORMAL) to (Picked unit)
                    • Unit - Add Max HP (NORMAL) to (Picked unit)
                    • Unit - Remove Attack (HARD) from (Picked unit)
                    • Unit - Remove Max HP (HARD) from (Picked unit)
                    • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected normal mode.)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Entered chat string) Equal to -hard
                  • Then - Actions
                    • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
                      • Loop - Actions
                        • Unit - Add Attack (HARD) to (Picked unit)
                        • Unit - Add Max HP (HARD) to (Picked unit)
                        • Unit - Remove Attack (NORMAL) from (Picked unit)
                        • Unit - Remove Max HP (NORMAL) from (Picked unit)
                        • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + has selected hard mode.)
                  • Else - Actions
     
  18. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,944
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Septimus, his is case insensitive, yours is not. Thus yours does not function the same as his.

    Anyway, this is hardly a difficulty selection method. Firstly it always works for some reason with Player(0) Red, which seems stupid as there is nothing special about him that the other players cant be. Secondly it only is influenced by one player.

    Eithor make it a multiple player voting system, or else make it that it asks the game host.

    An example of a propper difficulty selection system is seen in my Green Circle TD, for choosing difficulty. It asks with labled dialogs, is efficent and reasonably accurate (boundaries untested).
     
  19. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    In the example map I've included a dialog version. Check it out if you're interested at least a bit...
    And I'm not sure that "host" can select the modes, as this stuff is about players. What if the host decides to move down to blue, teal, purple? How will I decide which one the host is?
    That's why red can decide - in most of the cases, the host gets the red slot and remains there if he doesn't want to switch for some reason. I don't know about any method that can make the game decide which one the host is... There most possibly is one, I'm simply a newbie. But the system works and is great for newcomers like me - they were my targeted audience.
     
  20. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,174
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    At least it use lesser call. :p

    There is a system to detect who is the host. So no matter which side it choose, it would automatically select the same host.