Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

How to do Arithmetic operators

Discussion in 'World Editor Help Zone' started by Freaky Little Goblin, Dec 15, 2016.

  1. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    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
     
  2. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    Action Type: General: Set Variable
    You'll have something like
    Set Variable = Value

    Then upon clicking Value, select Arithmetic.
     
  3. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    Thanks! I will come back here if it didn't work.
     
  4. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    Wait, I can't click on Value tho, am I doing something wrong?
     
  5. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    You have to select the variable that you want to manipulate.
     
  6. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    Could you enlighten me on this subject? The tutorial did not include something like that variable manipulating. Or maybe I didn't see it. Lol anyways pls help me.
     
  7. Flux

    Flux

    Joined:
    Feb 6, 2014
    Messages:
    2,333
    Resources:
    28
    Maps:
    1
    Spells:
    19
    Tutorials:
    2
    JASS:
    6
    Resources:
    28
    So what are trying to achieve with your equation? Do you want to deal damage based on stat?
     
  8. Marcos_M

    Marcos_M

    Joined:
    Jan 23, 2011
    Messages:
    349
    Resources:
    0
    Resources:
    0
    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: Dec 16, 2016
  9. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    8,201
    Resources:
    31
    Packs:
    1
    Maps:
    9
    Spells:
    18
    Tutorials:
    3
    Resources:
    31
    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.
     
  10. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    On the ability's level, like at level one it should deal 150, and then when lvl 2 hits it deals 250. Or something like that.
     
  11. Athur12A2

    Athur12A2

    Joined:
    Sep 16, 2016
    Messages:
    269
    Resources:
    6
    Models:
    6
    Resources:
    6
    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) ]
     
  12. Radicool

    Radicool

    Joined:
    Mar 27, 2011
    Messages:
    1,148
    Resources:
    4
    Maps:
    4
    Resources:
    4
    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.
     
  13. 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: Dec 18, 2016
  14. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    Thanks a lot mate!
     
  15. Freaky Little Goblin

    Freaky Little Goblin

    Joined:
    Dec 15, 2016
    Messages:
    21
    Resources:
    0
    Resources:
    0
    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.
     
  16. 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)
     
  17. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    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.