How can i calculate this?

Level 18
Joined
Jun 2, 2009
Messages
1,226
I want to increase value of Integer A from 40 to 48. In other words, i want to increase it by 20%
But i have another Integer will make this calculation.
If the Integer B 0, it i will do nothing.
But if the Integer B is 100, it must increase Integer A by 20%
And of course this percentage increasing from 0 to 20 with the Integer B

This is math question i know and i am very bad at it.

  • Set TempRealMax = 24.00
  • Set TempInt = (Random integer number between (Integer(TempRealMin)) and (Integer(TempRealMax)))
  • Set DamageEventAmount = (DamageEventAmount + (Real(TempInt)))
  • /// I am adding Strength bonus in here
  • Set DamageEventAmount = (DamageEventAmount + ((Real((Strength of DamageEventSource (Include bonuses)))) x 0.10))
  • /// Now i have to add anatomy bonus
  • Set Help_Anatomy = ((Real(xSkill_Anatomy[(Player number of (Owner of DamageEventSource))])) x 0.20)
  • Set DamageEventAmount = (DamageEventAmount + Help_Anatomy)
  • Set DamageEventAmount = (DamageEventAmount + (Help_Anatomy x 0.20))
This is incorrect i know. I am experimenting on this and still i couldn't found any way to do that.

This is what exactly i want
If the damage it 36, it increases by 20% (43.4) because anatomy skill have an ability to increase damage as percent by 0-20 (anatomy skill min: 0 max: 100 and damage increases as the skill increases)
I need a template like this because in my map i will make many calculations like this.
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,090
What's the role of the Random Integer here?

The formula you are seeking for is essentially DamageAmount*(1 + 0.20*AnatomySkill), where in AnatomySkill gets values between 0 and 100.
So, in essence this is the line in the triggers:
  • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) + (1.00 x (0.20 x AnatomySkill)))
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
As far as I understand you want to do this:
  • -------- 10% of Strength bonus: --------
  • Set DamageEventAmount = (DamageEventAmount + ((Real((Strength of DamageEventSource (Include bonuses)))) x 0.10))
  • -------- 0% to 100% of Anatomy bonus: --------
  • Set TempIntMin = 0
  • Set TempIntMax = (20 x (Level of Anatomy for DamageEventSource))
  • Set TempInt = (Random integer number between TempIntMin and TempIntMax)
  • Set TempReal = ((Real(TempInt) / 100.00))
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + TempReal))
I've setup the bonus damage per level like this:
Level 1 = 0 -> 20% damage
Level 2 = 0 -> 40% damage
Level 3 = 0 -> 60% damage
Level 4 = 0 -> 80% damage
Level 5 = 0 -> 100% damage

Set TempIntMax to be whatever the maximum value is for the current level. If the ability isn't leveled then TempReal will be set to 0.00 and won't do anything.

But it's better to add an If Then Else that simply avoids the whole Anatomy calculation if it isn't leveled.
  • -------- 10% of Strength bonus: --------
  • Set DamageEventAmount = (DamageEventAmount + ((Real((Strength of DamageEventSource (Include bonuses)))) x 0.10))
  • -------- 0% to 100% of Anatomy bonus: --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Level of Anatomy for DamageEventSource) Greater than 0
    • Then - Actions
      • Set TempIntMin = 0
      • Set TempIntMax = (20 x (Level of Anatomy for DamageEventSource))
      • Set TempInt = (Random integer number between TempIntMin and TempIntMax)
      • Set TempReal = ((Real(TempInt) / 100.00))
      • Set DamageEventAmount = (DamageEventAmount x (1.00 + TempReal))
    • Else - Actions
So if it rolls a 10 for example then we convert that to a Real:
10 is converted to 10.00.
Then we divide that Real by 100.00 to get the proper amount to add later:
10.00 / 100.00 = 0.10.
Then in our damage calculation we add our Real to 1.00 so that our damage is always multiplied by at least 1.00:
(1.00 + 0.10) = 1.10
Lastly, we multiply the damage by this amount:
Damage * 1.10 = 10% more damage
Hopefully that makes sense. This allows a roll of 0 to add 0% damage and not mess things up -> Damage * (1.00 + 0.00)
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
You can completely ignore TempRealMin and TempRealMax. It is for calculating minimum and maximum damage for weapons.
I will check this and try when i return home.

I'm using those variables to do this:
anatomy skill have an ability to increase damage as percent by 0-20 (anatomy skill min: 0 max: 100 and damage increases as the skill increases)
TempRealMin = anatomy skill min: 0
TempRealMax = anatomy skill max: 100

I made TempRealMax depend on the level of the ability.
 
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,226
I have read and again totally confused. Still my brain can handle math. Can we fix on my trigger instead of these ones? Doing something without understanding will lead many issues. I don't understand many parts of these.

If you remember, i was this guy.
Being stupid person wasn't my choice. I am not telling this because of running away from argument. It is a fact. I am stupid person. Learning something new is difficult for me. And this trigger is far beyond my skills. I don't understand many parts of this trigger.
For example why my 35 damage increases to 55 with this trigger. It looks like it increases 20 instead of 20%
I want to increase 35 damage by 20% (35 > 42)

  • Set DamageEventAmount = (DamageEventAmount + (1.00 x (0.20 x Help_Anatomy)))


This is what i want if the player have 100 Anatomy but of course it changes between 1.00 to 1.20 (0-100 anatomy)
  • Set DamageEventAmount = (DamageEventAmount x 1.20)
I have a serious problems with math and it is a miracle to creating these systems all by myself with this math skills...

By the way i was trying to make it increase for every points it is possible.
Difference between 0 and 19 anatomy should makes sense. Hero with 81 and 97 anatomy should not the same.
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
I want to increase 35 damage by 20% (35 > 42)
  • Set DamageEventAmount = (DamageEventAmount + (1.00 x (0.20 x Help_Anatomy)))
I thought you wanted a random number based on the ability level. I understand now that you want 1% damage per level of Anatomy.

In the future just explain it to us like an ability tooltip:
Level 1 = 1% more damage
Level 2 = 2% more damage
Level 3 = 3% more damage

Anyway it's really simple:
  • Set Help_Anatomy = (Level of Anatomy for DamageEventSource)
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + (0.01 x Help_Anatomy)))
You multiply the damage dealt by 1.00 + 0.01 per ability level

So if the ability is level 50 then you'd do: Damage x (1.00 + 0.50)

In other words: Damage x 1.50
 
Last edited:

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,090
For example why my 35 damage increases to 55 with this trigger. It looks like it increases 20 instead of 20%
I want to increase 35 damage by 20% (35 > 42)
You're getting the wrong value because your formula is wrong.
  • Set DamageEventAmount = (DamageEventAmount + (1.00 x (0.20 x Help_Anatomy)))
While the correct formula would be:
  • Set DamageEventAmount = (DamageEventAmount * (1.00 + (0.002 x Help_Anatomy)))
My apologies, I miswrote the formula before.

So the trigger you really want is:
  • Example Trigger:
    • Events
      • Unit - A unit Takes damage (not sure when you want this effect to take place)
    • Conditions
    • Actions
      • Set VariableSet Integer_AnatomySkill = (Current research level of Anatomy Skill for (Owner of (Damage source)))
      • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) x (1.00 + (0.002 x (Real(Integer_AnatomySkill)))))
Note that I assumed you're using research to change the Anatomy Skill, but if it's an ability, then you'd check for the ability level of the unit instead, the logic itself would not change.

This trigger will increase the damage on the events by 0.2% per anatomy skill level, meaning that max skill level it will increase the damage by 20%.
 
Level 18
Joined
Jun 2, 2009
Messages
1,226
By the way Help_Anatomy is Real
xSkill_Anatomy is Integer
Ther are no abilities in this scenario.

Now i changed it just like this but my 35 damage increasing to 70

  • Set Help_Anatomy = (Real(xSkill_Anatomy[(Player number of (Owner of DamageEventSource))]))
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + (0.01 x Help_Anatomy)))
By the way i will make it add +20% bonus instead of +50% @Uncle but before i do that, i am trying to understand.
Now i want to make 35 to 42 (20% increment) but it increases to 70.

@Remixer we posted same time, now i am reading your post and i will make changes.

@Remixer Now it deals 0 damage and 700 damage with 100 anatomy.

  • Set Help_Anatomy = (Real(xSkill_Anatomy[(Player number of (Owner of DamageEventSource))]))
  • Set DamageEventAmount = (DamageEventAmount x (1.00 x (0.20 x Help_Anatomy)))
There are no abilities by the way. All of them integers and reals.
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
Just look at this line here:
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + (0.01 x Help_Anatomy)))
It's increasing the damage by 1% x Help_Anatomy.

Whatever you set 0.01 to will be how much bonus damage you get. 0.01 is the same as 1%.

Want 20% damage?
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + (0.20 x Help_Anatomy)))
Want 100% damage?
  • Set DamageEventAmount = (DamageEventAmount x (1.00 + (1.00 x Help_Anatomy)))
Simple enough.
 

Remixer

Map Reviewer
Level 33
Joined
Feb 19, 2011
Messages
2,090
@Remixer Now it deals 0 damage and 700 damage with 100 anatomy.

  • set.gif
    Set Help_Anatomy = (Real(xSkill_Anatomy[(Player number of (Owner of DamageEventSource))]))
  • set.gif
    Set DamageEventAmount = (DamageEventAmount x (1.00 x (0.20 x Help_Anatomy)))
There are no abilities by the way. All of them integers and reals.
That's because you have a multiplication symbol instead of a plus symbol between the 1.00 and (0.20 * Anatomy).

Edit: It actually seems GUI won't let you define reals below 0.01, it will turn them into 0.00 automatically, so you will probably have to make it two steps:
  • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) x (1.00 + (0.02 x (0.10 x (Real(Integer_AnatomySkill))))))
 
Level 18
Joined
Jun 2, 2009
Messages
1,226
@Uncle and @Remixer Everything is messed now because i am trying two of your solutions and during the post there are 2 new posts arrived. Let me show you the current situation and entire trigger with explanations. I think it would be better for us.

You can totally ignore TempRealMin, TempRealMax, TempInt in here.
Can we forget everything and proceed from here?
Currently it increases damage from 36 to 56. Please continue from here. I am already confused a lot and both of you already understand i am imbecil about math.
 

Attachments

  • aa.png
    aa.png
    50.6 KB · Views: 6

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
Sorry, I think I finally fully understand you... Here's all you need to do.
  • Set Help_Anatomy = (Real(xSkill_Anatomy[(Player number of (Owner of DamageEventSource))]))
  • Set Bonus_Damage = (Help_Anatomy x 0.01)
  • Set Bonus_Damage = (Bonus_Damage x 0.20)
  • Set Bonus_Damage = (Bonus_Damage + 1.00)
  • Set DamageEventAmount = (DamageEventAmount x Bonus_Damage)
Or try Remixer's solution.

You're now getting 0.20% bonus damage per 1 Help_Anatomy.

10 Help_Anatomy = 2% more damage.
100 Help_Anatomy = 20% more damage.
 
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,226
Thank you dear @Remixer and @Uncle now my 35 damage increases to 42. Here is another quick question.
My skills increases like this 0.8, 0.9, 1.0, 1.1 etc. Not like 1, 2, 3 etc etc. Is that causes any problem?
Yes values are correct now but i wanted to ask it.

I was already did something like this about that (my friend helped me about that of course)

  • Teach Healing Done
    • Events
      • Unit - A unit Pawns an item (to shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Gold
      • (Charges remaining in (Sold Item)) Equal to TempTeachGold[(Player number of (Owner of Hero[(Player number of (Owner of (Selling unit)))]))]
    • Actions
      • Set TempTeachGold[(Player number of (Triggering player))] = ((TempTeachGold[2] / 1) + 0)
      • Set xSkill_Healing[(Player number of (Owner of (Selling unit)))] = (xSkill_Healing[(Player number of (Owner of (Selling unit)))] + TempTeachGold[(Player number of (Owner of (Selling unit)))])
      • Set Virgul_Oncesi = (String((xSkill_Healing[(Player number of (Owner of (Selling unit)))] / 10)))
      • Set Virgul_Sonrasi = (String((xSkill_Healing[(Player number of (Owner of (Selling unit)))] mod 10)))
      • Game - Display to (Player group((Triggering player))) for 1.00 seconds the text: (Your skill Healing increased to + ((|cffffa500 + Virgul_Oncesi) + (. + (Virgul_Sonrasi + |r))))
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,626
My skills increases like this 0.8, 0.9, 1.0, 1.1 etc. Not like 1, 2, 3 etc etc. Is that causes any problem?
Basing this on my solution it'll work fine for any number. You can use a calculator and go through the calculations yourself:
1708279901069.png

Help_Anatomy = 0.8
Help_Anatomy x 0.01 = 0.008
0.008 x 0.2 = 0.0016
1.00 + 0.0016 = 1.0016

So with 0.8 Help_Anatomy your Damage is multiplied by 1.0016. That's not a lot of bonus damage at first but Help_Anatomy goes up to 100 so it'll get better later on - assuming this is how you want it to work.


I was already did something like this about that (my friend helped me about that of course)
That Teach Healing Done trigger looks a bit weird to me.

This Action seems wrong:
  • Set TempTeachGold[(Player number of (Triggering player))] = ((TempTeachGold[2] / 1) + 0)
If their Player Number is 2 (Player 2) then you're setting TempTeachGold[2] = TempTeachGold[2].

Maybe Player 2 can't sell the item? I don't know the specifics of your map but it looks wrong.

Also, you're dividing the gold by 1 and adding 0 to it. That literally does nothing.

100 gold / 1 = 100 gold
100 gold + 0 = 100 gold

You aren't changing the number.

Also, your Condition looks overcomplicated:
  • (Charges remaining in (Sold Item)) Equal to TempTeachGold[(Player number of (Owner of Hero[(Player number of (Owner of (Selling unit)))]))]
The Selling unit IS the player's Hero, and if it isn't, it's at least the same Owner. So you can just do this:
  • (Charges remaining in (Sold Item)) Equal to TempTeachGold[(Player number of (Owner of (Selling unit))]
 

Attachments

  • 1708278483427.png
    1708278483427.png
    19.7 KB · Views: 8
Last edited:
Top