1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] For some reason it isn't working as it should

Discussion in 'Triggers & Scripts' started by Dat-C3, Jun 6, 2014.

  1. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    It's a tome-based damage system and sadly it only loops once so I am confused now and would appreciate anyone's help if possible.
    Part 1 which is the item database

    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set itemamountmax = (itemamountmax + 1)
      • Set itembase[itemamountmax] = Zweihander
      • Set itembasedmg10s[itemamountmax] = 5
      • Set itembasedmg100s[itemamountmax] = 2


    Part 2

    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
            • Then - Actions
              • For each (Integer ZITEMLOOP[1]) from 1 to itembasedmg100s[itemloop1], do (Actions)
                • Loop - Actions
                  • Hero - Create atk add 100 and give it to (Triggering unit)
              • For each (Integer ZITEMLOOP[2]) from 1 to itembasedmg10s[itemloop1], do (Actions)
                • Loop - Actions
                  • Hero - Create atk add 10 and give it to (Triggering unit)
            • Else - Actions

     
    Last edited: Jun 6, 2014
  2. Death Adder

    Death Adder

    Joined:
    Nov 3, 2013
    Messages:
    892
    Resources:
    0
    Resources:
    0
    Loops? It says elapsed not periodic

    Edit: Nvm, it might be because of the inaccuracy of the waits? try with a longer experiation timer

    Edit 2: If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
    Then - Actions
    Else - Actions
    Skip remaining actions
    Nvm saw it wrong.

    Edit: I don't even know what you're doing tbh, i think i'm just gonna get some sleep and leave this for a real pro :3
     
  3. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    As usual everyone is fixated on them waits, I use them to reset the thread limit so I don't hit it. The waits aren't the issue and they're not evil/bad.

    I did say it was a tome-based damage add system, I guess it is a little complex.

    Oh forgot to remove that, the skip there was disabled so it isn't that.

    What's wrong is that it only provides 1 of each tome/item when it should do like 0 for some or 5 for another as according to the item database. It doesn't loop within the main loop for some reason. I might switch to 0 though I don't know if that still resets it however that wasn't the problem. Hopefully this helps and every time I provide a test map people complain but the one time I didn't... lol =(

    Thanks for trying Death Adder as well GreeN!X.
     
  4. Death Adder

    Death Adder

    Joined:
    Nov 3, 2013
    Messages:
    892
    Resources:
    0
    Resources:
    0
    Does the unit acquire items only through these two triggers? Because if so then It probably has to do with it only gets one item from the first trigger which sets the max index to 1 and then the 2nd trigger never run again because you never add another item with the first one.

    I mean all that stuff after the wait won't do a thing for the 2nd trigger since it only runs when you add an item.

    Again I don't even really understand what's supposed to be going on and I might be way off.
     
  5. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    The hero acquires items normally through picking them up or well in my case buying them. What do you mean only gets one item from first trigger? The loop doesn't run more then once because of the event? The max index, which one do you mean?

    It doesn't? Why would that be? The first trigger just sets up all the values and variables.

    It is an add damage system... what don't you get or what am I doing wrong?
     
  6. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,231
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    In your
    • For each (Integer ZITEMLOOP1) from 1 to itembasedmg100s[itemloop1], do (Actions)

    You use the wrong loopIndex in the comparisson. And the result will always be the same here.

    Also the other loops inside, for example:
    • For each (Integer ZITEMLOOP[1]) from 0 to itembasedmg100s[itemloop1], do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ZITEMLOOP[1] Less than or equal to itembasedmg100s[itemloop1]
            • ZITEMLOOP[1] Not equal to 0
          • Then - Actions
            • Game - Display to (All players) the text: (String(ZITEMLOOP[1]))
            • Hero - Create atk add 100 and give it to (Triggering unit)
            • Else - Actions


    You loop from null to maxIndex. In the If/Then/Else you check if the loopIndex is not null and less or equal itembasedmg100s[itemloop1].

    You can remove both conditions I think and just start the loop with 1 and not 0. It won't loop if the itembasedmg100s[itemloop1] is 0. (or else, pls explain if you need it)

    To simplify you could remove all the "Set blah = 0" initializations. They are 0 anyway.

    Also it might work in most cases but inside the loop I think it's better to use an ItemComparisson, not an ItemType comparisson.
     
  7. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    Ignore the last four loops inside the loop, they weren't working anyways so I tried something else, yeah I know I can remove all the 0s, I just wasn't done setting stuff.

    What do you mean by using item comparison instead of item type? Only item type will work from what I know with this, thanks though IcemanBo. Still the problem of the loops not working as they should, some items should give 2-3 atk add 100's but yet they only give one. Zweihander for example is the one I have been testing with and it is meant to give 2.

    Edit: I will remove all the extra stuff so it is easier to identify the issue at hand.
     
  8. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,166
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    Assuming the triggers in the first post is up to date.

    Try instead of running the two loops within the main loop to run a second trigger with the two item creating loops.
    • Events
    • Unit - A unit Acquires an item
    • Conditions
    • Actions
    • For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
    • Then - Actions
    • Run Item Creation Trigger
    • Else - Actions


    • Item Creation Trigger
    • Actions
      • For each (Integer ZITEMLOOP[1]) from 1 to itembasedmg100s[itemloop1], do (Actions)
      • Loop - Actions
      • Hero - Create atk add 100 and give it to (Triggering unit)
      • For each (Integer ZITEMLOOP[2]) from 1 to itembasedmg10s[itemloop1], do (Actions)
      • Loop - Actions
      • Hero - Create atk add 10 and give it to (Triggering unit)
     
  9. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    Tried that, thanks though. Was a great idea, no idea why it isn't working. . .
     
  10. MepH-

    MepH-

    Joined:
    Jan 14, 2014
    Messages:
    4
    Resources:
    0
    Resources:
    0
    Does just nothing happen when you pick up items?
     
  11. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,128
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    My only suggestion here is to set initial values of 0 (somewhere in Map Init or even your item data base trigger) for ZITEMLOOP[] array components that you will use. Maybe it doesn't loop because it returns null. Try debugging ZITEMLOOP[]'s value.
     
  12. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    It only works once as in only creates one tome which basically is that it isn't working at all.
     
  13. MepH-

    MepH-

    Joined:
    Jan 14, 2014
    Messages:
    4
    Resources:
    0
    Resources:
    0
    What happens when you print the loop index each time inside the loops?

    ("itemloop1 = " + I2S(itemloop1))
    ("ZITEMLOOP[1] = " + I2S(ZITEMLOOP[1]))
    ("ZITEMLOOP[2] = " + I2S(ZITEMLOOP[2]))

    Just to ensure the correct item index and as well the loops run properly. (I2S does mean Integer converted to String)
     
  14. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    Why does this work and not the original one?

    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
            • Then - Actions
              • For each (Integer ZITEMLOOP0) from 1 to (Integer((Current life of (Item being manipulated)))), do (Actions)
                • Loop - Actions
                  • Hero - Create atk add 1 and give it to (Triggering unit)
     
  15. MepH-

    MepH-

    Joined:
    Jan 14, 2014
    Messages:
    4
    Resources:
    0
    Resources:
    0
    I don't know. Hard to say without knowing all settings...
     
  16. Dat-C3

    Dat-C3

    Joined:
    Mar 15, 2012
    Messages:
    2,476
    Resources:
    10
    Models:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    1
    Resources:
    10
    That means what exactly?