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.

What is wrong with Unit Uses an item

Discussion in 'World Editor Help Zone' started by Slaydon, Nov 12, 2009.

  1. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Okay, you can see my title, it says alot.

    When im making a trigger with actions of an item, it only runs once, and sometimes only with one item, if i had 2. and it only works with the first one, take it off, and then use it again, but it's unusable, now, is there a way to prevent this?
     
  2. Airandius

    Airandius

    Joined:
    Jun 12, 2007
    Messages:
    1,238
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    You could add a dummy spell to the item, and when that dummy spell starts do your thing?

    Don't know how to fix your problem though, perhaps you have 2 items with the same I do recall having the same problem though... I forgot what I did.
     
  3. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    i got a dummy spell, but i cant have 200 dummy spells, so i have to use Uses item, but it only works once
     
  4. Airandius

    Airandius

    Joined:
    Jun 12, 2007
    Messages:
    1,238
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    Well anyway, post your trigger. You might have made a mistake and you keep overlooking it. It happens to everybody.
     
  5. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    • Item Use
      • Events
        • Unit - A unit Uses an item
      • Conditions
      • Actions
        • For each (Integer A) from 15 to 200, 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 InvsystemItems[(Integer A)]
              • Then - Actions
                • Set Point = (Position of SlotDests[ItemSlot[(Integer A)]])
                • Destructible - Pick every destructible within 40.50 of Point and do (Actions)
                  • Loop - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Destructible-type of (Picked destructible)) Not equal to ItemDestructibles[(Integer A)]
                        • (Destructible-type of (Picked destructible)) Not equal to Background
                        • ItemUsed[ItemSlot[(Integer A)]] Equal to No destructible
                      • Then - Actions
                        • Item - Remove (Item being manipulated)
                        • Destructible - Create a ItemDestructibles[(Integer A)] at Point facing 0.00 with scale 0.75 and variation 1
                        • Set ItemUsed[ItemSlot[(Integer A)]] = (Last created destructible)
                      • Else - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Destructible-type of (Picked destructible)) Equal to ItemDestructibles[(Integer A)]
                          • Then - Actions
                            • Game - Display to (All players) the text: Slot is already in ...
                          • Else - Actions
                • Custom script: call RemoveLocation(udg_Point)
              • Else - Actions


    And the drop trigger NOt the whole
    • For each (Integer A) from 1 to 14, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 15 to 200, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • TrackBoolean2[(Integer A)] Equal to True
              • Then - Actions
                • Set Point = (Position of SlotDests[(Integer A)])
                • Destructible - Pick every destructible within 40.50 of Point and do (Actions)
                  • Loop - Actions
                    • Set Point2 = (Position of (Picked destructible))
                    • Destructible - Pick every destructible within 40.50 of Point2 and do (Actions)
                      • Loop - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • ItemDestructibles[(Integer B)] Equal to (Destructible-type of SelectedDest)
                            • TrackBoolean2[14] Equal to True
                          • Then - Actions
                            • Set TempInt = (TempInt + 1)
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • TempInt Equal to 1
                              • Then - Actions
                                • Destructible - Remove ItemUsed[ItemSlot[(Integer A)]]
                                • Destructible - Remove SelectedDest
                                • Set ItemUsed[ItemSlot[(Integer A)]] = No destructible
                                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • (Number of items carried by Paladin 0001 <gen>) Equal to 6
                                  • Then - Actions
                                    • Game - Display to (All players) the text: Your item has been ...
                                    • Set Point3 = (Position of Paladin 0001 <gen>)
                                    • Item - Create InvsystemItems[(Integer B)] at Point3
                                    • Custom script: call RemoveLocation(udg_Point3)
                                  • Else - Actions
                                    • Hero - Create InvsystemItems[(Integer B)] and give it to Paladin 0001 <gen>
                              • Else - Actions
                          • Else - Actions
                    • Custom script: call RemoveLocation(udg_Point2)
                • Custom script: call RemoveLocation(udg_Point)
              • Else - Actions
    • Set SelectedDest = No destructible
     
  6. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Slaydon,

    • For each (Integer A) from 1 to 14, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 15 to 200, do (Actions)
          • Loop - Actions

    Why?

    • Hero - Create InvsystemItems[(Integer B)] and give it to Paladin 0001 <gen>

    Avoid static values if they are no settings.

    The whole destructable pickup thing is totally awful.

    Recode it please.


    Btw, give us more information about the item data.
     
  7. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2

    Ofcourse i will clean it, and it shouldnt b Paladin 0001 in the end;P, and the loops, i dont know its the only way it works ;/

    I will do alot of recoding ;S
     
  8. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Well avoid nested loops.
    And avoid picking up anything (items, units, players) in loops, or other pickups.
     
  9. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    i will try to recode it and make it much smoother, but can we please get to the problem ;)
     
  10. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Problem is:
    Too many loops and pickups.

    Wc3 got a thread crash after an amount of nesting of big loops / enumation.
    Therefor it won't work correctly.

    Just think about it:
    One loop iterates from 1 to 14
    Another one from 15 to 200.
    That means 185 * 14 executions of every action in that loops INSTANTLY.

    I mean, can you see how 2590 enumerations are to much for wc3 to handle at the same time?
     
  11. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    yes, but if i put an condition checking the trackable Before i apply the Loop, it will only stay 14 + 186 rite?

    EDIT: Ill take your sig as an answer ;P
     
  12. Airandius

    Airandius

    Joined:
    Jun 12, 2007
    Messages:
    1,238
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    My post didn't make it? I posted before. Owel.

    What I said in my post that somehow failed;
    One of your if's that check a variable, that's where it goes wrong.

    You did not post the entire drop trigger right? Well do so, I think you are setting one of the variables to nothing rendering the first trigger unable to run.

    I'm leaning towards this one being changed in another loop in your map.
    • (Item-type of (Item being manipulated)) Equal to InvsystemItems[(Integer A)]


    EDIT: The loop is not his problem Anachron, sure it takes a lot from wc3, but it can handle it. (I do agree that it has to be rewritten though.)
     
  13. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    i didnt show the whole trigger due the other stuff is just setting the selected, and then it can be dropped :p, and i got a database of the tems, can you give me an example where i set the item?
     
  14. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Atleast 14 * 185 will be looped through, even that would mean 2590 conditional checks at the same second. Never ever do that.
     
  15. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    if it is
    • For each (Integer A) from 1 to 14, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TrackBoolean2[(Integer A)] Equal to True
          • Then - Actions
            • For each (Integer B) from 15 to 200, do (Actions)
              • Loop - Actions


    it would only run it once, since it will check 14 times, then check 200.
     
  16. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    So you fixed it?
    The first code has this in it:
    • For each (Integer A) from 1 to 14, do (Actions)
      • Loop - Actions
        • For each (Integer B) from 15 to 200, do (Actions)
          • Loop - Actions


    Edit:
    So ok, here we go:

    To fix it, create a new hashtable.
    Into that hashtable, save with the key of the TrackAble the dataset into the table.

    On TrackableEvent, you load the dataset of the table, while you use the key oft the trackable.
    Now you know which trackable has been used and also exactly know the slot that has been used.

    Also try to avoid loop whenever you can. For checking for a variable being another one or such, loading is mostly better as
    looping through the whole struct.
     
  17. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    yes, i just saw that when you pointed it out, ;P Thanks.

    But the drop and then use wont work
     
  18. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    I read a little description how you can avoid the loops and finally manage how to not crash a trigger thread.

    If that problems continues, let me know! :)
     
  19. Slaydon

    Slaydon

    Joined:
    Jan 6, 2008
    Messages:
    2,432
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    ive never used hashtables before, do you think you can help me import it?
    The triggers: Hit2 and ItemUse, use JNGP ;/
     

    Attached Files:

  20. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Can't do this before sunday. I highly suggest to read the Hashtables Tutorial from wyrmlord.