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

How to do Arithmetic operators

Status
Not open for further replies.
Level 2
Joined
Dec 15, 2016
Messages
21
I saw a tutorial on trigger-enchancing spells and read through it till the end, what I cant understand is how he inputted some values, like equations(3*(600-100)) or something like that. If anyone can shed some light id be really thankful
 
Level 7
Joined
Jan 23, 2011
Messages
350
The function arithmetic can be used whenever you're going to set a value to an integer or a real (When you're about to deal damage, for example)

Create a new trigger, then click "Add Action" and then use an action, like "Unit - Unit damage target"(or something like that)
You will see a number(500.00 i think), that's a real. Click on it to modify it, in the Function list, look for Arithmetic, then you can use your basic operations
 
Last edited:
You need a real/integer (depending on the case ; damage is real) variable first.

Then, choose the Set Variable trigger.
Then, on the variable, select it and select the real variable you have created.
Then, on the value, select it and select arithmetic (or just press A) and there you can do your calculation.
 
Level 10
Joined
Sep 16, 2016
Messages
269
You shoud create a variable type real (ie TempReal) to do the damage. Then use action "Set Variable" for it: Choose Arithmetic. Sadly you can only work with 2 numbers at one time, like a + b; but you can replace a and b with another Arithmetic and expand the formula. Damage is calculated by real numbers, while level of ability is integer, you need the "Conversion" option to change it
  • Set TempReal = 50.00 + [ 100.00 x Real( Level of (Ability being cast) for TempUnit) ]
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Lol your all confusing him. I see you guys are trying to show good practice, but the OP didn't mention anything about variables. Hes just asking how to perform simple arithmetic. Keep it simple for him. Forget variables for the purpose of this explanation.
 

EdgeOfChaos

E

EdgeOfChaos

Doing arithmetic in GUI is somewhat inconvenient, but not too bad for a simple formula like this. Here's how to do it:

1) In the Action, select Damage Unit
2) Set the unit to damage to "Target unit of ability being cast"
3) Click the damage value to edit it (initially set to 500)
4) Click the drop down window and find "Arithmetic"
5) Now, you get two values: initially set to "1.00 + 1.00"
6) Select the first "1.00" and edit it to your base ability damage (in your case, 50)
7) Select your second "1.00". This will be our ability scaling value.
8) Inside here, click the drop-down menu. Select arithmetic again. It will autofill "1.00 + 1.00" again.
9) Select the first "1.00". Now since we need to use Level of Ability (which is an integer) but this is a real, we need to convert.
10) Find "Conversion - Convert Integer to Real". It will autofill "Point value of Footman". Click this to edit it.
11) Scroll down to "Unit - Level of Ability For Unit". Select the red text that says "Ability" inside this.
12) Find your custom ability and select it.
13) Select OK twice to get back to Arithmetic. Now, the screen should say "Real(Level of ___ For Unit) + 1.00"
14) Select the "+" operator, and change it to "x" inside the drop down box (multiplication)
15) Select the second "1.00". Change this to "100.00", because we want to multiply the level by 100.
16) It should now read: "50.00 + (Real(Level of ___ For Unit) x 100.00)
17) Press OK as many times as needed.

Here's a short video of me doing it. Slightly cut off, but it shows the important parts:

Remember: Order of Operations is IMPORTANT! Parenthesis always go first. 50 + (Real(Level of ___ For Unit) x 100.00) is NOT equal to (50 + Real(Level of ___ For Unit)) * 100
 
Last edited by a moderator:
Level 2
Joined
Dec 15, 2016
Messages
21
Doing arithmetic in GUI is somewhat inconvenient, but not too bad for a simple formula like this. Here's how to do it:

1) In the Action, select Damage Unit
2) Set the unit to damage to "Target unit of ability being cast"
3) Click the damage value to edit it (initially set to 500)
4) Click the drop down window and find "Arithmetic"
5) Now, you get two values: initially set to "1.00 + 1.00"
6) Select the first "1.00" and edit it to your base ability damage (in your case, 50)
7) Select your second "1.00". This will be our ability scaling value.
8) Inside here, click the drop-down menu. Select arithmetic again. It will autofill "1.00 + 1.00" again.
9) Select the first "1.00". Now since we need to use Level of Ability (which is an integer) but this is a real, we need to convert.
10) Find "Conversion - Convert Integer to Real". It will autofill "Point value of Footman". Click this to edit it.
11) Scroll down to "Unit - Level of Ability For Unit". Select the red text that says "Ability" inside this.
12) Find your custom ability and select it.
13) Select OK twice to get back to Arithmetic. Now, the screen should say "Real(Level of ___ For Unit) + 1.00"
14) Select the "+" operator, and change it to "x" inside the drop down box (multiplication)
15) Select the second "1.00". Change this to "100.00", because we want to multiply the level by 100.
16) It should now read: "50.00 + (Real(Level of ___ For Unit) x 100.00)
17) Press OK as many times as needed.

Here's a short video of me doing it. Slightly cut off, but it shows the important parts:

Remember: Order of Operations is IMPORTANT! Parenthesis always go first. 50 + (Real(Level of ___ For Unit) x 100.00) is NOT equal to (50 + Real(Level of ___ For Unit)) * 100

Thanks a lot mate!
 
Level 2
Joined
Dec 15, 2016
Messages
21
Lol your all confusing him. I see you guys are trying to show good practice, but the OP didn't mention anything about variables. Hes just asking how to perform simple arithmetic. Keep it simple for him. Forget variables for the purpose of this explanation.

Well, I am confused about this variable thingy-majhingy. But I know it's that important in making a campaign great. Although I can't quite understand most of what they say. Sorry im such a noob.
 

EdgeOfChaos

E

EdgeOfChaos

Variables are things that can store data for later use.

For example, if you want to both deal damage and then heal the caster by the same amount, you don't want to re-code the same arithmetic operations twice in two different actions. Instead, you can use a real variable (stores a number with a decimal point). You can set this variable to be equal to an expression, and then simply use the variable later on, inside the actions.

There are lots of variable types. The most common are real (number with decimal), integer (number without decimal) string (text), and boolean (holds either true or false)
 
Level 4
Joined
Aug 6, 2014
Messages
87
Do u still need help? PM me I can explain further and may be able to help you a lot faster if we communicate via Skype / Discord / Battle.net.
 
Status
Not open for further replies.
Top