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. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    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.

Increase damage after killing some units

Discussion in 'Diablo III Warcraft' started by TheFireMage, May 5, 2020.

  1. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    So I want to make a trigger that increase hero's damage every time the hero kills some units: upload_2020-5-5_19-10-31.png
    It works when I set Marksman=(Marksman+1) but that increase 1 damage every 1 unit killed, I want to increase 1 damage every 10 units killed.
    Did I miss something?
     
  2. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    926
    Resources:
    0
    Resources:
    0
    It took me a moment to see the logic behind your trigger, but I figured out why it doesn't work. I mean, I know what's happening, but the logic for that is something that I will summon @Uncle or @Dr Super Good or anyone smarter then me for, because I honestly have no damn clue how or why it's happening. And I'm curious :D

    ---

    Anyway, before we proceed - let me introduce you to the most basic concept of debugging (i.e. looking for errors) your own code. All you need is this lovely action:

    • Game - Display to (All players) the text: <Your String> // for example: value of a real/integer variable converted to a string

    The way basic debugging works is that you:
    1. Select the chunk of code you want to debug.
    2. Make sure that you can run that chunk of code quickly and easily (for instance by copying it to another trigger that fires periodically or when the user presses a key).
    3. Use the action above to print out (i.e. display on screen) the desired info.

    In the case of your trigger, you might want to print out the values of Marksman and Marksman 2 see a) if the trigger even gets through the initial set of conditions and b) what happens with these values and how they are converted between each other, because that's what's going to affect your second condition.

    To summarize - using text messages allows you to track the values of your variables, detect where the execution of the trigger gets stuck (e.g. which conditions aren't being passed successfully) or what actions aren't working as intended. And probably more.

    Anywho, that way you can easily identify which part of your code is causing issues and work on solutions.

    ---

    So, my first instinct was that your issue occured due to something happening with the way reals are converted to variables in the WE, so I've made this little debug trigger:

    • Set RealVariable = (RealVariable + 0.10)
    • Set IntegerVariable = (Integer(RealVariable))
    • Game - Display to (All players) the text: ((Real = + (String(RealVariable))) + (; Integer = + (String(IntegerVariable))))

    P.S. Don't worry about the "string math" I've used - it's just to make the results look pretty. A simpler version of that trigger using two text message actions, where the first one would be (String(RealVariable)) and the second (String(IntegerVariable)) would work just as well.

    I've expected the numbers to get truncated, i.e. the decimal part of the real variable to be cut, for example 1.2 -> 1; 1.7 -> 1; 2.0 -> 2, but... this is what I got:

    [​IMG]

    Here's where I ask the guru's how is this possible? (because I honestly have no idea)

    ---

    Anyway, that's the reason why your trigger didn't work - your logic was obviously to reach a point where when the real variable reaches for example 1.0 then it would get converted to a 1 integer value and thus the condition would be met. Unfortunately, that only happened when the real variable had the value of for instance 1.1 and thus it wasn't equal to 1 when you thought it was going to be.

    How to solve this? Well, you can simply counter this behavior by using math inside the condition to have things go your way:

    • Marksman Equal to ((Real(Marksman2)) + 0.1)

    OR

    • (Marksman - 0.1) Equal to (Real(Marksman2))

    But my question to you is... why? You chose a fairly awkward way of doing this trigger - a much simpler option would be to use a single integer variable and do this:

    • Set IntegerVariable = (IntegerVariable + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • IntegerVariable Equal to 10
      • Then - Actions
        • Set IntegerVariable = 0
        • //Your other actions//
      • Else - Actions

    That's just as effective, but simpler, cleaner and a tiny bit more efficient (I think) :)
     
    Last edited: May 5, 2020
  3. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    Not sure about the conversion stuff. I know it used to work like how you described. Must be a Reforged issue.

    Also, I'm curious if OP wants this effect to be MUI since he checks for different Unit-Types in his condition. Almost sounds like he does in his description.
     
  4. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    926
    Resources:
    0
    Resources:
    0
    I've tested it in 1.31:)
     
  5. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    How to set the limit now?
    I only want the unit to have 25 bonus damage for level 1, 50 bonus damage for level 2 and unlimited for level 3.
    Yes, this is MUI.
     
    Last edited: May 5, 2020
  6. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    926
    Resources:
    0
    Resources:
    0
    Try using another integer variable to track the numer of times the buff was applied :)
     
  7. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    Would it work this way? For MUI.
    • Marksman Lvl 1
      • Events
        • Unit - A unit Dies
      • Conditions
        • ((Dying unit) is A ground unit) Equal to True
        • (Level of Souls Capturer for (Killing unit)) Equal to 1
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Killing unit)) Equal to Archer Queen
            • (Unit-type of (Killing unit)) Equal to Archer Queen (AI)
      • Actions
        • Set Marksman = (Marksman + 0.10)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Marksman Equal to 1.00
          • Then - Actions
            • Set Marksman = 0.00
            • Set Marksman2 = (Base Damage of (Killing unit) for weapon index 1)
            • Unit - Set Base Damage of (Killing unit) to (Marksman2 + 1) for weapon index: 1
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Marksman2 Equal to 26
              • Then - Actions
                • Set Marksman2 = 25
                • Unit - Set Base Damage of (Killing unit) to (Marksman2 - 1) for weapon index: 1
              • Else - Actions
          • Else - Actions
     
  8. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    Global variables can only be set to one value at a time. Meaning those Marksman variables are shared between ALL of the Archer units.

    This is where a Hashtable or even easier a Unit Indexer comes into play.

    I can show you an example when I get a chance.

    Also, Marksman should be an Integer. Just increase it by 1 and count to 10 rather than 0.10 and 1.00.
     
  9. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    Can you help me with this? I'm a noob at hashtable and indexing. I'll be very grateful.
     
  10. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    • Marksman Setup
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Set VariableSet Marksman_Limit[1] = 25
        • Set VariableSet Marksman_Limit[2] = 50
        • Set VariableSet Marksman_Limit[3] = 0
        • -------- It doesn't matter what you set Marksman_Limit[3] to as it will always be Unlimited --------
        • -------- --------
        • -------- Set this variable as your Marksman Ability --------
        • Set VariableSet Marksman_Ability = Marksman Example

    • Marksman Kill
      • Events
        • Unit - A unit Dies
      • Conditions
      • Actions
        • Set VariableSet CV = (Custom value of (Killing unit))
        • Set VariableSet Level = (Level of Marksman_Ability for (Killing unit))
        • -------- --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • Marksman_BonusDamage[CV] Less than Marksman_Limit[Level]
                • Level Equal to 3
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Marksman_Counter[CV] Less than 10
              • Then - Actions
                • Set VariableSet Marksman_Counter[CV] = (Marksman_Counter[CV] + 1)
              • Else - Actions
                • Set VariableSet Marksman_Counter[CV] = 0
                • Set VariableSet Marksman_BonusDamage[CV] = (Marksman_BonusDamage[CV] + 1)
                • Unit - Set Base Damage of (Killing unit) to ((Base Damage of (Killing unit) for weapon index 0) + 1) for weapon index: 0
          • Else - Actions

    Uses Bribe's Unit Indexer -> GUI Unit Indexer 1.4.0.0

    I left the conditions blank, add your conditions to it.
     

    Attached Files:

  11. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    I cannot open the map, are you using latest WE?
    And I assume all of your variables are integers, except for Marksman_Ability. I see 6 variables in total in those triggers. These 2 triggers can be used for MUI, right?
     
    Last edited: May 6, 2020
  12. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    Im using the latest version.

    And yes, they're all Integers besides the Ability one. You dont even really need that Ability variable, I think it's only referenced once when you set Level = level of your ability for killing unit.

    Anything with a [ ] has an Array enabled.

    Dont forget the unit indexer. But be wary, if you use Custom Value in your map for other things this will interfere with that. Luckily it's an easy fix to make those triggers work with the unit indexer instead.
     
    Last edited: May 6, 2020
  13. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    So I have to combine Bribe's unit indexer with your triggers?
     
  14. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    You import the Unit Indexer into your map. It's a system that runs automatically. It assigns each unit a unique Custom Value.

    My triggers take advantage of this system by using the unit's Custom Value as the Index [] for the variables.


    How to set it all up: You copy the folder "Unit Indexer" and paste it into your map. Then you copy the folder containing my Marksman triggers and paste it into your map.

    After both folders are in your map, you'll want to configure the Marksman Setup and Marksman Kill triggers to work for your map.

    That means you'll want to add your old Conditions (Unit-type of killing unit equal to Archer etc...) to my Marksman Kill trigger. And in the Marksman Setup trigger you'll want to set Marksman_Ability = Souls Capturer.

    Note that you'll want to delete the condition "Level of Souls Capturer equal to 1", as my Marksman Kill trigger is designed to work for all 3 levels.
     
    Last edited: May 8, 2020
  15. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    Another important thing I forgot to mention.
    • Unit - Set Base Damage of (Killing unit) to ((Base Damage of (Killing unit) for weapon index 0) + 1) for weapon index: 0

    Blizzard made Indexes start at 0, so 0 = 1, and 1 = 2.

    In other words, weapon index: 0 = Attack 1. And weapon index: 1 = Attack 2.
     
  16. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    If I want to set the limit for both units killed based on levels, I have to make 3 different triggers based on your triggers? The condition that matters is this one?
    • Level equal to 3
    .
    And the limit for bonus damage in the triggers is this one?
    • Marksman_Counter[CV] Less than 10
     
  17. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    The limit is defined in the Marksman Setup trigger. You only need the triggers I provided.

    Level = the current level of the Marksman ability for the killing unit

    In the condition: Level equal to 3, i'm checking to see if the Level is 3 so I know if it's unlimited or not. Since level 3 is unlimited I can increase Counter/Damage freely without worrying.

    To further explain it, I use an OR to determine whether or not the Actions should run (the actions increase Counter and potentially increase Damage). So if you're under the limit OR the Level is equal to 3, then run the Actions, otherwise do nothing as you haven't met either of those conditions. If you wanted for example Level 2 of the ability to be unlimited as well, simply add another condition to that OR "Level equal to 2".

    And yes, that 10 is the 10th kill that increases damage.
     
    Last edited: May 8, 2020
  18. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    I put the weapon index 0 and it did not increase her damage, so I changed it to weapon index 1 and it works. One problem still, the bonus damage is still there since the bonus damage is applied permanently, not wit buff. She kept the bonus damage after she died. Anyway to remove bonus damage after she dies?
     
  19. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    1,701
    Resources:
    0
    Resources:
    0
    Marksman_BonusDamage is equal to the amount of damage added to your unit(s).

    So when the unit revives, subtract whatever damage it has gained so far, and reset the BonusDamage variable.
    • Revive
      • Events
        • Unit - A unit Finishes reviving
      • Conditions
        • Unit-type of Reviving unit equal to your Unit
      • Actions
        • Set VariableSet CV = (Custom value of (Reviving Hero))
        • Unit - Set Base Damage of (Reviving Hero) to ((Base Damage of (Reviving Hero) for weapon index 1) - Marksman_BonusDamage[CV]) for weapon index: 1
        • Set VariableSet Marksman_BonusDamage[CV] = 0

    You could also Reset the Counter, so it has to kill 10 units in a row again to gain 1 damage.
    • Set VariableSet Marksman_Counter[CV] = 0
     
  20. TheFireMage

    TheFireMage

    Joined:
    Jul 23, 2018
    Messages:
    68
    Resources:
    0
    Resources:
    0
    Thanks. And one more thing, that's one was increasing base damage, how about spell damage? I tried using unit group variable but it ended up being shared between other units.