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

[Solved] How to make it with less triggers

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,137
Hello everyone. I was created ability that increases attack damage when hit point decreases. But as you can see, it is painful with lot of triggers.
How to make it better?

  • Rage of Strength Run
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RageofStrengthCasterGroup and do (Actions)
        • Loop - Actions
          • Set Magnataur = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blizzard for Magnataur) Equal to 1
            • Then - Actions
              • If ((Percentage life of Magnataur) Greater than 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 1) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 2) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 50.00) then do (Unit - Set level of Rage of Strength for Magnataur to 3) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 25.00) then do (Unit - Set level of Rage of Strength for Magnataur to 4) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 10.00) then do (Unit - Set level of Rage of Strength for Magnataur to 5) else do (Do nothing)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blizzard for Magnataur) Equal to 2
            • Then - Actions
              • If ((Percentage life of Magnataur) Greater than 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 6) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 7) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 50.00) then do (Unit - Set level of Rage of Strength for Magnataur to 8) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 25.00) then do (Unit - Set level of Rage of Strength for Magnataur to 9) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 10.00) then do (Unit - Set level of Rage of Strength for Magnataur to 10) else do (Do nothing)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blizzard for Magnataur) Equal to 3
            • Then - Actions
              • If ((Percentage life of Magnataur) Greater than 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 11) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 12) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 50.00) then do (Unit - Set level of Rage of Strength for Magnataur to 13) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 25.00) then do (Unit - Set level of Rage of Strength for Magnataur to 14) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 10.00) then do (Unit - Set level of Rage of Strength for Magnataur to 15) else do (Do nothing)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blizzard for Magnataur) Equal to 4
            • Then - Actions
              • If ((Percentage life of Magnataur) Greater than 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 16) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 75.00) then do (Unit - Set level of Rage of Strength for Magnataur to 17) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 50.00) then do (Unit - Set level of Rage of Strength for Magnataur to 18) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 25.00) then do (Unit - Set level of Rage of Strength for Magnataur to 19) else do (Do nothing)
              • If ((Percentage life of Magnataur) Less than or equal to 10.00) then do (Unit - Set level of Rage of Strength for Magnataur to 20) else do (Do nothing)
            • Else - Actions
 
Level 12
Joined
Jan 10, 2023
Messages
191
Try to look for patterns in your numbers and then apply a math equation- a tip in general

To relate that tip to this, you have almost got a pattern in your numbers that you could use, or you could put most of it to a pattern.



Here's what I came up with. the tiniest nesting, I hope you don't mind:
I used (picked unit). I see no reason to make a variable Magnataur because unless you use Magnataur inside the 'Pick Every Unit' Loop, it will be useless because it is being overwritten again and again until the loop ends and then keeps one random Magnataur stored in the end. If you need a random unit from the group later, just use the 'Random Unit from Unit Group' function:
  • Unit - Kill (Random unit from RageOfStrengthCasterGroup)

Anyway, here it is:
  • Rage of Strength Run
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RageOfStrengthCasterGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Greater than 10.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Rage of Strength for (Picked unit)) Not equal to ((5 x ((Level of Blizzard for (Picked unit)) - 1)) + (5 - ((Integer((Percentage life of (Picked unit)))) / 25)))
                • Then - Actions
                  • Unit - Set level of Rage of Strength for (Picked unit) to ((5 x ((Level of Blizzard for (Picked unit)) - 1)) + (5 - ((Integer((Percentage life of (Picked unit)))) / 25)))
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Rage of Strength for (Picked unit)) Not equal to ((5 x ((Level of Blizzard for (Picked unit)) - 1)) + 5)
                • Then - Actions
                  • Unit - Set level of Rage of Strength for (Picked unit) to ((5 x ((Level of Blizzard for (Picked unit)) - 1)) + 5)
                • Else - Actions
The reason we have two different equations (one for over 10% health, and another for under 10% health) is that your function could be described as a "piece-wise function" which just means it's not really one function, but two functions spliced together.

The reason we are checking if the level of Rage of Strength is "Not equal" to the level it should be is because we don't want to waste an effort to change the level if it's the right level, somebody tell me if it's faster just to call the function, that's an easy fix if so I didn't bother worrying too much about it; either way, it will 'look' very much the same as far as the organization of the trigger.



What I had said before I edited the post to avoid double posting:
Before I get into that, instead of checking every .5 seconds, you could use the 'real value event' and make his % health the real value. I'll circle back to that near the end.

Instead of checking the percent for if its under 75%, 50%, 25%
and checking the ability level:

IF hp% > 10%
THEN:
set Rage = ( (5 - ConvertRealToInteger( HP% ) / 25 ) + ( 5 x ( AbilityLevel - 1 ) ) )
ELSE:
IF hp% <= 10% then
set Rage = 5 + ( 5 x ( AbilityLevel - 1 )



The Real event will require that you set a variable to the Boss's health % and update that variable whenever the Boss's health % changes.

Then make your events:
when Real (Your Boss Health %) becomes less than 75%, 50%, 25%, 10% ( Four events ).



That may be a lot to take in, but see what you can understand and maybe share what confused you if anything and I can try to explain the difficult parts in detail tonight, can only skim the Hive while on lunch at work for now...

PS: I'm not sure but I think this would go in the 'triggers and scripts' section.

EDIT: had some flawed math I fixed
 
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
*Bump

Bumping to notify JFAMAP because I posted a suggestion and have now posted a full solution and I am not sure if JFAMAP has seen the solution since edits don't notify people. I'm hoping this is solved...
 
Level 12
Joined
Jan 10, 2023
Messages
191
Ah thank you so much @Tristronic. I will try this after i solve my vital issues with my map.

It is functionally identical so your equation, so I'll attach the map here and you can just copy and paste it. The only thing you will have to change is the ability "Rage Of Strength", unless its ability id happens to be 'A000'. You may have to do the same with "Blizzard", I just used the vanilla Archmage's ability.

EDIT:

I made some updates for the sake of making it Copy & Paste friendly so there is no trouble switching to this system:
Making it import-easy added a few items, but also made it more adaptable.

This is what you will see that is new:
    • Set by the Trigger: StrengthRunMagnitude
    • Set by the Trigger: StrengthRunBonus
    • Set by clicking on the Variable: StrengthRunAbility
You will have to manually set StrengthRunAbility by clicking on the variable and then setting the default value to your Ability.
Since I don't know the Ability ID of your ability, this was the easiest way to make it fool-proof.

Setting the Ability Variable is going to look like this:
Set Ability Variable Default.jpg



I also added instructions for Copying and Pasting the from the demo map I made:
Intructions.jpg



Here's the trigger for anyone interested/ for the sake of having it seen for any potential discussion.

  • Strength Run
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RageofStrengthCasterGroup and do (Actions)
        • Loop - Actions
          • -------- About Variable: StrengthRunMagnitude --------
          • -------- This takes "Blizzard" out of the equation. Just set it here inside the Unit Group Loop to whatever ability/ other fact you want. --------
          • -------- We are subtracting One because math. --------
          • -------- You can leave it there if you want, but just think of Magnitude as "Bonus Magnitude" if you want to keep it simple. --------
          • Set VariableSet StrengthRunMagnitude = ((Level of Blizzard for (Picked unit)) - 1)
          • -------- About Variable: StrengthRunBonus --------
          • -------- In our case, this gives us a number that starts at 1 and increase by 1 for every 25% health below the maximum the (picked unit). --------
          • Set VariableSet StrengthRunBonus = (4 - ((Integer((Percentage life of (Picked unit)))) / 25))
          • -------- These next two will make sure our function never goes out of range, if we didn't do this, we would get have a bug when units are at full health. --------
          • If (StrengthRunMagnitude Less than 0) then do (Set VariableSet StrengthRunMagnitude = 0) else do (Do nothing)
          • If (StrengthRunBonus Less than 1) then do (Set VariableSet StrengthRunBonus = 1) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to 10.00
            • Then - Actions
              • -------- This was the 'unique' part of your function, when they are under 10% health they get a little extra bonus --------
              • -------- instead of having to lose a full 25% to get stronger, since then they would be dead. Not a bad idea! --------
              • Set VariableSet StrengthRunBonus = (StrengthRunBonus + 1)
            • Else - Actions
          • -------- The easiest way I can put it is like this: StregthRunMagnitude is counting by Fives and StrengthRunBonus counts by ones. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of StrengthRunAbility for (Picked unit)) Not equal to ((5 x StrengthRunMagnitude) + StrengthRunBonus)
            • Then - Actions
              • Unit - Set level of StrengthRunAbility for (Picked unit) to ((5 x StrengthRunMagnitude) + StrengthRunBonus)
            • Else - Actions
      • -------- --------
      • -------- ----------------------------------------------------------------------------------- Final Comments: ----------------------------------------------------------------------------------- --------
      • -------- --------
      • -------- The easiest way I can put it is like this: StregthRunMagnitude is counting by Fives and StrengthRunBonus counts by ones. --------
      • -------- --------
      • -------- I also have some recommendations: --------
      • -------- I used "Skip Remaining Actions" so that they don't interfere, if you decide not to, just delete everything below this line. --------
      • -------- --------
      • Skip remaining actions
      • -------- --------
      • -------- If you decide not to take my recommendation, just delete everything above this line. --------
      • -------- --------
      • Unit Group - Pick every unit in RageofStrengthCasterGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet StrengthRunMagnitude = (4 - ((Integer((Percentage life of (Picked unit)))) / 25))
          • Set VariableSet StrengthRunBonus = (Level of Blizzard for (Picked unit))
          • If (StrengthRunMagnitude Less than 0) then do (Set VariableSet StrengthRunMagnitude = 0) else do (Do nothing)
          • If (StrengthRunBonus Less than 1) then do (Set VariableSet StrengthRunBonus = 1) else do (Do nothing)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Less than or equal to 10.00
            • Then - Actions
              • -------- This was the 'unique' part of your function, when they are under 10% health they get a little extra bonus --------
              • -------- instead of having to lose a full 25% to get stronger, since then they would be dead. Not a bad idea! --------
              • Set VariableSet StrengthRunMagnitude = StrengthRunMagnitude
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of StrengthRunAbility for (Picked unit)) Not equal to ((5 x StrengthRunMagnitude) + StrengthRunBonus)
            • Then - Actions
              • Unit - Set level of StrengthRunAbility for (Picked unit) to ((5 x StrengthRunMagnitude) + StrengthRunBonus)
            • Else - Actions
      • -------- --------
      • -------- Here's an explanation on why I would recommend this, but it may not apply. It might be worth taking the time to read, I'm going to make it a simple as possible --------
      • -------- With your system, which I copied, a Unit with Blizzard Level 1 and less than 10% Health is weaker than a Full Health Unit with Blizzard Level 2. --------
      • -------- This might be what you want, but there is another potential problem if this is what you want: --------
      • -------- Without making some change, Units with Blizzard Level 4 get less of a bonus from having Low Health than Units with Blizzard Level 1. --------
      • -------- --------
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
      • -------- --------
      • -------- The details are a bit math-heavy so I'm going to just put it into percentages. --------
      • -------- --------
      • -------- When health is above 75% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 16 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 75% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 8.5 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 50% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 6 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 25% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4.75 times the Rage Level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 10% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4 times the Rage Level that a Unit with Blizzard Level 1 has. --------
      • -------- --------
      • -------- A Unit with Blizzard Level 4 will get a 6.25% bonus each time its health goes down a notch if Rage Of Strength scales evenly. --------
      • -------- That Unit will have a maximum bonus of 31.25%. when its health is below 10%. --------
      • -------- This will still be much higher than a Unit with Blizzard Level 1, but it won't seem like the Blizzard Level 4 Unit became much stronger than it already was. --------
      • -------- --------
      • -------- A Unit with Blizzard Level 1 will get a 100% bonus each time its health goes down a notch if Rage Of Strength scales evenly. --------
      • -------- That Unit will have a maximum bonus of 400%. when its health is below 10%. --------
      • -------- This will still be much lower than a Unit with Blizzard Level 4, but it will seem like the Blizzard Level 1 Unit became WAY stronger compared to A Blizzard Level 4 Unit. --------
      • -------- --------
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
      • -------- --------
      • -------- If you made the changes I recommended it will look like this: --------
      • -------- --------
      • -------- When health is above 75% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 75% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4.5 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 50% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4.66 times the Rage level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 25% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4.75 times the Rage Level that a Unit with Blizzard Level 1 has. --------
      • -------- When health is below 10% for both: --------
      • -------- A Unit with Blizzard Level 4 will have 4 times the Rage Level that a Unit with Blizzard Level 1 has. --------
      • -------- --------
      • -------- A Unit with Blizzard Level 4 will get a 125% bonus each time its health goes down a notch if Rage Of Strength scales evenly. --------
      • -------- That Unit will have a maximum bonus of 500%. when its health is below 10%. --------
      • -------- This will still be much higher than a Unit with Blizzard Level 1, but now you'll notice when a big guys gets mad because the scale is more ideal. --------
      • -------- --------
      • -------- A Unit with Blizzard Level 1 will get a 100% bonus each time its health goes down a notch if Rage Of Strength scales evenly. --------
      • -------- That Unit will have a maximum bonus of 400%. when its health is below 10%. --------
      • -------- This will still be much lower than a Unit with Blizzard Level 4, but it will seem like the Blizzard Level 1 Unit was boosted similarly to a Unit with Blizzard Level 4 ( pound-for-pound that is ) --------
      • -------- --------
 

Attachments

  • StrengthRunDemo.w3m
    18.6 KB · Views: 1
Status
Not open for further replies.
Top