• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Mathematics logic

Status
Not open for further replies.
SOLVED

Edit: The problem was indeed with absolute values. Even changing the y part of the "is x equal to y" there was still an "is x absolute" function in the trigger. I didn't even think of that.
Thank you all for your help.

  • Deal Damage
    • Events
    • Local Variables
    • Conditions
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • Or
            • Conditions
              • (Abs(Enemy Shields)) < 0
              • (Abs(Enemy Shields)) == 0
        • Then
          • Variable - Modify Enemy Hull: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Abs(Enemy Shields)) > 0
        • Then
          • Variable - Modify Enemy Shields: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
  • Deal Damage
    • Events
    • Local Variables
    • Conditions
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • Or
            • Conditions
              • Enemy Shields < 0
              • Enemy Shields == 0
        • Then
          • Variable - Modify Enemy Hull: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • Enemy Shields > 0
        • Then
          • Variable - Modify Enemy Shields: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
  • [/hidden]
This is with the sc2 editor, however both the wc3 and sc2 editor do mathematical calculations in the same fashion, so I assume its a wc3 editor problem as well.

Essentially it's registering negative integer variables as positive. Any help would be VERY appreciated.

http://www.hiveworkshop.com/forums/...ard-real-identifying-negative-numbers-227129/
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
Thread should be renamed to "Are You For Real ?"

I mean, like WaterKnight said in his comment on that thread, you used Abs function on the value, which will return any value to positive (well, that's because WHAT ABSOLUTE DOES !)

Abs(-1) = 1
Abs(0) = 0
Abs(1) = 1

You see ?
It always returns value as positive (where 0 is ambiguous - negligible).

If you want to detect whether this is true or not, try this trigger;
  • Actions
    • Set i = -1
    • Set i = (Abs(i))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i Less than 0
      • Then - Actions
        • Game - Display to (All players) the text: NEGATIVE
      • Else - Actions
        • Game - Display to (All players) the text: POSITIVE
Message will always show POSITIVE.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
To continue: if you want to see if the value is negative or positive, you should use "Sign", which gets either +1, or -1 (0 is positive according to this).
Or just use "Integer > 0" ("Sign" is actually used to get -1 or +1 into the equations, not for checking if something is negative/positive).

And if you're having problems with The "Abs"-function, visit Wolfram (it has some nice graphs on how the function behaves).
From those graphs, you can see that Abs(integer) is always positive (but this is just repeating what has already been said by WaterKnight, the Doctor and Defskull).
 
Last edited:
I was going to get irritated with all these posts pointing out the obvious but then I realized I didnt post a trigger I'd already tried... lol...

  • Deal Damage
    • Events
    • Local Variables
    • Conditions
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • Or
            • Conditions
              • (Abs(Enemy Shields)) < 0
              • (Abs(Enemy Shields)) == 0
        • Then
          • Variable - Modify Enemy Hull: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Abs(Enemy Shields)) > 0
        • Then
          • Variable - Modify Enemy Shields: - Player Weapon Effective Damage
          • Variable - Set Player Current Weapon Effective Cooldown = (Abs(Player Current Weapon Cooldown))
        • Else
so no.. having absolute is not the issue.. the above trigger does not work either..
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I'm just going to quote a part of your trigger, if that's okay.
  • Or - Conditions
    • (Abs(Enemy Shields)) < 0
    • (Abs(Enemy Shields)) == 0
That's the new trigger you showed us.
Can you see the part where it says "(Abs(Enemy Shields))"?
That should just be "Enemy Shields". The "Abs" in front of it means absolute value.

So yeah, that new trigger also uses absolute values.

Here's a question for you though: why do you post questions about the SC2 editor here?
This here is part of the Warcraft III Modding sub-forum.
Starcraft II has its own Help Zone.

Anyway, I think I found the problem. This is a short image-guide.
What you probably do is tihs:
attachment.php

And it's incorrect!
If "Enemy Shields" is a variable, then you should go to the variables-tab
attachment.php

If "Enemy Shields" means you get the shields of some unit, then you should still be in the "Functions"-tab, but then the "Unit"-category.
attachment.php


(It works the same way with Integers).
So don't use "Math -> Absolute value (integer/real)" unless you actually need it.
 

Attachments

  • Absolute1.jpg
    Absolute1.jpg
    38 KB · Views: 197
  • Absolute2.jpg
    Absolute2.jpg
    25.5 KB · Views: 182
  • Absolute3.jpg
    Absolute3.jpg
    41 KB · Views: 188
Hmm. My new trigger (at least on my screen) doesnt have absolute values. I changed it to variable checks.

But thank you for the elongated post! I appreciate your help.
Also I posted in the wc3 modding forum cause yes it is a starcraft issue but I assumed it was a break in mathematics logic which the wc3 editor also uses.

The wc3 editor help zone is much more populated =]
 

Attachments

  • edit.png
    edit.png
    63.1 KB · Views: 102
Level 28
Joined
Jan 26, 2007
Messages
4,789
Oh, you edited the first post. I thought you were just talking about the new trigger in your previous post (second to last one).

So it wasn't a math problem: the math works just fine :).
Also, instead of "Shields == 0" OR "Shields < 0", you can do "Shields <= 0" (this saves some lines).

Well, it seems like you solved it anyway :p.
 
Status
Not open for further replies.
Top