• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Bugged Maths

Status
Not open for further replies.
Level 4
Joined
Aug 6, 2014
Messages
87
I've got a problem with an income trigger, it should work like this: Lumber Mill created > add +1 to interger variable, every X sec give added X to player X.

The creation/build works fine, but the remove when a unit of type Lumber Mill dies seems to be bugged.
The problem with the decrease now is.. Everytime I build 5x a lumber mill I get +5 income, 5 get destroyed but I get -6 income... repeats everytime 5 lumber mills are being destroyed.

  • wood increase
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Lumber Mill
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Constructed structure)))] = (income_wood[(Player number of (Owner of (Constructed structure)))] + 1)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Lumber Mill v2
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Constructed structure)))] = (income_wood[(Player number of (Owner of (Constructed structure)))] + 5)
        • Else - Actions
          • Do nothing
Bugged function:
  • wood decrease
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • income_wood[(Player number of (Owner of (Dying unit)))] Greater than 0
          • (Unit-type of (Dying unit)) Equal to Lumber Mill
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Dying unit)))] = (income_wood[(Player number of (Owner of (Dying unit)))] - 1)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • income_wood[(Player number of (Owner of (Dying unit)))] Greater than 0
          • (Unit-type of (Dying unit)) Equal to Lumber Mill
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Dying unit)))] = (income_wood[(Player number of (Owner of (Dying unit)))] - 5)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • income_wood[(Player number of (Owner of (Dying unit)))] Less than 0
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Dying unit)))] = 0
      • Else - Actions
 
Level 8
Joined
Jan 28, 2016
Messages
486
You're checking the same unit-type in the second If-Then-Else statement of your Wood Decrease trigger; it should be Lumber Mill v2 instead. You can also remove all the DoNothing actions, they're worse than just leaving the Else sections blank.
 
Level 4
Joined
Aug 6, 2014
Messages
87
I know that it isn't the issue because I've added that function like 2mins before I posted. It has bugged before already
 
Level 8
Joined
Jan 28, 2016
Messages
486
Alright. Well there doesn't seem to be anything else in these triggers that would cause the problem you described.

What happens to your income when they each get destroyed? Do you still lose 1 income per mill as expected? What happens when you have any other number of mills or does this only happen when you have five destroyed?
 
Level 4
Joined
Aug 6, 2014
Messages
87
I don't know how, but it seems like it's fixed now, I had the same problem on another map..

Works perfect now, 1 mill created = +1, 1 mill destroyed = -1
 
Level 4
Joined
Aug 6, 2014
Messages
87
Tbh it does, I figured that out later yesterday.

I've been building 5 lumbermills, 2 were finished, 3 canceled and after that I got 0 lumber per sec, which should be 2 at least.

  • wood increase
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Lumber Mill
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Constructed structure)))] = (income_wood[(Player number of (Owner of (Constructed structure)))] + 2)
        • Else - Actions
          • Do nothing
  • wood decrease
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • income_wood[(Player number of (Owner of (Dying unit)))] Greater than 0
          • (Unit-type of (Dying unit)) Equal to Lumber Mill
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Dying unit)))] = (income_wood[(Player number of (Owner of (Dying unit)))] - 2)
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • income_wood[(Player number of (Owner of (Dying unit)))] Greater than 0
          • (Unit-type of (Dying unit)) Equal to Lumber Mill v2
        • Then - Actions
          • Set income_wood[(Player number of (Owner of (Dying unit)))] = (income_wood[(Player number of (Owner of (Dying unit)))] - 8)
        • Else - Actions
          • Do nothing
 
Last edited:
Level 4
Joined
Aug 6, 2014
Messages
87
And how do I do that ? I know how to make a boolean variable but Idk how to attach the variable to an unit.
 
Level 4
Joined
Aug 6, 2014
Messages
87
Hmm I thought of doing the same, but not as good as the indexer from the dude ^^.
Smth like an integer variable which adds +1 each time a unit gets created and then set the value of the variable to last created unit.

Well thank you ^^
 
Level 4
Joined
Aug 6, 2014
Messages
87
ive tried that before already and it didnt end up good, Ill keep it like it is now, seems to work like that. Thank you anyways
 
Status
Not open for further replies.
Top