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

[Trigger] A very simple trigger...

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
158
Hello hive members
I have alot of trouble with an annoying easy trigger.
The spell this trigger is based on is Endurance Aura. The spell has 100 levels. It should increase his attack speed by 1% for every 1% health he is missing (yeah, boring work!). But at some point this trigger won't increase the spells level?
  • Rage
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Morogar the Crusher 0052 <gen> is alive) Equal to True
        • Then - Actions
          • Unit - Set level of Rage for Morogar the Crusher 0052 <gen> to ((((Integer((Max life of Morogar the Crusher 0052 <gen>))) - (Integer((Life of Morogar the Crusher 0052 <gen>)))) / (Integer((Max life of Morogar the Crusher 0052 <gen>)))) x 100)
        • Else - Actions
          • Trigger - Turn off (This trigger)
This is an example of the calculation of the trigger:
2000-1500 = 500
500/2000 = 0.25
0.25x100 = 25%.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
The problem is that you can not represent 0.25 as an integer because integers are whole numbers.
You should do the conversion from "real" to "integer" after you have calculated everything.
(Like "Integer ((max life - life)/(max life))" )
(Which can be simplified to "Integer ( 1 - life/(max life))" )

Values like "max life" are of type "real" on default, e.g. they could be 0.001 or 1337.1337
But if you take two integers and divide them like this: 100/1000 the result will be rounded down and be 0.
 
Level 7
Joined
Jul 9, 2012
Messages
158
Hey, thanks for the reply. I have edited my trigger and tried to make it like you said, but I still have issues with it. - It still doesn't work.
  • Rage
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Morogar the Crusher 0052 <gen> is alive) Equal to True
        • Then - Actions
          • Unit - Set level of Rage for Morogar the Crusher 0052 <gen> to (Integer(((((Max life of Morogar the Crusher 0052 <gen>) - (Life of Morogar the Crusher 0052 <gen>)) / (Max life of Morogar the Crusher 0052 <gen>)) x 100.00)))
        • Else - Actions
          • Trigger - Turn off (This trigger)
Please correct me if it's wrong :)
 
Level 6
Joined
May 15, 2009
Messages
191
I have a fairly simple way to do it, but you would have to revert the Attack speed increase. So that level 100 is the lowest value, and level 1 is the highest attack speed value. If you make it like this, you can simply use percentage health of Morogar. Like below:

  • Rage
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Morogar the Crusher 0000 <gen> is alive) Equal to True
        • Then - Actions
          • Unit - Set level of Rage for Morogar the Crusher 0000 <gen> to (Integer((Percentage life of Morogar the Crusher 0000 <gen>)))
          • Game - Display to (All players) the text: (String((Level of Rage for Morogar the Crusher 0000 <gen>)))
        • Else - Actions
 
Status
Not open for further replies.
Top