Integer and Multiple Condition Issue

Rassyu

New Member
Reaction score
0
First of all, Hello.
I'm trying to create sort of a "requirement" system on my map, which implies using some integer to make it work, when the condition only includes one Integer Variable everything works fine, but when I tried to put 2 diferent conditions including integers on them it just won't work.

Here is the code:

Trigger:
  • Comprar Item 2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Item Troll
          • PuntosArania Less than or equal to 14
          • PuntosTroll Less than or equal to 9
        • Then - Actions
          • Item - Remove (Item being manipulated)
          • Unit - Order (Hero manipulating item) to Stop
          • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: No tienes suficient...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PuntosArania Greater than or equal to 15
              • PuntosTroll Greater than or equal to 10
              • (Item-type of (Item being manipulated)) Equal to Item Troll
            • Then - Actions
              • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: (Has adquirido: + (Name of (Item being manipulated)))
              • Set PuntosArania = (PuntosArania - 15)
              • Set PuntosTroll = (PuntosTroll - 10)
            • Else - Actions


Now, in the other one (the one of only 1 integer as condition) everything works fine, but here there is an issue, when I get at least ONE of the conditions (either getting 10 PuntosTroll or 15 PuntosArania) it gives the item to the hero, and it doesn't display ANY message to the players and also it doesn't subtracts the points of any of both integers, it's like it needed only one of the conditions, and it overrides the rest of the trigger.

The only way that this trigger works it's when you have the adecuate amount of points (15 and 10), and it displays the message, makes the subtraction of the integer and that.

Now the question is, why it displays "If all conditions are true" if it activates when only one of them is actually reached, and also, how can I make this trigger work?

Thanks in advance.

PS: just to clarify
PuntosArania and PuntosTroll are integers variables, you need to kill certains creeps to raise their values.
 

Infy

New Member
Reaction score
0
For starters, move the item-type condition up into the conditions tab just to clean it up a bit.

Secondly, in the first If condition block, make a new condition called And multiple conditions, then drag the 2 Puntos variables into that "And" block.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
For starters, move the item-type condition up into the conditions tab just to clean it up a bit.

Secondly, in the first If condition block, make a new condition called And multiple conditions, then drag the 2 Puntos variables into that "And" block.
you dont have to use a "and" block if you dont use a "or" block. the "and" is always used by default.

the trigger should work.
 

Rassyu

New Member
Reaction score
0
you dont have to use a "and" block if you dont use a "or" block. the "and" is always used by default.

the trigger should work.

Yeah that's what I thought in the first place, putting an "And (if conditions are true)" in "If (All conditions true)" didn't make much sense, I tried it either way, and it didn't work.

So far I've been trying everything, moving the Item-Type to the condition tab, making 2 different triggers, making 4 triggers (one for each point and each situation), using the "And (Multiple conditions) in like, everywhere... but nothing... It still only needs ONE of the conditions to give me the item and override the rest of the trigger (the game message and the point subtraction).

@Accname: Yeah, it should work but it doesn't =(, the oddest thing is that I have a trigger that works the same as this, and it works perfectly fine (with the difference that it only involves one integer variable)

Here is the working one:

Trigger:
  • Comprar Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Item Araña
          • PuntosArania Less than or equal to 19
        • Then - Actions
          • Item - Remove (Item being manipulated)
          • Unit - Order (Hero manipulating item) to Stop
          • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: No tienes suficient...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Item Araña
              • PuntosArania Greater than or equal to 20
            • Then - Actions
              • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: (Has adquirido: + (Name of (Item being manipulated)))
              • Set PuntosArania = (PuntosArania - 20)
            • Else - Actions
              • Do nothing


^
And it works great! I tried buying multiple items, buying them very fast to see if could get 2 items for 1 but no, it works just fine.

Now, I wonder if there is some kind of special exception when putting 2 integer variables as conditions or something like that...

Thanks anyways, still looking for the solution xD
 

KJP

New Member
Reaction score
5
I have had it before where the code has bugged, and though the condition logic has something like

Variable X = Value Y, it has been interpretted as the opposite and will pass the condition when X is not equal to Y but block it when X=Y. Maybe you have this too.

Also as has been suggested move the item checking condition to the conditions part of the trigger and remove the second one completely.

Might also be worth swapping the blocks from the if then else statement and dropping the conditions on the else block so it is more like
Trigger:
  • Comprar Item 2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Item Troll
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PuntosArania Greater than or equal to 15
          • PuntosTroll Greater than or equal to 10
        • Then - Actions
          • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: (Has adquirido: + (Name of (Item being manipulated)))
          • Set PuntosArania = (PuntosArania - 15)
          • Set PuntosTroll = (PuntosTroll - 10)
          • Else - Actions
            • Item - Remove (Item being manipulated)
            • Unit - Order (Hero manipulating item) to Stop
            • Game - Display to (All allies of (Owner of (Hero manipulating item))) the text: No tienes suficient...


side note: try disabling the item check to see if the trigger works properly.
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Let's say you have 20 PuntosArania and 5 PuntosTroll, the first "if,then, else" is false then. (since you don't have less then or equal to 14 PuntosArania) The trigger jumps to the else part of this bit then.

There it meets another "if, then, else".

Again, it doesn't meet the conditions, (5 < 10 PuntosTroll) so it just jumps to the empty part of the second "if, then, else" bit.

KJP's solution fixes this by the way.

(I'm a bit clueless on why you decided to make the condition checks so complicated...)
 

Rassyu

New Member
Reaction score
0
@KJP
It worked! I tried your code and it works perfectly!
This will save A LOT of time in future triggers of this kind, thanks KJP!

@Sirroelivan
I made it that way following the logic of other of my triggers (which worked, but wasn't exactly the SAME kind of actions), but now I see that they can be simplified, I have a lot to learn about triggers and variables yet xD

Thanks you everyone for your help!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top