• 🏆 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!

Increase damage after killing some units

Status
Not open for further replies.
Level 6
Joined
Jul 23, 2018
Messages
243
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?
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
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:

we-png.354143


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:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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.
 
Level 6
Joined
Jul 23, 2018
Messages
243
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.
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.
Yes, this is MUI.
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
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
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
  • 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.
 

Attachments

  • Marksman Example.w3m
    24 KB · Views: 68
Level 6
Joined
Jul 23, 2018
Messages
243
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:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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.
 
Level 6
Joined
Jul 23, 2018
Messages
243
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
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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:
Level 6
Joined
Jul 23, 2018
Messages
243
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?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
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
 
Level 6
Joined
Jul 23, 2018
Messages
243
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.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
Not too sure what you mean about the Unit Group.

Spell Damage will require a Damage Engine and some variables to store the value to each unit. A Unit Indexer + Damage Engine can do this.

The Damage Engine trigger would look like:
Events:
A unit takes damage
Conditions:
Damage type equal to Spell Damage
Actions:
Set DamageDealt = DamageDealt * SpellMultiplier[custom value of Damaging unit]

SpellMultiplier would be a Real that's equal to 1.00 by default. Whenever you increase/decrease a unit's Spell Damage, you scale this value.

So if you wanted a unit to deal 10% increased Spell Damage, you set it's SpellMultiplier to 1.10.

If you wanted to increase it's Spell Damage by 10% then you'd do Set SpellMultiplier[custom value of unit] = SpellMultiplier[custom value of unit] + 0.10.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
1) Create a new variable called SpellMultiplier
2) Make it a Real with an Array []
3) Set it's Initial Value to 1.00, which needs to be done in the Variable Editor (Control + B)

4) Then import this Damage Engine into your map: Damage Engine 5.6.1.0
5) Create a new trigger that looks like this (The Event can be found under Game - Value of Real Variable):
  • Damage Modifier Event
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to True
    • Actions
      • Set VariableSet CV = (Custom value of DamageEventSource)
      • Set VariableSet DamageEventAmount = (DamageEventAmount x SpellMultiplier[CV])
This will multiply ANY spell damage that a unit deals by it's SpellMultiplier stat.

From this point on you can increase/decrease/set SpellMultiplier[CV] whenever you want. It's like any other stat.

Here's an example of increasing a Hero's SpellMultiplier by 25% whenever it levels up.
  • Level Up Spell Dmg
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Set VariableSet CV = (Custom value of (Leveling Hero))
      • Set VariableSet SpellMultiplier[CV] = (SpellMultiplier[CV] + 0.25)
So if you wanted to increase a unit's SpellMultiplier[CV] in your Marksman trigger you could increase it the same way as you increase Marksman_BonusDamage[CV].
 

Attachments

  • Spell Damage.w3m
    41.7 KB · Views: 59
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
Actually, I'm using 1.29 so it's useless to open your map or the Damage Engine. Do you know any other damage engine that works for older patch?
 
Level 6
Joined
Jul 23, 2018
Messages
243
Unfortunately, I am unable to find older version of that Damage Engine. I already searched around on Hive. Or I have to copy the trigger Bribe showed? Or vJass?
 
Last edited:
Status
Not open for further replies.
Top