• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to 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
 
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.
 
I know that it isn't the issue because I've added that function like 2mins before I posted. It has bugged before already
 
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?
 
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
 
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:
And how do I do that ? I know how to make a boolean variable but Idk how to attach the variable to an unit.
 
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 ^^
 
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.
Back
Top