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. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. 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. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    It's a tiny script and easily implementable. I hope he knows how to use Jass script with GUI triggers.
     
  2. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Yea I thought there was one, the problem is just that I haven't really been reading guides or so, only figured out stuff on my own, that's why I'm not so well-informed in some things...
     
  3. Pyritie

    Pyritie

    Joined:
    Nov 26, 2006
    Messages:
    11,356
    Resources:
    60
    Models:
    30
    Icons:
    9
    Packs:
    3
    Skins:
    12
    Tools:
    1
    Maps:
    1
    Tutorials:
    4
    Resources:
    60
    Are you still working on this?
     
  4. redmarine

    redmarine

    Joined:
    Sep 4, 2007
    Messages:
    2,781
    Resources:
    1
    Maps:
    1
    Resources:
    1
    This seems like it has evolved into a tutorial now. Seems pretty good.
     
  5. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Nah, this is all I could/wanted to do. Thanks for the help to all of you, I think I can let it be as it is right now.
     
  6. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    Just a notice, i dont know why, but it seems like host system doesnt work at all anymore.. Ive been using it in my recently new map, and it chooses one of the other players, not me.
     
  7. intake360

    intake360

    Joined:
    May 3, 2009
    Messages:
    21
    Resources:
    0
    Resources:
    0
    You'll Know soon enuff.

    Just fix the leaks and it will be alll fine. :D. I usually save leak fixing till the end of a map. So you can have all the fun while brainstorming. Remember, leak fixing can boost your map performance by alot .
     
  8. busterkomo

    busterkomo

    Joined:
    Jun 17, 2007
    Messages:
    1,423
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    You can avoid unit groups all together by using upgrades.
     
  9. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Yea, but you'd have to add the upgrades to the monsters in the object editor... Which could mean a lot of work if there were a lot of creeps or/and a lot of upgrades.
     
  10. Hugget Sukker

    Hugget Sukker

    Joined:
    Jan 28, 2009
    Messages:
    367
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I experience the same frequently... with the random numbers not being random, you know. But I know that it still works.
    Thing is: Have you ever wondered why every time you place a Paladin or any other melee hero, it has the exact same name
    every time you test the map. That's because all maps use the same random seed every time they are launched from the World Editor.
    Try and run it by opening the game and playing it in Custom Game. Change the user away from WorldEdit just to be sure.
    I'm not sure how it works exactly.

    The unitGroup thing. It's true. Remember to do "custom script: set bj_wantDestroyGroup = true"... (it's JASS) OR set a unitgroup
    variable to the unitgroup you want to use (call it TempGroup or something similar), and then afterwards do "custom script: call DestroyGroup(udg_TempGroup)".

    You have to remove points, unit groups, player groups, special effects, regions, etc. if they are dynamically created through your triggers.
    As a rule of thumb, use a temporary variable, and destroy it afterwards. It will not destroy the object, but its handle, thus releasing more
    memory by preventing memory leaks, and thus improving your map's speed and decreasing risks of program crashes and such.

    Read the tutorials about memory leaks if you don't know anything about this. It's important. If you allready knew this, sorry.
    I was quite surprised the first time I ever heard about memory leaks. But they are in fact one of the most common problems you get when
    programming in almost any object-oriented language. Though, my pa claims he's never experienced a single memory leak in his hobby/work
    programs. I think there are languages in which you don't or very rarely get leaks.

    Integers, reals, and booleans don't leak. Strings may leak at a microscopic level, I've heard.

    Think about the system first. Make at least one template creep with necesary upgrades and such to CnP and base each creep type on.
    And the easiest difficulty system I know is to use a trigger to set Handicap for all creeps, and add some to the primary attribute(s) of the hero(es). Why not? It's so easy.
     
  11. .Ragnaros

    .Ragnaros

    Joined:
    Aug 13, 2009
    Messages:
    181
    Resources:
    0
    Resources:
    0
    Well instead of changing the max hp, can't you just play with the handicaps?
     
  12. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    The best thing to do would be playing with the handicap and using my idea together. For example, you could use a 150% handicap combined with a 30% evasion and 30% attack speed increase for a medium difficulty, and 200% handicap combined with a 60% evasion and 60% attack speed increase for a hard difficulty. Don't forget that these extra things are applied to the monsters, I'm not stupid. ><
     
  13. .Ragnaros

    .Ragnaros

    Joined:
    Aug 13, 2009
    Messages:
    181
    Resources:
    0
    Resources:
    0
    O'rly? :D

    Yep good idea...
     
  14. Tau Empire

    Tau Empire

    Joined:
    May 11, 2008
    Messages:
    854
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Sorry for the incredibly long necropost but, let's say I do a hero defense and it's spawn based all the time right? Well would these abilities work on all the spawn waves or just spawn 1?
     
  15. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    You make the trigger once, and after every spawn, you let it run that trigger.
     
  16. Tau Empire

    Tau Empire

    Joined:
    May 11, 2008
    Messages:
    854
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Ok I'm a little confused how to make the trigger run again like do I say add Event to Trigger every X seconds run this trigger? Cause if that's true then he has to type -easy, -normal or hard all the time lol.
     
  17. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Not really. You could create a variable. Call it let's say... "Difficulty". It could be a string or integer variable. When the host types -easy, then the variable (Difficulty) should be set to "easy" (if your variable is a string variable), or "1" (if it's an integer variable). This is one trigger.
    The next trigger does the actual thing, you should simply do it like on the first post (include the help we got from other members), but there has to be no event, and the requirements in the "IF" parts should be all about your little variable. For example: if "Difficulty" equals to "easy", then do..., else do...
    Whenever the host types the command to set the difficulty, you should make it run the actual trigger at the end. So, AFTER setting the variable, you must add "Run Trigger: XY" (whatever you called your trigger that adds the abilities and such).

    I know it got a little bit confusing, but yea... Hope it helps. If it doesn't, tell me what's not clear and I'll find an easier way to tell you.
     
  18. Tau Empire

    Tau Empire

    Joined:
    May 11, 2008
    Messages:
    854
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I think I get what you mean but just incase, throw in some triggers that I should be using, so I don't screw up anywhere.
     
  19. hunalexnl

    hunalexnl

    Joined:
    Jun 1, 2008
    Messages:
    173
    Resources:
    2
    Maps:
    1
    Tutorials:
    1
    Resources:
    2
    Here you go:

    First one is the chat message, setting the difficulty.
    • chat message
      • Events
        • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
      • 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
            • Set Difficulty = 1
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Entered chat string) Equal to -medium
              • Then - Actions
                • Set Difficulty = 2
              • 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
                    • Set Difficulty = 3
                  • Else - Actions
        • Trigger - Run add abilities <gen> (checking conditions)


    Second one is the trigger that I called "add abilities" - which applies the selected difficulty.
    • add abilities
      • Events
      • Conditions
      • Actions
        • Player - Set Neutral Hostile handicap to ((Real(Difficulty)) x 100.00)%
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
          • Loop - Actions
            • Unit - Remove Damage (Easy) from (Picked unit)
            • Unit - Remove Damage (Medium) from (Picked unit)
            • Unit - Remove Damage (Hard) from (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Difficulty Equal to 1
              • Then - Actions
                • Unit - Add Damage (Easy) to (Picked unit)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Difficulty Equal to 2
                  • Then - Actions
                    • Unit - Add Damage (Medium) to (Picked unit)
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Difficulty Equal to 3
                      • Then - Actions
                        • Unit - Add Damage (Hard) to (Picked unit)
                      • Else - Actions
        • Custom script: bj_wantDestroyGroup=true


    And the third one - in your case - is the monster spawn. This is a very basic setup, just to show you an example.
    • spawn
      • Events
        • Time - Every 10.00 seconds of game time
      • Conditions
      • Actions
        • Unit - Create 10 Footman for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        • Trigger - Run add abilities <gen> (checking conditions)


    Triggers: chat message, add abilities, spawn
    Variables: Difficulty (integer - but it could also be real type)

    Hope this helps.
     
  20. Tau Empire

    Tau Empire

    Joined:
    May 11, 2008
    Messages:
    854
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Yeap makes sense now thanks +rep also one tiny problem.

    • Difficulty Given
      • Events
      • Conditions
      • Actions
        • Player - Set Player 12 (Brown) handicap to (Real((Difficulty x 100)))%
        • Custom script: bj_wantDestroyGroup=true
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Difficulty Equal to 1
              • Then - Actions
                • Do nothing
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Difficulty Equal to 2
                  • Then - Actions
                    • Unit - Add Attack (NORMAL) to (Picked unit)
                    • Unit - Add Max HP (NORMAL) to (Picked unit)
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Difficulty Equal to 3
                      • Then - Actions
                        • Unit - Add Attack (HARD) to (Picked unit)
                        • Unit - Add Max HP (HARD) to (Picked unit)
                      • Else - Actions
                        • Do nothing


    I got a error from this one saying Expected 'set' on call ForGroupBJ( GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(11)), function Trig_Difficulty_Given_Func003A )
     
    Last edited: Sep 10, 2009